EnvLine   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 10
dl 0
loc 31
ccs 16
cts 16
cp 1
rs 10
c 3
b 0
f 1
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getValue() 0 3 1
A getComment() 0 3 1
A getKey() 0 3 1
A __toString() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
6
namespace Enjoys\Dotenv\Parser\Lines;
7
8
9
use Enjoys\Dotenv\Parser\Env\Comment;
10
use Enjoys\Dotenv\Parser\Env\Key;
11
use Enjoys\Dotenv\Parser\Env\Value;
12
13
final class EnvLine implements LineInterface
14
{
15 53
    public function __construct(private Key $key, private ?Value $value = null, private ?Comment $comment = null)
16
    {
17 53
    }
18
19
20 9
    public function __toString(): string
21
    {
22 9
        $format = ($this->value === null) ? '%s%s%s' : '%s=%s%s';
23 9
        return sprintf(
24 9
            $format,
25 9
            $this->key->__toString(),
26 9
            $this->value?->__toString() ?? '',
27 9
            $this->comment?->__toString() ?? ''
28 9
        );
29
    }
30
31 45
    public function getKey(): Key
32
    {
33 45
        return $this->key;
34
    }
35
36 43
    public function getValue(): ?Value
37
    {
38 43
        return $this->value;
39
    }
40
41 1
    public function getComment(): ?Comment
42
    {
43 1
        return $this->comment;
44
    }
45
}
46