| Conditions | 31 | 
| Paths | 16 | 
| Total Lines | 67 | 
| 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  | 
            ||
| 59 | public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): string  | 
            ||
| 60 |     { | 
            ||
| 61 |         if ($input instanceof CommentedItem) { | 
            ||
| 62 | //$comment = $input->getComment();  | 
            ||
| 63 | $output = '# '.$input->getComment()."\n";  | 
            ||
| 64 | $input = $input->getItem();  | 
            ||
| 65 |         } else { | 
            ||
| 66 | //$comment = null;  | 
            ||
| 67 | $output = '';  | 
            ||
| 68 | |||
| 69 | }  | 
            ||
| 70 | |||
| 71 | // $output = '';  | 
            ||
| 72 |         $prefix = $indent ? str_repeat(' ', $indent) : ''; | 
            ||
| 73 | $dumpObjectAsInlineMap = true;  | 
            ||
| 74 | |||
| 75 |         if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { | 
            ||
| 76 | $dumpObjectAsInlineMap = empty((array) $input);  | 
            ||
| 77 | }  | 
            ||
| 78 | |||
| 79 |         if ($inline <= 0 || (!\is_array($input) && $dumpObjectAsInlineMap) || empty($input)) { | 
            ||
| 80 | $output .= $prefix.Inline::dump($input, $flags);  | 
            ||
| 81 |         } else { | 
            ||
| 82 | $dumpAsMap = Inline::isHash($input);  | 
            ||
| 83 | |||
| 84 |             foreach ($input as $key => $value) { | 
            ||
| 85 |                 if ($value instanceof CommentedItem) { | 
            ||
| 86 | $comment = $value->getComment();  | 
            ||
| 87 | $value = $value->getItem();  | 
            ||
| 88 |                 } else { | 
            ||
| 89 | $comment = null;  | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 |                 if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) { | 
            ||
| 93 | // If the first line starts with a space character, the spec requires a blockIndicationIndicator  | 
            ||
| 94 | // http://www.yaml.org/spec/1.2/spec.html#id2793979  | 
            ||
| 95 |                     $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; | 
            ||
| 96 |                     $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); | 
            ||
| 97 | |||
| 98 |                     foreach (preg_split('/\n|\r\n/', $value) as $row) { | 
            ||
| 99 |                         $output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row); | 
            ||
| 100 | }  | 
            ||
| 101 | |||
| 102 | continue;  | 
            ||
| 103 | }  | 
            ||
| 104 | |||
| 105 | $dumpObjectAsInlineMap = true;  | 
            ||
| 106 | |||
| 107 |                 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { | 
            ||
| 108 | $dumpObjectAsInlineMap = empty((array) $value);  | 
            ||
| 109 | }  | 
            ||
| 110 | |||
| 111 | $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value);  | 
            ||
| 112 | |||
| 113 |                 if ($comment) { | 
            ||
| 114 |                     $output .= sprintf("%s# %s\n", $prefix, $comment); | 
            ||
| 115 | }  | 
            ||
| 116 |                 $output .= sprintf('%s%s%s%s', | 
            ||
| 117 | $prefix,  | 
            ||
| 118 | $dumpAsMap ? Inline::dump($key, $flags).':' : '-',  | 
            ||
| 119 | $willBeInlined ? ' ' : "\n",  | 
            ||
| 120 | $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags)  | 
            ||
| 121 | ).($willBeInlined ? "\n" : '');  | 
            ||
| 122 | }  | 
            ||
| 123 | }  | 
            ||
| 124 | |||
| 125 | return $output;  | 
            ||
| 126 | }  | 
            ||
| 128 |