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

RoleRole::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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\AbstractRoleRole;
0 ignored issues
show
Bug introduced by
The type Zemit\Models\Abstracts\AbstractRoleRole was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Zemit\Models\Interfaces\RoleRoleInterface;
15
16
/**
17
 * @property Role $Parent
18
 * @method Role getParent(?array $params = null)
19
 * 
20
 * @property Role $Child
21
 * @method Role getChild(?array $params = null)
22
 */
23
class RoleRole extends AbstractRoleRole implements RoleRoleInterface
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('parentId', Role::class, 'id', ['alias' => 'Parent']);
33
        $this->hasOne('childId', Role::class, 'id', ['alias' => 'Child']);
34
    }
35
36
    public function validation(): bool
37
    {
38
        $validator = $this->genericValidation();
39
        
40
        $this->addUniquenessValidation($validator, ['parentId', 'childId']);
41
        $this->addUnsignedIntValidation($validator, 'parentId', false);
42
        $this->addUnsignedIntValidation($validator, 'childId', false);
43
44
        return $this->validate($validator);
45
    }
46
}
47