1 | <?php |
||
9 | class Recording |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | public $id; |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | public $title; |
||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | public $score; |
||
23 | /** |
||
24 | * @var Release[] |
||
25 | */ |
||
26 | public $releases = array(); |
||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $data; |
||
31 | |||
32 | /** |
||
33 | * @param array $recording |
||
34 | * @param MusicBrainz $brainz |
||
35 | */ |
||
36 | public function __construct(array $recording, MusicBrainz $brainz) |
||
51 | |||
52 | /** |
||
53 | * @param array $releases |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function setReleases(array $releases) |
||
65 | |||
66 | /** |
||
67 | * @return int |
||
68 | */ |
||
69 | public function getScore() |
||
73 | |||
74 | /** |
||
75 | * @throws Exception |
||
76 | * @return array |
||
77 | */ |
||
78 | public function getReleaseDates() |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getId() |
||
104 | |||
105 | /** |
||
106 | * @return Artist |
||
107 | */ |
||
108 | public function getArtist() |
||
121 | |||
122 | /** |
||
123 | * @param string $format |
||
124 | * |
||
125 | * @return int|string |
||
126 | */ |
||
127 | public function getLength($format = 'int') |
||
141 | } |
||
142 |
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: