Utility methods for Erebot.
More...
|
|
const | VSTATIC_CONST = 0x01 |
| | Return the value of a constant.
|
| |
|
const | VSTATIC_VAR = 0x02 |
| | Return the value of a static variable.
|
| |
Utility methods for Erebot.
Definition at line 27 of file Utils.php.
| static Erebot\Utils::getCallerObject |
( |
| ) |
|
|
static |
Returns the object (if any) associated with the method that called the method which called Erebot::Utils::getCallerObject().
Consider the following example:
class Foo {
public function bar() {
}
}
class Bar {
public function baz() {
$foo = new Foo();
$foo->bar();
}
}
$bar = new Bar();
$bar->baz();
- Return values
-
Definition at line 60 of file Utils.php.
| static Erebot\Utils::getVStatic |
( |
|
$class, |
|
|
|
$name, |
|
|
|
$source = self::VSTATIC_CONST |
|
) |
| |
|
static |
Returns some static data from a class/object.
- Parameters
-
| string | object | $class | Either the name of a class or an instance of a class from which the static data will be retrieved. |
| string | $name | The name of the static data to return. |
| opaque | $source | (optional) The kind of static data to look for (either a constant or a static variable). Use Erebot::Utils::VSTATIC_CONST or Erebot::Utils::VSTATIC_VAR to select a specific source of data. The default is to look for a constant (same as if $source had been set to Erebot::Utils::VSTATIC_CONST). |
- Return values
-
| mixed | The content of the static data whose name is $name. |
- Exceptions
-
Definition at line 218 of file Utils.php.
| static Erebot\Utils::humanSize |
( |
|
$size, |
|
|
|
$max = null, |
|
|
|
$system = 'si', |
|
|
|
$retstring = '%01.2f %s' |
|
) |
| |
|
static |
| static Erebot\Utils::isUTF8 |
( |
|
$text | ) |
|
|
static |
Can be used to determine if a string contains a sequence of valid UTF-8 encoded codepoints.
- Parameters
-
| string | $text | Some text to test for UTF-8 correctness. |
- Return values
-
| true | The $text contains a valid UTF-8 sequence. |
| false | The $text is not a valid UTF-8 sequence. |
Definition at line 80 of file Utils.php.
| static Erebot\Utils::parseHumanSize |
( |
|
$humanSize | ) |
|
|
static |
Does the opposite of Erebot::Utils::humanSize. That is, this method takes some size expressed in a human-friendly fashion and returns the actual size.
- Parameters
-
| string | $humanSize | User-friendly size. |
- Return values
-
| mixed | The actual size as an integer or null if the size could not be determined. |
Definition at line 319 of file Utils.php.
Referenced by Erebot\Core\handleSignal().
| static Erebot\Utils::stringifiable |
( |
|
$item | ) |
|
|
static |
| static Erebot\Utils::toUTF8 |
( |
|
$text, |
|
|
|
$from = 'iso-8859-1' |
|
) |
| |
|
static |
Transforms the given text into a UTF-8 sequence.
- Parameters
-
| string | $text | The text to convert into a UTF-8 sequence. |
| null | string | $from | (optional) The encoding currently used by $text. A default of "iso-8859-1" is assumed. |
- Return values
-
| string | The original text, converted into UTF-8. |
- Exceptions
-
| Erebot::NotImplementedException | Raised if no method could be found to convert the text. See also the notes for information on how to avoid this exception being raised. |
- Note
- This method tries different technics to convert the text. If despite its best efforts, it still fails, you may consider installing one of PHP's extension for "Human Language and Character
Encoding Support".
Definition at line 124 of file Utils.php.
Referenced by Erebot\LineIO\getLine().
The documentation for this class was generated from the following file: