Skip to content

Commit 2bc6c8d

Browse files
committed
return null when message with name is not set
1 parent 39f75d9 commit 2bc6c8d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Helper/ProgressBar.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ public function setMessage(string $message, string $name = 'message')
169169
$this->messages[$name] = $message;
170170
}
171171

172+
/**
173+
* @return string|null
174+
*/
172175
public function getMessage(string $name = 'message')
173176
{
174-
return $this->messages[$name];
177+
return $this->messages[$name] ?? null;
175178
}
176179

177180
public function getStartTime(): int

Tests/Helper/ProgressBarTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -1173,4 +1173,11 @@ public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup()
11731173
stream_get_contents($output->getStream())
11741174
);
11751175
}
1176+
1177+
public function testGetNotSetMessage()
1178+
{
1179+
$progressBar = new ProgressBar($this->getOutputStream());
1180+
1181+
$this->assertNull($progressBar->getMessage());
1182+
}
11761183
}

0 commit comments

Comments
 (0)