Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Support

Functions

 __construct ( $data)
 Constructor.
 
 __construct (&$string)
 Constructor.
 
 __construct ()
 Constructor.
 
 __get ($key)
 
 __isset ($key)
 Checks the existance of $key in this array.
 
 __set ($key, $value)
 
 __unset ($key)
 Removes $key from this array.
 
 _andition ($string)
 
 _directReplacements ($string)
 easy/direct replacements
 
 _fractionalAddition ($string)
 
 _getRealOffset ($offset)
 Determines the actual array offset given the input offset.
 
 _hideAHalf ($string)
 take the 'a' out so it doesn't turn into a 1, save the half for the end
 
 _replaceBigPrefixes ($string)
 hundreds, thousands, millions, etc.
 
 _replaceTenPrefixes ($string)
 ten, twenty, etc.
 
 _splitHyphenatedWords ($string)
 will mutilate hyphenated-words but shouldn't matter for date extraction
 
 _splitHyphenateWords ($string)
 will mutilate hyphenated-words but shouldn't matter for date extraction
 
 camelize ($word, $firstLetter='upper')
 Camel-cases a word.
 
 classify ($tableName)
 Creates a class name from a table name like Rails does for table names to models.
 
 clear ()
 Clear out the array.
 
 clearCache ()
 Clears the inflection cache.
 
 count ()
 Count the number of elements.
 
 dasherize ($underscoredWord)
 Replaces underscores with dashes in the string.
 
 demodulize ($classNameInModule)
 Removes the module part from the expression in the string.
 
 fopen ()
 Return a stream handle to this stream.
 
 foreignKey ($className, $separateClassNameAndIdWithUnderscore=true)
 Creates a foreign key name from a class name.
 
 get ($key, $default=null)
 
 getCache ($word, $rule)
 Retuns a cached inflection.
 
 getData ()
 Return a reference to the data.
 
 getFileObject ()
 Return an SplFileObject representing this stream.
 
 getIterator ()
 
 getKeys ()
 Get the keys in the array.
 
 getOrSet ($offset, $default=null)
 Gets the value at $offset.
 
getString ()
 Return a reference to the wrapped string.
 
 getValues ()
 Get the values in the array.
 
 humanize ($lowerCaseAndUnderscoredWord)
 Capitalizes the first word and turns underscores into spaces and strips _id.
 
 installWrapper ()
 Install the horde-combine stream wrapper if it isn't already registered.
 
 numerize ( $string)
 Rules:
 
 offsetExists ($offset)
 Checks the existence of $offset in this array.
 
 offsetGet ($offset)
 Gets the value of $offset in this array.
 
 offsetSet ($offset, $value)
 Sets the value of $offset to $value.
 
 offsetUnset ($offset)
 Removes $offset from this array.
 
 ordinalize ($number)
 Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
 
 pluralize ($word)
 Singular English word to pluralize.
 
 pop ($offset, $default=null)
 Gets the value at $offset and deletes it from the array.
 
 pop ()
 Pop the latest tracker and return the difference with the current memory situation.
 
 push ()
 Push a new tracker on the stack.
 
 setCache ($word, $rule, $value)
 Caches an inflection.
 
 singularize ($word)
 Plural English word to singularize.
 
 tableize ($className)
 Creates the name of a table like Rails does for models to table names.
 
 titleize ($word)
 Capitalizes all the words and replaces some characters in the string to create a nicer looking title.
 
 uncountable ($word)
 Adds an uncountable word.
 
 underscore ($camelCasedWord)
 The reverse of camelize().
 
 update ($array)
 Update the array with the key/value pairs from $array.
 

Variables

integer $_idx = 0
 Current index for stacked trackers.
 
array $_pluralizationRules
 Rules for pluralizing English nouns.
 
array $_singularizationRules
 Rules for singularizing English nouns.
 
string $_string
 String data.
 
array $_uncountables
 An array of words with the same singular and plural spellings.
 
 $BIG_PREFIXES
 
 $BIG_PREFIXES
 
 $BIG_PREFIXES
 
$elapsed = $t->pop()
 
**< code > * $id = (string)new Horde_Support_Randomid()
 
*< code > * $t = new Horde_Support_Memory
 
