PHPackages                             outcloud/php-array-avg-callable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. outcloud/php-array-avg-callable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

outcloud/php-array-avg-callable
===============================

Calculates average of elements of array given by callable function

1.0.0(8y ago)014MITPHP &gt;=7.0

Since Nov 13Compare

[ Source](https://github.com/OutCloud/php_array_avg_callable)[ Packagist](https://packagist.org/packages/outcloud/php-array-avg-callable)[ RSS](/packages/outcloud-php-array-avg-callable/feed)WikiDiscussions Synced 2w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

php\_array\_avg\_callable
=========================

[](#php_array_avg_callable)

Calculates average value from array of objects/numbets via callable function

Example usage:
==============

[](#example-usage)

Let's assume we have any object of any class with some numeric value inside. We have an array of that objects, and we have to calculate a average of those numeric values.

Let's this be our class

```
class Num{
    private $value;

    public function __construct(int $number){
        $this->value = $number;
    }
    public function getValue(){
        return $this->value;
    }
}
```

we have array of items of 'Num' class

```
$items = [
    new Num(1),
    new Num(2),
    new Num(3),
];
```

Let's use array\_avg\_callable to calculate avg of that numbers

```
array_avg_callable($items, function($item){
    return $item->getValue();
});
```

Result will of course be: 2

#### Return Values

[](#return-values)

Returns the avg of values as an integer or float; an exception will be thrown if array is empty

Installation
============

[](#installation)

via Composer:

```
composer require outcloud/php-array-avg-callable
```

function will be registered in global namespace.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3197d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/178027883?v=4)[Macintoshx](/maintainers/Macintoshx)[@MacintoshX](https://github.com/MacintoshX)

---

Top Contributors

[![glieske](https://avatars.githubusercontent.com/u/7852170?v=4)](https://github.com/glieske "glieske (4 commits)")

### Embed Badge

![Health badge](/badges/outcloud-php-array-avg-callable/health.svg)

```
[![Health](https://phpackages.com/badges/outcloud-php-array-avg-callable/health.svg)](https://phpackages.com/packages/outcloud-php-array-avg-callable)
```

###  Alternatives

[yannisme/oxotheme

OXO Theme For Flarum

3611.0k](/packages/yannisme-oxotheme)[x-wp/di

The dependency injection container for WordPress

314.6k16](/packages/x-wp-di)[kayon-ariel/pix-php

Library to generate Static PIX codes in PHP

201.3k](/packages/kayon-ariel-pix-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
