31 public final static function expectInteger($arg, $argName =
'', $customMsg =
'')
33 $argInt = intval($arg);
35 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_INTEGER_EXPECTED', $argName, $customMsg));
53 $argInt = intval($arg);
54 if($arg != $argInt || $argInt <= 0)
55 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_INTEGER_NOTNULL_EXPECTED', $argName, $customMsg));
73 $argInt = intval($arg);
74 if($arg != $argInt || $argInt < 0)
75 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_INTEGER_NONNEGATIVE_EXPECTED', $argName, $customMsg));
94 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_STRING_NOTNULL_EXPECTED', $argName, $customMsg));
110 public final static function expectArray($arg, $argName =
'', $customMsg =
'')
113 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ARRAY_EXPECTED', $argName, $customMsg));
131 if(!is_array($arg) || empty($arg))
132 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ARRAY_NOT_EMPTY_EXPECTED', $argName, $customMsg));
151 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ARRAY_EXPECTED', $argName, $customMsg));
153 $arg = array_unique(array_values($arg));
155 foreach($arg as $k => $v)
158 if($v != $vInt || $vInt == 0)
159 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ARRAY_OF_INTEGER_NOT_NULL_EXPECTED', $argName, $customMsg));
181 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ARRAY_EXPECTED', $argName, $customMsg));
183 $arg = array_unique(array_values($arg));
185 foreach($arg as $k => $v)
189 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ARRAY_OF_STRING_NOT_NULL_EXPECTED', $argName, $customMsg));
214 if(!is_array($enum) || empty($enum))
218 foreach($enum as $variant)
224 throw new Main\ArgumentException(self::formMessage(
'SALE_LOCATION_ASSERT_ITEM_NOT_IN_ENUMERATION', $argName, $customMsg));
231 return ToLower(trim($value));
260 private static function formMessage($msgCode, $argName =
'', $customMsg =
'')
264 return str_replace(
'#ARG_NAME#', $argName, $customMsg);
267 return Loc::getMessage($msgCode, array(
'#ARG_NAME#' => $argName <>
''?
' "'.$argName.
'" ' :
' '));
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
static expectArray($arg, $argName='', $customMsg='')
static expectIntegerNonNegative($arg, $argName='', $customMsg='')
static expectNotEmptyArray($arg, $argName='', $customMsg='')
static expectIntegerPositive($arg, $argName='', $customMsg='')
static castTrimLC($value)
static expectArrayOfUniqueStringNotNull($arg, $argName='', $customMsg='')
static announceNotImplemented($msg='')
static expectArrayOfUniqueIntegerNotNull($arg, $argName='', $customMsg='')
static expectStringNotNull($arg, $argName='', $customMsg='')
static announceNotSupported($msg='')
static expectEnumerationMember($arg, $enum=array(), $argName='', $customMsg='')
static expectInteger($arg, $argName='', $customMsg='')