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

DBSeed::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.4285
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