Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Bundle/JoseFramework/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public function getConfigTreeBuilder()

return $treeBuilder;
}

private function getRootNode(TreeBuilder $treeBuilder, $name)
{
// BC layer for symfony/config 4.1 and older
if (! \method_exists($treeBuilder, 'getRootNode')) {
return $treeBuilder->root($name);
}

return $treeBuilder->getRootNode();
}
private function getRootNode(TreeBuilder $treeBuilder, $name)
{
// BC layer for symfony/config 4.1 and older
if (!\method_exists($treeBuilder, 'getRootNode')) {
return $treeBuilder->root($name);
}

return $treeBuilder->getRootNode();
}
}
10 changes: 5 additions & 5 deletions src/Bundle/JoseFramework/Serializer/JWEEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public function encode($data, $format, array $context = [])
return $this->serializerManager->serialize(mb_strtolower($format), $data, $this->getRecipientIndex($context));
} catch (\Exception $ex) {
$message = sprintf('Cannot encode JWE to %s format.', $format);

if (\class_exists('Symfony\Component\Serializer\Exception\NotEncodableValueException')) {
throw new NotEncodableValueException($message, 0, $ex);
}

throw new UnexpectedValueException($message, 0, $ex);
}
}
Expand All @@ -67,13 +67,13 @@ public function decode($data, $format, array $context = [])
{
try {
return $this->serializerManager->unserialize($data);
} catch (\Exception $ex) {
} catch (\Exception $ex) {
$message = sprintf('Cannot decode JWE from %s format.', $format);

if (\class_exists('Symfony\Component\Serializer\Exception\NotEncodableValueException')) {
throw new NotEncodableValueException($message, 0, $ex);
}

throw new UnexpectedValueException($message, 0, $ex);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Component/Core/Converter/JsonConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Jose\Component\Core\Converter;

/**
* @deprecated This interface is deprecated in v1.3 and will be removed in v2.0
*/
interface JsonConverter
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Component/Core/Converter/StandardConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Jose\Component\Core\Converter;

/**
* @deprecated This class is deprecated in v1.3 and will be removed in v2.0
*/
final class StandardConverter implements JsonConverter
{
/**
Expand Down
27 changes: 27 additions & 0 deletions src/Component/Core/Util/JsonConverter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2018 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

namespace Jose\Component\Core\Util;

final class JsonConverter
{
public static function encode($payload): string
{
return \json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

public static function decode(string $payload)
{
return \json_decode($payload, true, 512, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
}