BehaviorAlbum   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadModel() 0 3 1
A removeOwner() 0 3 1
1
<?php
2
3
namespace Itstructure\MFUploader\behaviors;
4
5
use yii\db\ActiveRecordInterface;
6
use Itstructure\MFUploader\models\OwnerAlbum;
7
use Itstructure\MFUploader\models\album\Album;
8
9
/**
10
 * Class BehaviorAlbum
11
 * BehaviorAlbum class to add, update and remove owners of Album model.
12
 *
13
 * @package Itstructure\MFUploader\behaviors
14
 *
15
 * @author Andrey Girnik <[email protected]>
16
 */
17
class BehaviorAlbum extends Behavior
18
{
19
    /**
20
     * Load Album model by conditions.
21
     *
22
     * @param array $conditions
23
     *
24
     * @return Album|ActiveRecordInterface|null
25
     */
26
    protected function loadModel(array $conditions)
27
    {
28
        return Album::findOne($conditions);
29
    }
30
31
    /**
32
     * Remove owner of Album model.
33
     *
34
     * @param int    $ownerId
35
     * @param string $owner
36
     * @param string $ownerAttribute
37
     *
38
     * @return bool
39
     */
40
    protected function removeOwner(int $ownerId, string $owner, string $ownerAttribute): bool
41
    {
42
        return OwnerAlbum::removeOwner($ownerId, $owner, $ownerAttribute);
43
    }
44
}
45