class ChangePropertyValue extends AbstractTransformation (View source)

Change the value of a given property.

This can apply two transformations:

If newValue is set, the value will be set to this, with any occurrences of the currentValuePlaceholder replaced with the current value of the property.

If search and replace are given, that replacement will be done on the value (after applying the newValue if set).

Properties

protected string $propertyName
protected string $newValue
$search
protected string $replace
protected string $currentValuePlaceholder

Placeholder for the current property value to be inserted in newValue.

Methods

bool
isTransformable(NodeData $node)

If the given node has the property this transformation should work on, this returns true.

execute(NodeData $node)

Change the property on the given node.

void
setProperty(string $propertyName)

Sets the name of the property to change.

void
setNewValue(string $newValue)

New property value to be set.

void
setSearch(string $search)

Search string to replace in current property value.

void
setReplace(string $replace)

Replacement for the search string

void
setCurrentValuePlaceholder(string $currentValuePlaceholder)

The value of this option (defaults to "{current}") will be used to include the current property value into the new value.

Details

bool isTransformable(NodeData $node)

If the given node has the property this transformation should work on, this returns true.

Parameters

NodeData $node

Return Value

bool

NodeData execute(NodeData $node)

Change the property on the given node.

Parameters

NodeData $node

Return Value

NodeData

Exceptions

NodeException

void setProperty(string $propertyName)

Sets the name of the property to change.

Parameters

string $propertyName

Return Value

void

void setNewValue(string $newValue)

New property value to be set.

The value of the option "currentValuePlaceholder" (defaults to "{current}") will be used to include the current property value into the new value.

Parameters

string $newValue

Return Value

void

void setSearch(string $search)

Search string to replace in current property value.

Parameters

string $search

Return Value

void

void setReplace(string $replace)

Replacement for the search string

Parameters

string $replace

Return Value

void

void setCurrentValuePlaceholder(string $currentValuePlaceholder)

The value of this option (defaults to "{current}") will be used to include the current property value into the new value.

Parameters

string $currentValuePlaceholder

Return Value

void