Passed
Push — master ( 56e3ba...d2a4fa )
by İbrahim
03:24
created

NestPay::buildCancelRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
namespace Paranoia\Pos;
3
4
use Paranoia\Builder\AbstractBuilderFactory;
5
use Paranoia\Builder\NestPayBuilderFactory;
6
use Paranoia\Configuration\AbstractConfiguration;
7
use Paranoia\Processor\NestPayProcessorFactory;
8
use Paranoia\Request\Request;
9
10
class NestPay extends AbstractPos
11
{
12
    /** @var AbstractBuilderFactory */
13
    private $builderFactory;
14
15
    /** @var NestPayProcessorFactory */
16
    private $processorFactory;
17
18
    public function __construct(AbstractConfiguration $configuration)
19
    {
20
        parent::__construct($configuration);
21
        $this->builderFactory = new NestPayBuilderFactory($this->configuration);
22
        $this->processorFactory = new NestPayProcessorFactory($this->configuration);
23
    }
24
25
26
    /**
27
     * {@inheritdoc}
28
     * @see \Paranoia\Pos\AbstractPos::buildRequest()
29
     */
30
    protected function buildRequest(Request $request, $transactionType)
31
    {
32
        $rawRequest = $this->builderFactory->createBuilder($transactionType)->build($request);
33
        return array( 'DATA' => $rawRequest);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     * @see \Paranoia\Pos\AbstractPos::parseResponse()
39
     */
40
    protected function parseResponse($rawResponse, $transactionType)
41
    {
42
        return $this->processorFactory->createProcessor($transactionType)->process($rawResponse);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->processorF...->process($rawResponse) returns the type Paranoia\Response which is incompatible with the return type mandated by Paranoia\Pos\AbstractPos::parseResponse() of Paranoia\Response\Response.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
43
    }
44
}
45