ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
JobEntities.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23final readonly class JobEntities implements \ILIAS\Cron\Job\JobCollection
24{
28 private \ArrayIterator $jobs;
29
30 public function __construct(\ILIAS\Cron\Job\JobEntity ...$jobs)
31 {
32 $this->jobs = new \ArrayIterator(array_values($jobs));
33 }
34
38 public function getIterator(): \ArrayIterator
39 {
40 return $this->jobs;
41 }
42
43 public function count(): int
44 {
45 return iterator_count($this);
46 }
47
48 public function add(\ILIAS\Cron\Job\JobEntity $job): void
49 {
50 $this->jobs->append($job);
51 }
52
53 public function filter(callable $callable): static
54 {
55 return new static(...array_values(array_filter(iterator_to_array($this), $callable)));
56 }
57
58 public function slice(int $offset, ?int $length = null): static
59 {
60 return new static(...\array_slice(iterator_to_array($this), $offset, $length, true));
61 }
62
66 public function toArray(): array
67 {
68 return iterator_to_array($this);
69 }
70}
filter(callable $callable)
Returns all the elements of this collection that satisfy the predicate $callable.
Definition: JobEntities.php:53
__construct(\ILIAS\Cron\Job\JobEntity ... $jobs)
Definition: JobEntities.php:30
slice(int $offset, ?int $length=null)
Extracts a slice of $length elements starting at position $offset from the Collection.
Definition: JobEntities.php:58
add(\ILIAS\Cron\Job\JobEntity $job)
Definition: JobEntities.php:48
@template-extends \IteratorAggregate<\ILIAS\Cron\Job\JobEntity>
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.