167 lines
4 KiB
YAML
167 lines
4 KiB
YAML
name: HeaderUtils
|
|
class_comment: '# * HTTP header utility functions.
|
|
|
|
# *
|
|
|
|
# * @author Christian Schmidt <github@chsc.dk>'
|
|
dependencies: []
|
|
properties: []
|
|
methods:
|
|
- name: __construct
|
|
visibility: private
|
|
parameters: []
|
|
comment: "# * HTTP header utility functions.\n# *\n# * @author Christian Schmidt\
|
|
\ <github@chsc.dk>\n# */\n# class HeaderUtils\n# {\n# public const DISPOSITION_ATTACHMENT\
|
|
\ = 'attachment';\n# public const DISPOSITION_INLINE = 'inline';\n# \n# /**\n\
|
|
# * This class should not be instantiated."
|
|
- name: split
|
|
visibility: public
|
|
parameters:
|
|
- name: header
|
|
- name: separators
|
|
comment: '# * Splits an HTTP header by one or more separators.
|
|
|
|
# *
|
|
|
|
# * Example:
|
|
|
|
# *
|
|
|
|
# * HeaderUtils::split(''da, en-gb;q=0.8'', '',;'')
|
|
|
|
# * # returns [[''da''], [''en-gb'', ''q=0.8'']]
|
|
|
|
# *
|
|
|
|
# * @param string $separators List of characters to split on, ordered by
|
|
|
|
# * precedence, e.g. '','', '';='', or '',;=''
|
|
|
|
# *
|
|
|
|
# * @return array Nested array with as many levels as there are characters in
|
|
|
|
# * $separators'
|
|
- name: combine
|
|
visibility: public
|
|
parameters:
|
|
- name: parts
|
|
comment: '# * Combines an array of arrays into one associative array.
|
|
|
|
# *
|
|
|
|
# * Each of the nested arrays should have one or two elements. The first
|
|
|
|
# * value will be used as the keys in the associative array, and the second
|
|
|
|
# * will be used as the values, or true if the nested array only contains one
|
|
|
|
# * element. Array keys are lowercased.
|
|
|
|
# *
|
|
|
|
# * Example:
|
|
|
|
# *
|
|
|
|
# * HeaderUtils::combine([[''foo'', ''abc''], [''bar'']])
|
|
|
|
# * // => [''foo'' => ''abc'', ''bar'' => true]'
|
|
- name: toString
|
|
visibility: public
|
|
parameters:
|
|
- name: assoc
|
|
- name: separator
|
|
comment: '# * Joins an associative array into a string for use in an HTTP header.
|
|
|
|
# *
|
|
|
|
# * The key and value of each entry are joined with ''='', and all entries
|
|
|
|
# * are joined with the specified separator and an additional space (for
|
|
|
|
# * readability). Values are quoted if necessary.
|
|
|
|
# *
|
|
|
|
# * Example:
|
|
|
|
# *
|
|
|
|
# * HeaderUtils::toString([''foo'' => ''abc'', ''bar'' => true, ''baz'' =>
|
|
''a b c''], '','')
|
|
|
|
# * // => ''foo=abc, bar, baz="a b c"'''
|
|
- name: quote
|
|
visibility: public
|
|
parameters:
|
|
- name: s
|
|
comment: '# * Encodes a string as a quoted string, if necessary.
|
|
|
|
# *
|
|
|
|
# * If a string contains characters not allowed by the "token" construct in
|
|
|
|
# * the HTTP specification, it is backslash-escaped and enclosed in quotes
|
|
|
|
# * to match the "quoted-string" construct.'
|
|
- name: unquote
|
|
visibility: public
|
|
parameters:
|
|
- name: s
|
|
comment: '# * Decodes a quoted string.
|
|
|
|
# *
|
|
|
|
# * If passed an unquoted string that matches the "token" construct (as
|
|
|
|
# * defined in the HTTP specification), it is passed through verbatim.'
|
|
- name: makeDisposition
|
|
visibility: public
|
|
parameters:
|
|
- name: disposition
|
|
- name: filename
|
|
- name: filenameFallback
|
|
default: ''''''
|
|
comment: '# * Generates an HTTP Content-Disposition field-value.
|
|
|
|
# *
|
|
|
|
# * @param string $disposition One of "inline" or "attachment"
|
|
|
|
# * @param string $filename A unicode string
|
|
|
|
# * @param string $filenameFallback A string containing only ASCII characters
|
|
that
|
|
|
|
# * is semantically equivalent to $filename. If
|
|
the filename is already ASCII,
|
|
|
|
# * it can be omitted, or just copied from $filename
|
|
|
|
# *
|
|
|
|
# * @throws \InvalidArgumentException
|
|
|
|
# *
|
|
|
|
# * @see RFC 6266'
|
|
- name: parseQuery
|
|
visibility: public
|
|
parameters:
|
|
- name: query
|
|
- name: ignoreBrackets
|
|
default: 'false'
|
|
- name: separator
|
|
default: '''&'''
|
|
comment: '# * Like parse_str(), but preserves dots in variable names.'
|
|
- name: groupParts
|
|
visibility: private
|
|
parameters:
|
|
- name: matches
|
|
- name: separators
|
|
- name: first
|
|
default: 'true'
|
|
comment: null
|
|
traits: []
|
|
interfaces: []
|