PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.2
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.2
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 / classes / Dependencies / League / Container / Inflector / InflectorAggregate.php

InflectorAggregate.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.2, at classes/Dependencies/League/Container/Inflector/InflectorAggregate.php

59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace Imagify\Dependencies\League\Container\Inflector;
4
5 use Generator;
6 use Imagify\Dependencies\League\Container\ContainerAwareTrait;
7
8 class InflectorAggregate implements InflectorAggregateInterface
9 {
10 use ContainerAwareTrait;
11
12 /**
13 * @var Inflector[]
14 */
15 protected $inflectors = [];
16
17 /**
18 * {@inheritdoc}
19 */
20 public function add(string $type, callable $callback = null) : Inflector
21 {
22 $inflector = new Inflector($type, $callback);
23 $this->inflectors[] = $inflector;
24
25 return $inflector;
26 }
27
28 /**
29 * {@inheritdoc}
30 */
31 public function getIterator() : Generator
32 {
33 $count = count($this->inflectors);
34
35 for ($i = 0; $i < $count; $i++) {
36 yield $this->inflectors[$i];
37 }
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 public function inflect($object)
44 {
45 foreach ($this->getIterator() as $inflector) {
46 $type = $inflector->getType();
47
48 if (! $object instanceof $type) {
49 continue;
50 }
51
52 $inflector->setLeagueContainer($this->getLeagueContainer());
53 $inflector->inflect($object);
54 }
55
56 return $object;
57 }
58 }
59