Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.php
More file actions
Latest commit
64 lines (51 loc) · 1.22 KB
/
Copy pathTask.php
File metadata and controls
64 lines (51 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
namespaceNetlogix\DependencyResolver;
useInvalidArgumentException;
class Task implements TaskInterface
{
/**
* @var true
*/
privatebool$resolved = false;
/**
* @param array<string> $dependencies
*/
publicfunction__construct(
privatereadonlystring$name,
privatereadonlyarray$dependencies = []
) {
if (array_filter($dependencies, fn ($i) => !is_string($i))) {
thrownewInvalidArgumentException('Dependencies must be strings');
}
}
publicfunctiongetName(): string
{
return$this->name;
}
publicfunctiongetDependencies(): array
{
return$this->dependencies;
}
/**
* @param iterable<string> $resolvedTasks
*/
publicfunctioncheckDependencies(array$resolvedTasks): bool
{
return [] === array_diff($this->getDependencies(), $resolvedTasks);
}
publicfunctionresolve(): self
{
$this->resolved = true;
return$this;
}
publicfunctionisResolved(): bool
{
return$this->resolved;
}
publicfunctionreset(): self
{
$this->resolved = false;
return$this;
}
}