for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mpyw\OpenGraph;
use DateTimeImmutable;
use DateTimeInterface;
use Throwable;
/**
* Trait GenericHelper
*/
trait GenericHelper
{
* @param string $value
* @return null|DateTimeInterface
protected function convertToDateTime(string $value): ?DateTimeInterface
try {
return new DateTimeImmutable($value);
} catch (Throwable $e) {
return null;
}
* @return bool
protected function convertToBoolean(string $value): bool
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
* @param null|string $string
* @return null|string
protected function emptyStringAsNull(?string $string): ?string
return (string)$string !== '' ? (string)$string : null;