Passed
Push — master ( 10a192...087136 )
by Aleksei
07:38 queued 05:42
created

ForeignKey   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 8
c 1
b 0
f 1
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A columnNames() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license MIT
7
 * @author  Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Migrations\Operation\ForeignKey;
13
14
use Cycle\Migrations\Operation\AbstractOperation;
15
16
abstract class ForeignKey extends AbstractOperation
17
{
18
    /**
19
     * Some options has set of aliases.
20
     *
21
     * @var array
22
     */
23
    protected $aliases = [
24
        'onDelete' => ['delete'],
25
        'onUpdate' => ['update'],
26
    ];
27
28
    /**
29
     * Column foreign key associated to.
30
     *
31
     * @var array
32
     */
33
    protected $columns = [];
34
35
    /**
36
     * @param string $table
37
     * @param array  $columns
38
     */
39
    public function __construct(string $table, array $columns)
40
    {
41
        parent::__construct($table);
42
        $this->columns = $columns;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function columnNames(): string
49
    {
50
        return implode(', ', $this->columns);
51
    }
52
}
53