Passed
Push — master ( ecb839...55faee )
by Sam
07:41
created

HasName   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 3 1
A setName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Traits;
6
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * Trait for all objects with a name
11
 */
12
trait HasName
13
{
14
    /**
15
     * @var string
16
     * @ORM\Column(type="string", length=191)
17
     */
18
    private $name;
19
20
    /**
21
     * Constructor
22
     *
23
     * @param string $name
24
     */
25 9
    public function __construct($name = '')
26
    {
27 9
        $this->setName($name);
28 9
    }
29
30
    /**
31
     * Set name
32
     *
33
     * @param string $name
34
     */
35 34
    public function setName($name): void
36
    {
37 34
        $this->name = $name;
38 34
    }
39
40
    /**
41
     * Get name
42
     *
43
     * @return string
44
     */
45 20
    public function getName(): string
46
    {
47 20
        return (string) $this->name;
48
    }
49
}
50