GlyphInline::setAlign()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 10
1
<?php
2
3
namespace VPA\Console\Glyphs;
4
5
use VPA\Console\Color;
6
use VPA\Console\FrameConfigInterface;
7
use VPA\Console\SymbolMode;
8
9
abstract class GlyphInline extends Glyph
10
{
11 34
    public function __construct(protected FrameConfigInterface $globalConfig)
12
    {
13 34
        parent::__construct($globalConfig);
14 34
        $this->setConfig([
15
                'textAlign' => 'left',
16
                'maxWidth' => 80,
17
                'color' => Color::WHITE,
18
                'backgroundColor' => Color::BLACK,
19
                'mode' => SymbolMode::DEFAULT,
20
            ]);
21
    }
22
23 4
    public function setAlign(string $align): GlyphInline
24
    {
25 4
        $aligns = ['left', 'center', 'right'];
26 4
        if (!in_array($align, $aligns)) {
27 1
            throw new \Exception('Incorrect align value for inline element');
28
        }
29 3
        $this->__set('textAlign', $align);
30 3
        return $this;
31
    }
32
}
33