Completed
Push — 1.9 ( 66be26...482137 )
by
unknown
62:03
created

denormalize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 6
nc 1
nop 4
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\ImportExport\Serializer;
4
5
use Psr\Log\LoggerInterface;
6
7
use Oro\Bundle\ImportExportBundle\Field\FieldHelper;
8
use Oro\Bundle\ImportExportBundle\Serializer\Normalizer\DenormalizerInterface;
9
10
use OroCRM\Bundle\MagentoBundle\Provider\ChannelType;
11
12
class DefaultConfigurableEntityDenormalizer implements DenormalizerInterface
13
{
14
    /** @var FieldHelper */
15
    protected $fieldHelper;
16
17
    /** @var LoggerInterface */
18
    protected $logger;
19
20
    /**
21
     * @param FieldHelper     $fieldHelper
22
     * @param LoggerInterface $logger
23
     */
24
    public function __construct(FieldHelper $fieldHelper, LoggerInterface $logger)
25
    {
26
        $this->fieldHelper = $fieldHelper;
27
        $this->logger      = $logger;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function denormalize($data, $class, $format = null, array $context = [])
34
    {
35
        $this->logger->warning(
36
            sprintf('Invalid configuration for %s for mapping configurable entity attributes.', $class),
37
            [
38
                'data'    => $data,
39
                'context' => $context
40
            ]
41
        );
42
43
        return null;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function supportsDenormalization($data, $type, $format = null, array $context = [])
50
    {
51
        return
52
            !is_array($data) &&
53
            class_exists($type) &&
54
            $this->fieldHelper->hasConfig($type) &&
55
            !empty($context['channelType']) &&
56
            $context['channelType'] == ChannelType::TYPE;
57
    }
58
}
59