| Conditions | 5 |
| Paths | 5 |
| Total Lines | 56 |
| Code Lines | 28 |
| 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 |
||
| 50 | public function validate(array $validationSubject) |
||
| 51 | { |
||
| 52 | $auth = $validationSubject['request']->getHeader('Authorization'); |
||
| 53 | |||
| 54 | if (empty($auth)) { |
||
| 55 | return $this->createResult( |
||
| 56 | false, |
||
| 57 | [ |
||
| 58 | 'status' => self::UNAUTHORIZED_STATUS, |
||
| 59 | 'message' => self::UNAUTHORIZED |
||
| 60 | ] |
||
| 61 | ); |
||
| 62 | } |
||
| 63 | |||
| 64 | $trackingId = $validationSubject['request']->getParam('tracking_id'); |
||
| 65 | |||
| 66 | if (empty($trackingId)) { |
||
| 67 | return $this->createResult( |
||
| 68 | false, |
||
| 69 | [ |
||
| 70 | 'status' => self::BAD_REQUEST_STATUS, |
||
| 71 | 'message' => self::BAD_REQUEST |
||
| 72 | ] |
||
| 73 | ); |
||
| 74 | } |
||
| 75 | |||
| 76 | $order = $this->orderFactory->create()->loadByIncrementId($trackingId); |
||
| 77 | |||
| 78 | if (empty($order->getEntityId())) { |
||
| 79 | return $this->createResult( |
||
| 80 | false, |
||
| 81 | [ |
||
| 82 | 'status' => self::BAD_REQUEST_STATUS, |
||
| 83 | 'message' => self::BAD_REQUEST |
||
| 84 | ] |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 88 | $b2binpay = $this->adapterFactory->create($order->getStoreId()); |
||
| 89 | |||
| 90 | $checkAuth = $b2binpay->getAuthorization(); |
||
| 91 | |||
| 92 | if ($auth !== $checkAuth) { |
||
| 93 | return $this->createResult( |
||
| 94 | false, |
||
| 95 | [ |
||
| 96 | 'status' => self::UNAUTHORIZED_STATUS, |
||
| 97 | 'message' => self::UNAUTHORIZED |
||
| 98 | ] |
||
| 99 | ); |
||
| 100 | } |
||
| 101 | |||
| 102 | return $this->createResult( |
||
| 103 | true, |
||
| 104 | [ |
||
| 105 | 'order' => $order |
||
| 106 | ] |
||
| 110 |
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