UrlRule   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 13
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUrl() 0 5 1
1
<?php
2
/**
3
 * @link https://github.com/LAV45/yii2-translated-behavior
4
 * @copyright Copyright (c) 2015 LAV45!
5
 * @author Alexey Loban <[email protected]>
6
 * @license http://opensource.org/licenses/BSD-3-Clause
7
 */
8
9
namespace lav45\translate\web;
10
11
/**
12
 * Class UrlRule
13
 * @package lav45\translate\web
14
 */
15
class UrlRule extends \yii\web\UrlRule
16
{
17
    use LanguageUrlTrait;
18
19
    /**
20
     * @inheritdoc
21
     */
22 1
    public function createUrl($manager, $route, $params)
23
    {
24 1
        $params = $this->checkLanguageParams($params);
25 1
        return parent::createUrl($manager, $route, $params);
0 ignored issues
show
Bug introduced by
It seems like $params defined by $this->checkLanguageParams($params) on line 24 can also be of type string; however, yii\web\UrlRule::createUrl() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
26
    }
27
}