MemberCollection   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getReadonlyIds() 0 3 1
A getMemberIds() 0 3 1
A add() 0 5 1
A getAdminIds() 0 3 1
A _getIds() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork\Entity\Collection;
6
7
use Polidog\Chatwork\Entity\EntityInterface;
8
use Polidog\Chatwork\Entity\Member;
9
10
class MemberCollection extends EntityCollection
11
{
12
    public function add(EntityInterface $entity)
13
    {
14
        assert($entity instanceof Member);
15
16
        return parent::add($entity);
17
    }
18
19
    /**
20
     * @return array
21
     */
22
    public function getAdminIds()
23
    {
24
        return $this->_getIds('admin');
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function getMemberIds()
31
    {
32
        return $this->_getIds('member');
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getReadonlyIds()
39
    {
40
        return $this->_getIds('readonly');
41
    }
42
43
    /**
44
     * @param string $type
45
     *
46
     * @return array
47
     */
48
    private function _getIds($type)
49
    {
50
        $ids = [];
51
        foreach ($this->entities as $entity) {
52
            if ($entity->role == $type) {
53
                $ids[] = $entity->account->accountId;
54
            }
55
        }
56
57
        return $ids;
58
    }
59
}
60