Method json() to parse JSON strings

- Parse a JSON string into array
- Test
This commit is contained in:
Daniel Ang
2021-06-18 12:43:17 +02:00
parent 5116b4341e
commit c1b27579ca
2 changed files with 25 additions and 0 deletions

View File

@ -60,6 +60,17 @@ final class Expectation
return new self($value);
}
/**
* Parses Json String to Array.
*/
public function json(): Expectation
{
Assert::assertIsString($this->value);
Assert::assertJson($this->value);
return new self(json_decode($this->value, true));
}
/**
* Dump the expectation value and end the script.
*