Skip to content

Commit 2157a3d

Browse files
renamed to follow bolt spec
1 parent 15284ab commit 2157a3d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/PackStream/v1/Packer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Duration,
1717
Point2D,
1818
Point3D,
19-
ByteArray
19+
Bytes
2020
};
2121

2222
/**
@@ -118,7 +118,7 @@ private function p($param): string
118118
case 'object':
119119
if ($param instanceof IStructure) {
120120
return $this->packStructure($param);
121-
} elseif ($param instanceof ByteArray) {
121+
} elseif ($param instanceof Bytes) {
122122
return $this->packByteArray($param);
123123
} else {
124124
return $this->packMap((array)$param);
@@ -267,11 +267,11 @@ private function packStructure(IStructure $structure): string
267267
}
268268

269269
/**
270-
* @param ByteArray $bytes
270+
* @param Bytes $bytes
271271
* @return string
272272
* @throws PackException
273273
*/
274-
private function packByteArray(ByteArray $bytes): string
274+
private function packByteArray(Bytes $bytes): string
275275
{
276276
$size = count($bytes);
277277
if ($size < self::MEDIUM) {

src/PackStream/v1/Unpacker.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Duration,
1818
Point2D,
1919
Point3D,
20-
ByteArray
20+
Bytes
2121
};
2222
use Bolt\PackStream\IUnpacker;
2323
use Bolt\error\UnpackException;
@@ -303,9 +303,9 @@ private function unpackList(int $marker): ?array
303303

304304
/**
305305
* @param int $marker
306-
* @return ByteArray|null
306+
* @return Bytes|null
307307
*/
308-
private function unpackByteArray(int $marker): ?ByteArray
308+
private function unpackByteArray(int $marker): ?Bytes
309309
{
310310
if ($marker == 0xCC) {
311311
$size = (int)unpack('C', $this->next(1))[1];
@@ -317,7 +317,7 @@ private function unpackByteArray(int $marker): ?ByteArray
317317
return null;
318318
}
319319

320-
return new ByteArray(mb_str_split($this->next($size), 1, '8bit'));
320+
return new Bytes(mb_str_split($this->next($size), 1, '8bit'));
321321
}
322322

323323
}

src/structures/ByteArray.php renamed to src/structures/Bytes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @link https://7687.org/packstream/packstream-specification-1.html#bytes
1313
* @package Bolt\structures
1414
*/
15-
class ByteArray implements ArrayAccess, Countable
15+
class Bytes implements ArrayAccess, Countable
1616
{
1717
private array $bytes = [];
1818

tests/PackStream/v1/StructuresTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Duration,
1919
Point2D,
2020
Point3D,
21-
ByteArray
21+
Bytes
2222
};
2323
use PHPUnit\Framework\TestCase;
2424
use Exception;
@@ -456,7 +456,7 @@ private function randomTimestamp(string $timezone = '+0000'): int
456456
* @depends testInit
457457
* @dataProvider providerByteArray
458458
*/
459-
public function testByteArray(ByteArray $arr, AProtocol $protocol)
459+
public function testByteArray(Bytes $arr, AProtocol $protocol)
460460
{
461461
try {
462462
$protocol->run('RETURN $arr', ['arr' => $arr]);
@@ -470,7 +470,7 @@ public function testByteArray(ByteArray $arr, AProtocol $protocol)
470470
public function providerByteArray(): \Generator
471471
{
472472
foreach ([0, 200, 60000, 70000] as $size) {
473-
$arr = new ByteArray();
473+
$arr = new Bytes();
474474
while (count($arr) < $size) {
475475
$arr[] = pack('H', mt_rand(0, 255));
476476
}

0 commit comments

Comments
 (0)