Image::getEmoji()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Emoji\Node;
6
7
class Image extends Node implements EmojiContainerInterface
8
{
9
    /** @var Emoji */
10
    private $emoji;
11
12 30
    public function __construct(string $value, Emoji $emoji, string $url, ?string $alt = null, ?string $title = null)
13
    {
14 30
        parent::__construct($value);
15
16 30
        $this->emoji = $emoji;
17
18 30
        $this->setAttribute('src', $url);
19
20 30
        if ($alt !== null) {
21 18
            $this->setAttribute('alt', $alt);
22
        }
23
24 30
        if ($title !== null) {
25 18
            $this->setAttribute('title', $title);
26
        }
27 30
    }
28
29 6
    public function getEmoji(): Emoji
30
    {
31 6
        return $this->emoji;
32
    }
33
34 9
    public function getUrl(): string
35
    {
36 9
        return (string) $this->getAttribute('src', '');
37
    }
38
39 3
    public function setUrl(string $url): void
40
    {
41 3
        $this->setAttribute('src', $url);
42 3
    }
43
}
44