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

Prefixed   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A generate() 0 4 1
A parse() 0 8 2
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