protected function formatItem(Item $item) { $rule = $item->getRule(); $components = $rule->getComponents(); // the dot array_splice($components, $item->getDotIndex(), 0, array('•')); if ($rule->getNumber() === 0) { $string = ''; } else { $string = sprintf("%s → ", $rule->getName()); } $string .= implode(' ', $components); if ($item->isReduceItem()) { $string .= sprintf(' [%s]', implode(' ', $item->getLookahead())); } return $string; }
/** * @test */ public function getUnrecognizedComponentsShouldReturnAllComponentAfterTheDottedOne() { $item = new Item(new Rule(1, 'A', array('a', 'b', 'c')), 1); $this->assertEquals(array('c'), $item->getUnrecognizedComponents()); }