Skip to content

Commit

Permalink
rework params for readability
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Oct 8, 2022
1 parent 7afe130 commit fe7567d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Core/Serialization/JsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ class JsonSerializer extends BaseSerializer
*
* @readonly
*/
private int $jsonEncodeOptions = 0
private int $jsonEncodeFlags = 0
| \JSON_THROW_ON_ERROR // prevent unexpected data
| \JSON_PRESERVE_ZERO_FRACTION // float/double not converted to int
;

/**
* @param int $jsonEncodeOptions Bitmask consisting of JSON_*
* @param int $jsonEncodeFlags Bitmask consisting of JSON_*
*/
public function __construct(
JSON\NormalizerFactory $normalizerFactory,
int $jsonEncodeOptions = \JSON_UNESCAPED_SLASHES // urls become shorter
int $jsonEncodeFlags = \JSON_UNESCAPED_SLASHES // urls become shorter
) {
$this->normalizerFactory = $normalizerFactory;
$this->jsonEncodeOptions |= $jsonEncodeOptions;
$this->jsonEncodeFlags |= $jsonEncodeFlags;
}

/**
Expand Down Expand Up @@ -100,12 +100,12 @@ protected function realSerialize($normalizedBom, bool $pretty): string
$normalizedBom['$schema'] = $schema;
}

$jsonEncodeOptions = $this->jsonEncodeOptions;
$jsonEncodeFlags = $this->jsonEncodeFlags;
if ($pretty) {
$jsonEncodeOptions |= \JSON_PRETTY_PRINT;
$jsonEncodeFlags |= \JSON_PRETTY_PRINT;
}

$json = json_encode($normalizedBom, $jsonEncodeOptions);
$json = json_encode($normalizedBom, $jsonEncodeFlags);
\assert(false !== $json); // as option JSON_THROW_ON_ERROR is expected to be set
\assert('' !== $json);

Expand Down

0 comments on commit fe7567d

Please sign in to comment.