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

GroupFeature::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\AbstractGroupFeature;
14
use Zemit\Models\Interfaces\GroupFeatureInterface;
15
16
/**
17
 * @property Group $Group
18
 * @method Group getGroup(?array $params = null)
19
 * 
20
 * @property Feature $Feature
21
 * @method Feature getFeature(?array $params = null)
22
 */
23
class GroupFeature extends AbstractGroupFeature implements GroupFeatureInterface
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('groupId', Group::class, 'id', ['alias' => 'Group']);
33
        $this->hasOne('featureId', Feature::class, 'id', ['alias' => 'Feature']);
34
    }
35
36
    public function validation(): bool
37
    {
38
        $validator = $this->genericValidation();
39
40
        $this->addUnsignedIntValidation($validator, 'groupId', false);
41
        $this->addUnsignedIntValidation($validator, 'featureId', false);
42
        $this->addUniquenessValidation($validator, ['groupId', 'featureId'], false);
43
        
44
        return $this->validate($validator);
45
    }
46
}
47