1 | <?php |
||
17 | class RunningBalance implements JsonSerializable |
||
18 | { |
||
19 | /** |
||
20 | * @var int |
||
21 | * |
||
22 | * @ORM\Id |
||
23 | * @ORM\Column(type="integer") |
||
24 | * @ORM\GeneratedValue(strategy="AUTO") |
||
25 | */ |
||
26 | protected $id = null; |
||
27 | |||
28 | /** |
||
29 | * @ORM\ManyToOne(targetEntity="JhUser\Entity\User") |
||
30 | */ |
||
31 | protected $user = null; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | * |
||
36 | * @ORM\Column(type="string", length=255, nullable=false) |
||
37 | */ |
||
38 | protected $balance = 0; |
||
39 | |||
40 | /** |
||
41 | * Set Defaults |
||
42 | */ |
||
43 | public function __construct() |
||
47 | |||
48 | /** |
||
49 | * @return int |
||
50 | */ |
||
51 | public function getId() |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | * @param \ZfcUser\Entity\UserInterface $user |
||
59 | * @return \JhFlexiTime\Entity\RunningBalance |
||
60 | */ |
||
61 | public function setUser(UserInterface $user) |
||
66 | |||
67 | /** |
||
68 | * @return \ZfcUser\Entity\UserInterface |
||
69 | */ |
||
70 | public function getUser() |
||
74 | |||
75 | /** |
||
76 | * @return int |
||
77 | */ |
||
78 | public function getBalance() |
||
82 | |||
83 | /** |
||
84 | * @param int $balance |
||
85 | * @return \JhFlexiTime\Entity\RunningBalance |
||
86 | */ |
||
87 | public function setBalance($balance) |
||
92 | |||
93 | /** |
||
94 | * @param float $balance |
||
95 | */ |
||
96 | public function addBalance($balance) |
||
100 | |||
101 | /** |
||
102 | * @param float $balance |
||
103 | */ |
||
104 | public function subtractBalance($balance) |
||
108 | |||
109 | /** |
||
110 | * @return array |
||
111 | * @throws \Exception |
||
112 | */ |
||
113 | public function jsonSerialize() |
||
125 | } |
||
126 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: