PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.1
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / league / container / src / Inflector / InflectorAggregate.php

InflectorAggregate.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.1, at vendor/league/container/src/Inflector/InflectorAggregate.php

45 lines 1004 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 Imagify\Dependencies\League\Container\Inflector;
6
7 use Generator;
8 use Imagify\Dependencies\League\Container\ContainerAwareTrait;
9
10 class InflectorAggregate implements InflectorAggregateInterface
11 {
12 use ContainerAwareTrait;
13
14 /**
15 * @var Inflector[]
16 */
17 protected $inflectors = [];
18
19 public function add(string $type, ?callable $callback = null): Inflector
20 {
21 $inflector = new Inflector($type, $callback);
22 $this->inflectors[] = $inflector;
23 return $inflector;
24 }
25
26 public function inflect($object)
27 {
28 foreach ($this->getIterator() as $inflector) {
29 $type = $inflector->getType();
30
31 if ($object instanceof $type) {
32 $inflector->setContainer($this->getContainer());
33 $inflector->inflect($object);
34 }
35 }
36
37 return $object;
38 }
39
40 public function getIterator(): Generator
41 {
42 yield from $this->inflectors;
43 }
44 }
45