Passed
Push — 4.x ( b027a1...820cf2 )
by Kit Loong
62:09
created

CharsetModifier   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 13 3
A __construct() 0 3 1
1
<?php
2
3
namespace KitLoong\MigrationsGenerator\Generators\Modifier;
4
5
use Doctrine\DBAL\Schema\Column;
6
use KitLoong\MigrationsGenerator\Generators\Decorator;
7
use KitLoong\MigrationsGenerator\MigrationMethod\ColumnModifier;
8
use KitLoong\MigrationsGenerator\MigrationsGeneratorSetting;
9
10
class CharsetModifier
11
{
12
    private $decorator;
13
14
    public function __construct(Decorator $decorator)
15
    {
16
        $this->decorator = $decorator;
17
    }
18
19
    public function generate(string $tableName, Column $column): string
0 ignored issues
show
Unused Code introduced by
The parameter $tableName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
    public function generate(/** @scrutinizer ignore-unused */ string $tableName, Column $column): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21
        if (app(MigrationsGeneratorSetting::class)->isUseDBCollation()) {
22
            $charset = $column->getPlatformOptions()['charset'] ?? null;
23
            if ($charset != null) {
24
                return $this->decorator->decorate(
25
                    ColumnModifier::CHARSET,
26
                    [$this->decorator->columnDefaultToString($charset)]
27
                );
28
            }
29
        }
30
31
        return '';
32
    }
33
}
34