RoomResource   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 86
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A getRoom() 0 4 1
A getItem() 0 4 1
A getQuantity() 0 4 1
A reduceQuantity() 0 4 1
1
<?php
2
3
namespace Rottenwood\KingdomBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Rottenwood\KingdomBundle\Entity\Infrastructure\Item;
7
8
/**
9
 * Недобытый природный ресурс
10
 * @ORM\Table(name="rooms_items")
11
 * @ORM\Entity(repositoryClass="Rottenwood\KingdomBundle\Entity\Infrastructure\RoomResourceRepository")
12
 */
13
class RoomResource
14
{
15
16
    /**
17
     * @ORM\Column(name="id", type="integer")
18
     * @ORM\Id
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     * @var int
21
     */
22
    private $id;
23
24
    /**
25
     * Комната в которой находится ресурс
26
     * @ORM\ManyToOne(targetEntity="Room")
27
     * @ORM\JoinColumn(name="room_id", referencedColumnName="id", nullable=false)
28
     * @var Room
29
     */
30
    private $room;
31
32
    /**
33
     * Предмет ресурса
34
     * @ORM\ManyToOne(targetEntity="Rottenwood\KingdomBundle\Entity\Infrastructure\Item")
35
     * @ORM\JoinColumn(name="item_id", referencedColumnName="id", nullable=false)
36
     * @var Item
37
     */
38
    private $item;
39
40
    /**
41
     * Количество предметов
42
     * @var int
43
     * @ORM\Column(name="quantity", type="integer")
44
     */
45
    private $quantity;
46
47
    /**
48
     * @param Room $room
49
     * @param Item $item
50
     * @param int  $quantity
51
     */
52
    public function __construct(Room $room, Item $item, $quantity)
53
    {
54
        $this->room = $room;
55
        $this->item = $item;
56
        $this->quantity = $quantity;
57
    }
58
59
    /**
60
     * @return int
61
     */
62
    public function getId()
63
    {
64
        return $this->id;
65
    }
66
67
    /**
68
     * @return Room
69
     */
70
    public function getRoom()
71
    {
72
        return $this->room;
73
    }
74
75
    /**
76
     * @return Item
77
     */
78
    public function getItem()
79
    {
80
        return $this->item;
81
    }
82
83
    /**
84
     * @return int
85
     */
86
    public function getQuantity()
87
    {
88
        return $this->quantity;
89
    }
90
91
    /**
92
     * @param int $amount
93
     */
94
    public function reduceQuantity($amount)
95
    {
96
        $this->quantity -= $amount;
97
    }
98
}
99