Passed
Push — master ( 294cf3...a47581 )
by Paweł
03:58
created

RebredirTrait::calculateRequiredAscension()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 3
nc 3
nop 0
crap 3
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 RebredirTrait
11
{
12
    private Etherum $etherumLoad;
13
14 1
    public function getEtherumLoad(): Etherum
15
    {
16 1
        return $this->etherumLoad;
17
    }
18
19 4
    public function getRequiredAscension(): Ascension
20
    {
21 4
        return $this->calculateRequiredAscension();
22
    }
23
24 4
    private function calculateRequiredAscension(): Ascension
25
    {
26 4
        foreach (range(Ascension::EIGHTH_ASCENSION, Ascension::FIRST_ASCENSION) as $ascension) {
27 4
            if ($this->etherumLoad->isGreaterThanOrEqual((new Ascension($ascension))->getRequiredEtherum())) {
28 3
                return new Ascension($ascension);
29
            }
30
        }
31
32 1
        return Ascension::firstAscension();
33
    }
34
}
35