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

Lock   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 85
ccs 0
cts 20
cp 0
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isCommandLocked() 0 4 1
A setCommandLocked() 0 14 2
A getChannel() 0 4 1
A setChannel() 0 6 1
A getLockedAt() 0 4 1
A getLockedBy() 0 4 1
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