Group   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 76.92%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 48
ccs 10
cts 13
cp 0.7692
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getMembers() 0 4 1
A equals() 0 20 5
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Model;
13
14
/**
15
 * A group of {@link Agent Agents} of a {@link Statement}.
16
 *
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
final class Group extends Actor
20
{
21
    private $members = array();
22
23
    /**
24
     * @param Agent[] $members
25
     */
26
    public function __construct(InverseFunctionalIdentifier $iri = null, string $name = null, array $members = array())
27
    {
28
        parent::__construct($iri, $name);
29
30
        $this->members = $members;
31 3
    }
32
33 3
    /**
34
     * Returns the members of this group.
35 3
     *
36 3
     * @return Agent[]
37
     */
38
    public function getMembers(): array
39
    {
40
        return $this->members;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function equals(StatementObject $actor): bool
47
    {
48
        if (!parent::equals($actor)) {
49
            return false;
50
        }
51 16
52
        /** @var Group $actor */
53 16
54 14
        if (count($this->members) !== count($actor->members)) {
55
            return false;
56
        }
57 2
58 1
        foreach ($this->members as $member) {
59
            if (!in_array($member, $actor->members)) {
60
                return false;
61
            }
62
        }
63 1
64
        return true;
65
    }
66
}
67