Completed
Push — master ( b27204...a2c64d )
by Nate
05:15 queued 02:48
created

UpdateOrganization   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
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 43
ccs 0
cts 20
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 12 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
        $organization = Organization::findOne([
39
            is_numeric($identifier) ? 'id' : 'slug' => $identifier,
40
            'siteId' => $site ? $site->id : null
41
        ]);
42
43
        $organization->setScenario(Organization::SCENARIO_LIVE);
44
45
        return $organization;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     * @param Organization $object
51
     * @return Organization
52
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
53
     */
54
    protected function populate(BaseObject $object): BaseObject
55
    {
56
        parent::populate($object);
57
        $this->populateFromRequest($object);
58
59
        return $object;
60
    }
61
}
62