Passed
Push — master ( 123b10...c45d3f )
by Julien
05:28
created

RoleFeature   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
dl 0
loc 22
ccs 0
cts 10
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 6 1
A validation() 0 9 1
1
<?php
2
/**
3
 * This file is part of the Zemit Framework.
4
 *
5
 * (c) Zemit Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE.txt
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zemit\Models;
12
13
use Zemit\Models\Abstracts\AbstractRoleFeature;
14
use Zemit\Models\Interfaces\RoleFeatureInterface;
15
16
/**
17
 * @property Role $RoleEntity
18
 * @method Role getRoleEntity(?array $params = null)
19
 * 
20
 * @property Feature $FeatureEntity
21
 * @method Feature getFeatureEntity(?array $params = null)
22
 */
23
class RoleFeature extends AbstractRoleFeature implements RoleFeatureInterface
24
{
25
    protected $deleted = self::NO;
26
    protected $position = self::NO;
27
28
    public function initialize(): void
29
    {
30
        parent::initialize();
31
32
        $this->hasOne('roleId', Role::class, 'id', ['alias' => 'Role']);
33
        $this->hasOne('featureId', Feature::class, 'id', ['alias' => 'Feature']);
34
    }
35
36
    public function validation(): bool
37
    {
38
        $validator = $this->genericValidation();
39
        
40
        $this->addUniquenessValidation($validator, ['roleId', 'featureId']);
41
        $this->addUnsignedIntValidation($validator, 'roleId', false);
42
        $this->addUnsignedIntValidation($validator, 'featureId', false);
43
44
        return $this->validate($validator);
45
    }
46
}
47