only a few comments to accept the PR : 
* please remove the blank lines,
* correct indentation for json_errors (4 spaces)
* remove "} else {" which are not needed as you already return in the ifs
* start with "if (null !== $deocded)" so you save 1 indent level.

Thanks!