An idea for splitting validation and running

[MAILPOET-4191]
This commit is contained in:
John Oleksowicz
2022-04-05 20:25:13 -05:00
committed by Veljko V
parent 70911d2424
commit 2cce9bf7ad
6 changed files with 267 additions and 163 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace MailPoet\Automation\Engine\Workflows;
class ActionValidationResult {
private $errors = [];
private $validated = [];
public function setValidatedParam(string $key, $value): void {
$this->validated[$key] = $value;
}
public function addError(\Exception $exception): void {
$this->errors[] = $exception;
}
public function isValid(): bool {
return count($this->getErrors()) === 0;
}
public function getErrors(): array {
return $this->errors;
}
public function hasErrors(): bool {
return count($this->getErrors()) > 0;
}
public function getValidatedParams(): array {
return $this->validated;
}
public function getValidatedParam(string $key) {
return $this->getValidatedParams()[$key] ?? null;
}
}