Completed
Push — master ( e6719d...13ae3c )
by John
01:53
created

BasicBodyParserFactory::create()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 1
1
<?php
2
namespace LunixREST\Request\BodyParser;
3
4
class BasicBodyParserFactory implements BodyParserFactory {
5
    /**
6
     * Parses API request data out of a url
7
     * @param string $contentType
8
     * @return BodyParser
9
     */
10
    public function create(string $contentType): BodyParser {
11
        switch($contentType) {
12
            case 'application/x-www-form-urlencoded':
13
            default:
14
                return new URLEncodedBodyParser();
15
            case 'application/json':
0 ignored issues
show
Unused Code introduced by
case 'application/json':...arser\JSONBodyParser(); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
16
                return new JSONBodyParser();
17
        }
18
    }
19
}
20