Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
66.67% |
4 / 6 |
CRAP | |
76.47% |
13 / 17 |
| DateLexerResult | |
0.00% |
0 / 1 |
|
66.67% |
4 / 6 |
10.06 | |
76.47% |
13 / 17 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getOffset | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| set | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| get | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| merge | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| getFirst | |
100.00% |
1 / 1 |
3 | |
100.00% |
6 / 6 |
|||
| <?php | |
| namespace Popy\Calendar\Parser; | |
| /** | |
| * DateLexerResult | |
| */ | |
| class DateLexerResult | |
| { | |
| /** | |
| * Resulting offset. | |
| * | |
| * @var integer | |
| */ | |
| protected $offset; | |
| /** | |
| * Data extracted by the lexer. | |
| * | |
| * @var array | |
| */ | |
| protected $data = []; | |
| /** | |
| * Class constructor. | |
| * | |
| * @param integer $offset [description] | |
| */ | |
| public function __construct($offset) | |
| { | |
| $this->offset = $offset; | |
| } | |
| /** | |
| * Gets offset. | |
| * | |
| * @return integer | |
| */ | |
| public function getOffset() | |
| { | |
| return $this->offset; | |
| } | |
| /** | |
| * Set parsed symbol value. | |
| * | |
| * @param string $name Symbol name. | |
| * @param mixed $value Symbol value. | |
| */ | |
| public function set($name, $value) | |
| { | |
| $this->data[$name] = $value; | |
| return $this; | |
| } | |
| /** | |
| * Gets a symbol value. | |
| * | |
| * @param string $name Symbol name. | |
| * @param mixed $default Fallback value. | |
| * | |
| * @return mixed | |
| */ | |
| public function get($name, $default = null) | |
| { | |
| if (isset($this->data[$name])) { | |
| return $this->data[$name]; | |
| } | |
| return $default; | |
| } | |
| /** | |
| * Merges a result into this one. | |
| * | |
| * @param DateLexerResult $result | |
| */ | |
| public function merge(DateLexerResult $result) | |
| { | |
| $this->offset = $result->offset; | |
| $this->data = array_merge($this->data, $result->data); | |
| } | |
| /** | |
| * Get first set symbol value. | |
| * | |
| * @param string $name | |
| * @param string ...$name | |
| * | |
| * @return mixed | |
| */ | |
| public function getFirst($name) | |
| { | |
| $names = func_get_args(); | |
| foreach ($names as $name) { | |
| if (isset($this->data[$name])) { | |
| return $this->data[$name]; | |
| } | |
| } | |
| } | |
| } |