Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
35 | |||
36 | 58 | public static function fromStream(Readable $stream): Value |
|
37 | { |
||
38 | 58 | return new self( |
|
39 | ...$stream |
||
40 | 58 | ->read(1) |
|
41 | 58 | ->toEncoding('ASCII') |
|
42 | 58 | ->chunk() |
|
43 | 58 | ->reduce( |
|
44 | 58 | new Seq, |
|
45 | 58 | static function(Seq $bits, Str $bit): Seq { |
|
46 | 58 | return (new Str(decbin(ord((string) $bit)))) |
|
47 | 58 | ->chunk() |
|
48 | 58 | ->reduce( |
|
49 | 58 | $bits, |
|
50 | 58 | static function(Seq $bits, Str $bit): Seq { |
|
51 | 58 | return $bits->add((int) (string) $bit); |
|
52 | 58 | } |
|
53 | ); |
||
54 | 58 | } |
|
55 | ) |
||
56 | 58 | ->map(static function(int $bit): bool { |
|
57 | 58 | return (bool) $bit; |
|
58 | 58 | }) |
|
76 |