Skip to content

Commit

Permalink
set default values for version and date
Browse files Browse the repository at this point in the history
  • Loading branch information
hehobasilico committed Feb 28, 2020
1 parent 334b348 commit dfc20ab
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,21 @@ public function __construct(
string $rocketChatBaseUri,
string $rocketChatChannel,
string $message,
array $messageParameters
array $messageParameters
) {
parent::__construct();
$this->rocketChatUser = $rocketChatUser;
$this->rocketChatPassword = $rocketChatPassword;
$this->rocketChatBaseUri = $rocketChatBaseUri;
$this->rocketChatChannel = $rocketChatChannel;
$this->message = $message;
$this->parameters = $messageParameters;
$this->parameters = array_merge(
[
'date' => 'Y-m-d H:i:s',
'version' => 'latest',
],
$messageParameters
);
}

/**
Expand Down Expand Up @@ -203,11 +209,11 @@ private function postToChannel(): void
private function createMessage()
{
foreach ($this->parameters as $parameterName => $parameterValue) {
if ($parameterName == 'date') {
if ($parameterName === 'date') {
$time = new DateTime('now');
$parameterValue = $time->format($parameterValue);
}
if ($parameterName == 'version' && $this->versionTag != '') {
if ($parameterName === 'version' && $this->versionTag !== '') {
$parameterValue = $this->versionTag;
}

Expand Down

0 comments on commit dfc20ab

Please sign in to comment.