EnumField::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
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 KitLoong\MigrationsGenerator\Repositories\MySQLRepository;
11
12
class EnumField
13
{
14
    private $decorator;
15
16
    private $mysqlRepository;
17
18 57
    public function __construct(Decorator $decorator, MySQLRepository $mySQLRepository)
19
    {
20 57
        $this->decorator = $decorator;
21 57
        $this->mysqlRepository = $mySQLRepository;
22 57
    }
23
24 6
    public function makeField(string $tableName, array $field): array
25
    {
26 6
        $value = $this->mysqlRepository->getEnumPresetValues($tableName, $field['field']);
27 6
        if ($value !== null) {
28 3
            $field['args'][] = $value;
29
        }
30
31 6
        return $field;
32
    }
33
}
34