Passed
Push — master ( e9dd98...02cf1a )
by Richard
01:44
created

DatabaseModify::getTryInsertAgain()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Maphper\DataSource;
3
4
class DatabaseModify {
5
    private $adapter;
6
    private $alterDb;
7
    private $table;
8
9
    public function __construct(DatabaseAdapter $adapter, $alterDb, $table) {
10
        $this->adapter = $adapter;
11
        $this->alterDb = $alterDb;
12
        $this->table = $table;
13
    }
14
15
    public function addIndex($args) {
16
		if (Database::EDIT_INDEX & $this->alterDb) $this->adapter->addIndex($this->table, $args);
17
	}
18
19
    public function optimizeColumns() {
20
        if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0,500) == 1) $this->adapter->optimiseColumns($this->table);
21
    }
22
23
    public function getTryInsertAgain($tryagain) {
24
        return $tryagain && Database::EDIT_STRUCTURE & $this->alterDb;
25
    }
26
}
27