Passed
Pull Request — master (#23)
by
unknown
13:36 queued 10:51
created

ImageProcessorName   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 2
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A command() 0 3 1
A isDot() 0 3 1
A value() 0 3 1
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Processors;
7
8
final class ImageProcessorName
9
{
10
    /** @var string[] */
11
    private const NAMES = ['neato', 'dot'];
12
13
    private readonly string $name;
14
15 13
    public function __construct(string $name)
16
    {
17 13
        if (! \in_array($name, self::NAMES, true)) {
18 1
            throw UnknownImageProcessor::named($name, self::NAMES);
19
        }
20 12
        $this->name = $name;
0 ignored issues
show
Bug introduced by
The property name is declared read-only in PhUml\Processors\ImageProcessorName.
Loading history...
21
    }
22
23 9
    public function command(): string
24
    {
25 9
        return $this->name;
26
    }
27
28 9
    public function value(): string
29
    {
30 9
        return ucfirst($this->name);
31
    }
32
33 7
    public function isDot(): bool
34
    {
35 7
        return $this->name === 'dot';
36
    }
37
}
38