Conditions | 4 |
Paths | 3 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | protected function validateSignature(): void |
||
25 | { |
||
26 | $data = $this->getData(); |
||
|
|||
27 | |||
28 | if (! isset($data['vpc_SecureHash'])) { |
||
29 | throw new InvalidResponseException('Response from OnePay is invalid!'); |
||
30 | } |
||
31 | |||
32 | $dataSignature = array_filter($data, function ($parameter) { |
||
33 | return 0 === strpos($parameter, 'vpc_') && 'vpc_SecureHash' !== $parameter; |
||
34 | }, ARRAY_FILTER_USE_KEY); |
||
35 | $signature = new Signature( |
||
36 | $this->getRequest()->getVpcHashKey() |
||
37 | ); |
||
38 | |||
39 | if (! $signature->validate($dataSignature, $data['vpc_SecureHash'])) { |
||
40 | throw new InvalidResponseException(sprintf('Data signature response from OnePay is invalid!')); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.