DatabaseSeed::findComposer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 6
rs 10
1
<?php
2
3
namespace CodexShaper\DBM\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Symfony\Component\Console\Input\InputOption;
8
9
class DatabaseSeed extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'dbm:seed';
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Seed the Laravel Database Manager';
23
    /**
24
     * The database Seeder Path.
25
     *
26
     * @var string
27
     */
28
    protected $seedersPath = __DIR__.'/../../database/seeds/';
29
30
    /**
31
     * Get Option.
32
     *
33
     * @return array
34
     */
35
    protected function getOptions()
36
    {
37
        return [
38
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production', null],
39
        ];
40
    }
41
42
    /**
43
     * Get the composer command for the environment.
44
     *
45
     * @return string
46
     */
47
    protected function findComposer()
48
    {
49
        if (file_exists(getcwd().'/composer.phar')) {
50
            return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar';
51
        }
52
53
        return 'composer';
54
    }
55
56
    /**
57
     * Execute the console command.
58
     *
59
     * @param \Illuminate\Filesystem\Filesystem $filesystem
60
     *
61
     * @return void
62
     */
63
    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

63
    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...
64
    {
65
        $this->info('Database Manager Seeding...');
66
        // Seeding Dummy Data
67
        $class = 'DatabaseManagerSeeder';
68
        $file = $this->seedersPath.$class.'.php';
69
        if (file_exists($file) && ! class_exists($class)) {
70
            require_once $file;
71
        }
72
        with(new $class())->run();
73
74
        $this->info('Seeding Completed');
75
    }
76
}
77