Passed
Pull Request — master (#4)
by Aleksey
11:47 queued 02:44
created

CrefoPayQuoteExpander::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\CrefoPay\Quote;
9
10
use Generated\Shared\Transfer\CrefoPayTransactionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oPayTransactionTransfer 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...
11
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
12
use SprykerEco\Client\CrefoPay\CrefoPayClientInterface;
13
use Symfony\Component\HttpFoundation\Request;
14
15
class CrefoPayQuoteExpander implements CrefoPayQuoteExpanderInterface
16
{
17
    /**
18
     * @var \SprykerEco\Client\CrefoPay\CrefoPayClientInterface
19
     */
20
    protected $client;
21
22
    /**
23
     * @param \SprykerEco\Client\CrefoPay\CrefoPayClientInterface $client
24
     */
25
    public function __construct(CrefoPayClientInterface $client)
26
    {
27
        $this->client = $client;
28
    }
29
30
    /**
31
     * @param \Symfony\Component\HttpFoundation\Request $request
32
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
33
     *
34
     * @return \Generated\Shared\Transfer\QuoteTransfer
35
     */
36
    public function expand(Request $request, QuoteTransfer $quoteTransfer): QuoteTransfer
37
    {
38
        $crefoPayTransaction = $quoteTransfer->getCrefoPayTransaction();
39
        if ($crefoPayTransaction !== null && $crefoPayTransaction->getIsSuccess()) {
40
            return $quoteTransfer;
41
        }
42
43
        $quoteTransfer->setCrefoPayTransaction(
44
            $this->createCrefoPayTransactionTransfer($request)
45
        );
46
47
        return $this->client->startCrefoPayTransaction($quoteTransfer);
48
    }
49
50
    /**
51
     * @param \Symfony\Component\HttpFoundation\Request $request
52
     *
53
     * @return \Generated\Shared\Transfer\CrefoPayTransactionTransfer
54
     */
55
    protected function createCrefoPayTransactionTransfer(Request $request): CrefoPayTransactionTransfer
56
    {
57
        return (new CrefoPayTransactionTransfer())
58
            ->setClientIp($request->getClientIp());
59
    }
60
}
61