Passed
Push — develop ( 577144...bf5480 )
by
unknown
01:39
created

Company::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 15
rs 9.8333
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 Company\Infrastructure\Doctrine\Entity;
15
16
use Administration\Infrastructure\Persistence\DoctrineOrm\Entities\Contact;
17
use Company\Domain\Model\Company as CompanyModel;
18
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...
19
20
/**
21
 * @ORM\Table(name="company")
22
 * @ORM\Entity(repositoryClass="Company\Infrastructure\Doctrine\Repository\CompanyRepository")
23
 */
24
class Company extends Contact
25
{
26
    public function __construct(Contact $contact)
27
    {
28
        parent::__construct(
29
            $contact->uuid,
30
            $contact->companyName,
31
            $contact->address,
32
            $contact->zipCode,
33
            $contact->town,
34
            $contact->country,
35
            $contact->phone,
36
            $contact->facsimile,
37
            $contact->email,
38
            $contact->contactName,
39
            $contact->cellphone,
40
            $contact->slug
41
        );
42
    }
43
44
    public static function fromModel(CompanyModel $companyModel): self
45
    {
46
        $contact = Contact::create(
47
            $companyModel->uuid(),
48
            $companyModel->companyName(),
49
            $companyModel->address(),
50
            $companyModel->zipCode(),
51
            $companyModel->town(),
52
            $companyModel->country(),
53
            $companyModel->phone(),
54
            $companyModel->facsimile(),
55
            $companyModel->email(),
56
            $companyModel->contactName(),
57
            $companyModel->cellphone(),
58
            $companyModel->slug()
59
        );
60
61
        return new self($contact);
62
    }
63
64
    public function update(CompanyModel $companyModel): self
65
    {
66
        $this->companyName = $companyModel->companyName();
67
        $this->address = $companyModel->address();
68
        $this->zipCode = $companyModel->zipCode();
69
        $this->town = $companyModel->town();
70
        $this->country = $companyModel->country();
71
        $this->phone = $companyModel->phone();
72
        $this->facsimile = $companyModel->facsimile();
73
        $this->email = $companyModel->email();
74
        $this->contactName = $companyModel->contactName();
75
        $this->cellphone = $companyModel->cellphone();
76
77
        return $this;
78
    }
79
}
80