MoneyServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 1
cp 0
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace ByTIC\Money;
5
6
use ByTIC\Assets\Encore\EntrypointLookupFactory;
7
use ByTIC\Assets\Encore\EntrypointsCollection;
8
use ByTIC\Money\Formatter\Manager;
9
use Money\Currencies\ISOCurrencies;
10
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
11
use Symfony\Component\Asset\Package;
12
use Symfony\Component\Asset\Packages;
13
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
14
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection;
15
use Symfony\WebpackEncoreBundle\Asset\TagRenderer;
16
17
/**
18
 * Class MoneyServiceProvider
19
 * @package ByTIC\Money
20
 */
21
class MoneyServiceProvider extends AbstractSignatureServiceProvider
22
{
23
    public const NAME = 'money';
24
25
    public const MONEY_CURRENCIES = 'money.currencies';
26
    /**
27
     * @inheritDoc
28
     */
29
    public function provides()
30
    {
31
        return [
32
            self::MONEY_CURRENCIES,
33
            'money.currency',
34
            'money.formatter',
35
        ];
36
    }
37
38
    public function register()
39
    {
40
        $this->registerCurrencies();
41
        $this->registerCurrency();
42
        $this->registerFormatter();
43
    }
44
45
    protected function registerCurrencies()
46
    {
47
        $this->getContainer()->share(self::MONEY_CURRENCIES, function () {
48
            return new ISOCurrencies();
49
        });
50
    }
51
52
    protected function registerCurrency()
53
    {
54
        $this->getContainer()->share('money.currency', function () {
55
        });
56
    }
57
58
    protected function registerFormatter()
59
    {
60
        $this->getContainer()->share('money.formatter', function () {
61
            return Manager::instance();
62
        });
63
    }
64
}
65