isGraphQLType() 공개 정적인 메소드

public static isGraphQLType ( $type )
예제 #1
0
 /**
  * NonNullType constructor.
  *
  * @param AbstractType|string $fieldType
  *
  * @throws ConfigurationException
  */
 public function __construct($fieldType)
 {
     if (!TypeService::isGraphQLType($fieldType)) {
         throw new ConfigurationException('NonNullType accepts only GraphpQL Types as argument');
     }
     if (TypeService::isScalarType($fieldType)) {
         $fieldType = TypeFactory::getScalarType($fieldType);
     }
     $this->_typeOf = $fieldType;
 }
예제 #2
0
 public function validate($data, $ruleInfo)
 {
     if (!is_string($ruleInfo)) {
         return false;
     }
     switch ($ruleInfo) {
         case TypeService::TYPE_ANY:
             return true;
         case TypeService::TYPE_ANY_OBJECT:
             return is_object($data);
         case TypeService::TYPE_CALLABLE:
             return is_callable($data);
         case TypeService::TYPE_BOOLEAN:
             return is_bool($data);
         case TypeService::TYPE_ARRAY:
             return is_array($data);
         case TypeService::TYPE_STRING:
             return TypeFactory::getScalarType($ruleInfo)->isValidValue($data);
         case TypeService::TYPE_GRAPHQL_TYPE:
             return TypeService::isGraphQLType($data);
         case TypeService::TYPE_OBJECT_TYPE:
             return TypeService::isObjectType($data);
         case TypeService::TYPE_ARRAY_OF_OBJECT_TYPES:
             return $this->isArrayOfObjectTypes($data);
         case TypeService::TYPE_ARRAY_OF_FIELDS_CONFIG:
             return $this->isArrayOfFields($data);
         case TypeService::TYPE_OBJECT_INPUT_TYPE:
             return TypeService::isInputObjectType($data);
         case TypeService::TYPE_ENUM_VALUES:
             return $this->isEnumValues($data);
         case TypeService::TYPE_ARRAY_OF_INPUT_FIELDS:
             return $this->isArrayOfInputFields($data);
         case TypeService::TYPE_ANY_INPUT:
             return TypeService::isInputType($data);
         case TypeService::TYPE_ARRAY_OF_INTERFACES:
             return $this->isArrayOfInterfaces($data);
         default:
             return false;
     }
 }