TextColor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A load() 0 6 1
A getColor() 0 3 1
A attrs() 0 4 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
    public function getColor(): string
31
    {
32
        return $this->color;
33
    }
34
35
    protected function attrs(): array
36
    {
37
        return [
38
            'color' => $this->color,
39
        ];
40
    }
41
}
42