GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 4b3d26...06dcf5 )
by Enjoys
12:36 queued 13s
created

Value   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A __construct() 0 5 1
A __toString() 0 3 1
A handleValue() 0 9 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Enjoys\Dotenv\Parser\Env;
6
7
final class Value implements \Stringable
8
{
9
    private string $value;
10
11
12 48
    public function __construct(
13
        string $value,
14
        private ?string $quote = null
15
    ) {
16 48
        $this->value = $this->handleValue($value);
17
    }
18
19 48
    private function handleValue(string $value): string
20
    {
21 48
        if (preg_match('/#+/', $value)) {
22 6
            $this->quote = '"';
23
        }
24 48
        if (preg_match('/^["\']+/', $value)) {
25 24
            $this->quote = null;
26
        }
27 48
        return $this->quote ? sprintf('%2$s%1$s%2$s', $value, $this->quote) : $value;
28
    }
29
30 5
    public function __toString(): string
31
    {
32 5
        return $this->value;
33
    }
34
35 43
    public function getValue(): string
36
    {
37 43
        return $this->value;
38
    }
39
40
}
41