fixed CS
This commit is contained in:
parent
00108fbd62
commit
563f77a3f0
@ -64,12 +64,14 @@ class ContentInnerNameIterator extends \ArrayIterator
|
||||
public function isFile()
|
||||
{
|
||||
$name = parent::current();
|
||||
|
||||
return preg_match('/file/', $name);
|
||||
}
|
||||
|
||||
public function isDir()
|
||||
{
|
||||
$name = parent::current();
|
||||
|
||||
return preg_match('/directory/', $name);
|
||||
}
|
||||
|
||||
@ -81,6 +83,7 @@ class ContentInnerNameIterator extends \ArrayIterator
|
||||
public function isReadable()
|
||||
{
|
||||
$name = parent::current();
|
||||
|
||||
return preg_match('/r\+/', $name);
|
||||
}
|
||||
|
||||
|
@ -13,60 +13,53 @@ namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
/**
|
||||
* Decodes JSON data
|
||||
*
|
||||
* @author Sander Coolen <sander@jibber.nl>
|
||||
*
|
||||
* @author Sander Coolen <sander@jibber.nl>
|
||||
*/
|
||||
class JsonDecode implements DecoderInterface
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $associative = false;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $recursionDepth = 512;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $associative;
|
||||
private $recursionDepth;
|
||||
private $lastError = JSON_ERROR_NONE;
|
||||
|
||||
public function __construct($assoc = false, $depth = 512)
|
||||
|
||||
public function __construct($associative = false, $depth = 512)
|
||||
{
|
||||
$this->associative = $assoc;
|
||||
$this->associative = $associative;
|
||||
$this->recursionDepth = $depth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the last decoding error (if any)
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
|
||||
*/
|
||||
public function getLastError()
|
||||
{
|
||||
return $this->lastError;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decodes a JSON string into PHP data
|
||||
*
|
||||
*
|
||||
* @param string $data JSON
|
||||
* @return mixed
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function decode($data, $format)
|
||||
{
|
||||
$decodedData = json_decode($data, $this->associative, $this->recursionDepth);
|
||||
$this->lastError = json_last_error();
|
||||
|
||||
|
||||
return $decodedData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsDecoding($format)
|
||||
{
|
||||
return JsonEncoder::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,45 +18,41 @@ namespace Symfony\Component\Serializer\Encoder;
|
||||
*/
|
||||
class JsonEncode implements EncoderInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $options = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $options ;
|
||||
private $lastError = JSON_ERROR_NONE;
|
||||
|
||||
|
||||
public function __construct($bitmask = 0)
|
||||
{
|
||||
$this->options = $bitmask;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the last encoding error (if any)
|
||||
*
|
||||
* @return int
|
||||
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
|
||||
*/
|
||||
public function getLastError()
|
||||
{
|
||||
return $this->lastError;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encodes PHP data to a JSON string
|
||||
*
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encode($data, $format)
|
||||
{
|
||||
$encodedJson = json_encode($data, $this->options);
|
||||
$this->lastError = json_last_error();
|
||||
|
||||
|
||||
return $encodedJson;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -64,4 +60,4 @@ class JsonEncode implements EncoderInterface
|
||||
{
|
||||
return JsonEncoder::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,12 @@ namespace Symfony\Component\Serializer\Encoder;
|
||||
class JsonEncoder implements EncoderInterface, DecoderInterface
|
||||
{
|
||||
const FORMAT = 'json';
|
||||
|
||||
|
||||
/**
|
||||
* @var JsonEncode
|
||||
*/
|
||||
protected $encodingImpl;
|
||||
|
||||
/**
|
||||
* @var JsonDecode
|
||||
*/
|
||||
@ -31,36 +32,30 @@ class JsonEncoder implements EncoderInterface, DecoderInterface
|
||||
|
||||
public function __construct(JsonEncode $encodingImpl = null, JsonDecode $decodingImpl = null)
|
||||
{
|
||||
if (null === $encodingImpl) {
|
||||
$encodingImpl = new JsonEncode;
|
||||
}
|
||||
$this->encodingImpl = $encodingImpl;
|
||||
if (null === $decodingImpl) {
|
||||
$decodingImpl = new JsonDecode(true);
|
||||
}
|
||||
$this->decodingImpl = $decodingImpl;
|
||||
$this->encodingImpl = null === $encodingImpl ? new JsonEncode() : $encodingImpl;
|
||||
$this->decodingImpl = null === $decodingImpl ? new JsonDecode(true) : $decodingImpl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the last encoding error (if any)
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLastEncodingError()
|
||||
{
|
||||
return $this->encodingImpl->getLastError();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the last decoding error (if any)
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLastDecodingError()
|
||||
{
|
||||
return $this->decodingImpl->getLastError();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -92,4 +87,4 @@ class JsonEncoder implements EncoderInterface, DecoderInterface
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user