AbstractSalesPeriod::setYear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * This file is part of handelsgids/sales-periods.
4
 *
5
 * (c) Handelsgids NV
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Handelsgids\SalesPeriods;
12
13
use Handelsgids\SalesPeriods\Model\SalesPeriod;
14
use ReflectionClass;
15
use ReflectionException;
16
17
abstract class AbstractSalesPeriod extends SalesPeriod implements SalesPeriodInterface
18
{
19
    /** @var int */
20
    private $year;
21
22
    /**
23
     * @param null|int $year
24
     * @throws ReflectionException
25
     */
26
    public function __construct($year = null)
27
    {
28
        if ($year === null) {
29
            $year = (int) date('Y');
30
        }
31
32
        $this->setYear($year);
33
34
        $this->init();
35
36
        $reflection = new ReflectionClass($this);
37
        $namespace = $reflection->getNamespaceName();
38
        $region = substr($namespace, strrpos($namespace, '\\') + 1);
39
40
        $this->setRegion($region);
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getYear()
47
    {
48
        return $this->year;
49
    }
50
51
    /**
52
     * @param int $year
53
     */
54
    public function setYear($year): void
55
    {
56
        $this->year = $year;
57
    }
58
}
59