1 | <?php |
||
11 | class DataEnricher |
||
12 | { |
||
13 | /** |
||
14 | * Default processors |
||
15 | * @var array |
||
16 | */ |
||
17 | public static $defaultProcessors = [ |
||
18 | '<ifset>' => Processor\IfSet::class, |
||
19 | '<ref>' => Processor\Reference::class, |
||
20 | '<switch>' => Processor\SwitchChoose::class, |
||
21 | '<src>' => Processor\Http::class, |
||
22 | '<merge>' => Processor\Merge::class, |
||
23 | '<jmespath>' => Processor\JmesPath::class, |
||
24 | '<tpl>' => Processor\Mustache::class, |
||
25 | '<transformation>' => Processor\Transform::class, |
||
26 | |||
27 | // Deprecated |
||
28 | '_ref' => Processor\Reference::class, |
||
29 | '_switch' => Processor\SwitchChoose::class, |
||
30 | '_src' => Processor\Http::class, |
||
31 | '_merge' => Processor\Merge::class, |
||
32 | '_jmespath' => Processor\JmesPath::class, |
||
33 | '_tpl' => Processor\Mustache::class, |
||
34 | '_transformation' => Processor\Transform::class |
||
35 | ]; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @var object |
||
40 | */ |
||
41 | protected $source; |
||
42 | |||
43 | /** |
||
44 | * Processors, applied in specified order. |
||
45 | * |
||
46 | * @var DataEnricher\Processor[] |
||
47 | */ |
||
48 | public $processors; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Class constructor |
||
53 | * |
||
54 | * @param object $source Data source |
||
55 | */ |
||
56 | public function __construct($source) |
||
73 | |||
74 | /** |
||
75 | * Get the source object |
||
76 | * |
||
77 | * @return object |
||
78 | */ |
||
79 | public function getSource() |
||
83 | |||
84 | |||
85 | /** |
||
86 | * Invoke enricher |
||
87 | * |
||
88 | * @param array|object|string $target Target or dot key path |
||
89 | */ |
||
90 | public function applyTo($target) |
||
112 | |||
113 | /** |
||
114 | * Find nodes that have processing instructions |
||
115 | * |
||
116 | * @param array|object $target |
||
117 | * @return array |
||
118 | */ |
||
119 | public function findNodes(&$target) |
||
136 | |||
137 | /** |
||
138 | * Check if object has at leas one process property |
||
139 | * |
||
140 | * @param \stdClass $value |
||
141 | * @return boolean |
||
142 | */ |
||
143 | protected function hasProcessorProperty($value) |
||
153 | |||
154 | /** |
||
155 | * Replace nodes with their results |
||
156 | * |
||
157 | * @param array|object $target |
||
158 | */ |
||
159 | public function applyNodeResults(&$target) |
||
169 | |||
170 | /** |
||
171 | * Enrich object |
||
172 | * |
||
173 | * @param object $subject |
||
174 | */ |
||
175 | public static function process($subject) |
||
180 | } |
||
181 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.