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

InfoController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 19
c 0
b 0
f 0
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 25 5
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