NormalizerGuesser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A guessNormalizer() 0 13 2
1
<?php
2
3
namespace Actualys\Bundle\DrupalCommerceConnectorBundle\Guesser;
4
5
use Actualys\Bundle\DrupalCommerceConnectorBundle\DependencyInjection\Compiler\AggregatedTaggedNormalizer;
6
use Actualys\Bundle\DrupalCommerceConnectorBundle\Guesser\Exception\GuessException;
7
8
class NormalizerGuesser
9
{
10
    /** @var AggregatedTaggedNormalizer */
11
    protected $normalizers;
12
13
    /**
14
     * @param AggregatedTaggedNormalizer $normalizer
15
     */
16
    public function __construct(
17
      AggregatedTaggedNormalizer $normalizer
18
    ) {
19
        $this->normalizers = $normalizer;
20
    }
21
22
    /**
23
     * @param $type
24
     * @param $normalizeType
25
     * @return mixed
26
     * @throws GuessException
27
     */
28
    public function guessNormalizer($type, $normalizeType)
29
    {
30
        $normalizer = $this->normalizers->getNormalizer(
31
          $type.'.'.$normalizeType
32
        );
33
        if (is_null($normalizer)) {
34
            throw new GuessException(
35
              'Type de normalizer non géré: '.$normalizeType.' pour '.$type
36
            );
37
        }
38
39
        return $normalizer;
40
    }
41
}
42