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 |
||
| 5 | abstract class RsaSsaPkcs implements AsymmetricInterface |
||
| 6 | { |
||
| 7 | public function __construct() |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @throws \RuntimeException |
||
| 14 | */ |
||
| 15 | public function ensureSupport() |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return array |
||
| 30 | */ |
||
| 31 | private function getSslErrors() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param string $value |
||
| 44 | * @param string|resource $privateKey |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | View Code Duplication | public function sign($value, $privateKey) |
|
| 57 | |||
| 58 | /** |
||
| 59 | * @param string $value |
||
| 60 | * @param string $signature |
||
| 61 | * @param string|resource $publicKey |
||
| 62 | * @return boolean |
||
| 63 | */ |
||
| 64 | View Code Duplication | public function verify($value, $signature, $publicKey) |
|
| 74 | |||
| 75 | /** |
||
| 76 | * @return integer |
||
| 77 | */ |
||
| 78 | abstract protected function getAlgorithm(); |
||
| 79 | } |
||
| 80 |