1 | <?php |
||
18 | class Track extends TrackEndpoint implements IMusicServiceEndpoint |
||
19 | { |
||
20 | const DATA_SOURCE = 'vocadb'; |
||
21 | |||
22 | protected $parent; |
||
23 | |||
24 | /** |
||
25 | * @param $apiService |
||
26 | * |
||
27 | * @return Track |
||
28 | */ |
||
29 | public function setParent($apiService) |
||
35 | |||
36 | /** |
||
37 | * Transform single item to model |
||
38 | * |
||
39 | * @param VocaDBTrackModel $raw |
||
40 | * |
||
41 | * @return BaseModel |
||
42 | */ |
||
43 | public function transformSingle($raw) |
||
44 | { |
||
45 | $object = new TrackModel(); |
||
46 | $object |
||
47 | ->setId($raw->getId()) |
||
48 | ->setName($raw->getName()) |
||
49 | ->setDataSource(self::DATA_SOURCE) |
||
50 | ->setRawData($raw); |
||
51 | |||
52 | return $object; |
||
53 | |||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Transform collection to models |
||
58 | * |
||
59 | * @param $raw |
||
60 | * |
||
61 | * @return ArrayCollection |
||
62 | */ |
||
63 | public function transformCollection($raw) |
||
64 | { |
||
65 | $collection = new ArrayCollection(); |
||
66 | foreach ($raw->collection as $artist) { |
||
67 | $collection->add($this->transformSingle($artist)); |
||
68 | } |
||
69 | |||
70 | return $collection; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Transform to models |
||
75 | * |
||
76 | * @param $raw |
||
77 | * |
||
78 | * @return ArrayCollection |
||
79 | */ |
||
80 | public function transform($raw) |
||
81 | { |
||
82 | return $this->transformCollection($raw); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return mixed |
||
87 | */ |
||
88 | public function getParent() |
||
92 | |||
93 | /** |
||
94 | * @param $guid |
||
95 | * |
||
96 | * @return ArrayCollection |
||
97 | */ |
||
98 | public function getByGuid($guid, $complete = true) |
||
102 | |||
103 | public function getByName($name, $complete = true) |
||
104 | { |
||
105 | return $this->transform(parent::getByName($name, $complete)); |
||
107 | } |
||
108 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.