Skip to content

Commit

Permalink
[6.x] Remove webmozart/assert package (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguilimzero authored Apr 1, 2024
1 parent ac8b8c9 commit b2fc2e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"php": "^8.2",
"illuminate/contracts": "^11.0",
"laravel/prompts": "^0.1.10",
"laravel/socialite": "^5.12",
"webmozart/assert": "^1.11"
"laravel/socialite": "^5.12"
},
"require-dev": {
"laravel/breeze": "^2.0",
Expand Down
17 changes: 12 additions & 5 deletions src/Data/ProviderData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use JoelButcher\Socialstream\Enums\ProviderEnum;
use JoelButcher\Socialstream\Providers;
use Webmozart\Assert\Assert;

/**
* @internal
Expand All @@ -16,15 +15,23 @@ private function __construct(
public readonly string $name,
public readonly ?string $buttonLabel = null,
) {
Assert::stringNotEmpty($id);
Assert::stringNotEmpty($name);
if ($id === '') {
throw new \InvalidArgumentException('Expected a different value than \'\'');
}
if ($name === '') {
throw new \InvalidArgumentException('Expected a different value than \'\'');
}
}

public static function from(ProviderEnum|string|array $provider): self
{
if (is_array($provider)) {
Assert::keyExists($provider, 'id');
Assert::keyExists($provider, 'name');
if (! array_key_exists('id', $provider)) {
throw new \InvalidArgumentException('Expected the key \'id\' to exist');
}
if (! array_key_exists('name', $provider)) {
throw new \InvalidArgumentException('Expected the key \'name\' to exist');
}
}

return match (true) {
Expand Down

0 comments on commit b2fc2e8

Please sign in to comment.