Passed
Push — master ( a47581...085587 )
by Paweł
05:58
created

EtherumVessel::getRequiredAscension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 EtherumVessel
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