Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
5 / 5
JSON
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 parse
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
<?php
namespace PHPixie\HTTPProcessors\Parsers\Parser;
class JSON implements \PHPixie\HTTPProcessors\Parsers\Parser
{
    public function parse($string)
    {
        $parsed = json_decode($string, true);
        
        $errorCode = json_last_error();
        if($errorCode !== JSON_ERROR_NONE) {
            throw new \PHPixie\HTTPProcessors\Exception("Error parsing JSON data");
        }
        
        return $parsed;
    }
}