Skip to content

Commit

Permalink
Merge pull request #121 from sukei/json
Browse files Browse the repository at this point in the history
Makes the json converter compatible with every kinds of types.
  • Loading branch information
chanmix51 committed Dec 18, 2013
2 parents 65ddc39 + 8b3c4d8 commit 5d0f223
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions Pomm/Converter/PgJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pomm\Converter;

use Pomm\Converter\ConverterInterface;
use Pomm\Exception\Exception as PommException;

/**
* Pomm\Converter\PgJSON -- JSON converter
Expand Down Expand Up @@ -37,21 +36,6 @@ public function __construct($output_type = true)
*/
public function toPg($data, $type = null)
{
if ($this->output_type === static::OUTPUT_ARRAYS)
{
if (!is_array($data))
{
throw new PommException(sprintf("Json converter 'toPg()' with OUTPUT_ARRAYS expects data to be array. '%s' given.", gettype($data)));
}
}
else
{
if (!(is_object($data) or $data instanceOf \StdClass))
{
throw new PommException(sprintf("Json converter 'toPg()' with OUTPUT_OBJECTS expecte data to be instance of StdClass, '%s' given", get_class($data)));
}
}

$data = json_encode($data);
$type = is_null($type) ? '' : sprintf("%s ", $type);
$data = sprintf("%s'%s'", $type, $data);
Expand Down

0 comments on commit 5d0f223

Please sign in to comment.