NullableNameTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A setName() 0 10 2
1
<?php
2
3
/**
4
 * This file is part of the Axstrad library.
5
 *
6
 * (c) Dan Kempster <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @copyright 2014-2015 Dan Kempster <[email protected]>
12
 */
13
14
namespace Axstrad\Common\Traits;
15
16
17
/**
18
 * Axstrad\Common\Traits\NullableNameTrait
19
 *
20
 * @author Dan Kempster <[email protected]>
21
 * @license MIT
22
 * @package Axstrad/Common
23
 * @subpackage Traits
24
 */
25
trait NullableNameTrait
26
{
27
    use NameTrait;
28
29
30
    /**
31
     * Set name
32
     *
33
     * @param null|string $name
34
     * @return self
35
     * @see getTitle
36
     */
37
    public function setName($name = null)
38
    {
39
        if ($name === null) {
40
            $this->name = null;
41
        }
42
        else {
43
            $this->name = (string) $name;
44
        }
45
        return $this;
46
    }
47
}
48