DbNameValidator::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\validators;
12
13
use yii\validators\RegularExpressionValidator;
14
15
/**
16
 * Class DbNameValidator is used to validate DB names.
17
 */
18
class DbNameValidator extends RegularExpressionValidator
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public $pattern = '/^[a-z0-9_-]{2,31}$/';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function init()
29
    {
30
        $this->message = \Yii::t('hipanel:hosting', '{attribute} should contain only letters, digits, underscores or hyphens and be at least 2 symbols length');
31
    }
32
}
33