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

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