Skip to content

Commit

Permalink
Use Null Coalescing Assignment Operators
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Nov 25, 2023
1 parent dd0dc4b commit d973530
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Json
*/
public static function decode(string $json, ?bool $forceArray = null): mixed
{
$forceArray = $forceArray ?? false;
$forceArray ??= false;
$flags = $forceArray ? JSON_OBJECT_AS_ARRAY : 0;

try {
Expand Down Expand Up @@ -66,7 +66,7 @@ public static function decodeFile(string $path, bool $forceArray = null): mixed
*/
public static function encode(mixed $data, ?int $options = null): string
{
$options = $options ?? 0;
$options ??= 0;

try {
return json_encode($data, $options | self::ENCODE_DEFAULT | JSON_THROW_ON_ERROR);
Expand All @@ -80,7 +80,7 @@ public static function encode(mixed $data, ?int $options = null): string
*/
public static function pretty(mixed $value, ?int $options = null): string
{
$options = $options ?? 0;
$options ??= 0;

return self::encode($value, $options | self::ENCODE_PRETTY);
}
Expand Down

0 comments on commit d973530

Please sign in to comment.