Belgium   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 20
c 0
b 0
f 0
dl 0
loc 47
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 29 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the Yasumi package.
4
 *
5
 * Copyright (c) 2015 - 2020 AzuyaLabs
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author Sacha Telgenhof <[email protected]>
11
 */
12
13
namespace Yasumi\Provider;
14
15
use DateTime;
16
use Yasumi\Exception\InvalidDateException;
17
use Yasumi\Exception\UnknownLocaleException;
18
use Yasumi\Holiday;
19
20
/**
21
 * Provider for all holidays in Belgium.
22
 */
23
class Belgium extends AbstractProvider
24
{
25
    use CommonHolidays, ChristianHolidays;
26
27
    /**
28
     * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
29
     * country or sub-region.
30
     */
31
    public const ID = 'BE';
32
33
    /**
34
     * Initialize holidays for Belgium.
35
     *
36
     * @throws InvalidDateException
37
     * @throws \InvalidArgumentException
38
     * @throws UnknownLocaleException
39
     * @throws \Exception
40
     */
41
    public function initialize(): void
42
    {
43
        $this->timezone = 'Europe/Brussels';
44
45
        // Add common holidays
46
        $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
47
        $this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
48
49
        // Add Christian holidays
50
        $this->addHoliday($this->easter($this->year, $this->timezone, $this->locale));
51
        $this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
52
        $this->addHoliday($this->ascensionDay($this->year, $this->timezone, $this->locale));
53
        $this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale));
54
        $this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale));
55
        $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
56
        $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
57
        $this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale));
58
        $this->addHoliday($this->armisticeDay($this->year, $this->timezone, $this->locale));
59
60
        /**
61
         * Belgian National Day.
62
         *
63
         * Belgian National Day is the National Day of Belgium celebrated on 21 July each year.
64
         */
65
        $this->addHoliday(new Holiday('nationalDay', [
66
            'fr' => 'Fête nationale',
67
            'en' => 'Belgian National Day',
68
            'nl' => 'nationale feestdag',
69
        ], new DateTime("$this->year-7-21", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale));
70
    }
71
}
72