Skip to content

Commit

Permalink
return null when message with name is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Apr 3, 2024
1 parent 39f75d9 commit 2bc6c8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Helper/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ public function setMessage(string $message, string $name = 'message')
$this->messages[$name] = $message;
}

/**
* @return string|null
*/
public function getMessage(string $name = 'message')
{
return $this->messages[$name];
return $this->messages[$name] ?? null;
}

public function getStartTime(): int
Expand Down
7 changes: 7 additions & 0 deletions Tests/Helper/ProgressBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1173,4 +1173,11 @@ public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup()
stream_get_contents($output->getStream())
);
}

public function testGetNotSetMessage()
{
$progressBar = new ProgressBar($this->getOutputStream());

$this->assertNull($progressBar->getMessage());
}
}

0 comments on commit 2bc6c8d

Please sign in to comment.