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

orchestral / sidekick / 15232715762

25 May 2025 01:08AM UTC coverage: 93.642% (-1.3%) from 94.904%
15232715762

push

github

web-flow
Add `Orchestra\Sidekick\Env` class (#48)

* Add `Orchestra\Sidekick\Env` class

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

13 of 16 new or added lines in 1 file covered. (81.25%)

162 of 173 relevant lines covered (93.64%)

6.42 hits per line

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

81.25
/src/Env.php
1
<?php
2

3
namespace Orchestra\Sidekick;
4

5
/**
6
 * @api
7
 */
8
class Env extends \Illuminate\Support\Env
9
{
10
    /**
11
     * Determine if environmemt variable is available.
12
     */
13
    public static function has(string $key): bool
14
    {
15
        return static::get($key, new UndefinedValue) instanceof UndefinedValue === false;
2✔
16
    }
17

18
    /**
19
     * Set an environment value.
20
     */
21
    public static function set(string $key, string $value): void
22
    {
NEW
23
        static::getRepository()->set($key, $value);
×
24
    }
25

26
    /**
27
     * Forget an environment variable.
28
     *
29
     *
30
     * @throws \InvalidArgumentException
31
     */
32
    public static function forget(string $key): bool
33
    {
NEW
34
        return static::getRepository()->clear($key);
×
35
    }
36

37
    /**
38
     * Forward environment value.
39
     *
40
     * @param  \Orchestra\Sidekick\UndefinedValue|mixed|null  $default
41
     * @return mixed
42
     */
43
    public static function forward(string $key, $default = null)
44
    {
45
        if (\func_num_args() === 1) {
1✔
46
            $default = new UndefinedValue;
1✔
47
        }
48

49
        $value = static::get($key, $default);
1✔
50

51
        if ($value instanceof UndefinedValue) {
1✔
52
            return false;
1✔
53
        }
54

55
        return static::encode($value);
1✔
56
    }
57

58
    /**
59
     * Encode environment variable value.
60
     *
61
     * @param  mixed  $value
62
     * @return mixed
63
     */
64
    public static function encode($value)
65
    {
66
        if (\is_null($value)) {
1✔
67
            return '(null)';
1✔
68
        }
69

70
        if (\is_bool($value)) {
1✔
71
            return $value === true ? '(true)' : '(false)';
1✔
72
        }
73

74
        if (empty($value)) {
1✔
75
            return '(empty)';
1✔
76
        }
77

NEW
78
        return $value;
×
79
    }
80
}
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

© 2025 Coveralls, Inc