Passed
Pull Request — master (#32)
by Dmitriy
71:48 queued 56:42
created

ParamsConfigTest::phpFilesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 41
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 56
rs 9.264

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Tests\Integration\Tests\Config;
6
7
use stdClass;
8
use Yiisoft\Composer\Config\Tests\Integration\Tests\Helper\LiterallyCallback;
9
10
final class ParamsConfigTest extends ConfigTest
11
{
12
    public function configProvider(): array
13
    {
14
        return [
15
            ...$this->phpFilesProvider(),
16
            ...$this->yamlFilesProvider(),
17
        ];
18
    }
19
20
    protected function getDefaultConfigName(): string
21
    {
22
        return 'params';
23
    }
24
25
    private function phpFilesProvider(): array
26
    {
27
        return [
28
            ['boolean parameter', true],
29
            ['string parameter', 'value of param 1'],
30
            ['NAN parameter', 'NAN'],
31
            ['float parameter', 1.0000001],
32
            ['int parameter', 123],
33
            ['long int parameter', 123_000],
0 ignored issues
show
Bug introduced by
The constant Yiisoft\Composer\Config\...on\Tests\Config\123_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
            ['array parameter', [
35
                'changed value' => 'from root config',
36
                'first-vendor/first-package' => true,
37
                'first-vendor/second-package' => true,
38
                'second-vendor/first-package' => true,
39
                'second-vendor/second-package' => true,
40
                [[[[[]]]]],
41
            ]],
42
            ['array parameter with UnsetArrayValue', [
43
                'first-vendor/second-package' => true,
44
                'second-vendor/first-package' => true,
45
                'second-vendor/second-package' => true,
46
            ]],
47
            ['array parameter with ReplaceArrayValue', ['replace']],
48
            ['array parameter with RemoveArrayKeys', [
49
                'first-vendor/first-package',
50
                'first-vendor/second-package',
51
                'second-vendor/first-package',
52
                'second-vendor/second-package',
53
                'root value',
54
            ]],
55
            [
56
                'callable parameter',
57
                new LiterallyCallback(function () {
58
                    return 'I am callable';
59
                }),
60
            ],
61
            [
62
                'static callable parameter',
63
                new LiterallyCallback(static function () {
64
                    return 'I am callable';
65
                }),
66
            ],
67
            ['object parameter', new stdClass()],
68
            /**
69
             * Test for subpackages parameters
70
             */
71
            ['first-vendor/first-package', true],
72
            ['first-vendor/second-package', true],
73
            ['first-dev-vendor/first-package', true],
74
            ['first-dev-vendor/second-package', true],
75
            ['second-vendor/first-package', true],
76
            ['second-vendor/second-package', true],
77
            ['second-dev-vendor/first-package', true],
78
            ['second-dev-vendor/second-package', true],
79
            ['constant_based_parameter', 'a constant value defined in config/constants.php'],
80
            ['constant_from_vendor', 'a constant value defined in first-dev-vendor/second-package'],
81
        ];
82
    }
83
84
    private function yamlFilesProvider(): array
85
    {
86
        return [
87
            [
88
                'parameters',
89
                [
90
                    'param1' => 'value1',
91
                    'param2' => true,
92
                    'param3' => [1, 'value2'],
93
                ],
94
            ],
95
        ];
96
    }
97
}
98