BehaviorAlbum::getChildModel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Itstructure\MFU\Behaviors\Owner;
4
5
use Itstructure\MFU\Interfaces\HasOwnerInterface;
6
use Itstructure\MFU\Models\Albums\AlbumBase;
7
use Itstructure\MFU\Models\Owners\OwnerAlbum;
8
9
/**
10
 * Class BehaviorAlbum
11
 * @package Itstructure\MFU\Behaviors\Owner
12
 */
13
class BehaviorAlbum extends Behavior
14
{
15
    /**
16
     * @param $attributeValue
17
     * @return HasOwnerInterface|null
18
     */
19
    protected function getChildModel($attributeValue): ?HasOwnerInterface
20
    {
21
        return AlbumBase::where($this->findChildModelKey, '=', $attributeValue)->first();
22
    }
23
24
    /**
25
     * @param int $ownerId
26
     * @param string $ownerName
27
     * @param string|null $ownerAttribute
28
     * @param bool $removeDependencies
29
     * @return bool
30
     */
31
    protected function removeOwner(int $ownerId, string $ownerName, string $ownerAttribute = null, bool $removeDependencies = false): bool
32
    {
33
        return OwnerAlbum::removeOwner($ownerId, $ownerName, $ownerAttribute, $removeDependencies);
34
    }
35
}
36