auraphp /
Aura.Marshal
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * |
||
| 4 | * This file is part of the Aura project for PHP. |
||
| 5 | * |
||
| 6 | * @package Aura.Marshal |
||
| 7 | * |
||
| 8 | * @license https://opensource.org/licenses/mit-license.php MIT |
||
| 9 | * |
||
| 10 | */ |
||
| 11 | namespace Aura\Marshal\Collection; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * |
||
| 15 | * Creates a new collection object for a type. |
||
| 16 | * |
||
| 17 | * @package Aura.Marshal |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | class Builder implements BuilderInterface |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * |
||
| 24 | * The class to use for new instances. |
||
| 25 | * |
||
| 26 | * @var class-string<GenericCollection> |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 27 | * |
||
| 28 | */ |
||
| 29 | protected $class = 'Aura\Marshal\Collection\GenericCollection'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * |
||
| 33 | * Creates a new collection object. |
||
| 34 | * |
||
| 35 | * @param array<int|string, mixed> $data Data to load into the collection. |
||
| 36 | * |
||
| 37 | * @return GenericCollection |
||
| 38 | * |
||
| 39 | */ |
||
| 40 | public function newInstance(array $data) |
||
| 41 | { |
||
| 42 | $class = $this->class; |
||
| 43 | return new $class($data); |
||
| 44 | } |
||
| 45 | } |
||
| 46 |