ProcessTitleTrait::setProcessTitle()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 9
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Hhxsv5\LaravelS\Swoole\Process;
4
5
trait ProcessTitleTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait ProcessTitleTrait
Loading history...
6
{
7
    public function setProcessTitle($title)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setProcessTitle()
Loading history...
8
    {
9
        if (PHP_OS === 'Darwin') {
10
            return;
11
        }
12
        if (function_exists('cli_set_process_title')) {
13
            @cli_set_process_title($title);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for cli_set_process_title(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

13
            /** @scrutinizer ignore-unhandled */ @cli_set_process_title($title);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
14
        } elseif (function_exists('swoole_set_process_name')) {
15
            @swoole_set_process_name($title);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for swoole_set_process_name(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

15
            /** @scrutinizer ignore-unhandled */ @swoole_set_process_name($title);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
16
        }
17
    }
18
}