Skip to content

Commit 088eb26

Browse files
committed
Improve documentation and examples
1 parent 4faf1c4 commit 088eb26

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# clue/reactphp-tar
22

3-
[![CI status](https://github.com/clue/reactphp-tar/workflows/CI/badge.svg)](https://github.com/clue/reactphp-tar/actions)
3+
[![CI status](https://github.com/clue/reactphp-tar/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-tar/actions)
44
[![installs on Packagist](https://img.shields.io/packagist/dt/clue/tar-react?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/tar-react)
55

66
Streaming parser to extract tarballs with [ReactPHP](https://reactphp.org/).
@@ -31,9 +31,9 @@ tar stream into the `Decoder` which emits "entry" events for each individual fil
3131

3232
require __DIR__ . '/vendor/autoload.php';
3333

34-
$stream = new ReadableResourceStream(fopen('archive.tar', 'r'));
34+
$stream = new React\Stream\ReadableResourceStream(fopen('archive.tar', 'r'));
3535

36-
$decoder = new Decoder();
36+
$decoder = new Clue\React\Tar\Decoder();
3737

3838
$decoder->on('entry', function (array $header, React\Stream\ReadableStreamInterface $file) {
3939
echo 'File ' . $header['filename'];
@@ -47,39 +47,39 @@ $decoder->on('entry', function (array $header, React\Stream\ReadableStreamInterf
4747
$stream->pipe($decoder);
4848
```
4949

50-
See also the [examples](examples).
50+
See also the [examples](examples/).
5151

5252
## Install
5353

54-
The recommended way to install this library is [through Composer](https://getcomposer.org).
54+
The recommended way to install this library is [through Composer](https://getcomposer.org/).
5555
[New to Composer?](https://getcomposer.org/doc/00-intro.md)
5656

5757
While in beta, this project does not currently follow [SemVer](https://semver.org/).
5858
This will install the latest supported version:
5959

6060
```bash
61-
$ composer require clue/tar-react:^0.2
61+
composer require clue/tar-react:^0.2
6262
```
6363

6464
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
6565

6666
This project aims to run on any platform and thus does not require any PHP
6767
extensions and supports running on legacy PHP 5.3 through current PHP 8+.
68-
It's *highly recommended to use PHP 7+* for this project.
68+
It's *highly recommended to use the latest supported PHP version* for this project.
6969

7070
## Tests
7171

7272
To run the test suite, you first need to clone this repo and then install all
73-
dependencies [through Composer](https://getcomposer.org):
73+
dependencies [through Composer](https://getcomposer.org/):
7474

7575
```bash
76-
$ composer install
76+
composer install
7777
```
7878

7979
To run the test suite, go to the project root and run:
8080

8181
```bash
82-
$ vendor/bin/phpunit
82+
vendor/bin/phpunit
8383
```
8484

8585
## License

examples/dump.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<?php
22

3-
use Clue\Hexdump\Hexdump;
4-
use Clue\React\Tar\Decoder;
5-
use React\Stream\ReadableResourceStream;
6-
use React\Stream\ReadableStreamInterface;
7-
83
require __DIR__ . '/../vendor/autoload.php';
94

105
$in = isset($argv[1]) ? $argv[1] : (__DIR__ . '/../tests/fixtures/alice-bob.tar');
116
echo 'Reading file "' . $in . '" (pass as argument to example)' . PHP_EOL;
127

13-
$stream = new ReadableResourceStream(fopen($in, 'r'));
8+
$stream = new React\Stream\ReadableResourceStream(fopen($in, 'r'));
149

15-
$decoder = new Decoder();
16-
$decoder->on('entry', function (array $header, ReadableStreamInterface $file) {
10+
$decoder = new Clue\React\Tar\Decoder();
11+
$decoder->on('entry', function (array $header, React\Stream\ReadableStreamInterface $file) {
1712
static $i = 0;
1813
echo 'FILE #' . ++$i . PHP_EOL;
1914

@@ -27,7 +22,7 @@
2722
$file->on('close', function () use (&$contents) {
2823
echo 'Received entry contents (' . strlen($contents) . ' bytes)' . PHP_EOL;
2924

30-
$d = new Hexdump();
25+
$d = new Clue\Hexdump\Hexdump();
3126
echo $d->dump($contents) . PHP_EOL . PHP_EOL;
3227
});
3328
});

src/Decoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ private function readHeader($header)
256256
throw new RuntimeException('Invalid header checksum, expected "' . $record['checksum'] . '", but calculated "' . $checksum . '" (looks like the archive is corrupted)');
257257
}
258258

259-
// padding consits of X NULL bytes after record entry until next BLOCK_SIZE boundary
259+
// padding consists of X NULL bytes after record entry until next BLOCK_SIZE boundary
260260
$record['padding'] = (self::BLOCK_SIZE - ($record['size'] % self::BLOCK_SIZE)) % self::BLOCK_SIZE;
261261

262-
// filename consits of prefix and name
262+
// filename consists of prefix and name
263263
$record['filename'] = $record['prefix'] . $record['name'];
264264

265265
return $record;

tests/FunctionalDecoderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testStreamingSingleEmptyEmitsSingleEntryWithEmptyStream()
7171
Loop::run();
7272
}
7373

74-
public function testCompleteEndSingleEmtpyBehavesSameAsStreaming()
74+
public function testCompleteEndSingleEmptyBehavesSameAsStreaming()
7575
{
7676
$this->decoder->on('entry', $this->expectCallableOnce());
7777
$this->decoder->on('close', $this->expectCallableOnce());

0 commit comments

Comments
 (0)