Completed
Pull Request — master (#41)
by guillaume
20:22
created

Lock::getLockedBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Itkg\DelayEventBundle\Model;
4
5
/**
6
 * Class Lock
7
 */
8
class Lock
9
{
10
    /**
11
     * @var bool
12
     */
13
    protected $commandLocked = false;
14
15
    /**
16
     * @var string
17
     */
18
    protected $channel = '';
19
20
    /**
21
     * @var \DateTime
22
     */
23
    protected $lockedAt;
24
25
    /**
26
     * @var string
27
     */
28
    protected $lockedBy;
29
30
    /**
31
     * @return boolean
32
     */
33
    public function isCommandLocked()
34
    {
35
        return $this->commandLocked;
36
    }
37
38
    /**
39
     * @param boolean $commandLocked
40
     *
41
     * @return $this
42
     */
43
    public function setCommandLocked($commandLocked)
44
    {
45
        $this->commandLocked = $commandLocked;
46
47
        if ($commandLocked) {
48
            $this->lockedAt = new \DateTime();
49
            $this->lockedBy = php_uname('n');
50
        } else {
51
            $this->lockedAt = null;
52
            $this->lockedBy = '';
53
        }
54
55
        return $this;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getChannel()
62
    {
63
        return $this->channel;
64
    }
65
66
    /**
67
     * @param string $channel
68
     *
69
     * @return Lock
70
     */
71
    public function setChannel($channel)
72
    {
73
        $this->channel = $channel;
74
75
        return $this;
76
    }
77
78
    /**
79
     * @return \DateTime
80
     */
81
    public function getLockedAt()
82
    {
83
        return $this->lockedAt;
84
    }
85
    /**
86
     * @return string
87
     */
88
    public function getLockedBy()
89
    {
90
        return $this->lockedBy;
91
    }
92
}
93