Passed
Pull Request — orm-management (#169)
by Laurent
03:05 queued 01:30
created

Settings::setCurrency()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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\Settings\Model\Settings as SettingsModel;
17
use Administration\Domain\Settings\Model\VO\Currency;
18
use Administration\Domain\Settings\Model\VO\Locale;
19
use Administration\Domain\Settings\Model\VO\SettingsUuid;
20
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...
21
22
/**
23
 * @ORM\Table(name="settings")
24
 * @ORM\Entity(repositoryClass="Administration\Infrastructure\Persistence\DoctrineOrm\Repositories\DoctrineSettingsRepository")
25
 */
26
class Settings
27
{
28
    /**
29
     * @ORM\Id
30
     * @ORM\Column(type="guid", name="uuid")
31
     * @ORM\GeneratedValue(strategy="NONE")
32
     */
33
    private string $uuid;
34
35
    /**
36
     * @ORM\Column(type="string", name="locale", nullable=false)
37
     */
38
    private string $locale;
39
40
    /**
41
     * @ORM\Column(type="string", name="currency", nullable=false)
42
     */
43
    private string $currency;
44
45
    public function __construct(string $uuid, string $locale, string $currency)
46
    {
47
        $this->uuid = $uuid;
48
        $this->locale = $locale;
49
        $this->currency = $currency;
50
    }
51
52
    public static function fromModel(SettingsModel $settingsModel): self
53
    {
54
        return new self(
55
            $settingsModel->uuid(),
56
            $settingsModel->locale(),
57
            $settingsModel->currency()
58
        );
59
    }
60
61
    public static function toModel(self $settings): SettingsModel
62
    {
63
        return new SettingsModel(
64
            SettingsUuid::fromString($settings->getUuid()),
65
            Locale::fromString($settings->getLocale()),
66
            Currency::fromString($settings->getCurrency())
67
        );
68
    }
69
70
    public function getUuid(): string
71
    {
72
        return $this->uuid;
73
    }
74
75
    public function setUuid(string $uuid): self
76
    {
77
        $this->uuid = $uuid;
78
79
        return $this;
80
    }
81
82
    public function getLocale(): string
83
    {
84
        return $this->locale;
85
    }
86
87
    public function setLocale(string $locale): self
88
    {
89
        $this->locale = $locale;
90
91
        return $this;
92
    }
93
94
    public function getCurrency(): string
95
    {
96
        return $this->currency;
97
    }
98
99
    public function setCurrency(string $currency): self
100
    {
101
        $this->currency = $currency;
102
103
        return $this;
104
    }
105
}
106