A solver for feature constraints.

A \FeaturePhp\Model\Model can contain complex relationships between features that a configuration needs to satisfy. These relationships are represented as feature and cross-tree constraints, which in turn are represented as propositional formulas. A constraint solver extracts all constraints from a feature model and uses them to build a solver (i.e. a complex formula, see \FeaturePhp\Helper\Logic). This formula can then be evaluated for a \FeaturePhp\Model\Configuration to determine its validity.

package Default

 Methods

Creates a constraint solver.

__construct(\FeaturePhp\Model\Model $model) 

Every feature constraint is translated into a formula using the semantics defined in Chapter 2 of "Feature-Oriented Software Product Lines" (see http://www.springer.com/de/book/9783642375200). Every cross-tree constraint is already a formula and only needs to be transformed from an XML representation to a formula (i.e. callable). Finally, all formulas are conjoined to build a solver.

Parameters

$model

\FeaturePhp\Model\Model

Returns formulas for all constraints from the feature model.

getConstraints() : array<mixed,callable>

Returns

array<mixed,callable>

Returns the feature model the constraint solver relates to.

getModel() : \FeaturePhp\Model\Model

Returns

\FeaturePhp\Model\Model

Returns one formula that validates all feature constraints.

getSolver() : callable

Returns

callable

Returns whether a configuration is valid.

isValid(\FeaturePhp\Model\Configuration $configuration) : boolean

This is done by evaluating the solver for the configuration's selected features.

Parameters

$configuration

\FeaturePhp\Model\Configuration

Returns

boolean

Semantics for a feature that provides a choice using an inclusive or.

_or(\FeaturePhp\Model\Feature $feature) : callable
Static

At least one child of such a feature is selected.

Parameters

$feature

\FeaturePhp\Model\Feature

Returns

callable

Semantics for a feature that provides an alternative choice.

alternative(\FeaturePhp\Model\Feature $feature) : callable
Static

Exactly one child of such a feature is selected.

Parameters

$feature

\FeaturePhp\Model\Feature

Returns

callable

Transforms a cross-tree constraint from an XML rule to a formula.

crossTreeConstraint(\SimpleXMLElement $rule) : callable

Parameters

$rule

\SimpleXMLElement

Returns

callable

Semantics for a mandatory feature.

mandatory(\FeaturePhp\Model\Feature $feature) : callable
Static

A mandatory feature is selected iff its parent is selected.

Parameters

$feature

\FeaturePhp\Model\Feature

Returns

callable

Semantics for an optional feature.

optional(\FeaturePhp\Model\Feature $feature) : callable
Static

If an optional feature is selected, its parent is selected.

Parameters

$feature

\FeaturePhp\Model\Feature

Returns

callable

Semantics for the root feature.

root(\FeaturePhp\Model\Feature $feature) : callable
Static

The root feature is always selected.

Parameters

$feature

\FeaturePhp\Model\Feature

Returns

callable

Evaluates the solver for a list of features.

solve(array<mixed,\FeaturePhp\Model\Feature> $features) : boolean

Parameters

$features

array<mixed,\FeaturePhp\Model\Feature>

Returns

boolean

 Properties

 

formulas for all constraints from the feature model

$constraints : array<mixed,callable>

Default

 

the feature model the constraint solver relates to

$model : \FeaturePhp\Model\Model

Default

 

one formula that validates all feature constraints

$solver : callable

Default