protected function validateType($entity, $schema, $entityName)
    {
        if (isset($schema->type)) {
	        $types = $schema->type;
		} else {
			$types = 'any';
            //throw new ValidationException(sprintf('No type given for [%s]', $entityName));
        }

        if (!is_array($types)) {
            $types = array($types);
        }

        $valid = false;

        foreach ($types as $type) {
            switch ($type) {
                case 'object':
                    if (is_object($entity)) {
                        $this->checkTypeObject($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'string':
                    if (is_string($entity)) {
                        $this->checkTypeString($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'array':
                    if (is_array($entity)) {
                        $this->checkTypeArray($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'integer':
                    if (!is_string($entity) && is_int($entity)) {
                        $this->checkTypeInteger($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'number':
                    if (!is_string($entity) && is_numeric($entity)) {
                        $this->checkTypeNumber($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'boolean':
                    if (!is_string($entity) && is_bool($entity)) {
                        $this->checkTypeBoolean($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'null':
                    if (is_null($entity)) {
                        $this->checkTypeNull($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'any':
                    $this->checkTypeAny($entity, $schema, $entityName);
                    $valid = true;
                    break;
                default:
                    // Do nothing
                    $valid = true;
                    break;
            }
        }

        if (!$valid) {
            throw new ValidationException(sprintf('Property [%s] must be one of the following types: [%s]', $entityName, implode(', ', $types)));
        }

        return $this;
    }
protected function validateType($entity, $schema, $entityName)
    {
        if (isset($schema->type)) {
	        $types = $schema->type;
		} else {
			$types = 'any';
            //throw new ValidationException(sprintf('No type given for [%s]', $entityName));
        }

        if (!is_array($types)) {
            $types = array($types);
        }

        $valid = false;

        foreach ($types as $type) {
            switch ($type) {
                case 'object':
                    if (is_object($entity)) {
                        $this->checkTypeObject($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'string':
                    if (is_string($entity)) {
                        $this->checkTypeString($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'array':
                    if (is_array($entity)) {
                        $this->checkTypeArray($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'integer':
                    if (!is_string($entity) && is_int($entity)) {
                        $this->checkTypeInteger($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'number':
                    if (!is_string($entity) && is_numeric($entity)) {
                        $this->checkTypeNumber($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'boolean':
                    if (!is_string($entity) && is_bool($entity)) {
                        $this->checkTypeBoolean($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'null':
                    if (is_null($entity)) {
                        $this->checkTypeNull($entity, $schema, $entityName);
                        $valid = true;
                    }
                    break;
                case 'any':
                    $this->checkTypeAny($entity, $schema, $entityName);
                    $valid = true;
                    break;
                default:
                    // Do nothing
                    $valid = true;
                    break;
            }
        }

        if (!$valid) {
            throw new ValidationException(sprintf('Property [%s] must be one of the following types: [%s]', $entityName, implode(', ', $types)));
        }

        return $this;
    }
protected function validateType ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> type ) ) { $ types = $ schema -> type ; } else { $ types = 'any' ; //throw new ValidationException(sprintf('No type given for [%s]', $entityName)); } if ( ! is_array ( $ types ) ) { $ types = array ( $ types ) ; } $ valid = false ; foreach ( $ types as $ type ) { switch ( $ type ) { case 'object' : if ( is_object ( $ entity ) ) { $ this -> checkTypeObject ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'string' : if ( is_string ( $ entity ) ) { $ this -> checkTypeString ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'array' : if ( is_array ( $ entity ) ) { $ this -> checkTypeArray ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'integer' : if ( ! is_string ( $ entity ) && is_int ( $ entity ) ) { $ this -> checkTypeInteger ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'number' : if ( ! is_string ( $ entity ) && is_numeric ( $ entity ) ) { $ this -> checkTypeNumber ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'boolean' : if ( ! is_string ( $ entity ) && is_bool ( $ entity ) ) { $ this -> checkTypeBoolean ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'null' : if ( is_null ( $ entity ) ) { $ this -> checkTypeNull ( $ entity , $ schema , $ entityName ) ; $ valid = true ; } break ; case 'any' : $ this -> checkTypeAny ( $ entity , $ schema , $ entityName ) ; $ valid = true ; break ; default : // Do nothing $ valid = true ; break ; } } if ( ! $ valid ) { throw new ValidationException ( sprintf ( 'Property [%s] must be one of the following types: [%s]' , $ entityName , implode ( ', ' , $ types ) ) ) ; } return $ this ; }
Validate entity type

@param mixed $entity
@param object $schema
@param string $entityName

@return Validator
Validate entity type