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

RbacRuleExistsValidator::validateValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
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