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 provider's state stored on a remote LRS. |
16
|
|
|
* |
17
|
|
|
* @author Christian Flothmann <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
final class State |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Activity The associated activity |
23
|
|
|
*/ |
24
|
|
|
private $activity; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var Actor The associated actor |
28
|
|
|
*/ |
29
|
|
|
private $actor; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string An optional registration id |
33
|
|
|
*/ |
34
|
|
|
private $registrationId; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string The state id |
38
|
|
|
*/ |
39
|
|
|
private $stateId; |
40
|
|
|
|
41
|
4 |
|
public function __construct(Activity $activity, Actor $actor, $stateId, $registrationId = null) |
42
|
|
|
{ |
43
|
4 |
|
if (!$actor instanceof Agent) { |
44
|
4 |
|
@trigger_error(sprintf('Passing a "%s" instance as the 2nd argument is deprecated since 1.1.1 and 2.0.1. In 3.0, only instance of "Xabbuh\XApi\Model\Agent" will be accepted.', get_class($actor)), E_USER_DEPRECATED); |
45
|
4 |
|
} |
46
|
4 |
|
|
47
|
4 |
|
$this->activity = $activity; |
48
|
|
|
$this->actor = $actor; |
49
|
|
|
$this->stateId = $stateId; |
50
|
|
|
$this->registrationId = $registrationId; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Returns the activity. |
55
|
|
|
* |
56
|
|
|
* @return Activity The activity |
57
|
|
|
*/ |
58
|
|
|
public function getActivity() |
59
|
|
|
{ |
60
|
|
|
return $this->activity; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Returns the actor. |
65
|
|
|
* |
66
|
|
|
* @return Actor The actor |
67
|
|
|
* |
68
|
|
|
* @deprecated since 1.1.1 and 2.0.1, to be removed in 3.0 |
69
|
|
|
*/ |
70
|
|
|
public function getActor() |
71
|
|
|
{ |
72
|
|
|
@trigger_error(sprintf('The "%s()" method is deprecated since 1.1.1 and 2.0.1, and will be removed in 3.0. Use "%s::getAgent()" method instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED); |
73
|
|
|
|
74
|
|
|
return $this->getAgent(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Returns the agent. |
79
|
|
|
* |
80
|
|
|
* @return Actor The agent |
81
|
|
|
*/ |
82
|
|
|
public function getAgent() |
83
|
|
|
{ |
84
|
|
|
return $this->actor; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns the registration id. |
89
|
|
|
* |
90
|
|
|
* @return string The registration id |
91
|
|
|
*/ |
92
|
|
|
public function getRegistrationId() |
93
|
|
|
{ |
94
|
|
|
return $this->registrationId; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Returns the state's id. |
99
|
|
|
* |
100
|
|
|
* @return string The id |
101
|
|
|
*/ |
102
|
|
|
public function getStateId() |
103
|
|
|
{ |
104
|
|
|
return $this->stateId; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|