public static createForInvalidReferenceType ( string $reference ) : InvalidArgumentException | ||
$reference | string | |
리턴 | InvalidArgumentException |
public function testTestCreateForInvalidReferenceType() { $exception = InvalidArgumentExceptionFactory::createForInvalidReferenceType('foo'); $this->assertEquals('Expected reference to be either a string or a "Nelmio\\Alice\\Definition\\ValueInterface" instance, got "foo"' . ' instead.', $exception->getMessage()); $this->assertEquals(0, $exception->getCode()); $this->assertNull($exception->getPrevious()); }
/** * @param string|ValueInterface $reference e.g. "user0" */ public function __construct($reference) { if (false === is_string($reference) && false === $reference instanceof ValueInterface) { if (null === $reference) { $referenceString = 'null'; } elseif (is_array($reference)) { $referenceString = 'array'; } else { $referenceString = is_scalar($reference) ? gettype($reference) : get_class($reference); } throw InvalidArgumentExceptionFactory::createForInvalidReferenceType($referenceString); } $this->reference = $reference; }