Completed
Push — master ( 84cf1c...e28c1d )
by John
03:12
created

BasicURLParser::parse()   B

Complexity

Conditions 4
Paths 3

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 18
nc 3
nop 1
dl 0
loc 29
rs 8.5806
c 0
b 0
f 0
ccs 17
cts 17
cp 1
crap 4
1
<?php
2
namespace LunixRESTBasics\APIRequest\URLParser;
3
4
use LunixREST\APIRequest\URLParser\RegexURLParser\RegexURLParser;
5
6
/**
7
 * A basic URL parser. Expects URLS in the format:
8
 * /VERSION/APIKEY/ENDPOINT_NAME[/INSTANCE_ID].EXTENSION[?QUERY_STRING]
9
 * Class BasicURLParser
10
 * @package LunixRESTBasics\APIRequest\URLParser
11
 */
12
class BasicURLParser extends RegexURLParser
13
{
14
    private const URL_PATTERN = "@/(?<version>[^/]*)/(?<apiKey>[^/]*)/(?<endpoint>[^/.]*)(?:/(?<element>[^.]*))?.(?<acceptableExtension>[^/]*)/?@";
15
16
    /**
17
     * BasicURLParser constructor.
18
     */
19 4
    public function __construct()
20
    {
21 4
        parent::__construct(self::URL_PATTERN, new GuzzleMIMEProvider());
22 4
    }
23
}
24