1 | <?php |
||
14 | class AbstractMeta |
||
15 | { |
||
16 | /*** Id ***/ |
||
17 | /** |
||
18 | * @return integer |
||
19 | */ |
||
20 | public function getId() |
||
24 | |||
25 | /** |
||
26 | * @param $id |
||
27 | * |
||
28 | * @return AbstractMeta |
||
29 | */ |
||
30 | public function setId($id) |
||
36 | |||
37 | /*** Key ***/ |
||
38 | /** |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getKey() |
||
45 | |||
46 | /** |
||
47 | * @param $key |
||
48 | * |
||
49 | * @return AbstractMeta |
||
50 | */ |
||
51 | public function setKey($key) |
||
57 | |||
58 | /*** Value ***/ |
||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getValue() |
||
66 | |||
67 | /** |
||
68 | * @param $value |
||
69 | * |
||
70 | * @return AbstractMeta |
||
71 | */ |
||
72 | public function setValue($value) |
||
78 | |||
79 | /*** Time created ***/ |
||
80 | /** |
||
81 | * @return \DateTime |
||
82 | */ |
||
83 | public function getTimeCreated() |
||
87 | |||
88 | /** |
||
89 | * @param \DateTime $timeCreated |
||
90 | * |
||
91 | * @return AbstractMeta |
||
92 | */ |
||
93 | public function setTimeCreated(\DateTime $timeCreated) |
||
99 | |||
100 | /*** Time updated ***/ |
||
101 | /** |
||
102 | * @return \DateTime |
||
103 | */ |
||
104 | public function getTimeUpdated() |
||
108 | |||
109 | /** |
||
110 | * @param \DateTime $timeUpdated |
||
111 | * |
||
112 | * @return AbstractMeta |
||
113 | */ |
||
114 | public function setTimeUpdated(\DateTime $timeUpdated) |
||
120 | |||
121 | /** |
||
122 | * Returns data in array |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | public function toArray() |
||
135 | |||
136 | /** |
||
137 | * Converts the key and value to string |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function __toString() |
||
155 | } |
||
156 |
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: