Submitter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
c 0
b 0
f 0
dl 0
loc 49
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 24 2
A create() 0 14 4
1
<?php
2
3
namespace App\Babel\Submit;
4
5
use App\Models\Submission\SubmissionModel;
6
use App\Babel\Submit\Core;
0 ignored issues
show
Bug introduced by
The type App\Babel\Submit\Core was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Support\Facades\Validator;
8
use Auth;
9
use ErrorException;
10
use Exception;
11
12
class Submitter
13
{
14
    public $post_data=[];
15
16
    /**
17
     * Initial
18
     *
19
     * @return Response
0 ignored issues
show
Bug introduced by
The type App\Babel\Submit\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
20
     */
21
    public function __construct($all_data)
22
    {
23
        $this->post_data=$all_data;
24
25
        set_time_limit(0);
26
27
        $sub=[
28
            'time'=>'0',
29
            'verdict'=>'Waiting',
30
            'memory'=>'0',
31
            'remote_id'=>'',
32
            'score'=>0,
33
            'compile_info'=>'',
34
        ];
35
36
        $submitter=self::create($this->post_data["oj"], $sub, $all_data);
37
        if (!is_null($submitter)) {
38
            $submitter->submit();
39
        }
40
41
        // insert submission
42
43
        $submission=new SubmissionModel();
44
        $submission->updateSubmission($this->post_data["sid"], $sub);
45
    }
46
47
    public static function create($oj, & $sub, $all_data)
48
    {
49
        $submitterProvider="Submitter";
50
        try {
51
            $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$oj/babel.json")), true);
52
            $submitterProvider=$BabelConfig["provider"]["submitter"];
53
        } catch (ErrorException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
54
        } catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
55
        }
56
        $className="App\\Babel\\Extension\\$oj\\$submitterProvider";
57
        if (class_exists($className)) {
58
            return new $className($sub, $all_data);
59
        } else {
60
            return null;
61
        }
62
    }
63
}
64