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__)).'/../libs/httpful/bootstrap.php'); |
||
| 6 | } |
||
| 7 | |||
| 8 | class FlipsideAPIUser extends User |
||
| 9 | { |
||
| 10 | private $userData; |
||
| 11 | private $groupData = null; |
||
| 12 | private $apiUrl = 'https://profiles.burningflipside.com/api/v1'; |
||
| 13 | |||
| 14 | public function __construct($data = false, $apiUrl = false) |
||
| 15 | { |
||
| 16 | if(($data !== false) && !isset($data['extended'])) |
||
| 17 | { |
||
| 18 | //Generic user object |
||
| 19 | //TODO get from API |
||
| 20 | } |
||
| 21 | else |
||
| 22 | { |
||
| 23 | if(isset($data['extended'])) |
||
| 24 | { |
||
| 25 | $this->userData = $data['extended']; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | if($apiUrl !== false) |
||
| 29 | { |
||
| 30 | $this->apiUrl = $apiUrl; |
||
|
0 ignored issues
–
show
|
|||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | public function isInGroupNamed($name) |
||
| 35 | { |
||
| 36 | if($this->groupData === null) |
||
| 37 | { |
||
| 38 | $resp = \Httpful\Request::get($this->apiUrl.'/users/me/groups')->authenticateWith($this->userData->uid, $this->userData->userPassword)->send(); |
||
| 39 | if($resp->hasErrors()) |
||
| 40 | { |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | $this->groupData = $resp->body; |
||
| 44 | } |
||
| 45 | $count = count($this->groupData); |
||
| 46 | for($i = 0; $i < $count; $i++) |
||
| 47 | { |
||
| 48 | if($this->groupData[$i]->cn === $name) |
||
| 49 | { |
||
| 50 | return true; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | return false; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function __get($propName) |
||
| 57 | { |
||
| 58 | if($this->userData === null) |
||
| 59 | { |
||
| 60 | return parent::__get($propName); |
||
| 61 | } |
||
| 62 | $propName = strtolower($propName); |
||
| 63 | return $this->userData->{$propName}; |
||
| 64 | } |
||
| 65 | |||
| 66 | public function __set($propName, $value) |
||
| 67 | { |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.