BackgroundProcessService::isRoot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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