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 |
||
| 24 | View Code Duplication | class CreateTransactionCommand extends Command implements CommandRequiresCapCheckInterface |
|
| 25 | { |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var EE_Checkout $checkout |
||
| 29 | */ |
||
| 30 | protected $checkout; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var array $transaction_details |
||
| 34 | */ |
||
| 35 | protected $transaction_details; |
||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | /** |
||
| 40 | * CreateTransactionCommand constructor. |
||
| 41 | * |
||
| 42 | * @param EE_Checkout $checkout |
||
| 43 | * @param array $transaction_details |
||
| 44 | */ |
||
| 45 | public function __construct(EE_Checkout $checkout = null, array $transaction_details = array()) |
||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | /** |
||
| 54 | * @return CapCheckInterface |
||
| 55 | * @throws InvalidDataTypeException |
||
| 56 | */ |
||
| 57 | public function getCapCheck() |
||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | /** |
||
| 71 | * @return EE_Checkout |
||
| 72 | */ |
||
| 73 | public function checkout() |
||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | /** |
||
| 81 | * @return array |
||
| 82 | */ |
||
| 83 | public function transactionDetails() |
||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | } |
||
| 91 | // End of file CreateTransactionCommand.php |
||
| 92 | // Location: EventEspresso\core\services\commands\transaction/CreateTransactionCommand.php |