src/Command/InitCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name    = ucfirst($input->getArgument('name'));
        $pattern = '/^[A-Z][a-zA-Z0-9]*$/';
        if (1 !== preg_match($pattern, $name)) {
            throw new Exception('Invalid name.');
        }

        $path       = $input->getArgument('location');
        $path       = ('/' === $path[0]) ? $path : getcwd().'/'.$path;
        $pathExists = is_dir($path);
        $pathInfo   = pathinfo($path);
        if (
            ($pathExists && !is_writable($path)) ||
            (!$pathExists && !is_writable($pathInfo['dirname']))
        ) {
            throw new Exception('Cannot write to path.');
        }

        if ($pathExists && 2 !== count(scandir($path))) {
            throw new Exception('Path not empty.');
        }

        try {
            $this->skeletonService->create($path, $name);
            $this->migrationService->init($path);
            $output->writeln('<info>'.static::$successMessage.'</info>');
        } catch (Exception $e) {
            $output->writeln($e->getMessage());
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name    = ucfirst($input->getArgument('name'));
        $pattern = '/^[A-Z][a-zA-Z0-9]*$/';
        if (1 !== preg_match($pattern, $name)) {
            throw new Exception('Invalid name.');
        }

        $path       = $input->getArgument('location');
        $path       = ('/' === $path[0]) ? $path : getcwd().'/'.$path;
        $pathExists = is_dir($path);
        $pathInfo   = pathinfo($path);
        if (
            ($pathExists && !is_writable($path)) ||
            (!$pathExists && !is_writable($pathInfo['dirname']))
        ) {
            throw new Exception('Cannot write to path.');
        }

        if ($pathExists && 2 !== count(scandir($path))) {
            throw new Exception('Path not empty.');
        }

        try {
            $this->skeletonService->create($path, $name);
            $this->migrationService->init($path);
            $output->writeln('<info>'.static::$successMessage.'</info>');
        } catch (Exception $e) {
            $output->writeln($e->getMessage());
        }
    }
{@inheritdoc}