Passed
Push — master ( 411399...13c9c0 )
by
unknown
01:51
created
1
<?php
2
namespace PTS\Paysera;
3
4
use Http\Message\MessageFactory;
5
use function League\Uri\create;
6
use Payum\Core\Bridge\Spl\ArrayObject;
7
use Payum\Core\Exception\Http\HttpException;
8
use Payum\Core\HttpClientInterface;
9
use Payum\Core\Reply\HttpPostRedirect;
10
use Payum\Core\Reply\HttpResponse;
11
use Payum\Core\Request\GetHttpRequest;
12
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
The type Symfony\Component\HttpFoundation\Request 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...
13
use WebToPay;
14
15
class Api
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $options = [];
21
22
    /**
23
     * Api constructor.
24
     * @param array $options
25
     */
26
    public function __construct(array $options)
27
    {
28
        $options = ArrayObject::ensureArrayObject($options);
29
        $options->defaults($this->options);
30
31
        $this->options = $options;
0 ignored issues
show
Documentation Bug introduced by
It seems like $options of type Payum\Core\Bridge\Spl\ArrayObject is incompatible with the declared type array of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
32
    }
33
34
    public function doPayment(array $fields)
35
    {
36
        $fields['projectid'] = $this->options['projectid'];
37
        $fields['sign_password'] = $this->options['sign_password'];
38
        $this->options['test'] ? $fields['test'] = 1 : $fields['test'] = 0;
39
        $authorizeTokenUrl = $this->getApiEndpoint();
40
        $data = WebToPay::buildRequest($fields);
41
        throw new HttpPostRedirect($authorizeTokenUrl, $data);
42
    }
43
44
    public function doNotify(array $fields)
45
    {
46
        $response = WebToPay::validateAndParseData(
47
            $fields,
48
            $this->options['projectid'],
49
            $this->options['sign_password']);
50
        if ($response['status'] === '1') {
51
            return true;
52
        } else {
53
            return false;
54
        }
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    protected function getApiEndpoint()
61
    {
62
        return WebToPay::PAY_URL;
63
    }
64
65
    public function getApiOptions()
66
    {
67
        return $this->options;
68
    }
69
}
70