| Conditions | 25 |
| Paths | 27 |
| Total Lines | 64 |
| Code Lines | 42 |
| 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 |
||
| 114 | public function compile($otherOperator) |
||
| 115 | { |
||
| 116 | if (\strpos($this->version, 'dev-') === 0) { |
||
| 117 | if (self::OP_EQ === $this->operator) { |
||
| 118 | if (self::OP_EQ === $otherOperator) { |
||
| 119 | return \sprintf('$b && $v === %s', \var_export($this->version, \true)); |
||
| 120 | } |
||
| 121 | if (self::OP_NE === $otherOperator) { |
||
| 122 | return \sprintf('!$b || $v !== %s', \var_export($this->version, \true)); |
||
| 123 | } |
||
| 124 | return 'false'; |
||
| 125 | } |
||
| 126 | if (self::OP_NE === $this->operator) { |
||
| 127 | if (self::OP_EQ === $otherOperator) { |
||
| 128 | return \sprintf('!$b || $v !== %s', \var_export($this->version, \true)); |
||
| 129 | } |
||
| 130 | if (self::OP_NE === $otherOperator) { |
||
| 131 | return 'true'; |
||
| 132 | } |
||
| 133 | return '!$b'; |
||
| 134 | } |
||
| 135 | return 'false'; |
||
| 136 | } |
||
| 137 | if (self::OP_EQ === $this->operator) { |
||
| 138 | if (self::OP_EQ === $otherOperator) { |
||
| 139 | return \sprintf('\\version_compare($v, %s, \'==\')', \var_export($this->version, \true)); |
||
| 140 | } |
||
| 141 | if (self::OP_NE === $otherOperator) { |
||
| 142 | return \sprintf('$b || \\version_compare($v, %s, \'!=\')', \var_export($this->version, \true)); |
||
| 143 | } |
||
| 144 | return \sprintf('!$b && \\version_compare(%s, $v, \'%s\')', \var_export($this->version, \true), self::$transOpInt[$otherOperator]); |
||
| 145 | } |
||
| 146 | if (self::OP_NE === $this->operator) { |
||
| 147 | if (self::OP_EQ === $otherOperator) { |
||
| 148 | return \sprintf('$b || (!$b && \\version_compare($v, %s, \'!=\'))', \var_export($this->version, \true)); |
||
| 149 | } |
||
| 150 | if (self::OP_NE === $otherOperator) { |
||
| 151 | return 'true'; |
||
| 152 | } |
||
| 153 | return '!$b'; |
||
| 154 | } |
||
| 155 | if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) { |
||
| 156 | if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) { |
||
| 157 | return '!$b'; |
||
| 158 | } |
||
| 159 | } else { |
||
| 160 | if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) { |
||
| 161 | return '!$b'; |
||
| 162 | } |
||
| 163 | } |
||
| 164 | if (self::OP_NE === $otherOperator) { |
||
| 165 | return 'true'; |
||
| 166 | } |
||
| 167 | $codeComparison = \sprintf('\\version_compare($v, %s, \'%s\')', \var_export($this->version, \true), self::$transOpInt[$this->operator]); |
||
| 168 | if ($this->operator === self::OP_LE) { |
||
| 169 | if ($otherOperator === self::OP_GT) { |
||
| 170 | return \sprintf('!$b && \\version_compare($v, %s, \'!=\') && ', \var_export($this->version, \true)) . $codeComparison; |
||
| 171 | } |
||
| 172 | } elseif ($this->operator === self::OP_GE) { |
||
| 173 | if ($otherOperator === self::OP_LT) { |
||
| 174 | return \sprintf('!$b && \\version_compare($v, %s, \'!=\') && ', \var_export($this->version, \true)) . $codeComparison; |
||
| 175 | } |
||
| 176 | } |
||
| 177 | return \sprintf('!$b && %s', $codeComparison); |
||
| 178 | } |
||
| 262 |