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

Delete::where()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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