1 | <?php declare(strict_types=1); |
||
9 | class Inflector implements ArgumentResolverInterface |
||
10 | { |
||
11 | use ArgumentResolverTrait; |
||
12 | use ContainerAwareTrait; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $type; |
||
18 | |||
19 | /** |
||
20 | * @var callable |
||
21 | */ |
||
22 | protected $callback; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $methods = []; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | 6 | */ |
|
32 | protected $properties = []; |
||
33 | 6 | ||
34 | /** |
||
35 | 6 | * Construct. |
|
36 | * |
||
37 | * @param string $type |
||
38 | * @param callable|null $callback |
||
39 | */ |
||
40 | public function __construct(string $type, callable $callback = null) |
||
45 | |||
46 | 3 | /** |
|
47 | 3 | * Get the type. |
|
48 | 2 | * |
|
49 | * @return string |
||
50 | 3 | */ |
|
51 | public function getType(): string |
||
55 | |||
56 | /** |
||
57 | * Defines a method to be invoked on the subject object. |
||
58 | * |
||
59 | * @param string $name |
||
60 | 9 | * @param array $args |
|
61 | * |
||
62 | 9 | * @return self |
|
63 | */ |
||
64 | 9 | public function invokeMethod(string $name, array $args): self |
|
70 | |||
71 | /** |
||
72 | * Defines multiple methods to be invoked on the subject object. |
||
73 | 3 | * |
|
74 | * @param array $methods |
||
75 | 3 | * |
|
76 | 3 | * @return self |
|
77 | 2 | */ |
|
78 | public function invokeMethods(array $methods): self |
||
86 | |||
87 | /** |
||
88 | 9 | * Defines a property to be set on the subject object. |
|
89 | * |
||
90 | 9 | * @param string $property |
|
91 | 9 | * @param mixed $value |
|
92 | * |
||
93 | 9 | * @return self |
|
94 | 6 | */ |
|
95 | 6 | public function setProperty(string $property, $value): self |
|
101 | 6 | ||
102 | 9 | /** |
|
103 | * Defines multiple properties to be set on the subject object. |
||
104 | * |
||
105 | * @param array $properties |
||
106 | * |
||
107 | * @return self |
||
108 | */ |
||
109 | public function setProperties(array $properties): self |
||
117 | |||
118 | /** |
||
119 | * Apply inflections to an object. |
||
120 | * |
||
121 | * @param object $object |
||
122 | * |
||
123 | * @return void |
||
124 | */ |
||
125 | public function inflect($object) |
||
144 | } |
||
145 |