TranslatableColumns   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A dropColumns() 0 6 1
A columns() 0 6 1
A getDefaultColumns() 0 5 1
1
<?php
2
3
namespace Fomvasss\LaravelTranslatable;
4
5
use Illuminate\Database\Schema\Blueprint;
6
7
class TranslatableColumns
8
{
9
    /**
10
     * Add default nested set columns to the table. Also create an index.
11
     *
12
     * @param \Illuminate\Database\Schema\Blueprint $table
13
     */
14
    public static function columns(Blueprint $table)
15
    {
16
        $table->string(config('translatable.db.columns.langcode'))->nullable();
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

16
        $table->string(/** @scrutinizer ignore-call */ config('translatable.db.columns.langcode'))->nullable();
Loading history...
17
        $table->uuid(config('translatable.db.columns.translation_uuid'))->nullable();
18
19
        $table->index(static::getDefaultColumns());
20
    }
21
22
    /**
23
     * Drop Translatable columns.
24
     *
25
     * @param \Illuminate\Database\Schema\Blueprint $table
26
     */
27
    public static function dropColumns(Blueprint $table)
28
    {
29
        $columns = static::getDefaultColumns();
30
31
        $table->dropIndex($columns);
32
        $table->dropColumn($columns);
33
    }
34
35
    /**
36
     * Get a list of default columns.
37
     *
38
     * @return array
39
     */
40
    public static function getDefaultColumns()
41
    {
42
        return [
43
            config('translatable.db.columns.langcode'),
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

43
            /** @scrutinizer ignore-call */ 
44
            config('translatable.db.columns.langcode'),
Loading history...
44
            config('translatable.db.columns.translation_uuid'),
45
        ];
46
    }
47
}