From 2b90e649ef3677f007c40257e6105603548d8629 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Date: Mon, 15 Jun 2015 13:07:02 +0430 Subject: [PATCH] Update JsonWrapper.php --- src/Parsidev/Json/JsonWrapper.php | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Parsidev/Json/JsonWrapper.php b/src/Parsidev/Json/JsonWrapper.php index 0977e77..9e6b5c0 100644 --- a/src/Parsidev/Json/JsonWrapper.php +++ b/src/Parsidev/Json/JsonWrapper.php @@ -1,8 +1,5 @@ encoder = new JsonEncoder; } - public static function __callStatic($method, $parameters) + public function encoder($data, $schema = null) + { + return $this->encoder->encode($data, $schema); + } + + public function encoderFile($data, $file, $schema = null) + { + $this->encoder->encodeFile($data, $file, $schema); + } + + + public function decoder($json, $schema = null) { - $self = new static; - return $self->__call($method, $parameters); + return $this->decoder->decode($json, $schema); } - public function __call($method, $parameters) + public function decoderFile($file, $schema = null) { - $encoder = new ReflectionClass(JsonEncoder::class); - if ($encoder->hasMethod($method)) { - return call_user_func_array(array($this->encoder, $method), $parameters); - } - $decoder = new ReflectionClass(JsonDecoder::class); - if ($decoder->hasMethod($method)) { - return call_user_func_array(array($this->decoder, $method), $parameters); - } - throw new BadMethodCallException; + return $this->decoder->decodeFile($file, $schema); } -} \ No newline at end of file +}