Username::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
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\UsernameInterface;
6
use Pageon\SlackWebhookMonolog\General\SerializeToString;
7
8
/**
9
 * @author Jelmer Prins <[email protected]>
10
 *
11
 * @since 0.1.0
12
 */
13
class Username extends SerializeToString implements UsernameInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $username;
19
20
    /**
21
     * Username constructor.
22
     *
23
     * @param string $username
24
     */
25 8
    public function __construct($username)
26
    {
27 8
        $this->setUsername($username);
28 8
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 5
    public function getUsername()
34
    {
35 5
        return $this->username;
36
    }
37
38
    /**
39
     * @param string $username
40
     *
41
     * @return self
42
     */
43 8
    private function setUsername($username)
44
    {
45 8
        $this->username = trim($username);
46
47 8
        return $this;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 4
    public function __toString()
54
    {
55 4
        return $this->getUsername();
56
    }
57
}
58