@@ 33-49 (lines=17) @@ | ||
30 | /** |
|
31 | * @inheritdoc |
|
32 | */ |
|
33 | public function matchOnInt() |
|
34 | { |
|
35 | if (!\is_int($this->operand)) { |
|
36 | $msg = 'Non-integer passed to: ' . __FUNCTION__ . '()'; |
|
37 | throw new JSONTextInvalidArgsException($msg); |
|
38 | } |
|
39 | ||
40 | $expr = '$.[' . $this->operand . ']'; |
|
41 | $fetch = $this->jsonText->getJSONStore()->get($expr); |
|
42 | $vals = \array_values($fetch); |
|
43 | ||
44 | if (isset($vals[0])) { |
|
45 | return [$this->operand => $vals[0]]; |
|
46 | } |
|
47 | ||
48 | return []; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @inheritdoc |
|
@@ 54-70 (lines=17) @@ | ||
51 | /** |
|
52 | * @inheritdoc |
|
53 | */ |
|
54 | public function matchOnStr() |
|
55 | { |
|
56 | if (!\is_string($this->operand)) { |
|
57 | $msg = 'Non-string passed to: ' . __FUNCTION__ . '()'; |
|
58 | throw new JSONTextInvalidArgsException($msg); |
|
59 | } |
|
60 | ||
61 | $expr = '$..' . $this->operand; |
|
62 | $fetch = $this->jsonText->getJSONStore()->get($expr); |
|
63 | $vals = \array_values($fetch); |
|
64 | ||
65 | if (isset($vals[0])) { |
|
66 | return [$this->operand => $vals[0]]; |
|
67 | } |
|
68 | ||
69 | return []; |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * @inheritdoc |