Completed
Push — EZP-26494 ( 820e2b...591f1b )
by
unknown
21:34
created

Prefixed::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the Prefixed class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 *
9
 * @version //autogentag//
10
 */
11
namespace eZ\Publish\Core\REST\Common\RequestParser;
12
13
use eZ\Publish\Core\REST\Common\RequestParser\EzPublish as EzPublishRequestParser;
14
15
class Prefixed extends EzPublishRequestParser
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $prefix;
21
22
    public function __construct($prefix = '', array $map = array())
23
    {
24
        $this->prefix = $prefix;
25
        parent::__construct($map);
26
    }
27
28
    public function generate($type, array $values = array())
29
    {
30
        return $this->prefix . parent::generate($type, $values);
31
    }
32
33
    public function parse($type, $url)
34
    {
35
        if (strpos($url, $this->prefix) === 0) {
36
            $url = substr($url, strlen($this->prefix));
37
        }
38
39
        return parent::parse($type, $url);
40
    }
41
}
42