Test Failed
Push — 1.0.0-alpha ( ed4ef1...66d0a7 )
by Alex
05:33 queued 02:55
created

KernelRouterAssociation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A dispatchToRouter() 0 9 1
1
<?php
2
3
namespace Huntie\JsonApi\Routing;
4
5
trait KernelRouterAssociation
6
{
7
    /**
8
     * Get the route dispatcher callback.
9
     *
10
     * @return \Closure
11
     */
12
    protected function dispatchToRouter()
13
    {
14
        // Whilst Laravel provides the package Router instance within all app
15
        // code, it is hardcoded in the base Kernel class and needs to be set
16
        // directly here when we are using custom JSON API router extensions.
17
        parent::__construct($this->app, $this->app['router']);
0 ignored issues
show
Bug introduced by
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Comprehensibility Bug introduced by
It seems like you call parent on a different method (__construct() instead of dispatchToRouter()). Are you sure this is correct? If so, you might want to change this to $this->__construct().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
18
19
        return parent::dispatchToRouter();
20
    }
21
}
22