SanitizerServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 76.47%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 2
c 2
b 1
f 1
lcom 1
cbo 4
dl 0
loc 36
ccs 13
cts 17
cp 0.7647
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 16 1
A provides() 0 7 1
1
<?php
2
3
namespace Alfheim\Sanitizer;
4
5
use Alfheim\Sanitizer\Registrar\LaravelRegistrar;
6
use Alfheim\Sanitizer\Registrar\RegistrarInterface;
7
use Illuminate\Support\ServiceProvider;
8
use Illuminate\Contracts\Container\Container;
9
use Illuminate\Contracts\Foundation\Application;
10
11
class SanitizerServiceProvider extends ServiceProvider
12
{
13
    /** {@inheritdoc} */
14
    protected $defer = true;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 4
    public function register()
20
    {
21 4
        $this->app->singleton(RegistrarInterface::class,
22
            function (Container $app) {
23
                return new LaravelRegistrar($app);
24 1
            }
25 3
        );
26
27 4
        $this->app->bind(Sanitizer::class,
28 1
            function (Application $app) {
29
                return (new Sanitizer)->setRegistrar(
30
                    $app->make(RegistrarInterface::class)
31
                );
32 1
            }
33 3
        );
34 4
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 4
    public function provides()
40
    {
41
        return [
42 4
            Sanitizer::class,
43 3
            RegistrarInterface::class,
44 3
        ];
45
    }
46
}
47