InteractionComponent   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A getDescription() 0 4 1
A equals() 0 16 6
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\Interaction;
13
14
use Xabbuh\XApi\Model\LanguageMap;
15
16
/**
17
 * An XAPI activity interaction component.
18
 *
19
 * @author Christian Flothmann <[email protected]>
20
 */
21
final class InteractionComponent
22
{
23
    private $id;
24
    private $description;
25
26
    public function __construct(string $id, LanguageMap $description = null)
27
    {
28
        $this->id = $id;
29
        $this->description = $description;
30
    }
31
32
    public function getId(): string
33
    {
34
        return $this->id;
35
    }
36
37
    public function getDescription(): ?LanguageMap
38
    {
39
        return $this->description;
40
    }
41
42
    public function equals(InteractionComponent $interactionComponent): bool
43
    {
44
        if ($this->id !== $interactionComponent->id) {
45
            return false;
46
        }
47
48
        if (null !== $this->description xor null !== $interactionComponent->description) {
49
            return false;
50
        }
51
52
        if (null !== $this->description && null !== $interactionComponent->description && !$this->description->equals($interactionComponent->description)) {
53
            return false;
54
        }
55
56
        return true;
57
    }
58
}
59