22
33declare (strict_types=1 );
44
5- namespace Bamarni \Composer \Bin ;
5+ namespace Bamarni \Composer \Bin \ Config ;
66
77use Composer \Composer ;
8- use UnexpectedValueException ;
98use function array_key_exists ;
109use function array_merge ;
10+ use function function_exists ;
11+ use function is_bool ;
12+ use function is_string ;
13+ use function sprintf ;
1114
1215final class Config
1316{
@@ -43,13 +46,18 @@ final class Config
4346 */
4447 private $ deprecations = [];
4548
49+ /**
50+ * @throws InvalidBamarniComposerExtraConfig
51+ */
4652 public static function fromComposer (Composer $ composer ): self
4753 {
4854 return new self ($ composer ->getPackage ()->getExtra ());
4955 }
5056
5157 /**
5258 * @param mixed[] $extra
59+ *
60+ * @throws InvalidBamarniComposerExtraConfig
5361 */
5462 public function __construct (array $ extra )
5563 {
@@ -62,7 +70,7 @@ public function __construct(array $extra)
6270 $ binLinks = $ config [self ::BIN_LINKS_ENABLED ];
6371
6472 if (!is_bool ($ binLinks )) {
65- throw new UnexpectedValueException (
73+ throw new InvalidBamarniComposerExtraConfig (
6674 sprintf (
6775 'Expected setting "%s.%s" to be a boolean value. Got "%s". ' ,
6876 self ::EXTRA_CONFIG_KEY ,
@@ -85,7 +93,7 @@ public function __construct(array $extra)
8593 $ targetDirectory = $ config [self ::TARGET_DIRECTORY ];
8694
8795 if (!is_string ($ targetDirectory )) {
88- throw new UnexpectedValueException (
96+ throw new InvalidBamarniComposerExtraConfig (
8997 sprintf (
9098 'Expected setting "%s.%s" to be a string. Got "%s". ' ,
9199 self ::EXTRA_CONFIG_KEY ,
@@ -98,7 +106,7 @@ public function __construct(array $extra)
98106 $ forwardCommand = $ config [self ::FORWARD_COMMAND ];
99107
100108 if (!is_bool ($ forwardCommand )) {
101- throw new UnexpectedValueException (
109+ throw new InvalidBamarniComposerExtraConfig (
102110 sprintf (
103111 'Expected setting "%s.%s" to be a boolean value. Got "%s". ' ,
104112 self ::EXTRA_CONFIG_KEY ,
0 commit comments