src/Maths/Arithmetic/Helper.php
public static function getModuloUsingTruncation($a, $b)
    {
        $a = round($a, 0, ($a>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP));
        $b = round($b, 0, ($b>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP));
        $tmp_a = $a;
        $ab = $a/$b;
        $counter = 0;
        while ($ab!==0 && ($ab!==round($ab, 0))) {
            $counter++;
            if ($tmp_a>0) {
                $tmp_a = $a - $counter;
                $ab = $tmp_a/$b;
            } elseif ($tmp_a<0) {
                $tmp_a = $a + $counter;
                $ab = $tmp_a/$b;
            } else {
                $ab = 0;
            }
        }
        return ($a>=0 ? $counter : -$counter);
    }
public static function getModuloUsingTruncation($a, $b)
    {
        $a = round($a, 0, ($a>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP));
        $b = round($b, 0, ($b>=0 ? PHP_ROUND_HALF_DOWN : PHP_ROUND_HALF_UP));
        $tmp_a = $a;
        $ab = $a/$b;
        $counter = 0;
        while ($ab!==0 && ($ab!==round($ab, 0))) {
            $counter++;
            if ($tmp_a>0) {
                $tmp_a = $a - $counter;
                $ab = $tmp_a/$b;
            } elseif ($tmp_a<0) {
                $tmp_a = $a + $counter;
                $ab = $tmp_a/$b;
            } else {
                $ab = 0;
            }
        }
        return ($a>=0 ? $counter : -$counter);
    }
This method is an alternative to the native `a % b` using the loop method.
The result will always be in range `[0 ; a]` and have the same sign as `a`.

This method is VERY slow but can be considered as the real calculation of a "modulo".

@param $a
@param $b
@return int