CardDAV Client Library

TextMatch
in package
implements XmlSerializable

Represents XML urn:ietf:params:xml:ns:carddav:text-match elements as PHP objects (RFC 6352).

From RFC 6352: The CARDDAV:text-match XML element specifies text used for a substring match against the vCard property or parameter value specified in an address book REPORT request.

The "collation" attribute is used to select the collation that the server MUST use for character string matching. In the absence of this attribute, the server MUST use the "i;unicode-casemap" collation.

The "negate-condition" attribute is used to indicate that this test returns a match if the text matches, when the attribute value is set to "no", or return a match if the text does not match, if the attribute value is set to "yes". For example, this can be used to match components with a CATEGORIES property not set to PERSON.

The "match-type" attribute is used to indicate the type of match operation to use. Possible choices are:

  • "equals" - an exact match to the target string
  • "contains" - a substring match, matching anywhere within the target string
  • "starts-with" - a substring match, matching only at the start of the target string
  • "ends-with" - a substring match, matching only at the end of the target string
    <!ELEMENT text-match (#PCDATA)>
    <!-- PCDATA value: string -->
    <!ATTLIST text-match
       collation CDATA "i;unicode-casemap"
       negate-condition (yes | no) "no"
       match-type (equals|contains|starts-with|ends-with) "contains">

Interfaces, Classes and Traits

XmlSerializable

Table of Contents

$collation  : string
Collation to use for comparison (currently constant)
$invertMatch  : bool
Whether to invert the result of the match
$matchType  : string
The type of text match to apply
$needle  : string
The string to match for
__construct()  : mixed
Constructs a TextMatch element.
xmlAttributes()  : array<string, string>
Produces a list of attributes for this filter suitable to pass to a Sabre XML Writer.
xmlSerialize()  : void
This function encodes the element's value (not the element itself!) to the given XML writer.
xmlSerializeElement()  : void
This function serializes the full element to the given XML writer.

Properties

$collation

Collation to use for comparison (currently constant)

public string $collation = 'i;unicode-casemap'
Tags
psalm-readonly

$invertMatch

Whether to invert the result of the match

public bool $invertMatch = false
Tags
psalm-readonly

$matchType

The type of text match to apply

public string $matchType = 'contains'
Tags
psalm-var

'equals' | 'contains' | 'starts-with' | 'ends-with'

psalm-readonly

$needle

The string to match for

public string $needle = ''
Tags
psalm-readonly

Methods

__construct()

Constructs a TextMatch element.

public __construct(string $matchSpec) : mixed

The match is specified in a string form that encodes all properties of the match.

  • The match string must be enclosed in / (e.g. /foo/)
  • The / character has no special meaning other than to separate the match string from modifiers. No escaping is needed if / appears as part of the match string (e.g. /http:/// matches for "http://").
  • To invert the match, insert ! before the initial / (e.g. !/foo/)
  • The default match type is "contains" semantics. If you want to match the start or end of the property value, or perform an exact match, use the ^/$/= modifiers after the final slash. Examples:
    • /abc/=: The property/parameter must match the value "abc" exactly
    • /abc/^: The property/parameter must start with "abc"
    • /abc/$: The property/parameter must end with "abc"
    • /abc/: The property/parameter must contain "abc"
  • The matching is performed case insensitive with UTF8 character set (this is currently not changeable).
Parameters
$matchSpec : string

Specification of the text match that encodes all properties of the match.

Return values
mixed

xmlAttributes()

Produces a list of attributes for this filter suitable to pass to a Sabre XML Writer.

public xmlAttributes() : array<string, string>
Return values
array<string, string>

A list of attributes (attrname => attrvalue)

xmlSerialize()

This function encodes the element's value (not the element itself!) to the given XML writer.

public xmlSerialize(Writer $writer) : void
Parameters
$writer : Writer
Return values
void

xmlSerializeElement()

This function serializes the full element to the given XML writer.

public xmlSerializeElement(Writer $writer) : void
Parameters
$writer : Writer
Return values
void

Search results