RegistryEntryMatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 9 1
A _matchOr() 0 7 1
1
<?php
2
3
namespace Magefix\Fixtures;
4
5
6
use Magefix\Fixture\Factory\Builder;
7
use Magefix\Magento\Model\Mapper;
8
9
/**
10
 * Class RegistryEntryMatcher
11
 *
12
 * @package Magefix\Fixtures
13
 * @author  Carlo Tasca <[email protected]>
14
 */
15
class RegistryEntryMatcher
16
{
17
    /**
18
     * @param string $hook
19
     * @param string $key
20
     * @return array
21
     */
22
    public static function match($hook, $key)
23
    {
24
        $matches = [];
25
        $matchOr = self::_matchOr();
26
27
        preg_match("/^({$matchOr})_{$hook}/", $key, $matches);
28
29
        return $matches;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    private static function _matchOr()
36
    {
37
        $mapperKeys = array_keys(Mapper::getMap());
38
        $matchOr = implode('|', $mapperKeys);
39
40
        return $matchOr;
41
    }
42
}
43