1 | <?php |
||
20 | class Permission extends AbstractModel implements CategorizableInterface |
||
21 | { |
||
22 | use CategorizableTrait; |
||
23 | |||
24 | /** |
||
25 | * @var string $ident |
||
26 | */ |
||
27 | private $ident; |
||
28 | |||
29 | /** |
||
30 | * @var TranslationString $name |
||
31 | */ |
||
32 | private $name; |
||
33 | |||
34 | /** |
||
35 | * Permission can be used as a string (ident). |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | public function __toString() |
||
40 | { |
||
41 | return (string)$this->ident; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param string $ident The permission identifier. |
||
46 | * @throws InvalidArgumentException If the ident is not a string. |
||
47 | * @return Permission Chainable |
||
48 | */ |
||
49 | public function setIdent($ident) |
||
50 | { |
||
51 | if (!is_string($ident)) { |
||
52 | throw new InvalidArgumentException( |
||
53 | 'Permission ident needs to be a string' |
||
54 | ); |
||
55 | } |
||
56 | $this->ident = $ident; |
||
57 | return $this; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | public function ident() |
||
64 | { |
||
65 | return $this->ident; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param mixed $name The permission name / label. |
||
70 | * @return Permission Chainable |
||
71 | */ |
||
72 | public function setName($name) |
||
73 | { |
||
74 | $this->name = new TranslationString($name); |
||
75 | return $this; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return TranslationString |
||
80 | */ |
||
81 | public function name() |
||
82 | { |
||
83 | return $this->name; |
||
84 | } |
||
85 | } |
||
86 |