Passed
Pull Request — master (#184)
by Chenyi
03:56
created

SyncContest::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 10
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 13
rs 9.9332
1
<?php
2
3
namespace App\Console\Commands\Babel;
4
5
use Illuminate\Console\Command;
6
use App\Babel\Babel;
7
use Exception;
8
use function GuzzleHttp\json_decode;
9
10
class SyncContest extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'babel:sync {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Crawl contests for a given Babel Extension to NOJ';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        $extension = $this->argument('extension');
44
        $vcid = $this->option('vcid');
45
        $gid = $this->option('gid');
46
        $className = "App\\Babel\\Extension\\$extension\\Synchronizer";
47
        $all_data = [
48
            'oj'=>$extension,
49
            'vcid'=>$vcid,
50
            'gid'=>$gid,
51
        ];
52
        $Sync = new $className($all_data);
53
        $Sync->crawlContest();
54
    }
55
}
56