ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
AbstractCollection.php
Go to the documentation of this file.
2
3use Generator;
4
5/******************************************************************************
6 *
7 * This file is part of ILIAS, a powerful learning management system.
8 *
9 * ILIAS is licensed with the GPL-3.0, you should have received a copy
10 * of said license along with the source code.
11 *
12 * If this is not the case or you just want to try ILIAS, you'll find
13 * us at:
14 * https://www.ilias.de
15 * https://github.com/ILIAS-eLearning
16 *
17 *****************************************************************************/
23abstract class AbstractCollection
24{
25 protected $resource_version = '';
26
30 protected $items = [];
31
35 public function __construct(string $resource_version)
36 {
37 $this->resource_version = $resource_version;
38 }
39
40 public function clear()
41 {
42 $this->items = [];
43 }
44
45
49 public function getItems() : Generator
50 {
51 yield from $this->items;
52 }
53
57 public function getItemsInOrderOfDelivery() : array
58 {
59 return $this->items;
60 }
61
62
68 protected function stripPath(string $path) : string
69 {
70 if (strpos($path, '?') !== false) {
71 return parse_url($path, PHP_URL_PATH);
72 }
73
74 return $path;
75 }
76}
An exception for terminatinating execution or to throw for unit testing.