ImmutableTrait::__set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Igorsgm\TibiaDataApi\Traits;
4
5
use Igorsgm\TibiaDataApi\Exceptions\ImmutableException;
6
7
/**
8
 * Trait ImmutableTrait
9
 * @package Igorsgm\TibiaDataApi\Models
10
 */
11
trait ImmutableTrait
12
{
13
    /**
14
     * @var bool
15
     */
16
    protected $mutable = true;
17
18
    /**
19
     * @throws ImmutableException
20
     */
21
    public function handleImmutableConstructor()
22
    {
23
        if (!$this->mutable) {
24
            throw new ImmutableException();
25
        }
26
27
        $this->mutable = false;
28
    }
29
30
    /**
31
     * @param $key
32
     * @param $value
33
     * @throws ImmutableException
34
     */
35
    public function __set($key, $value)
36
    {
37
        throw new ImmutableException();
38
    }
39
}
40