BuildingCost   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 79
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setCommodityId() 0 5 1
A getCommodityId() 0 3 1
A getAmount() 0 3 1
A getBuildingId() 0 3 1
A setBuildingId() 0 5 1
A getId() 0 3 1
A getHalfAmount() 0 3 1
A getCommodity() 0 3 1
A setAmount() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\GeneratedValue;
10
use Doctrine\ORM\Mapping\Id;
11
use Doctrine\ORM\Mapping\Index;
12
use Doctrine\ORM\Mapping\JoinColumn;
13
use Doctrine\ORM\Mapping\ManyToOne;
14
use Doctrine\ORM\Mapping\Table;
15
use Stu\Orm\Repository\BuildingCostRepository;
16
17
#[Table(name: 'stu_buildings_cost')]
18
#[Index(name: 'building_cost_building_idx', columns: ['buildings_id'])]
19
#[Entity(repositoryClass: BuildingCostRepository::class)]
20
class BuildingCost
21
{
22
    #[Id]
23
    #[Column(type: 'integer')]
24
    #[GeneratedValue(strategy: 'IDENTITY')]
25
    private int $id;
26
27
    #[Column(type: 'integer')]
28
    private int $buildings_id = 0;
29
30
    #[Column(type: 'integer')]
31
    private int $commodity_id = 0;
32
33
    #[Column(type: 'integer')]
34
    private int $count = 0;
35
36
    #[ManyToOne(targetEntity: Commodity::class)]
37
    #[JoinColumn(name: 'commodity_id', nullable: false, referencedColumnName: 'id', onDelete: 'CASCADE')]
38
    private Commodity $commodity;
39
40
    /**
41
     * @var Building
42
     */
43
    #[ManyToOne(targetEntity: Building::class, inversedBy: 'buildingCosts')]
44
    #[JoinColumn(name: 'buildings_id', nullable: false, referencedColumnName: 'id', onDelete: 'CASCADE')]
45
    private $building;
0 ignored issues
show
introduced by
The private property $building is not used, and could be removed.
Loading history...
46
47
    public function getId(): int
48
    {
49
        return $this->id;
50
    }
51
52
    public function getBuildingId(): int
53
    {
54
        return $this->buildings_id;
55
    }
56
57
    public function setBuildingId(int $buildingId): BuildingCost
58
    {
59
        $this->buildings_id = $buildingId;
60
61
        return $this;
62
    }
63
64
    public function getCommodityId(): int
65
    {
66
        return $this->commodity_id;
67
    }
68
69
    public function setCommodityId(int $commodityId): BuildingCost
70
    {
71
        $this->commodity_id = $commodityId;
72
73
        return $this;
74
    }
75
76
    public function getAmount(): int
77
    {
78
        return $this->count;
79
    }
80
81
    public function setAmount(int $amount): BuildingCost
82
    {
83
        $this->count = $amount;
84
85
        return $this;
86
    }
87
88
    public function getCommodity(): Commodity
89
    {
90
        return $this->commodity;
91
    }
92
93
    public function getHalfAmount(): int
94
    {
95
        return (int) ceil($this->getAmount() / 2);
96
    }
97
}
98