Skip to content

Commit 851d237

Browse files
committed
Improve Component:fromUri implementation
1 parent 7c3dd47 commit 851d237

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

FeatureDetection.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,32 @@ public static function supportsFileDetection(): void
3434
static $isSupported = null;
3535
$isSupported = $isSupported ?? class_exists(finfo::class);
3636

37-
if (!$isSupported) {
38-
throw new MissingFeature('Support for file type detection requires the `fileinfo` extension.');
39-
}
37+
$isSupported || throw new MissingFeature('Support for file type detection requires the `fileinfo` extension.');
38+
4039
}
4140

4241
public static function supportsIdn(): void
4342
{
4443
static $isSupported = null;
4544
$isSupported = $isSupported ?? (function_exists('\idn_to_ascii') && defined('\INTL_IDNA_VARIANT_UTS46'));
4645

47-
if (!$isSupported) {
48-
throw new MissingFeature('Support for IDN host requires the `intl` extension for best performance or run "composer require symfony/polyfill-intl-idn" to install a polyfill.');
49-
}
46+
$isSupported || throw new MissingFeature('Support for IDN host requires the `intl` extension for best performance or run "composer require symfony/polyfill-intl-idn" to install a polyfill.');
47+
5048
}
5149

5250
public static function supportsIPv4Conversion(): void
5351
{
5452
static $isSupported = null;
5553
$isSupported = $isSupported ?? (extension_loaded('gmp') || extension_loaded('bcmath') || (4 < PHP_INT_SIZE));
5654

57-
if (!$isSupported) {
58-
throw new MissingFeature('A '.Calculator::class.' implementation could not be automatically loaded. To perform IPv4 conversion use a x.64 PHP build or install one of the following extension GMP or BCMath. You can also ship your own implmentation.');
59-
}
55+
$isSupported || throw new MissingFeature('A '.Calculator::class.' implementation could not be automatically loaded. To perform IPv4 conversion use a x.64 PHP build or install one of the following extension GMP or BCMath. You can also ship your own implementation.');
6056
}
6157

6258
public static function supportsDom(): void
6359
{
6460
static $isSupported = null;
6561
$isSupported = $isSupported ?? extension_loaded('dom');
6662

67-
if (!$isSupported) {
68-
throw new MissingFeature('To use a DOM related feature, the DOM extension must be installed in your system.');
69-
}
63+
$isSupported || throw new MissingFeature('To use a DOM related feature, the DOM extension must be installed in your system.');
7064
}
7165
}

0 commit comments

Comments
 (0)