Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
4 / 4 |
PresetFormatter | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
4 / 4 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
format | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
namespace Popy\Calendar; | |
use DateTimeInterface; | |
/** | |
* Utility/Helper class : Stores a preset date formatting to be used as a quick formatter. | |
*/ | |
class PresetFormatter | |
{ | |
/** | |
* Formatter. | |
* | |
* @var FormatterInterface | |
*/ | |
protected $formatter; | |
/** | |
* Preset format. | |
* | |
* @var string | |
*/ | |
protected $format; | |
/** | |
* Class constructor. | |
* | |
* @param FormatterInterface $formatter Formatter | |
* @param string $format Date format | |
*/ | |
public function __construct(FormatterInterface $formatter, $format) | |
{ | |
$this->formatter = $formatter; | |
$this->format = $format; | |
} | |
/** | |
* Format the input date. | |
* | |
* @param DateTimeInterface $input | |
* | |
* @return string | |
*/ | |
public function format(DateTimeInterface $input) | |
{ | |
return $this->formatter->format($input, $this->format); | |
} | |
} |