• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IlyasDeckers / ody-core / 13532154862

25 Feb 2025 10:24PM UTC coverage: 30.374% (+1.7%) from 28.706%
13532154862

push

github

web-flow
Update php.yml

544 of 1791 relevant lines covered (30.37%)

9.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Config/Config.php
1
<?php
2

3
namespace Ody\Core\Config;
4

5
class Config
6
{
7
    protected static self $instance;
8

9
    protected array $fileCache = [];
10
    protected array $keyCache = [];
11

12
    public static function getInstance(): self
×
13
    {
14
        if (isset(self::$instance)) {
×
15
            return self::$instance;
×
16
        }
17

18
        return self::$instance = new self();
×
19
    }
20

21
    public function get(string $key, string|int|bool|array|float|null $default = null): string|int|bool|array|float|null
×
22
    {
23
        $key = \explode('.' , $key);
×
24
        $configPath = $key[0];
×
25
        unset($key[0]);
×
26
        $key = \implode('.' , $key);
×
27

28
        $config = $this->fileCache[$configPath] ?? ($this->fileCache[$configPath] = require_once configPath("$configPath.php"));
×
29

30
        if ($key == ''){
×
31
            return $config;
×
32
        }
33

34
        return $this->keyCache["$configPath.$key"] ?? ($this->keyCache["$configPath.$key"] = $this->getData($config, $key, $default));
×
35
    }
36

37
    protected function getData(array $array, string $key, string|int|bool|array|float|null $default = null): string|int|bool|array|float|null
×
38
    {
39
        if (array_key_exists($key, $array)) {
×
40
            return $array[$key];
×
41
        }
42

43
        if (!str_contains($key, '.')) {
×
44
            return $array[$key] ?? value($default);
×
45
        }
46

47
        foreach (explode('.', $key) as $segment) {
×
48
            if (array_key_exists($segment, $array)) {
×
49
                $array = $array[$segment];
×
50
            } else {
51
                return value($default);
×
52
            }
53
        }
54

55
        return $array;
×
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc