Passed
Pull Request — master (#9)
by Volodymyr
17:33 queued 09:33
created

BraintreeDependencyProvider::addGlossaryClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
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\Kernel\Store;
11
use Spryker\Yves\Currency\Plugin\CurrencyPlugin;
12
use Spryker\Yves\Kernel\AbstractBundleDependencyProvider;
13
use Spryker\Yves\Kernel\Container;
14
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToGlossaryClientBridge;
15
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToPaymentClientBridge;
16
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientBridge;
17
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToShipmentClientBridge;
18
use SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceBridge;
19
use SprykerShop\Yves\MoneyWidget\Plugin\MoneyPlugin;
0 ignored issues
show
Bug introduced by
The type SprykerShop\Yves\MoneyWidget\Plugin\MoneyPlugin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
class BraintreeDependencyProvider extends AbstractBundleDependencyProvider
22
{
23
    public const PLUGIN_CURRENCY = 'PLUGIN_CURRENCY';
24
25
    public const CLIENT_QUOTE = 'CLIENT_QUOTE';
26
    public const CLIENT_PAYMENT = 'CLIENT_PAYMENT';
27
    public const CLIENT_SHIPMENT = 'CLIENT_SHIPMENT';
28
    public const CLIENT_GLOSSARY = 'CLIENT_GLOSSARY';
29
30
    public const SERVICE_UTIL_ENCODING = 'UTIL_ENCODING_SERVICE';
31
32
    public const PLUGIN_MONEY = 'PLUGIN_MONEY';
33
34
    public const STORE = 'STORE';
35
36
    /**
37
     * @param \Spryker\Yves\Kernel\Container $container
38
     *
39
     * @return \Spryker\Yves\Kernel\Container|\Spryker\Zed\Kernel\Container
40
     */
41
    public function provideDependencies(Container $container)
42
    {
43
        $container = $this->addCurrencyPlugin($container);
44
        $container = $this->addQuoteClient($container);
45
        $container = $this->addUtilEncodingService($container);
46
        $container = $this->addPaymentClient($container);
47
        $container = $this->addShipmentClient($container);
48
        $container = $this->addGlossaryClient($container);
49
        $container = $this->addMoneyPlugin($container);
50
        $container = $this->addStore($container);
51
52
        return $container;
53
    }
54
55
    /**
56
     * @param \Spryker\Yves\Kernel\Container $container
57
     *
58
     * @return \Spryker\Yves\Kernel\Container
59
     */
60
    protected function addCurrencyPlugin(Container $container)
61
    {
62
        $container[static::PLUGIN_CURRENCY] = function (Container $container) {
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

62
        $container[static::PLUGIN_CURRENCY] = function (/** @scrutinizer ignore-unused */ Container $container) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
            return new CurrencyPlugin();
64
        };
65
66
        return $container;
67
    }
68
69
    /**
70
     * @param \Spryker\Yves\Kernel\Container $container
71
     *
72
     * @return \Spryker\Yves\Kernel\Container
73
     */
74
    protected function addQuoteClient(Container $container): Container
75
    {
76
        $container[static::CLIENT_QUOTE] = function (Container $container) {
77
            return new BraintreeToQuoteClientBridge($container->getLocator()->quote()->client());
78
        };
79
80
        return $container;
81
    }
82
83
    /**
84
     * @param \Spryker\Yves\Kernel\Container $container
85
     *
86
     * @return \Spryker\Yves\Kernel\Container
87
     */
88
    protected function addUtilEncodingService(Container $container): Container
89
    {
90
        $container[static::SERVICE_UTIL_ENCODING] = function (Container $container) {
91
            return new BraintreeToUtilEncodingServiceBridge($container->getLocator()->utilEncoding()->service());
92
        };
93
94
        return $container;
95
    }
96
97
    /**
98
     * @param \Spryker\Yves\Kernel\Container $container
99
     *
100
     * @return \Spryker\Yves\Kernel\Container
101
     */
102
    protected function addPaymentClient(Container $container): Container
103
    {
104
        $container[static::CLIENT_PAYMENT] = function (Container $container) {
105
            return new BraintreeToPaymentClientBridge($container->getLocator()->payment()->client());
106
        };
107
108
        return $container;
109
    }
110
111
    /**
112
     * @param \Spryker\Yves\Kernel\Container $container
113
     *
114
     * @return \Spryker\Yves\Kernel\Container
115
     */
116
    protected function addShipmentClient(Container $container): Container
117
    {
118
        $container[static::CLIENT_SHIPMENT] = function (Container $container) {
119
            return new BraintreeToShipmentClientBridge($container->getLocator()->shipment()->client());
120
        };
121
122
        return $container;
123
    }
124
125
    /**
126
     * @param \Spryker\Yves\Kernel\Container $container
127
     *
128
     * @return \Spryker\Yves\Kernel\Container
129
     */
130
    protected function addGlossaryClient(Container $container): Container
131
    {
132
        $container[static::CLIENT_GLOSSARY] = function (Container $container) {
133
            return new BraintreeToGlossaryClientBridge($container->getLocator()->glossary()->client());
134
        };
135
136
        return $container;
137
    }
138
139
    /**
140
     * @param \Spryker\Yves\Kernel\Container $container
141
     *
142
     * @return \Spryker\Yves\Kernel\Container
143
     */
144
    protected function addStore(Container $container)
145
    {
146
        $container[static::STORE] = function () {
147
            return Store::getInstance();
148
        };
149
150
        return $container;
151
    }
152
153
    /**
154
     * @param \Spryker\Yves\Kernel\Container $container
155
     *
156
     * @return \Spryker\Yves\Kernel\Container
157
     */
158
    protected function addMoneyPlugin(Container $container): Container
159
    {
160
        $container[static::PLUGIN_MONEY] = function () {
161
            return new MoneyPlugin();
162
        };
163
164
        return $container;
165
    }
166
}
167