-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlainStringCodec.php
More file actions
28 lines (22 loc) · 705 Bytes
/
Copy pathPlainStringCodec.php
File metadata and controls
28 lines (22 loc) · 705 Bytes
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
<?php declare(strict_types=1);
namespace uuf6429\PhpCsFixerBlockstring\InterpolationCodec;
use RuntimeException;
use uuf6429\PhpCsFixerBlockstring\BlockString\StringSegment;
final class PlainStringCodec implements CodecInterface
{
public function encode(array $segments): CodecResult
{
if (count($segments) !== 1 || !($segments[0] instanceof StringSegment)) {
throw new RuntimeException('PlainStringCodec does not support string interpolation by default');
}
return new CodecResult([], $segments[0]->value);
}
public function decode(CodecResult $result): array
{
return [new StringSegment($result->content)];
}
public function getCacheFingerprint()
{
return [self::class];
}
}