PimCatalogTextNormalizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 17 3
1
<?php
2
3
namespace Actualys\Bundle\DrupalCommerceConnectorBundle\Normalizer\ProductValue;
4
5
use Pim\Bundle\CatalogBundle\Model\ProductValue;
6
7
/**
8
 * Class PimCatalogText
9
 *
10
 * @package Actualys\Bundle\DrupalCommerceConnectorBundle\Normalizer
11
 */
12
class PimCatalogTextNormalizer implements ProductValueNormalizerInterface
13
{
14
    /**
15
     * @param array        $drupalProduct
16
     * @param ProductValue $productValue
17
     * @param string       $field
18
     * @param array        $context
19
     */
20
    public function normalize(
21
      array &$drupalProduct,
22
      $productValue,
23
      $field,
24
      array $context = array()
25
    ) {
26
        $text = $productValue->getText();
27
        if (is_null($text)) {
28
            $text = $productValue->getVarchar();
29
        }
30
        if (null !== $text) {
31
            $drupalProduct['values'][$field][$context['locale']][] = array(
32
              'type' => 'pim_catalog_text',
33
              'value' => $text,
34
            );
35
        }
36
    }
37
}
38