Skip to content

Commit

Permalink
Merge pull request #19 from enricodelazzari/main
Browse files Browse the repository at this point in the history
FIX issue #18
  • Loading branch information
riccardodallavia authored Jan 25, 2024
2 parents 37bae66 + 2a5eba6 commit 7ca89e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utils/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function serialize($value): string

public static function unserialize(string $payload)
{
$payload = explode(':', $payload);
$payload = explode(':', $payload, 2);

if (count($payload) !== 2) {
throw new UnserializationException();
Expand Down
9 changes: 9 additions & 0 deletions tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function it_should_serialize_all_supported_values()
Serializer::serialize('test')
);

$this->assertEquals(
'string:test:test',
Serializer::serialize('test:test')
);

$this->assertEquals(
'integer:1',
Serializer::serialize(1)
Expand Down Expand Up @@ -55,6 +60,10 @@ public function it_should_unserialize_all_supported_values()
$this->assertIsString($string);
$this->assertEquals('test', $string);

$string = Serializer::unserialize('string:test:test');
$this->assertIsString($string);
$this->assertEquals('test:test', $string);

$integer = Serializer::unserialize('integer:1');
$this->assertIsInt($integer);
$this->assertEquals(1, $integer);
Expand Down

0 comments on commit 7ca89e9

Please sign in to comment.