ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDBStepReader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
26 public function getLatestStepNumber(string $step_class_name, string $step_prefix): int
27 {
28 $steps = $this->readStepNumbers($step_class_name, $step_prefix);
29 return $steps[count($steps) - 1];
30 }
31
35 public function readStepNumbers(string $step_class_name, string $step_prefix): array
36 {
37 $step_numbers = [];
38 foreach (get_class_methods($step_class_name) as $method) {
39 if (stripos($method, $step_prefix) !== 0) {
40 continue;
41 }
42
43 $number = substr($method, strlen($step_prefix));
44
45 if (!preg_match("/^[1-9]\d*$/", $number)) {
46 throw new LogicException("Method $method seems to be a step but has an odd looking number");
47 }
48
49 $step_numbers[] = (int) $number;
50 }
51
52 sort($step_numbers);
53 return $step_numbers;
54 }
55}
readStepNumbers(string $step_class_name, string $step_prefix)
Get a list of all steps in this class.
getLatestStepNumber(string $step_class_name, string $step_prefix)
Get the number of the latest database step in this class.