src/Pipeline/IsPipeline.php
public function replace($needle, $replacement): Pipeline
	{
		$stages = [];
		$found  = false;
		foreach ($this->stages as $stage) {
			if ($this->matches($stage, $needle)) {
				$stages[] = $replacement;
				$found    = true;
				continue;
			}

			$stages[] = $stage;
		}

		if ($found) {
			$pipeline         = clone $this;
			$pipeline->stages = $stages;

			return $pipeline;
		}

		unset($stages);

		return $this;
	}
public function replace($needle, $replacement): Pipeline
	{
		$stages = [];
		$found  = false;
		foreach ($this->stages as $stage) {
			if ($this->matches($stage, $needle)) {
				$stages[] = $replacement;
				$found    = true;
				continue;
			}

			$stages[] = $stage;
		}

		if ($found) {
			$pipeline         = clone $this;
			$pipeline->stages = $stages;

			return $pipeline;
		}

		unset($stages);

		return $this;
	}
Replaces the first occurrence of the stage in the pipeline

If no replacement is made the original pipeline is returned

@param string $needle The class name to replace
@param        $replacement
@return Pipeline