Skip to content

Commit c97bc12

Browse files
committed
Merge branch 'release/1.3.0'; fix #1
2 parents 5708264 + 5654981 commit c97bc12

File tree

10 files changed

+326
-55
lines changed

10 files changed

+326
-55
lines changed

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: php
2+
php:
3+
- '5.4'
4+
- '5.5'
5+
- '5.6'
6+
- '7.1'
7+
- '7.2'
8+
- '7.3'
9+
10+
cache:
11+
directories:
12+
- vendor
13+
- $HOME/.composer/cache
14+
15+
install:
16+
- travis_retry composer self-update && composer --version
17+
- travis_retry composer install --no-interaction
18+
19+
script:
20+
- composer validate --no-check-lock
21+
- vendor/bin/phpunit -c phpunit.xml

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# `php-buffer` -> Read And Write Binary Data
1+
# `nelexa/buffer` -> Read And Write Binary Data
2+
3+
[![Packagist Version](https://img.shields.io/packagist/v/nelexa/buffer.svg)](https://packagist.org/packages/nelexa/buffer)
4+
[![Packagist](https://img.shields.io/packagist/dt/nelexa/buffer.svg?color=%23ff007f)](https://packagist.org/packages/nelexa/buffer)
5+
[![Build Status](https://travis-ci.org/Ne-Lexa/php-byte-buffer.svg?branch=master)](https://travis-ci.org/Ne-Lexa/php-byte-buffer
6+
)
7+
[![License](https://img.shields.io/packagist/l/nelexa/buffer.svg)](https://packagist.org/packages/nelexa/buffer)
28

39
This is classes defines methods for **reading and writing** values of all primitive types. Primitive values are translated to (or from) sequences of bytes according to the buffer's current byte order, which may be retrieved and modified via the order methods. The initial order of a byte buffer is always Buffer::BIG_ENDIAN.
410

@@ -50,7 +56,7 @@ Checking the possibility of recording in the buffer
5056
$boolValue = $buffer->isReadOnly();
5157
```
5258

53-
Modifies this buffer's byte order, either Buffer::BIG_ENDIAN or Buffer::LITTLE_ENDIAN
59+
Modifies this buffer's byte order, either `Buffer::BIG_ENDIAN` or `Buffer::LITTLE_ENDIAN`
5460
```php
5561
$buffer->setOrder(\Nelexa\Buffer::LITTLE_ENDIAN);
5662
```
@@ -94,6 +100,8 @@ $buffer->skipByte(); // skip 1 byte
94100
$buffer->skipShort(); // skip 2 bytes
95101
$buffer->skipInt(); // skip 4 bytes
96102
$buffer->skipLong(); // skip 8 bytes
103+
$buffer->skipFloat(); // skip 4 bytes
104+
$buffer->skipDouble(); // skip 8 bytes
97105
```
98106

99107
Rewinds this buffer. The position is set to zero.
@@ -187,6 +195,8 @@ Method | Type | Values
187195
`$buffer->getInt()` | int (4 bytes) | -2147483648 ... 2147483647
188196
`$buffer->getUnsignedInt()` | unsigned int (uint) | 0 ... 4294967296
189197
`$buffer->getLong()` | long (8 bytes) | -9223372036854775808 ... 9223372036854775807
198+
`$buffer->getFloat()` | float (4 bytes) | single-precision 32-bit IEEE 754 floating point number
199+
`$buffer->getDouble()` | double (5 bytes) | double-precision 64-bit IEEE 754 floating point number
190200
`$buffer->getArrayBytes($length)` | byte[] | `array`
191201
`$buffer->getString($length)` | string (length bytes) | `string`
192202
`$buffer->getUTF()` | string | `string`
@@ -235,6 +245,14 @@ Insert long value (-9223372036854775808 >= long <= 9223372036854775807). Change
235245
```php
236246
$buffer->insertLong($longValue);
237247
```
248+
Insert float value (single-precision 32-bit IEEE 754 floating point number). Change position +4.
249+
```php
250+
$buffer->insertFloat($floatValue);
251+
```
252+
Insert double value (double-precision 64-bit IEEE 754 floating point number). Change position +8.
253+
```php
254+
$buffer->insertDouble($doubleValue);
255+
```
238256
Insert array bytes. Change size and position by +(size array).
239257
```php
240258
$buffer->insertArrayBytes($bytes);
@@ -293,6 +311,14 @@ Put long value (-9223372036854775808 >= long <= 9223372036854775807). Change pos
293311
```php
294312
$buffer->putLong($longValue);
295313
```
314+
Put float value (single-precision 32-bit IEEE 754 floating point number). Change position +4.
315+
```php
316+
$buffer->putFloat($floatValue);
317+
```
318+
Put double value (double-precision 64-bit IEEE 754 floating point number). Change position +8.
319+
```php
320+
$buffer->putDouble($doubleValue);
321+
```
296322
Put array bytes. Change position by +(size array).
297323
```php
298324
$buffer->putArrayBytes($bytes);
@@ -351,6 +377,14 @@ Replace by long value (-9223372036854775808 >= long <= 9223372036854775807). Cha
351377
```php
352378
$buffer->replaceLong($longValue, $length);
353379
```
380+
Replace by float value (single-precision 32-bit IEEE 754 floating point number). Change size by (-$length + 4) and position +4.
381+
```php
382+
$buffer->replaceFloat($floatValue, $length);
383+
```
384+
Replace by double value (double-precision 64-bit IEEE 754 floating point number). Change size by (-$length + 8) and position +8.
385+
```php
386+
$buffer->replaceDouble($doubleValue, $length);
387+
```
354388
Replace by array bytes. Change size by (-$length + size array) and position +(size array).
355389
```php
356390
$buffer->replaceArrayBytes($bytes, $length);

bootstrap.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nelexa/buffer",
3-
"description": "Reading And Writing Binary Data (incl. primitive types, ex. byte, ubyte, short, ushort, int, uint, long). The classes also help with porting the I/O operations of the JAVA code.",
3+
"description": "Reading And Writing Binary Data (incl. primitive types, ex. byte, ubyte, short, ushort, int, uint, long, float, double). The classes also help with porting the I/O operations of the JAVA code.",
44
"type": "library",
55
"keywords": [
66
"binary",
@@ -12,6 +12,8 @@
1212
"int",
1313
"uint",
1414
"long",
15+
"float",
16+
"double",
1517
"io",
1618
"java",
1719
"pack",
@@ -40,4 +42,4 @@
4042
"Nelexa\\Buffer\\": "tests/Nelexa/Buffer"
4143
}
4244
}
43-
}
45+
}

phpunit.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
bootstrap="./vendor/autoload.php">
12+
<testsuites>
13+
<testsuite name="Buffer test suite">
14+
<directory>tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory>src/</directory>
20+
</whitelist>
21+
</filter>
22+
</phpunit>

0 commit comments

Comments
 (0)