BehaviorMediafile   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\{Mediafile, OwnerMediafile};
7
8
/**
9
 * Class BehaviorMediafile
10
 * BehaviorMediafile class to add, update and remove owners of Mediafile model.
11
 *
12
 * @package Itstructure\MFUploader\behaviors
13
 *
14
 * @author Andrey Girnik <[email protected]>
15
 */
16
class BehaviorMediafile extends Behavior
17
{
18
    /**
19
     * Load Mediafile model by conditions.
20
     *
21
     * @param array $conditions
22
     *
23
     * @return Mediafile|ActiveRecordInterface|null
24
     */
25
    protected function loadModel(array $conditions)
26
    {
27
        return Mediafile::findOne($conditions);
28
    }
29
30
    /**
31
     * Remove owner of Mediafile model.
32
     *
33
     * @param int    $ownerId
34
     * @param string $owner
35
     * @param string $ownerAttribute
36
     *
37
     * @return bool
38
     */
39
    protected function removeOwner(int $ownerId, string $owner, string $ownerAttribute): bool
40
    {
41
        return OwnerMediafile::removeOwner($ownerId, $owner, $ownerAttribute);
42
    }
43
}
44