for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Yoanm\ComposerConfigManager\Application\Serializer\Encoder;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
class ComposerEncoder
{
/**
* @param mixed $data
*
* @return string
*/
public function encode($data)
$encodedJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new UnexpectedValueException(json_last_error_msg());
} else {
$encodedJson .= "\n";
}
return $encodedJson;
* @param string $data
* @return mixed
public function decode($data)
$decoded = json_decode($data, true);
return $decoded;