Actor   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 57
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getInverseFunctionalIdentifier() 0 4 1
A getName() 0 4 1
B equals() 0 24 8
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
 * The Actor of a {@link Statement}.
16
 *
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
abstract class Actor extends StatementObject
20
{
21
    private $iri;
22
    private $name;
23
24
    public function __construct(InverseFunctionalIdentifier $iri = null, string $name = null)
25
    {
26
        $this->iri = $iri;
27
        $this->name = $name;
28
    }
29
30
    /**
31
     * Returns the Actor's {@link InverseFunctionalIdentifier inverse functional identifier}.
32
     */
33
    public function getInverseFunctionalIdentifier(): ?InverseFunctionalIdentifier
34
    {
35
        return $this->iri;
36
    }
37
38 15
    /**
39
     * Returns the name of the {@link Agent} or {@link Group}.
40 15
     */
41 15
    public function getName(): ?string
42 15
    {
43
        return $this->name;
44
    }
45
46
    /**
47
     * Checks if another actor is equal.
48
     *
49 19
     * Two actors are equal if and only if all of their properties are equal.
50
     */
51 19
    public function equals(StatementObject $actor): bool
52
    {
53
        if (!parent::equals($actor)) {
54
            return false;
55
        }
56
57
        if (!$actor instanceof Actor) {
58
            return false;
59
        }
60
61
        if ($this->name !== $actor->name) {
62
            return false;
63
        }
64
65
        if (null !== $this->iri xor null !== $actor->iri) {
66
            return false;
67
        }
68
69
        if (null !== $this->iri && null !== $actor->iri && !$this->iri->equals($actor->iri)) {
70
            return false;
71
        }
72
73 26
        return true;
74
    }
75
}
76