Completed
Push — master ( 6acfe1...0042b2 )
by Radu
11:51 queued 10s
created

ConfigLibraryHelper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 1
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A library() 0 6 2
A getSettings() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WebServCo\Framework\Helpers;
6
7
use WebServCo\Framework\Libraries\Config;
8
9
abstract class ConfigLibraryHelper extends AbstractLibraryHelper
10
{
11
    private static ?Config $object = null;
12
13
    /**
14
    * @return array<mixed>
15
    */
16
    public static function getSettings(string $name): array
17
    {
18
        $projectPath = self::library()->get(
19
            \sprintf(
20
                'app%1$spath%1$sproject',
21
                \WebServCo\Framework\Settings::DIVIDER,
22
            ),
23
        );
24
        if (empty($projectPath)) {
25
            return [];
26
        }
27
        return self::library()->load($name, $projectPath);
28
    }
29
30
    public static function library(): Config
31
    {
32
        if (!self::$object instanceof Config) {
33
            self::$object = new Config();
34
        }
35
        return self::$object;
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::object could return the type null which is incompatible with the type-hinted return WebServCo\Framework\Libraries\Config. Consider adding an additional type-check to rule them out.
Loading history...
36
    }
37
}
38