Completed
Push — dev ( 9f49ce...7f87b9 )
by Zach
02:14
created

MakeSeeder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 34.29 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
dl 12
loc 35
rs 10
c 0
b 0
f 0
wmc 2
lcom 2
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 1
A execute() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Yarak\Commands;
4
5
use Yarak\Config\Config;
6
use Yarak\DB\Seeders\SeederCreator;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class MakeSeeder extends YarakCommand
13
{
14
    /**
15
     * Configure the command.
16
     */
17
    protected function configure()
18
    {
19
        $this->setName('make:seeder')
20
            ->setDescription('Create a new seeder file.')
21
            ->setHelp('This command will generate a new seeder file.')
22
            ->addArgument(
23
                'name',
24
                InputArgument::REQUIRED,
25
                'The name of your seeder file.');
26
    }
27
28
    /**
29
     * Execute the command.
30
     *
31
     * @param InputInterface  $input
32
     * @param OutputInterface $output
33
     */
34 View Code Duplication
    protected function execute(InputInterface $input, OutputInterface $output)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    {
36
        $name = $input->getArgument('name');
37
38
        $config = Config::getInstance($this->configArray);
39
40
        $creator = new SeederCreator($config);
41
42
        $creator->create($name);
43
44
        $output->writeln("<info>Successfully created seeder {$name}.</info>");
45
    }
46
}
47