Passed
Push — 0.7.0 ( 91f75a...a316e5 )
by Alexander
09:55
created

PutenvAdapter::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php 
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2021 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
namespace Syscodes\Dotenv\Repository\Adapters;
24
25
use Syscodes\Contracts\Dotenv\Adapter;
26
27
/**
28
 * Read, write and delete an environment variable for 
29
 * process of putenv.
30
 * 
31
 * @author Alexander Campo <[email protected]>
32
 */
33
class PutenvAdapter implements Adapter
34
{
35
    /**
36
     * Read an environment variable.
37
     * 
38
     * @param  string  $name
39
     * 
40
     * @return array
41
     */
42
    public function read(string $name)
43
    {
44
        return getenv($name);
0 ignored issues
show
Bug Best Practice introduced by
The expression return getenv($name) returns the type string which is incompatible with the documented return type array.
Loading history...
45
    }
46
47
     /**
48
     * Write to an environment variable.
49
     * 
50
     * @param  string  $name
51
     * @param  string  $value
52
     * 
53
     * @return bool
54
     */
55
    public function write(string $name, string $value)
56
    {
57
        putenv("$name=$value");
58
59
        return true;
60
    }
61
62
    /**
63
     * Delete an environment variable.
64
     * 
65
     * @param  string  $name
66
     * 
67
     * @return bool
68
     */
69
    public function delete(string $name)
70
    {
71
        putenv($name);
72
73
        return true;
74
    }
75
}