Synchronizer::create()   A
last analyzed

Complexity

Conditions 4
Paths 10

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
c 0
b 0
f 0
nc 10
nop 2
dl 0
loc 14
rs 9.9
1
<?php
2
3
namespace App\Babel\Synchronize;
4
use ErrorException;
5
use Exception;
6
7
class Synchronizer
8
{
9
    /**
10
     * Initial
11
     *
12
     * @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...
13
     */
14
    public function __construct($all_data)
15
    {
16
        $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...
17
    }
18
19
    public static function create($oj, $all_data)
20
    {
21
        $synchronizerProvider="Synchronizer";
22
        try {
23
            $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$oj/babel.json")), true);
24
            $synchronizerProvider=$BabelConfig["provider"]["synchronizer"];
25
        } catch (ErrorException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
26
        } catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
27
        }
28
        $className="App\\Babel\\Extension\\$oj\\$synchronizerProvider";
29
        if (class_exists($className)) {
30
            return new $className($all_data);
31
        } else {
32
            return null;
33
        }
34
    }
35
}
36