Code Duplication    Length = 23-23 lines in 2 locations

src/Console/EndpointCommand.php 1 location

@@ 42-64 (lines=23) @@
39
     * @param \Symfony\Component\Console\Output\OutputInterface $output
40
     * @return void
41
     */
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        // args
45
        $namespace = str_replace('.', '\\', $input->getArgument('namespace'));
46
        $name = $input->getArgument('name');
47
        $path = $this->getApplication()->endpointPath();
48
        $file = $path . str_plural($name) . '.php';
49
50
        // only write file if path exists and file does not exist yet
51
        if (file_exists($path) && !file_exists($file)) {
52
            // write file
53
            $endpoint = fopen($file, "w+");
54
            fwrite($endpoint, $this->template($namespace, $name));
55
            fclose($endpoint);
56
57
            // output
58
            $output->writeln("<info>Created Endpoint: $name</info>");
59
            return;
60
        }
61
62
        // error
63
        $output->writeln("<error>Could not create file $file at $path</error>");
64
    }
65
66
    /**
67
     * File Template

src/Console/ModelCommand.php 1 location

@@ 42-64 (lines=23) @@
39
     * @param \Symfony\Component\Console\Output\OutputInterface $output
40
     * @return void
41
     */
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        // args
45
        $namespace = str_replace('.', '\\', $input->getArgument('namespace'));
46
        $name = $input->getArgument('name');
47
        $path = $this->getApplication()->modelPath();
48
        $file = $path . str_plural($name) . '.php';
49
50
        // only write file if path exists and file does not exist yet
51
        if (file_exists($path) && !file_exists($file)) {
52
            // write file
53
            $endpoint = fopen($file, "w+");
54
            fwrite($endpoint, $this->template($namespace, $name));
55
            fclose($endpoint);
56
57
            // output
58
            $output->writeln("<info>Created Model: $name</info>");
59
            return;
60
        }
61
62
        // error
63
        $output->writeln("<error>Could not create file $file at $path</error>");
64
    }
65
66
    /**
67
     * File Template