ButtonFactoryBootstrapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBindings() 0 4 1
A registerBindings() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\PropellerAdmin\Bootstrappers\Html\Component;
6
7
use AbterPhp\Framework\Constant\Html5;
8
use AbterPhp\Framework\Html\Component\ButtonFactory;
9
use Opulence\Ioc\Bootstrappers\Bootstrapper;
10
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper;
11
use Opulence\Ioc\IContainer;
12
use Opulence\Routing\Urls\UrlGenerator;
13
14
class ButtonFactoryBootstrapper extends Bootstrapper implements ILazyBootstrapper
15
{
16
    /** @var array */
17
    protected $iconAttributes = [
18
        Html5::ATTR_CLASS => 'material-icons media-left media-middle',
19
    ];
20
21
    /** @var array */
22
    protected $textAttributes = [
23
        Html5::ATTR_CLASS => 'media-body',
24
    ];
25
26
    /**
27
     * @return array
28
     */
29
    public function getBindings(): array
30
    {
31
        return [
32
            ButtonFactory::class,
33
        ];
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function registerBindings(IContainer $container)
40
    {
41
        /** @var UrlGenerator $urlGenerator */
42
        $urlGenerator = $container->resolve(UrlGenerator::class);
43
44
        $buttonFactory = new ButtonFactory($urlGenerator, $this->textAttributes, $this->iconAttributes);
45
46
        $container->bindInstance(ButtonFactory::class, $buttonFactory);
47
    }
48
}
49