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%
4 / 4
PresetParser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
4 / 4
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 parse
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
namespace Popy\Calendar;
use DateTimeInterface;
/**
 * Utility/Helper class : Stores a preset date formatting to be used as a quick parser.
 */
class PresetParser
{
    /**
     * Parser.
     *
     * @var ParserInterface
     */
    protected $parser;
    /**
     * Preset format.
     *
     * @var string
     */
    protected $format;
    /**
     * Class constructor.
     *
     * @param ParserInterface $parser parser
     * @param string          $format   Date format
     */
    public function __construct(ParserInterface $parser, $format)
    {
        $this->parser = $parser;
        $this->format = $format;
    }
    /**
     * Parses the input string into a date.
     *
     * @param string $input
     *
     * @return DateTimeInterface
     */
    public function parse($input)
    {
        return $this->parser->parse($input, $this->format);
    }
}