MockedApi::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
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
Bug introduced by
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 MockedApi
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fields is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    public function doNotify(/** @scrutinizer ignore-unused */ array $fields)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        return true;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    protected function getApiEndpoint()
53
    {
54
        return WebToPay::PAY_URL;
55
    }
56
57
    public function getApiOptions()
58
    {
59
        return $this->options;
60
    }
61
}
62