Completed
Push — master ( 131b5c...25b0c2 )
by CodexShaper
05:29 queued 15s
created

DatabaseSeed   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 66
ccs 0
cts 23
cp 0
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 3
A getOptions() 0 4 1
A findComposer() 0 7 2
1
<?php
2
3
namespace CodexShaper\DBM\Commands;
4
5
use CodexShaper\DBM\ManagerServiceProvider;
6
use Illuminate\Console\Command;
7
use Illuminate\Filesystem\Filesystem;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Process\Process;
10
11
class DatabaseSeed extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'dbm:seed';
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Seed the Laravel Database Manager';
25
    /**
26
     * The database Seeder Path.
27
     *
28
     * @var string
29
     */
30
    protected $seedersPath = __DIR__.'/../../database/seeds/';
31
32
    /**
33
     * Get Option.
34
     *
35
     * @return array
36
     */
37
    protected function getOptions()
38
    {
39
        return [
40
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production', null],
41
        ];
42
    }
43
44
    /**
45
     * Get the composer command for the environment.
46
     *
47
     * @return string
48
     */
49
    protected function findComposer()
50
    {
51
        if (file_exists(getcwd().'/composer.phar')) {
52
            return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar';
53
        }
54
55
        return 'composer';
56
    }
57
58
    /**
59
     * Execute the console command.
60
     *
61
     * @param \Illuminate\Filesystem\Filesystem $filesystem
62
     *
63
     * @return void
64
     */
65
    public function handle(Filesystem $filesystem)
0 ignored issues
show
Unused Code introduced by
The parameter $filesystem is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

65
    public function handle(/** @scrutinizer ignore-unused */ Filesystem $filesystem)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        $this->info('Database Manager Seeding...');
68
        // Seeding Dummy Data
69
        $class = 'DatabaseManagerSeeder';
70
        $file = $this->seedersPath.$class.'.php';
71
        if (file_exists($file) && ! class_exists($class)) {
72
            require_once $file;
73
        }
74
        with(new $class())->run();
75
76
        $this->info('Seeding Completed');
77
    }
78
}
79