Code Duplication    Length = 21-21 lines in 2 locations

Persister/Persister.php 2 locations

@@ 95-115 (lines=21) @@
92
     *
93
     * @throws Exception
94
     */
95
    protected function persistOneToOneRelations(EntityInterface $entity)
96
    {
97
        $joinData = array();
98
        $relations = $entity->getOneToOneRelations();
99
        foreach ($relations as $relation) {
100
            $oneToOne = $this->relationFactory->create(DataMapper::RELATION_ONE_TO_ONE, $relation);
101
            $entity = $this->entityFactory->create($oneToOne->getEntity());
102
            $id = $this->persistRecursive($entity);
103
            $joinVal = $entity->getProperty($oneToOne->getJoinColumnReferencedColumnName());
104
            $joinData[$oneToOne->getJoinColumnName()] = !is_null($joinVal)
105
                ? $joinVal
106
                : $this->provider->getColumnValueWhere(
107
                    $oneToOne->getTable(),
108
                    $oneToOne->getJoinColumnReferencedColumnName(),
109
                    key($id),
110
                    current($id)
111
                );
112
        }
113
114
        return $joinData;
115
    }
116
117
    /**
118
     * Persist manyToOne relations
@@ 126-146 (lines=21) @@
123
     *
124
     * @throws Exception
125
     */
126
    protected function persistManyToOneRelations(EntityInterface $entity)
127
    {
128
        $joinData = array();
129
        $relations = $entity->getManyToOneRelations();
130
        foreach ($relations as $relation) {
131
            $manyToOne = $this->relationFactory->create(DataMapper::RELATION_MANY_TO_ONE, $relation);
132
            $entity = $this->entityFactory->create($manyToOne->getEntity());
133
            $id = $this->persistRecursive($entity);
134
            $joinVal = $entity->getProperty($manyToOne->getJoinColumnReferencedColumnName());
135
            $joinData[$manyToOne->getJoinColumnName()] = !is_null($joinVal)
136
                ? $joinVal
137
                : $this->provider->getColumnValueWhere(
138
                    $manyToOne->getTable(),
139
                    $manyToOne->getJoinColumnReferencedColumnName(),
140
                    key($id),
141
                    current($id)
142
                );
143
        }
144
145
        return $joinData;
146
    }
147
148
    /**
149
     * @param EntityInterface $entity