Skip to content

Commit

Permalink
Check passing driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
wapmorgan committed Jun 24, 2023
1 parent f9e47fc commit ab6d546
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/UnifiedArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,28 @@ protected static function getCreationDriver($archiveFormat, $inString, $encrypte
* @param string $format Archive type
* @param string|null $password
*/
public function __construct($fileName, $format, $abilities = [], $password = null)
public function __construct($fileName, $format, $abilities = [], $password = null, $driver = null)
{
if (empty($abilities)) {
$abilities = [Abilities::OPEN];
if (!empty($password)) {
$abilities[] = Abilities::OPEN_ENCRYPTED;
}
}
$driver = Formats::getFormatDriver($format, $abilities);
if ($driver === null) {
throw new UnsupportedArchiveException(
'Format ' . $format . ' driver with abilities ('
. implode(
', ',
array_map(function ($ability) {
return array_search($ability, Abilities::$abilitiesLabels);
}, $abilities)
)
. ') is not found');
$driver = Formats::getFormatDriver($format, $abilities);
if ($driver === null) {
throw new UnsupportedArchiveException(
'Format ' . $format . ' driver with abilities ('
. implode(
', ',
array_map(function ($ability) {
return array_search($ability, Abilities::$abilitiesLabels);
}, $abilities)
)
. ') is not found'
);
}
}

$this->format = $format;
Expand Down

0 comments on commit ab6d546

Please sign in to comment.