-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for supplying customizable fields in a given workflow/run
- Loading branch information
Showing
8 changed files
with
247 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use CraigPaul\Blitz\Testing\TestCase; | ||
|
||
class {{ class }} extends TestCase | ||
{ | ||
/** | ||
* Set up the workflow to be put under load. | ||
* | ||
* @return void | ||
*/ | ||
public function handle(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Set up the dynamic fields for this workflow. | ||
* | ||
* @return array | ||
*/ | ||
public function fields(): array | ||
{ | ||
return [ | ||
// | ||
] | ||
} | ||
} |
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,66 @@ | ||
<?php | ||
|
||
namespace CraigPaul\Blitz\Support; | ||
|
||
use JsonSerializable; | ||
|
||
class Field implements JsonSerializable | ||
{ | ||
/** | ||
* Create a new Field instance. | ||
* | ||
* @param string|null $description | ||
* @param string $label | ||
* @param string $name | ||
* @param \CraigPaul\Blitz\Support\Option[] $options | ||
* @param string|null $placeholder | ||
* @param \CraigPaul\Blitz\Support\FieldType $type | ||
*/ | ||
public function __construct( | ||
public readonly ?string $description, | ||
public readonly string $label, | ||
public readonly string $name, | ||
public readonly array $options = [], | ||
public readonly ?string $placeholder, | ||
public readonly FieldType $type, | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function jsonSerialize(): mixed | ||
{ | ||
return [ | ||
'description' => $this->description, | ||
'label' => $this->label, | ||
'name' => $this->name, | ||
'options' => $this->options, | ||
'placeholder' => $this->placeholder, | ||
'type' => $this->type, | ||
]; | ||
} | ||
|
||
/** | ||
* Create a new Field instance with a type of select. | ||
* | ||
* @param string|null $description | ||
* @param string $label | ||
* @param string $name | ||
* @param \CraigPaul\Blitz\Support\Option[] $options | ||
* @param string|null $placeholder | ||
* | ||
* @return static | ||
*/ | ||
public static function select(?string $description = null, string $label, string $name, array $options, ?string $placeholder): static | ||
{ | ||
return new static( | ||
description: $description, | ||
label: $label, | ||
name: $name, | ||
options: $options, | ||
placeholder: $placeholder, | ||
type: FieldType::Select, | ||
); | ||
} | ||
} |
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 CraigPaul\Blitz\Support; | ||
|
||
enum FieldType: string | ||
{ | ||
case Select = 'select'; | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace CraigPaul\Blitz\Support; | ||
|
||
use JsonSerializable; | ||
|
||
class Option implements JsonSerializable | ||
{ | ||
/** | ||
* Create a new Option instance. | ||
* | ||
* @param string $text | ||
* @param bool|int|float|string|null $value | ||
* | ||
* @return void | ||
*/ | ||
public function __construct( | ||
public readonly string $text, | ||
public readonly bool|int|float|string|null $value, | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function jsonSerialize(): mixed | ||
{ | ||
return [ | ||
'text' => $this->text, | ||
'value' => $this->value, | ||
]; | ||
} | ||
} |
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