Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php  | 
            ||
| 23 | class Certificate implements AuthProviderInterface  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 24 | { | 
            ||
| 25 | /**  | 
            ||
| 26 | * Path to certificate.  | 
            ||
| 27 | *  | 
            ||
| 28 | * @var string  | 
            ||
| 29 | */  | 
            ||
| 30 | private $certificatePath;  | 
            ||
| 31 | |||
| 32 | /**  | 
            ||
| 33 | * Certificate secret.  | 
            ||
| 34 | *  | 
            ||
| 35 | * @var string  | 
            ||
| 36 | */  | 
            ||
| 37 | private $certificateSecret;  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * The bundle ID for app obtained from Apple developer account.  | 
            ||
| 41 | *  | 
            ||
| 42 | * @var string  | 
            ||
| 43 | */  | 
            ||
| 44 | private $appBundleId;  | 
            ||
| 45 | |||
| 46 | /**  | 
            ||
| 47 | * This provider accepts the following options:  | 
            ||
| 48 | *  | 
            ||
| 49 | * - certificate_path  | 
            ||
| 50 | * - certificate_secret  | 
            ||
| 51 | *  | 
            ||
| 52 | * @param array $options  | 
            ||
| 53 | */  | 
            ||
| 54 | private function __construct(array $options)  | 
            ||
| 60 | |||
| 61 | /**  | 
            ||
| 62 | * Create Certificate Auth provider.  | 
            ||
| 63 | *  | 
            ||
| 64 | * @param array $options  | 
            ||
| 65 | * @return Certificate  | 
            ||
| 66 | */  | 
            ||
| 67 | public static function create(array $options): Certificate  | 
            ||
| 71 | |||
| 72 | /**  | 
            ||
| 73 | * Authenticate client.  | 
            ||
| 74 | *  | 
            ||
| 75 | * @param Request $request  | 
            ||
| 76 | */  | 
            ||
| 77 | public function authenticateClient(Request $request)  | 
            ||
| 90 | |||
| 91 | /**  | 
            ||
| 92 | * Generate a correct apns-topic string  | 
            ||
| 93 | *  | 
            ||
| 94 | * @param string $pushType  | 
            ||
| 95 | * @return string  | 
            ||
| 96 | */  | 
            ||
| 97 | View Code Duplication | public function generateApnsTopic(string $pushType)  | 
            |
| 117 | }  | 
            ||
| 118 |