Text   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A new() 0 3 1
A generate() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Murtukov\PHPCodeGenerator;
6
7
class Text extends AbstractGenerator
8
{
9
    public string $value;
10
    public bool $doubleQuotes;
11
12 2
    public function __construct(string $value, bool $doubleQuotes = false)
13
    {
14 2
        $this->value = $value;
15 2
        $this->doubleQuotes = $doubleQuotes;
16 2
    }
17
18 1
    public static function new(string $value, bool $doubleQuotes = false): self
19
    {
20 1
        return new self($value, $doubleQuotes);
21
    }
22
23 2
    public function generate(): string
24
    {
25 2
        if ($this->doubleQuotes) {
26 1
            return '"'.$this->value.'"';
27
        } else {
28 2
            return "'$this->value'";
29
        }
30
    }
31
}
32