| Conditions | 4 |
| Paths | 4 |
| Total Lines | 48 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 = []; |
||
| 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'; |
||
| 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 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.