Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

(no description)

License: http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
File Size: 250 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Enum:: (13 methods):
  __construct()
  getValue()
  getKey()
  __toString()
  equals()
  keys()
  values()
  toArray()
  isValid()
  isValidKey()
  search()
  __callStatic()
  jsonSerialize()


Class: Enum  - X-Ref

Base Enum class

Create an enum by implementing this class and adding class constants.

__construct($value)   X-Ref
Creates a new value of some type

param: mixed $value

getValue()   X-Ref

return: mixed

getKey()   X-Ref
Returns the enum key (i.e. the constant name).

return: mixed

__toString()   X-Ref

return: string

equals($variable = null)   X-Ref
Determines if Enum should be considered equal with the variable passed as a parameter.
Returns false if an argument is an object of different class or not an object.

This method is final, for more information read https://github.com/myclabs/php-enum/issues/4

return: bool

keys()   X-Ref
Returns the names (keys) of all constants in the Enum class

return: array

values()   X-Ref
Returns instances of the Enum class of all Enum constants

return: static[] Constant name in key, Enum instance in value

toArray()   X-Ref
Returns all possible values as an array

return: array Constant name in key, constant value in value

isValid($value)   X-Ref
Check if is valid enum value

param: $value
return: bool

isValidKey($key)   X-Ref
Check if is valid enum key

param: $key
return: bool

search($value)   X-Ref
Return key for value

param: $value
return: mixed

__callStatic($name, $arguments)   X-Ref
Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant

param: string $name
param: array  $arguments
return: static

jsonSerialize()   X-Ref
Specify data which should be serialized to JSON. This method returns data that can be serialized by json_encode()
natively.

return: mixed