Completed
Push — master ( a00622...08b3e1 )
by Martin
14:53
created

ServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 71
rs 10
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A config() 0 4 1
plugins() 0 1 ?
A __call() 0 7 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Spires\Core;
5
6
use BadMethodCallException;
7
use Spires\Contracts\Core\Core as CoreContract;
8
9
abstract class ServiceProvider
10
{
11
    /**
12
     * @var \Spires\Contracts\Core\Core
13
     */
14
    protected $core;
15
16
    /**
17
     * @param  \Spires\Contracts\Core\Core $core
18
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
19
     */
20
    public function __construct(CoreContract $core)
21
    {
22
        $this->core = $core;
23
    }
24
25
    /**
26
     * Define config keys with their default values.
27
     *
28
     * @return array
29
     */
30
    public function config()
31
    {
32
        return [];
33
    }
34
35
    /**
36
     * (Optional) Register the service provider.
37
     *
38
     * @return void
39
     */
40
//    public function register()
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
//    {
42
//        //
43
//    }
44
45
    /**
46
     * (Optional) Boot the service provider.
47
     * Parameters are resolved through the container.
48
     *
49
     * @return void
50
     */
51
//    public function boot()
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
//    {
53
//        //
54
//    }
55
56
    /**
57
     * Plugins provided.
58
     *
59
     * @return string[]
60
     */
61
    abstract public function plugins();
62
63
    /**
64
     * Dynamically handle missing method calls.
65
     *
66
     * @param  string  $method
67
     * @param  array  $parameters
68
     * @return mixed
69
     *
70
     * @throws \BadMethodCallException
71
     */
72
    public function __call($method, $parameters)
73
    {
74
        if (in_array($method, ['register', 'boot'])) {
75
            return;
76
        }
77
        throw new BadMethodCallException("Call to undefined method [{$method}]");
78
    }
79
}
80