*< code > * $t = new Horde_Support_Timer
 
*author Chuck Hagenbuch< chuck @horde.org > *license $TEN_PREFIXES
 
*author Chuck Hagenbuch< chuck @horde.org > *author Jan Schneider< jan @horde.org > *license $TEN_PREFIXES
 
*license $TEN_PREFIXES
 
*< code > * $uid = (string)new Horde_Support_Guid([$opts = array()])
 
$used = $t->pop()
 
*< code > * $uuid = (string)new Horde_Support_Uuid
 
*todo Incorporate stuff from Horde_Array Countable
 
*category Horde *copyright Horde LLC *license Countable
 
*</code > **Do not expect too much of this memory tracker Profiling memory is not *trivial as your placement of the measurements may obscure important *information As a trivial example
 
*todo Incorporate stuff from Horde_Array * http
 
*See the enclosed file LICENSE for license information(BSD). If you *did not receive this file see http
 
*author Michael Slusarz< slusarz @horde.org > *license http
 
*category Horde *ingroup Support *license http
 
*author Chuck Hagenbuch< chuck @horde.org > *license http
 
*author Chuck Hagenbuch< chuck @horde.org > *license http
 
*author Chuck Hagenbuch< chuck @horde.org > *author Jan Schneider< jan @horde.org > *license http
 
*license http
 
*author Chuck Hagenbuch< chuck @horde.org > *category Horde *license http
 
*category Horde *copyright Horde LLC *license http
 
*todo Incorporate stuff from Horde_Array IteratorAggregate
 
*and also the original paper
 

Detailed Description

Function Documentation

◆ __construct() [1/3]

__construct ( $data)

Constructor.

Parameters
array$dataAn array of strings and/or streams to combine into a single stream.

◆ __construct() [2/3]

__construct ( & $string)

Constructor.

Parameters
string&$stringReference to the string to wrap as a stream

◆ __construct() [3/3]

__construct ( )

Constructor.

Stores a map of the uncountable words for quicker checks.

◆ _getRealOffset()

_getRealOffset ( $offset)
protected

Determines the actual array offset given the input offset.

Parameters
string$offsetInput offset.
Return values
stringReal offset or null.

◆ camelize()

camelize ( $word,
$firstLetter = 'upper' )

Camel-cases a word.

Todo
Do we want locale-specific or locale-independent camel casing?
Parameters
string$wordThe word to camel-case.
string$firstLetterWhether to upper or lower case the first. letter of each slash-separated section.
Return values
stringCamelized $word

◆ classify()

classify ( $tableName)

Creates a class name from a table name like Rails does for table names to models.

Examples:

  1. classify("egg_and_hams") => "EggAndHam"
  2. classify("post") => "Post"

◆ count()

count ( )

Count the number of elements.

Return values
integer

◆ dasherize()

dasherize ( $underscoredWord)

Replaces underscores with dashes in the string.

Example:

  1. dasherize("puni_puni") => "puni-puni"

◆ demodulize()

demodulize ( $classNameInModule)

Removes the module part from the expression in the string.

Examples:

  1. demodulize("Fax_Job") => "Job"
  1. demodulize("User") => "User"

◆ fopen()

fopen ( )

Return a stream handle to this stream.

Return a stream handle to this string stream.

Return values
resource
Examples
/home/runner/work/phpdoc/phpdoc/.moodle/lib/adodb/adodb-perf.inc.php.

◆ foreignKey()

foreignKey ( $className,
$separateClassNameAndIdWithUnderscore = true )

Creates a foreign key name from a class name.

$separateClassNameAndIdWithUnderscore sets whether the method should put '_' between the name and 'id'.

Examples:

  1. foreignKey("Message") => "message_id"
  2. foreignKey("Message", false) => "messageid"
  3. foreignKey("Fax_Job") => "fax_job_id"

◆ getCache()

getCache ( $word,
$rule )

Retuns a cached inflection.

Return values
string| false

◆ getData()

getData ( )

Return a reference to the data.

Return values
array

◆ getFileObject()

getFileObject ( )

Return an SplFileObject representing this stream.

Return an SplFileObject representing this string stream.

Return values
SplFileObject

◆ getKeys()

