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

ImsLtiServiceRequestFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 16 5
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