for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Helldar\Support\Helpers;
final class Boolean
{
/**
* Determines if the value is `true`, otherwise it will return `false`.
*
* @param mixed $value
* @return bool
*/
public function isTrue($value): bool
return $this->to($value) === true;
}
* Determines if the value is `false`, otherwise it will return `true`.
public function isFalse($value): bool
return $this->to($value) === false;
* Converts a value to a boolean type.
public function to($value): bool
return (bool) $this->parse($value);
* Getting a filtered value in a boolean view.
* @return bool|null
public function parse($value): ?bool
if (is_null($value)) {
return null;
return filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
* Converts a boolean value to a string.
* @param bool $value
* @return string
public function convertToString(bool $value): string
return $value ? 'true' : 'false';