Completed
Push — feature/collation ( 3fa00f )
by Kit Loong
04:36
created

OtherField::makeField()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 12
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: liow.kitloong
5
 * Date: 2020/03/29
6
 */
7
8
namespace KitLoong\MigrationsGenerator\Generators;
9
10
use Doctrine\DBAL\Schema\Column;
11
use KitLoong\MigrationsGenerator\Generators\Modifier\CollationModifier;
12
13
class OtherField
14
{
15
    private $collationModifier;
16
17
    public function __construct(CollationModifier $collationModifier)
18
    {
19
        $this->collationModifier = $collationModifier;
20
    }
21
22
    public function makeField(string $tableName, array $field, Column $column): array
23
    {
24
        if (isset(FieldGenerator::$fieldTypeMap[$field['type']])) {
25
            $field['type'] = FieldGenerator::$fieldTypeMap[$field['type']];
26
        }
27
28
        $collation = $this->collationModifier->generate($tableName, $column);
29
        if ($collation !== '') {
30
            $field['decorators'][] = $collation;
31
        }
32
33
        return $field;
34
    }
35
}
36