public function __invoke(Route $route, Console $console) : int { $message = 'Creating tag cloud'; $length = strlen($message); $width = $console->getWidth(); $console->write($message, Color::BLUE); if (!$route->matchedParam('output')) { return $this->reportError($console, $width, $length, 'Missing output file'); } $output = $route->getMatchedParam('output'); $cloud = $this->mapper->fetchTagCloud(); $markup = sprintf("<h4>Tag Cloud</h4>\n<div class=\"cloud\">%s</div>", $cloud->render()); file_put_contents($output, $markup); return $this->reportSuccess($console, $width, $length); }
/** * Handle the incoming console request */ public function __invoke(Route $route, Console $console) : int { if (!$route->matchedParam('output')) { return $this->reportError($console, $width, $length, 'Missing output file'); } $message = 'Retrieving Github activity links'; $length = strlen($message); $width = $console->getWidth(); $console->write($message, Color::BLUE); try { $data = $this->reader->read(); } catch (Throwable $e) { return $this->reportError($console, $width, $length, $e); } file_put_contents($route->getMatchedParam('output'), $this->createContentFromData($data, $route->getMatchedParam('template', $this->outputTemplateString))); return $this->reportSuccess($console, $width, $length); }
public function testMatchedParamReturnsTrueForParameterMatched() { $route = new Route('foo', 'foo <bar>'); $matches = $route->match(['foo', 'BAR']); $this->assertTrue($route->matchedParam('bar')); }