DeleteEntity::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Rougin\Windstorm\Mutators;
4
5
use Rougin\Windstorm\QueryInterface;
6
use Rougin\Windstorm\MutatorInterface;
7
8
/**
9
 * Delete Entity Mutator
10
 *
11
 * @package Windstorm
12
 * @author  Rougin Gutib <[email protected]>
13
 */
14
class DeleteEntity implements MutatorInterface
15
{
16
    /**
17
     * @var integer
18
     */
19
    protected $id;
20
21
    /**
22
     * @var string
23
     */
24
    protected $primary = 'id';
25
26
    /**
27
     * @var string
28
     */
29
    protected $table = '';
30
31
    /**
32
     * Initializes the mutator instance.
33
     *
34
     * @param integer $id
35
     */
36 6
    public function __construct($id)
37
    {
38 6
        $this->id = $id;
39 6
    }
40
41
    /**
42
     * Mutates the specified query instance.
43
     *
44
     * @param \Rougin\Windstorm\QueryInterface $query
45
     */
46 6
    public function set(QueryInterface $query)
47
    {
48 6
        $query = $query->deleteFrom((string) $this->table);
49
50 6
        return $query->where($this->primary)->equals($this->id);
51
    }
52
}
53