Test Setup Failed
Push — master ( ecdc34...0769f8 )
by Gabriel
02:46 queued 11s
created

HasGeneratorTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assemble() 0 4 1
A assembleFull() 0 4 1
1
<?php
2
3
namespace Nip\Router\Router\Traits;
4
5
use Nip\Router\Route\Route;
6
use Nip\Router\Router;
7
8
/**
9
 * Trait HasGeneratorTrait
10
 * @package Nip\Router\Router\Traits
11
 */
12
trait HasGeneratorTrait
13
{
14
15
    /**
16
     * @param $name
17
     * @param array $params
18
     * @return string|null
19
     */
20 1
    public function assemble($name, $params = [])
21
    {
22 1
        return $this->generate($name, $params);
0 ignored issues
show
Bug introduced by
It seems like generate() 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...
23
    }
24
25
    /**
26
     * @param $name
27
     * @param array $params
28
     * @return string
29
     */
30
    public function assembleFull($name, $params = [])
31
    {
32
        return $this->generate($name, $params, self::ABSOLUTE_URL);
0 ignored issues
show
Bug introduced by
It seems like generate() 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...
33
    }
34
}
35