<?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);
You have javascript disabled. You will not be able to edit any code.