Total Complexity | 6 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class UrlValidator extends Validator |
||
8 | { |
||
9 | public const COMPONENT_SCHEME = 'scheme'; |
||
10 | public const COMPONENT_HOST = 'host'; |
||
11 | public const COMPONENT_PORT = 'port'; |
||
12 | public const COMPONENT_USER = 'user'; |
||
13 | public const COMPONENT_PASS = 'pass'; |
||
14 | public const COMPONENT_PATH = 'path'; |
||
15 | public const COMPONENT_QUERY = 'query'; |
||
16 | public const COMPONENT_FRAGMENT = 'fragment'; |
||
17 | |||
18 | public $schemes = ['http', 'https']; |
||
19 | |||
20 | public $components = [ |
||
21 | self::COMPONENT_SCHEME, |
||
22 | self::COMPONENT_HOST, |
||
23 | ]; |
||
24 | |||
25 | 4 | public function init() |
|
26 | { |
||
27 | 4 | parent::init(); |
|
28 | |||
29 | 4 | if ($this->message === null) { |
|
30 | 4 | $this->message = Yii::t('yii', '{attribute} is not a valid URL.'); |
|
31 | } |
||
32 | 4 | } |
|
33 | |||
34 | 4 | protected function validateValue($value) |
|
48 | } |
||
49 | } |
||
50 |