-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncoder.php
More file actions
48 lines (41 loc) · 1.11 KB
/
Encoder.php
File metadata and controls
48 lines (41 loc) · 1.11 KB
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
<?php
declare(strict_types=1);
namespace PetrKnap\Binary;
final class Encoder extends Coder
{
public function base64(bool|null $urlSafe = null): static
{
return $this->withData((new Coder\Base64())->encode(
$this->data,
urlSafe: $urlSafe,
));
}
public function checksum(string|null $algorithm = null): static
{
return $this->withData((new Coder\Checksum())->encode(
$this->data,
algorithm: $algorithm,
));
}
public function hex(): static
{
return $this->withData((new Coder\Hex())->encode(
$this->data,
));
}
public function xz(int|null $compressionPreset = null): static
{
return $this->withData((new Coder\Xz())->encode(
$this->data,
compressionPreset: $compressionPreset,
));
}
public function zlib(int|null $encoding = null, int|null $level = null): static
{
return $this->withData((new Coder\Zlib())->encode(
$this->data,
encoding: $encoding,
level: $level,
));
}
}