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 |
||
| 39 | class PayolutionBase extends PayoneMethod |
||
| 40 | { |
||
| 41 | /* Payment method sub types */ |
||
| 42 | const METHOD_PAYOLUTION_SUBTYPE_INVOICE = 'PYV'; |
||
| 43 | const METHOD_PAYOLUTION_SUBTYPE_DEBIT = 'PYD'; |
||
| 44 | const METHOD_PAYOLUTION_SUBTYPE_INSTALLMENT = 'PYS'; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Clearingtype for PAYONE authorization request |
||
| 48 | * |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | protected $sClearingtype = 'fnc'; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Payment method group identifier |
||
| 55 | * |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | protected $sGroupName = PayoneConfig::METHOD_GROUP_PAYOLUTION; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Payment method long sub type |
||
| 62 | * |
||
| 63 | * @var string|bool |
||
| 64 | */ |
||
| 65 | protected $sLongSubType = false; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Keys that need to be assigned to the additionalinformation fields |
||
| 69 | * |
||
| 70 | * @var array |
||
| 71 | */ |
||
| 72 | protected $aAssignKeys = [ |
||
| 73 | 'telephone', |
||
| 74 | 'b2bmode', |
||
| 75 | 'trade_registry_number', |
||
| 76 | 'dateofbirth' |
||
| 77 | ]; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * PAYONE genericpayment pre_check request model |
||
| 81 | * |
||
| 82 | * @var \Payone\Core\Model\Api\Request\Genericpayment\PreCheck |
||
| 83 | */ |
||
| 84 | protected $precheckRequest; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Info instructions block path |
||
| 88 | * |
||
| 89 | * @var string |
||
| 90 | */ |
||
| 91 | protected $_infoBlockType = 'Payone\Core\Block\Info\ClearingReference'; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Constructor |
||
| 95 | * |
||
| 96 | * @param \Magento\Framework\Model\Context $context |
||
| 97 | * @param \Magento\Framework\Registry $registry |
||
| 98 | * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory |
||
| 99 | * @param \Magento\Framework\Api\AttributeValueFactory $customAttrFactory |
||
| 100 | * @param \Magento\Payment\Helper\Data $paymentData |
||
| 101 | * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig |
||
| 102 | * @param \Magento\Payment\Model\Method\Logger $logger |
||
| 103 | * @param \Payone\Core\Helper\Toolkit $toolkitHelper |
||
| 104 | * @param \Payone\Core\Helper\Shop $shopHelper |
||
| 105 | * @param \Magento\Framework\Url $url |
||
| 106 | * @param \Magento\Checkout\Model\Session $checkoutSession |
||
| 107 | * @param \Payone\Core\Model\Api\Request\Debit $debitRequest |
||
| 108 | * @param \Payone\Core\Model\Api\Request\Capture $captureRequest |
||
| 109 | * @param \Payone\Core\Model\Api\Request\Authorization $authorizationRequest |
||
| 110 | * @param \Payone\Core\Model\Api\Request\Genericpayment\PreCheck $precheckRequest |
||
| 111 | * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource |
||
| 112 | * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection |
||
| 113 | * @param array $data |
||
| 114 | */ |
||
| 115 | public function __construct( |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Return parameters specific to this payment type |
||
| 141 | * |
||
| 142 | * @param Order $oOrder |
||
| 143 | * @return array |
||
| 144 | */ |
||
| 145 | public function getPaymentSpecificParameters(Order $oOrder) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Method to trigger the Payone genericpayment request pre-check |
||
| 171 | * |
||
| 172 | * @param float $dAmount |
||
| 173 | * @param string|bool $sBirthday |
||
|
|
|||
| 174 | * @return array |
||
| 175 | * @throws LocalizedException |
||
| 176 | */ |
||
| 177 | public function sendPayonePreCheck($dAmount) |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Return long subtype |
||
| 192 | * |
||
| 193 | * @return string |
||
| 194 | */ |
||
| 195 | public function getLongSubType() |
||
| 199 | |||
| 200 | /** |
||
| 201 | * Add the checkout-form-data to the checkout session |
||
| 202 | * |
||
| 203 | * @param DataObject $data |
||
| 204 | * @return $this |
||
| 205 | */ |
||
| 206 | public function assignData(DataObject $data) |
||
| 220 | } |
||
| 221 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.