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 | class CRLDistributionPointsExtension extends Extension implements \Countable, |
||
|
|
|||
| 16 | \IteratorAggregate |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Distribution points. |
||
| 20 | * |
||
| 21 | * @var DistributionPoint[] $_distributionPoints |
||
| 22 | */ |
||
| 23 | protected $_distributionPoints; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Constructor |
||
| 27 | * |
||
| 28 | * @param bool $critical |
||
| 29 | * @param DistributionPoint ...$distribution_points |
||
| 30 | */ |
||
| 31 | 7 | public function __construct($critical, |
|
| 36 | |||
| 37 | 7 | View Code Duplication | protected static function _fromDER($data, $critical) { |
| 50 | |||
| 51 | 4 | View Code Duplication | protected function _valueASN1() { |
| 61 | |||
| 62 | /** |
||
| 63 | * Get distribution points. |
||
| 64 | * |
||
| 65 | * @return DistributionPoint[] |
||
| 66 | */ |
||
| 67 | 1 | public function distributionPoints() { |
|
| 70 | |||
| 71 | /** |
||
| 72 | * Get the number of distribution points. |
||
| 73 | * |
||
| 74 | * @see Countable::count() |
||
| 75 | * @return int |
||
| 76 | */ |
||
| 77 | 1 | public function count() { |
|
| 80 | |||
| 81 | /** |
||
| 82 | * Get iterator for distribution points. |
||
| 83 | * |
||
| 84 | * @see IteratorAggregate::getIterator() |
||
| 85 | * @return \ArrayIterator |
||
| 86 | */ |
||
| 87 | 3 | public function getIterator() { |
|
| 90 | } |
||
| 91 |