Adapter/PlentymarketsAdapter/ResponseParser/Product/Variation/VariationResponseParser.php
private function getBarcodes(array $variation)
    {
        static $barcodeMapping;

        if (null === $barcodeMapping) {
            $systemBarcodes = $this->itemBarcodeApi->findAll();

            foreach ($systemBarcodes as $systemBarcode) {
                $typeMapping = [
                    'GTIN_13' => Barcode::TYPE_GTIN13,
                    'GTIN_128' => Barcode::TYPE_GTIN128,
                    'UPC' => Barcode::TYPE_UPC,
                    'ISBN' => Barcode::TYPE_ISBN,
                ];

                if (array_key_exists($systemBarcode['type'], $typeMapping)) {
                    $barcodeMapping[$systemBarcode['id']] = $typeMapping[$systemBarcode['type']];
                }
            }

            $barcodeMapping = array_filter($barcodeMapping);
        }

        $barcodes = array_filter($variation['variationBarcodes'], function (array $barcode) use ($barcodeMapping) {
            return array_key_exists($barcode['barcodeId'], $barcodeMapping);
        });

        $barcodes = array_map(function (array $barcode) use ($barcodeMapping) {
            $barcodeObject = new Barcode();
            $barcodeObject->setType($barcodeMapping[$barcode['barcodeId']]);
            $barcodeObject->setCode($barcode['code']);

            return $barcodeObject;
        }, $barcodes);

        return $barcodes;
    }
private function getBarcodes(array $variation)
    {
        static $barcodeMapping;

        if (null === $barcodeMapping) {
            $systemBarcodes = $this->itemBarcodeApi->findAll();

            foreach ($systemBarcodes as $systemBarcode) {
                $typeMapping = [
                    'GTIN_13' => Barcode::TYPE_GTIN13,
                    'GTIN_128' => Barcode::TYPE_GTIN128,
                    'UPC' => Barcode::TYPE_UPC,
                    'ISBN' => Barcode::TYPE_ISBN,
                ];

                if (array_key_exists($systemBarcode['type'], $typeMapping)) {
                    $barcodeMapping[$systemBarcode['id']] = $typeMapping[$systemBarcode['type']];
                }
            }

            $barcodeMapping = array_filter($barcodeMapping);
        }

        $barcodes = array_filter($variation['variationBarcodes'], function (array $barcode) use ($barcodeMapping) {
            return array_key_exists($barcode['barcodeId'], $barcodeMapping);
        });

        $barcodes = array_map(function (array $barcode) use ($barcodeMapping) {
            $barcodeObject = new Barcode();
            $barcodeObject->setType($barcodeMapping[$barcode['barcodeId']]);
            $barcodeObject->setCode($barcode['code']);

            return $barcodeObject;
        }, $barcodes);

        return $barcodes;
    }
private function getBarcodes ( array $ variation ) { static $ barcodeMapping ; if ( null === $ barcodeMapping ) { $ systemBarcodes = $ this -> itemBarcodeApi -> findAll ( ) ; foreach ( $ systemBarcodes as $ systemBarcode ) { $ typeMapping = [ 'GTIN_13' => Barcode :: TYPE_GTIN13 , 'GTIN_128' => Barcode :: TYPE_GTIN128 , 'UPC' => Barcode :: TYPE_UPC , 'ISBN' => Barcode :: TYPE_ISBN , ] ; if ( array_key_exists ( $ systemBarcode [ 'type' ] , $ typeMapping ) ) { $ barcodeMapping [ $ systemBarcode [ 'id' ] ] = $ typeMapping [ $ systemBarcode [ 'type' ] ] ; } } $ barcodeMapping = array_filter ( $ barcodeMapping ) ; } $ barcodes = array_filter ( $ variation [ 'variationBarcodes' ] , function ( array $ barcode ) use ( $ barcodeMapping ) { return array_key_exists ( $ barcode [ 'barcodeId' ] , $ barcodeMapping ) ; } ) ; $ barcodes = array_map ( function ( array $ barcode ) use ( $ barcodeMapping ) { $ barcodeObject = new Barcode ( ) ; $ barcodeObject -> setType ( $ barcodeMapping [ $ barcode [ 'barcodeId' ] ] ) ; $ barcodeObject -> setCode ( $ barcode [ 'code' ] ) ; return $ barcodeObject ; } , $ barcodes ) ; return $ barcodes ; }
@param array $variation

@return Barcode[]
@param array $variation