CustomerViewFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\Factory\Customer;
6
7
use Setono\SyliusLagersystemPlugin\View\Customer\CustomerView;
8
use Sylius\Component\Core\Model\CustomerInterface;
9
10
class CustomerViewFactory implements CustomerViewFactoryInterface
11
{
12
    /** @var string */
13
    protected $customerViewClass;
14
15
    public function __construct(string $customerViewClass)
16
    {
17
        $this->customerViewClass = $customerViewClass;
18
    }
19
20
    public function create(CustomerInterface $customer): CustomerView
21
    {
22
        /** @var CustomerView $customerView */
23
        $customerView = new $this->customerViewClass();
24
        $customerView->id = $customer->getId();
25
        $customerView->firstName = $customer->getFirstName();
26
        $customerView->lastName = $customer->getLastName();
27
        $customerView->email = $customer->getEmail();
28
        $customerView->birthday = $customer->getBirthday();
29
        $customerView->gender = $customer->getGender();
30
        $customerView->phoneNumber = $customer->getPhoneNumber();
31
32
        return $customerView;
33
    }
34
}
35