RegistryEntryMatcher::_matchOr()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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