Test Failed
Pull Request — master (#12)
by wujunze
03:09
created

Context::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Seasx\SeasLogger;
5
6
7
use Co;
8
9
/**
10
 * Class Context
11
 * @package Seasx\SeasLogger
12
 */
13
class Context
14
{
15
    /**
16
     * @param string $name
17
     * @param $value
18
     */
19
    public static function set(string $name, $value): void
20
    {
21
        Co::getContext()[$name] = $value;
0 ignored issues
show
Bug introduced by
Are you sure the usage of Co::getContext() targeting Swoole\Coroutine::getContext() 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...
22
    }
23
24
    /**
25
     * @param string $name
26
     * @return mixed
27
     */
28
    public static function get(string $name)
29
    {
30
        return isset(Co::getContext()[$name]) ? Co::getContext()[$name] : null;
0 ignored issues
show
Bug introduced by
Are you sure the usage of Co::getContext() targeting Swoole\Coroutine::getContext() 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...
31
    }
32
33
    /**
34
     * @param string $name
35
     * @return bool
36
     */
37
    public static function has(string $name): bool
38
    {
39
        return isset(Co::getContext()[$name]);
0 ignored issues
show
Bug introduced by
Are you sure the usage of Co::getContext() targeting Swoole\Coroutine::getContext() 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...
40
    }
41
42
    /**
43
     * @param string $name
44
     */
45
    public static function delete(string $name): void
46
    {
47
        unset(Co::getContext()[$name]);
0 ignored issues
show
Bug introduced by
Are you sure the usage of Co::getContext() targeting Swoole\Coroutine::getContext() 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...
48
    }
49
}