Passed
Pull Request — master (#372)
by Wilmer
03:00
created

SchemaCacheProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A tablePrefixes() 0 42 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Provider;
6
7
use function sprintf;
8
9
final class SchemaCacheProvider
10
{
11
    public function tablePrefixes(): array
12
    {
13
        $configs = [
14
            [
15
                'prefix' => '',
16
                'name' => 'type',
17
            ],
18
            [
19
                'prefix' => '',
20
                'name' => '{{%type}}',
21
            ],
22
            [
23
                'prefix' => 'ty',
24
                'name' => '{{%pe}}',
25
            ],
26
        ];
27
28
        $data = [];
29
30
        foreach ($configs as $config) {
31
            foreach ($configs as $testConfig) {
32
                if ($config === $testConfig) {
33
                    continue;
34
                }
35
36
                $description = sprintf(
37
                    "%s (with '%s' prefix) against %s (with '%s' prefix)",
38
                    $config['name'],
39
                    $config['prefix'],
40
                    $testConfig['name'],
41
                    $testConfig['prefix']
42
                );
43
                $data[$description] = [
44
                    $config['prefix'],
45
                    $config['name'],
46
                    $testConfig['prefix'],
47
                    $testConfig['name'],
48
                ];
49
            }
50
        }
51
52
        return $data;
53
    }
54
}
55