Completed
Pull Request — develop (#6)
by Carlo
02:24
created

Mapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 34
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_USER_FIXTURE_TYPE => 'api/user'
25
    ];
26
27
    public static function getMap()
28
    {
29
        return self::$_map;
30
    }
31
32
    /**
33
     * @param $fixtureType
34
     * @return mixed
35
     * @throws UnmappableType
36
     */
37
    public static function map($fixtureType)
38
    {
39
        if (!isset(self::$_map[$fixtureType])) {
40
            throw new UnmappableType("Fixture type '{$fixtureType}' could not be mapped to any Magento model");
41
        }
42
43
        return self::$_map[$fixtureType];
44
    }
45
}