MemberList   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 67
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A first() 0 4 1
A nth() 0 4 1
A all() 0 4 1
A elders() 0 8 1
A coLeaders() 0 8 1
A leader() 0 8 1
1
<?php
2
3
namespace ClashOfClans\Api\Clan;
4
5
use ClashOfClans\Api\AbstractResource;
6
7
class MemberList extends AbstractResource
8
{
9
10
    protected $casts = [
11
        'all' => Player::class
12
    ];
13
14
    /**
15
     * @return Player|null
16
     */
17
    public function first()
18
    {
19
        return $this->get(0);
20
    }
21
22
    /**
23
     * @return Player|null
24
     */
25
    public function nth($i)
26
    {
27
        return $this->get($i);
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function all()
34
    {
35
        return $this->get();
36
    }
37
38
    /**
39
     * @return Player
40
     */
41
    public function leader()
42
    {
43
        $members = $this->all();
44
45
        return array_filter($members, function ($player) {
46
            return $player->isLeader();
47
        })[0];
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function elders()
54
    {
55
        $members = $this->all();
56
57
        return array_filter($members, function ($player) {
58
            return $player->isElder();
59
        });
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function coLeaders()
66
    {
67
        $members = $this->all();
68
69
        return array_filter($members, function ($player) {
70
            return $player->isCoLeader();
71
        });
72
    }
73
}
74