Passed
Branch v1.4.0 (f21782)
by Wanderson
01:16
created

Delete   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A toString() 0 6 1
A execute() 0 3 1
A __construct() 0 5 1
A getValues() 0 3 1
A where() 0 3 1
1
<?php
2
3
namespace Win\Database\Sql\Queries;
4
5
use Win\Database\RepositoryInterface;
6
use Win\Database\Sql\Clauses\Limit;
7
use Win\Database\Sql\Clauses\Where;
8
use Win\Database\Sql\Query;
9
10
/**
11
 * DELETE FROM
12
 */
13
class Delete extends Query
14
{
15
	/** @var Where */
16
	protected $where;
17
18
	/** @var Limit */
19
	public $limit;
20
21
	public function __construct(RepositoryInterface $repository)
22
	{
23
		parent::__construct($repository);
24
		$this->where = new Where();
25
		$this->limit = new Limit();
26
	}
27
28
	/** @return string */
29
	public function toString()
30
	{
31
		return 'DELETE FROM '
32
				. $this->table
33
				. $this->where
34
				. $this->limit;
35
	}
36
37
	/** @return mixed[] */
38
	public function getValues()
39
	{
40
		return $this->where->values();
41
	}
42
43
	/** @return bool */
44
	public function execute()
45
	{
46
		return $this->conn->query($this, $this->getValues());
47
	}
48
49
	/** @return Where */
50
	public function where()
51
	{
52
		return $this->where;
53
	}
54
}
55