Passed
Push — next ( bea07e...b4e6e6 )
by Bas
05:12 queued 01:45
created

ColumnCommands   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 36
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renameColumn() 0 9 1
A dropColumn() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Schema\Concerns;
6
7
use Illuminate\Support\Fluent;
8
9
trait ColumnCommands
10
{
11
    /**
12
     * Indicate that the given attributes should be renamed.
13
     *
14
     * @param  string  $from
15
     * @param  string  $to
16
     * @return Fluent
17
     */
18 1
    public function renameColumn($from, $to)
19
    {
20 1
        $parameters = [];
21 1
        $parameters['handler'] = 'aql';
22 1
        $parameters['explanation'] = "Rename the column '$from' to '$to'.";
23 1
        $parameters['from'] = $from;
24 1
        $parameters['to'] = $to;
25
26 1
        return $this->addCommand('renameAttribute', $parameters);
0 ignored issues
show
Bug introduced by
It seems like addCommand() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

26
        return $this->/** @scrutinizer ignore-call */ addCommand('renameAttribute', $parameters);
Loading history...
27
    }
28
29
    /**
30
     * Indicate that the given column(s) should be dropped.
31
     *
32
     * @param  array|mixed  $columns
33
     * @return Fluent
34
     */
35 2
    public function dropColumn($columns)
36
    {
37 2
        $columns = is_array($columns) ? $columns : func_get_args();
38
39 2
        $parameters = [];
40 2
        $parameters['handler'] = 'aql';
41 2
        $parameters['attributes'] = $columns;
42 2
        $parameters['explanation'] = 'Drop the following column(s): ' . implode(',', $columns) . '.';
43
44 2
        return $this->addCommand('dropColumn', $parameters);
45
    }
46
}
47