FinalTrait::isFinal()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Igni\Utils\ReflectionApi;
4
5
use Igni\Utils\Exception\ReflectionApiException;
6
7 View Code Duplication
trait FinalTrait
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    private $final = false;
10
11 3
    public function makeFinal(bool $final = true): self
12
    {
13 3
        if (isset($this->abstract) && $this->abstract) {
0 ignored issues
show
Bug introduced by
The property abstract does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
14 1
            throw ReflectionApiException::forFinalAbstract();
15
        }
16
17 2
        $this->final = $final;
18
19 2
        return $this;
20
    }
21
22 9
    public function isFinal(): bool
23
    {
24 9
        return $this->final;
25
    }
26
}
27