Skip to content

Commit

Permalink
Fixed a bug with unexpected "action" key
Browse files Browse the repository at this point in the history
  • Loading branch information
arturskonfino committed Nov 17, 2020
1 parent c5d1580 commit f43edeb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/AssetOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,19 @@ public static function buildFromArray(array $array, string $package, string $pac
} else {
$metadata = [];
}

if (isset($array['action'])) {
$action = $array['action'];
unset($array['action']);
} else {
$action = self::ADD;
}

if (!empty($array)) {
throw new JsonException(sprintf('Unexpected key(s) in discovery.json from package %s: "%s"', $package, implode(', ', array_keys($array))));
}

return new self(self::ADD, new Asset($value, $package, $packageDir, $priority, $metadata));
return new self($action, new Asset($value, $package, $packageDir, $priority, $metadata));
}

/**
Expand Down

0 comments on commit f43edeb

Please sign in to comment.