AbstractRole   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 2 1
A getName() 0 2 1
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
}