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  | 
            ||
| 15 | View Code Duplication | class DirectoryName extends GeneralName  | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 16 | { | 
            ||
| 17 | /**  | 
            ||
| 18 | * Directory name.  | 
            ||
| 19 | *  | 
            ||
| 20 | * @var Name $_dn  | 
            ||
| 21 | */  | 
            ||
| 22 | protected $_dn;  | 
            ||
| 23 | |||
| 24 | /**  | 
            ||
| 25 | * Constructor  | 
            ||
| 26 | *  | 
            ||
| 27 | * @param Name $dn  | 
            ||
| 28 | */  | 
            ||
| 29 | 45 | 	public function __construct(Name $dn) { | 
            |
| 33 | |||
| 34 | /**  | 
            ||
| 35 | *  | 
            ||
| 36 | * @param UnspecifiedType $el  | 
            ||
| 37 | * @return self  | 
            ||
| 38 | */  | 
            ||
| 39 | 29 | 	public static function fromChosenASN1(UnspecifiedType $el) { | 
            |
| 42 | |||
| 43 | /**  | 
            ||
| 44 | * Initialize from distinguished name string.  | 
            ||
| 45 | *  | 
            ||
| 46 | * @param string $str  | 
            ||
| 47 | * @return self  | 
            ||
| 48 | */  | 
            ||
| 49 | 15 | 	public static function fromDNString($str) { | 
            |
| 52 | |||
| 53 | 3 | 	public function string() { | 
            |
| 56 | |||
| 57 | /**  | 
            ||
| 58 | * Get directory name.  | 
            ||
| 59 | *  | 
            ||
| 60 | * @return Name  | 
            ||
| 61 | */  | 
            ||
| 62 | 16 | 	public function dn() { | 
            |
| 65 | |||
| 66 | 42 | 	protected function _choiceASN1() { | 
            |
| 71 | }  | 
            ||
| 72 | 
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.