| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace juniorb2ss\DeathByCaptcha; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use GuzzleHttp\Client as GuzzleClient; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use GuzzleHttp\ClientInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use GuzzleHttp\Psr7\Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use juniorb2ss\DeathByCaptcha\Abstracts\HttpDeathByCaptchaAbstract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use juniorb2ss\DeathByCaptcha\Interfaces\AccountInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use juniorb2ss\DeathByCaptcha\Interfaces\DeathByCaptchaInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use juniorb2ss\DeathByCaptcha\Interfaces\ReportInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use juniorb2ss\DeathByCaptcha\Interfaces\ResolveInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use juniorb2ss\DeathByCaptcha\Interfaces\StatusInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use juniorb2ss\DeathByCaptcha\Services\AccountService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use juniorb2ss\DeathByCaptcha\Services\ImageService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use juniorb2ss\DeathByCaptcha\Services\ReportService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use juniorb2ss\DeathByCaptcha\Services\ResolveService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use juniorb2ss\DeathByCaptcha\Services\StatusService; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | class DeathByCaptcha extends HttpDeathByCaptchaAbstract implements DeathByCaptchaInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |      * URL do serviço | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     const API_URL = 'http://api.dbcapi.me/api/'; | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      * API Version | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     const API_VERSION = 'DBC/PHP v5'; | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * Request DEFAULT TIMEOUT | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     const DEFAULT_TIMEOUT = 60; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      * @param string                $username | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * @param string                $password | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * @param ClientInterface|null  $client | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * @param AccountInterface|null $account | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      * @param StatusInterface|null  $status | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 81 |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         string $username, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         string $password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 81 |  |         $this->username = $username; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 81 |  |         $this->password = $password; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 81 |  |         $this->client = new GuzzleClient; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 81 |  |         $this->account = new AccountService; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 81 |  |         $this->status = new StatusService; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 81 |  |         $this->report = new ReportService; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 81 |  |         $this->resolve = new ResolveService; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 56 | 81 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 81 |  |     public function setHttpClient(ClientInterface $client) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 81 |  |         $this->client = $client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 81 |  |         return $this; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 39 |  |     public function account(): AccountInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 39 |  |         $response = $this->accountRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 24 |  |         return $this->account | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 24 |  |                     ->setResponse($response); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 18 |  |     public function status(): StatusInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 18 |  |         $response = $this->statusRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 18 |  |         return $this->status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 18 |  |                     ->setResponse($response); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 3 |  |     public function report(int $id): ReportInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 3 |  |         $response = $this->captchAsIncorrect($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 3 |  |         return $this->report | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 3 |  |                     ->setResponse($response); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 21 |  |     public function resolve($captcha): ResolveInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         // If passed captcha id, retrieve captcha text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 21 |  |         if (is_int($captcha)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 6 |  |             $response = $this->retrieveCaptcha($captcha); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 15 |  |             $image = ImageService::base64From($captcha); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 12 |  |             $response = $this->uploadCaptcha($image); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 6 |  |         return $this->resolve | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 6 |  |                     ->setResponse($response); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     public function resolveV2(string $mix, string $url = null): ResolveInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         if (is_null($url)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $response = $this->retrieveCaptcha($mix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             $response = $this->sendReCaptchaV2($mix, $url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         return $this->resolve | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                     ->setResponse($response); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 114 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 115 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 116 |  |  |  | 
            
                        
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.