SanitizerServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 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