@param IObjectMapper            $mapper
@param MemberPropertyExpression $part

@return IRelation
@throws BaseException
974197
private function mapPropertyToRelation(IObjectMapper $mapper, MemberPropertyExpression $part) : IRelation
    {
        $definition = $mapper->getDefinition();

        $property = $part->getProperty();

        $relation = $definition->getRelationMappedToProperty($property->getName());

        if (!$relation) {
            throw BaseException::format(
                'invalid property \'%s\' of type %s, must be mapped to a relation',
                $property->getName(), $definition->getClassName()
            );
        }

        return $relation;
    }
1246308
protected function mapLoadExpressionToRelations(
        IObjectMapper $mapper,
        LoadIdFromEntitySetMethodExpression $part,
        IObjectMapper &$finalMapper = null
    ) : array
    {
        /** @var EntityRelation $relationToLoadAsObject */
        $innerRelations         = $this->mapMemberExpressionsToRelations($mapper, $part->getIdMember()->getParts(), $finalMapper);
        $relationToLoadAsObject = array_pop($innerRelations);

        $relationsToAdd   = $innerRelations;
        $relationsToAdd[] = $relationToLoadAsObject->withObjectReference();

        return $relationsToAdd;
    }
930992
public function getLimitedPartStream(StreamInterface $stream, PartBuilder $part)
    {
        return $this->newLimitStream(
            $stream,
            $part->getStreamPartLength(),
            $part->getStreamPartStartOffset()
        );
    }
540359
protected function parsePart($stream, $uid, $part, $partNo = 1)
    {
        if (!in_array($part->type, [TYPETEXT, TYPEMULTIPART])) {
            return null;
        }

        $body = imap_fetchbody($stream, $uid, $partNo, static::$bodyFlags);

        $body = static::decode($body, $part->encoding);
        if ('' !== ($charset = $this->findCharset($part))) {
            $body = static::convertBodyEncoding($body, $charset, $part->encoding);
        }

        return (object) [
            'body' => $body,
            'mime_type' => strtolower($part->subtype)
        ];
    }
361245
public function subclass(): SubClassMappingDefiner
    {
        $this->verifyDefinedClass();

        return new SubClassMappingDefiner(
            $this->orm,
            $this,
            function (callable $mappingLoader, MapperDefinition $subClassDefinition) {
                $subClassDefinition->verifyDefinedClass();
                $subClassName = $subClassDefinition->class->getClassName();

                if (!is_a($subClassName, $this->class->getClassName(), true)) {
                    throw IncompleteMapperDefinitionException::format(
                        'Invalid subclass mapper definition for: defined type must be a subclass of %s, %s given',
                        $this->class->getClassName(),
                        $subClassName
                    );
                }

                $this->subClassMappingFactories[$subClassName] = $mappingLoader;
            }
        );
    }
1062588
protected function mapFinalSelfRelation(IEntityMapper $mapper) : MemberMapping
    {
        return $this->mapFinalRelationToMapping(
            [],
            [],
            new ToOneRelation(
                self::SELF_RELATION_ID,
                new ToOneRelationObjectReference($mapper),
                $mapper->getDefinition()->getTable()->getPrimaryKeyColumnName(),
                new NonIdentifyingRelationMode()
            )
        );
    }
303832
protected function readPart($handle, PartBuilder $partBuilder)
    {
        $partBuilder->setStreamPartStartPos(ftell($handle));
        
        if ($partBuilder->canHaveHeaders()) {
            $this->readHeaders($handle, $partBuilder);
            $this->lastLineSeparatorLength = 0;
        }
        if ($partBuilder->getParent() === null && !$partBuilder->isMime()) {
            $this->readUUEncodedOrPlainTextMessage($handle, $partBuilder);
        } else {
            $this->readPartContent($handle, $partBuilder);
        }
    }
