Skip to content

Commit

Permalink
refactor: format things according with sonarlint
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimorillo committed Mar 16, 2024
1 parent ebe64cb commit 97dcdc6
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/Shared/EventBus/EventRepositoryInMySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public function __construct(mysqli $mysqli)
public function store(Event $event): void
{
$stmt = $this->mysqli->prepare(
"INSERT INTO `events`
(`eventId`, `domainEvent`, `commandHandlerFQN`, `occurredOn`)
"INSERT INTO `events`
(`eventId`, `domainEvent`, `commandHandlerFQN`, `occurredOn`)
VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `domainEvent`=VALUES(`domainEvent`),
`commandHandlerFQN`=VALUES(`commandHandlerFQN`), `occurredOn`=VALUES(`occurredOn`);
"
);
$stmt->bind_param('ssss', $eventIdValue, $domainEventValue, $commandHandlerValue, $occurredOnValue);
$eventIdValue = $event->getEventId()->toString();
$domainEventValue = json_encode($event->getDomainEvent(), JSON_THROW_ON_ERROR);
$commandHandlerValue = $event->getCommandHandlerFQN();
$occurredOnValue = $event->getOccurredOn()->format('Y-m-d H:i:s');
$stmt->bind_param('ssss', $eventIdValue, $domainEventValue, $commandHandlerValue, $occurredOnValue);
$stmt->execute();
}

Expand Down
24 changes: 5 additions & 19 deletions src/Shared/MysqlClient/MysqlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,12 @@ public static function resetDatabase(string $database, bool $importFixtures = tr
{
$structureFile = dirname(__DIR__, 3) . '/resources/structure.sql';
$testDataFile = dirname(__DIR__, 3) . '/resources/test_fixtures.sql';
shell_exec(
'mysql -u' . $_ENV['MYSQL_USER'] . ' -p' . $_ENV['MYSQL_PASS']
. ' -e \'DROP DATABASE IF EXISTS `' . $database . '`\' 2>&1'
);
shell_exec(
'mysql -u' . $_ENV['MYSQL_USER']
. ' -p' . $_ENV['MYSQL_PASS']
. ' --execute=\'CREATE DATABASE `' . $database . '`\' 2>&1'
);
shell_exec(
'mysql -u' . $_ENV['MYSQL_USER']
. ' -p' . $_ENV['MYSQL_PASS']
. ' ' . $database . ' < ' . $structureFile . ' 2>&1'
);
$startMysqlQuery = 'mysql -u' . $_ENV['MYSQL_USER'] . ' -p' . $_ENV['MYSQL_PASS'];
shell_exec($startMysqlQuery . ' -e \'DROP DATABASE IF EXISTS `' . $database . '`\' 2>&1');
shell_exec($startMysqlQuery . ' --execute=\'CREATE DATABASE `' . $database . '`\' 2>&1');
shell_exec($startMysqlQuery . ' ' . $database . ' < ' . $structureFile . ' 2>&1');
if ($importFixtures === true) {
shell_exec(
'mysql -u' . $_ENV['MYSQL_USER']
. ' -p' . $_ENV['MYSQL_PASS']
. ' ' . $database . ' < ' . $testDataFile . ' 2>&1'
);
shell_exec($startMysqlQuery . ' ' . $database . ' < ' . $testDataFile . ' 2>&1');
}
}
}
2 changes: 1 addition & 1 deletion src/User/Application/Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public function getPassword(): string
{
return $this->password;
}
}
}
2 changes: 1 addition & 1 deletion src/User/Domain/ValueObject/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function __toString(): string
{
return $this->email;
}
}
}
2 changes: 1 addition & 1 deletion src/User/Domain/ValueObject/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function __toString(): string
{
return $this->password;
}
}
}
2 changes: 1 addition & 1 deletion src/User/Domain/ValueObject/StringValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface StringValueObject
public function toString(): string;

public function __toString(): string;
}
}
2 changes: 1 addition & 1 deletion src/User/Domain/ValueObject/UserId.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public function __toString(): string
{
return $this->identifier;
}
}
}

0 comments on commit 97dcdc6

Please sign in to comment.