Completed
Pull Request — feature/paypal-express (#12)
by Oleksandr
11:54
created

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