protected static function mapSchemaDataToModelData(
        iterable $captures,
        string $schemaClass,
        ModelSchemaInfoInterface $schemaInfo
    ): array {
        static::assertClassImplements($schemaClass, SchemaInterface::class);

        /** @var SchemaInterface $schemaClass */
        static::assertClassImplements($modelClass = $schemaClass::MODEL, ModelInterface::class);

        $index         = null;
        $fields        = [];
        $toManyIndexes = [];
        foreach ($captures as $name => $value) {
            assert(is_string($name) === true);
            if ($name === DI::KEYWORD_ID) {
                $index = $value;
            } elseif ($schemaClass::hasAttributeMapping($name) === true) {
                $fieldName          = $schemaClass::getAttributeMapping($name);
                $fields[$fieldName] = $value;
            } elseif ($schemaClass::hasRelationshipMapping($name) === true) {
                $modelRelName = $schemaClass::getRelationshipMapping($name);
                $relType      = $schemaInfo->getRelationshipType($modelClass, $modelRelName);
                if ($relType === RelationshipTypes::BELONGS_TO) {
                    $fkName          = $schemaInfo->getForeignKey($modelClass, $modelRelName);
                    $fields[$fkName] = $value;
                } elseif ($relType === RelationshipTypes::BELONGS_TO_MANY) {
                    $toManyIndexes[$modelRelName] = $value;
                }
            }
        }

        $result = [$index, $fields, $toManyIndexes];

        return $result;
    }
protected static function mapSchemaDataToModelData(
        iterable $captures,
        string $schemaClass,
        ModelSchemaInfoInterface $schemaInfo
    ): array {
        static::assertClassImplements($schemaClass, SchemaInterface::class);

        /** @var SchemaInterface $schemaClass */
        static::assertClassImplements($modelClass = $schemaClass::MODEL, ModelInterface::class);

        $index         = null;
        $fields        = [];
        $toManyIndexes = [];
        foreach ($captures as $name => $value) {
            assert(is_string($name) === true);
            if ($name === DI::KEYWORD_ID) {
                $index = $value;
            } elseif ($schemaClass::hasAttributeMapping($name) === true) {
                $fieldName          = $schemaClass::getAttributeMapping($name);
                $fields[$fieldName] = $value;
            } elseif ($schemaClass::hasRelationshipMapping($name) === true) {
                $modelRelName = $schemaClass::getRelationshipMapping($name);
                $relType      = $schemaInfo->getRelationshipType($modelClass, $modelRelName);
                if ($relType === RelationshipTypes::BELONGS_TO) {
                    $fkName          = $schemaInfo->getForeignKey($modelClass, $modelRelName);
                    $fields[$fkName] = $value;
                } elseif ($relType === RelationshipTypes::BELONGS_TO_MANY) {
                    $toManyIndexes[$modelRelName] = $value;
                }
            }
        }

        $result = [$index, $fields, $toManyIndexes];

        return $result;
    }
protected static function mapSchemaDataToModelData ( iterable $ captures , string $ schemaClass , ModelSchemaInfoInterface $ schemaInfo ) : array { static :: assertClassImplements ( $ schemaClass , SchemaInterface :: class ) ; /** @var SchemaInterface $schemaClass */ static :: assertClassImplements ( $ modelClass = $ schemaClass :: MODEL , ModelInterface :: class ) ; $ index = null ; $ fields = [ ] ; $ toManyIndexes = [ ] ; foreach ( $ captures as $ name => $ value ) { assert ( is_string ( $ name ) === true ) ; if ( $ name === DI :: KEYWORD_ID ) { $ index = $ value ; } elseif ( $ schemaClass :: hasAttributeMapping ( $ name ) === true ) { $ fieldName = $ schemaClass :: getAttributeMapping ( $ name ) ; $ fields [ $ fieldName ] = $ value ; } elseif ( $ schemaClass :: hasRelationshipMapping ( $ name ) === true ) { $ modelRelName = $ schemaClass :: getRelationshipMapping ( $ name ) ; $ relType = $ schemaInfo -> getRelationshipType ( $ modelClass , $ modelRelName ) ; if ( $ relType === RelationshipTypes :: BELONGS_TO ) { $ fkName = $ schemaInfo -> getForeignKey ( $ modelClass , $ modelRelName ) ; $ fields [ $ fkName ] = $ value ; } elseif ( $ relType === RelationshipTypes :: BELONGS_TO_MANY ) { $ toManyIndexes [ $ modelRelName ] = $ value ; } } } $ result = [ $ index , $ fields , $ toManyIndexes ] ; return $ result ; }
Developers can override the method in order to use custom data mapping from a Schema to Model.

@param iterable                 $captures
@param string                   $schemaClass
@param ModelSchemaInfoInterface $schemaInfo

@return array
Developers can override the method in order to use custom data mapping from a Schema to Model .