EnvCollection::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 1
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
6
namespace Enjoys\Dotenv;
7
8
9
final class EnvCollection
10
{
11
12
    /**
13
     * @var array<string, string|bool|int|float|null>
14
     */
15
    private array $collection = [];
16
17 46
    public function add(string $key, string|bool|int|float|null $value): void
18
    {
19 46
        $this->collection[$key] = $value;
20
    }
21
22 20
    public function get(string $key, float|bool|int|string|null $default = null): float|bool|int|string|null
23
    {
24 20
        return $this->has($key) ? $this->collection[$key] : $default;
25
    }
26
27 21
    public function has(string $key): bool
28
    {
29 21
        return array_key_exists($key, $this->collection);
30
    }
31
32 1
    public function delete(string $key): void
33
    {
34 1
        unset($this->collection[$key]);
35
    }
36
37
    /**
38
     * @return string[]
39
     */
40 43
    public function getKeys(): array
41
    {
42 43
        return array_keys($this->collection);
43
    }
44
45
46 5
    public function getCollection(): array
47
    {
48 5
        return $this->collection;
49
    }
50
51
52
}
53