Code Duplication    Length = 26-26 lines in 2 locations

Normalizer/AssociationNormalizer.php 1 location

@@ 42-67 (lines=26) @@
39
        $normalizedAssociations['sku'] = $sku;
40
        $normalizedAssociations['family'] = $product->getFamily()->getCode();
41
        $normalizedAssociations['associations'] = [];
42
        foreach ($product->getAssociations() as $association) {
43
            $associationCode = $association->getAssociationType()->getCode();
44
45
            if ($association->getGroups()->count(
46
              ) > 0 || $association->getProducts()->count() > 0
47
            ) {
48
49
                /**@var Product $product * */
50
                $normalizedAssociations['associations'][$associationCode] = [
51
                  'type'     => null,
52
                  'groups'   => [],
53
                  'products' => [],
54
                ];
55
56
                $normalizedAssociations['associations'][$associationCode]['type'] = $associationCode;
57
                foreach ($association->getGroups() as $group) {
58
                    $normalizedAssociations['associations'][$associationCode]['groups'][] = $group->getCode(
59
                    );
60
                }
61
                foreach ($association->getProducts() as $product) {
62
                    $normalizedAssociations['associations'][$associationCode]['products'][] = $product->getValue(
63
                      $identifierAttributeCode
64
                    )->getData();
65
                }
66
            }
67
        }
68
69
        return $normalizedAssociations;
70
    }

Normalizer/ProductNormalizer.php 1 location

@@ 172-197 (lines=26) @@
169
        $identifierAttributeCode = $this->productManager->getIdentifierAttribute(
170
        )->getCode();
171
       /** @var Group $group */
172
       foreach ($product->getAssociations() as $association) {
173
           $associationCode = $association->getAssociationType()->getCode();
174
175
           if ($association->getGroups()->count(
176
             ) > 0 || $association->getProducts()->count() > 0
177
           ) {
178
179
               /**@var Product $product * */
180
               $drupalProduct['associations'][$associationCode] = [
181
                 'type'     => null,
182
                 'groups'   => [],
183
                 'products' => [],
184
               ];
185
186
               $drupalProduct['associations'][$associationCode]['type'] = $associationCode;
187
               foreach ($association->getGroups() as $group) {
188
                   $drupalProduct['associations'][$associationCode]['groups'][] = $group->getCode(
189
                   );
190
               }
191
               foreach ($association->getProducts() as $product) {
192
                   $drupalProduct['associations'][$associationCode]['products'][] = $product->getValue(
193
                     $identifierAttributeCode
194
                   )->getData();
195
               }
196
           }
197
       }
198
    }
199
200
    /**