Beberlei Asserts - assertions and guard methods for input validation

Code
<?php

use Assert\Assertion;

class Foo
{
    public function intOnly($value)
    {
        Assertion::integer($value);
        return $value;
    }
    
    public function floatOnly($value)
    {
        Assertion::float($value);
        return $value;
    }
    
    public function sum($collection)
    {
        Assertion::isTraversable($collection);
        $result = 0;
        foreach ($collection as $value) {
            Assertion::integer($value);
            $result += $value;
        }
        return $result;
    }
}

$foo = new Foo();

try {
    $foo->intOnly('1');
} catch (Exception $e) {
    dump($e->getMessage());
}


try {
    $foo->floatOnly(1);
} catch (Exception $e) {
    dump($e->getMessage());
}


try {
    $foo->sum([1, 1, '1']);
} catch (Exception $e) {
    dump($e->getMessage());
}

try {
    $foo->sum(4);
} catch (Exception $e) {
    dump($e->getMessage());
}
Result
^ "Value "1" is not an integer."

^ "Value "1" is not a float."

^ "Value "1" is not an integer."

^ "Value "4" is not an array and does not implement Traversable."
Used Versions
PHP 8.3, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8