AbstractType::__set()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
/**
3
 * ShouldPHP
4
 *
5
 * @author  Gabriel Jacinto <[email protected]>
6
 * @status  dev
7
 * @link    https://github.com/GabrielJMJ/ShouldPHP
8
 * @license MIT
9
 */
10
 
11
namespace Gabrieljmj\Should;
12
13
use Gabrieljmj\Should\ShouldInterface;
14
15
abstract class AbstractType
16
{
17
    /**
18
     * @var \Gabrieljmj\Should\ShouldInterface
19
     */
20
    protected $should;
21
22
    /**
23
     * @param string $property
24
     * @param mixed  $value
25
     */
26
    public function __set($property, $value)
27
    {
28
        if ($property === 'should') {
29
            throw new Exception(sprintf('You can not set the property Gabrieljmj\Should\%s::$should', get_class($this)));
30
        }
31
        
32
        $this->{$property} = $value;
33
    }
34
35
    /**
36
     * @param \Gabrieljmj\Should\ShouldInterface $should
37
     */
38
    protected function setShould(ShouldInterface $should)
39
    {
40
        $this->should = $should;
41
    }
42
}