Passed
Pull Request — master (#9)
by Volodymyr
05:48
created

BraintreeFactory::getCountryClient()   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 0
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\Braintree;
9
10
use Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface;
11
use Spryker\Yves\Kernel\AbstractFactory;
12
use Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface;
13
use Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface;
14
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCalculationClientInterface;
15
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCountryClientInterface;
16
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToGlossaryClientInterface;
17
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToPaymentClientInterface;
18
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface;
19
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToShipmentClientInterface;
20
use SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceInterface;
21
use SprykerEco\Yves\Braintree\Form\CreditCardSubForm;
22
use SprykerEco\Yves\Braintree\Form\DataProvider\CheckoutShipmentFormDataProvider;
23
use SprykerEco\Yves\Braintree\Form\DataProvider\CreditCardDataProvider;
24
use SprykerEco\Yves\Braintree\Form\DataProvider\PayPalDataProvider;
25
use SprykerEco\Yves\Braintree\Form\PayPalExpressSubForm;
26
use SprykerEco\Yves\Braintree\Form\PayPalSubForm;
27
use SprykerEco\Yves\Braintree\Handler\BraintreeHandler;
28
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapper;
29
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface;
30
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessor;
31
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface;
32
use SprykerEco\Yves\Braintree\Model\QuoteExpander\QuoteExpander;
33
use SprykerEco\Yves\Braintree\Model\QuoteExpander\QuoteExpanderInterface;
34
35
/**
36
 * @method \SprykerEco\Yves\Braintree\BraintreeConfig getConfig()
37
 */
38
class BraintreeFactory extends AbstractFactory
39
{
40
    /**
41
     * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface
42
     */
43
    public function createPayPalForm()
44
    {
45
        return new PayPalSubForm();
46
    }
47
48
    /**
49
     * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface
50
     */
51
    public function createPayPalExpressForm()
52
    {
53
        return new PayPalExpressSubForm();
54
    }
55
56
    /**
57
     * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface
58
     */
59
    public function createCreditCardForm()
60
    {
61
        return new CreditCardSubForm();
62
    }
63
64
    /**
65
     * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
66
     */
67
    public function createPayPalFormDataProvider()
68
    {
69
        return new PayPalDataProvider();
70
    }
71
72
    /**
73
     * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
74
     */
75
    public function createPayPalExpressFormDataProvider()
76
    {
77
        return new PayPalDataProvider();
78
    }
79
80
    /**
81
     * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
82
     */
83
    public function createCreditCardFormDataProvider()
84
    {
85
        return new CreditCardDataProvider();
86
    }
87
88
    /**
89
     * @return \SprykerEco\Yves\Braintree\Handler\BraintreeHandlerInterface
90
     */
91
    public function createBraintreeHandler()
92
    {
93
        return new BraintreeHandler($this->getCurrencyPlugin());
94
    }
95
96
    /**
97
     * @return \Spryker\Yves\Currency\Plugin\CurrencyPluginInterface
98
     */
99
    public function getCurrencyPlugin()
100
    {
101
        return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_CURRENCY);
102
    }
103
104
    /**
105
     * @return \SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface
106
     */
107
    public function createResponseProcessor(): PaypalResponseProcessorInterface
108
    {
109
        return new PaypalResponseProcessor(
110
            $this->createPaypalResponseMapper(),
111
            $this->getQuoteClient()
112
        );
113
    }
114
115
    /**
116
     * @return \SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface
117
     */
118
    public function createPaypalResponseMapper(): PaypalResponseMapperInterface
119
    {
120
        return new PaypalResponseMapper($this->getPaymentClient(), $this->getCountryClient(), $this->getMoneyPlugin());
121
    }
122
123
    /**
124
     * @return \SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceInterface
125
     */
126
    public function getUtilEncodingService(): BraintreeToUtilEncodingServiceInterface
127
    {
128
        return $this->getProvidedDependency(BraintreeDependencyProvider::SERVICE_UTIL_ENCODING);
129
    }
130
131
    /**
132
     * @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface
133
     */
134
    public function getQuoteClient(): BraintreeToQuoteClientInterface
135
    {
136
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_QUOTE);
137
    }
138
139
    /**
140
     * @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToShipmentClientInterface
141
     */
142
    public function getShipmentClient(): BraintreeToShipmentClientInterface
143
    {
144
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_SHIPMENT);
145
    }
146
147
    /**
148
     * @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToGlossaryClientInterface
149
     */
150
    public function getGlossaryClient(): BraintreeToGlossaryClientInterface
151
    {
152
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_GLOSSARY);
153
    }
154
155
    /**
156
     * @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToPaymentClientInterface
157
     */
158
    public function getPaymentClient(): BraintreeToPaymentClientInterface
159
    {
160
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_PAYMENT);
161
    }
162
163
    /**
164
     * @return \Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface
165
     */
166
    public function getMoneyPlugin(): MoneyPluginInterface
167
    {
168
        return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_MONEY);
169
    }
170
171
    /**
172
     * @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCalculationClientInterface
173
     */
174
    public function getCalculationClient(): BraintreeToCalculationClientInterface
175
    {
176
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_CALCULATION);
177
    }
178
179
    /**
180
     * @return \Spryker\Shared\Kernel\Store
181
     */
182
    public function getStore()
183
    {
184
        return $this->getProvidedDependency(BraintreeDependencyProvider::STORE);
185
    }
186
187
    /**
188
     * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
189
     */
190
    public function createBraintreePaypalExpressShipmentFormDataProvider(): StepEngineFormDataProviderInterface
191
    {
192
        return new CheckoutShipmentFormDataProvider(
193
            $this->getShipmentClient(),
194
            $this->getGlossaryClient(),
195
            $this->getStore(),
196
            $this->getMoneyPlugin()
197
        );
198
    }
199
200
    /**
201
     * @return \SprykerEco\Yves\Braintree\Model\QuoteExpander\QuoteExpanderInterface
202
     */
203
    public function createQuoteExpander(): QuoteExpanderInterface
204
    {
205
        return new QuoteExpander(
206
            $this->getQuoteClient(),
207
            $this->getCalculationClient(),
208
            $this->getShipmentHandlerPlugin()
209
        );
210
    }
211
212
    /**
213
     * @return \Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface
214
     */
215
    public function getShipmentHandlerPlugin(): StepHandlerPluginInterface
216
    {
217
        return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_SHIPMENT_HANDLER);
218
    }
219
220
    /**
221
     * @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCountryClientInterface
222
     */
223
    public function getCountryClient(): BraintreeToCountryClientInterface
224
    {
225
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_COUNTRY);
226
    }
227
}
228