Passed
Pull Request — master (#182)
by John
04:04
created

Synchronizer::create()   A

Complexity

Conditions 4
Paths 10

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 11
nc 10
nop 2
dl 0
loc 13
rs 9.9
c 1
b 0
f 1
1
<?php
2
3
namespace App\Babel\Synchronize;
4
5
class Synchronizer
6
{
7
    /**
8
     * Initial
9
     *
10
     * @return Response
0 ignored issues
show
Bug introduced by
The type App\Babel\Synchronize\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
11
     */
12
    public function __construct($all_data)
13
    {
14
        $submitter=self::create($all_data["oj"], $all_data);
0 ignored issues
show
Unused Code introduced by
The assignment to $submitter is dead and can be removed.
Loading history...
15
    }
16
17
    public static function create($oj, $all_data) {
18
        $synchronizerProvider="Synchronizer";
19
        try {
20
            $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$oj/babel.json")), true);
21
            $synchronizerProvider=$BabelConfig["provider"]["synchronizer"];
22
        } catch(ErrorException $e) {
0 ignored issues
show
Bug introduced by
The type App\Babel\Synchronize\ErrorException was not found. Did you mean ErrorException? If so, make sure to prefix the type with \.
Loading history...
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
23
        } catch(Exception $e) {
0 ignored issues
show
Bug introduced by
The type App\Babel\Synchronize\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
24
        }
25
        $className = "App\\Babel\\Extension\\$oj\\$synchronizerProvider";
26
        if(class_exists($className)) {
27
            return new $className($all_data);
28
        } else {
29
            return null;
30
        }
31
    }
32
}
33