ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Collection.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
26 protected array $elements;
27 protected int $index;
28
29 public function __construct(
30 protected FactoryInterface $factory,
32 ) {
33 $this->elements = $elements;
34 $this->index = 0;
35 }
36
37 public function getElementsByStatusIds(
38 string ...$lp_status_ids
40 $elements = [];
41 foreach ($lp_status_ids as $lp_status_id) {
42 $element = $this->getElementByStatusId($lp_status_id);
43 if (is_null($element)) {
44 continue;
45 }
46 $elements[] = $element;
47 }
48 return $this->factory->collection(...$elements);
49 }
50
51 public function getElementByStatusId(
52 string $lp_status_id
53 ): LPStatusInterface|null {
54 foreach ($this->elements as $element) {
55 if ($element->getLPStatusId() === $lp_status_id) {
56 return $element;
57 }
58 }
59 return null;
60 }
61
62 public function current(): LPStatusInterface
63 {
64 return $this->elements[$this->index];
65 }
66
67 public function key(): int
68 {
69 return $this->index;
70 }
71
72 public function next(): void
73 {
74 $this->index++;
75 }
76
77 public function valid(): bool
78 {
79 return isset($this->elements[$this->index]);
80 }
81
82 public function rewind(): void
83 {
84 $this->index = 0;
85 }
86
87 public function count(): int
88 {
89 return count($this->elements);
90 }
91}
factory()
getElementByStatusId(string $lp_status_id)
Definition: Collection.php:51
getElementsByStatusIds(string ... $lp_status_ids)
Definition: Collection.php:37
__construct(protected FactoryInterface $factory, LPStatusInterface ... $elements)
Definition: Collection.php:29
foreach( $report as $row)