1 | <?php |
||
15 | class Http implements Processor |
||
16 | { |
||
17 | /** |
||
18 | * Property key which should trigger the processor |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $property; |
||
22 | |||
23 | /** |
||
24 | * @var \SplObjectStorage|Promise\PromiseInterface[] |
||
25 | */ |
||
26 | protected $promises; |
||
27 | |||
28 | /** |
||
29 | * Class constructor |
||
30 | * |
||
31 | * @param DataEnricher $invoker |
||
32 | * @param string $property Property key with the processing instruction |
||
33 | */ |
||
34 | public function __construct(DataEnricher $invoker, $property) |
||
35 | { |
||
36 | $this->property = $property; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Get the property key that holds the processing instruction |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | public function getProperty() |
||
45 | { |
||
46 | return $this->property; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Prepare processing to nodes |
||
51 | * |
||
52 | * @param Node[] $nodes |
||
53 | */ |
||
54 | public function prepare(array $nodes) |
||
55 | { |
||
56 | $this->promises = $this->request($nodes); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Do async requests for each node |
||
61 | * |
||
62 | * @param Node[] $nodes |
||
63 | * @return \SplObjectStorage|Promise\PromiseInterface[] |
||
64 | */ |
||
65 | protected function request($nodes) |
||
79 | |||
80 | /** |
||
81 | * Apply results to a node |
||
82 | * |
||
83 | * @param Node $node |
||
84 | */ |
||
85 | public function applyToNode(Node $node) |
||
105 | |||
106 | /** |
||
107 | * Check if we got an expected response |
||
108 | * |
||
109 | * @param Response $response |
||
110 | * @return boolean |
||
111 | */ |
||
112 | protected function hasExpectedResponse(Response $response) |
||
132 | } |
||
133 |
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.