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

Util::getAdapterReplacements()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 2
nop 1
crap 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