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
|
|
|
private $activity; |
22
|
|
|
private $actor; |
23
|
|
|
private $registrationId; |
24
|
|
|
private $stateId; |
25
|
|
|
|
26
|
|
|
public function __construct(Activity $activity, Actor $actor, string $stateId, string $registrationId = null) |
27
|
|
|
{ |
28
|
|
|
if (!$actor instanceof Agent) { |
29
|
|
|
@trigger_error(sprintf('Passing an instance of "%s" as the second argument is deprecated since 1.2. In 4.0, only instances of "Xabbuh\XApi\Model\Agent" will be accepted.', get_class($actor)), E_USER_DEPRECATED); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$this->activity = $activity; |
33
|
|
|
$this->actor = $actor; |
34
|
|
|
$this->stateId = $stateId; |
35
|
|
|
$this->registrationId = $registrationId; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns the activity. |
40
|
|
|
*/ |
41
|
4 |
|
public function getActivity(): Activity |
42
|
|
|
{ |
43
|
4 |
|
return $this->activity; |
44
|
4 |
|
} |
45
|
4 |
|
|
46
|
4 |
|
/** |
47
|
4 |
|
* Returns the actor. |
48
|
|
|
* |
49
|
|
|
* @deprecated since 1.2, to be removed in 4.0 |
50
|
|
|
*/ |
51
|
|
|
public function getActor(): Actor |
52
|
|
|
{ |
53
|
|
|
@trigger_error(sprintf('The "%s()" method is deprecated since 1.2 and will be removed in 4.0, use "%s::getAgent()" instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED); |
54
|
|
|
|
55
|
|
|
return $this->getAgent(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns the agent. |
60
|
|
|
* |
61
|
|
|
* @return Actor The agent |
62
|
|
|
*/ |
63
|
|
|
public function getAgent() |
64
|
|
|
{ |
65
|
|
|
return $this->actor; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Returns the registration id. |
70
|
|
|
*/ |
71
|
|
|
public function getRegistrationId(): ?string |
72
|
|
|
{ |
73
|
|
|
return $this->registrationId; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Returns the state's id. |
78
|
|
|
*/ |
79
|
|
|
public function getStateId(): string |
80
|
|
|
{ |
81
|
|
|
return $this->stateId; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|