Passed
Branch feature/babel (9a8402)
by John
03:52
created

Submitter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 2
A create() 0 6 2
1
<?php
2
3
namespace App\Babel\Submit;
4
5
use App\Models\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
10
class Submitter
11
{
12
    private $sub;
13
    // public $ret=[];
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->sub=& $sub;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $sub seems to be never defined.
Loading history...
24
        $this->post_data=$all_data;
25
26
        set_time_limit(0);
27
28
        $sub=[
29
            'time'=>'0',
30
            'verdict'=>'Waiting',
31
            'memory'=>'0',
32
            'remote_id'=>'',
33
            'score'=>0,
34
            'compile_info'=>'',
35
        ];
36
37
        $submitter=self::create($this->post_data["oj"], $sub, $all_data);
38
        if(!is_null($submitter)) $submitter->submit();
39
40
        // insert submission
41
42
        $submission=new SubmissionModel();
43
        $submission->updateSubmission($this->post_data["sid"], $sub);
44
    }
45
46
    public static function create($oj,& $sub, $all_data) {
47
        $className = "App\\Babel\\Extension\\$oj\\Submitter";
48
        if(class_exists($className)) {
49
            return new $className($sub, $all_data);
50
        } else {
51
            return null;
52
        }
53
    }
54
}
55