Passed
Push — master ( 04cf7a...5cb2ae )
by Jon
03:42
created

AbstractComponent::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace FlatPlan\Components;
2
3
abstract class AbstractComponent {
4
5
    protected $role;
6
7
    abstract protected function getComponent();
8
9
    public function setRole($role)
10
    {
11
        if (!in_array($role, $this->roles)) {
12
            throw new \ErrorException('Invalid role supplied.');
13
        }
14
        $this->role = $role;
15
    }
16
17
    public function getRole()
18
    {
19
        return $this->role;
20
    }
21
22
    public function __toString()
23
    {
24
        return json_encode($this->getComponent());
25
    }
26
}
27