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

IlyasDeckers / ody-core / 13589380408

28 Feb 2025 01:41PM UTC coverage: 13.422% (-19.7%) from 33.151%
13589380408

push

github

IlyasDeckers
add support classes/methods (wip)

0 of 2412 new or added lines in 16 files covered. (0.0%)

544 of 4053 relevant lines covered (13.42%)

4.04 hits per line

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

0.0
/src/Support/DotenvManager.php
1
<?php
2
declare(strict_types=1);
3

4
namespace Ody\Core\Support;
5

6
use Dotenv\Dotenv;
7
use Dotenv\Repository\Adapter\AdapterInterface;
8
use Dotenv\Repository\Adapter\PutenvAdapter;
9
use Dotenv\Repository\RepositoryBuilder;
10

11
class DotenvManager
12
{
13
    protected static AdapterInterface $adapter;
14

15
    protected static Dotenv $dotenv;
16

17
    protected static array $cachedValues;
18

NEW
19
    public static function load(array $paths): void
×
20
    {
NEW
21
        if (isset(static::$cachedValues)) {
×
NEW
22
            return;
×
23
        }
24

NEW
25
        static::$cachedValues = static::getDotenv($paths)->load();
×
26
    }
27

NEW
28
    public static function reload(array $paths, bool $force = false): void
×
29
    {
NEW
30
        if (! isset(static::$cachedValues)) {
×
NEW
31
            static::load($paths);
×
32

NEW
33
            return;
×
34
        }
35

NEW
36
        foreach (static::$cachedValues as $deletedEntry => $value) {
×
NEW
37
            static::getAdapter()->delete($deletedEntry);
×
38
        }
39

NEW
40
        static::$cachedValues = static::getDotenv($paths, $force)->load();
×
41
    }
42

NEW
43
    protected static function getDotenv(array $paths, bool $force = false): Dotenv
×
44
    {
NEW
45
        if (isset(static::$dotenv) && ! $force) {
×
NEW
46
            return static::$dotenv;
×
47
        }
48

NEW
49
        return static::$dotenv = Dotenv::create(
×
NEW
50
            RepositoryBuilder::createWithNoAdapters()
×
NEW
51
                ->addAdapter(static::getAdapter($force))
×
NEW
52
                ->immutable()
×
NEW
53
                ->make(),
×
NEW
54
            $paths
×
NEW
55
        );
×
56
    }
57

NEW
58
    protected static function getAdapter(bool $force = false): AdapterInterface
×
59
    {
NEW
60
        if (isset(static::$adapter) && ! $force) {
×
NEW
61
            return static::$adapter;
×
62
        }
63

NEW
64
        return static::$adapter = PutenvAdapter::create()->get();
×
65
    }
66
}
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