ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Concatenate.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
9 {
13  public static function CONCATENATE(...$args): string
14  {
15  $returnValue = '';
16 
17  // Loop through arguments
18  $aArgs = Functions::flattenArray($args);
19  foreach ($aArgs as $arg) {
20  if (is_bool($arg)) {
21  $arg = self::convertBooleanValue($arg);
22  }
23  $returnValue .= $arg;
24  }
25 
26  return $returnValue;
27  }
28 
36  public static function TEXTJOIN($delimiter, $ignoreEmpty, ...$args): string
37  {
38  // Loop through arguments
39  $aArgs = Functions::flattenArray($args);
40  foreach ($aArgs as $key => &$arg) {
41  if ($ignoreEmpty === true && is_string($arg) && trim($arg) === '') {
42  unset($aArgs[$key]);
43  } elseif (is_bool($arg)) {
44  $arg = self::convertBooleanValue($arg);
45  }
46  }
47 
48  return implode($delimiter, $aArgs);
49  }
50 
59  public static function builtinREPT($stringValue, $repeatCount): string
60  {
61  $repeatCount = Functions::flattenSingleValue($repeatCount);
62 
63  if (!is_numeric($repeatCount) || $repeatCount < 0) {
64  return Functions::VALUE();
65  }
66 
67  if (is_bool($stringValue)) {
68  $stringValue = self::convertBooleanValue($stringValue);
69  }
70 
71  return str_repeat($stringValue, (int) $repeatCount);
72  }
73 
74  private static function convertBooleanValue($value)
75  {
77  return (int) $value;
78  }
79 
80  return ($value) ? Calculation::getTRUE() : Calculation::getFALSE();
81  }
82 }
static builtinREPT($stringValue, $repeatCount)
REPT.
Definition: Concatenate.php:59
$delimiter
Definition: showstats.php:16
static TEXTJOIN($delimiter, $ignoreEmpty,... $args)
TEXTJOIN.
Definition: Concatenate.php:36
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:583
static getFALSE()
Return the locale-specific translation of FALSE.
static getTRUE()
Return the locale-specific translation of TRUE.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:649
$key
Definition: croninfo.php:18
static getCompatibilityMode()
Return the current Compatibility Mode.
Definition: Functions.php:93