DbNameValidator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 15
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
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