-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Encoder.php
40 lines (34 loc) · 943 Bytes
/
Encoder.php
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
<?php
declare(strict_types=1);
namespace PetrKnap\Binary;
class Encoder extends Coder implements EncoderInterface
{
public function base64(?bool $urlSafe = null): static
{
return static::create($this, (new Coder\Base64())->encode(
$this->data,
urlSafe: $urlSafe,
));
}
public function checksum(?string $algorithm = null): static
{
return static::create($this, (new Coder\Checksum())->encode(
$this->data,
algorithm: $algorithm,
));
}
public function hex(): static
{
return static::create($this, (new Coder\Hex())->encode(
$this->data,
));
}
public function zlib(?int $encoding = null, ?int $level = null): static
{
return static::create($this, (new Coder\Zlib())->encode(
$this->data,
encoding: $encoding,
level: $level,
));
}
}