Passed
Push — main ( e8ebe8...e1a2dc )
by Miaad
01:30
created

multi::setUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BPT\receiver;
4
5
use BPT\BPT;
6
use BPT\lock;
7
use BPT\logger;
8
use BPT\receiver\multi\exec;
9
use BPT\receiver\multi\curl;
10
11
class multi extends webhook {
12
    public static function init() {
13
        if (lock::exist('BPT-MULTI-EXEC')) {
14
            self::setUpdate(exec::init());
15
        }
16
        elseif(lock::exist('BPT-MULTI-CURL')) {
17
            self::setUpdate(curl::init());
18
        }
19
        else {
20
            self::deleteOldLocks();
21
            self::checkURL();
22
            self::setCertificate();
23
            exec::support() ? exec::install() : curl::install();
24
        }
25
    }
26
27
    private static function setUpdate(string $update) {
28
        BPT::$update = receiver::processUpdate($update);
29
        logger::write('Update received , lets process it ;)');
30
    }
31
32
    private static function deleteOldLocks() {
33
        if (lock::exist('BPT')) {
34
            lock::delete('BPT');
35
        }
36
        if (lock::exist('getUpdate')) {
37
            lock::delete('getUpdate');
38
        }
39
    }
40
}