Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

(no description)

License: http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
File Size: 239 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