blumilksoftware / blt

Behat+Laravel toolbox. Still in progress.
https://packagist.org/packages/blumilksoftware/blt
3 stars 0 forks source link

Add helper for nullable strings #9

Closed krzysztofrewak closed 1 month ago

krzysztofrewak commented 3 years ago
if ($expected === "null") {
    $expected = null;
}

This is shit and it's repeated in many scenarios. My proposition is to add some helper to maintain things like this:

function behat_null(string $nullable): ?string
{
    return $nullable !== "null" ? $nullable : null;
}

Only question is how: as a loose function or some static helper? Probably we could add some helpers for converting true/false from strings too.