Completed
Push — master ( 36743e...544afa )
by jelmer
02:21
created

User::getIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Pageon\SlackWebhookMonolog\Slack;
4
5
use Pageon\SlackWebhookMonolog\Slack\Interfaces\IconInterface;
6
use Pageon\SlackWebhookMonolog\Slack\Interfaces\UserInterface;
7
use Pageon\SlackWebhookMonolog\Slack\Interfaces\UsernameInterface;
8
9
/**
10
 * @author Jelmer Prins <[email protected]>
11
 *
12
 * @since 0.1.0
13
 */
14
class User implements UserInterface
15
{
16
    /**
17
     * @var UsernameInterface|null
18
     */
19
    private $username = null;
20
21
    /**
22
     * @var IconInterface|null
23
     */
24
    private $icon = null;
25
26
    /**
27
     * Setting a custom Username or Icon is not required.
28
     * If they are not provided slack will fallback to the default settings from the configuration in slack.
29
     *
30
     * @param UsernameInterface|null $username
31
     * @param IconInterface|null $icon
32
     */
33 7
    public function __construct(UsernameInterface $username = null, IconInterface $icon = null)
34
    {
35 7
        $this->username = $username;
36 7
        $this->icon = $icon;
37 7
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 2
    public function getUsername()
43
    {
44 2
        return $this->username;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 4
    public function hasUsername()
51
    {
52 4
        return $this->username !== null;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 3
    public function getIcon()
59
    {
60 3
        return $this->icon;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 4
    public function hasIcon()
67
    {
68 4
        return $this->icon !== null;
69
    }
70
}
71