Activity   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 12
c 5
b 0
f 0
lcom 1
cbo 2
dl 0
loc 73
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A getDefinition() 0 4 1
D equals() 0 26 9
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
 * An Activity in a {@link Statement}.
16
 *
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
final class Activity extends Object
20
{
21
    /**
22
     * The Activity's unique identifier
23
     * @var string
24
     */
25
    private $id;
26
27
    /**
28
     * @var Definition The Activity's {@link Definition}
29
     */
30
    private $definition;
31
32
    /**
33
     * @param string     $id
34
     * @param Definition $definition
35
     */
36
    public function __construct($id = '', Definition $definition = null)
37
    {
38
        $this->id = $id;
39
        $this->definition = $definition;
40
    }
41
42
    /**
43
     * Returns the Activity's unique identifier.
44
     *
45
     * @return string The identifier
46
     */
47
    public function getId()
48
    {
49
        return $this->id;
50
    }
51
52
    /**
53
     * Returns the Activity's {@link Definition}.
54
     *
55
     * @return Definition The Definition
56
     */
57
    public function getDefinition()
58
    {
59
        return $this->definition;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function equals(Object $object)
66
    {
67
        if ('Xabbuh\XApi\Model\Activity' !== get_class($object)) {
68
            return false;
69
        }
70
71
        /** @var Activity $object */
72
73
        if ($this->id !== $object->id) {
74
            return false;
75
        }
76
77
        if (null === $this->definition && null !== $object->definition) {
78
            return false;
79
        }
80
81
        if (null !== $this->definition && null === $object->definition) {
82
            return false;
83
        }
84
85
        if (null !== $this->definition && !$this->definition->equals($object->definition)) {
86
            return false;
87
        }
88
89
        return true;
90
    }
91
}
92