| Conditions | 9 |
| Paths | 96 |
| Total Lines | 52 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 77 | private function updateConfig() |
||
| 78 | { |
||
| 79 | $data = static::config()->get('data'); |
||
| 80 | $transactionDate = $data['TransactionDate']; |
||
| 81 | static::config()->merge('data', [ |
||
| 82 | 'TransactionDate' => strtotime($transactionDate), |
||
| 83 | ]); |
||
| 84 | |||
| 85 | $orderID = $data['OrderID']; |
||
| 86 | if ($orderID === 'auto' || $orderID < 1) { |
||
| 87 | $lastOrderID = 0; |
||
| 88 | if ($lastOrder = Order::get()->sort('OrderID')->last()) { |
||
| 89 | $lastOrderID = $lastOrder->OrderID; |
||
| 90 | }; |
||
| 91 | static::config()->merge('data', [ |
||
| 92 | 'OrderID' => $lastOrderID + 1, |
||
| 93 | ]); |
||
| 94 | } |
||
| 95 | |||
| 96 | $email = $data['Email']; |
||
| 97 | if ($email === 'auto') { |
||
| 98 | static::config()->merge('data', [ |
||
| 99 | 'Email' => $this->generateEmail(), |
||
| 100 | ]); |
||
| 101 | } |
||
| 102 | |||
| 103 | $orderDetails = $data['OrderDetails']; |
||
| 104 | if (count($orderDetails) === 0) { |
||
| 105 | static::config()->merge('data', [ |
||
| 106 | 'OrderDetails' => [ |
||
| 107 | $this->generateOrderDetail() |
||
| 108 | ], |
||
| 109 | ]); |
||
| 110 | } |
||
| 111 | |||
| 112 | if (!array_key_exists('Salt', $data)) { |
||
| 113 | static::config()->merge('data', [ |
||
| 114 | 'Salt' => 'faGgWXUTdZ7i42lpA6cljzKeGBeUwShBSNHECwsJmt', |
||
| 115 | ]); |
||
| 116 | } |
||
| 117 | |||
| 118 | if (!array_key_exists('HashType', $data)) { |
||
| 119 | static::config()->merge('data', [ |
||
| 120 | 'HashType' => 'sha1_v2.4', |
||
| 121 | ]); |
||
| 122 | } |
||
| 123 | |||
| 124 | $data = static::config()->get('data'); |
||
| 125 | if (!array_key_exists('HashedPassword', $data)) { |
||
| 126 | $encryptor = PasswordEncryptor::create_for_algorithm($data['HashType']); |
||
| 127 | static::config()->merge('data', [ |
||
| 128 | 'HashedPassword' => $encryptor->encrypt($data['Password'], $data['Salt']), |
||
| 129 | ]); |
||
| 197 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths