- First commit
This commit is contained in:
commit
f5317f906d
9 files changed
+484
No files matched your search
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user