Passed
Push — master ( 65060b...2b54a2 )
by Julito
10:15
created

ImsLtiServiceRequestFactory::create()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 10
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 16
rs 9.6111
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
/**
5
 * Class ImsLtiServiceRequestFactory.
6
 */
7
class ImsLtiServiceRequestFactory
8
{
9
    /**
10
     * @param SimpleXMLElement $xml
11
     *
12
     * @return ImsLtiServiceRequest|null
13
     */
14
    public static function create(SimpleXMLElement $xml)
15
    {
16
        $bodyChildren = $xml->imsx_POXBody->children();
17
18
        if (!empty($bodyChildren)) {
19
            switch ($bodyChildren->getName()) {
20
                case 'replaceResultRequest':
21
                    return new ImsLtiServiceReplaceRequest($xml);
22
                case 'readResultRequest':
23
                    return new ImsLtiServiceReadRequest($xml);
24
                case 'deleteResultRequest':
25
                    return new ImsLtiServiceDeleteRequest($xml);
26
            }
27
        }
28
29
        return null;
30
    }
31
}
32