Completed
Push — master ( 4df4ca...f9b142 )
by recca
02:09
created

LaravelPanel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setLaravel() 0 11 3
A isLaravel() 0 4 1
1
<?php
2
3
namespace Recca0120\LaravelTracy\Panels;
4
5
use Illuminate\Contracts\Foundation\Application;
6
7
trait LaravelPanel
8
{
9
    /**
10
     * $laravel description.
11
     *
12
     * @var \Illuminate\Contracts\Foundation\Application
13
     */
14
    protected $laravel;
15
16
    /**
17
     * setLaravel.
18
     *
19
     * @param \Illuminate\Contracts\Foundation\Application $laravel
20
     * @return static
21
     */
22 17
    public function setLaravel(Application $laravel = null)
23
    {
24 17
        if (is_null($laravel) === false) {
25 16
            $this->laravel = $laravel;
26 16
            if (is_subclass_of($this, 'Recca0120\LaravelTracy\Panels\ISubscriablePanel') === true) {
27 7
                $this->subscribe();
0 ignored issues
show
Bug introduced by
It seems like subscribe() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
28 7
            }
29 16
        }
30
31 17
        return $this;
32
    }
33
34
    /**
35
     * is laravel.
36
     *
37
     * @return bool
38
     */
39 8
    protected function isLaravel()
40
    {
41 8
        return is_a($this->laravel, Application::class);
42
    }
43
}
44