UrlRule::createRule()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 6
rs 10
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-rest/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-rest
7
 */
8
9
namespace flipbox\craft\rest;
10
11
/**
12
 * @inheritdoc
13
 *
14
 * @author Flipbox Factory <[email protected]>
15
 * @since 1.0.0
16
 */
17
class UrlRule extends \yii\rest\UrlRule
18
{
19
    /**
20
     * The prefix to the action
21
     *
22
     * @var string
23
     */
24
    public $prepend;
25
26
    /**
27
     * @inheritdoc
28
     */
29
    protected function createRule($pattern, $prefix, $action)
30
    {
31
        if (!empty($this->prepend)) {
32
            $action = $this->prepend . '/' . $action;
33
        }
34
35
        return parent::createRule($pattern, $prefix, $action);
36
    }
37
}
38