PHP Class Zumba\Swivel\Builder

Inheritance: implements Zumba\Swivel\BuilderInterface, use trait Psr\Log\LoggerAwareTrait
Show file Open project: zumba/swivel Class Usage Examples

Protected Properties

Property Type Description
$args array Arguments to be passed to the behavior.
$behavior Behavior The behavior to be executed.
$bucket Zumba\Swivel\BucketInterface The user's Bucket.
$defaultWaived boolean Whether this feature requires a default behavior.
$metrics Zumba\Swivel\MetricsInterface A Metrics object.
$slug string Parent Feature slug.

Public Methods

Method Description
__construct ( string $slug, Zumba\Swivel\BucketInterface $bucket ) Zumba\Swivel\Builder.
addBehavior ( string $slug, mixed $strategy, array $args = [] ) : Zumba\Swivel\BuilderInterface Add a behavior to be executed later.
addValue ( string $slug, mixed $value ) : Zumba\Swivel\BuilderInterface Add a value to be returned when the builder is executed.
defaultBehavior ( callable $strategy, array $args = [] ) : Zumba\Swivel\BuilderInterface Add a default behavior.
defaultValue ( mixed $value ) : Zumba\Swivel\BuilderInterface Add a default value.
execute ( ) : mixed Execute the feature.
getBehavior ( string $slug, callable $strategy = self::DEFAULT_STRATEGY ) : Zumba\Swivel\BehaviorInterface Create and return a new Behavior.
noDefault ( ) : Zumba\Swivel\BuilderInterface Waive the default behavior for this feature.
setMetrics ( Zumba\Swivel\MetricsInterface $metrics ) Set a metrics object.

Protected Methods

Method Description
setBehavior ( Behavior $behavior, array $args = [] ) Set the behavior and it's args.
startMetrics ( string $behaviorSlug ) Start collecting metrics about this feature.
stopMetrics ( string $behaviorSlug ) Stop collecting metrics about this feature.

Method Details

__construct() public method

Zumba\Swivel\Builder.
public __construct ( string $slug, Zumba\Swivel\BucketInterface $bucket )
$slug string
$bucket Zumba\Swivel\BucketInterface

addBehavior() public method

Behavior will only be added if it is enabled for the user's bucket.
public addBehavior ( string $slug, mixed $strategy, array $args = [] ) : Zumba\Swivel\BuilderInterface
$slug string
$strategy mixed
$args array
return Zumba\Swivel\BuilderInterface

addValue() public method

Value will only be returned if it is enabled for the user's bucket.
public addValue ( string $slug, mixed $value ) : Zumba\Swivel\BuilderInterface
$slug string
$value mixed
return Zumba\Swivel\BuilderInterface

defaultBehavior() public method

Will be used if all other behaviors and values are not enabled for the user's bucket.
public defaultBehavior ( callable $strategy, array $args = [] ) : Zumba\Swivel\BuilderInterface
$strategy callable
$args array
return Zumba\Swivel\BuilderInterface

defaultValue() public method

Will be used if all other behaviors and values are not enabled for the user's bucket.
public defaultValue ( mixed $value ) : Zumba\Swivel\BuilderInterface
$value mixed
return Zumba\Swivel\BuilderInterface

execute() public method

Execute the feature.
public execute ( ) : mixed
return mixed

getBehavior() public method

The $strategy parameter must be a valid callable.
public getBehavior ( string $slug, callable $strategy = self::DEFAULT_STRATEGY ) : Zumba\Swivel\BehaviorInterface
$slug string
$strategy callable
return Zumba\Swivel\BehaviorInterface

noDefault() public method

Waive the default behavior for this feature.
public noDefault ( ) : Zumba\Swivel\BuilderInterface
return Zumba\Swivel\BuilderInterface

setBehavior() protected method

Set the behavior and it's args.
protected setBehavior ( Behavior $behavior, array $args = [] )
$behavior Behavior
$args array

setMetrics() public method

Set a metrics object.
public setMetrics ( Zumba\Swivel\MetricsInterface $metrics )
$metrics Zumba\Swivel\MetricsInterface

startMetrics() protected method

Start collecting metrics about this feature.
protected startMetrics ( string $behaviorSlug )
$behaviorSlug string

stopMetrics() protected method

Stop collecting metrics about this feature.
protected stopMetrics ( string $behaviorSlug )
$behaviorSlug string

Property Details

$args protected property

Arguments to be passed to the behavior.
protected array $args
return array

$behavior protected property

The behavior to be executed.
protected Behavior,Zumba\Swivel $behavior
return Behavior

$bucket protected property

The user's Bucket.
protected BucketInterface,Zumba\Swivel $bucket
return Zumba\Swivel\BucketInterface

$defaultWaived protected property

Whether this feature requires a default behavior.
protected bool $defaultWaived
return boolean

$metrics protected property

A Metrics object.
protected MetricsInterface,Zumba\Swivel $metrics
return Zumba\Swivel\MetricsInterface

$slug protected property

Parent Feature slug.
protected string $slug
return string