ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlStructureCidGenerator Class Reference

Class ilCtrlStructureCidGenerator. More...

+ Collaboration diagram for ilCtrlStructureCidGenerator:

Public Member Functions

 __construct (int $starting_index=0)
 ilCtrlStructureCidGenerator Constructor More...
 
 getIndexByCid (string $cid)
 Returns the index of a given cid. More...
 
 getCidByIndex (int $index)
 Returns the cid for a given index. More...
 
 getCid ()
 Returns the next available cid. More...
 

Private Member Functions

 invertIndex (int $index)
 Helper function that inverts an integer value. More...
 

Private Attributes

int $index
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCtrlStructureCidGenerator::__construct ( int  $starting_index = 0)

ilCtrlStructureCidGenerator Constructor

Parameters
int$starting_index

Definition at line 24 of file class.ilCtrlStructureCidGenerator.php.

25  {
26  $this->index = $starting_index;
27  }

Member Function Documentation

◆ getCid()

ilCtrlStructureCidGenerator::getCid ( )

Returns the next available cid.

Returns
string

Definition at line 67 of file class.ilCtrlStructureCidGenerator.php.

References getCidByIndex().

67  : string
68  {
69  return $this->getCidByIndex($this->index++);
70  }
getCidByIndex(int $index)
Returns the cid for a given index.
+ Here is the call graph for this function:

◆ getCidByIndex()

ilCtrlStructureCidGenerator::getCidByIndex ( int  $index)

Returns the cid for a given index.

Parameters
int$index
Returns
string

Definition at line 53 of file class.ilCtrlStructureCidGenerator.php.

References invertIndex().

Referenced by getCid().

53  : string
54  {
55  if (0 > $index) {
56  return '-' . base_convert((string) $this->invertIndex($index), 10, 36);
57  }
58 
59  return base_convert((string) $index, 10, 36);
60  }
invertIndex(int $index)
Helper function that inverts an integer value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIndexByCid()

ilCtrlStructureCidGenerator::getIndexByCid ( string  $cid)

Returns the index of a given cid.

Parameters
string$cid
Returns
int

Definition at line 35 of file class.ilCtrlStructureCidGenerator.php.

References ILIAS\Repository\int(), and invertIndex().

35  : int
36  {
37  if (strpos($cid, '-') === 0) {
38  $inverted_cid = str_replace('-', '', $cid);
39  $index = (int) base_convert($inverted_cid, 36, 10);
40 
41  return $this->invertIndex($index);
42  }
43 
44  return (int) base_convert($cid, 36, 10);
45  }
invertIndex(int $index)
Helper function that inverts an integer value.
+ Here is the call graph for this function:

◆ invertIndex()

ilCtrlStructureCidGenerator::invertIndex ( int  $index)
private

Helper function that inverts an integer value.

Parameters
int$index
Returns
int

Definition at line 78 of file class.ilCtrlStructureCidGenerator.php.

Referenced by getCidByIndex(), and getIndexByCid().

78  : int
79  {
80  return (-1 * $index);
81  }
+ Here is the caller graph for this function:

Field Documentation

◆ $index

int ilCtrlStructureCidGenerator::$index
private

Definition at line 17 of file class.ilCtrlStructureCidGenerator.php.


The documentation for this class was generated from the following file: