EventFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 1
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
The method getThreads() 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 ignore-call  annotation

22
		$event->setThreadNb(count($pool->/** @scrutinizer ignore-call */ getThreads()));
Loading history...
23 1
		$event->setThreadDoneNb(count($pool->getThreads()) - count($pool->getToRunThreads()));
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

23
		$event->setThreadDoneNb(count($pool->getThreads()) - count($pool->/** @scrutinizer ignore-call */ getToRunThreads()));
Loading history...
24 1
		$event->setMaxRunningThreadNb($pool->getMaxRunningThreadNb());
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

24
		$event->setMaxRunningThreadNb($pool->/** @scrutinizer ignore-call */ getMaxRunningThreadNb());
Loading history...
25 1
		$event->setThreadLeftNb(count($pool->getToRunThreads()));
26 1
		$event->setRunningThreadNb(count($pool->getRunningThreads()));
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

26
		$event->setRunningThreadNb(count($pool->/** @scrutinizer ignore-call */ getRunningThreads()));
Loading history...
27 1
		$event->setThread($thread);
28
29 1
		return $event;
30
	}
31
32
}
33