Completed
Push — develop ( fcce06...87d9a9 )
by Nate
02:07
created

UpdateOrganization   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 4 1
A find() 0 8 3
A populate() 0 7 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/organization/license
6
 * @link       https://www.flipboxfactory.com/software/organization/
7
 */
8
9
namespace flipbox\organizations\actions\organizations;
10
11
use flipbox\craft\ember\actions\elements\UpdateElement;
12
use flipbox\organizations\elements\Organization;
13
use yii\base\BaseObject;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class UpdateOrganization extends UpdateElement
20
{
21
    use PopulateOrganizationTrait;
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function run($organization)
27
    {
28
        return parent::run($organization);
29
    }
30
31
    /**
32
     * @inheritdoc
33
     * @return Organization
34
     */
35
    public function find($identifier)
36
    {
37
        $site = $this->resolveSiteFromRequest();
38
        return Organization::findOne([
0 ignored issues
show
Bug Compatibility introduced by
The expression \flipbox\organizations\e...e ? $site->id : null)); of type craft\base\Element|null|craft\base\Element[] adds the type craft\base\Element[] to the return on line 38 which is incompatible with the return type documented by flipbox\organizations\ac...pdateOrganization::find of type flipbox\organizations\elements\Organization|null.
Loading history...
39
            is_numeric($identifier) ? 'id' : 'slug' => $identifier,
40
            'siteId' => $site ? $site->id : null
41
        ]);
42
    }
43
44
    /**
45
     * @inheritdoc
46
     * @param Organization $object
47
     * @return Organization
48
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
49
     */
50
    protected function populate(BaseObject $object): BaseObject
51
    {
52
        parent::populate($object);
53
        $this->populateFromRequest($object);
54
55
        return $object;
56
    }
57
}
58