Passed
Branch v1.4.0 (ac3196)
by Wanderson
01:13
created

Delete   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4

4 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
1
<?php
2
3
namespace Win\Database\Sql\Queries;
4
5
use Win\Database\Orm;
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
	public $where;
17
18
	/** @var Limit */
19
	public $limit;
20
21
	public function __construct(Orm $orm)
22
	{
23
		parent::__construct($orm);
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->connection->query($this, $this->getValues());
47
	}
48
}
49