ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
StorableFlavourDecorator.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
21 
25 
30 final class StorableFlavourDecorator extends Flavour
31 {
32  private array $streams = [];
33  protected Flavour $flavour;
34 
35  public function __construct(Flavour $flavour)
36  {
37  $this->flavour = $flavour;
38  }
39 
40  public function getFlavour(): Flavour
41  {
42  return $this->flavour;
43  }
44 
45  public function getPersistingName(): string
46  {
47  return $this->flavour->getPersistingName();
48  }
49 
50  public function getName(): string
51  {
52  return $this->flavour->getName();
53  }
54 
56  {
57  return $this->flavour->getResourceId();
58  }
59 
60  public function getDefinition(): FlavourDefinition
61  {
62  return $this->flavour->getDefinition();
63  }
64 
65  public function getRevision(): int
66  {
67  return $this->flavour->getRevision();
68  }
69 
70  // STREAMS
71 
75  public function filterStreams(\Closure $filter): void
76  {
77  $this->streams = array_filter(
78  $this->streams,
79  $filter
80  );
81  }
82 
83  public function setStreams(array $streams): void
84  {
85  foreach ($streams as $index => $stream) {
86  $this->addStream($index, $stream);
87  }
88  }
89 
90 
91  public function addStream(int $index, FileStream $stream): self
92  {
93  $this->streams[$index] = $stream;
94 
95  return $this;
96  }
97 
98  public function getStream(int $index = 0): ?FileStream
99  {
100  return $this->streams[$index] ?? null;
101  }
102 
106  public function getStreams(): array
107  {
108  return $this->streams;
109  }
110 }
filterStreams(\Closure $filter)
Filter Streams with a Closure which accepts a FileStream and returns bool
The base interface for all filesystem streams.
Definition: FileStream.php:31