Regions::all()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 13
rs 10
1
<?php
2
/**
3
 * This file is part of handelsgids/sales-periods.
4
 *
5
 * (c) Handelsgids NV
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Handelsgids\SalesPeriods;
12
13
/**
14
 * Class to list all available salles period regions.
15
 */
16
final class Regions
17
{
18
    const DEFAULT_REGION = 'Belgium';
19
20
    /**
21
     * @return string[]
22
     */
23
    public static function all()
24
    {
25
        $regionPathPattern = __DIR__ . '/Region/*';
26
        $availableRegions = glob($regionPathPattern, GLOB_ONLYDIR);
27
28
        $output = [];
29
        if ($availableRegions !== false) {
30
            $output = array_map(function($regionPath) {
31
                return substr($regionPath, strrpos($regionPath, DIRECTORY_SEPARATOR) + 1);
32
            }, $availableRegions);
33
        }
34
35
        return $output;
36
    }
37
}
38