StatementFixtures::getVoidStatement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 5
nc 1
nop 1
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\Activity;
17
use Xabbuh\XApi\Model\Definition;
18
use Xabbuh\XApi\Model\Group;
19
use Xabbuh\XApi\Model\Result;
20
use Xabbuh\XApi\Model\Score;
21
use Xabbuh\XApi\Model\Statement;
22
use Xabbuh\XApi\Model\StatementReference;
23
use Xabbuh\XApi\Model\SubStatement;
24
use Xabbuh\XApi\Model\Verb;
25
26
/**
27
 * Statement fixtures.
28
 *
29
 * @author Christian Flothmann <[email protected]>
30
 */
31
class StatementFixtures
32
{
33
    const DEFAULT_STATEMENT_ID = '12345678-1234-5678-8234-567812345678';
34
35
    /**
36
     * Loads a minimal valid statement.
37
     *
38
     * @param string $id The id of the new Statement
39
     *
40
     * @return Statement
41
     */
42 View Code Duplication
    public static function getMinimalStatement($id = self::DEFAULT_STATEMENT_ID)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $actor = new Agent('mailto:[email protected]');
45
        $verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
46
        $activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
47
48
        return new Statement($id, $actor, $verb, $activity);
49
    }
50
51
    /**
52
     * Loads a statement with a group as an actor.
53
     *
54
     * @param string $id The id of the new Statement
55
     *
56
     * @return Statement
57
     */
58 View Code Duplication
    public static function getStatementWithGroupActor($id = self::DEFAULT_STATEMENT_ID)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        $group = ActorFixtures::getGroup();
61
        $verb = VerbFixtures::getVerb();
62
        $activity = ActivityFixtures::getActivity();
63
64
        return new Statement($id, $group, $verb, $activity);
65
    }
66
67
    /**
68
     * Loads a statement with a group that has no members as an actor.
69
     *
70
     * @param string $id The id of the new Statement
71
     *
72
     * @return Statement
73
     */
74 View Code Duplication
    public static function getStatementWithGroupActorWithoutMembers($id = self::DEFAULT_STATEMENT_ID)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        $group = ActorFixtures::getGroupWithoutMembers();
77
        $verb = VerbFixtures::getVerb();
78
        $activity = ActivityFixtures::getActivity();
79
80
        return new Statement($id, $group, $verb, $activity);
81
    }
82
83
    /**
84
     * Loads a statement including a reference to another statement.
85
     *
86
     * @param string $id The id of the new Statement
87
     *
88
     * @return Statement
89
     */
90
    public static function getStatementWithStatementRef($id = self::DEFAULT_STATEMENT_ID)
91
    {
92
        $minimalStatement = static::getMinimalStatement($id);
93
94
        return new Statement(
95
            $minimalStatement->getId(),
96
            $minimalStatement->getActor(),
97
            $minimalStatement->getVerb(),
98
            new StatementReference('8f87ccde-bb56-4c2e-ab83-44982ef22df0')
99
        );
100
    }
101
102
    /**
103
     * Loads a statement including a result.
104
     *
105
     * @param string $id The id of the new Statement
106
     *
107
     * @return Statement
108
     */
109
    public static function getStatementWithResult($id = self::DEFAULT_STATEMENT_ID)
110
    {
111
        $actor = new Agent('mailto:[email protected]');
112
        $verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
113
        $activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
114
        $score = new Score(0.95, 31, 0, 50);
115
        $result = new Result($score, true, true, 'Wow, nice work!', 'PT1H0M0S');
116
117
        return new Statement($id, $actor, $verb, $activity, $result);
118
    }
119
120
    /**
121
     * Loads a statement including a sub statement.
122
     *
123
     * @param string $id The id of the new Statement
124
     *
125
     * @return Statement
126
     */
127
    public static function getStatementWithSubStatement($id = self::DEFAULT_STATEMENT_ID)
128
    {
129
        $actor = new Agent('mailto:[email protected]');
130
        $verb = new Verb('http://example.com/visited', array('en-US' => 'will visit'));
131
        $definition = new Definition(
132
            array('en-US' => 'Some Awesome Website'),
133
            array('en-US' => 'The visited website'),
134
            'http://example.com/definition-type'
135
        );
136
        $activity = new Activity('http://example.com/website', $definition);
137
        $subStatement = new SubStatement(null, $actor, $verb, $activity);
138
139
        $actor = new Agent('mailto:[email protected]');
140
        $verb = new Verb('http://example.com/planned', array('en-US' => 'planned'));
141
142
        return new Statement($id, $actor, $verb, $subStatement);
143
    }
144
145
    /**
146
     * Loads a statement including an agent authority.
147
     *
148
     * @param string $id The id of the new Statement
149
     *
150
     * @return Statement
151
     */
152
    public static function getStatementWithAgentAuthority($id = self::DEFAULT_STATEMENT_ID)
153
    {
154
        $actor = new Agent('mailto:[email protected]');
155
        $verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
156
        $activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
157
        $authority = new Agent(null, null, null, new Account('anonymous', 'http://cloud.scorm.com/'));
158
159
        return new Statement($id, $actor, $verb, $activity, null, $authority);
160
    }
161
162
    /**
163
     * Loads a statement including a group authority.
164
     *
165
     * @param string $id The id of the new Statement
166
     *
167
     * @return Statement
168
     */
169 View Code Duplication
    public static function getStatementWithGroupAuthority($id = self::DEFAULT_STATEMENT_ID)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
170
    {
171
        $actor = new Agent('mailto:[email protected]');
172
        $verb = new Verb('http://adlnet.gov/expapi/verbs/created', array('en-US' => 'created'));
173
        $activity = new Activity('http://example.adlnet.gov/xapi/example/activity');
174
        $user = new Agent(null, null, null, new Account('oauth_consumer_x75db', 'http://example.com/xAPI/OAuth/Token'));
175
        $application = new Agent('mailto:[email protected]');
176
        $authority = new Group(null, null, null, null, null, array($user, $application));
177
178
        return new Statement($id, $actor, $verb, $activity, null, $authority);
179
    }
180
181
    /**
182
     * Loads a void statement.
183
     *
184
     * @param string $id The id of the new Statement
185
     *
186
     * @return Statement
187
     */
188
    public static function getVoidStatement($id = self::DEFAULT_STATEMENT_ID)
189
    {
190
        $actor = new Agent('mailto:[email protected]');
191
        $verb = Verb::createVoidVerb();
192
        $object = new StatementReference('e05aa883-acaf-40ad-bf54-02c8ce485fb0');
193
194
        return new Statement($id, $actor, $verb, $object);
195
    }
196
}
197