Passed
Push — bugfix/support-windows ( 0e99e7...b5ecf8 )
by Jesús
06:33 queued 02:55
created

PathFinder::ensureGlobBraceIsDefined()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
crap 2.1481
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Config;
6
7
use function define;
8
use function defined;
9
10
final class PathFinder implements PathFinderInterface
11
{
12
    /**
13
     * @return string[]
14
     */
15 37
    public function matchingPattern(string $pattern): array
16
    {
17 37
        if ($pattern === '') {
18 32
            return [];
19
        }
20
21 37
        $this->ensureGlobBraceIsDefined();
22
23 37
        return glob($pattern, GLOB_BRACE) ?: [];
24
    }
25
26
    /**
27
     * Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris or Alpine Linux.
28
     *
29
     * @see https://www.php.net/manual/en/function.glob.php
30
     */
31 37
    private function ensureGlobBraceIsDefined(): void
32
    {
33 37
        if (!defined('GLOB_BRACE')) {
34
            define('GLOB_BRACE', 0x10);
35
        }
36
    }
37
}
38