Completed
Push — master ( f706eb...84b009 )
by Antonio
01:40
created

RbacRuleExistsValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateValue() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-usuario project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\User\Validator;
13
14
use Da\User\Traits\AuthManagerAwareTrait;
15
use Yii;
16
use yii\validators\Validator;
17
18
class RbacRuleExistsValidator extends Validator
19
{
20
    use AuthManagerAwareTrait;
21
22
    protected function validateValue($value)
23
    {
24
        $rule = $this->getAuthManager()->getRule($value);
25
26
        if (!$rule) {
27
            return [Yii::t('usuario', 'Rule {0} does not exists', $value), []];
28
        }
29
    }
30
}
31