Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Commit

Permalink
UserName VO fix no. 2 (revert "fix") & check guild before creating en…
Browse files Browse the repository at this point in the history
…tity
  • Loading branch information
chonsser committed Jun 15, 2017
1 parent 509ccfc commit 93b0c63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions src/Provider/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,18 @@ protected function createResourceOwner(array $response, AccessToken $token)
);

foreach ($guilds as $key => $guild) {
$_guild = new Guild();

$_guild
->setId($guild['id'])
->setName(new GuildName($guild['name']))
->setIcon($guild['icon'])
->setOwner($guild['owner'])
->setPermissions($guild['permissions']);

$user->addGuild($_guild);
if($guild['id'] !== null){
$_guild = new Guild();

$_guild
->setId($guild['id'])
->setName(new GuildName($guild['name']))
->setIcon($guild['icon'])
->setOwner($guild['owner'])
->setPermissions($guild['permissions']);

$user->addGuild($_guild);
}
}

return $user;
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/ValueObject/UserName.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ private function guardUserName($user_name)

$name_length = strlen($user_name);

if ($name_length >= self::MAX_LENGTH) {
if ($name_length > self::MAX_LENGTH) {
throw new InvalidUserNameException("Username must have less than " . self::MAX_LENGTH . " characters");
}

if ($name_length <= self::MIN_LENGTH) {
if ($name_length < self::MIN_LENGTH) {
throw new InvalidUserNameException("Username must have more than " . self::MIN_LENGTH . " characters");
}
}
Expand Down

0 comments on commit 93b0c63

Please sign in to comment.