Completed
Push — master ( 9f49ce...6e65c6 )
by Zach
02:45 queued 40s
created

DBSeed   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 3
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
A execute() 0 10 2
1
<?php
2
3
namespace Yarak\Commands;
4
5
use Yarak\DB\Seeders\SeedRunner;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class DBSeed extends YarakCommand
11
{
12
    /**
13
     * Configure the command.
14
     */
15
    protected function configure()
16
    {
17
        $this->setName('db:seed')
18
            ->setDescription('Seed the database.')
19
            ->setHelp('This command will run the given seeder class.')
20
            ->addArgument(
21
                'class',
22
                InputArgument::OPTIONAL,
23
                'The name of the seeder class to run.',
24
                'DatabaseSeeder'
25
            );
26
    }
27
28
    /**
29
     * Execute the command.
30
     *
31
     * @param InputInterface  $input
32
     * @param OutputInterface $output
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $seedRunner = new SeedRunner();
37
38
        $seedRunner->run($input->getArgument('class'));
39
40
        foreach ($seedRunner->getLog() as $message) {
41
            $output->writeln($message);
42
        }
43
    }
44
}
45