| Conditions | 1 |
| Paths | 1 |
| Total Lines | 62 |
| 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 // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
||
| 75 | public function provideRunCommand() { |
||
| 76 | $tmp = sys_get_temp_dir(); |
||
| 77 | |||
| 78 | return array( |
||
| 79 | 'true' => array( |
||
| 80 | 'true', |
||
| 81 | array(), |
||
| 82 | 0, |
||
| 83 | '', |
||
| 84 | '', |
||
| 85 | " RUN '{SHELL}' '-c' 'true'\n\n", |
||
| 86 | ), |
||
| 87 | 'false' => array( |
||
| 88 | 'false', |
||
| 89 | array(), |
||
| 90 | 1, |
||
| 91 | '', |
||
| 92 | '', |
||
| 93 | " RUN '{SHELL}' '-c' 'false'\n\n", |
||
| 94 | ), |
||
| 95 | 'true, non-debug verbosity' => array( |
||
| 96 | 'true', |
||
| 97 | array(), |
||
| 98 | 0, |
||
| 99 | '', |
||
| 100 | '', |
||
| 101 | '', |
||
| 102 | BufferedOutput::VERBOSITY_VERY_VERBOSE, |
||
| 103 | ), |
||
| 104 | 'With cwd' => array( |
||
| 105 | 'pwd', |
||
| 106 | array( |
||
| 107 | 'cwd' => $tmp, |
||
| 108 | ), |
||
| 109 | 0, |
||
| 110 | "$tmp\n", |
||
| 111 | '', |
||
| 112 | " RUN '{SHELL}' '-c' 'pwd'\n\n OUT $tmp\n OUT \n", |
||
| 113 | ), |
||
| 114 | 'With env' => array( |
||
| 115 | 'echo "$FOO" >&2', |
||
| 116 | array( |
||
| 117 | 'env' => array( 'FOO' => 'FOOBAR' ), |
||
| 118 | ), |
||
| 119 | 0, |
||
| 120 | '', |
||
| 121 | "FOOBAR\n", |
||
| 122 | " RUN '{SHELL}' '-c' 'echo \"\$FOO\" >&2'\n\n ERR FOOBAR\n ERR \n", |
||
| 123 | ), |
||
| 124 | 'With input' => array( |
||
| 125 | 'while IFS= read X; do echo "{{$X}}"; done', |
||
| 126 | array( |
||
| 127 | 'input' => "A\nB\nC\n", |
||
| 128 | ), |
||
| 129 | 0, |
||
| 130 | "{{A}}\n{{B}}\n{{C}}\n", |
||
| 131 | '', |
||
| 132 | '', |
||
| 133 | BufferedOutput::VERBOSITY_NORMAL, |
||
| 134 | ), |
||
| 135 | ); |
||
| 136 | } |
||
| 137 | |||
| 155 |