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

Posnet::buildSaleRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 1
1
<?php
2
namespace Paranoia\Pos;
3
4
use Paranoia\Builder\PosnetBuilderFactory;
5
use Paranoia\Configuration\AbstractConfiguration;
6
use Paranoia\Processor\PosnetProcessorFactory;
7
use Paranoia\Request\Request;
8
9
class Posnet extends AbstractPos
10
{
11
    /** @var PosnetBuilderFactory */
12
    private $builderFactory;
13
14
    /** @var PosnetProcessorFactory */
15
    private $processorFactory;
16
17
    public function __construct(AbstractConfiguration $configuration)
18
    {
19
        parent::__construct($configuration);
20
        $this->builderFactory = new PosnetBuilderFactory($this->configuration);
21
        $this->processorFactory = new PosnetProcessorFactory($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( 'xmldata' => $rawRequest);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     * @see \Paranoia\Pos\AbstractPos::parseResponse()
37
     */
38
    protected function parseResponse($rawResponse, $transactionType)
39
    {
40
        $rawRequest = $this->builderFactory->createBuilder($transactionType)->build($request);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $request does not exist. Did you maybe mean $rawRequest?
Loading history...
41
        return array( 'DATA' => $rawRequest);
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('DATA' => $rawRequest) returns the type array<string,string> 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...
42
    }
43
}
44