TitleParam::parse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 2
crap 12
1
<?php declare(strict_types=1);
2
3
4
namespace Bigwhoop\Trumpet\Config\Params;
5
6
use Bigwhoop\Trumpet\Config\ConfigException;
7
use Bigwhoop\Trumpet\Config\Presentation;
8
9
final class TitleParam implements Param
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function parse($value, Presentation $presentation)
15
    {
16
        if (!is_string($value)) {
17
            throw new ConfigException('Title must be a string.');
18
        }
19
20
        if (empty($value)) {
21
            throw new ConfigException('Title must not be empty.');
22
        }
23
24
        $presentation->title = $value;
25
    }
26
}
27