-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathStreamInterface.php
76 lines (69 loc) · 1.79 KB
/
StreamInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types=1);
namespace ParagonIE\Halite\Contract;
use ParagonIE\Halite\Alerts\{
CannotPerformOperation,
FileAccessDenied
};
/**
* Interface StreamInterface
*
* A stream used by Halite, internally.
*
* This library makes heavy use of return-type declarations,
* which are a PHP 7 only feature. Read more about them here:
*
* @ref https://www.php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration
*
* @package ParagonIE\Halite\Contract
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://www.mozilla.org/en-US/MPL/2.0/.
*/
interface StreamInterface
{
/**
* Where are we in the buffer?
*
* @return int
*/
public function getPos(): int;
/**
* How big is this buffer?
*
* @return int
*/
public function getSize(): int;
/**
* Get information about the stream.
*
* @return array
*/
public function getStreamMetadata(): array;
/**
* Read from a stream; prevent partial reads
*
* @param int $num
* @param bool $skipTests
* @return string
* @throws FileAccessDenied
* @throws CannotPerformOperation
*/
public function readBytes(int $num, bool $skipTests = false): string;
/**
* How many bytes are left between here and the end of the stream?
*
* @return int
*/
public function remainingBytes(): int;
/**
* Write to a stream; prevent partial writes
*
* @param string $buf
* @param ?int $num (number of bytes)
* @return int
* @throws FileAccessDenied
*/
public function writeBytes(string $buf, ?int $num = null): int;
}