Code Duplication    Length = 17-26 lines in 2 locations

lib/Subscriber/Core/MappingSubscriber.php 2 locations

@@ 147-163 (lines=17) @@
144
     * @param mixed $locale
145
     * @param array $fieldMapping
146
     */
147
    private function persistGeneric(
148
        NodeInterface $node,
149
        DocumentAccessor $accessor,
150
        $fieldName,
151
        $locale,
152
        array $fieldMapping
153
    ) {
154
        try {
155
            $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale);
156
            $value = $accessor->get($fieldName);
157
            $this->validateFieldValue($value, $fieldName, $fieldMapping);
158
            $node->setProperty($phpcrName, $value);
159
        } catch (InvalidLocaleException $ex) {
160
            // arguments unvalid no valid propertyname could be generated (e.g. no locale given for localized encoding)
161
            return;
162
        }
163
    }
164
165
    /**
166
     * @param AbstractMappingEvent $event
@@ 210-235 (lines=26) @@
207
     * @param mixed $locale
208
     * @param array $fieldMapping
209
     */
210
    private function hydrateReferenceField(
211
        NodeInterface $node,
212
        $document,
213
        DocumentAccessor $accessor,
214
        $fieldName,
215
        $locale,
216
        array $fieldMapping
217
    ) {
218
        try {
219
            $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale);
220
            $referencedNode = $node->getPropertyValueWithDefault(
221
                $phpcrName,
222
                $this->getDefaultValue($fieldMapping)
223
            );
224
225
            if ($referencedNode) {
226
                $accessor->set(
227
                    $fieldName,
228
                    $this->proxyFactory->createProxyForNode($document, $referencedNode)
229
                );
230
            }
231
        } catch (InvalidLocaleException $ex) {
232
            // arguments unvalid no valid propertyname could be generated (e.g. no locale given for localized encoding)
233
            return;
234
        }
235
    }
236
237
    /**
238
     * Hydrate "scalar" field types.