Completed
Push — refactor-entity-validators ( 9b4b77...c6627d )
by Stefano
13:07 queued 10:18
created

SluggableTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 29
ccs 2
cts 2
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSlug() 0 4 1
A setSlug() 0 8 2
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
    public function getSlug()
21
    {
22
        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
        if ($slug !== null) {
33 1
            $slug = (string) $slug;
34
        }
35
36
        $this->slug = $slug;
37
    }
38
}
39