Location
1 day ago
Script
1 day ago
Assets.php
1 day ago
Enqueueable.php
1 day ago
Enqueueables.php
1 day ago
Location.php
1 day ago
Script.php
1 day ago
Style.php
1 day ago
Assets.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Asset; |
| 6 | |
| 7 | use AC\Collection; |
| 8 | |
| 9 | class Assets extends Collection |
| 10 | { |
| 11 | public function __construct(array $enqueueables = []) |
| 12 | { |
| 13 | array_map([$this, 'add'], $enqueueables); |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * @return Enqueueable[] |
| 18 | */ |
| 19 | public function all(): array |
| 20 | { |
| 21 | return $this->data; |
| 22 | } |
| 23 | |
| 24 | public function add(Enqueueable $enqueueable): self |
| 25 | { |
| 26 | $this->data[] = $enqueueable; |
| 27 | |
| 28 | return $this; |
| 29 | } |
| 30 | |
| 31 | public function current(): Enqueueable |
| 32 | { |
| 33 | return current($this->data); |
| 34 | } |
| 35 | |
| 36 | public function add_collection(Assets $assets) |
| 37 | { |
| 38 | array_map([$this, 'add'], $assets->all()); |
| 39 | } |
| 40 | |
| 41 | } |
| 42 |