Completed
Branch feature/pre-split (540d96)
by Anton
03:41
created

DeleteCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setWhere() 0 4 1
A execute() 0 5 1
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\ORM\Commands;
8
9
use Spiral\Database\Entities\Table;
10
11
class DeleteCommand extends TableCommand
12
{
13
    /**
14
     * Where conditions (short where format).
15
     *
16
     * @var array
17
     */
18
    private $where = [];
19
20
    /**
21
     * @param Table $table
22
     * @param mixed $where
23
     */
24
    public function __construct(Table $table, array $where)
25
    {
26
        parent::__construct($table);
27
        $this->where = $where;
28
    }
29
30
    /**
31
     * @param array $where
32
     */
33
    public function setWhere(array $where)
34
    {
35
        $this->where = $where;
36
    }
37
38
    /**
39
     * Inserting data into associated table.
40
     */
41
    public function execute()
42
    {
43
        $this->table->delete($this->where)->run();
44
        parent::execute();
45
    }
46
}