| Conditions | 20 |
| Paths | 8448 |
| Total Lines | 58 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 8 | public function assignFrame(array &$frame) |
||
| 9 | { |
||
| 10 | $this->trace = array( |
||
| 11 | 'function' => isset($frame['function']) ? $frame['function'] : null, |
||
| 12 | 'line' => isset($frame['line']) ? $frame['line'] : null, |
||
| 13 | 'file' => isset($frame['file']) ? $frame['file'] : null, |
||
| 14 | 'class' => isset($frame['class']) ? $frame['class'] : null, |
||
| 15 | 'type' => isset($frame['type']) ? $frame['type'] : null, |
||
| 16 | 'object' => null, |
||
| 17 | 'args' => null, |
||
| 18 | ); |
||
| 19 | |||
| 20 | if ($this->trace['class'] && method_exists($this->trace['class'], $this->trace['function'])) { |
||
| 21 | $func = new ReflectionMethod($this->trace['class'], $this->trace['function']); |
||
| 22 | $this->trace['function'] = new Kint_Object_Method($func); |
||
| 23 | } elseif (!$this->trace['class'] && function_exists($this->trace['function'])) { |
||
| 24 | $func = new ReflectionFunction($this->trace['function']); |
||
| 25 | $this->trace['function'] = new Kint_Object_Method($func); |
||
| 26 | } |
||
| 27 | |||
| 28 | foreach ($this->value->contents as $frame_prop) { |
||
| 29 | if ($frame_prop->name === 'object') { |
||
| 30 | $this->trace['object'] = $frame_prop; |
||
| 31 | $this->trace['object']->name = null; |
||
| 32 | $this->trace['object']->operator = Kint_Object::OPERATOR_NONE; |
||
| 33 | } |
||
| 34 | if ($frame_prop->name === 'args') { |
||
| 35 | $this->trace['args'] = $frame_prop->value->contents; |
||
| 36 | |||
| 37 | if (is_object($this->trace['function'])) { |
||
| 38 | foreach (array_values($this->trace['function']->parameters) as $param) { |
||
| 39 | if (isset($this->trace['args'][$param->position])) { |
||
| 40 | $this->trace['args'][$param->position]->name = $param->getName(); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->clearRepresentations(); |
||
| 48 | |||
| 49 | if (isset($this->trace['file'], $this->trace['line']) && is_readable($this->trace['file'])) { |
||
| 50 | $this->addRepresentation(new Kint_Object_Representation_Source($this->trace['file'], $this->trace['line'])); |
||
| 51 | } |
||
| 52 | |||
| 53 | if ($this->trace['args']) { |
||
| 54 | $args = new Kint_Object_Representation('Arguments'); |
||
| 55 | $args->contents = $this->trace['args']; |
||
| 56 | $this->addRepresentation($args); |
||
| 57 | } |
||
| 58 | |||
| 59 | if ($this->trace['object']) { |
||
| 60 | $callee = new Kint_Object_Representation('object'); |
||
| 61 | $callee->label = 'Callee object ['.$this->trace['object']->classname.']'; |
||
| 62 | $callee->contents[] = $this->trace['object']; |
||
| 63 | $this->addRepresentation($callee); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 |