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

Synchronizer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
dl 0
loc 25
rs 10
c 1
b 0
f 1
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 4
A __construct() 0 3 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