Passed
Push — master ( 02bea5...62dfbf )
by Rutger
03:04
created

InfoController::actionIndex()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
c 0
b 0
f 0
dl 0
loc 25
rs 9.3554
cc 5
nc 3
nop 0
1
<?php
2
3
namespace sample\controllers\web;
4
5
use Yii;
6
use yii\web\Controller;
7
use yii\web\UnauthorizedHttpException;
8
9
class InfoController extends Controller
10
{
11
    /**
12
     * Show phpinfo()
13
     * @return string
14
     * @throws UnauthorizedHttpException
15
     */
16
    public function actionIndex()
17
    {
18
        if (!YII_DEBUG) {
19
            throw new UnauthorizedHttpException();
20
        }
21
22
        ob_start();
23
        echo 'User IP: ' . Yii::$app->request->userIP;
24
        echo '<br>';
25
        echo 'Xdebug extension loaded: ' . (extension_loaded('xdebug') ? 'yes' : 'no');
26
        echo '<br>';
27
        echo 'Xdebug debugger active: ' . ((@xdebug_is_debugger_active() ?? false) ? 'yes' : 'no');
28
        echo '<br>';
29
        echo 'realpath_cache_size: ' . Yii::$app->formatter->asShortSize(realpath_cache_size());
30
        echo '<br>';
31
        phpinfo();
32
        $output = ob_get_clean();
33
34
        if (extension_loaded('xdebug')) {
35
            ob_start();
36
            xdebug_info();
37
            $output .= ob_get_clean();
38
        }
39
40
        return $output;
41
    }
42
}
43