public function writeTo(string $dest) { if (file_exists($dest)) { if ('n' == CLI::prompt('Destination exists. Overwrite?', ['y', 'n'])) { die; } } if (strpos($dest, 'user_guide_src/source/') !== false) { $dest = substr($dest, strlen('user_guide_src/source/')); } str_ireplace('.rst', '', $dest); $dest = dirname(__FILE__) . '/source/' . $dest . '.rst'; if (!($fp = fopen($dest, 'wb'))) { die('Unable to write to: ' . $dest); } fwrite($fp, $this->prose . "\n"); fclose($fp); }
/** * Displays a caught exception. * * @param \Exception $e */ protected function showError(\Exception $e) { CLI::error($e->getMessage()); CLI::write($e->getFile() . ' - ' . $e->getLine(), 'white'); }
/** * Loads the specified seeder and runs it. * * @param string $class * * @throws RuntimeException */ public function call(string $class) { if (empty($class)) { throw new \InvalidArgumentException('No Seeder was specified.'); } $path = $this->seedPath . str_replace('.php', '', $class) . '.php'; if (!is_file($path)) { throw new \InvalidArgumentException('The specified Seeder is not a valid file: ' . $path); } if (!class_exists($class, false)) { require $path; } $seeder = new $class($this->config); $seeder->run(); unset($seeder); if (is_cli() && !$this->silent) { CLI::write("Seeded: {$class}", 'green'); } }