Thread
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
final class Thread
{
/** @var array[string|int => int|\UVAsync] */
protected $threads = [];
File Thread.php
has 324 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Async\Threads;
Method create
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create($tid, callable $task, ...$args): ?TWorker
{
$tid = \is_scalar($tid) ? $tid : (int) $tid;
if (!isset($this->threads[$tid])) {
\uv_mutex_lock($this->lock);
Function join
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function join($tid = null): void
{
$isCoroutine = self::isCoroutine($this->loop);
$isCancelling = !empty($tid) && $this->isCancelled($tid);
while (!empty($tid) ? ($this->isRunning($tid) || $this->isCancelled($tid)) : !$this->isEmpty()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function handlers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function handlers($tid): void
{
if ($this->isSuccessful($tid)) {
if ($this->hasLoop) // @codeCoverageIgnoreStart
$this->loop->executeTask($this->success, $tid);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function triggerError
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function triggerError($tid)
{
if (isset($this->exception[$tid])) {
$exception = $this->exception[$tid];
if ($this->isYield)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function cancel
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function cancel($tid = null): void
{
if (isset($this->status[$tid])) {
\uv_mutex_lock($this->lock);
$this->status[$tid] = ['cancelled'];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"