Passed
Push — master ( e800ea...3ba9d6 )
by Quetzy
03:28
created

AuditTableCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * This file is part of the Laravel Auditing package.
4
 *
5
 * @author     Antério Vieira <[email protected]>
6
 * @author     Quetzy Garcia  <[email protected]>
7
 * @author     Raphael França <[email protected]>
8
 * @copyright  2015-2018
9
 *
10
 * For the full copyright and license information,
11
 * please view the LICENSE.md file that was distributed
12
 * with this source code.
13
 */
14
15
namespace OwenIt\Auditing\Console;
16
17
use Illuminate\Console\Command;
18
use Illuminate\Filesystem\Filesystem;
19
use Illuminate\Support\Composer;
20
21
class AuditTableCommand extends Command
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected $name = 'auditing:table';
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected $description = 'Create a migration for the audits table';
32
33
    /**
34
     * The filesystem instance.
35
     *
36
     * @var \Illuminate\Filesystem\Filesystem
37
     */
38
    protected $files;
39
40
    /**
41
     * Composer.
42
     *
43
     * @var \Illuminate\Support\Composer
44
     */
45
    protected $composer;
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 246
    public function __construct(Filesystem $files, Composer $composer)
51
    {
52 246
        parent::__construct();
53
54 246
        $this->files = $files;
55 246
        $this->composer = $composer;
56 246
    }
57
58
    /**
59
     * Execute the console command.
60
     *
61
     * @return void
62
     */
63
    public function handle()
64
    {
65
        $source = __DIR__.'/../../database/migrations/audits.stub';
66
67
        $destination = $this->laravel['migration.creator']->create(
68
            'create_audits_table',
69
            $this->laravel->databasePath().'/migrations'
70
        );
71
72
        $this->files->copy($source, $destination);
73
74
        $this->info('Migration created successfully!');
75
76
        $this->composer->dumpAutoloads();
77
    }
78
}
79