Passed
Push — master ( 48f23f...3d04cc )
by Jean-Christophe
07:46 queued 13s
created

BulkDeletes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createSQL() 0 7 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
	public function addInstance($instance, $id = null) {
18
		$id = $id ?? OrmUtils::getFirstKeyValue ( $instance );
19
		$this->instances [$id] = $instance;
20
	}
21
22
	public function createSQL() {
23
		$quote = $this->db->quote;
24
		$tableName = OrmUtils::getTableName ( $this->class );
25
		$this->parameters = \array_keys ( $this->instances );
26
		$count = \count ( $this->parameters );
27
28
		return "DELETE FROM {$quote}{$tableName}{$quote} WHERE {$quote}{$this->pkName}{$quote} IN (" . \implode ( ',', \array_fill ( 0, $count, '?' ) ) . ')';
29
	}
30
}
31
32