Passed
Pull Request — master (#16)
by
unknown
06:16 queued 02:52
created

createEasycreditClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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