Keyword
in package
Quote-aware keyword scanning class
Tags
Table of Contents
Methods
- indexOf() : int|false
- Find the position of the first occurrence of $needle in $haystack, ignoring any occurrence found inside a single-quoted, double-quoted or backtick-quoted span.
- split() : array<string|int, mixed>
- Split an expression string on AND/OR (case-sensitive, word-boundary-aware), ignoring matches inside a quoted span. Returns the same alternating [expr, 'AND'|'OR', expr, ...] shape as the preg_split call it replaces.
- matchKeywordAt() : string|null
- Determine if one of the given keywords matches exactly (case-sensitive) at the given position, bounded by non-alphanumeric/non-underscore characters on both sides.
Methods
indexOf()
Find the position of the first occurrence of $needle in $haystack, ignoring any occurrence found inside a single-quoted, double-quoted or backtick-quoted span.
public
static indexOf(string $haystack, string $needle[, int $offset = 0 ][, bool $caseInsensitive = true ]) : int|false
Parameters
- $haystack : string
- $needle : string
- $offset : int = 0
- $caseInsensitive : bool = true
Return values
int|falsesplit()
Split an expression string on AND/OR (case-sensitive, word-boundary-aware), ignoring matches inside a quoted span. Returns the same alternating [expr, 'AND'|'OR', expr, ...] shape as the preg_split call it replaces.
public
static split(string $expression) : array<string|int, mixed>
Parameters
- $expression : string
Return values
array<string|int, mixed>matchKeywordAt()
Determine if one of the given keywords matches exactly (case-sensitive) at the given position, bounded by non-alphanumeric/non-underscore characters on both sides.
protected
static matchKeywordAt(string $expression, int $position, array<string|int, mixed> $keywords) : string|null
Parameters
- $expression : string
- $position : int
- $keywords : array<string|int, mixed>