Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
7 / 7 |
Litteral | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
7 / 7 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
formatSymbol | |
100.00% |
1 / 1 |
4 | |
100.00% |
5 / 5 |
<?php | |
namespace Popy\Calendar\Formatter\SymbolFormatter; | |
use Popy\Calendar\FormatterInterface; | |
use Popy\Calendar\Parser\FormatToken; | |
use Popy\Calendar\Formatter\SymbolFormatterInterface; | |
use Popy\Calendar\ValueObject\DateRepresentationInterface; | |
/** | |
* Handles Litteral tokens. | |
*/ | |
class Litteral implements SymbolFormatterInterface | |
{ | |
/** | |
* Will consider symbols (not handled by previous formatters) as litterals | |
* | |
* @var boolean | |
*/ | |
protected $considerSymbolsAsLitterals; | |
/** | |
* Class constructor. | |
* | |
* @param boolean $considerSymbolsAsLitterals | |
*/ | |
public function __construct($considerSymbolsAsLitterals = false) | |
{ | |
$this->considerSymbolsAsLitterals = $considerSymbolsAsLitterals; | |
} | |
/** | |
* @inheritDoc | |
*/ | |
public function formatSymbol(DateRepresentationInterface $input, FormatToken $token, FormatterInterface $formatter) | |
{ | |
if ( | |
$token->isLitteral() | |
|| $this->considerSymbolsAsLitterals && $token->isSymbol() | |
) { | |
return $token->getValue(); | |
} | |
} | |
} |