CustomerViewFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 13
rs 9.9666
c 1
b 0
f 0
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