Passed
Push — master ( c1a112...72443c )
by Syed Abidur
05:15
created

HttpRequestApiLogServiceProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Sarahman\HttpRequestApiLog;
4
5
use Illuminate\Foundation\Application as IlluminateApplication;
0 ignored issues
show
Bug introduced by
The type Illuminate\Foundation\Application was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\ServiceProvider;
7
8
class HttpRequestApiLogServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = false;
16
17
    /**
18
     * Actual provider based on Laravel version.
19
     *
20
     * @var \Illuminate\Support\ServiceProvider
21
     */
22
    protected $provider;
23
24
    /**
25
     * Create a new service provider instance.
26
     *
27
     * @param \Illuminate\Contracts\Foundation\Application $app
28
     *
29
     * @return void
30
     */
31
    public function __construct($app)
32
    {
33
        parent::__construct($app);
34
35
        $this->provider = $this->getProvider();
36
    }
37
38
    /**
39
     * Bootstrap the application events.
40
     *
41
     * @return void
42
     */
43
    public function boot()
44
    {
45
        if (method_exists($this->provider, 'boot')) {
46
            return $this->provider->boot();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->provider->boot() targeting Illuminate\Support\ServiceProvider::__call() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
47
        }
48
    }
49
50
    /**
51
     * Register the service provider.
52
     *
53
     * @return void
54
     */
55
    public function register()
56
    {
57
        return $this->provider->register();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->provider->register() targeting Illuminate\Support\ServiceProvider::register() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
58
    }
59
60
    /**
61
     * Return ServiceProvider according to Laravel version.
62
     *
63
     * @return \Illuminate\Support\ServiceProvider
64
     */
65
    private function getProvider()
66
    {
67
        if (version_compare(IlluminateApplication::VERSION, '5.0', '<')) {
68
            $provider = '\Sarahman\HttpRequestApiLog\ServiceProviderForLaravel4';
69
        } else {
70
            $provider = '\Sarahman\HttpRequestApiLog\ServiceProviderForLaravelRecent';
71
        }
72
73
        return new $provider($this->app);
74
    }
75
76
    /**
77
     * Get the services provided by the provider.
78
     *
79
     * @return array
80
     */
81
    public function provides()
82
    {
83
        return ['http-request-api-log'];
84
    }
85
}
86