Passed
Push — master ( 79ca65...aa6b0d )
by 世昌
03:39
created

IntParameter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace nebula\route\uri\parameter;
3
4
use nebula\route\uri\parameter\Parameter;
5
6
/**
7
 * 匹配int参数
8
 */
9
class IntParameter extends Parameter {
10
11
    protected static $name = 'int';
12
13
14
    public function __construct(string $extra) {
15
        $this->default = intval($this->getCommonDefault($extra));
16
    }
17
 
18
    public function unpackValue(string $matched) {
19
        return intval($matched);
20
    }
21
22
    /**
23
     * 获取匹配字符串
24
     *
25
     * @return string
26
     */
27
    public function getMatch():string {
28
        return '(\d+)';
29
    }
30
}