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

BulkDeletes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createSQL() 0 6 1
A addInstance() 0 3 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