| Conditions | 10 |
| Paths | 11 |
| Total Lines | 21 |
| Code Lines | 15 |
| 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 |
||
| 35 | public function build(&$parent = null) |
||
| 36 | { |
||
| 37 | if ($this->getParent() instanceof NodeRoot && is_null($this->value)) { |
||
| 38 | $this->getParent()->getYamlObject()->addTag($this->_tag); |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | $value = $this->value; |
||
| 42 | if (is_null($parent) && isOneOf($value, ['NodeItem', 'NodeKey'])) { |
||
|
|
|||
| 43 | $value = new NodeList($value); |
||
| 44 | } |
||
| 45 | if (TagFactory::isKnown($this->_tag)) { |
||
| 46 | if ($value instanceof NodeLiterals) { |
||
| 47 | $value = $value->value; |
||
| 48 | } |
||
| 49 | $built = TagFactory::transform($this->_tag, $value); |
||
| 50 | if ($built instanceof Node || $built instanceof NodeList) { |
||
| 51 | return $built->build($parent); |
||
| 52 | } |
||
| 53 | return $built; |
||
| 54 | } else { |
||
| 55 | return new Tag($this->_tag, is_null($value) ? null : $value->build($parent)); |
||
| 56 | } |
||
| 58 | } |