Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #613 from tienvx/prevent-updating-bug-steps-after-…
…running Prevent updating bug's steps after running
- Loading branch information
Showing
14 changed files
with
172 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Service\Step; | ||
|
||
use SingleColorPetrinet\Model\Color; | ||
use Tienvx\Bundle\MbtBundle\Exception\UnexpectedValueException; | ||
use Tienvx\Bundle\MbtBundle\Model\Bug\StepInterface; | ||
|
||
class StepHelper implements StepHelperInterface | ||
{ | ||
public function cloneStepsAndResetColor(array $steps): array | ||
{ | ||
$lastColor = null; | ||
$newSteps = []; | ||
foreach ($steps as $step) { | ||
if (!$step instanceof StepInterface) { | ||
throw new UnexpectedValueException(sprintf('Step must be instance of "%s".', StepInterface::class)); | ||
} | ||
$newStep = clone $step; | ||
$newStep->setColor($lastColor ?? new Color()); | ||
$newSteps[] = $newStep; | ||
$lastColor = clone $step->getColor(); | ||
} | ||
|
||
return $newSteps; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Service\Step; | ||
|
||
interface StepHelperInterface | ||
{ | ||
public function cloneStepsAndResetColor(array $steps): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.