Passed
Push — main ( 29a37d...09a857 )
by Damien
07:06
created

InlineNodeBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mention() 0 6 1
A emoji() 0 6 1
A break() 0 5 1
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\Mention;
10
use DH\Adf\Node\Node;
11
12
trait InlineNodeBuilder
13
{
14
    public function emoji(string $shortName, ?string $id = null, ?string $text = null): self
15
    {
16
        $emoji = new Emoji($shortName, $id, $text);
17
        $this->append($emoji);
18
19
        return $this;
20
    }
21
22
    public function mention(string $mentionId, string $text, ?string $accessLevel = null): self
23
    {
24
        $mention = new Mention($mentionId, $text, $accessLevel);
25
        $this->append($mention);
26
27
        return $this;
28
    }
29
30
    public function break(?Node $parent = null): self
31
    {
32
        $this->append(new Hardbreak($parent));
33
        
34
        return $this;
35
    }
36
37
    abstract protected function append(Node $node): void;
38
}
39