WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface::createResourceTypeUnacceptableException PHP Method

createResourceTypeUnacceptableException() public method

public createResourceTypeUnacceptableException ( string $currentType, array $acceptedTypes ) : Exception
$currentType string
$acceptedTypes array
return Exception
    public function createResourceTypeUnacceptableException($currentType, array $acceptedTypes);

Usage Example

示例#1
0
 /**
  * @param array $data
  * @param \WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory
  * @throws \Exception
  */
 protected function validateType($data, ExceptionFactoryInterface $exceptionFactory)
 {
     if (empty($data["type"])) {
         throw $exceptionFactory->createResourceTypeMissingException();
     }
     $acceptedType = $this->getAcceptedType();
     if (is_string($acceptedType) === true && $data["type"] !== $acceptedType) {
         throw $exceptionFactory->createResourceTypeUnacceptableException($data["type"], [$acceptedType]);
     }
     if (is_array($acceptedType) && in_array($data["type"], $acceptedType) === false) {
         throw $exceptionFactory->createResourceTypeUnacceptableException($data["type"], $acceptedType);
     }
 }