argument('name')) ? $this->argument('name') : $this->ask('What is the name of the metric?', 'SmoothiesCount'); $contents = file_get_contents(__DIR__.'/../stubs/metric.php'); $contents = str_replace('SmoothiesCount', $name, $contents); $contents = str_replace('smoothies-count', Str::snake($name, '-'), $contents); $path = app_path('Pilot/Metrics/'.$name.'.php'); if (file_exists($path)) { $this->error('Metric already exists!'); return; } @mkdir(dirname($path), 0755, true); file_put_contents($path, $contents); $this->info('Metric created successfully!'); } }