SystemController::index()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.2559

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
ccs 6
cts 10
cp 0.6
rs 9.2
cc 2
eloc 14
nc 2
nop 1
crap 2.2559
1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\Controller\Admin\Setting\System;
26
27
use Eccube\Application;
28
use Eccube\Common\Constant;
29
30
class SystemController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
31
{
32
33
    private $maintitle;
0 ignored issues
show
Unused Code introduced by
The property $maintitle is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
34
35
    private $subtitle;
0 ignored issues
show
Unused Code introduced by
The property $subtitle is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
36
37 1
    public function __construct()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
38
    {
39 1
    }
40
41 1
    public function index(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
42
    {
43
        switch ($app['request']->get('mode')) {
44 1
            case 'info':
45
                ob_start();
46
                phpinfo();
47
                $phpinfo = ob_get_contents();
48
                ob_end_clean();
49
50
                return $phpinfo;
51
52
               break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
53
            default:
54 1
                break;
55
        }
56
57
        $this->arrSystemInfo = $this->getSystemInfo($app);
0 ignored issues
show
Bug introduced by
The property arrSystemInfo does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
58
59 1
        return $app->render('Setting/System/system.twig', array(
60 1
            'arrSystemInfo' => $this->arrSystemInfo,
61
        ));
62 1
    }
63
64 1
     public function getSystemInfo(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
65
     {
66
        $system = $app['eccube.service.system'];
67
        $server = $app['request'];
68
69
        $arrSystemInfo = array(
70 1
            array('title' => 'EC-CUBE',     'value' => Constant::VERSION),
71
            array('title' => 'サーバーOS',    'value' => php_uname()),
72
            array('title' => 'DBサーバー',    'value' => $system->getDbversion()),
73
            array('title' => 'WEBサーバー',   'value' => $server->server->get("SERVER_SOFTWARE")),
74 1
        );
75
76
        $value = phpversion() . ' (' . implode(', ', get_loaded_extensions()) . ')';
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
77 1
        $arrSystemInfo[] = array('title' => 'PHP', 'value' => $value);
78
        $arrSystemInfo[] = array('title' => 'HTTPユーザーエージェント', 'value' => $server->headers->get('User-Agent'));
79
80 1
        return $arrSystemInfo;
81 1
     }
82
}
83