JsonApiSpec
class JsonApiSpec (View source)
| internal | JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it. |
Defines constants used for compliance with the JSON:API specification.
Constants
| SUPPORTED_SPECIFICATION_VERSION |
The minimum supported specification version. |
| SUPPORTED_SPECIFICATION_PERMALINK |
The URI of the supported specification document. |
| MEMBER_NAME_GLOBALLY_ALLOWED_CHARACTER_CLASS |
Member name: globally allowed characters. U+0080 and above (non-ASCII Unicode characters) are allowed, but are not URL-safe. It is RECOMMENDED to not use them. A character class, for use in regular expressions. |
| MEMBER_NAME_INNER_ALLOWED_CHARACTERS |
Member name: allowed characters except as the first or last character. Space (U+0020) is allowed, but is not URL-safe. It is RECOMMENDED to not use it. A character class, for use in regular expressions. |
| MEMBER_NAME_REGEXP |
Regular expression to check the validity of a member name. |
| RESERVED_QUERY_PARAMETERS |
The reserved (official) query parameters. |
| VERSION_QUERY_PARAMETER |
The query parameter for providing a version (revision) value. |
Methods
Checks whether the given member name is valid.
Gets the reserved (official) JSON:API query parameters.
Checks whether the given custom query parameter name is valid.
Details
static bool
isValidMemberName(string $member_name)
Checks whether the given member name is valid.
Requirements:
- it MUST contain at least one character.
- it MUST contain only the allowed characters
- it MUST start and end with a "globally allowed character"
static string[]
getReservedQueryParameters()
Gets the reserved (official) JSON:API query parameters.
static bool
isValidCustomQueryParameter(string $custom_query_parameter_name)
Checks whether the given custom query parameter name is valid.
A custom query parameter name must be a valid member name, with one additional requirement: it MUST contain at least one non a-z character.
Requirements:
- it MUST contain at least one character.
- it MUST contain only the allowed characters
- it MUST start and end with a "globally allowed character"
- it MUST contain at least none a-z (U+0061 to U+007A) character
It is RECOMMENDED that a hyphen (U+002D), underscore (U+005F) or capital letter is used (i.e. camelCasing).