ApiUser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 1
cbo 3
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 12 1
A _buildApiRoleFixture() 0 8 1
1
<?php
2
3
namespace Magefix\Fixture\Builder;
4
5
use Magefix\Fixture\Builder\Helper\ApiUser as ApiUserHelper;
6
use Magefix\Fixture\Factory\Builder;
7
use Magefix\Fixture\Instanciator;
8
9
/**
10
 * Class ApiUser
11
 * @package Magefix\Fixture\Builder
12
 *
13
 * @author  Carlo Tasca <[email protected]>
14
 */
15
class ApiUser extends AbstractBuilder
16
{
17
    /**
18
     *
19
     * Concrete classes to provide implementation for build method
20
     *
21
     * @return mixed
22
     */
23
    public function build()
24
    {
25
        $this->invokeProvidersMethods();
26
27
        $this->_throwUndefinedAttributesException(isset($this->_data['fixture']['api_role']['model']),
28
            'Api Role model has not been defined. Check fixture yml.');
29
        $roleId = $this->_buildApiRoleFixture();
30
31
        $fixtureId = ApiUserHelper::create($this->_getMageModel(), $roleId, $this->_data['fixture']['attributes']);
32
33
        return $fixtureId;
34
    }
35
36
    /**
37
     * @return mixed
38
     */
39
    protected function _buildApiRoleFixture()
40
    {
41
        $roleBuilderData = [];
42
        $roleBuilderData['fixture'] = $this->_data['fixture']['api_role'];
43
        $fixture = Instanciator::instance(Builder::API_ROLE_FIXTURE_TYPE, $roleBuilderData, $this->_getHook());
44
        $roleId = $fixture->buildAndRegister();
45
        return $roleId;
46
    }
47
}
48