/** * @param Event $event */ public function __invoke(Event $event) { $exercise = $event->getParameter('exercise'); if ($exercise instanceof SelfCheck) { $this->results->add($exercise->check($event->getParameter('fileName'))); } }
public function testExeceptionIsThrownIfParameterDoesNotExist() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Parameter: "cool" does not exist'); $e = new Event('super-sweet-event-with-cool-params'); $e->getParameter('cool'); }
/** * @param Event $event */ public function revert(Event $event) { if (null === $this->originalCode) { throw new RuntimeException('Can only revert previously patched code'); } file_put_contents($event->getParameter('fileName'), $this->originalCode); }
/** * @param Event $event */ public function __invoke(Event $event) { /** @var CommandDefinition $command */ $command = $event->getParameter('command'); if (!in_array($command->getName(), ['verify', 'run'])) { return; } $currentExercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise()); $this->runnerManager->configureInput($currentExercise, $command); }
/** * @param Event $event */ public function __invoke(Event $event) { /** @var CommandDefinition $command */ $command = $event->getParameter('command'); if (!in_array($command->getName(), ['verify', 'run', 'print'])) { return; } if (!$this->userState->isAssignedExercise()) { throw new \RuntimeException('No active exercise. Select one from the menu'); } }
/** * @param Event $event */ public function __invoke(Event $event) { $solution = $event->getParameter('exercise')->getSolution(); if ($solution->hasComposerFile()) { //prepare composer deps //only install if composer.lock file not available if (!file_exists(sprintf('%s/vendor', $solution->getBaseDirectory()))) { $process = new Process(sprintf('%s install --no-interaction', $this->locateComposer()), $solution->getBaseDirectory()); $process->run(); } } }