Completed
Push — master ( abd772...b3b6a4 )
by Sergi Tur
03:23
created

DevTools::devtools()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 3
nop 0
1
<?php
2
3
namespace Acacha\Llum\Traits;
4
5
/**
6
 * Class DevTools.
7
 */
8
trait DevTools
9
{
10
    /**
11
     * Execute devtools command.
12
     * @return int -1 if error occurred
13
     */
14
    protected function devtools()
15
    {
16
        if ($this->idehelper() == -1) {
17
            return -1;
18
        }
19
        if ($this->debugbar() == -1) {
20
            return -1;
21
        }
22
    }
23
24
    /**
25
     *  Install Laravel ide helper package.
26
     *  @return int -1 if error occurred
27
     */
28
    protected function idehelper()
29
    {
30
        return $this->package('barryvdh/laravel-ide-helper');
0 ignored issues
show
Bug introduced by
It seems like package() 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...
31
    }
32
33
    /**
34
     * Install Laravel debugbar package.
35
     * @return int -1 if error occurred
36
     */
37
    protected function debugbar()
38
    {
39
        return $this->package('barryvdh/laravel-debugbar');
0 ignored issues
show
Bug introduced by
It seems like package() 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...
40
    }
41
}
42