Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
UniqueFeatureIndex | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
getLimit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
queryOptions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
limitIndexSize | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
removeFromIndex | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Flow\Data\Index; |
4 | |
5 | use Flow\Exception\DataModelException; |
6 | |
7 | /** |
8 | * Offers direct lookup of an object via a unique feature(set of properties) |
9 | * on the object. |
10 | */ |
11 | class UniqueFeatureIndex extends FeatureIndex { |
12 | |
13 | public function getLimit() { |
14 | return 1; |
15 | } |
16 | |
17 | public function queryOptions() { |
18 | return [ 'LIMIT' => $this->getLimit() ]; |
19 | } |
20 | |
21 | public function limitIndexSize( array $values ) { |
22 | if ( count( $values ) > $this->getLimit() ) { |
23 | throw new DataModelException( 'Unique index should never have more than ' . $this->getLimit() . ' value', 'process-data' ); |
24 | } |
25 | return $values; |
26 | } |
27 | |
28 | protected function removeFromIndex( array $indexed, array $row ) { |
29 | $this->cache->delete( $this->cacheKey( $indexed ) ); |
30 | } |
31 | } |