Passed
Push — develop ( 6aee1f...577144 )
by Laurent
01:44
created

Company::toModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 14
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Administration\Infrastructure\Persistence\DoctrineOrm\Entities;
15
16
use Administration\Domain\Company\Model\Company as CompanyModel;
17
use Core\Domain\Common\Model\VO\ContactUuid;
18
use Core\Domain\Common\Model\VO\EmailField;
19
use Core\Domain\Common\Model\VO\NameField;
20
use Core\Domain\Common\Model\VO\PhoneField;
21
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
23
/**
24
 * @ORM\Table(name="company")
25
 * @ORM\Entity(repositoryClass="Administration\Infrastructure\Persistence\DoctrineOrm\Repositories\DoctrineCompanyRepository")
26
 */
27
class Company extends Contact
28
{
29
    public function __construct(Contact $contact)
30
    {
31
        parent::__construct(
32
            $contact->uuid,
33
            $contact->companyName,
34
            $contact->address,
35
            $contact->zipCode,
36
            $contact->town,
37
            $contact->country,
38
            $contact->phone,
39
            $contact->facsimile,
40
            $contact->email,
41
            $contact->contactName,
42
            $contact->cellphone,
43
            $contact->slug
44
        );
45
    }
46
47
    public static function fromModel(CompanyModel $companyModel): self
48
    {
49
        $contact = Contact::create(
50
            $companyModel->uuid(),
51
            $companyModel->companyName(),
52
            $companyModel->address(),
53
            $companyModel->zipCode(),
54
            $companyModel->town(),
55
            $companyModel->country(),
56
            $companyModel->phone(),
57
            $companyModel->facsimile(),
58
            $companyModel->email(),
59
            $companyModel->contactName(),
60
            $companyModel->cellphone(),
61
            $companyModel->slug()
62
        );
63
64
        return new self($contact);
65
    }
66
67
    public static function toModel(self $company): CompanyModel
68
    {
69
        return CompanyModel::create(
70
            ContactUuid::fromString($company->getUuid()),
71
            NameField::fromString($company->getCompanyName()),
72
            $company->getAddress(),
73
            $company->getZipCode(),
74
            $company->getTown(),
75
            $company->getCountry(),
76
            PhoneField::fromString($company->getPhone()),
77
            PhoneField::fromString($company->getFacsimile()),
78
            EmailField::fromString($company->getEmail()),
79
            $company->getContactName(),
80
            PhoneField::fromString($company->getCellphone())
81
        );
82
    }
83
}
84