src/Schema/SchemaContainer.php
public function register(string $type, $schema): void
    {
        if (empty($type) === true || \class_exists($type) === false) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_MODEL_TYPE));
        }

        $isOk = (
            (
                \is_string($schema) === true &&
                empty($schema) === false &&
                \class_exists($schema) === true &&
                \in_array(SchemaInterface::class, \class_implements($schema)) === true
            ) ||
            \is_callable($schema) ||
            $schema instanceof SchemaInterface
        );
        if ($isOk === false) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_SCHEME, $type));
        }

        if ($this->hasProviderMapping($type) === true) {
            throw new InvalidArgumentException(_(static::MSG_TYPE_REUSE_FORBIDDEN, $type));
        }

        if ($schema instanceof SchemaInterface) {
            $this->setProviderMapping($type, \get_class($schema));
            $this->setResourceToJsonTypeMapping($schema->getType(), $type);
            $this->setCreatedProvider($type, $schema);
        } else {
            $this->setProviderMapping($type, $schema);
        }
    }
public function register(string $type, $schema): void
    {
        if (empty($type) === true || \class_exists($type) === false) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_MODEL_TYPE));
        }

        $isOk = (
            (
                \is_string($schema) === true &&
                empty($schema) === false &&
                \class_exists($schema) === true &&
                \in_array(SchemaInterface::class, \class_implements($schema)) === true
            ) ||
            \is_callable($schema) ||
            $schema instanceof SchemaInterface
        );
        if ($isOk === false) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_SCHEME, $type));
        }

        if ($this->hasProviderMapping($type) === true) {
            throw new InvalidArgumentException(_(static::MSG_TYPE_REUSE_FORBIDDEN, $type));
        }

        if ($schema instanceof SchemaInterface) {
            $this->setProviderMapping($type, \get_class($schema));
            $this->setResourceToJsonTypeMapping($schema->getType(), $type);
            $this->setCreatedProvider($type, $schema);
        } else {
            $this->setProviderMapping($type, $schema);
        }
    }
public function register ( string $ type , $ schema ) : void { if ( empty ( $ type ) === true || \ class_exists ( $ type ) === false ) { throw new InvalidArgumentException ( _ ( static :: MSG_INVALID_MODEL_TYPE ) ) ; } $ isOk = ( ( \ is_string ( $ schema ) === true && empty ( $ schema ) === false && \ class_exists ( $ schema ) === true && \ in_array ( SchemaInterface :: class , \ class_implements ( $ schema ) ) === true ) || \ is_callable ( $ schema ) || $ schema instanceof SchemaInterface ) ; if ( $ isOk === false ) { throw new InvalidArgumentException ( _ ( static :: MSG_INVALID_SCHEME , $ type ) ) ; } if ( $ this -> hasProviderMapping ( $ type ) === true ) { throw new InvalidArgumentException ( _ ( static :: MSG_TYPE_REUSE_FORBIDDEN , $ type ) ) ; } if ( $ schema instanceof SchemaInterface ) { $ this -> setProviderMapping ( $ type , \ get_class ( $ schema ) ) ; $ this -> setResourceToJsonTypeMapping ( $ schema -> getType ( ) , $ type ) ; $ this -> setCreatedProvider ( $ type , $ schema ) ; } else { $ this -> setProviderMapping ( $ type , $ schema ) ; } }
Register provider for resource type.

@param string         $type
@param string|Closure $schema

@return void

@SuppressWarnings(PHPMD.StaticAccess)
@SuppressWarnings(PHPMD.ElseExpression)
@SuppressWarnings(PHPMD.CyclomaticComplexity)
Register provider for resource type .