blob: 969068e95e5b6039072da1f967872957490b1fb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Hook\PropertyModifierHook;
class PropertyModifierXlsNumericIp extends PropertyModifierHook
{
public function getName()
{
return 'Fix IP formatted as a number in MS Excel';
}
public function transform($value)
{
if (ctype_digit($value) && strlen($value) > 9 && strlen($value) <= 12) {
return preg_replace(
'/^(\d{1,3})(\d{3})(\d{3})(\d{3})/',
'\1.\2.\3.\4',
$value
);
} else {
return $value;
}
}
}
|