Test Setup Failed
Pull Request — latest (#3)
by Mark
32:07
created

Image   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 12
c 1
b 0
f 1
dl 0
loc 35
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUrl() 0 3 1
A getUrl() 0 3 1
A __construct() 0 14 3
A getEmoji() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UnicornFail\Emoji\Node;
6
7
class Image extends AbstractStringContainer implements EmojiContainerInterface
8
{
9
    /** @var Emoji */
10
    private $emoji;
11
12
    public function __construct(string $value, Emoji $emoji, string $url, ?string $alt = null, ?string $title = null)
13
    {
14
        parent::__construct($value);
15
16
        $this->emoji = $emoji;
17
18
        $this->attributes->set('src', $url);
19
20
        if ($alt !== null) {
21
            $this->attributes->set('alt', $alt);
22
        }
23
24
        if ($title !== null) {
25
            $this->attributes->set('title', $title);
26
        }
27
    }
28
29
    public function getEmoji(): Emoji
30
    {
31
        return $this->emoji;
32
    }
33
34
    public function getUrl(): string
35
    {
36
        return (string) $this->attributes->get('src');
37
    }
38
39
    public function setUrl(string $url): void
40
    {
41
        $this->attributes->set('src', $url);
42
    }
43
}
44