Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
11 / 11
EqualLengthMonthes
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
11 / 11
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 getAllFragmentSizes
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
8 / 8
<?php
namespace Popy\Calendar\Converter\UnixTimeConverter;
use Popy\Calendar\Converter\CompleteLeapYearCalculatorInterface;
use Popy\Calendar\ValueObject\DateFragmentedRepresentationInterface;
/**
 * Equal length monthes implementation.
 */
class EqualLengthMonthes extends AbstractDatePartsSolarSplitter
{
    /**
     * Leap year calculator.
     *
     * @var CompleteLeapYearCalculatorInterface
     */
    protected $calculator;
    /**
     * Month length.
     *
     * @var integer
     */
    protected $length;
    /**
     * Class constructor.
     *
     * @param CompleteLeapYearCalculatorInterface $calculator Leap year calculator.
     * @param integer                             $length     Month length.
     */
    public function __construct(CompleteLeapYearCalculatorInterface $calculator, $length)
    {
        $this->calculator = $calculator;
        $this->length     = $length;
    }
    /**
     * @inheritDoc
     */
    protected function getAllFragmentSizes(DateFragmentedRepresentationInterface $input)
    {
        $days = $this->calculator->getYearLength($input->getYear());
        $monthes = array_fill(
            0,
            intval($days / $this->length),
            $this->length
        );
        $monthes[] = $days % $this->length;
        return [$monthes];
    }
}