mageekguy\atoum\asserters\object::isInstanceOf PHP Метод

isInstanceOf() публичный Метод

public isInstanceOf ( $value, $failMessage = null )
    public function isInstanceOf($value, $failMessage = null)
    {
        try {
            self::check($value, __FUNCTION__);
        } catch (\logicException $exception) {
            if (self::classExists($value) === false) {
                throw new exceptions\logic('Argument of ' . __METHOD__ . '() must be a class instance or a class name');
            }
        }
        $this->valueIsSet()->value instanceof $value ? $this->pass() : $this->fail($failMessage ?: $this->_('%s is not an instance of %s', $this, is_string($value) === true ? $value : $this->getTypeOf($value)));
        return $this;
    }

Usage Example

Пример #1
0
 public function isInstanceOf($value, $failMessage = null)
 {
     try {
         $this->check($value, __FUNCTION__);
     } catch (\logicException $exception) {
         if (self::classExists($value) === false || strtolower(ltrim($value, '\\')) !== 'exception' && is_subclass_of($value, 'exception') === false) {
             throw new exceptions\logic\invalidArgument('Argument of ' . __METHOD__ . '() must be a \\exception instance or an exception class name');
         }
     }
     return parent::isInstanceOf($value, $failMessage);
 }