PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / app / Http / Metricool / Traits / IsSummable.php

IsSummable.php in Metricool – Social media and site statistics 2.1.1, at app/Http/Metricool/Traits/IsSummable.php

28 lines 707 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Metricool\Http\Metricool\Traits;
6
7 trait IsSummable
8 {
9 /**
10 * Abstract method to be implemented by classes using this trait. It should
11 * return an array of data. When {@see sum()} is called, this method will
12 * be used to retrieve the data to sum.
13 */
14 abstract public function get(): array;
15
16 /**
17 * Method just returns the sum of the items in the array returned by the
18 * get() method. Operation type methods should always return an array.
19 */
20 public function sum(): array
21 {
22 $numericValues = array_filter($this->get(), 'is_numeric');
23 return [
24 array_sum($numericValues),
25 ];
26 }
27 }
28