3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Assert { public static function isString($value) : string { if (false === is_string($value)) { throw new Exception('Not string.'); } return __CLASS__; } public static function notEmptyString($value) : string { if ('' === trim($value)) { throw new DomainException('Empty string.'); } return __CLASS__; } } $string = 'test'; $emptyString = ' '; Assert::isString($string)::notEmptyString($string); Assert::isString($emptyString)::notEmptyString($emptyString);

preferences:
81.94 ms | 404 KiB | 5 Q