| Conditions | 17 |
| Paths | 21 |
| Total Lines | 38 |
| Code Lines | 26 |
| 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 |
||
| 118 | public static function getPHPExecutable() { |
||
| 119 | if (defined ( 'PHP_BINARY' ) && PHP_BINARY && in_array ( PHP_SAPI, array ('cli','cli-server' ) ) && is_file ( PHP_BINARY )) { |
||
| 120 | return PHP_BINARY; |
||
| 121 | } else if (strtoupper ( substr ( PHP_OS, 0, 3 ) ) === 'WIN') { |
||
| 122 | $paths = explode ( PATH_SEPARATOR, getenv ( 'PATH' ) ); |
||
| 123 | foreach ( $paths as $path ) { |
||
| 124 | if (substr ( $path, strlen ( $path ) - 1 ) == \DS) { |
||
| 125 | $path = substr ( $path, 0, strlen ( $path ) - 1 ); |
||
| 126 | } |
||
| 127 | if (substr ( $path, strlen ( $path ) - strlen ( 'php' ) ) == 'php') { |
||
| 128 | $response = $path . \DS . 'php.exe'; |
||
| 129 | if (is_file ( $response )) { |
||
| 130 | return $response; |
||
| 131 | } |
||
| 132 | } else if (substr ( $path, strlen ( $path ) - strlen ( 'php.exe' ) ) == 'php.exe') { |
||
| 133 | if (is_file ( $response )) { |
||
| 134 | return $response; |
||
| 135 | } |
||
| 136 | } |
||
| 137 | } |
||
| 138 | } else { |
||
| 139 | $paths = explode ( PATH_SEPARATOR, getenv ( 'PATH' ) ); |
||
| 140 | foreach ( $paths as $path ) { |
||
| 141 | if (substr ( $path, strlen ( $path ) - 1 ) == \DS) { |
||
| 142 | $path = substr ( $path, strlen ( $path ) - 1 ); |
||
| 143 | } |
||
| 144 | if (substr ( $path, strlen ( $path ) - strlen ( 'php' ) ) == 'php') { |
||
| 145 | if (is_file ( $path )) { |
||
| 146 | return $path; |
||
| 147 | } |
||
| 148 | $response = $path . \DS . 'php'; |
||
| 149 | if (is_file ( $response )) { |
||
| 150 | return $response; |
||
| 151 | } |
||
| 152 | } |
||
| 153 | } |
||
| 154 | } |
||
| 155 | return null; |
||
| 156 | } |
||
| 158 |