for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Aeq\LargestRemainder\Math;
use Aeq\LargestRemainder\Exception\AlreadyNormalizedException;
use Aeq\LargestRemainder\Exception\NotYetNormalizedException;
class Number
{
/**
* @var float
*/
private $number = 0.0;
* @var int
private $precision = 0;
private $isNormalized = false;
* @param float $number
* @param int $precision
public function __construct(float $number, int $precision = 0)
$this->number = $number;
$this->precision = $precision;
}
* @return Number
* @throws AlreadyNormalizedException
public function normalize(): self
if ($this->isNormalized) {
throw new AlreadyNormalizedException(1538928749);
$this->number = $this->number * pow(10, $this->precision);
$this->isNormalized = true;
$isNormalized
double
true
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
return $this;
return $this
Aeq\LargestRemainder\Math\Number
integer|double
* @throws NotYetNormalizedException
public function denormalize(): self
if (false === $this->isNormalized) {
$this->isNormalized
false
src/Math/Number.php
21
throw new NotYetNormalizedException(1538928762);
$this->number = $this->number / pow(10, $this->precision);
$this->isNormalized = false;
* @param $val
public function add($val): self
$this->number += $val;
public function sub($val): self
$this->number -= $val;
public function floor(): self
$this->number = floor($this->number);
* @return float
public function value(): float
return $this->number;
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.