Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
60.00% covered (warning)
60.00%
3 / 5
CRAP
75.00% covered (warning)
75.00%
6 / 8
ComposedCalendar
0.00% covered (danger)
0.00%
0 / 1
60.00% covered (warning)
60.00%
3 / 5
5.39
75.00% covered (warning)
75.00%
6 / 8
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 format
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 formatDateRepresentation
0.00% covered (danger)
0.00%
0 / 1
1.12
50.00% covered (danger)
50.00%
1 / 2
 parse
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 parseToDateRepresentation
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
namespace Popy\Calendar\Calendar;
use DateTimeZone;
use DateTimeInterface;
use Popy\Calendar\CalendarInterface;
use Popy\Calendar\FormatterInterface;
use Popy\Calendar\ParserInterface;
use Popy\Calendar\ValueObject\DateRepresentationInterface;
/**
 * Composition implementation.
 */
class ComposedCalendar implements CalendarInterface
{
    /**
     * Formatter
     *
     * @var FormatterInterface
     */
    protected $formatter;
    /**
     * Parser
     *
     * @var ParserInterface
     */
    protected $parser;
    /**
     * Class constructor.
     *
     * @param FormatterInterface $formatter
     * @param ParserInterface   $parser
     */
    public function __construct(FormatterInterface $formatter, ParserInterface $parser)
    {
        $this->formatter = $formatter;
        $this->parser   = $parser;
    }
    /**
     * @inheritDoc
     */
    public function format(DateTimeInterface $input, $format)
    {
        return $this->formatter->format($input, $format);
    }
    /**
     * @inheritDoc
     */
    public function formatDateRepresentation(DateRepresentationInterface $input, $format)
    {
        return $this->formatter->formatDateRepresentation($input, $format);
    }
    /**
     * @inheritDoc
     */
    public function parse($input, $format, DateTimeZone $timezone = null)
    {
        return $this->parser->parse($input, $format, $timezone);
    }
    
    /**
     * @inheritDoc
     */
    public function parseToDateRepresentation($input, $format, DateTimeZone $timezone = null)
    {
        return $this->parser->parseToDateRepresentation($input, $format, $timezone);
    }
}