Total Complexity | 7 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | class JudgerService |
||
10 | { |
||
11 | /** |
||
12 | * @param string $name |
||
13 | * @param null $bind_ip |
||
|
|||
14 | * |
||
15 | * @throws \App\Exceptions\Judger\JudgerNameExist |
||
16 | * |
||
17 | * @return \App\Entities\Judger |
||
18 | */ |
||
19 | public function newJudger($name, $bind_ip = null) |
||
20 | { |
||
21 | if ($this->exist($name)) { |
||
22 | throw new JudgerNameExist(); |
||
23 | } |
||
24 | $judger = new Judger(); |
||
25 | $judger->name = $name; |
||
26 | $judger->code = new_judge_code(); |
||
27 | $judger->status = Judger::ST_ACTIVITY; |
||
28 | if ($bind_ip) { |
||
29 | $judger->bind_ip = $bind_ip; |
||
30 | } |
||
31 | $judger->save(); |
||
32 | |||
33 | return $judger; |
||
34 | } |
||
35 | |||
36 | public function find($id) |
||
39 | } |
||
40 | /** |
||
41 | * @param $code |
||
42 | * |
||
43 | * @return Judger |
||
44 | */ |
||
45 | public function getJudger($code) |
||
52 | } |
||
53 | |||
54 | private function exist($name) |
||
57 | } |
||
58 | } |
||
59 |