Conditions | 16 |
Paths | 17 |
Total Lines | 38 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
97 | private function run_json_path(string $path):void |
||
98 | { |
||
99 | $this->buffer =& $this->data; |
||
100 | unset($this->pool); |
||
101 | $this->pool = null; |
||
102 | $this->poolKey = null; |
||
103 | $steps = explode('.', $path); |
||
104 | foreach ($steps as $loopIndex => $step) { |
||
105 | switch ($step) { |
||
106 | case '$': |
||
107 | case '': |
||
108 | continue; |
||
109 | default: |
||
110 | if ($this->exact_match(self::FIELD_REGEX, $step)) { |
||
111 | if ($this->pool == null) { |
||
112 | $this->buffer =& $this->buffer[$step]; |
||
113 | } else { |
||
114 | $this->poolKey = $step; |
||
115 | } |
||
116 | if ($loopIndex == count($steps) - 1) { break; } else { continue; } |
||
117 | } |
||
118 | if (preg_match(self::ARRAY_REGEX, $step)) { |
||
119 | if (preg_match(self::SPECIFIC_ARRAY_REGEX, $step)) { |
||
120 | list($key, $index) = $this->parse_specific_array_notation($step); |
||
121 | if ($this->pool == null) { |
||
122 | $this->buffer =& $this->buffer[$key][$index]; |
||
123 | } else { |
||
124 | $this->poolKey = [$key, $index]; |
||
125 | } |
||
126 | if ($loopIndex == count($steps) - 1) { break; } else { continue; } |
||
127 | } |
||
128 | if ($step == '[*]' || $step == '*') { |
||
129 | $this->pool =& $this->buffer[$this->get_key_from_notation($step)]; |
||
130 | if ($loopIndex == count($steps) - 1) { break; } else { continue; } |
||
131 | } |
||
132 | if (preg_match(self::ALL_ARRAY_REGEX, $step)) { |
||
133 | $this->pool =& $this->buffer[$this->get_key_from_notation($step)]; |
||
134 | if ($loopIndex == count($steps) - 1) { break; } else { continue; } |
||
135 | } |
||
175 |