959758
public function setPartOfRecord($partOfRecord)
    {
        if (is_bool($partOfRecord)) {
            $this->isPartOfRecord = $partOfRecord;
        } else {
            $msg = "The argument must be a boolean, '" . gettype($partOfRecord) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
801237
public function resolve($part, $source)
    {
        if (is_array($source)) {
            $source = $this->handleArray($part, $source);
        } elseif (is_object($source)) {
            $source = $this->handleObject($part, $source);
        }

        return $source;
    }
1135255
private void applySerializationModifier(ObjectMapper mapper) {
		SerializerFactory factory = BeanSerializerFactory.instance
				.withSerializerModifier(new GenericSerializerModifier());
		mapper.setSerializerFactory(factory);
	}
1259426
protected function define(MapperDefinition $map)
    {
        $map->type($this->classType());

        $this->defineStringColumnType($map->property(StringValueObject::STRING)->to($this->columnName));
    }
955311
public function apply($queryBuilder, JoinMap $joinMap): ?string
    {
        $alias = null;

        $rootAlias = $joinMap->getAlias();
        $rootClassMetadata = $joinMap->getClassMetadata();
        $executedAliases = $this->executedAliases($queryBuilder);

        $alias = $rootAlias;
        foreach ($joinMap->getJoinMap() as $path => $fields) {
            foreach ($fields as $fieldData) {
                $field    = $fieldData['field'];
                $joinType = $fieldData['joinType'];
                $joinAlias = $alias . '_' . $field;

                if (!in_array($joinAlias, $executedAliases)) {
                    if ($path == $rootAlias) {
                        $classMetadata = $rootClassMetadata;

                    } else {
                        $pathWithoutRootAlias = substr($path, strlen($rootAlias) + 1);
                        $classMetadata = $this->getClassMetadataByPath($pathWithoutRootAlias, $rootClassMetadata);
                    }

                    $joinMethod = $joinType == JoinMap::JOIN_TYPE_LEFT ? 'leftJoin' : ($joinType == JoinMap::JOIN_TYPE_INNER ? 'innerJoin' : null);

                    if (!$joinMethod) {
                        throw new \RuntimeException('Join type not defined or has wrong type.');
                    }

                    $associationMapping = $classMetadata->getAssociationMapping($field);

                    if ($associationMapping['type'] === ClassMetadata::MANY_TO_MANY) {
                        // If is owning side
                        if ($associationMapping['isOwningSide']) {
                            $joinTable = $associationMapping['joinTable'];
                            $joinTableName = $joinTable['name'];
                            $joinTableAlias = $alias . '_' . $joinTable['name'];

                            $relationToSourceKeyColumns = $associationMapping['relationToSourceKeyColumns'];

                            $queryBuilder->$joinMethod(
                                $alias,
                                $joinTableName,
                                $joinTableAlias,
                                $joinTableAlias . '.' . key($relationToSourceKeyColumns) . ' = ' . $alias . '.' . current($relationToSourceKeyColumns)
                            );

                            $fieldClassMetadata = $this->getClassMetadata($associationMapping['targetEntity']);
                            $fieldTableName = $fieldClassMetadata->getTableName();
                            $relationToTargetKeyColumns = $associationMapping['relationToTargetKeyColumns'];

                            $queryBuilder->$joinMethod(
                                $alias,
                                $fieldTableName,
                                $joinAlias,
                                $joinAlias . '.' . current($relationToTargetKeyColumns) . ' = ' . $joinTableAlias . '.' . key($relationToTargetKeyColumns)
                            );

                        } else {
                            $fieldClassMetadata = $this->getClassMetadata($associationMapping['targetEntity']);
                            $fieldAssociationMapping = $fieldClassMetadata->getAssociationMapping($associationMapping['mappedBy']);
                            $fieldTableName = $fieldClassMetadata->getTableName();

                            $joinTable = $fieldAssociationMapping['joinTable'];
                            $joinTableName = $joinTable['name'];
                            $joinTableAlias = $alias . '_' . $joinTable['name'];
                            $relationToSourceKeyColumns = $fieldAssociationMapping['relationToSourceKeyColumns'];
                            $relationToTargetKeyColumns = $fieldAssociationMapping['relationToTargetKeyColumns'];

                            $queryBuilder->$joinMethod(
                                $alias,
                                $joinTableName,
                                $joinTableAlias,
                                $joinTableAlias . '.' . key($relationToTargetKeyColumns) . ' = ' . $alias . '.' . current($relationToTargetKeyColumns)
                            );

                            $queryBuilder->$joinMethod(
                                $alias,
                                $fieldTableName,
                                $joinAlias,
                                $joinAlias . '.' . current($relationToSourceKeyColumns) . ' = ' . $joinTableAlias . '.' . key($relationToSourceKeyColumns)
                            );
                        }

                    } elseif ($associationMapping['type'] === ClassMetadata::ONE_TO_MANY) {
                        $fieldClassMetadata = $this->getClassMetadata($associationMapping['targetEntity']);
                        $fieldAssociationMapping = $fieldClassMetadata->getAssociationMapping($associationMapping['mappedBy']);
                        $fieldTableName = $fieldClassMetadata->getTableName();
                        $sourceToTargetKeyColumns = $fieldAssociationMapping['sourceToTargetKeyColumns'];

                        $queryBuilder->$joinMethod(
                            $alias,
                            $fieldTableName,
                            $joinAlias,
                            $joinAlias . '.' . key($sourceToTargetKeyColumns) . ' = ' . $alias . '.' . current($sourceToTargetKeyColumns)
                        );

                    } elseif ($associationMapping['type'] === ClassMetadata::MANY_TO_ONE) {
                        $fieldClassMetadata = $this->getClassMetadata($associationMapping['targetEntity']);
                        $fieldTableName = $fieldClassMetadata->getTableName();
                        $sourceToTargetKeyColumns = $associationMapping['sourceToTargetKeyColumns'];

                        $queryBuilder->$joinMethod(
                            $alias,
                            $fieldTableName,
                            $joinAlias,
                            $joinAlias . '.' . current($sourceToTargetKeyColumns) . ' = ' . $alias . '.' . key($sourceToTargetKeyColumns)
                        );

                    } elseif ($associationMapping['type'] === ClassMetadata::ONE_TO_ONE) {
                        if ($associationMapping['isOwningSide']) {
                            $fieldClassMetadata = $this->getClassMetadata($associationMapping['targetEntity']);
                            $fieldTableName = $fieldClassMetadata->getTableName();
                            $sourceToTargetKeyColumns = $associationMapping['sourceToTargetKeyColumns'];

                            $queryBuilder->leftJoin(
                                $alias,
                                $fieldTableName,
                                $joinAlias,
                                $alias . '.' . key($sourceToTargetKeyColumns) . ' = ' . $joinAlias . '.' . current($sourceToTargetKeyColumns)
                            );

                        } else {
                            $fieldClassMetadata = $this->getClassMetadata($associationMapping['targetEntity']);
                            $fieldTableName = $fieldClassMetadata->getTableName();
                            $fieldAssociationMapping = $fieldClassMetadata->getAssociationMapping($associationMapping['mappedBy']);
                            $sourceToTargetKeyColumns = $fieldAssociationMapping['sourceToTargetKeyColumns'];

                            $queryBuilder->leftJoin(
                                $alias,
                                $fieldTableName,
                                $joinAlias,
                                $alias . '.' . current($sourceToTargetKeyColumns) . ' = ' . $joinAlias . '.' . key($sourceToTargetKeyColumns)
                            );
                        }
                    }
                }

                $alias = $joinAlias;
            }
        }

        return $alias;
    }
151543
protected function createObject($mapperClass, $element, $included)
    {
        /** @var Mapper $mapper */
        $mapper = new $mapperClass;

        return $mapper->createObject(array_merge($this->getAttributes($element), $included));
    }
290222
public function getResolverForPart(EmailPart $part): EmailPartResolver
    {
        $identifier = get_class($part);

        if (!array_key_exists($identifier, $this->resolvers)) {
            throw new InvalidArgumentException(sprintf(
                'Resolver for the part "%s" does not exists. Please choose one of the following: %s',
                $identifier,
                implode(', ', array_keys($this->resolvers))
            ));
        }

        return $this->resolvers[$identifier];
    }
1051142
public function setJoinMap(JoinMap $joinMap)
    {
        if ($this->joinMap) {
            $this->joinMap->merge($joinMap);

        } else {
            $this->joinMap = $joinMap;
        }

        return $this;
    }
1279986
public function addResolver(EmailPartResolver $resolver, $part): self
    {
        $this->resolvers[$part] = $resolver;

        return $this;
    }
411494
private function getCustomMapper(MappingInterface $mapping): ?MapperInterface
    {
        $customMapper = $mapping->getCustomMapper();

        if ($customMapper instanceof MapperAwareOperation) {
            $customMapper->setMapper($this);
        }

        return $customMapper;
    }