Passed
Pull Request — master (#16)
by
unknown
06:16 queued 02:52
created

EasycreditDependencyProvider::addHttpClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 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\Zed\Easycredit;
9
10
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
11
use Spryker\Zed\Kernel\Container;
12
use Spryker\Zed\Money\Communication\Plugin\MoneyPlugin;
13
use SprykerEco\Service\Easycredit\Dependency\Service\EasycreditToUtilEncodingServiceBridge;
14
use SprykerEco\Zed\Easycredit\Dependency\External\EasycreditToHttpClientAdapter;
15
16
/**
17
 * @method \SprykerEco\Zed\Easycredit\EasycreditConfig getConfig()
18
 */
19
class EasycreditDependencyProvider extends AbstractBundleDependencyProvider
20
{
21
    /**
22
     * @var string
23
     */
24
    public const SERVICE_UTIL_ENCODING = 'SERVICE_UTIL_ENCODING';
25
26
    /**
27
     * @var string
28
     */
29
    public const PLUGIN_MONEY = 'PLUGIN_MONEY';
30
31
    /**
32
     * @var string
33
     */
34
    public const CLIENT_HTTP = 'CLIENT_HTTP';
35
36
    /**
37
     * @param \Spryker\Zed\Kernel\Container $container
38
     *
39
     * @return \Spryker\Zed\Kernel\Container
40
     */
41
    public function provideBusinessLayerDependencies(Container $container): Container
42
    {
43
        $container = $this->addUtilEncodingService($container);
44
        $container = $this->addPluginMoney($container);
45
        $container = $this->addHttpClient($container);
46
47
        return $container;
48
    }
49
50
    /**
51
     * @param \Spryker\Zed\Kernel\Container $container
52
     *
53
     * @return \Spryker\Zed\Kernel\Container
54
     */
55
    protected function addUtilEncodingService(Container $container): Container
56
    {
57
        $container->set(static::SERVICE_UTIL_ENCODING, function (Container $container) {
58
            return new EasycreditToUtilEncodingServiceBridge($container->getLocator()->utilEncoding()->service());
59
        });
60
61
        return $container;
62
    }
63
64
    /**
65
     * @param \Spryker\Zed\Kernel\Container $container
66
     *
67
     * @return \Spryker\Zed\Kernel\Container
68
     */
69
    protected function addPluginMoney(Container $container): Container
70
    {
71
        $container->set(static::PLUGIN_MONEY, function () {
72
            return new MoneyPlugin();
73
        });
74
75
        return $container;
76
    }
77
78
    /**
79
     * @param \Spryker\Zed\Kernel\Container $container
80
     *
81
     * @return \Spryker\Zed\Kernel\Container
82
     */
83
    protected function addHttpClient(Container $container): Container
84
    {
85
        $container->set(static::CLIENT_HTTP, function () {
86
            return new EasycreditToHttpClientAdapter();
87
        });
88
89
        return $container;
90
    }
91
}
92