DelConfirm::play()   B
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 45
Code Lines 26

Duplication

Lines 11
Ratio 24.44 %

Importance

Changes 2
Bugs 1 Features 2
Metric Value
c 2
b 1
f 2
dl 11
loc 45
rs 8.8571
cc 3
eloc 26
nc 3
nop 0
1
<?php
2
/**
3
 * DelConfirm
4
 *
5
 * グループ削除画面(確認)を実現するためのクラス
6
 *
7
 * @package           risoluto
8
 * @author            Risoluto Developers
9
 * @license           http://opensource.org/licenses/bsd-license.php new BSD license
10
 * @copyright     (C) 2008-2015 Risoluto Developers / All Rights Reserved.
11
 */
12
13
//------------------------------------------------------//
14
// 名前空間の定義
15
//------------------------------------------------------//
16
namespace RisolutoApps\Admin\GroupMng;
17
18
//------------------------------------------------------//
19
// クラス定義
20
//------------------------------------------------------//
21
class DelConfirm extends \Risoluto\RisolutoControllerBase implements \Risoluto\RisolutoControllerInterface
22
{
23
    // View関連の処理を使用する
24
    use \Risoluto\RisolutoViewTrait;
25
26
    /**
27
     * play()
28
     *
29
     * 主処理を行う
30
     *
31
     * @access    public
32
     *
33
     * @param     void
34
     *
35
     * @return    void    なし
36
     */
37
    public function play()
38
    {
39
        // セッションをスタート
40
        $sess = new \Risoluto\Session();
41
        $sess->start();
42
43
        // 共通処理クラスを呼び出し
44
        $common = new \RisolutoApps\Admin\AdminCommon;
45
        $detail = $common->loginCheck( $sess, true );
46
47
        $param = $this->getParam();
48 View Code Duplication
        if (is_numeric( $param[ 0 ] )) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
            // 引数値がセットされていれば、それを元に登録情報を呼び出す
50
            $target = \Risoluto\Auth::callProviderMethod( 'showGroupByNo', [ 'no' => $param[ 0 ] ] );
51
            if (empty( $target )) {
52
                // 情報が取得できなかった場合も例外をThrow
53
                Throw new \Exception( 'Cannot load user data' );
54
            }
55
        } else {
56
            // 指定されていなければ例外をThrowする
57
            Throw new \Exception( 'Require args not found' );
58
        }
59
60
        // 情報が取得できたら整形してセッションに保存する
61
        $getVals[ 'entered' ] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$getVals was never initialized. Although not strictly required by PHP, it is generally a good practice to add $getVals = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
62
            'no' => $target[ 0 ][ 'no' ],
63
            'groupid' => $target[ 0 ][ 'groupid' ],
64
            'groupname' => $target[ 0 ][ 'groupname' ],
65
            'status' => $target[ 0 ][ 'status' ]
66
        ];
67
        $sess->store( 'form', $getVals );
68
69
        // ヘッダ情報のセット
70
        $header = $this->getDefaultHeader();
71
        $header = $this->replaceHeader( $header, 'robots', 'NOINDEX,NOFOLLOW' );
72
73
        // テンプレートエンジン関連の処理
74
        $assign_value = [
75
            'header' => $header,
76
            'detail' => $detail,
77
            'entered' => $getVals,
78
            'csrf_token' => $sess->load( 'csrf_token' )
79
        ];
80
        $this->risolutoView( $assign_value );
81
    }
82
}