BackgroundProcessService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canRunAsUser() 0 6 2
A isRoot() 0 4 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