PHP Class Bravo3\Orm\Drivers\Common\WorkerPool

Show file Open project: bravo3/orm Class Usage Examples

Protected Properties

Property Type Description
$worker_data mixed
$workers Bravo3\Orm\Drivers\Common\WorkerInterface[]

Public Methods

Method Description
__construct ( array $workers = [], mixed $worker_data = null ) Creates a lazy-loading worker pool
addWorker ( string $name, Bravo3\Orm\Drivers\Common\WorkerInterface | string $worker ) Adds a worker to the pool
execute ( Command $command ) : mixed Have the appropriate worker execute a command
hasWorker ( string $name ) : boolean Check if we have a worker for a given command

Protected Methods

Method Description
getWorker ( $name ) : Bravo3\Orm\Drivers\Common\WorkerInterface Get a worker, lazy-loading as required

Method Details

__construct() public method

If any of the workers passed in $workers are a string, it is considered the class name for a WorkerInterface that is lazy-loaded on demand.
public __construct ( array $workers = [], mixed $worker_data = null )
$workers array Preload the pool with some workers
$worker_data mixed Data to pass to worker constructors

addWorker() public method

Adds a worker to the pool
public addWorker ( string $name, Bravo3\Orm\Drivers\Common\WorkerInterface | string $worker )
$name string Command name the worker fulfills
$worker Bravo3\Orm\Drivers\Common\WorkerInterface | string Worker object or class name

execute() public method

Have the appropriate worker execute a command
public execute ( Command $command ) : mixed
$command Command
return mixed

getWorker() protected method

Get a worker, lazy-loading as required
protected getWorker ( $name ) : Bravo3\Orm\Drivers\Common\WorkerInterface
$name
return Bravo3\Orm\Drivers\Common\WorkerInterface

hasWorker() public method

Check if we have a worker for a given command
public hasWorker ( string $name ) : boolean
$name string
return boolean

Property Details

$worker_data protected property

protected mixed $worker_data
return mixed

$workers protected property

protected WorkerInterface[],Bravo3\Orm\Drivers\Common $workers
return Bravo3\Orm\Drivers\Common\WorkerInterface[]