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

CreateOrganization::newElement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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