ConfigWriter::write()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 18
rs 10
1
<?php
2
3
namespace WebnetFr\DatabaseAnonymizer\ConfigGuesser;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
/**
8
 * @author Vlad Riabchenko <[email protected]>
9
 */
10
class ConfigWriter
11
{
12
    /**
13
     * @var array
14
     *
15
     * @return string
16
     */
17
    public function write(array $hints)
18
    {
19
        $config = [];
20
21
        foreach ($hints as $tableName => $tableHints) {
22
            foreach ($tableHints as $columnName => $hint) {
23
                /** @var ConfigGuesserHint $hint */
24
                $config[$tableName]['fields'][$columnName] = $hint->getConfigArray();
25
            }
26
        }
27
28
        $config = [
29
            'webnet_fr_database_anonymizer' => [
30
                'tables' => $config,
31
            ],
32
        ];
33
34
        return Yaml::dump($config, 6);
35
    }
36
}
37