AbstractRole::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @file AbstractRole.php
5
 * @brief This file contains the AbstractRole class.
6
 * @details
7
 * @author Filippo F. Fadda
8
 */
9
10
11
namespace Daikengo\Role;
12
13
14
use ToolBag\Helper\ClassHelper;
15
16
17
/**
18
 * @brief Abstract class that implements the IRole interface. Since abstract this class cannot be instantiated.
19
 * @nosubgrouping
20
 */
21
abstract class AbstractRole implements IRole {
22
  
23
  protected $name;
24
25
26
  public function __construct() {
27
    // The role's name must be lowercase.
28
    $this->name = strtolower(preg_replace('/Role$/', '', ClassHelper::getClassName(get_class($this))));
29
  }
30
31
32
  public function __toString() {
33
    return $this->getName();
34
  }
35
36
37
  public function getName() {
38
    return $this->name;
39
  }
40
41
42
  abstract public function getDescription();
43
44
}