28 lines
427 B
PHP
28 lines
427 B
PHP
<?php
|
|
|
|
namespace Lucent\Schema;
|
|
|
|
final class Nullable
|
|
{
|
|
public function __construct(
|
|
public bool $nullable,
|
|
public mixed $value,
|
|
public mixed $default,
|
|
)
|
|
{
|
|
}
|
|
|
|
public function value(): mixed
|
|
{
|
|
|
|
if (!empty($this->value)) {
|
|
return $this->value;
|
|
}
|
|
|
|
if ($this->nullable) {
|
|
return null;
|
|
}
|
|
return $this->default;
|
|
}
|
|
}
|