\League\Floor9design\SearchStringParserSearchStringParser

Class SearchStringParser

Provides a set of parsing tools for search items. if you create a search feature, searching by string can be a minefield. This is a simple tool to help organise this process

Summary

Methods
Properties
Constants
getSearchStrings()
getReturnStrings()
parse()
No public properties found
No constants found
setSearchStrings()
setReturnStrings()
extractLiterals()
splitTerms()
recursiveArrayImplode()
$search_strings
$return_strings
N/A
No private methods found
No private properties found
N/A

Properties

$search_strings

$search_strings : mixed

Type

mixed — Items submitted to parse.

$return_strings

$return_strings : array

Type

array — Array of items returned

Methods

getSearchStrings()

getSearchStrings() : mixed

get Search Strings

Returns

mixed —

$this->search_strings

getReturnStrings()

getReturnStrings() : mixed

get Return Strings

Returns

mixed —

$this->return_strings

parse()

parse(mixed  $mixed) : array

This function "auto parses" the file.

It is meant as catch all, and will attempt to make the best of the data it is given.

This takes a "mixed", auto switching depending on the context. Accepts: string, multi-dimensional array, int, float

Parameters

mixed $mixed

item to parse

Returns

array —

$return

setSearchStrings()

setSearchStrings(mixed  $search_strings) : \League\Floor9design\SearchStringParser\League\Floor9design\SearchStringParser

Set the search strings Protected - should only be used internally

Parameters

mixed $search_strings

Returns

\League\Floor9design\SearchStringParser\League\Floor9design\SearchStringParser —

$this

setReturnStrings()

setReturnStrings(mixed  $return_strings) : \League\Floor9design\SearchStringParser\League\Floor9design\SearchStringParser

Set the search strings Protected - should only be used internally

Parameters

mixed $return_strings

Returns

\League\Floor9design\SearchStringParser\League\Floor9design\SearchStringParser —

$this

extractLiterals()

extractLiterals(string  $string) : array

extractLiterals

Parses a string for literals i.e things in quotes Returns an array of literals. Note - ignores non literal searched items.

Parameters

string $string

string of items to parse

Returns

array —

$array parsed search items

splitTerms()

splitTerms(string  $string) : array

splitTerms

Breaks string items into an array Takes " " as the word break Ignores literals i.e things in quotes Returns an array of items

Parameters

string $string

string of items to parse

Returns

array —

$array parsed search items

recursiveArrayImplode()

recursiveArrayImplode(array  $array, string  $glue = ' ') : string

Converts a multidimensional array to an imploded string

Parameters

array $array

Multidimensional array to implode

string $glue

Glue to implode with together

Returns

string —

Converted string