ConstObject   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 36
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __set() 0 4 1
A getIterator() 0 4 1
A count() 0 4 1
A __get() 0 9 2
1
<?php
2
/**
3
 * spindle/types
4
 *
5
 * @license CC0-1.0 (Public Domain) https://creativecommons.org/publicdomain/zero/1.0/
6
 */
7
namespace Spindle\Types;
8
9
/**
10
 * TypedObjectを固定化するDecoratorクラス
11
 *
12
 */
13
class ConstObject implements
14
    \IteratorAggregate,
15
    \Countable
16
{
17
    protected $_object;
18
19 3
    final function __construct(TypedObject $obj)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
20
    {
21 3
        $this->_object = $obj;
22 3
    }
23
24 1
    final function __get($name)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
    {
26 1
        $val = $this->_object->$name;
27 1
        if ($val instanceof TypedObject) {
28 1
            return new self($val);
29
        } else {
30 1
            return $val;
31
        }
32
    }
33
34 1
    final function __set($name, $value)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
    {
36 1
        throw new \DomainException(__CLASS__ . "->$name = $value is not allowed.");
37
    }
38
39 1
    function getIterator()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
    {
41 1
        return $this->_object->getIterator();
42
    }
43
44 1
    function count()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
45
    {
46 1
        return $this->_object->count();
47
    }
48
}
49