/** * @param string $className * * @return ReflectionClass * * @throws InvalidArgumentException */ private function getReflectionClass($className) { if (!class_exists($className)) { throw InvalidArgumentException::fromNonExistingClass($className); } $reflection = new ReflectionClass($className); if ($reflection->isAbstract()) { throw InvalidArgumentException::fromAbstractClass($reflection); } return $reflection; }
public function testFromNonExistingTypeWithInterface() { $exception = InvalidArgumentException::fromNonExistingClass('Instantiator\\InstantiatorInterface'); $this->assertSame('The provided type "Instantiator\\InstantiatorInterface" is an interface, and can not be instantiated', $exception->getMessage()); }