AliceMajere /
wonderland-thread
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Wonderland\Thread\Factory; |
||||
| 4 | |||||
| 5 | use Wonderland\Thread\AbstractThreadPoolMediator; |
||||
| 6 | use Wonderland\Thread\Event\Event; |
||||
| 7 | use Wonderland\Thread\Thread; |
||||
| 8 | use Wonderland\Thread\ThreadPool; |
||||
| 9 | |||||
| 10 | class EventFactory |
||||
| 11 | { |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * @param string $eventName |
||||
| 15 | * @param ThreadPool|AbstractThreadPoolMediator $pool |
||||
| 16 | * @param Thread|null $thread |
||||
| 17 | * @return Event |
||||
| 18 | */ |
||||
| 19 | 1 | public static function create(string $eventName, AbstractThreadPoolMediator $pool, ?Thread $thread = null): Event |
|||
| 20 | { |
||||
| 21 | 1 | $event = new Event($eventName); |
|||
| 22 | 1 | $event->setThreadNb(count($pool->getThreads())); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 23 | 1 | $event->setThreadDoneNb(count($pool->getThreads()) - count($pool->getToRunThreads())); |
|||
|
0 ignored issues
–
show
The method
getToRunThreads() does not exist on Wonderland\Thread\AbstractThreadPoolMediator. Since it exists in all sub-types, consider adding an abstract or default implementation to Wonderland\Thread\AbstractThreadPoolMediator.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 24 | 1 | $event->setMaxRunningThreadNb($pool->getMaxRunningThreadNb()); |
|||
|
0 ignored issues
–
show
The method
getMaxRunningThreadNb() does not exist on Wonderland\Thread\AbstractThreadPoolMediator. Since it exists in all sub-types, consider adding an abstract or default implementation to Wonderland\Thread\AbstractThreadPoolMediator.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 25 | 1 | $event->setThreadLeftNb(count($pool->getToRunThreads())); |
|||
| 26 | 1 | $event->setRunningThreadNb(count($pool->getRunningThreads())); |
|||
|
0 ignored issues
–
show
The method
getRunningThreads() does not exist on Wonderland\Thread\AbstractThreadPoolMediator. Since it exists in all sub-types, consider adding an abstract or default implementation to Wonderland\Thread\AbstractThreadPoolMediator.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 27 | 1 | $event->setThread($thread); |
|||
| 28 | |||||
| 29 | 1 | return $event; |
|||
| 30 | } |
||||
| 31 | |||||
| 32 | } |
||||
| 33 |