<?php
use Assert\AssertionChain;
$assertValue = function ($value) {
try {
$assert = new AssertionChain($value);
$assert->integer()
->choice([42, 0, 7])
->same(42);
echo $value . ' is okay. You shall pass' . PHP_EOL;
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
};
$assertValue(42);
$assertValue(7);
$assertValue(9);
$assertValue('42');