| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Http\Metricool\Traits; |
| 6 |
|
| 7 |
trait IsCountable |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Abstract method to be implemented by classes using this trait. It should |
| 11 |
* return an array of data. When {@see count()} is called, this method will |
| 12 |
* be used to retrieve the data to count. |
| 13 |
*/ |
| 14 |
abstract public function get(): array; |
| 15 |
|
| 16 |
/** |
| 17 |
* Method just returns the count of the items in the array returned by the |
| 18 |
* get() method. Operation type methods should always return an array. |
| 19 |
*/ |
| 20 |
public function count(): array |
| 21 |
{ |
| 22 |
return [ |
| 23 |
count($this->get()), |
| 24 |
]; |
| 25 |
} |
| 26 |
} |
| 27 |
|