SluggableTrait::getSlug()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Persistence\Entity;
9
10
trait SluggableTrait
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $slug;
16
17
    /**
18
     * @return string
19
     */
20 1
    public function getSlug()
21
    {
22 1
        return $this->slug;
23
    }
24
25
    /**
26
     * Setting to null should regenerate the slug
27
     *
28
     * @param string|null $slug
29
     */
30 1
    public function setSlug($slug)
31
    {
32 1
        if ($slug !== null) {
33 1
            $slug = (string) $slug;
34 1
        }
35
36 1
        $this->slug = $slug;
37 1
    }
38
}
39