Resource   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 38
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseRequest() 0 23 6
1
<?php
2
3
namespace roaresearch\yii2\roa\urlRules;
4
5
use Yii;
6
7
/**
8
 * Default Url Rule to handle resources with collections.
9
 *
10
 * Supports representative URL using ownership slug.
11
 *
12
 * @author Angel (Faryshta) Guevara <[email protected]>
13
 */
14
class Resource extends \yii\rest\UrlRule
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public $pluralize = false;
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public $tokens = ['{id}' => '<id:\d+>'];
25
26
    /**
27
     * @inheritdoc
28
     */
29 18
    public function parseRequest($manager, $request)
30
    {
31 18
        $pathInfo = $request->getPathInfo();
0 ignored issues
show
Unused Code introduced by
The assignment to $pathInfo is dead and can be removed.
Loading history...
32 18
        foreach ($this->rules as $urlName => $rules) {
33 18
            foreach ($rules as $rule) {
34
                /* @var $rule \yii\web\UrlRule */
35 18
                $result = $rule->parseRequest($manager, $request);
36 18
                if (YII_DEBUG) {
37 18
                    Yii::trace([
0 ignored issues
show
Deprecated Code introduced by
The function yii\BaseYii::trace() has been deprecated: since 2.0.14. Use [[debug()]] instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

37
                    /** @scrutinizer ignore-deprecated */ Yii::trace([

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
38 18
                        'rule' => $rule instanceof \Stringable
39 18
                            ? (string)$rule
40 18
                            : $rule::class,
41
                        'match' => $result !== false,
42
                        'parent' => static::class,
43
                    ], __METHOD__);
44
                }
45 18
                if ($result !== false) {
46 18
                    return $result;
47
                }
48
            }
49
        }
50
51 14
        return false;
52
    }
53
}
54