getKeys ( )

Get the keys in the array.

Return values
array

◆ getOrSet()

getOrSet ( $offset,
$default = null )

Gets the value at $offset.

If no value exists at that offset, or the value $offset is NULL, then $default is set as the value of $offset.

Parameters
string$offsetOffset to retrieve and set if unset
string$defaultDefault value if $offset does not exist
Return values
mixedValue at $offset or $default

◆ getString()

& getString ( )

Return a reference to the wrapped string.

Return values
string

◆ getValues()

getValues ( )

Get the values in the array.

Return values
array

◆ humanize()

humanize ( $lowerCaseAndUnderscoredWord)

Capitalizes the first word and turns underscores into spaces and strips _id.

Like titleize(), this is meant for creating pretty output.

Examples:

  1. humanize("employee_salary") => "Employee salary"
  2. humanize("author_id") => "Author"

◆ installWrapper()

installWrapper ( )

Install the horde-combine stream wrapper if it isn't already registered.

Install the stream wrapper if it isn't already registered.

Exceptions
Exception

◆ numerize()

numerize ( $string)

Rules:

  • there are irregular word for 11 and 12 like in English
  • numbers below one million are written together (1 M = "eine Million", 100 = "einhundert")
  • "a" is declinable (see above, "one" = "eins", "a" = "ein/eine")
  • numbers below 100 are flipped compared to english, and have an "and = "und" (21 = "twenty-one" = "einundzwanzig")

◆ offsetExists()

offsetExists ( $offset)

Checks the existence of $offset in this array.

See also
__isset()

◆ offsetGet()

offsetGet ( $offset)

Gets the value of $offset in this array.

See also
__get()

◆ offsetSet()

offsetSet ( $offset,
$value )

Sets the value of $offset to $value.

See also
__set()

◆ offsetUnset()

offsetUnset ( $offset)

Removes $offset from this array.

See also
__unset()

◆ ordinalize()

ordinalize ( $number)

Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

Examples:

  1. ordinalize(1) => "1st"
  2. ordinalize(2) => "2nd"
  3. ordinalize(1002) => "1002nd"
  4. ordinalize(1003) => "1003rd"

◆ pluralize()

pluralize ( $word)

Singular English word to pluralize.

Parameters
string$wordWord to pluralize.
Return values
stringPlural form of $word.

◆ pop() [1/2]

pop ( $offset,
$default = null )

Gets the value at $offset and deletes it from the array.

If no value exists at $offset, or the value at $offset is null, then $default will be returned.

Parameters
string$offsetOffset to pop
string$defaultDefault value
Return values
mixedValue at $offset or $default

◆ pop() [2/2]

pop ( )

Pop the latest tracker and return the difference with the current memory situation.

Return values
arrayThe change in memory allocated via emalloc() in between the push() and the pop() call. The array holds four values: the first one indicates the change in current usage of memory while the second value indicates any changes in the peak amount of memory used. The third and fourth value show current and peak usage as well but indicate the real memory usage and not just the part allocated via emalloc(),

◆ setCache()

setCache ( $word,
$rule,
$value )

Caches an inflection.

Parameters
string$wordThe word being inflected.
string$ruleThe inflection rule.
string$valueThe inflected value of $word.
Return values
stringThe inflected value

◆ singularize()

singularize ( $word)

Plural English word to singularize.

Parameters
string$wordWord to singularize.
Return values
stringSingular form of $word.

◆ tableize()

tableize ( $className)

Creates the name of a table like Rails does for models to table names.

This method uses the pluralize() method on the last word in the string.

Examples:

  1. tableize("RawScaledScorer") => "raw_scaled_scorers"
  2. tableize("egg_and_ham") => "egg_and_hams"
  3. tableize("fancyCategory") => "fancy_categories"

◆ titleize()

titleize ( $word)

Capitalizes all the words and replaces some characters in the string to create a nicer looking title.

Titleize is meant for creating pretty output.

See:

Examples:

  1. titleize("man from the boondocks") => "Man From The Boondocks"
  2. titleize("x-men: the last stand") => "X Men: The Last Stand"

◆ uncountable()

uncountable ( $word)

Adds an uncountable word.

