Test Failed
Pull Request — master (#12)
by
unknown
02:46
created

Context   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 43
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 5 1
A get() 0 5 2
A delete() 0 5 1
A set() 0 5 1
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
        /** @var \ArrayObject $context */
22
        $context = Co::getContext();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $context is correct as 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 assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
23
        $context[$name] = $value;
24
    }
25
26
    /**
27
     * @param string $name
28
     * @return mixed
29
     */
30
    public static function get(string $name)
31
    {
32
        /** @var \ArrayObject $context */
33
        $context = Co::getContext();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $context is correct as 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 assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
34
        return isset($context[$name]) ? $context[$name] : null;
35
    }
36
37
    /**
38
     * @param string $name
39
     * @return bool
40
     */
41
    public static function has(string $name): bool
42
    {
43
        /** @var \ArrayObject $context */
44
        $context = Co::getContext();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $context is correct as 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 assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
45
        return isset($context[$name]);
46
    }
47
48
    /**
49
     * @param string $name
50
     */
51
    public static function delete(string $name): void
52
    {
53
        /** @var \ArrayObject $context */
54
        $context = Co::getContext();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $context is correct as 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 assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
55
        unset($context[$name]);
56
    }
57
}