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

FloatParameter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMatch() 0 2 1
A __construct() 0 2 1
A unpackValue() 0 2 1
1
<?php
2
namespace nebula\route\uri\parameter;
3
4
use nebula\route\uri\parameter\Parameter;
5
6
/**
7
 * 匹配float参数
8
 */
9
class FloatParameter extends Parameter {
10
11
    protected static $name = 'float';
12
13
14
    public function __construct(string $extra) {
15
        $this->default = floatval($this->getCommonDefault($extra));
16
    }
17
 
18
    public function unpackValue(string $matched) {
19
        return floatval($matched);
20
    }
21
22
    /**
23
     * 获取匹配字符串
24
     *
25
     * @return string
26
     */
27
    public function getMatch():string {
28
        return '(\d+\.\d+)';
29
    }
30
}