Skip to content

Commit e217d39

Browse files
committed
Minor tweaks
1 parent bfa8d7b commit e217d39

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

components/intl.rst

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,22 @@ to catching the exception, you can also check if a given currency code is valid:
311311

312312
$isValidCurrency = Currencies::exists($currencyCode);
313313

314-
If the currencies need to be filtered, there are also helpers to query and
315-
validate currencies in relation to countries. These methods use ICU metadata
316-
(``tender``, ``from`` and ``to`` dates) to determine whether a currency is
317-
`legal tender`_ and/or active at a given point in time::
314+
By default, the previous currency methods return all currencies, including
315+
those that are no longer in use. Symfony provides several methods to filter
316+
currencies so you can work only with those that are actually valid and in use
317+
for a given country.
318+
319+
These methods use ICU metadata (``tender``, ``from`` and ``to`` dates) to
320+
determine whether a currency is `legal tender`_ and/or active at a specific
321+
point in time::
318322

319323
use Symfony\Component\Intl\Currencies;
320324

321-
// Get the list of legal and active currencies for a country (defaults to "today")
325+
// get the list of today's legal and active currencies for a country
322326
$codes = Currencies::forCountry('FR');
323327
// ['EUR']
324328

325-
// Include non-legal currencies too, and check them at a given date
329+
// include non-legal currencies too, and check them at a given date
326330
$codesAll = Currencies::forCountry(
327331
'ES',
328332
legalTender: null,
@@ -331,11 +335,11 @@ validate currencies in relation to countries. These methods use ICU metadata
331335
);
332336
// ['ESP', 'ESB']
333337

334-
// Validate a currency for a given country
338+
// check if a currency is valid today for a country
335339
$isOk = Currencies::isValidInCountry('CH', 'CHF');
336340
// true
337341

338-
// Check if a currency is valid in *any* country on a specific date
342+
// check if a currency is valid in any country on a specific date
339343
$isGlobal = Currencies::isValidInAnyCountry(
340344
'USD',
341345
legalTender: true,
@@ -344,9 +348,14 @@ validate currencies in relation to countries. These methods use ICU metadata
344348
);
345349
// true
346350

347-
Note that some currencies (especially non-legal-tender ones) do not have validity ranges defined.
348-
In such cases, a ``RuntimeException`` will be thrown.
349-
In addition, an ``InvalidArgumentException`` will be thrown if the specified currency is invalid.
351+
Note that some currencies (especially non-legal-tender ones) do not have validity
352+
ranges defined. In such cases, a ``RuntimeException`` will be thrown. In addition,
353+
an ``InvalidArgumentException`` will be thrown if the specified currency is invalid.
354+
355+
.. versionadded:: 7.4
356+
357+
The ``forCountry()``, ``isValidInCountry()`` and ``isValidInAnyCountry()``
358+
methods were introduced in Symfony 7.4.
350359

351360
.. _component-intl-timezones:
352361

0 commit comments

Comments
 (0)