Completed
Push — master ( b6640d...1255af )
by Mathieu
04:15
created

Permission   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A setName() 0 5 1
A name() 0 4 1
1
<?php
2
3
namespace Charcoal\User;
4
5
// Module `charcoal-core` dependencies
6
use \Charcoal\Model\AbstractModel;
7
8
// Module `charcoal-base` dependencies
9
use \Charcoal\Object\CategorizableInterface;
10
use \Charcoal\Object\CategorizableTrait;
11
12
// Module `charcoal-translation` dependencies
13
use \Charcoal\Translation\TranslationString;
14
15
/**
16
 * A permission is a simple string, that can be read with additional data (name + category) from storage.
17
 */
18
class Permission extends AbstractModel implements CategorizableInterface
19
{
20
    use CategorizableTrait;
21
22
    /**
23
     * @var string $ident
24
     */
25
    public $ident;
26
27
    /**
28
     * @var TranslationString $name
29
     */
30
    private $name;
31
32
    /**
33
     * Permission can be used as a string (ident).
34
     *
35
     * @return string
36
     */
37
    public function __toString()
38
    {
39
        return (string)$this->ident;
40
    }
41
42
    /**
43
     * @param mixed $name The permission name / label.
44
     * @return Permission Chainable
45
     */
46
    public function setName($name)
47
    {
48
        $this->name = new TranslationString($name);
49
        return $this;
50
    }
51
52
    /**
53
     * @return TranslationString
54
     */
55
    public function name()
56
    {
57
        return $this->name;
58
    }
59
}
60