EnvCollection   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 40
ccs 12
cts 12
cp 1
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getKeys() 0 3 1
A has() 0 3 1
A add() 0 3 1
A delete() 0 3 1
A get() 0 3 2
A getCollection() 0 3 1
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