Lines
91.66%
11 / 12
Functions and Methods
85.71%
6 / 7
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| District | 91.66% | 11 / 12 | 85.71% | 6 / 7 | 7.03 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | |||||
| getId | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| getName | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| getArea | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| getPopulation | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| getCity | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| update | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Districts\Core\Domain; | |
| 6 | ||
| 7 | use Doctrine\ORM\Mapping as ORM; | |
| 8 | ||
| 9 | #[ORM\Entity] | |
| 10 | #[ORM\Table(name: "districts")] | |
| 11 | #[ORM\UniqueConstraint(name: "districts_city_id_name", columns: ["city_id", "name"])] | |
| 12 | class District | |
| 13 | { | |
| 14 | #[ORM\Id] | |
| 15 | #[ORM\Column(type: "integer")] | |
| 16 | #[ORM\GeneratedValue] | |
| 17 | private int $id; | |
| 18 | ||
| 19 | #[ORM\Embedded(class: Name::class, columnPrefix: false)] | |
| 20 | private Name $name; | |
| 21 | ||
| 22 | #[ORM\Embedded(class: Area::class, columnPrefix: false)] | |
| 23 | private Area $area; | |
| 24 | ||
| 25 | #[ORM\Embedded(class: Population::class, columnPrefix: false)] | |
| 26 | private Population $population; | |
| 27 | ||
| 28 | #[ORM\ManyToOne(targetEntity: City::class, inversedBy: "districts")] | |
| 29 | #[ORM\JoinColumn(nullable: false)] | |
| 30 | private City $city; | |
| 31 | ||
| 32 | public function __construct(City $city, Name $name, Area $area, Population $population) | |
| 33 | { | |
| 34 | $this->city = $city; | |
| 35 | $this->name = $name; | |
| 36 | $this->area = $area; | |
| 37 | $this->population = $population; | |
| 38 | } | |
| 39 | ||
| 40 | public function getId(): int | |
| 41 | { | |
| 42 | return $this->id; | |
| 43 | } | |
| 44 | ||
| 45 | public function getName(): Name | |
| 46 | { | |
| 47 | return $this->name; | |
| 48 | } | |
| 49 | ||
| 50 | public function getArea(): Area | |
| 51 | { | |
| 52 | return $this->area; | |
| 53 | } | |
| 54 | ||
| 55 | public function getPopulation(): Population | |
| 56 | { | |
| 57 | return $this->population; | |
| 58 | } | |
| 59 | ||
| 60 | public function getCity(): City | |
| 61 | { | |
| 62 | return $this->city; | |
| 63 | } | |
| 64 | ||
| 65 | public function update(Name $name, Area $area, Population $population): void | |
| 66 | { | |
| 67 | $this->name = $name; | |
| 68 | $this->area = $area; | |
| 69 | $this->population = $population; | |
| 70 | } | |
| 71 | } |