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

orchestral / sidekick / 15228273612

24 May 2025 03:03PM UTC coverage: 86.127% (-8.8%) from 94.904%
15228273612

Pull #48

github

web-flow
Merge 9bd487f30 into 268c27398
Pull Request #48: Add `Orchestra\Sidekick\Env` class

0 of 16 new or added lines in 1 file covered. (0.0%)

149 of 173 relevant lines covered (86.13%)

6.21 hits per line

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

0.0
/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
     * @param  string  $key
14
     * @return bool
15
     */
16
    public static function has(string $key): bool
17
    {
NEW
18
        return static::get($key, new UndefinedValue) instanceof UndefinedValue === false;
×
19
    }
20

21
    /**
22
     * Set an environment value.
23
     *
24
     * @param  string  $key
25
     * @param  string  $value
26
     * @return void
27
     */
28
    public static function set(string $key, string $value): void
29
    {
NEW
30
        static::getRepository()->set($key, $value);
×
31
    }
32

33
    /**
34
     * Forget an environment variable.
35
     *
36
     * @param  string  $key
37
     * @return bool
38
     *
39
     * @throws \InvalidArgumentException
40
     */
41
    public static function forget(string $key): bool
42
    {
NEW
43
        return static::getRepository()->clear($key);
×
44
    }
45

46
    /**
47
     * Forward environment value.
48
     *
49
     * @param  string  $key
50
     * @param  \Orchestra\Sidekick\UndefinedValue|mixed|null  $default
51
     * @return mixed
52
     */
53
    public static function forward(string $key, $default = null)
54
    {
NEW
55
        if (\func_num_args() === 1) {
×
NEW
56
            $default = new UndefinedValue;
×
57
        }
58

NEW
59
        $value = static::get($key, $default);
×
60

NEW
61
        if ($value instanceof UndefinedValue) {
×
NEW
62
            return false;
×
63
        }
64

NEW
65
        return static::encode($value);
×
66
    }
67

68
    /**
69
     * Encode environment variable value.
70
     *
71
     * @param  mixed  $value
72
     * @return mixed
73
     */
74
    public static function encode($value)
75
    {
NEW
76
        if (\is_null($value)) {
×
NEW
77
            return '(null)';
×
78
        }
79

NEW
80
        if (\is_bool($value)) {
×
NEW
81
            return $value === true ? '(true)' : '(false)';
×
82
        }
83

NEW
84
        if (empty($value)) {
×
NEW
85
            return '(empty)';
×
86
        }
87

NEW
88
        return $value;
×
89
    }
90
}
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