Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
CRAP
36.84% covered (warning)
36.84%
7 / 19
MongoPipelineJsonDecodeException
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
19.34
36.84% covered (warning)
36.84%
7 / 19
 __construct
0.00% covered (danger)
0.00%
0 / 1
19.34
36.84% covered (warning)
36.84%
7 / 19
1<?php
2
3namespace Qmp\Laravel\MongoLow\Exceptions;
4
5use Exception;
6
7/**
8 * Json decode error
9 */
10class MongoPipelineJsonDecodeException extends Exception
11{
12
13    public function __construct($message, $error, $json)
14    {
15        switch ($error) {
16            case JSON_ERROR_DEPTH:
17                $message .= ' - Maximum stack depth exceeded';
18                break;
19            case JSON_ERROR_STATE_MISMATCH:
20                $message .= ' - Underflow or the modes mismatch';
21                break;
22            case JSON_ERROR_CTRL_CHAR:
23                $message .= ' - Unexpected control character found';
24                break;
25            case JSON_ERROR_SYNTAX:
26                $message .= ' - Syntax error, malformed JSON';
27                break;
28            case JSON_ERROR_UTF8:
29                $message .= ' - Malformed UTF-8 characters, possibly incorrectly encoded';
30                break;
31            default:
32                $message .= ' - Unknown error';
33                break;
34        }
35
36        parent::__construct($message . PHP_EOL . $json);
37    }
38}