AbstractFinalTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 42
rs 10

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 samsonphp\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
    public function defFinal()
28
    {
29
        if ($this->isAbstract) {
30
            throw new \InvalidArgumentException('Method cannot be final as it is already abstract');
31
        }
32
33
        $this->isFinal = true;
34
35
        return $this;
36
    }
37
38
    /**
39
     * Set to be abstract.
40
     *
41
     * @return $this
42
     * @throws \InvalidArgumentException
43
     */
44
    public function defAbstract()
45
    {
46
        if ($this->isFinal) {
47
            throw new \InvalidArgumentException('Method cannot be abstract as it is already final');
48
        }
49
50
        $this->isAbstract = true;
51
52
        return $this;
53
    }
54
}
55