These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace vfalies\tmdb\Results; |
||
4 | |||
5 | use vfalies\tmdb\Abstracts\Results; |
||
6 | use vfalies\tmdb\Tmdb; |
||
7 | use vfalies\tmdb\Interfaces\Results\CollectionResultsInterface; |
||
8 | use vfalies\tmdb\Traits\ElementTrait; |
||
9 | |||
10 | class Collection extends Results implements CollectionResultsInterface |
||
11 | { |
||
12 | use ElementTrait; |
||
13 | |||
14 | protected $name = null; |
||
15 | protected $poster_path = null; |
||
16 | protected $backdrop_path = null; |
||
17 | |||
18 | /** |
||
19 | * Constructor |
||
20 | * @param \vfalies\tmdb\Tmdb $tmdb |
||
21 | * @param \stdClass $result |
||
22 | */ |
||
23 | 3 | public function __construct(Tmdb $tmdb, \stdClass $result) |
|
24 | { |
||
25 | 3 | parent::__construct($tmdb, $result); |
|
26 | |||
27 | // Populate data |
||
28 | 3 | $this->id = $this->data->id; |
|
0 ignored issues
–
show
|
|||
29 | 3 | $this->name = $this->data->name; |
|
30 | 3 | $this->poster_path = $this->data->poster_path; |
|
31 | 3 | $this->backdrop_path = $this->data->backdrop_path; |
|
32 | 3 | } |
|
33 | |||
34 | /** |
||
35 | * Get collection ID |
||
36 | * @return int |
||
37 | */ |
||
38 | 1 | public function getId() |
|
39 | { |
||
40 | 1 | return (int) $this->id; |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Get collection name |
||
45 | * @return string |
||
46 | */ |
||
47 | 1 | public function getTitle() |
|
48 | { |
||
49 | 1 | return $this->name; |
|
50 | } |
||
51 | } |
||
52 |
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: