Issues (13)

Converter/UnixTimeConverter/EqualLengthMonthes.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Popy\Calendar\Converter\UnixTimeConverter;
4
5
use Popy\Calendar\Converter\CompleteLeapYearCalculatorInterface;
6
use Popy\Calendar\ValueObject\DateFragmentedRepresentationInterface;
7
8
/**
9
 * Equal length monthes implementation.
10
 */
11
class EqualLengthMonthes extends AbstractDatePartsSolarSplitter
12
{
13
    /**
14
     * Leap year calculator.
15
     *
16
     * @var CompleteLeapYearCalculatorInterface
17
     */
18
    protected $calculator;
19
20
    /**
21
     * Month length.
22
     *
23
     * @var integer
24
     */
25
    protected $length;
26
27
    /**
28
     * Class constructor.
29
     *
30
     * @param CompleteLeapYearCalculatorInterface $calculator Leap year calculator.
31
     * @param integer                             $length     Month length.
32
     */
33
    public function __construct(CompleteLeapYearCalculatorInterface $calculator, $length)
34
    {
35
        $this->calculator = $calculator;
36
        $this->length     = $length;
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    protected function getAllFragmentSizes(DateFragmentedRepresentationInterface $input)
43
    {
44
        $days = $this->calculator->getYearLength($input->getYear());
0 ignored issues
show
The method getYear() does not exist on Popy\Calendar\ValueObjec...RepresentationInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Popy\Calendar\ValueObjec...RepresentationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        $days = $this->calculator->getYearLength($input->/** @scrutinizer ignore-call */ getYear());
Loading history...
45
        $monthes = array_fill(
46
            0,
47
            intval($days / $this->length),
48
            $this->length
49
        );
50
        $monthes[] = $days % $this->length;
51
52
        return [$monthes];
53
    }
54
}
55