CodeSniffer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 48
rs 10
wmc 4
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 18 3
1
<?php
2
3
namespace PHPHub\Console\Commands;
4
5
use Exception;
6
use Illuminate\Console\Command;
7
use Illuminate\Contracts\Bus\SelfHandling;
8
use Symfony\Component\Process\Process;
9
10
class CodeSniffer extends Command implements SelfHandling
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'format';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = '格式化代码';
25
26
    /**
27
     * Create a new command instance.
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return mixed
38
     */
39
    public function handle()
40
    {
41
        $process = new Process('php '.base_path('vendor/bin/php-cs-fixer').' fix');
42
43
        try {
44
            $process->run(function ($type, $buffer) {
45
                if (Process::ERR === $type) {
46
                    $this->error($buffer);
47
                } else {
48
                    $this->info($buffer);
49
                }
50
            });
51
52
            $this->line('Finished.');
53
        } catch (Exception $e) {
54
            $this->error($e->getMessage());
55
        }
56
    }
57
}
58