ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LookupBase.php
Go to the documentation of this file.
1<?php
2
4
7
8abstract class LookupBase
9{
10 protected static function validateIndexLookup($lookup_array, $index_number)
11 {
12 // index_number must be a number greater than or equal to 1
13 if (!is_numeric($index_number) || $index_number < 1) {
14 throw new Exception(Functions::VALUE());
15 }
16
17 // index_number must be less than or equal to the number of columns in lookup_array
18 if ((!is_array($lookup_array)) || (empty($lookup_array))) {
19 throw new Exception(Functions::REF());
20 }
21
22 return (int) $index_number;
23 }
24
25 protected static function checkMatch(
26 bool $bothNumeric,
27 bool $bothNotNumeric,
28 $notExactMatch,
29 int $rowKey,
30 string $cellDataLower,
31 string $lookupLower,
32 ?int $rowNumber
33 ): ?int {
34 // remember the last key, but only if datatypes match
35 if ($bothNumeric || $bothNotNumeric) {
36 // Spreadsheets software returns first exact match,
37 // we have sorted and we might have broken key orders
38 // we want the first one (by its initial index)
39 if ($notExactMatch) {
40 $rowNumber = $rowKey;
41 } elseif (($cellDataLower == $lookupLower) && (($rowNumber === null) || ($rowKey < $rowNumber))) {
42 $rowNumber = $rowKey;
43 }
44 }
45
46 return $rowNumber;
47 }
48}
An exception for terminatinating execution or to throw for unit testing.
static validateIndexLookup($lookup_array, $index_number)
Definition: LookupBase.php:10
static checkMatch(bool $bothNumeric, bool $bothNotNumeric, $notExactMatch, int $rowKey, string $cellDataLower, string $lookupLower, ?int $rowNumber)
Definition: LookupBase.php:25
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12