LaravelMessageService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0
ccs 0
cts 9
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A runsMigrations() 0 5 1
A ignoreMigrations() 0 6 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: alive
5
 * Date: 4/28/18
6
 * Time: 3:34 AM
7
 */
8
9
namespace Alive2212\LaravelMessageService;
10
11
12
class LaravelMessageService
13
{
14
15
    /**
16
     * @var bool
17
     */
18
    static $runsMigrations = true;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $runsMigrations.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
19
20
    /**
21
     * @return bool
22
     */
23
    public function runsMigrations()
24
    {
25
        // TODO check migration was copied into projects or not
26
        return false;
27
    }
28
29
    /**
30
     * Configure Package to not register its migrations.
31
     *
32
     * @return static
33
     */
34
    public static function ignoreMigrations()
35
    {
36
        static::$runsMigrations = false;
0 ignored issues
show
Bug introduced by
Since $runsMigrations is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $runsMigrations to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
37
38
        return new static;
39
    }
40
41
}