<?php
namespace Websocket\Request\Validator;
/**
* Class JsonValidator
*
* @package Websocket\Request\Validator
*/
class JsonValidator
{
/**
* Checks whether the data is json or not
*
* @param mixed $data The data to check if json (usually string, but won't error if not)
*
* @return bool
*/
public function validate($data)
{
$data = @json_decode($data);
if (is_null($data) || json_last_error() !== JSON_ERROR_NONE)
{
return false;
}
return true;
}
}