EnumField   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A makeField() 0 8 2
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