LaravelRegistrar   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 93.75%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 6
c 3
b 2
f 0
lcom 1
cbo 2
dl 0
loc 42
ccs 15
cts 16
cp 0.9375
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B resolve() 0 23 5
1
<?php
2
3
namespace Alfheim\Sanitizer\Registrar;
4
5
use Illuminate\Contracts\Container\Container;
6
7
class LaravelRegistrar extends BaseRegistrar
8
{
9
    /** @var \Illuminate\Contracts\Container\Container */
10
    private $container;
11
12
    /**
13
     * Create a new Laravel registrar instance.
14
     *
15
     * @param  \Illuminate\Contracts\Container\Container  $container
16
     */
17 12
    public function __construct(Container $container)
18
    {
19 12
        $this->container = $container;
20 12
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 12
    public function resolve($name)
26
    {
27 12
        $value = $this->registrations[$name];
28
29 12
        if (is_string($value)) {
30
            // Check for `class@method` format.
31 12
            if (strpos($value, '@') >= 1) {
32 4
                $segments = explode('@', $value, 2);
33
34 4
                if ($this->container->bound($segments[0])) {
35
                    return [
36 4
                        $this->container->make($segments[0]), $segments[1],
37 3
                    ];
38
                }
39
            }
40
41 8
            if ($this->container->bound($name)) {
42 4
                return $this->container->make($name);
43
            }
44 3
        }
45
46 4
        return parent::resolve($name);
47
    }
48
}
49