Completed
Push — develop ( ceb446...cffdc8 )
by Carlo
03:56
created

Mapper::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
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::CATEGORY_FIXTURE_TYPE => 'catalog/category',
22
        Builder::CUSTOMER_FIXTURE_TYPE => 'customer/customer',
23
        Builder::SALES_ORDER_FIXTURE_TYPE => 'sales/order',
24
        Builder::API_ROLE_FIXTURE_TYPE => 'api/roles',
25
        Builder::API_USER_FIXTURE_TYPE => 'api/user',
26
    ];
27
28
    public static function getMap()
29
    {
30
        return self::$_map;
31
    }
32
33
    /**
34
     * @param $fixtureType
35
     * @return mixed
36
     * @throws UnmappableType
37
     */
38
    public static function map($fixtureType)
39
    {
40
        if (!isset(self::$_map[$fixtureType])) {
41
            throw new UnmappableType("Fixture type '{$fixtureType}' could not be mapped to any Magento model");
42
        }
43
44
        return self::$_map[$fixtureType];
45
    }
46
}