Files
iTop/sources/Core/AttributeDefinition/AttributeIPAddress.php
Benjamin Dalsass abafeff24d N°8699 - attributedef.class.inc.php to PSR4 [2-DISPATCH]
- Restore attributedef.class.inc.php with requires
- Update each attribute file code
2025-09-12 13:49:33 +02:00

39 lines
1.1 KiB
PHP

<?php
/**
* Specialization of a string: IP address
*
* @package iTopORM
*/
class AttributeIPAddress extends AttributeString
{
/**
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
*
* @see https://www.php.net/manual/fr/language.oop5.decon.php states that child constructor can be ommited
* @see https://bugs.php.net/bug.php?id=79010 bug solved in PHP 7.4.9
*
* @param string $sCode
* @param array $aParams
*
* @throws \Exception
* @noinspection SenselessProxyMethodInspection
*/
public function __construct($sCode, $aParams)
{
parent::__construct($sCode, $aParams);
}
public function GetValidationPattern()
{
$sNum = '(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])';
return "^($sNum\\.$sNum\\.$sNum\\.$sNum)$";
}
public function GetOrderBySQLExpressions($sClassAlias)
{
// Note: This is the responsibility of this function to place backticks around column aliases
return array('INET_ATON(`' . $sClassAlias . $this->GetCode() . '`)');
}
}