114 lines
3.5 KiB
YAML
114 lines
3.5 KiB
YAML
name: ArrayChoiceList
|
|
class_comment: '# * A list of choices with arbitrary data types.
|
|
|
|
# *
|
|
|
|
# * The user of this class is responsible for assigning string values to the
|
|
|
|
# * choices and for their uniqueness.
|
|
|
|
# * Both the choices and their values are passed to the constructor.
|
|
|
|
# * Each choice must have a corresponding value (with the same key) in
|
|
|
|
# * the values array.
|
|
|
|
# *
|
|
|
|
# * @author Bernhard Schussek <bschussek@gmail.com>'
|
|
dependencies: []
|
|
properties: []
|
|
methods:
|
|
- name: __construct
|
|
visibility: public
|
|
parameters:
|
|
- name: choices
|
|
- name: value
|
|
default: 'null'
|
|
comment: "# * A list of choices with arbitrary data types.\n# *\n# * The user of\
|
|
\ this class is responsible for assigning string values to the\n# * choices and\
|
|
\ for their uniqueness.\n# * Both the choices and their values are passed to the\
|
|
\ constructor.\n# * Each choice must have a corresponding value (with the same\
|
|
\ key) in\n# * the values array.\n# *\n# * @author Bernhard Schussek <bschussek@gmail.com>\n\
|
|
# */\n# class ArrayChoiceList implements ChoiceListInterface\n# {\n# protected\
|
|
\ array $choices;\n# \n# /**\n# * The values indexed by the original keys.\n#\
|
|
\ */\n# protected array $structuredValues;\n# \n# /**\n# * The original keys of\
|
|
\ the choices array.\n# */\n# protected array $originalKeys;\n# protected ?\\\
|
|
Closure $valueCallback = null;\n# \n# /**\n# * Creates a list with the given choices\
|
|
\ and values.\n# *\n# * The given choice array must have the same array keys as\
|
|
\ the value array.\n# *\n# * @param iterable $choices The selectable choices\n\
|
|
# * @param callable|null $value The callable for creating the value\n# * \
|
|
\ for a choice. If `null` is passed,\n# * \
|
|
\ incrementing integers are used as\n# * \
|
|
\ values"
|
|
- name: getChoices
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getValues
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getStructuredValues
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getOriginalKeys
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getChoicesForValues
|
|
visibility: public
|
|
parameters:
|
|
- name: values
|
|
comment: null
|
|
- name: getValuesForChoices
|
|
visibility: public
|
|
parameters:
|
|
- name: choices
|
|
comment: null
|
|
- name: flatten
|
|
visibility: protected
|
|
parameters:
|
|
- name: choices
|
|
- name: value
|
|
- name: '&$choicesByValues'
|
|
- name: '&$keysByValues'
|
|
- name: '&$structuredValues'
|
|
comment: '# * Flattens an array into the given output variables.
|
|
|
|
# *
|
|
|
|
# * @param array $choices The array to flatten
|
|
|
|
# * @param callable $value The callable for generating choice values
|
|
|
|
# * @param array|null $choicesByValues The flattened choices indexed by the
|
|
|
|
# * corresponding values
|
|
|
|
# * @param array|null $keysByValues The original keys indexed by the
|
|
|
|
# * corresponding values
|
|
|
|
# * @param array|null $structuredValues The values indexed by the original keys
|
|
|
|
# *
|
|
|
|
# * @internal'
|
|
- name: castableToString
|
|
visibility: private
|
|
parameters:
|
|
- name: choices
|
|
- name: '&$cache'
|
|
default: '[]'
|
|
comment: '# * Checks whether the given choices can be cast to strings without
|
|
|
|
# * generating duplicates.
|
|
|
|
# * This method is responsible for preventing conflict between scalar values
|
|
|
|
# * and the empty value.'
|
|
traits: []
|
|
interfaces:
|
|
- ChoiceListInterface
|