Completed
Push — master ( fdd703...40dd8e )
by Sebastian
03:16
created

Util   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 24
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAdapterReplacements() 0 15 3
1
<?php
2
3
namespace phpbu\App\Adapter;
4
5
/**
6
 * Adapter utility class
7
 *
8
 * @package    phpbu
9
 * @subpackage App
10
 * @author     Sebastian Feldmann <[email protected]>
11
 * @copyright  Sebastian Feldmann <[email protected]>
12
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
13
 * @link       http://phpbu.de/
14
 * @since      Class available since Release 5.0.7
15
 */
16
abstract class Util
17
{
18
    /**
19
     * Finds all adapter references in a value string.
20
     *
21
     * @param string $value
22
     * @return array
23
     */
24 34
    public static function getAdapterReplacements(string $value) : array
25
    {
26 34
        $values  = [];
27 34
        $matches = [];
28 34
        if (preg_match_all('#:?adapter:([a-z0-9_\-]+):([^:]+):?#i', $value, $matches, PREG_SET_ORDER)) {
29 9
            foreach ($matches as $match) {
30 9
                $values[] = [
31 9
                    'search'  => $match[0],
32 9
                    'adapter' => $match[1],
33 9
                    'path'    => $match[2]
34
                ];
35
            }
36
        }
37 34
        return $values;
38
    }
39
}
40