BackgroundProcessService::canRunAsUser()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 2
1
<?php namespace Indatus\Dispatcher\Services;
2
3
/**
4
 * This file is part of Dispatcher
5
 *
6
 * (c) Ben Kuhl <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
use App;
13
14
class BackgroundProcessService
15
{
16
    /**
17
     * Determine if the background process can run as another user
18
     * @return bool
19
     */
20 2
    public function canRunAsUser()
21
    {
22 2
        $platform = App::make('Indatus\Dispatcher\Platform');
23
24 2
        return !$platform->isWindows() && $this->isRoot();
25
    }
26
27
    /**
28
     * Is the current command being run as root?
29
     * @return bool
30
     */
31 1
    public function isRoot()
32
    {
33 1
        return (posix_getuid() === 0);
34
    }
35
}
36