Passed
Push — master ( 14e18f...4d6973 )
by Dong
01:45
created

config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
1
<?php
2
namespace Dongdavid\Notify;
3
4
use Dongdavid\Notify\utils\Redis;
5
6
// 如果没有cache方法就自定义一个方法用redis做缓存
7
if (!function_exists('cache')) {
8
    function cache($name, $value = null)
9
    {
10
        if (is_array($name)) {
11
            // name 若传入为数组,则当作redis链接配置
12
            Redis::setConfig($name);
13
        } else {
14
            if ($value === null) {
15
                return Redis::get($name);
16
            } else {
17
                Redis::set($name, $value);
18
            }
19
        }
20
    }
21
} else {
22
    function cache($name, $value = null)
23
    {
24
        return \cache($name, $value);
0 ignored issues
show
Bug introduced by
The function cache was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return /** @scrutinizer ignore-call */ \cache($name, $value);
Loading history...
25
    }
26
}
27
28
if (!function_exists('config')) {
29
    function config($name, $value = null)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
    function config(/** @scrutinizer ignore-unused */ $name, $value = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        if (null !== $value) {
32
            \Dongdavid\Notify\cache('notify-config', $value);
33
        } else {
34
            return \Dongdavid\Notify\cache('notify-config');
35
        }
36
    }
37
} else {
38
    function config($name, $value = null)
39
    {
40
        return \config($name, $value);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        return /** @scrutinizer ignore-call */ \config($name, $value);
Loading history...
41
    }
42
}