PHPInfoTask::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Prints out the php environment informations for admins.
5
 *
6
 * Can be useful if you can't run this command directly on the server because you haven't got the shell access.
7
 */
8
9
class PHPInfoTask extends BuildTask
10
{
11
    /**
12
     * title of the task
13
     *
14
     * @var string
15
     */
16
    public $title = 'Display PHPInfo information';
17
18
    /**
19
     * description of the task
20
     *
21
     * @var string
22
     */
23
    public $description = 'Displays the output of phpinfo() for this environment.';
24
25
    /**
26
     * @param SS_HTTPResponse $request
0 ignored issues
show
Documentation introduced by
Should the type for parameter $request not be SS_HTTPResponse|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
27
     */
28
    public function run($request = null)
29
    {
30
        if (Permission::check('ADMIN') !== true) {
31
            $this->message('Only admins can run this task.');
32
        } else {
33
            phpinfo();
34
        }
35
    }
36
37
    /**
38
     * @param string $text
39
     */
40
    protected function message($text)
41
    {
42
        if (PHP_SAPI !== 'cli') {
43
            $text = '<p>' . $text.'</p>';
44
        }
45
46
        echo $text . PHP_EOL;
47
    }
48
}
49