CustomerInitializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A initialize() 0 7 2
1
<?php
2
3
/*
4
 * This file is part of AppName.
5
 *
6
 * (c) Monofony
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Validator\Initializer;
13
14
use Sylius\Component\Customer\Model\CustomerInterface;
15
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
16
use Symfony\Component\Validator\ObjectInitializerInterface;
17
18
final class CustomerInitializer implements ObjectInitializerInterface
19
{
20
    /**
21
     * @var CanonicalizerInterface
22
     */
23
    private $canonicalizer;
24
25
    /**
26
     * @param CanonicalizerInterface $canonicalizer
27
     */
28
    public function __construct(CanonicalizerInterface $canonicalizer)
29
    {
30
        $this->canonicalizer = $canonicalizer;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function initialize($object)
37
    {
38
        if ($object instanceof CustomerInterface) {
39
            $emailCanonical = $this->canonicalizer->canonicalize($object->getEmail());
40
            $object->setEmailCanonical($emailCanonical);
41
        }
42
    }
43
}
44