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

CreateOrganization   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 32
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newElement() 0 9 1
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 craft\base\ElementInterface;
12
use flipbox\craft\ember\actions\elements\CreateElement;
13
use flipbox\organizations\elements\Organization;
14
use yii\base\BaseObject;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class CreateOrganization extends CreateElement
21
{
22
    use PopulateOrganizationTrait;
23
24
    /**
25
     * @inheritdoc
26
     * @return Organization|ElementInterface
27
     */
28
    public function newElement(array $config = []): ElementInterface
29
    {
30
        $organization = new Organization();
31
32
        $organization->setScenario(Organization::SCENARIO_LIVE);
33
        $organization->setAttributes($config);
34
35
        return $organization;
36
    }
37
38
    /**
39
     * @inheritdoc
40
     * @param Organization $object
41
     * @return Organization
42
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
43
     */
44
    public function populate(BaseObject $object): BaseObject
45
    {
46
        parent::populate($object);
47
        $this->populateFromRequest($object);
48
49
        return $object;
50
    }
51
}
52