Completed
Pull Request — master (#15)
by Wachter
10:44
created

Factory::createTask()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle;
13
14
use Task\TaskBundle\Entity\Task;
15
use Task\TaskBundle\Entity\TaskExecution;
16
use Task\TaskInterface;
17
18
/**
19
 * Factory which returns doctrine entities for tasks and task-execution.
20
 */
21
class Factory extends \Task\Factory
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function createTask($handlerClass, $workload)
27
    {
28
        return new Task($handlerClass, $workload);
0 ignored issues
show
Bug introduced by
It seems like $workload defined by parameter $workload on line 26 can also be of type object<Serializable>; however, Task\Task::__construct() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function createTaskExecution(TaskInterface $task, \DateTime $scheduleTime)
35
    {
36
        return new TaskExecution($task, $task->getHandlerClass(), $scheduleTime, $task->getWorkload());
0 ignored issues
show
Bug introduced by
It seems like $task->getWorkload() targeting Task\TaskInterface::getWorkload() can also be of type object<Serializable>; however, Task\Execution\TaskExecution::__construct() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
37
    }
38
}
39