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

HasName::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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