SharedMemory::close()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php namespace Comodojo\Daemon\Worker;
2
3
/**
4
 * @package     Comodojo Daemon
5
 * @author      Marco Giovinazzi <[email protected]>
6
 * @license     MIT
7
 *
8
 * LICENSE:
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16
 * THE SOFTWARE.
17
 */
18
19
class SharedMemory {
20
21
    private $key;
22
23
    public function __construct($id) {
24
25
        $this->key = shmop_open($id, "c", 0644, 128);
26
27
    }
28
29
    public function getKey() {
30
31
        return $this->key;
32
33
    }
34
35
    public function send($signal) {
36
37
        return shmop_write($this->key, $signal, 0);
38
39
    }
40
41
    public function read() {
42
43
        return trim(shmop_read($this->key, 0, 128));
44
45
    }
46
47
    public function delete() {
48
49
        return shmop_write($this->key, str_pad('', 128), 0);
50
51
    }
52
53
    public function close() {
54
55
        shmop_delete($this->key);
56
57
        return shmop_close($this->key);
0 ignored issues
show
Bug introduced by
Are you sure the usage of shmop_close($this->key) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
58
59
    }
60
61
}
62