Passed
Push — bugfix/support-windows ( 517fb4...0e99e7 )
by Chema
04:47
created

PathFinder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 21
ccs 5
cts 6
cp 0.8333
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ensureGlobBraceIsDefined() 0 4 2
A matchingPattern() 0 5 2
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
        $this->ensureGlobBraceIsDefined();
18
19 37
        return glob($pattern, GLOB_BRACE) ?: [];
20
    }
21
22
    /**
23
     * Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris or Alpine Linux.
24
     *
25
     * @see https://www.php.net/manual/en/function.glob.php
26
     */
27 37
    private function ensureGlobBraceIsDefined(): void
28
    {
29 37
        if (!defined('GLOB_BRACE')) {
30
            define('GLOB_BRACE', 0x10);
31
        }
32
    }
33
}
34