Description   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 13
c 1
b 0
f 0
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getText() 0 3 1
A getSubject() 0 3 1
A __construct() 0 16 3
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