PHP Class SimilarText\Finder

Mostra file Open project: rap2hpoutre/similar-text-finder Class Usage Examples

Protected Properties

Property Type Description
$haystack Haystack
$needle Needle
$sorted_haystack Hold the sorted comparison stack.

Public Methods

Method Description
__construct ( string $needle, array $haystack ) : void Finder constructor.
all ( ) : array Return all strings in sorted match order.
first ( ) : mixed Return the highest match.
hasExactMatch ( ) : boolean Return whether there is an exact match.

Protected Methods

Method Description
levenshteinUtf8 ( string $string1, string $string2 ) : integer Calculate the levenshtein distance between two strings.
sortHaystack ( ) : void Sort Haystack.
utf8ToExtendedAscii ( string $str, array &$map ) : string Ensure a string only uses ascii characters.

Method Details

__construct() public method

Finder constructor.
public __construct ( string $needle, array $haystack ) : void
$needle string
$haystack array
return void

all() public method

Return all strings in sorted match order.
public all ( ) : array
return array

first() public method

Return the highest match.
public first ( ) : mixed
return mixed

hasExactMatch() public method

Return whether there is an exact match.
public hasExactMatch ( ) : boolean
return boolean

levenshteinUtf8() protected method

Calculate the levenshtein distance between two strings.
protected levenshteinUtf8 ( string $string1, string $string2 ) : integer
$string1 string
$string2 string
return integer

sortHaystack() protected method

Sort Haystack.
protected sortHaystack ( ) : void
return void

utf8ToExtendedAscii() protected method

Ensure a string only uses ascii characters.
protected utf8ToExtendedAscii ( string $str, array &$map ) : string
$str string
$map array
return string

Property Details

$haystack protected_oe property

Haystack
protected $haystack

$needle protected_oe property

Needle
protected $needle

$sorted_haystack protected_oe property

Hold the sorted comparison stack.
protected $sorted_haystack