private function applyStorageStrategy(array &$mapping) : void
    {
        if (! isset($mapping['type']) || isset($mapping['id'])) {
            return;
        }

        switch (true) {
            case $mapping['type'] === 'int':
            case $mapping['type'] === 'float':
                $defaultStrategy   = self::STORAGE_STRATEGY_SET;
                $allowedStrategies = [self::STORAGE_STRATEGY_SET, self::STORAGE_STRATEGY_INCREMENT];
                break;

            case $mapping['type'] === 'many':
                $defaultStrategy   = CollectionHelper::DEFAULT_STRATEGY;
                $allowedStrategies = [
                    self::STORAGE_STRATEGY_PUSH_ALL,
                    self::STORAGE_STRATEGY_ADD_TO_SET,
                    self::STORAGE_STRATEGY_SET,
                    self::STORAGE_STRATEGY_SET_ARRAY,
                    self::STORAGE_STRATEGY_ATOMIC_SET,
                    self::STORAGE_STRATEGY_ATOMIC_SET_ARRAY,
                ];
                break;

            default:
                $defaultStrategy   = self::STORAGE_STRATEGY_SET;
                $allowedStrategies = [self::STORAGE_STRATEGY_SET];
        }

        if (! isset($mapping['strategy'])) {
            $mapping['strategy'] = $defaultStrategy;
        }

        if (! in_array($mapping['strategy'], $allowedStrategies)) {
            throw MappingException::invalidStorageStrategy($this->name, $mapping['fieldName'], $mapping['type'], $mapping['strategy']);
        }

        if (isset($mapping['reference']) && $mapping['type'] === 'many' && $mapping['isOwningSide']
            && ! empty($mapping['sort']) && ! CollectionHelper::usesSet($mapping['strategy'])) {
            throw MappingException::referenceManySortMustNotBeUsedWithNonSetCollectionStrategy($this->name, $mapping['fieldName'], $mapping['strategy']);
        }
    }
private function applyStorageStrategy(array &$mapping) : void
    {
        if (! isset($mapping['type']) || isset($mapping['id'])) {
            return;
        }

        switch (true) {
            case $mapping['type'] === 'int':
            case $mapping['type'] === 'float':
                $defaultStrategy   = self::STORAGE_STRATEGY_SET;
                $allowedStrategies = [self::STORAGE_STRATEGY_SET, self::STORAGE_STRATEGY_INCREMENT];
                break;

            case $mapping['type'] === 'many':
                $defaultStrategy   = CollectionHelper::DEFAULT_STRATEGY;
                $allowedStrategies = [
                    self::STORAGE_STRATEGY_PUSH_ALL,
                    self::STORAGE_STRATEGY_ADD_TO_SET,
                    self::STORAGE_STRATEGY_SET,
                    self::STORAGE_STRATEGY_SET_ARRAY,
                    self::STORAGE_STRATEGY_ATOMIC_SET,
                    self::STORAGE_STRATEGY_ATOMIC_SET_ARRAY,
                ];
                break;

            default:
                $defaultStrategy   = self::STORAGE_STRATEGY_SET;
                $allowedStrategies = [self::STORAGE_STRATEGY_SET];
        }

        if (! isset($mapping['strategy'])) {
            $mapping['strategy'] = $defaultStrategy;
        }

        if (! in_array($mapping['strategy'], $allowedStrategies)) {
            throw MappingException::invalidStorageStrategy($this->name, $mapping['fieldName'], $mapping['type'], $mapping['strategy']);
        }

        if (isset($mapping['reference']) && $mapping['type'] === 'many' && $mapping['isOwningSide']
            && ! empty($mapping['sort']) && ! CollectionHelper::usesSet($mapping['strategy'])) {
            throw MappingException::referenceManySortMustNotBeUsedWithNonSetCollectionStrategy($this->name, $mapping['fieldName'], $mapping['strategy']);
        }
    }
private function applyStorageStrategy ( array & $ mapping ) : void { if ( ! isset ( $ mapping [ 'type' ] ) || isset ( $ mapping [ 'id' ] ) ) { return ; } switch ( true ) { case $ mapping [ 'type' ] === 'int' : case $ mapping [ 'type' ] === 'float' : $ defaultStrategy = self :: STORAGE_STRATEGY_SET ; $ allowedStrategies = [ self :: STORAGE_STRATEGY_SET , self :: STORAGE_STRATEGY_INCREMENT ] ; break ; case $ mapping [ 'type' ] === 'many' : $ defaultStrategy = CollectionHelper :: DEFAULT_STRATEGY ; $ allowedStrategies = [ self :: STORAGE_STRATEGY_PUSH_ALL , self :: STORAGE_STRATEGY_ADD_TO_SET , self :: STORAGE_STRATEGY_SET , self :: STORAGE_STRATEGY_SET_ARRAY , self :: STORAGE_STRATEGY_ATOMIC_SET , self :: STORAGE_STRATEGY_ATOMIC_SET_ARRAY , ] ; break ; default : $ defaultStrategy = self :: STORAGE_STRATEGY_SET ; $ allowedStrategies = [ self :: STORAGE_STRATEGY_SET ] ; } if ( ! isset ( $ mapping [ 'strategy' ] ) ) { $ mapping [ 'strategy' ] = $ defaultStrategy ; } if ( ! in_array ( $ mapping [ 'strategy' ] , $ allowedStrategies ) ) { throw MappingException :: invalidStorageStrategy ( $ this -> name , $ mapping [ 'fieldName' ] , $ mapping [ 'type' ] , $ mapping [ 'strategy' ] ) ; } if ( isset ( $ mapping [ 'reference' ] ) && $ mapping [ 'type' ] === 'many' && $ mapping [ 'isOwningSide' ] && ! empty ( $ mapping [ 'sort' ] ) && ! CollectionHelper :: usesSet ( $ mapping [ 'strategy' ] ) ) { throw MappingException :: referenceManySortMustNotBeUsedWithNonSetCollectionStrategy ( $ this -> name , $ mapping [ 'fieldName' ] , $ mapping [ 'strategy' ] ) ; } }
Validates the storage strategy of a mapping for consistency

@throws MappingException
Validates the storage strategy of a mapping for consistency