DeleteEntity   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 37
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A set() 0 5 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