Mapper::getMap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
}