| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the GesdinetJWTRefreshTokenBundle package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Gesdinet <http://www.gesdinet.com/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Gesdinet\JWTRefreshTokenBundle\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Symfony\Component\Console\Command\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Symfony\Component\Console\Input\InputArgument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Symfony\Component\Console\Input\InputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\Console\Output\OutputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Class ClearInvalidRefreshTokensCommand. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class RevokeRefreshTokenCommand extends Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected static $defaultName = 'gesdinet:jwt:revoke'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 5 |  |     private $refreshTokenManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 5 |  |     public function __construct(RefreshTokenManagerInterface $refreshTokenManager) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 5 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 5 |  |         parent::__construct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 5 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 5 |  |         $this->refreshTokenManager = $refreshTokenManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 5 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 5 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @see Command | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     protected function configure() | 
            
                                                                        
                            
            
                                    
            
            
                | 40 | 2 |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         $this | 
            
                                                                        
                            
            
                                    
            
            
                | 42 | 2 |  |             ->setDescription('Revoke a refresh token') | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |             ->addArgument('refresh_token', InputArgument::REQUIRED, 'The refresh token to revoke'); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 | 2 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 2 |  |      * @see Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     protected function execute(InputInterface $input, OutputInterface $output) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $refreshTokenParam = $input->getArgument('refresh_token'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |         $refreshToken = $this->refreshTokenManager->get($refreshTokenParam); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |         if (null === $refreshToken) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 1 |  |             $output->writeln(sprintf('<error>Not Found:</error> Refresh Token <comment>%s</comment> doesn\'t exists', $refreshTokenParam)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             return -1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->refreshTokenManager->delete($refreshToken); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $output->writeln(sprintf('Revoke <comment>%s</comment>', $refreshToken->getRefreshToken())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |  | 
            
                        
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.