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

AdapterRepository::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
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;
24
25
use Syscodes\Contracts\Dotenv\Repository;
26
27
/**
28
 * Gets to all the adapters.
29
 * 
30
 * @author Alexander Campo <[email protected]>
31
 */
32
final class AdapterRepository implements Repository
33
{
34
    /**
35
     * Get an adapter to use.
36
     * 
37
     * @var \Syscodes\Contracts\Dotenv\Adapter $adapter
38
     */
39
    protected $adapter;
40
41
    /**
42
     * Constructor. Create a new AdapterRepository instance.
43
     * 
44
     * @param  \Syscodes\Contracts\Dotenv\Adapter  $adapter
45
     * 
46
     * @return void
47
     */
48
    public function __construct(Adapter $adapter)
49
    {
50
        $this->adapter = $adapter;
51
    }
52
53
    /**
54
     * Get an environment variable.
55
     * 
56
     * @param  string  $name
57
     * 
58
     * @return bool
59
     */
60
    public function get(string $name)
61
    {
62
        return $this->adapter->read($name);
63
    }
64
65
     /**
66
     * Set an environment variable.
67
     * 
68
     * @param  string  $name
69
     * @param  string  $value
70
     * 
71
     * @return bool
72
     */
73
    public function set(string $name, string $value)
74
    {
75
        return $this->adapter->write($name);
76
    }
77
78
    /**
79
     * Clear an environment variable.
80
     * 
81
     * @param  string  $name
82
     * 
83
     * @return bool
84
     */
85
    public function clear(string $name)
86
    {
87
        return $this->adapter->delete($name);
88
    }
89
}