-
Notifications
You must be signed in to change notification settings - Fork 2
/
TaskFactory.php
58 lines (53 loc) · 1.39 KB
/
TaskFactory.php
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
<?php
namespace Aternos\Taskmaster\Task;
/**
* Class TaskFactory
*
* A task factory creates tasks for the {@link Taskmaster}.
*
* @see TaskFactoryInterface
* @package Aternos\Taskmaster\Task
*/
abstract class TaskFactory implements TaskFactoryInterface
{
/**
* @var string[]|null[]|null
*/
protected ?array $groups = null;
/**
* Set the groups this task factory creates tasks for.
*
* Only if a task for that group is requested, the task factory will be used.
* If null is returned, the task factory will be used for all groups.
* If the returned array contains null, the task factory will be used for tasks without a group.
*
* @param array|null $groups
*/
public function setGroups(?array $groups): void
{
$this->groups = $groups;
}
/**
* Add a group this task factory creates tasks for.
*
* Only if a task for that group is requested, the task factory will be used.
* If you add null, the task factory will be used for tasks without a group.
*
* @param string|null $group
* @return void
*/
public function addGroup(?string $group): void
{
if ($this->groups === null) {
$this->groups = [];
}
$this->groups[] = $group;
}
/**
* @inheritDoc
*/
public function getGroups(): ?array
{
return $this->groups;
}
}