ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilIndex.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 use ILIAS\Export\ImportHandler\I\File\Path\Node\ilIndexInterface as ilIndexFilePathNodeInterface;
26 
27 class ilIndex implements ilIndexFilePathNodeInterface
28 {
30  protected int $index;
32 
33  public function __construct()
34  {
35  $this->comparison = new ilHandlerDummy();
36  $this->index = 0;
37  $this->indexing_from_end_enabled = false;
38  }
39 
40  public function withIndex(int $index): ilIndexFilePathNodeInterface
41  {
42  $clone = clone $this;
43  $clone->index = $index;
44  return $clone;
45  }
46 
47  public function withComparison(ilHandlerInterface $comparison): ilIndexFilePathNodeInterface
48  {
49  $clone = clone $this;
50  $clone->comparison = $comparison;
51  return $clone;
52  }
53 
54  public function withIndexingFromEndEnabled(bool $enabled): ilIndexFilePathNodeInterface
55  {
56  $clone = clone $this;
57  $clone->indexing_from_end_enabled = $enabled;
58  return $clone;
59  }
60 
61  public function toString(): string
62  {
63  $indexing = '';
64 
65  if ($this->comparison instanceof ilHandlerDummy) {
66  $indexing = $this->indexing_from_end_enabled
67  ? '(last)-' . $this->index
68  : $this->index;
69  } else {
70  $indexing = 'position()' . $this->comparison->toString();
71  }
72 
73  return '[' . $indexing . ']';
74  }
75 
76  public function requiresPathSeparator(): bool
77  {
78  return false;
79  }
80 }
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
withComparison(ilHandlerInterface $comparison)