Passed
Push — feature/paypal-express ( 956c37...c5cd7f )
by Volodymyr
05:02
created

BraintreeFactory   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 83
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A createCreditCardForm() 0 3 1
A createPayPalFormDataProvider() 0 3 1
A createResponseProcessor() 0 5 1
A getUtilEncodingService() 0 3 1
A getQuoteClient() 0 3 1
A createPaypalResponseMapper() 0 3 1
A createBraintreeHandler() 0 3 1
A getCurrencyPlugin() 0 3 1
A createPayPalForm() 0 3 1
A createCreditCardFormDataProvider() 0 3 1
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\Yves\Kernel\AbstractFactory;
11
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface;
12
use SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceInterface;
13
use SprykerEco\Yves\Braintree\Form\CreditCardSubForm;
14
use SprykerEco\Yves\Braintree\Form\DataProvider\CreditCardDataProvider;
15
use SprykerEco\Yves\Braintree\Form\DataProvider\PayPalDataProvider;
16
use SprykerEco\Yves\Braintree\Form\PayPalSubForm;
17
use SprykerEco\Yves\Braintree\Handler\BraintreeHandler;
18
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapper;
19
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface;
20
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessor;
21
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface;
22
23
class BraintreeFactory extends AbstractFactory
24
{
25
    /**
26
     * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface
27
     */
28
    public function createPayPalForm()
29
    {
30
        return new PayPalSubForm();
31
    }
32
33
    /**
34
     * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface
35
     */
36
    public function createCreditCardForm()
37
    {
38
        return new CreditCardSubForm();
39
    }
40
41
    /**
42
     * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
43
     */
44
    public function createPayPalFormDataProvider()
45
    {
46
        return new PayPalDataProvider();
47
    }
48
49
    /**
50
     * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
51
     */
52
    public function createCreditCardFormDataProvider()
53
    {
54
        return new CreditCardDataProvider();
55
    }
56
57
    /**
58
     * @return \SprykerEco\Yves\Braintree\Handler\BraintreeHandlerInterface
59
     */
60
    public function createBraintreeHandler()
61
    {
62
        return new BraintreeHandler($this->getCurrencyPlugin());
63
    }
64
65
    /**
66
     * @return \Spryker\Yves\Currency\Plugin\CurrencyPluginInterface
67
     */
68
    public function getCurrencyPlugin()
69
    {
70
        return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_CURRENCY);
71
    }
72
73
    /**
74
     * @return \SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface
75
     */
76
    public function createResponseProcessor(): PaypalResponseProcessorInterface
77
    {
78
        return new PaypalResponseProcessor(
79
            $this->createPaypalResponseMapper(),
80
            $this->getQuoteClient()
81
        );
82
    }
83
84
    /**
85
     * @return \SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface
86
     */
87
    public function createPaypalResponseMapper(): PaypalResponseMapperInterface
88
    {
89
        return new PaypalResponseMapper();
90
    }
91
92
    /**
93
     * @return BraintreeToUtilEncodingServiceInterface
94
     */
95
    public function getUtilEncodingService(): BraintreeToUtilEncodingServiceInterface
96
    {
97
        return $this->getProvidedDependency(BraintreeDependencyProvider::SERVICE_UTIL_ENCODING);
98
    }
99
100
    /**
101
     * @return BraintreeToQuoteClientInterface
102
     */
103
    public function getQuoteClient(): BraintreeToQuoteClientInterface
104
    {
105
        return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_QUOTE);
106
    }
107
}
108