Skip to content

Commit

Permalink
🩹 Change match statement to conditional for PHP 7.x (Fixes #90) (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Nov 5, 2024
1 parent 1f05c68 commit b9faed6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Advanced Custom Fields: Phone Number
* Plugin URI: https://github.com/log1x/acf-phone-number
* Description: A real ACF phone number field.
* Version: 1.3.0
* Version: 1.3.1
* Author: Brandon Nifong
* Author URI: https://github.com/log1x
*/
Expand Down
10 changes: 6 additions & 4 deletions src/PhoneNumberField.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ public function input_admin_enqueue_scripts()
public function format_value($value, $post_id, $field)
{
$number = new PhoneNumber($value);
$format = $field['return_format'] ?? $this->defaults['return_format'];

return match ($field['return_format'] ?? $this->defaults['return_format']) {
'array' => $number->toArray(),
default => $number,
};
if ($format === 'array') {
return $number->toArray();
}

return $number;
}

/**
Expand Down

0 comments on commit b9faed6

Please sign in to comment.