FinalTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A makeFinal() 10 10 3
A isFinal() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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