/** * @param InputInterface $input * @param OutputInterface $output * @param DomainMessage $domainMessage */ private function interactOnDomainMessage(InputInterface $input, OutputInterface $output, DomainMessage $domainMessage) { $metadata = ""; $payload = ""; $reflector = new DomainMessageReflector($domainMessage); $questionHelper = new QuestionHelper(); $question = new ConfirmationQuestion('Continue to next playhead? (Y/n)', true); $reflections = $reflector->reflect(DomainMessageReflector::METADATA); foreach ($reflections as $property => $value) { $metadata = $metadata . $property . ': ' . $value . " "; } $reflections = $reflector->reflect(DomainMessageReflector::PAYLOAD); foreach ($reflections as $property => $value) { $payload = $payload . $property . ': ' . $value . " "; } $table = new Table($output); $table->setHeaders(array("Property", "Value"))->setRows(array(array("Id", $domainMessage->getId()), array("Recorded at", $domainMessage->getRecordedOn()->toString()), array("Playhead number", $domainMessage->getPlayhead()), array("Command", $domainMessage->getType())))->render(); $table = new Table($output); $table->setHeaders(array("Metadata"))->setRows(array(array($metadata)))->render(); $table = new Table($output); $table->setHeaders(array("Payload"))->setRows(array(array($payload)))->render(); if (false === $questionHelper->ask($input, $output, $question)) { exit("replaying stopped"); } }
public function testReflectorWithArrays() { $reflector = new DomainMessageReflector(new DomainMessage('id', 1, new Metadata(array()), new DummyClass(), DateTime::now())); $reflections = $reflector->reflect(DomainMessageReflector::PAYLOAD); $this->assertEquals(array("property1" => "private", "property2" => "protected", "property3" => "public"), $reflections); }