JsonDriver.php (921B)
1 <?php 2 3 namespace Finwo\Mapper\Driver; 4 5 class JsonDriver extends AbstractDriver implements DriverInterface 6 { 7 /** 8 * {@inheritdoc} 9 */ 10 public function encodeSupport($testData) 11 { 12 // TODO: implement proper testing 13 try { 14 $this->encode($testData); 15 return true; 16 } catch (\Exception $e) { 17 return false; 18 } 19 } 20 21 /** 22 * {@inheritdoc} 23 */ 24 public function decodeSupport($testData) 25 { 26 // TODO: implement proper testing 27 try { 28 $this->decode($testData); 29 return true; 30 } catch (\Exception $e) { 31 return false; 32 } 33 } 34 35 /** 36 * {@inheritdoc} 37 */ 38 public function encode($raw) 39 { 40 return json_encode($raw); 41 } 42 43 /** 44 * {@inheritdoc} 45 */ 46 public function decode($testData) 47 { 48 return json_decode($testData); 49 } 50 }