Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 20 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
25 | 58 | public static function fromStream(Readable $stream): Value |
|
26 | { |
||
27 | 58 | return new self( |
|
28 | ...$stream |
||
29 | 58 | ->read(1) |
|
30 | 58 | ->toEncoding('ASCII') |
|
31 | 58 | ->chunk() |
|
32 | 58 | ->reduce( |
|
33 | 58 | new Seq, |
|
34 | 58 | static function(Seq $bits, Str $bit): Seq { |
|
35 | 58 | return (new Str(decbin(ord((string) $bit)))) |
|
36 | 58 | ->chunk() |
|
37 | 58 | ->reduce( |
|
38 | 58 | $bits, |
|
39 | 58 | static function(Seq $bits, Str $bit): Seq { |
|
40 | 58 | return $bits->add((int) (string) $bit); |
|
41 | 58 | } |
|
42 | ); |
||
43 | 58 | } |
|
44 | ) |
||
45 | 58 | ->map(static function(int $bit): bool { |
|
46 | 58 | return (bool) $bit; |
|
47 | 58 | }) |
|
48 | 58 | ->reverse() |
|
49 | ); |
||
76 |