Skip to content

Commit 12034e4

Browse files
committed
Update README
1 parent cc76ff5 commit 12034e4

2 files changed

Lines changed: 58 additions & 35 deletions

File tree

.mddoc.xml.dist

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,22 @@
11
<mddoc>
2-
32
<docpage target="README.md">
4-
5-
<section title="Stream Functions">
3+
<section title="Quorum Stream Functions">
64
<badge-poser type="version"/>
75
<badge-poser type="license"/>
86
<badge-github-action name="QuorumCollection/StreamFunctions" workflow="CI"/>
9-
<text>Useful functions for manipulating PHP streams (resources)</text>
7+
<text>Useful functions for manipulating PHP streams (resources).</text>
8+
<text>The general structure of these are inspired by a [talk given by Rob Pike](https://www.youtube.com/watch?v=HxaD_trXwRE).</text>
9+
1010
<section title="Requirements">
1111
<composer-requires/>
1212
</section>
13+
1314
<section title="Installing">
1415
<composer-install/>
1516
</section>
16-
<section title="Stream Functions">
17-
<section title="`Quorum\Streams\faccept( $stream, string ...$accept ) : ?string`">
18-
<text><![CDATA[
19-
faccept peeks the given stream for the given string returning it if it is found * or null if it is not.
2017

21-
If the string is found, the cursor remains advanced to the end of the string.
22-
23-
If the string is not found, the cursor is reset to its original position.
24-
]]></text>
25-
</section>
26-
27-
<section title="`Quorum\Streams\fpeek( $stream, int $length = 1 ) : string`">
28-
<text><![CDATA[
29-
fpeek peeks the given stream for the given length returning as found.
30-
31-
The cursor is reset to its original position.
32-
]]></text>
33-
</section>
34-
35-
<section title="`Quorum\Streams\funtil( $stream, string $until ) : string`">
36-
<text><![CDATA[
37-
funtil reads the given stream until the given string is found or eof is reached
38-
]]></text>
39-
</section>
18+
<section title="Stream Functions">
19+
<file name="src/streams.php" />
4020
</section>
4121
</section>
4222
</docpage>

README.md

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Stream Functions
1+
# Quorum Stream Functions
22

33
[![Latest Stable Version](https://poser.pugx.org/quorum/stream-functions/version)](https://packagist.org/packages/quorum/stream-functions)
44
[![License](https://poser.pugx.org/quorum/stream-functions/license)](https://packagist.org/packages/quorum/stream-functions)
55
[![CI](https://github.com/QuorumCollection/StreamFunctions/workflows/CI/badge.svg?)](https://github.com/QuorumCollection/StreamFunctions/actions?query=workflow%3ACI)
66

77

8-
Useful functions for manipulating PHP streams (resources)
8+
Useful functions for manipulating PHP streams (resources).
9+
10+
The general structure of these are inspired by a [talk given by Rob Pike](https://www.youtube.com/watch?v=HxaD_trXwRE).
911

1012
## Requirements
1113

@@ -21,20 +23,61 @@ composer require 'quorum/stream-functions'
2123

2224
## Stream Functions
2325

24-
### `Quorum\Streams\faccept( $stream, string ...$accept ) : ?string`
26+
### Function: \Quorum\Streams\faccept
27+
28+
```php
29+
function faccept($stream, string ...$accept) : ?string
30+
```
31+
32+
##### Parameters:
2533

26-
faccept peeks the given stream for the given string returning it if it is found * or null if it is not.
34+
- ***resource*** `$stream` - The stream to peek, must be a seekable resource
35+
- ***string*** `$accept` - One or more strings to accept
2736

28-
If the string is found, the cursor remains advanced to the end of the string.
37+
##### Returns:
2938

39+
- ***string*** | ***null*** - The accepted string or null if none were found
40+
41+
faccept peeks the given stream for the given string returning it if it is
42+
found * or null if it is not.
43+
44+
If the string is found, the cursor remains advanced to the end of the string.
3045
If the string is not found, the cursor is reset to its original position.
3146

32-
### `Quorum\Streams\fpeek( $stream, int $length = 1 ) : string`
47+
### Function: \Quorum\Streams\fpeek
48+
49+
```php
50+
function fpeek($stream [, int $length = 1]) : string
51+
```
52+
53+
##### Parameters:
3354

34-
fpeek peeks the given stream for the given length returning as found.
55+
- ***resource*** `$stream` - The stream to peek, must be a seekable resource
56+
- ***int*** `$length` - Up to length number of bytes read.
3557

58+
##### Returns:
59+
60+
- ***string*** - The peeked string of up to length bytes
61+
62+
fpeek peeks the given stream for the given length returning as found.
63+
3664
The cursor is reset to its original position.
3765

38-
### `Quorum\Streams\funtil( $stream, string $until ) : string`
66+
### Function: \Quorum\Streams\funtil
67+
68+
```php
69+
function funtil($stream, string $until [, int $length = 0 [, ?string $buf = null]]) : bool
70+
```
71+
72+
##### Parameters:
73+
74+
- ***resource*** `$stream` - The stream to read, must be a seekable resource
75+
- ***string*** `$until` - The string to read until
76+
- ***int*** `$length` - The maximum number of bytes to read, defaults to 0 (no limit)
77+
- ***string*** | ***null*** `$buf` - The buffered contents by reference
78+
79+
##### Returns:
80+
81+
- ***bool***
3982

4083
funtil reads the given stream until the given string is found or eof is reached

0 commit comments

Comments
 (0)