Test Failed
Branch master (fb3e9d)
by 世昌
03:53
created

Parameter::setIndexName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace nebula\route\uri\parameter;
3
4
/**
5
 * 匹配参数
6
 */
7
abstract class Parameter   {
8
9
    protected static $name;
10
    /**
11
     * 索引名
12
     *
13
     * @var string
14
     */
15
    protected $indexName;
16
    /**
17
     * 默认值
18
     *
19
     * @var mixed
20
     */
21
    protected $default;
22
23
    public static function name():string {
24
        return static::$name;
25
    }
26
27
    public static function build(string $indexName, string $extra):Parameter {
28
        $parameter =  new static($extra);
0 ignored issues
show
Unused Code introduced by
The call to nebula\route\uri\paramet...arameter::__construct() has too many arguments starting with $extra. ( Ignorable by Annotation )

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

28
        $parameter =  /** @scrutinizer ignore-call */ new static($extra);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
29
        $parameter->setIndexName($indexName);
30
        return $parameter;
31
    }
32
    
33
    public function getValue(string $matched) {
34
        return $matched;
35
    }
36
37
    public function getDefaultValue() {
38
        return isset($this->default) ? $this->default : null;
39
    }
40
41
    /**
42
     * 获取匹配字符串
43
     *
44
     * @return string
45
     */
46
    abstract function getMatch():string;
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
47
48
    public function getCommonDefault(string $extra):string {
49
        return $extra;
50
    }
51
52
    /**
53
     * Get 索引名
54
     *
55
     * @return  string
56
     */ 
57
    public function getIndexName()
58
    {
59
        return $this->indexName;
60
    }
61
62
    /**
63
     * Set 索引名
64
     *
65
     * @param  string  $indexName  索引名
66
     *
67
     * @return  self
68
     */ 
69
    public function setIndexName(string $indexName)
70
    {
71
        $this->indexName = $indexName;
72
73
        return $this;
74
    }
75
}