Progression::raidById()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php namespace GameScan\WoW\Entity\Player;
2
3
trait Progression
4
{
5
6
    abstract public function getEntityInformations();
7
    abstract public function retreiveField($fielName);
8
9
    public function raids()
10
    {
11
        $this->retreiveField("progression");
12
        return $this->getEntityInformations()->progression->raids;
13
    }
14
15
    public function raidById($id)
16
    {
17
        return $this->extratRaid("id", $id);
18
    }
19
20
    public function raidByName($name)
21
    {
22
        return $this->extratRaid("name", $name);
23
    }
24
25
    protected function extratRaid($key, $value)
26
    {
27
        $raids = $this->raids();
28
        $raid = array_filter($raids, function ($raid) use ($key, $value) {
29
            return $raid->{$key} === $value;
30
        });
31
32
        return array_shift($raid);
33
    }
34
}
35