pssht  latest
SSH server library written in PHP
fpoirotte\Pssht\Algorithms Class Reference

Public Member Functions

 __clone ()
 Prevent cloning of the singleton.
 
 getAlgorithms ($type)
 
 getClass ($type, $name)
 
 getClasses ($type)
 
 register ($type, $class)
 
 restore ($type, $name)
 
 unregister ($type, $name)
 

Static Public Member Functions

static factory ()
 
static sortAlgorithms ($a, $b)
 

Protected Member Functions

 getValidAlgorithm ($class)
 
 getValidClass ($type, $name)
 

Protected Attributes

 $algos
 Array with currently available algorithms.
 
 $interfaces
 Mapping between algorithm types and their corresponding interface.
 
 $savedAlgos
 A backup of $algos when it was first populated.
 

Private Member Functions

 __construct ()
 

Detailed Description

A singleton that gives access to supported algorithms.

Definition at line 17 of file Algorithms.php.

Constructor & Destructor Documentation

fpoirotte\Pssht\Algorithms::__construct ( )
private

Construct the only instance of this singleton.

Definition at line 31 of file Algorithms.php.

References fpoirotte\Pssht\Algorithms\$algos, fpoirotte\Pssht\Algorithms\getValidAlgorithm(), and fpoirotte\Pssht\Algorithms\getValidClass().

Member Function Documentation

fpoirotte\Pssht\Algorithms::getAlgorithms (   $type)

Get a list of all registered algorithms with the given type.

Parameters
string$typeType of algorithms to retrieve.
Return values
arrayA list with the names of all the algorithms currently registered with the given type.

Definition at line 311 of file Algorithms.php.

fpoirotte\Pssht\Algorithms::getClass (   $type,
  $name 
)

Get the class responsible for providing the algorithm with the given type and name.

Parameters
string$typeType of algorithm to retrieve.
string$nameName of the algorithm.
Return values
stringFull name (with namespace) of the class providing the given algorithm.
nullNo class provides an algorithm with the given type and name.

Definition at line 356 of file Algorithms.php.

fpoirotte\Pssht\Algorithms::getClasses (   $type)

Get a list of all registered classes with the given type.

Parameters
string$typeType of algorithms to retrieve.
Return values
arrayA list with the names of the classes currently registered providing algorithms of the given type.

Definition at line 330 of file Algorithms.php.

fpoirotte\Pssht\Algorithms::getValidAlgorithm (   $class)
protected

Check for valid algorithm names.

Parameters
string$className of the class whose algorithm name must be checked.
Return values
stringThe class' algorithm name.
nullNo valid algorithm name for the given class.

Definition at line 195 of file Algorithms.php.

Referenced by fpoirotte\Pssht\Algorithms\__construct(), and fpoirotte\Pssht\Algorithms\register().

fpoirotte\Pssht\Algorithms::getValidClass (   $type,
  $name 
)
protected

Check for valid classnames.

Parameters
string$typeExpected type of class (algorithm name).
string$nameName of the class.
Return values
stringFull classname (with namespace).
nullNo valid class found with this type and name.

Definition at line 129 of file Algorithms.php.

Referenced by fpoirotte\Pssht\Algorithms\__construct().

fpoirotte\Pssht\Algorithms::register (   $type,
  $class 
)

Register a new algorithm.

Parameters
string$typeType of algorithm provided by the class.
string | object$classClass or object that provides the algorithm.
Return values
AlgorithmsReturns the singleton.
Note
A class registered with this method will overwrite any previously registered class with the same algorithm name.

Definition at line 229 of file Algorithms.php.

References fpoirotte\Pssht\Algorithms\getValidAlgorithm().

fpoirotte\Pssht\Algorithms::restore (   $type,
  $name 
)

Restore an algorithm.

Reset the class in charge of providing a given algorithm to its initial value.

Parameters
string$typeAlgorithm type.
string$nameName of the algorithm to restore.
Return values
AlgorithmsReturns the singleton.

Definition at line 289 of file Algorithms.php.

static fpoirotte\Pssht\Algorithms::sortAlgorithms (   $a,
  $b 
)
static

Sort algorithms based on preferences.

Parameters
string$aName of the first algorithm.
string$bName of the second algorithm.
Return values
intAn integer that is less than zero if the first algorithm should be preferred, equal to zero if both algorithms have the same preference and greater than zero when the second algorithm should be preferred.

Definition at line 385 of file Algorithms.php.

fpoirotte\Pssht\Algorithms::unregister (   $type,
  $name 
)

Unregister an algorithm.

Parameters
string$typeAlgorithm type.
string$nameName of the algorithm to unregister.
Return values
AlgorithmsReturns the singleton.

Definition at line 262 of file Algorithms.php.


The documentation for this class was generated from the following file: