for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* Copyright (c) Nate Brunette.
* Distributed under the MIT License (http://opensource.org/licenses/MIT)
*/
declare(strict_types=1);
namespace Tebru\Gson\TypeAdapter;
use Tebru\Gson\Context\ReaderContext;
use Tebru\Gson\TypeAdapter;
use Tebru\Gson\Context\WriterContext;
/**
* Class IntegerTypeAdapter
*
* @author Nate Brunette <[email protected]>
class IntegerTypeAdapter extends TypeAdapter
{
* Read the next value, convert it to its type and return it
* @param int|null $value
* @param ReaderContext $context
* @return int|null
public function read($value, ReaderContext $context): ?int
return $value === null ? null : (int)$value;
}
* Write the value to the writer for the type
* @param WriterContext $context
public function write($value, WriterContext $context): ?int