Exemple #1
0
 public function convertToPHPValue($value, $type)
 {
     if ($type == 'date') {
         return \Maestro\Manager::Date($value);
     } elseif ($type == 'timestamp') {
         return \Maestro\Manager::Timestamp($value);
     } elseif ($type == 'currency') {
         return \Maestro\Manager::currency($value);
     } elseif ($type == 'cnpj') {
         return \Maestro\Types\MCNPJ::create($value);
     } elseif ($type == 'cpf') {
         return \Maestro\Types\MCPF::create($value);
     } elseif ($type == 'currency') {
         return \Maestro\Manager::currency($value);
     } elseif ($type == 'boolean') {
         return !empty($value);
     } elseif ($type == 'blob') {
         $value = \Maestro\Types\MFile::file(base64_decode($value));
         return $value;
     } else {
         return $value;
     }
 }
Exemple #2
0
 public function convertToPHPValue($value, $type)
 {
     if ($type == 'date') {
         return $value;
     } elseif ($type == 'timestamp') {
         return $value;
     } elseif ($type == 'currency') {
         return \Manager::currency($value);
     } elseif ($type == 'cnpj') {
         return MCNPJ::create($value);
     } elseif ($type == 'cpf') {
         return MCPF::create($value);
     } elseif ($type == 'boolean') {
         return $value;
     } elseif ($type == 'decimal' || $type == 'float') {
         return str_replace(',', '.', $value);
     } elseif ($type == 'blob') {
         $parsedValue = '';
         if (is_resource($value) or is_resource($value->descriptor)) {
             while (!$value->eof()) {
                 $parsedValue .= $value->read(2000);
             }
             $value = MFile::file($parsedValue);
         } else {
             $value = MFile::file($value);
         }
         return $value;
     } elseif ($type == 'clob') {
         return is_a($value, '\\OCI-Lob') ? $value->load() : $value;
     } else {
         return $value;
     }
 }