Holiday::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4.1574

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 4
eloc 13
c 1
b 1
f 0
nc 4
nop 4
dl 0
loc 27
ccs 11
cts 14
cp 0.7856
crap 4.1574
rs 9.8333
1
<?php
2
3
namespace Andreshg112\HolidaysPhp;
4
5
use Jenssegers\Date\Date;
6
7
class Holiday
8
{
9
    /** @var string */
10
    public $country;
11
12
    /** @var \Jenssegers\Date\Date */
13
    public $date;
14
15
    /** @var string */
16
    public $title;
17
18
    /** @var string */
19
    public $language;
20
21 2
    public function __construct(string $country, Date $date, string $title, string $language)
22
    {
23 2
        $country = trim($country);
24
25 2
        if (empty($country)) {
26
            throw HolidaysPhpException::notEmptyCountry();
27
        }
28
29 2
        $title = trim($title);
30
31 2
        if (empty($title)) {
32
            throw HolidaysPhpException::notEmptyTitle();
33
        }
34
35 2
        $language = trim($language);
36
37 2
        if (empty($language)) {
38
            throw HolidaysPhpException::notEmptyLanguage();
39
        }
40
41 2
        $this->country = $country;
42
43 2
        $this->date = $date->setTime(0, 0);
44
45 2
        $this->title = $title;
46
47 2
        $this->language = $language;
48 2
    }
49
}
50