Parameters
string$wordThe uncountable word.

◆ underscore()

underscore ( $camelCasedWord)

The reverse of camelize().

Makes an underscored form from the expression in the string.

Examples:

  1. underscore("ActiveRecord") => "active_record"
  2. underscore("ActiveRecord_Errors") => "active_record_errors"

    Todo
    Do we want locale-specific or locale-independent lowercasing?

◆ update()

update ( $array)

Update the array with the key/value pairs from $array.

Parameters
array$arrayKey/value pairs to set/change in the array.

Variable Documentation

◆ $_pluralizationRules

array $_pluralizationRules
protected
Initial value:
= array(
'/move$/i' => 'moves',
'/sex$/i' => 'sexes',
'/child$/i' => 'children',
'/man$/i' => 'men',
'/foot$/i' => 'feet',
'/person$/i' => 'people',
'/(quiz)$/i' => '$1zes',
'/^(ox)$/i' => '$1en',
'/(m|l)ouse$/i' => '$1ice',
'/(matr|vert|ind)ix|ex$/i' => '$1ices',
'/(x|ch|ss|sh)$/i' => '$1es',
'/([^aeiouy]|qu)ies$/i' => '$1y',
'/([^aeiouy]|qu)y$/i' => '$1ies',
'/(?:([^f])fe|([lr])f)$/i' => '$1$2ves',
'/sis$/i' => 'ses',
'/([ti])um$/i' => '$1a',
'/(buffal|tomat)o$/i' => '$1oes',
'/(bu)s$/i' => '$1ses',
'/(alias|status)$/i' => '$1es',
'/(octop|vir)us$/i' => '$1i',
'/(ax|test)is$/i' => '$1es',
'/s$/i' => 's',
'/$/' => 's',
)

Rules for pluralizing English nouns.

◆ $_uncountables

array $_uncountables
protected
Initial value:
= array(
'aircraft',
'cannon',
'deer',
'equipment',
'fish',
'information',
'money',
'moose',
'rice',
'series',
'sheep',
'species',
'swine',
)

An array of words with the same singular and plural spellings.

◆ $BIG_PREFIXES [1/3]

$BIG_PREFIXES
Initial value:
= array(
'hundred' => 100,
'thousand' => 1000,
'million' => 1000000,
'billion' => 1000000000,
'trillion' => 1000000000000,
)

◆ $BIG_PREFIXES [2/3]

$BIG_PREFIXES
Initial value:
= array(
'hundert' => 100,
'tausend' => 1000,
'million *' => 1000000,
'milliarde *' => 1000000000,
'billion *' => 1000000000000,
)

◆ $BIG_PREFIXES [3/3]

$BIG_PREFIXES
Initial value:
= array(
'cem' => '100',
'mil' => '1000',
'milhao *' => '1000000',
'milhar de *' => '1000000000',
'biliao *' => '1000000000000',
)

◆ $TEN_PREFIXES [1/3]

* author Chuck Hagenbuch<chuck@horde.org>* license $TEN_PREFIXES
Initial value:
= array(
'twenty' => 20,
'thirty' => 30,
'forty' => 40,
'fourty' => 40,
'fifty' => 50,
'sixty' => 60,
'seventy' => 70,
'eighty' => 80,
'ninety' => 90,
'ninty' => 90,
)

◆ $TEN_PREFIXES [2/3]

* author Chuck Hagenbuch<chuck@horde.org>* author Jan Schneider<jan@horde.org>* license $TEN_PREFIXES
Initial value:
= array(
'zwanzig' => 20,
'dreißig' => 30,
'vierzig' => 40,
'fünfzig' => 50,
'sechzig' => 60,
'siebzig' => 70,
'achtzig' => 80,
'neunzig' => 90,
)

◆ $TEN_PREFIXES [3/3]

* license $TEN_PREFIXES
Initial value:
= array(
'vinte' => '20',
'trinta' => '30',
'quarenta' => '40',
'cinquenta' => '50',
'sessenta' => '60',
'setenta' => '70',
'oitenta' => '80',
'noventa' => '90',
)

◆ IteratorAggregate

* todo Incorporate stuff from Horde_Array IteratorAggregate
Initial value:
{
protected $_array = array()