Passed
Push — master ( 2844e2...c932ad )
by John
03:09
created

DotpayManager::callback()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Evilnet\Dotpay;
4
5
use Evilnet\Dotpay\DotpayApi\DotpayApi;
6
use Dotenv\Exception\InvalidCallbackException;
0 ignored issues
show
Bug introduced by
The type Dotenv\Exception\InvalidCallbackException was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Evilnet\Dotpay\DotpayApi\Response;
8
9
class DotpayManager
10
{
11
    private $dotpayApi;
12
    private $response;
13
14
    public function __construct(DotpayApi $dotpayApi)
15
    {
16
        $this->dotpayApi = $dotpayApi;
17
    }
18
19
    //It will return url for dotpay transaction
20
21
    public function createPayment($data)
22
    {
23
        return $this->dotpayApi->createPayment($data);
24
    }
25
26
27
    public function response()
28
    {
29
        return $this->response;
30
    }
31
32
    //It will listen for dotpay POST with status. We need to calculate hash and check status
33
    public function callback(array $data)
34
    {
35
        if ($this->dotpayApi->verifyCallback($data)) {
36
            return new Response($data);
37
        }
38
        throw new InvalidCallbackException('invalid_hash');
39
    }
40
}