EasycreditBusinessFactory::createResponseParser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\Zed\Easycredit\Business;
9
10
use GuzzleHttp\ClientInterface;
11
use Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface;
12
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;
13
use SprykerEco\Service\Easycredit\Dependency\Service\EasycreditToUtilEncodingServiceInterface;
14
use SprykerEco\Zed\Easycredit\Business\Api\Adapter\Http\Factory\AdapterFactory;
15
use SprykerEco\Zed\Easycredit\Business\Api\Adapter\Http\Factory\AdapterFactoryInterface;
16
use SprykerEco\Zed\Easycredit\Business\Api\Client\EasycreditClient;
17
use SprykerEco\Zed\Easycredit\Business\Api\RequestSender\RequestSender;
18
use SprykerEco\Zed\Easycredit\Business\Api\RequestSender\RequestSenderInterface;
19
use SprykerEco\Zed\Easycredit\Business\Logger\EasycreditLogger;
20
use SprykerEco\Zed\Easycredit\Business\Logger\EasycreditLoggerInterface;
21
use SprykerEco\Zed\Easycredit\Business\Mapper\EasycreditMapper;
22
use SprykerEco\Zed\Easycredit\Business\Mapper\MapperInterface;
23
use SprykerEco\Zed\Easycredit\Business\Parser\ResponseParser;
24
use SprykerEco\Zed\Easycredit\Business\Parser\ResponseParserInterface;
25
use SprykerEco\Zed\Easycredit\Business\Payment\PaymentMethodFilter;
26
use SprykerEco\Zed\Easycredit\Business\Payment\PaymentMethodFilterInterface;
27
use SprykerEco\Zed\Easycredit\Business\Saver\EasycreditOrderIdentifierSaver;
28
use SprykerEco\Zed\Easycredit\Business\Saver\EasycreditOrderIdentifierSaverInterface;
29
use SprykerEco\Zed\Easycredit\EasycreditDependencyProvider;
30
31
/**
32
 * @method \SprykerEco\Zed\Easycredit\EasycreditConfig getConfig()
33
 * @method \SprykerEco\Zed\Easycredit\Persistence\EasycreditEntityManagerInterface getEntityManager()
34
 * @method \SprykerEco\Zed\Easycredit\Persistence\EasycreditRepositoryInterface getRepository()
35
 */
36
class EasycreditBusinessFactory extends AbstractBusinessFactory
37
{
38
    /**
39
     * @return \GuzzleHttp\ClientInterface
40
     */
41
    public function createEasycreditClient(): ClientInterface
42
    {
43
        return new EasycreditClient();
44
    }
45
46
    /**
47
     * @return \SprykerEco\Service\Easycredit\Dependency\Service\EasycreditToUtilEncodingServiceInterface
48
     */
49
    public function getUtilEncodingService(): EasycreditToUtilEncodingServiceInterface
50
    {
51
        return $this->getProvidedDependency(EasycreditDependencyProvider::SERVICE_UTIL_ENCODING);
52
    }
53
54
    /**
55
     * @return \SprykerEco\Zed\Easycredit\Business\Payment\PaymentMethodFilterInterface
56
     */
57
    public function createPaymentMethodFilter(): PaymentMethodFilterInterface
58
    {
59
        return new PaymentMethodFilter($this->getConfig());
60
    }
61
62
    /**
63
     * @return \SprykerEco\Zed\Easycredit\Business\Logger\EasycreditLoggerInterface
64
     */
65
    public function createEasycreditLogger(): EasycreditLoggerInterface
66
    {
67
        return new EasycreditLogger($this->getEntityManager());
68
    }
69
70
    /**
71
     * @return \SprykerEco\Zed\Easycredit\Business\Saver\EasycreditOrderIdentifierSaverInterface
72
     */
73
    public function createEasycreditOrderIdentifierSaver(): EasycreditOrderIdentifierSaverInterface
74
    {
75
        return new EasycreditOrderIdentifierSaver($this->getEntityManager());
76
    }
77
78
    /**
79
     * @return \SprykerEco\Zed\Easycredit\Business\Mapper\MapperInterface
80
     */
81
    public function createMapper(): MapperInterface
82
    {
83
        return new EasycreditMapper(
84
            $this->getConfig(),
85
            $this->getMoneyPlugin()
86
        );
87
    }
88
89
    /**
90
     * @return \SprykerEco\Zed\Easycredit\Business\Api\Adapter\Http\Factory\AdapterFactoryInterface
91
     */
92
    public function createAdapterFactory(): AdapterFactoryInterface
93
    {
94
        return new AdapterFactory(
95
            $this->createEasycreditClient(),
96
            $this->getUtilEncodingService(),
97
            $this->getConfig()
98
        );
99
    }
100
101
    /**
102
     * @return \SprykerEco\Zed\Easycredit\Business\Parser\ResponseParserInterface
103
     */
104
    public function createResponseParser(): ResponseParserInterface
105
    {
106
        return new ResponseParser();
107
    }
108
109
    /**
110
     * @return \SprykerEco\Zed\Easycredit\Business\Api\RequestSender\RequestSenderInterface
111
     */
112
    public function createRequestSender(): RequestSenderInterface
113
    {
114
        return new RequestSender(
115
            $this->createMapper(),
116
            $this->createAdapterFactory(),
117
            $this->createResponseParser(),
118
            $this->createEasycreditLogger(),
119
            $this->getRepository(),
120
            $this->getEntityManager()
121
        );
122
    }
123
124
    /**
125
     * @return \Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface
126
     */
127
    public function getMoneyPlugin(): MoneyPluginInterface
128
    {
129
        return $this->getProvidedDependency(EasycreditDependencyProvider::PLUGIN_MONEY);
130
    }
131
}
132