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

SchemaCacheProvider::tablePrefixes()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 42
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 24
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 42
rs 9.536
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