- First commit

This commit is contained in:
Dave Mc Nicoll committed 2024-10-14 15:28:35 +00:00
commit f5317f906d
9 files changed
+484

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<?php
namespace Lean\Api;
trait DescriptorTrait
{
protected function displayValue(mixed $value) : string
{
if (is_null($value)) {
return "NULL";
}
elseif (is_bool($value)) {
return $value ? "TRUE" : "FALSE";
}
elseif ($value instanceof \UnitEnum) {
return $value::class . "::" . $value->name;
}
return $value;
}
protected function yesOrNo(bool $toggle) : string
{
return sprintf("<span style='color:%s'>%s</span>", $toggle ? 'green' : '#ac1b1b', $toggle ? 'oui' : 'non');
}
protected function length(int|null $length) : string
{
return sprintf("<span style='color:%s'>%s</span>", $length ? 'black' : 'gray', $length ?? "non-défini");
}
}