Passed
Push — master ( 7b7005...55ec05 )
by Brent
02:29
created

Process::setSocket()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Pageon\Pcntl;
4
5
abstract class Process
6
{
7
    protected $pid;
8
9
    protected $name;
10
11
    protected $socket;
12
13
    protected $success;
14
15
    protected $startTime;
16
17
    protected $maxRunTime = 300;
18
19
    public abstract function execute();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
20
21
    public function setPid($pid) : Process {
22
        $this->pid = $pid;
23
24
        return $this;
25
    }
26
27
    public function getPid() {
28
        return $this->pid;
29
    }
30
31
    public function setSocket($socket) : Process {
32
        $this->socket = $socket;
33
34
        return $this;
35
    }
36
37
    public function getSocket() {
38
        return $this->socket;
39
    }
40
41
    public function setName(string $name) : Process {
42
        $this->name = $name;
43
44
        return $this;
45
    }
46
47
    public function getName() : string {
48
        return $this->name;
49
    }
50
51
    public function onSuccess(callable $callback) {
52
        $this->success = $callback;
53
    }
54
55
    public function getSuccess() {
56
        return $this->success;
57
    }
58
59
    public function setStartTime($startTime) {
60
        $this->startTime = $startTime;
61
62
        return $this;
63
    }
64
65
    public function getStartTime() {
66
        return $this->startTime;
67
    }
68
69
    public function setMaxRunTime(int $maxRunTime) : Process {
70
        $this->maxRunTime = $maxRunTime;
71
72
        return $this;
73
    }
74
75
    public function getMaxRunTime() : int {
76
        return $this->maxRunTime;
77
    }
78
79
    public function triggerSuccess($output) {
80
        if (!$this->success) {
81
            return null;
82
        }
83
84
        return call_user_func_array($this->success, [$output]);
85
    }
86
}
87