DocumentFixtures::getStateDocument()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 11
loc 11
rs 9.4285
c 2
b 0
f 0
cc 2
eloc 6
nc 2
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\Activity;
15
use Xabbuh\XApi\Model\ActivityProfile;
16
use Xabbuh\XApi\Model\ActivityProfileDocument;
17
use Xabbuh\XApi\Model\Agent;
18
use Xabbuh\XApi\Model\AgentProfile;
19
use Xabbuh\XApi\Model\AgentProfileDocument;
20
use Xabbuh\XApi\Model\DocumentData;
21
use Xabbuh\XApi\Model\State;
22
use Xabbuh\XApi\Model\StateDocument;
23
24
/**
25
 * Document fixtures.
26
 *
27
 * @author Christian Flothmann <[email protected]>
28
 */
29
class DocumentFixtures
30
{
31
    /**
32
     * Loads empty document data.
33
     *
34
     * @return DocumentData
35
     */
36
    public static function getEmptyDocumentData()
37
    {
38
        return new DocumentData();
39
    }
40
41
    /**
42
     * Loads document data.
43
     *
44
     * @return DocumentData
45
     */
46
    public static function getDocumentData()
47
    {
48
        return new DocumentData(array('x' => 'foo', 'y' => 'bar'));
49
    }
50
51
    /**
52
     * Loads an activity profile document.
53
     *
54
     * @param DocumentData $documentData The document data, by default, a some
55
     *                                   default data will be used
56
     *
57
     * @return ActivityProfileDocument
58
     */
59 View Code Duplication
    public static function getActivityProfileDocument(DocumentData $documentData = null)
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...
60
    {
61
        if (null === $documentData) {
62
            $documentData = static::getDocumentData();
63
        }
64
65
        $activityProfile = new ActivityProfile('profile-id', new Activity('activity-id'));
66
67
        return new ActivityProfileDocument($activityProfile, $documentData);
68
    }
69
70
    /**
71
     * Loads an agent profile document.
72
     *
73
     * @param DocumentData $documentData The document data, by default, a some
74
     *                                   default data will be used
75
     *
76
     * @return AgentProfileDocument
77
     */
78
    public static function getAgentProfileDocument(DocumentData $documentData = null)
79
    {
80
        if (null === $documentData) {
81
            $documentData = static::getDocumentData();
82
        }
83
84
        return new AgentProfileDocument(new AgentProfile('profile-id', new Agent()), $documentData);
85
    }
86
87
    /**
88
     * Loads a state document.
89
     *
90
     * @param DocumentData $documentData The document data, by default, a some
91
     *                                   default data will be used
92
     *
93
     * @return StateDocument
94
     */
95 View Code Duplication
    public static function getStateDocument(DocumentData $documentData = null)
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...
96
    {
97
        if (null === $documentData) {
98
            $documentData = static::getDocumentData();
99
        }
100
101
        $agent = new Agent('mailto:[email protected]');
102
        $activity = new Activity('activity-id');
103
104
        return new StateDocument(new State($activity, $agent, 'state-id'), $documentData);
105
    }
106
}
107