BurningFlipside /
CommonCode
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace Auth; |
||
| 3 | if(!class_exists('Httpful\Request')) |
||
| 4 | { |
||
| 5 | require(realpath(dirname(__FILE__)).'/../vendor/autoload.php'); |
||
| 6 | } |
||
| 7 | |||
| 8 | class FlipsideAPIUser extends User |
||
| 9 | { |
||
| 10 | private $userData; |
||
| 11 | private $groupData = null; |
||
| 12 | private $profilesUrl; |
||
| 13 | private $apiUrl; |
||
| 14 | |||
| 15 | public function __construct($data = false, $apiUrl = false) |
||
| 16 | { |
||
| 17 | $this->settings = \Settings::getInstance(); |
||
|
0 ignored issues
–
show
|
|||
| 18 | $this->profilesUrl = $this->settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com/'); |
||
|
0 ignored issues
–
show
The property
settings does not exist on object<Auth\FlipsideAPIUser>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 19 | $this->apiUrl = $this->profilesUrl.'api/v1'; |
||
| 20 | |||
| 21 | View Code Duplication | if(($data !== false) && !isset($data['extended'])) |
|
| 22 | { |
||
| 23 | //Generic user object |
||
| 24 | //TODO get from API |
||
| 25 | } |
||
| 26 | else |
||
| 27 | { |
||
| 28 | if(isset($data['extended'])) |
||
| 29 | { |
||
| 30 | $this->userData = $data['extended']; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | if($apiUrl !== false) |
||
| 34 | { |
||
| 35 | $this->apiUrl = $apiUrl; |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | public function isInGroupNamed($name) |
||
| 40 | { |
||
| 41 | if($this->groupData === null) |
||
| 42 | { |
||
| 43 | $resp = \Httpful\Request::get($this->apiUrl.'/users/me/groups')->authenticateWith($this->userData->uid, $this->userData->userPassword)->send(); |
||
| 44 | if($resp->hasErrors()) |
||
| 45 | { |
||
| 46 | return false; |
||
| 47 | } |
||
| 48 | $this->groupData = $resp->body; |
||
| 49 | } |
||
| 50 | $count = count($this->groupData); |
||
| 51 | for($i = 0; $i < $count; $i++) |
||
| 52 | { |
||
| 53 | if($this->groupData[$i]->cn === $name) |
||
| 54 | { |
||
| 55 | return true; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | return false; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function __get($propName) |
||
| 62 | { |
||
| 63 | if($this->userData === null) |
||
| 64 | { |
||
| 65 | return parent::__get($propName); |
||
| 66 | } |
||
| 67 | $propName = strtolower($propName); |
||
| 68 | return $this->userData->{$propName}; |
||
| 69 | } |
||
| 70 | |||
| 71 | public function __set($propName, $value) |
||
| 72 | { |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.