IpVNException::chooseTemplate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * @link https://github.com/phpviet/validation
4
 *
5
 * @copyright (c) PHP Viet
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace PHPViet\Validation\Exceptions;
10
11
use Respect\Validation\Exceptions\ValidationException;
12
13
/**
14
 * @author Vuong Minh <[email protected]>
15
 * @since 1.0.0
16
 */
17
class IpVNException extends ValidationException
18
{
19
    const STANDARD = 0;
20
21
    const VERSION = 1;
22
23
    public static $defaultTemplates = [
24
        self::MODE_DEFAULT => [
25
            self::STANDARD => '{{name}} must be an IP address of Viet Nam',
26
            self::VERSION  => '{{name}} must not be an IP address version {{version}} of Viet Nam',
27
        ],
28
        self::MODE_NEGATIVE => [
29
            self::STANDARD => '{{name}} must be an IP address of Viet Nam',
30
            self::VERSION  => '{{name}} must not be an IP address version {{version}} of Viet Nam',
31
        ],
32
    ];
33
34
    public function chooseTemplate()
35
    {
36
        if (null !== $this->getParam('version')) {
37
            return static::VERSION;
38
        } else {
39
            return static::STANDARD;
40
        }
41
    }
42
}
43