multi   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 26
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpdate() 0 3 1
A init() 0 12 4
A deleteOldLocks() 0 2 1
1
<?php
2
3
namespace BPT\receiver;
4
5
use BPT\lock;
6
use BPT\logger;
7
use BPT\receiver\multi\exec;
8
use BPT\receiver\multi\curl;
9
10
/**
11
 * multi class , for multiprocessing webhook updates
12
 */
13
class multi extends webhook {
14
    /**
15
     * @internal Only for BPT self usage , Don't use it in your source!
16
     */
17
    public static function init() {
18
        if (lock::exist('BPT-MULTI-EXEC')) {
19
            self::setUpdate(exec::init());
20
        }
21
        elseif(lock::exist('BPT-MULTI-CURL')) {
22
            self::setUpdate(curl::init());
23
        }
24
        else {
25
            self::deleteOldLocks();
26
            self::checkURL();
27
            self::setCertificate();
28
            exec::support() ? exec::install() : curl::install();
29
        }
30
    }
31
32
    private static function setUpdate(string $update) {
33
        receiver::processUpdate($update);
34
        logger::write('Update received , lets process it ;)');
35
    }
36
37
    private static function deleteOldLocks() {
38
        lock::deleteIfExist(['BPT', 'getUpdate', 'getUpdateHook']);
39
    }
40
}