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\DataFixtures; |
13
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Model\Account; |
15
|
|
|
use Xabbuh\XApi\Model\Agent; |
16
|
|
|
use Xabbuh\XApi\Model\Group; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Actor fixtures. |
20
|
|
|
* |
21
|
|
|
* @author Christian Flothmann <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class ActorFixtures |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Loads an agent. |
27
|
|
|
* |
28
|
|
|
* @return Agent |
29
|
|
|
*/ |
30
|
|
|
public static function getAgent() |
31
|
|
|
{ |
32
|
|
|
$agent = new Agent('mailto:[email protected]', null, null, null, 'Christian'); |
33
|
|
|
|
34
|
|
|
return $agent; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Loads a group. |
39
|
|
|
* |
40
|
|
|
* @return Group |
41
|
|
|
*/ |
42
|
|
|
public static function getGroup() |
43
|
|
|
{ |
44
|
|
|
$account = new Account('GroupAccount', 'http://example.com/homePage'); |
45
|
|
|
|
46
|
|
|
return static::createGroup('Example Group', $account); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Loads a group that has no members. |
51
|
|
|
* |
52
|
|
|
* @return Group |
53
|
|
|
*/ |
54
|
|
|
public static function getGroupWithoutMembers() |
55
|
|
|
{ |
56
|
|
|
$account = new Account('GroupAccount', 'http://example.com/homePage'); |
57
|
|
|
|
58
|
|
|
return new Group(null, null, null, $account, 'Example Group'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Loads an anonymous group. |
63
|
|
|
* |
64
|
|
|
* @return Group |
65
|
|
|
*/ |
66
|
|
|
public static function getAnonymousGroup() |
67
|
|
|
{ |
68
|
|
|
return static::createGroup('Anonymous Group'); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
private static function createGroup($name, Account $account = null) |
72
|
|
|
{ |
73
|
|
|
$memberAccount = new Account('Member of a group', 'http://example.com/account'); |
74
|
|
|
$agent1 = new Agent('mailto:[email protected]', null, null, $memberAccount, 'Andrew Downes'); |
75
|
|
|
$agent2 = new Agent(null, null, 'aaron.openid.example.org', null, 'Aaron Silvers'); |
76
|
|
|
$group = new Group(null, null, null, $account, $name, array($agent1, $agent2)); |
77
|
|
|
|
78
|
|
|
return $group; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: