コード例 #1
0
ファイル: Type.php プロジェクト: apparat/object
 /**
  * Type constructor
  *
  * @param string $type Object type
  * @param TypeServiceInterface $typeService Type service
  * @throws InvalidArgumentException If the type is not supported
  */
 public function __construct($type, TypeServiceInterface $typeService)
 {
     $this->typeService = $typeService;
     // If the type is not supported
     if (!$this->typeService->supportsType($type)) {
         throw new InvalidArgumentException(sprintf('Invalid object type "%s"', $type), InvalidArgumentException::INVALID_OBJECT_TYPE);
     }
     $this->type = $type;
 }
コード例 #2
0
ファイル: Selector.php プロジェクト: apparat/object
 /**
  * Validate the type component
  *
  * @param TypeServiceInterface $typeService Type Service
  * @param string|NULL $type Object type
  * @throws InvalidArgumentException If the type component isn't valid
  */
 protected function validateTypeComponent(TypeServiceInterface $typeService, $type)
 {
     // If the type component isn't valid
     if (!$typeService->supportsType($type) && $type !== self::WILDCARD) {
         throw new InvalidArgumentException(sprintf('Invalid repository selector type component "%s"', $type), InvalidArgumentException::INVALID_REPOSITORY_SELECTOR_COMPONENT, null, 'type');
     }
     $this->type = $type;
 }