Completed
Push — master ( c6f552...0c6c94 )
by Dmitry
15:05
created

NamedEventTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
A getName() 0 4 1
1
<?php
2
3
namespace hiapi\event;
4
5
/**
6
 * Trait NamedEventTrait
7
 *
8
 * @author Dmytro Naumenko <[email protected]>
9
 */
10
trait NamedEventTrait
11
{
12
    /**
13
     * @var string
14
     */
15
    private $name;
16
    
17
    public static function create(string $name, $target = null): self
18
    {
19
        $event = new self($target);
0 ignored issues
show
Unused Code introduced by
The call to NamedEventTrait::__construct() has too many arguments starting with $target.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
20
        $event->name = $name;
21
        
22
        return $event;
23
    }
24
    
25
    /**
26
     * @inheritdoc
27
     */
28
    public function getName()
29
    {
30
        return $this->name;
31
    }
32
}
33