File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/PhpSpreadsheet/Style/NumberFormat/Wizard Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,31 @@ public function __construct(
3838 $ this ->setLocale ($ locale );
3939 }
4040
41+ /**
42+ * @throws Exception if the Intl extension and ICU version don't support Accounting formats
43+ */
4144 protected function getLocaleFormat (): string
4245 {
46+ if (version_compare (PHP_VERSION , '7.4.1 ' , '< ' )) {
47+ throw new Exception ('The Intl extension does not support Accounting Formats below PHP 7.4.1 ' );
48+ }
49+
50+ if ($ this ->icuVersion () < 53.0 ) {
51+ throw new Exception ('The Intl extension does not support Accounting Formats without ICU 53 ' );
52+ }
53+
4354 $ formatter = new Locale ($ this ->fullLocale , NumberFormatter::CURRENCY_ACCOUNTING ); // @phpstan-ignore-line
4455
4556 return str_replace ('¤ ' , $ this ->formatCurrencyCode (), $ formatter ->format ());
4657 }
4758
59+ private function icuVersion (): float
60+ {
61+ [$ major , $ minor ] = explode ('. ' , INTL_ICU_VERSION );
62+
63+ return (float ) "{$ major }. {$ minor }" ;
64+ }
65+
4866 private function formatCurrencyCode (): string
4967 {
5068 if ($ this ->locale === null ) {
You can’t perform that action at this time.
0 commit comments