Exemple #1
0
 public function __construct()
 {
     $serializer = function (&$value, &$key) {
         $value = $value === true ? "true" : "false";
         return true;
     };
     $deserializer = function (&$value, &$key) {
         $value = $value == "true";
         return true;
     };
     parent::__construct($serializer, $deserializer);
 }
 public function __construct()
 {
     $serializer = function (&$row, &$key) {
         if ($row instanceof OA) {
             $row = $row->toArray();
         }
         return true;
     };
     $deserializer = function (&$row, &$key) {
         if (!$row instanceof OA) {
             $row = new OA($row);
         }
         return true;
     };
     parent::__construct($serializer, $deserializer);
 }
Exemple #3
0
 public function __construct()
 {
     $serializer = function (&$value, &$key) {
         $value = "" . $value;
         return true;
     };
     $deserializer = function (&$value, &$key) {
         if (strpos($value, ".")) {
             $value = (double) $value;
         } else {
             $value = (int) $value;
         }
         return true;
     };
     parent::__construct($serializer, $deserializer);
 }
Exemple #4
0
 public function __construct($format, \DateTimeZone $timezone = null)
 {
     $this->format = $format;
     $this->timezone = $timezone;
     $serializer = function (&$value, &$key) {
         if ($value instanceof \DateTime) {
             $value = $value->format($this->format);
         }
         return true;
     };
     $deserializer = function (&$value, &$key) {
         if (!$value instanceof \DateTime) {
             $value = \DateTime::createFromFormat($this->format, $value);
             if ($this->timezone instanceof \DateTimeZone) {
                 $value->setTimezone($this->timezone);
             }
         }
         return true;
     };
     parent::__construct($serializer, $deserializer);
 }