Mapper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 6
Bugs 0 Features 4
Metric Value
c 6
b 0
f 4
dl 0
loc 38
wmc 3
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMap() 0 4 1
A map() 0 8 2
1
<?php
2
3
namespace Magefix\Magento\Model;
4
5
use Magefix\Exceptions\UnmappableType;
6
use Magefix\Fixture\Factory\Builder;
7
8
/**
9
 * Class Mapper
10
 * @package Magefix\Magento\Model
11
 */
12
class Mapper
13
{
14
    /**
15
     * @var array
16
     */
17
    private static $_map = [
18
        Builder::SIMPLE_PRODUCT_FIXTURE_TYPE => 'catalog/product',
19
        Builder::CONFIGURABLE_PRODUCT_FIXTURE_TYPE => 'catalog/product',
20
        Builder::BUNDLE_PRODUCT_FIXTURE_TYPE => 'catalog/product',
21
        Builder::GROUPED_PRODUCT_FIXTURE_TYPE => 'catalog/product',
22
        Builder::CATEGORY_FIXTURE_TYPE => 'catalog/category',
23
        Builder::CUSTOMER_FIXTURE_TYPE => 'customer/customer',
24
        Builder::SALES_ORDER_FIXTURE_TYPE => 'sales/order',
25
        Builder::API_ROLE_FIXTURE_TYPE => 'api/roles',
26
        Builder::API_USER_FIXTURE_TYPE => 'api/user',
27
        Builder::ADMIN_FIXTURE_TYPE => 'admin/user',
28
        Builder::OAUTH_CONSUMER_FIXTURE_TYPE => 'oauth/consumer',
29
    ];
30
31
    public static function getMap()
32
    {
33
        return self::$_map;
34
    }
35
36
    /**
37
     * @param $fixtureType
38
     * @return mixed
39
     * @throws UnmappableType
40
     */
41
    public static function map($fixtureType)
42
    {
43
        if (!isset(self::$_map[$fixtureType])) {
44
            throw new UnmappableType("Fixture type '{$fixtureType}' could not be mapped to any Magento model");
45
        }
46
47
        return self::$_map[$fixtureType];
48
    }
49
}