icingaweb2-module-director/library/Director/PropertyModifier/PropertyModifierToString.php
Ravi Kumar Kempapura Srinivasa a5837727ec
Some checks failed
L10n Update / update (push) Has been cancelled
PHP Tests / Static analysis for php 7.2 on ubuntu-latest (push) Has been cancelled
PHP Tests / Static analysis for php 7.3 on ubuntu-latest (push) Has been cancelled
PHP Tests / Static analysis for php 7.4 on ubuntu-latest (push) Has been cancelled
PHP Tests / Static analysis for php 8.0 on ubuntu-latest (push) Has been cancelled
PHP Tests / Static analysis for php 8.1 on ubuntu-latest (push) Has been cancelled
PHP Tests / Static analysis for php 8.2 on ubuntu-latest (push) Has been cancelled
PHP Tests / Static analysis for php 8.3 on ubuntu-latest (push) Has been cancelled
PHP Tests / Unit tests with php 8.2 on ubuntu-latest (push) Has been cancelled
PHP Tests / Unit tests with php 8.3 on ubuntu-latest (push) Has been cancelled
Add import source property modifier to cast int to string (#3047)
2026-03-26 15:06:18 +01:00

31 lines
667 B
PHP

<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Data\InvalidDataException;
use Icinga\Module\Director\Hook\PropertyModifierHook;
class PropertyModifierToString extends PropertyModifierHook
{
public function getName()
{
return 'Cast an integer value to a string';
}
public function transform($value)
{
if ($value === null) {
return null;
}
if (is_string($value)) {
return $value;
}
if (is_int($value)) {
return (string) $value;
}
throw new InvalidDataException('String, integer or null', $value);
}
}