| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Give\Donations\Migrations; |
| 6 |
|
| 7 |
use Give\Framework\Migrations\Contracts\Migration; |
| 8 |
use NumberFormatter; |
| 9 |
|
| 10 |
/** |
| 11 |
* Sets the initial automatic formatting option based on whether the intl extension is installed. |
| 12 |
* |
| 13 |
* @since 2.24.2 |
| 14 |
*/ |
| 15 |
class SetAutomaticFormattingOption extends Migration |
| 16 |
{ |
| 17 |
public static function id(): string |
| 18 |
{ |
| 19 |
return 'set_automatic_formatting_option'; |
| 20 |
} |
| 21 |
|
| 22 |
public static function timestamp(): int |
| 23 |
{ |
| 24 |
return strtotime('2022-01-20'); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @inheritDoc |
| 29 |
*/ |
| 30 |
public function run() |
| 31 |
{ |
| 32 |
$hasIntlExtension = class_exists(NumberFormatter::class); |
| 33 |
|
| 34 |
give_update_option('auto_format_currency', $hasIntlExtension ? 'on' : false); |
| 35 |
} |
| 36 |
} |
| 37 |
|