Description::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
rs 10
cc 3
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Skrill\ValueObject;
6
7
use Skrill\Exception\InvalidDescriptionException;
8
9
/**
10
 * Value object for additional details.
11
 *
12
 * @see https://www.skrill.com/fileadmin/content/pdf/Skrill_Quick_Checkout_Guide.pdf
13
 */
14
final class Description
15
{
16
    /**
17
     * @var string
18
     */
19
    private $subject;
20
21
    /**
22
     * @var string
23
     */
24
    private $text;
25
26
    /**
27
     * @param string $subject
28
     * @param string $text
29
     *
30
     * @throws InvalidDescriptionException
31
     */
32
    public function __construct(string $subject, string $text)
33
    {
34
        $subject = trim($subject);
35
36
        if (empty($subject)) {
37
            throw InvalidDescriptionException::emptySubject();
38
        }
39
40
        $text = trim($text);
41
42
        if (empty($text)) {
43
            throw InvalidDescriptionException::emptyText();
44
        }
45
46
        $this->subject = $subject;
47
        $this->text = $text;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getText(): string
54
    {
55
        return $this->text;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getSubject(): string
62
    {
63
        return $this->subject;
64
    }
65
}
66