setDescription('Create a new constant class'); $this->addOption('type', 't', InputOption::VALUE_OPTIONAL, 'Constant type, const or enum', ''); parent::configure(); } public function getType(): string { return (string) $this->input->getOption('type'); } protected function getStub(): string { $type = $this->getType(); if (! $type) { return $this->getConfig()['stub'] ?? __DIR__ . '/stubs/constant_enum.stub'; } $stubs = array_merge( ['const' => __DIR__ . '/stubs/constant.stub', 'enum' => __DIR__ . '/stubs/constant_enum.stub'], $this->getConfig()['stubs'] ?? [] ); if (! isset($stubs[$type])) { throw new InvalidArgumentException('The type of constant is not exists.'); } return $stubs[$type]; } protected function getDefaultNamespace(): string { return $this->getConfig()['namespace'] ?? 'App\Constants'; } }