GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 45bcc8...fd9927 )
by Syo
06:17 queued 02:57
created

_createRequestConnpassApiUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Services\Contents\It\Event;
4
5
/**
6
 * ConnpassEventService.
7
 *
8
 * ConnpassEventを扱うService
9
 */
10
class ConnpassEventService
11
{
12
    /**
13
     * Create a new instance.
14
     */
15
    public function __construct()
16
    {
17
    }
18
    
19
    /**
20
     * ConnpassAPIにリクエストするURLの生成
21
     * @param リクエストパラム
22
     * @return string ConnpassAPIにリクエストするURL
23
     */
24
    private function _createRequestConnpassApiUrl($param) {
25
        $year = $param['year'];
26
        $month = $param['month'];
27
        $count = $param['count'];
0 ignored issues
show
Unused Code introduced by
$count is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
28
        $firstMonth = date("$year-$month-01");
0 ignored issues
show
Unused Code introduced by
$firstMonth is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
        $lastMonth = date("$year-$month-t");
0 ignored issues
show
Unused Code introduced by
$lastMonth is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
30
31
        return "http://connpass.com/api/v1/event/?keyword=python";
32
    }
33
34
    /**
35
     * connpassのAPIからJSONを取得する.
36
     * 
37
     * @param array リクエストパラム
38
     * @return array connpassのイベントを取得
39
     */
40
    public function getConnpassApiOneMonthEventJson($param)
41
    {   
42
        $context = stream_context_create([
43
           'http' => array('ignore_errors' => true)
44
        ]);
45
        $response = file_get_contents(
46
            $this->_createRequestConnpassApiUrl($param),
47
            false,
48
            $context
49
        );
50
51
        // ステータスコードを取得する
52
        preg_match(
53
            '/HTTP\/1\.[0|1|x] ([0-9]{3})/',
54
            $http_response_header[0],
55
            $matches
56
        );
57
        $status_code = $matches[1];
58
        
59
        // APIのデータ取得用変数
60
        $eventData = [];
0 ignored issues
show
Unused Code introduced by
$eventData is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
61
62
        switch ($status_code) {
63
            case '200':
64
                // JSONファイルは配列に変換しておく
65
                $jsonData = mb_convert_encoding($response, 'UTF8', 'auto');
66
                $eventData = json_decode($jsonData, true);
67
                break;
68
            case '403';
0 ignored issues
show
Coding Style introduced by
CASE statements must be defined using a colon

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
69
                // 403の場合
70
                $eventData = [
71
                    'status' => '403'
72
                ];
73
                break;
74
            case '404':
75
                // 404の場合
76
                $eventData = [
77
                    'status' => '404'
78
                ];
79
                break;
80
            default:
81
                $eventData = [
82
                    'status' => 'error'
83
                ];
84
                break;
85
        }
86
        return $eventData;
87
    }
88
}
89