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 FreedomCore\VK\API; |
||
4 | |||
5 | use FreedomCore\VK\VKBase; |
||
6 | use FreedomCore\VK\VKException; |
||
7 | |||
8 | /** |
||
9 | * Class VKUsers |
||
10 | * @package FreedomCore\VK |
||
11 | */ |
||
12 | class VKUsers extends VKAPI { |
||
13 | |||
14 | /** |
||
15 | * API Method for this class |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $apiMethod = 'users.'; |
||
19 | |||
20 | /** |
||
21 | * Default Fields For Selection |
||
22 | */ |
||
23 | const standardFields = ['sex', 'online', 'country', 'city', 'bdate']; |
||
24 | |||
25 | /** |
||
26 | * VKUsers constructor. |
||
27 | * @param VKBase $vkObject |
||
28 | */ |
||
29 | public function __construct(VKBase $vkObject){ |
||
30 | parent::__construct($vkObject); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Returns detailed information on users |
||
35 | * @param array $usersIDs |
||
36 | * @param array $requestFields |
||
37 | * @param string $nameCase |
||
38 | * @return mixed |
||
39 | * @throws VKException |
||
40 | */ |
||
41 | public function get($usersIDs, $requestFields = self::standardFields, $nameCase = 'nom') { |
||
42 | parent::isAllowed(); |
||
0 ignored issues
–
show
|
|||
43 | if(!is_array($usersIDs)) |
||
44 | throw new VKException('First Parameters Must Be Represented By Array Of Users IDs', 1); |
||
45 | if(!is_array($requestFields)) |
||
46 | throw new VKException('Second Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
||
47 | |||
48 | $requestParameters = [ |
||
49 | 'user_ids' => implode(',',$usersIDs), |
||
50 | 'fields' => $this->returnAllowedFields($requestFields), |
||
51 | 'name_case' => $this->returnAllowedNC($nameCase) |
||
52 | ]; |
||
53 | |||
54 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Returns a list of users matching the search criteria |
||
59 | * @param string $searchQuery |
||
60 | * @param int $isOnline |
||
61 | * @param array $requestFields |
||
62 | * @param int $sortBy |
||
63 | * @param int $displayCount |
||
64 | * @return array |
||
65 | * @throws VKException |
||
66 | */ |
||
67 | public function search($searchQuery, $isOnline = 1, $requestFields = self::standardFields, $sortBy = 0, $displayCount = 5) { |
||
68 | parent::isAllowed(); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
isAllowed() instead of search() ). Are you sure this is correct? If so, you might want to change this to $this->isAllowed() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The
Loading history...
|
|||
69 | if(!is_array($requestFields)) |
||
70 | throw new VKException('Forth Parameters Must Be Represented By Array Of Fields To Be Requested', 1); |
||
71 | $requestFields = $this->returnAllowedFields($requestFields); |
||
72 | $sortBy = ($sortBy > 1 || $sortBy < 0) ? 0 : $sortBy; |
||
73 | $isOnline = ($isOnline > 1 || $isOnline < 0) ? 1 : $isOnline; |
||
74 | |||
75 | $requestParameters = [ |
||
76 | 'q' => $searchQuery, |
||
77 | 'sort' => $sortBy, |
||
78 | 'count' => $displayCount, |
||
79 | 'fields' => $requestFields, |
||
80 | 'online' => $isOnline |
||
81 | ]; |
||
82 | |||
83 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Returns information whether a user installed the application |
||
88 | * @param int $userID |
||
89 | * @return mixed |
||
90 | * @throws VKException |
||
91 | */ |
||
92 | public function isAppUser($userID){ |
||
93 | parent::isAllowed(); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
isAllowed() instead of isAppUser() ). Are you sure this is correct? If so, you might want to change this to $this->isAllowed() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The
Loading history...
|
|||
94 | $requestParameters = [ |
||
95 | 'user_id' => $userID |
||
96 | ]; |
||
97 | |||
98 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Returns a list of IDs of users and communities followed by the user |
||
103 | * @param int $userID |
||
104 | * @param int $combineResults |
||
105 | * @param array $requestFields |
||
106 | * @param int $resultCount |
||
107 | * @return mixed |
||
108 | * @throws VKException |
||
109 | */ |
||
110 | View Code Duplication | public function getSubscriptions($userID, $combineResults = 0, $requestFields = self::standardFields, $resultCount = 20){ |
|
111 | parent::isAllowed(); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
isAllowed() instead of getSubscriptions() ). Are you sure this is correct? If so, you might want to change this to $this->isAllowed() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The
Loading history...
|
|||
112 | $requestParameters = [ |
||
113 | 'user_id' => $userID, |
||
114 | 'extended' => ($combineResults > 1 || $combineResults < 0) ? 0 : $combineResults, |
||
115 | 'count' => $resultCount, |
||
116 | 'fields' => $this->returnAllowedFields($requestFields) |
||
117 | ]; |
||
118 | |||
119 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Returns a list of IDs of followers of the user in question, sorted by date added, most recent first |
||
124 | * @param int $userID |
||
125 | * @param int $setOffset |
||
126 | * @param int $displayCount |
||
127 | * @param array $requestFields |
||
128 | * @param string $nameCase |
||
129 | * @return mixed |
||
130 | * @throws VKException |
||
131 | */ |
||
132 | View Code Duplication | public function getFollowers($userID, $setOffset = 0, $displayCount = 100, $requestFields = self::standardFields, $nameCase = 'nom'){ |
|
133 | parent::isAllowed(); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
isAllowed() instead of getFollowers() ). Are you sure this is correct? If so, you might want to change this to $this->isAllowed() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The
Loading history...
|
|||
134 | $requestParameters = [ |
||
135 | 'user_id' => $userID, |
||
136 | 'offset' => $setOffset, |
||
137 | 'count' => $displayCount, |
||
138 | 'fields' => $this->returnAllowedFields($requestFields), |
||
139 | 'name_case' => $this->returnAllowedNC($nameCase) |
||
140 | ]; |
||
141 | |||
142 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * Get Nearby Users Based On Current Latitude and Longitude |
||
147 | * @param float $currentLatitude |
||
148 | * @param float $currentLongitude |
||
149 | * @param int $setTimeOut |
||
150 | * @param int $setRadius |
||
151 | * @param array $requestFields |
||
152 | * @param string $nameCase |
||
153 | * @return mixed |
||
154 | * @throws VKException |
||
155 | */ |
||
156 | public function getNearby($currentLatitude, $currentLongitude, $setTimeOut = 7200, $setRadius = 1, $requestFields = self::standardFields, $nameCase = 'nom'){ |
||
157 | parent::isAllowed(); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
isAllowed() instead of getNearby() ). Are you sure this is correct? If so, you might want to change this to $this->isAllowed() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The
Loading history...
|
|||
158 | $requestParameters = [ |
||
159 | 'latitude' => $currentLatitude, |
||
160 | 'longitude' => $currentLongitude, |
||
161 | 'timeout' => ($setTimeOut < 0) ? 7200 : $setTimeOut, |
||
162 | 'radius' => ($setRadius < 0 || $setRadius > 4) ? 1 : $setRadius, |
||
163 | 'fields' => $this->returnAllowedFields($requestFields), |
||
164 | 'name_case' => $this->returnAllowedNC($nameCase) |
||
165 | ]; |
||
166 | |||
167 | return parent::executeQuery(__FUNCTION__, $requestParameters); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Return fields which are allowed to be used |
||
172 | * @param $fieldsArray |
||
173 | * @return mixed |
||
174 | */ |
||
175 | private function returnAllowedFields($fieldsArray){ |
||
176 | $allowedFields = ['photo_id', 'verified', 'sex', 'bdate', 'city', 'country', 'home_town', 'has_photo', 'photo_50', 'photo_100', 'photo_200_orig', 'photo_200', 'photo_400_orig', 'photo_max', 'photo_max_orig', 'online', 'lists', 'domain', 'has_mobile', 'contacts', 'site', 'education', 'universities', 'schools', 'status', 'last_seen', 'followers_count', 'common_count', 'occupation', 'nickname', 'relatives', 'relation', 'personal', 'connections', 'exports', 'wall_comments', 'activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'about', 'quotes', 'can_post', 'can_see_all_posts', 'can_see_audio', 'can_write_private_message', 'can_send_friend_request', 'is_favorite', 'is_hidden_from_feed', 'timezone', 'screen_name', 'maiden_name', 'crop_photo', 'is_friend', 'friend_status', 'career', 'military', 'blacklisted', 'blacklisted_by_me']; |
||
177 | foreach($fieldsArray as $fKey => $fValue){ if(!in_array($fValue, $allowedFields)) unset($fieldsArray[$fKey]); } |
||
178 | return implode(',', $fieldsArray); |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Return Allowed Name Case |
||
183 | * @param $ncValue |
||
184 | * @return string |
||
185 | */ |
||
186 | private function returnAllowedNC($ncValue){ |
||
187 | $allowedNameCases = ['nom', 'gen', 'dat', 'acc', 'ins', 'abl']; |
||
188 | if(!in_array($ncValue, $allowedNameCases)) $ncValue = 'nom'; |
||
189 | return $ncValue; |
||
190 | } |
||
191 | } |
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.