protected function checkAndReturn($candidate)
    {
        if (!is_object($candidate)) {
            throw new InvalidArgumentException('Only objects are supported not '.gettype($candidate));
        }

        $type = $this->getCandidateType();

        if ($candidate instanceof $type) {
            return $candidate;
        }

        $thisClass = get_class($this);

        throw new InvalidArgumentException("You can only add $type objects to this object. Or define another class via an allow property in $thisClass");
    }
protected function checkAndReturn($candidate)
    {
        if (!is_object($candidate)) {
            throw new InvalidArgumentException('Only objects are supported not '.gettype($candidate));
        }

        $type = $this->getCandidateType();

        if ($candidate instanceof $type) {
            return $candidate;
        }

        $thisClass = get_class($this);

        throw new InvalidArgumentException("You can only add $type objects to this object. Or define another class via an allow property in $thisClass");
    }
protected function checkAndReturn ( $ candidate ) { if ( ! is_object ( $ candidate ) ) { throw new InvalidArgumentException ( 'Only objects are supported not ' . gettype ( $ candidate ) ) ; } $ type = $ this -> getCandidateType ( ) ; if ( $ candidate instanceof $ type ) { return $ candidate ; } $ thisClass = get_class ( $ this ) ; throw new InvalidArgumentException ( "You can only add $type objects to this object. Or define another class via an allow property in $thisClass" ) ; }
Check the type of the extension and return it.

@param mixed $candidate

@return mixed
Check the type of the extension and return it .