| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * SocialConnect project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @author: Patsura Dmitry https://github.com/ovr <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | namespace SocialConnect\OAuth1\Provider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SocialConnect\Common\Http\Client\Client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SocialConnect\Provider\AccessTokenInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use SocialConnect\Provider\Exception\InvalidResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use SocialConnect\OAuth1\AbstractProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use SocialConnect\Common\Entity\User; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use SocialConnect\Common\Hydrator\ObjectMap; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class Px500 extends AbstractProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     const NAME = 'px500'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     public function getBaseUri() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         return 'https://api.500px.com/v1/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     public function getAuthorizeUri() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         return 'https://api.500px.com/v1/oauth/authorize'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function getRequestTokenUri() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         return 'https://api.500px.com/v1/oauth/request_token'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function getRequestTokenAccessUri() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         return 'https://api.500px.com/v1/oauth/access_token'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         return self::NAME; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     public function getIdentity(AccessTokenInterface $accessToken) | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         $this->consumerToken = $accessToken; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |         $parameters = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |             'oauth_consumer_key' => $this->consumer->getKey(), | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |             'oauth_token' => $accessToken->getToken() | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |         $response = $this->oauthRequest( | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |             $this->getBaseUri() . 'users', | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             Client::GET, | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |             $parameters | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |         if (!$response->isSuccess()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |             throw new InvalidResponse( | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |                 'API response with error code', | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |                 $response | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |         $result = $response->json(); | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |         if (!$result) { | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |             throw new InvalidResponse( | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |                 'API response is not a valid JSON object', | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |                 $response | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         if (!isset($result->user) || !$result->user) { | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |             throw new InvalidResponse( | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |                 'API response without user inside JSON', | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |                 $response | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |         $hydrator = new ObjectMap( | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |                 'id' => 'id', | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |                 'name' => 'name', | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |             ] | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |         return $hydrator->hydrate(new User(), $result->user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 110 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 111 |  |  |  | 
            
                        
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..