PropertyModifierToInt: new property modifier
This commit is contained in:
parent
407a387dab
commit
a17fc32b41
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
|
||||
class PropertyModifierToInt extends PropertyModifierHook
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'Cast a string value to an Integer';
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
return (int) $value;
|
||||
}
|
||||
}
|
||||
}
|
1
run.php
1
run.php
|
@ -34,6 +34,7 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
|
|||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierBitmask');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierMakeBoolean');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierJsonDecode');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierToInt');
|
||||
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob');
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\ConfigJob');
|
||||
|
|
Loading…
Reference in New Issue