PHP Class Kahlan\Plugin\Stub

Datei anzeigen Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Property Type Description
$_chain Kahlan\Plugin\Stub\Method[] Method chain.
$_methods Kahlan\Plugin\Stub\Method[] Stubbed methods.
$_needToBePatched integer Stub index counter.
$_registered array Registered stubbed instance/class methods.
$_stubs Kahlan\Plugin\Stub\Method[] Generic stubs.

Public Methods

Method Description
__construct ( mixed $reference ) The Constructor.
find ( mixed $references, string $method = null, array $args = null ) : object | null Finds a stub.
method ( string $path, string $closure = null ) : Method Stubs a method.
methods ( array $name = [] ) : Method[] Getd/Setd stubs for methods or get stubbed methods array.
on ( object | string $reference ) : self Stubs class methods.
registered ( mixed $hash = null ) : boolean | array Checks if a stub has been registered for a hash
reset ( string $reference = null ) Clears the registered references.
where ( $requirements = [] ) : self Set arguments requirement indexed by method name.

Protected Methods

Method Description
_reference ( mixed $reference ) Return the actual reference which must be used.

Method Details

__construct() public method

The Constructor.
public __construct ( mixed $reference )
$reference mixed An instance or a fully-namespaced class name.

_reference() protected method

Return the actual reference which must be used.
protected _reference ( mixed $reference )
$reference mixed An instance or a fully-namespaced class name.

find() public static method

Finds a stub.
public static find ( mixed $references, string $method = null, array $args = null ) : object | null
$references mixed An instance or a fully namespaced class name. or an array of that.
$method string The method name.
$args array The required arguments.
return object | null Return the subbed method or `null` if not founded.

method() public method

Stubs a method.
public method ( string $path, string $closure = null ) : Method
$path string Method name or array of stubs where key are method names and values the stubs.
$closure string The stub implementation.
return Kahlan\Plugin\Stub\Method The created array of method instances.

methods() public method

Getd/Setd stubs for methods or get stubbed methods array.
public methods ( array $name = [] ) : Method[]
$name array An array of method names.
return Kahlan\Plugin\Stub\Method[] Return the array of stubbed methods.

on() public static method

Stubs class methods.
public static on ( object | string $reference ) : self
$reference object | string An instance or a fully-namespaced class name.
return self The Stub instance.

registered() public static method

Checks if a stub has been registered for a hash
public static registered ( mixed $hash = null ) : boolean | array
$hash mixed An instance hash or a fully namespaced class name.
return boolean | array

reset() public static method

Clears the registered references.
public static reset ( string $reference = null )
$reference string An instance or a fully namespaced class name or `null` to clear all.

where() public method

Set arguments requirement indexed by method name.
public where ( $requirements = [] ) : self
return self

Property Details

$_chain protected_oe property

Method chain.
protected Method[],Kahlan\Plugin\Stub $_chain
return Kahlan\Plugin\Stub\Method[]

$_methods protected_oe property

Stubbed methods.
protected Method[],Kahlan\Plugin\Stub $_methods
return Kahlan\Plugin\Stub\Method[]

$_needToBePatched protected_oe property

Stub index counter.
protected int $_needToBePatched
return integer

$_registered protected_oe static_oe property

Registered stubbed instance/class methods.
protected static array $_registered
return array

$_stubs protected_oe property

Generic stubs.
protected Method[],Kahlan\Plugin\Stub $_stubs
return Kahlan\Plugin\Stub\Method[]