Passed
Push — master ( 609799...41987d )
by John
04:18
created

Submit   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
1
<?php
2
3
namespace App\Babel\Judger;
4
5
use App\Models\SubmissionModel;
6
use App\Http\Controllers\VirtualJudge\Core;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, App\Babel\Judger\Core. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
7
use Illuminate\Support\Facades\Validator;
8
use Auth;
9
10
class Submit
11
{
12
    public $ret=[];
13
    public $post_data=[];
14
15
    /**
16
     * Initial
17
     *
18
     * @return Response
0 ignored issues
show
Bug introduced by
The type App\Babel\Judger\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
19
     */
20
    public function __construct($all_data)
21
    {
22
        $this->post_data=$all_data;
23
24
        set_time_limit(0);
25
26
        $sub=[
27
            'time'=>'0',
28
            'verdict'=>'Waiting',
29
            'memory'=>'0',
30
            'remote_id'=>'',
31
            'score'=>0,
32
            'compile_info'=>'',
33
        ];
34
35
        $curl=new Core($sub, $this->post_data['oj'], $this->post_data);
0 ignored issues
show
Unused Code introduced by
The assignment to $curl is dead and can be removed.
Loading history...
36
37
        // insert submission
38
39
        $submission=new SubmissionModel();
40
        $submission->updateSubmission($this->post_data["sid"], $sub);
41
    }
42
}
43