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

Mapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 35
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::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
}