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

EtherumVessel   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 8
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequiredAscension() 0 3 1
A calculateRequiredAscension() 0 9 3
A getEtherumLoad() 0 3 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