Error   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 6
Bugs 3 Features 3
Metric Value
wmc 1
c 6
b 3
f 3
lcom 1
cbo 2
dl 28
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A play() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Error
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;
17
18
//------------------------------------------------------//
19
// クラス定義
20
//------------------------------------------------------//
21 View Code Duplication
class Error 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
        $header = $this->getDefaultHeader();
41
        $header = $this->replaceHeader( $header, 'robots', 'NOINDEX,NOFOLLOW' );
42
        $header = $this->replaceHeader( $header, 'title', 'エラーが発生しました' );
0 ignored issues
show
Security Bug introduced by Yuta Hayakawa
It seems like $header defined by $this->replaceHeader($he...が発生しました') on line 42 can also be of type false; however, Risoluto\RisolutoViewTrait::replaceHeader() does only seem to accept array, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
43
44
        // テンプレートエンジン関連の処理
45
        $assign_value = [ 'header' => $header ];
46
        $this->risolutoView( $assign_value );
47
    }
48
}