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

Gvp::buildCard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
namespace Paranoia\Pos;
3
4
use Paranoia\Builder\GvpBuilderFactory;
5
use Paranoia\Configuration\AbstractConfiguration;
6
use Paranoia\Processor\GvpProcessorFactory;
7
use Paranoia\Request\Request;
8
9
class Gvp extends AbstractPos
10
{
11
    /** @var GvpBuilderFactory */
12
    private $builderFactory;
13
14
    /** @var  GvpProcessorFactory */
15
    private $processorFactory;
16
17
    public function __construct(AbstractConfiguration $configuration)
18
    {
19
        parent::__construct($configuration);
20
        $this->builderFactory = new GvpBuilderFactory($this->configuration);
21
        $this->processorFactory = new GvpProcessorFactory($this->configuration);
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     * @see \Paranoia\Pos\AbstractPos::buildRequest()
27
     */
28
    protected function buildRequest(Request $request, $transactionType)
29
    {
30
        $rawRequest = $this->builderFactory->createBuilder($transactionType)->build($request);
31
        return array( 'data' => $rawRequest);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     * @see \Paranoia\Pos\AbstractPos::parseResponse()
37
     */
38
    protected function parseResponse($rawResponse, $transactionType)
39
    {
40
        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...
41
    }
42
}
43