Completed
Push — master ( e09a05...0dc2bf )
by Sebastian
01:59
created

call_user_func_array()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 26
nc 1
nop 2
dl 0
loc 42
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace SebastianFeldmann\Ftp;
4
5
/**
6
 * Mock internal ftp_connect.
7
 *
8
 * @param  string $host
9
 * @param  string $port
10
 * @return array
11
 */
12
function ftp_connect($host, $port)
13
{
14
    return ['host' => $host, 'port' => $port];
15
}
16
17
/**
18
 * Mock internal ftp_login.
19
 *
20
 * @param  array  $connection
21
 * @param  string $user
22
 * @param  string $password
23
 * @return bool
24
 * @throws \Exception
25
 */
26
function ftp_login($connection, $user, $password)
0 ignored issues
show
Unused Code introduced by
The parameter $password 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

26
function ftp_login($connection, $user, /** @scrutinizer ignore-unused */ $password)

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...
Unused Code introduced by
The parameter $user 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

26
function ftp_login($connection, /** @scrutinizer ignore-unused */ $user, $password)

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...
27
{
28
    if ($connection['host'] != 'example.com') {
29
        throw new \Exception('invalid connection');
30
    }
31
    if ($connection['port'] != 21) {
32
        throw new \Exception('invalid connection');
33
    }
34
    return true;
35
}
36
37
/**
38
 * Mock internal call_user_func_array.
39
 *
40
 * @param  string $name
41
 * @param  array  $args
42
 * @return bool
43
 */
44
function call_user_func_array($name, $args)
0 ignored issues
show
Unused Code introduced by
The parameter $args 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

44
function call_user_func_array($name, /** @scrutinizer ignore-unused */ $args)

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...
45
{
46
    static $iterations;
47
48
    $iteration = $iterations[$name] ?? 0;
49
    $iterations[$name]++;
50
51
    $return = [
52
        'ftp_nlist' => [
53
            ['foo.txt', 'bar.txt', 'fiz', 'baz'],
54
        ],
55
        'ftp_pwd'   => [
56
            '/root',
57
        ],
58
        'ftp_chdir' => [
59
            false,
60
            false,
61
            true,
62
            true,
63
            true,
64
            true,
65
        ],
66
        'ftp_mdtm' => [
67
            '20180101123055',
68
            '20180101123056',
69
            '20180101123057',
70
            '20180101123058'
71
        ],
72
        'ftp_size' => [
73
            100,
74
            200,
75
            1,
76
            1,
77
            1,
78
            1,
79
        ],
80
        'ftp_put' => [
81
            true,
82
        ],
83
    ];
84
85
    return $return[$name][$iteration] ?? true;
86
}
87