Completed
Push — master ( 40f202...d22295 )
by Dmitry
02:28
created

Application::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Basis;
4
5
use League\Container\Container;
6
use League\Container\ReflectionContainer;
7
8
class Application
9
{
10
    private $startTime;
11
12 11
    public function __construct($root)
13
    {
14 11
        $this->startTime = microtime(1);
15 11
        $this->container = new Container;
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
17 11
        $fs = new Filesystem($this, $root);
18
19 11
        $this->container->share(Container::class, $this->container);
20 11
        $this->container->share(Application::class, $this);
21 11
        $this->container->share(Filesystem::class, $fs);
22 11
        $this->container->share(Framework::class, new Framework($this));
0 ignored issues
show
Unused Code introduced by
The call to Framework::__construct() has too many arguments starting with $this.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
23
24 11
        $this->container->addServiceProvider(Providers\Core::class);
25 11
        $this->container->addServiceProvider(Providers\Logging::class);
26 11
        $this->container->addServiceProvider(Providers\Tarantool::class);
27
28 11
        foreach($fs->listClasses('Providers') as $provider) {
29 11
            $this->container->addServiceProvider($provider);
30 11
        }
31
32 11
        $this->container->delegate(new ReflectionContainer());
33 11
    }
34
35 11
    public function get($class)
36
    {
37 11
        return $this->container->get($class);
38
    }
39
40 4
    public function dispatch($command, $params = [])
41
    {
42 4
        return $this->get(Runner::class)->dispatch($command, $params);
43
    }
44
45 1
    public function getRunningTime()
46
    {
47 1
        return microtime(1) - $this->startTime;
48
    }
49
}