| Total Complexity | 2 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | final class AggregatorCollection extends Collection |
||
| 26 | { |
||
| 27 | use SerializesAndRestoresModelIdentifiers; |
||
|
|
|||
| 28 | |||
| 29 | /** |
||
| 30 | * The class name of the aggregator. |
||
| 31 | * |
||
| 32 | * @var string|null |
||
| 33 | */ |
||
| 34 | public $aggregator; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Prepare the instance for serialization. |
||
| 38 | * |
||
| 39 | * @return array []string |
||
| 40 | */ |
||
| 41 | 1 | public function __sleep() |
|
| 42 | { |
||
| 43 | 1 | $this->aggregator = get_class($this->first()); |
|
| 44 | |||
| 45 | $this->items = $this->getSerializedPropertyValue(EloquentCollection::make($this->map(function ($aggregator) { |
||
| 46 | 1 | return $aggregator->getModel(); |
|
| 47 | 1 | }))); |
|
| 48 | |||
| 49 | 1 | return ['aggregator', 'items']; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Restore the model after serialization. |
||
| 54 | * |
||
| 55 | * @return void |
||
| 56 | */ |
||
| 57 | 1 | public function __wakeup() |
|
| 62 | 1 | } |
|
| 63 | } |
||
| 64 |