Skip to content

Commit a6ec9ac

Browse files
committed
wip
1 parent 6406f80 commit a6ec9ac

File tree

12 files changed

+70
-6
lines changed

12 files changed

+70
-6
lines changed

src/Concerns/ShareableInterpreter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public function __construct(
2121
// ...
2222
}
2323

24+
/**
25+
* Resolve the dependencies for the action.
26+
*/
2427
final public function dependencies(Container $container): DependencyResolver
2528
{
2629
return $container->make(DependencyResolver::class, [
@@ -29,13 +32,17 @@ final public function dependencies(Container $container): DependencyResolver
2932
]);
3033
}
3134

35+
/** {@inheritDoc} */
3236
final public function then(array $then): self
3337
{
3438
$this->then = $then;
3539

3640
return $this;
3741
}
3842

43+
/**
44+
* Run the hooks after the action is handled.
45+
*/
3946
final public function hooks(): void
4047
{
4148
if ($this->then === []) {

src/Configurable/DeferUsing.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function __construct(
1515
//
1616
}
1717

18+
/** {@inheritDoc} */
1819
public function toArray(): array
1920
{
2021
return [

src/Configurable/QueueUsing.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __construct(
1616
//
1717
}
1818

19+
/** {@inheritDoc} */
1920
public function toArray(): array
2021
{
2122
return [

src/Contracts/Configurable.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66

77
interface Configurable
88
{
9+
/**
10+
* Configure the interpreter with the given data.
11+
*/
912
public function configure(array $data): void;
1013
}

src/Contracts/ShouldInterpreter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
interface ShouldInterpreter
1010
{
11+
/**
12+
* Handle the action.
13+
*/
1114
public function handle(Container $container): mixed;
1215

16+
/**
17+
* Register the action's hooks.
18+
*/
1319
public function then(array $then): self;
1420
}

src/FractionBuilder.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,21 @@
2323

2424
final class FractionBuilder implements Arrayable
2525
{
26+
/**
27+
* The array of "then" hooks.
28+
*
29+
* @var array<int, string>
30+
*/
2631
private array $then = [];
2732

33+
/**
34+
* Configuration for queueing the action.
35+
*/
2836
private ?QueueUsing $queued = null;
2937

38+
/**
39+
* Configuration for deferring the action.
40+
*/
3041
private ?DeferUsing $deferred = null;
3142

3243
public function __construct(
@@ -37,7 +48,10 @@ public function __construct(
3748
// ...
3849
}
3950

40-
/** @throws BindingResolutionException|InvalidArgumentException|PreventDeferQueueSameTime
51+
/**
52+
* Run the action.
53+
*
54+
* @throws BindingResolutionException|InvalidArgumentException|PreventDeferQueueSameTime
4155
*/
4256
public function __invoke(...$arguments): mixed
4357
{
@@ -73,13 +87,21 @@ public function __invoke(...$arguments): mixed
7387
return $result;
7488
}
7589

90+
/**
91+
* Register a "then" hook.
92+
*/
7693
public function then(string|UnitEnum $action): self
7794
{
7895
$this->then[] = new Then($this->action, $action);
7996

8097
return $this;
8198
}
8299

100+
/**
101+
* Enable the action to be queued.
102+
*
103+
* @return $this
104+
*/
83105
public function queued(
84106
mixed $delay = null,
85107
?string $queue = null,
@@ -90,6 +112,11 @@ public function queued(
90112
return $this;
91113
}
92114

115+
/**
116+
* Enable the action to be deferred.
117+
*
118+
* @return $this
119+
*/
93120
public function deferred(
94121
bool $always = false,
95122
?string $name = null,
@@ -99,6 +126,7 @@ public function deferred(
99126
return $this;
100127
}
101128

129+
/** {@inheritDoc} */
102130
public function toArray(): array
103131
{
104132
return [

src/FractionManager.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function __construct(public Application $application)
2121
}
2222

2323
/**
24+
* Register a new action.
25+
*
2426
* @throws UnallowedActionDuplication
2527
*/
2628
public function register(string|UnitEnum $action, Closure $closure): FractionBuilder
@@ -41,6 +43,8 @@ public function register(string|UnitEnum $action, Closure $closure): FractionBui
4143
}
4244

4345
/**
46+
* Get the action by its name.
47+
*
4448
* @throws ActionNotRegistered
4549
*/
4650
public function get(string|UnitEnum $action): mixed
@@ -52,6 +56,9 @@ public function get(string|UnitEnum $action): mixed
5256
return $this->fractions[$action] ?? throw new ActionNotRegistered($original);
5357
}
5458

59+
/**
60+
* Bootstrap the actions.
61+
*/
5562
public function boot(): void
5663
{
5764
$cached = [];

src/Interpreters/AsDefault.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
use Fraction\Concerns\ShareableInterpreter;
88
use Fraction\Contracts\ShouldInterpreter;
99
use Illuminate\Container\Container;
10-
use Illuminate\Contracts\Container\BindingResolutionException;
11-
use ReflectionException;
1210

1311
final class AsDefault implements ShouldInterpreter
1412
{
1513
use ShareableInterpreter;
1614

17-
/** @throws ReflectionException|BindingResolutionException */
1815
public function handle(Container $container): mixed
1916
{
2017
$result = $this->dependencies($container)->resolve($this->closure, $this->arguments);

src/Jobs/FractionJob.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Fraction\Jobs;
66

7+
use Fraction\Exceptions\DependencyUnresolvable;
78
use Fraction\Support\DependencyResolver;
89
use Fraction\ValueObjects\Then;
910
use Illuminate\Container\Container;
@@ -26,7 +27,11 @@ public function __construct(
2627
// ...
2728
}
2829

29-
/** @throws ReflectionException|BindingResolutionException */
30+
/**
31+
* Handle the job.
32+
*
33+
* @throws ReflectionException|BindingResolutionException|DependencyUnresolvable
34+
*/
3035
public function handle(Container $application): void
3136
{
3237
$application->make(DependencyResolver::class, [

src/Support/DependencyResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
}
2626

2727
/**
28-
* //
28+
* Resolve the dependencies of a closure or serializable closure.
2929
*
3030
* @throws ReflectionException|BindingResolutionException|DependencyUnresolvable
3131
*/

0 commit comments

Comments
 (0)