Passed
Push — master ( 5a7d8c...49f3d4 )
by Paweł
02:50
created

RebredirWeapon::calculateRequiredAscension()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Inventory\Weapon;
6
7
use AardsGerds\Game\Build\Attribute\Etherum;
8
use AardsGerds\Game\Build\Talent\SecretKnowledge\Ascension;
9
10
trait RebredirWeapon
11
{
12
    private Etherum $etherumLoad;
13
14
    public function getEtherumLoad(): Etherum
15
    {
16
        return $this->etherumLoad;
17
    }
18
19
    public function getRequiredAscension(): Ascension
20
    {
21
        return $this->calculateRequiredAscension();
22
    }
23
24
    private function calculateRequiredAscension(): Ascension
25
    {
26
        foreach (range(Ascension::EIGHTH_ASCENSION, Ascension::FIRST_ASCENSION) as $ascension) {
27
            if ($this->etherumLoad->isGreaterThanOrEqual((new Ascension($ascension))->getRequiredEtherum())) {
28
                return new Ascension($ascension);
29
            }
30
        }
31
32
        return Ascension::firstAscension();
33
    }
34
}
35