ILIAS  release_8 Revision v8.24
Streams.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
7use Psr\Http\Message\StreamInterface;
8
9/******************************************************************************
10 *
11 * This file is part of ILIAS, a powerful learning management system.
12 *
13 * ILIAS is licensed with the GPL-3.0, you should have received a copy
14 * of said license along with the source code.
15 *
16 * If this is not the case or you just want to try ILIAS, you'll find
17 * us at:
18 * https://www.ilias.de
19 * https://github.com/ILIAS-eLearning
20 *
21 *****************************************************************************/
33final class Streams
34{
43 public static function ofString(string $string): \ILIAS\Filesystem\Stream\Stream
44 {
45 if (!is_string($string)) {
46 throw new \InvalidArgumentException('The argument $string must be of type string but was "' . gettype($string) . '"');
47 }
48
49 $stream = new Stream(fopen('php://memory', 'rw'));
50 $stream->write($string);
51 return $stream;
52 }
53
54
65 public static function ofResource($resource): \ILIAS\Filesystem\Stream\Stream
66 {
67 if (!is_resource($resource)) {
68 throw new \InvalidArgumentException('The argument $resource must be of type resource but was "' . gettype($resource) . '"');
69 }
70
71 return new Stream($resource);
72 }
73
74
82 public static function ofPsr7Stream(StreamInterface $stream): \ILIAS\Filesystem\Stream\Stream
83 {
84 $resource = $stream->detach();
85 return self::ofResource($resource);
86 }
87
88 public function ofZipResource(\ZipArchive $zip, int $index): void
89 {
90 }
91}
static ofPsr7Stream(StreamInterface $stream)
Create a FileStream from a Psr7 compliant stream.
Definition: Streams.php:82
ofZipResource(\ZipArchive $zip, int $index)
Definition: Streams.php:88
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:65
$index
Definition: metadata.php:145
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ChatMainBarProvider \MainMenu\Provider.