Passed
Push — main ( e16d46...16e3d2 )
by Damien
07:21
created

TextColor::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\Adf\Node\Mark;
6
7
use DH\Adf\Node\MarkNode;
8
9
/**
10
 * @see https://developer.atlassian.com/cloud/jira/platform/apis/document/marks/textColor
11
 */
12
class TextColor extends MarkNode
13
{
14
    protected string $type = 'textColor';
15
    private string $color = 'black';
16
17
    public function __construct(string $color = 'black')
18
    {
19
        $this->color = $color;
20
    }
21
22
    public static function load(array $data): self
23
    {
24
        self::checkNodeData(static::class, $data, ['attrs']);
25
        self::checkRequiredKeys(['color'], $data['attrs']);
26
27
        return new self($data['attrs']['color'] ?? 'black');
28
    }
29
30
    protected function attrs(): array
31
    {
32
        return [
33
            'color' => $this->color,
34
        ];
35
    }
36
}
37