| Conditions | 12 |
| Paths | 8 |
| Total Lines | 41 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 66 | private static function _toBase(DecimalInterface $input, int $base): string |
||
| 67 | { |
||
| 68 | $intPart = '0'; |
||
| 69 | $decPart = '0'; |
||
| 70 | $baseNum = Numbers::make(Numbers::IMMUTABLE, $base, $input->getScale()); |
||
| 71 | $inputInt = Numbers::make(Numbers::IMMUTABLE, $input->getWholePart()); |
||
| 72 | $inputDec = Numbers::make(Numbers::IMMUTABLE, strrev($input->getDecimalPart())); |
||
| 73 | $runningTotal = Numbers::makeZero(); |
||
| 74 | |||
| 75 | if ($inputInt->isGreaterThan(0)) { |
||
| 76 | for ($pos = 0; $runningTotal->isLessThan($inputInt); $pos++) { |
||
| 77 | $basePow = $pos ? |
||
| 78 | $baseNum->pow($pos) : |
||
| 79 | $baseNum->pow($pos+1); |
||
| 80 | $intPart = $pos ? $intPart : ''; |
||
| 81 | $mod = $pos ? |
||
| 82 | (int)gmp_strval(gmp_div_q($inputInt->getAsBaseTenRealNumber(), $basePow->getAsBaseTenRealNumber())) : |
||
| 83 | (int)gmp_strval(gmp_div_r($inputInt->getAsBaseTenRealNumber(), $basePow->getAsBaseTenRealNumber())); |
||
| 84 | $intPart = self::$chars[$mod] . $intPart; |
||
| 85 | $runningTotal = $pos ? |
||
| 86 | $runningTotal->add($basePow->multiply($mod)) : |
||
| 87 | $runningTotal->add($mod); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | if ($inputDec->isGreaterThan(0)) { |
||
| 92 | $runningTotal = Numbers::makeZero(); |
||
| 93 | for ($pos = 0; $runningTotal->isLessThan($decPart); $pos++) { |
||
| 94 | $basePow = $baseNum->pow($pos); |
||
| 95 | $decPart = $pos ? $decPart : ''; |
||
| 96 | $mod = $pos ? |
||
| 97 | (int)gmp_strval(gmp_div_q($inputDec->getAsBaseTenRealNumber(), $baseNum->pow($pos)->getAsBaseTenRealNumber())) : |
||
| 98 | $inputDec->modulo($baseNum->pow($pos))->asInt(); |
||
| 99 | $decPart = self::$chars[$mod] . $decPart; |
||
| 100 | $runningTotal = $runningTotal->add($basePow->multiply($mod)); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | $sign = $input->isNegative() ? '-' : ''; |
||
| 105 | |||
| 106 | return $sign.$intPart.'.'.strrev($decPart); |
||
| 107 | } |
||
| 129 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.