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

StringParameter::packValue()   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
 * 匹配 string 参数
8
 */
9
class StringParameter extends Parameter {
10
11
    protected static $name = 'string';
12
    
13
    public function __construct(string $extra) {
14
        $this->default = $this->getCommonDefault($extra);
15
    }
16
 
17
    public function unpackValue(string $matched) {
18
        return urldecode($matched);
19
    }
20
21
    public function packValue(string $matched) {
22
        return urlencode($matched);
23
    }
24
    
25
    /**
26
     * 获取匹配字符串
27
     *
28
     * @return string
29
     */
30
    public function getMatch():string {
31
        return '([^\/]+)';
32
    }
33
}