This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
8
{
9
/**
10
* @var QueueWriter
11
*/
12
protected $queueWriter;
13
14
/**
15
* @var Task[]
16
*/
17
protected $tasks = [];
18
19
/**
20
* Producer constructor.
21
* @param QueueWriter $queueWriter
22
*/
23
public function __construct(QueueWriter $queueWriter)
24
{
25
$this->queueWriter = $queueWriter;
26
}
27
28
/**
29
* @param TaskInterface $task
30
* @return $this
31
*/
32
public function add(TaskInterface $task)
33
{
34
$this->tasks[] = $task;
35
return $this;
36
}
37
38
/**
39
* @throws TaskException
40
*/
41
public function produce()
42
{
43
if(!isset($this->tasks[0])) {
44
throw new TaskException('You must add at least 1 Task before producing.');
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.