Passed
Pull Request — master (#216)
by Chenyi
04:17
created

SyncProblems   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 46
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 1
A __construct() 0 3 1
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 SyncProblems extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'babel:syncpro {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid= : The holding group} {--cid= : The contest in NOJ}';
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
        $cid = $this->option('cid');
47
        $className = "App\\Babel\\Extension\\$extension\\Synchronizer";
48
        $all_data = [
49
            'oj'=>$extension,
50
            'vcid'=>$vcid,
51
            'gid'=>$gid,
52
            'cid'=>$cid,
53
        ];
54
        $Sync = new $className($all_data);
55
        $Sync->scheduleCrawl();
56
    }
57
}