class Dependency (View source)

A value object representing dependency information.

Properties

protected string $name

The name of the dependency.

protected string $project

The project namespace for the dependency.

protected Constraint $constraintString

The constraint string.

protected Constraint $constraint

The Constraint object from the constraint string.

Methods

__construct(string $name, string $project, string $constraint)

Dependency constructor.

string
getName()

Gets the dependency's name.

string
getProject()

Gets the dependency's project namespace.

string
getConstraintString()

Gets constraint string from the dependency.

getConstraint()

Gets the Constraint object.

bool
isCompatible(string $version)

Determines if the provided version is compatible with this dependency.

static Dependency
createFromString(string $dependency)

Creates a new instance of this class from a dependency string.

array
__sleep()

Prevents unnecessary serialization of constraint objects.

Details

__construct(string $name, string $project, string $constraint)

Dependency constructor.

Parameters

string $name

The name of the dependency.

string $project

The project namespace for the dependency.

string $constraint

The constraint string. For example, '>8.x-1.1'.

string getName()

Gets the dependency's name.

Return Value

string

The dependency's name.

string getProject()

Gets the dependency's project namespace.

Return Value

string

The dependency's project namespace.

string getConstraintString()

Gets constraint string from the dependency.

Return Value

string

The constraint string.

protected Constraint getConstraint()

Gets the Constraint object.

Return Value

Constraint

The Constraint object.

bool isCompatible(string $version)

Determines if the provided version is compatible with this dependency.

Parameters

string $version

The version to check, for example '4.2'.

Return Value

bool

TRUE if compatible with the provided version, FALSE if not.

static Dependency createFromString(string $dependency)

Creates a new instance of this class from a dependency string.

Parameters

string $dependency

A dependency string, which specifies a module or theme dependency, and optionally the project it comes from and a constraint string that determines the versions that are supported. Supported formats include:

  • 'module'
  • 'project:module'
  • 'project:module (>=version, <=version)'.

Return Value

Dependency

array __sleep()

Prevents unnecessary serialization of constraint objects.

Return Value

array

The properties to serialize.