SpatialMatch
extends BaseMatch
in package
Tags
Table of Contents
Constants
- KEYBOARD_AVERAGE_DEGREES = 4.5957446809
- KEYBOARD_STARTING_POSITION = 94
- KEYPAD_AVERAGE_DEGREES = 5.0666666667
- KEYPAD_STARTING_POSITION = 15
- SHIFTED_CHARACTERS = '~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?'
Properties
- $begin : mixed
- $end : mixed
- $graph : string
- $password : mixed
- $pattern : mixed
- $shiftedCount : int
- $token : mixed
- $turns : int
- $adjacencyGraphs : array<string|int, mixed>
Methods
- __construct() : mixed
- binom() : float
- Calculate binomial coefficient (n choose k).
- findAll() : array<string|int, mixed>
- Find all occurrences of regular expression in a string.
- getAdjacencyGraphs() : array<string|int, mixed>
- Load adjacency graphs.
- getFeedback() : array{'warning': string, "suggestions": string[]}
- Get feedback to a user based on the match.
- getGuesses() : float
- getGuessesLog10() : float
- match() : array<string|int, SpatialMatch>
- Match spatial patterns based on keyboard layouts (e.g. qwerty, dvorak, keypad).
- getMinimumGuesses() : float
- getRawGuesses() : float
- graphMatch() : array<string|int, mixed>
- Match spatial patterns in a adjacency graph.
- indexOf() : int
- Get the index of a string a character first
Constants
KEYBOARD_AVERAGE_DEGREES
public
mixed
KEYBOARD_AVERAGE_DEGREES
= 4.5957446809
KEYBOARD_STARTING_POSITION
public
mixed
KEYBOARD_STARTING_POSITION
= 94
KEYPAD_AVERAGE_DEGREES
public
mixed
KEYPAD_AVERAGE_DEGREES
= 5.0666666667
KEYPAD_STARTING_POSITION
public
mixed
KEYPAD_STARTING_POSITION
= 15
SHIFTED_CHARACTERS
public
mixed
SHIFTED_CHARACTERS
= '~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?'
Properties
$begin
public
mixed
$begin
Tags
$end
public
mixed
$end
Tags
$graph
public
string
$graph
The keyboard layout that the token is a spatial match on.
$password
public
mixed
$password
Tags
$pattern
public
mixed
$pattern
= 'spatial'
$shiftedCount
public
int
$shiftedCount
The number of characters the shift key was held for in the token.
$token
public
mixed
$token
Tags
$turns
public
int
$turns
The number of turns on the keyboard required to complete the token.
$adjacencyGraphs
protected
static array<string|int, mixed>
$adjacencyGraphs
= []
A cache of the adjacency_graphs json file
Methods
__construct()
public
__construct(string $password, int $begin, int $end, string $token[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
- $password : string
- $begin : int
- $end : int
- $token : string
- $params : array<string|int, mixed> = []
-
An array with keys: [graph (required), shifted_count, turns].
binom()
Calculate binomial coefficient (n choose k).
public
static binom(int $n, int $k) : float
Use Binomial::binom() instead
Parameters
- $n : int
- $k : int
Return values
floatfindAll()
Find all occurrences of regular expression in a string.
public
static findAll(string $string, string $regex[, int $offset = 0 ]) : array<string|int, mixed>
Parameters
- $string : string
-
String to search.
- $regex : string
-
Regular expression with captures.
- $offset : int = 0
Return values
array<string|int, mixed> —Array of capture groups. Captures in a group have named indexes: 'begin', 'end', 'token'. e.g. fishfish /(fish)/ array( array( array('begin' => 0, 'end' => 3, 'token' => 'fish'), array('begin' => 0, 'end' => 3, 'token' => 'fish') ), array( array('begin' => 4, 'end' => 7, 'token' => 'fish'), array('begin' => 4, 'end' => 7, 'token' => 'fish') ) )
getAdjacencyGraphs()
Load adjacency graphs.
public
static getAdjacencyGraphs() : array<string|int, mixed>
Return values
array<string|int, mixed>getFeedback()
Get feedback to a user based on the match.
public
getFeedback(bool $isSoleMatch) : array{'warning': string, "suggestions": string[]}
Parameters
- $isSoleMatch : bool
-
Whether this is the only match in the password
Return values
array{'warning': string, "suggestions": string[]}getGuesses()
public
getGuesses() : float
Return values
floatgetGuessesLog10()
public
getGuessesLog10() : float
Return values
floatmatch()
Match spatial patterns based on keyboard layouts (e.g. qwerty, dvorak, keypad).
public
static match(string $password[, array<string|int, mixed> $userInputs = [] ][, array<string|int, mixed> $graphs = [] ]) : array<string|int, SpatialMatch>
Parameters
- $password : string
- $userInputs : array<string|int, mixed> = []
- $graphs : array<string|int, mixed> = []
Return values
array<string|int, SpatialMatch>getMinimumGuesses()
protected
getMinimumGuesses() : float
Return values
floatgetRawGuesses()
protected
getRawGuesses() : float
Return values
floatgraphMatch()
Match spatial patterns in a adjacency graph.
protected
static graphMatch(string $password, array<string|int, mixed> $graph, string $graphName) : array<string|int, mixed>
Parameters
- $password : string
- $graph : array<string|int, mixed>
- $graphName : string
Return values
array<string|int, mixed>indexOf()
Get the index of a string a character first
protected
static indexOf(string $string, string $char) : int
Parameters
- $string : string
- $char : string