mapper.php

Basically a serialization wrapper for netresearch/jsonmapper
git clone git://git.finwo.net/lib/mapper.php
Log | Files | Refs | README

UrlEncodedDriver.php (930B)


      1 <?php
      2 
      3 namespace Finwo\Mapper\Driver;
      4 
      5 class UrlEncodedDriver 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 http_build_query($raw);
     41     }
     42 
     43     /**
     44      * {@inheritdoc}
     45      */
     46     public function decode($testData)
     47     {
     48         return parse_str($testData);
     49     }
     50 }