AbstractFinalTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A defFinal() 0 10 2
A defAbstract() 0 10 2
1
<?php declare(strict_types=1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 04.09.16 at 12:07
5
 */
6
namespace samsonframework\generator;
7
8
/**
9
 * Class AbstractFinalTrait
10
 *
11
 * @author Vitaly Egorov <[email protected]>
12
 */
13
trait AbstractFinalTrait
14
{
15
    /** @var bool Flag that method is abstract */
16
    protected $isAbstract = false;
17
18
    /** @var bool Flag that method is final */
19
    protected $isFinal = false;
20
21
    /**
22
     * Set to be final.
23
     *
24
     * @return $this
25
     * @throws \InvalidArgumentException
26
     */
27 7
    public function defFinal()
28
    {
29 7
        if ($this->isAbstract) {
30 2
            throw new \InvalidArgumentException('Method cannot be final as it is already abstract');
31
        }
32
33 5
        $this->isFinal = true;
34
35 5
        return $this;
36
    }
37
38
    /**
39
     * Set to be abstract.
40
     *
41
     * @return $this
42
     * @throws \InvalidArgumentException
43
     */
44 8
    public function defAbstract()
45
    {
46 8
        if ($this->isFinal) {
47 2
            throw new \InvalidArgumentException('Method cannot be abstract as it is already final');
48
        }
49
50 6
        $this->isAbstract = true;
51
52 6
        return $this;
53
    }
54
}
55