Passed
Push — master ( 297df4...34d528 )
by Jean-Christophe
09:37
created

BulkDeletes::createSQL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ubiquity\orm\bulk;
4
5
use Ubiquity\orm\OrmUtils;
6
7
/**
8
 * Ubiquity\orm\bulk$BulkDeletes
9
 * This class is part of Ubiquity
10
 *
11
 * @author jcheron <[email protected]>
12
 * @version 1.0.0
13
 *
14
 */
15
class BulkDeletes extends AbstractBulks {
16
17 1
	public function addInstance($instance, $id = null) {
18 1
		$id = $id ?? OrmUtils::getFirstKeyValue ( $instance );
19 1
		$this->instances [$id] = $instance;
20 1
	}
21
22 1
	public function createSQL() {
23 1
		$quote = $this->db->quote;
24 1
		$this->parameters = \array_keys ( $this->instances );
25 1
		$count = \count ( $this->parameters );
26
27 1
		return "DELETE FROM {$quote}{$this->tableName}{$quote} WHERE {$quote}{$this->pkName}{$quote} IN (" . \implode ( ',', \array_fill ( 0, $count, '?' ) ) . ')';
28
	}
29
}
30
31