BaseObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getIterator() 0 4 1
A getName() 0 4 1
A setName() 0 4 1
1
<?php
2
3
namespace SimpleAcl;
4
5
use IteratorAggregate;
6
use SimpleAcl\Object\RecursiveIterator;
7
8
/**
9
 * Use to keep shared function between Roles and Resources.
10
 *
11
 * @package SimpleAcl
12
 */
13
abstract class BaseObject implements IteratorAggregate
14
{
15
  /**
16
   * Hold the name of object.
17
   *
18
   * @var string
19
   */
20
  public $name;
21
22
  /**
23
   * Create Object with given name.
24
   *
25
   * @param string $name
26
   */
27
  public function __construct(string $name)
28
  {
29
    $this->setName($name);
30
  }
31
32
  /**
33
   * @return RecursiveIterator
34
   */
35
  public function getIterator(): RecursiveIterator
36
  {
37
    return new RecursiveIterator([$this]);
38
  }
39
40
  /**
41
   * @return string
42
   */
43
  public function getName(): string
44
  {
45
    return $this->name;
46
  }
47
48
  /**
49
   * @param string $name
50
   */
51
  public function setName(string $name)
52
  {
53
    $this->name = $name;
54
  }
55
}
56