Passed
Pull Request — main (#9)
by
unknown
01:36
created

InlineNodeBuilder::card()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\Adf\Builder;
6
7
use DH\Adf\Node\Inline\Emoji;
8
use DH\Adf\Node\Inline\Hardbreak;
9
use DH\Adf\Node\Inline\InlineCard;
10
use DH\Adf\Node\Inline\Mention;
11
use DH\Adf\Node\Node;
12
13
trait InlineNodeBuilder
14
{
15
    public function emoji(string $shortName, ?string $id = null, ?string $text = null): self
16
    {
17
        $emoji = new Emoji($shortName, $id, $text);
18
        $this->append($emoji);
19
20
        return $this;
21
    }
22
23
    public function mention(string $mentionId, string $text, ?string $accessLevel = null): self
24
    {
25
        $mention = new Mention($mentionId, $text, $accessLevel);
26
        $this->append($mention);
27
28
        return $this;
29
    }
30
31
    public function break(?Node $parent = null): self
32
    {
33
        $this->append(new Hardbreak($parent));
34
35
        return $this;
36
    }
37
38
    public function card(string $url, ?string $data = null): self
39
    {
40
        $this->append(new InlineCard($url, $data));
41
42
        return $this;
43
    }
44
45
    abstract protected function append(Node $node): void;
46
}
47