Completed
Push — master ( 2bedd9...b42c0c )
by Christian
02:23
created

InteractionComponent::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
    /**
27
     * @param string           $id
28
     * @param LanguageMap|null $description
29
     */
30
    public function __construct($id, LanguageMap $description = null)
31
    {
32
        $this->id = $id;
33
        $this->description = $description;
34
    }
35
36
    public function getId()
37
    {
38
        return $this->id;
39
    }
40
41
    public function getDescription()
42
    {
43
        return $this->description;
44
    }
45
46
    public function equals(InteractionComponent $interactionComponent)
47
    {
48
        if ($this->id !== $interactionComponent->id) {
49
            return false;
50
        }
51
52
        if (null !== $this->description xor null !== $interactionComponent->description) {
53
            return false;
54
        }
55
56
        if (null !== $this->description && null !== $interactionComponent->description && !$this->description->equals($interactionComponent->description)) {
57
            return false;
58
        }
59
60
        return true;
61
    }
62
}
63