for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Pomm's Foundation package.
*
* (c) 2014 - 2015 Grégoire HUBERT <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PommProject\Foundation\Converter;
use PommProject\Foundation\Session\Session;
/**
* PgNumber
* Converter for numbers.
* @package Foundation
* @copyright 2014 - 2015 Grégoire HUBERT
* @author Grégoire HUBERT
* @license X11 {@link http://opensource.org/licenses/mit-license.php}
* @see ConverterInterface
class PgNumber implements ConverterInterface
{
* fromPg
public function fromPg($data, $type, Session $session)
$data = trim($data);
if ($data === '') {
return null;
}
return $data + 0;
* toPg
public function toPg($data, $type, Session $session)
return
$data !== null
? sprintf("%s '%s'", $type, $data + 0)
: sprintf("NULL::%s", $type)
;
* toPgStandardFormat
public function toPgStandardFormat($data, $type, Session $session)
? sprintf("%s", $data + 0)
: null