@@ 13-34 (lines=22) @@ | ||
10 | * Process JMESPath compatible expression |
|
11 | * @see http://jmespath.org/ |
|
12 | */ |
|
13 | class Evaluate implements Processor |
|
14 | { |
|
15 | use Processor\Implementation, |
|
16 | Helper\GetByReference |
|
17 | { |
|
18 | Helper\GetByReference::withSourceAndTarget insteadof Processor\Implementation; |
|
19 | } |
|
20 | ||
21 | /** |
|
22 | * Apply processing to a single node |
|
23 | * |
|
24 | * @param Node $node |
|
25 | */ |
|
26 | public function applyToNode(Node $node) |
|
27 | { |
|
28 | $instruction = $node->getInstruction($this); |
|
29 | ||
30 | $result = jmespath_search($instruction, $this->source); |
|
31 | ||
32 | $node->setResult($result); |
|
33 | } |
|
34 | } |
|
35 |
@@ 12-32 (lines=21) @@ | ||
9 | * Reference JMESPath processor |
|
10 | * @see http://jmespath.org/ |
|
11 | */ |
|
12 | class Reference implements Processor |
|
13 | { |
|
14 | use Processor\Implementation, |
|
15 | Helper\GetByReference |
|
16 | { |
|
17 | Helper\GetByReference::withSourceAndTarget insteadof Processor\Implementation; |
|
18 | } |
|
19 | ||
20 | /** |
|
21 | * Apply processing to a single node |
|
22 | * |
|
23 | * @param Node $node |
|
24 | */ |
|
25 | public function applyToNode(Node $node) |
|
26 | { |
|
27 | $ref = $node->getInstruction($this); |
|
28 | ||
29 | $result = $this->getByReference($ref, $this->source, $this->target); |
|
30 | $node->setResult($result); |
|
31 | } |
|
32 | } |
|
33 |