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 — develop ( 55aa0a...3d3ece )
by gyeong-won
13:31
created

boardAPI::arrangeContent()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 12
nc 3
nop 1
dl 0
loc 18
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
4
/**
5
 * @class  boardAPI
6
 * @author NAVER ([email protected])
7
 * @brief  board module View Action에 대한 API 처리
8
 **/
9
10
class boardAPI extends board {
11
12
/* do not use dispBoardContent .
13
	function dispBoardContent(&$oModule) {
14
	}
15
*/
16
17
	/**
18
	 * @brief notice list
19
	 **/
20
	function dispBoardNoticeList(&$oModule) {
21
		 $oModule->add('notice_list',$this->arrangeContentList(Context::get('notice_list')));
22
	}
23
24
25
	/**
26
	 * @brief content list
27
	 **/
28
	function dispBoardContentList(&$oModule) {
29
		$api_type = Context::get('api_type');
30
		$document_list = $this->arrangeContentList(Context::get('document_list'));
31
32
		if($api_type =='summary')
33
		{
34
			$content_cut_size = Context::get('content_cut_size');
35
			$content_cut_size = $content_cut_size?$content_cut_size:50;
36
			foreach($document_list as $k=>$v)
37
			{
38
				$oDocument = new documentItem();
39
				$oDocument->setAttribute($v, false);
40
				$document_list[$k]->content = $oDocument->getSummary($content_cut_size);
41
				unset($oDocument);
42
			}
43
		}
44
45
		$oModule->add('document_list',$document_list);
46
		$oModule->add('page_navigation',Context::get('page_navigation'));
47
	}
48
49
50
	/**
51
	 * @brief category list
52
	 **/
53
	function dispBoardCategoryList(&$oModule) {
54
		$oModule->add('category_list',Context::get('category_list'));
55
	}
56
57
	/**
58
	 * @brief board content view
59
	 **/
60
	function dispBoardContentView(&$oModule) {
61
		$oDocument = Context::get('oDocument');
62
		$extra_vars = $oDocument->getExtraVars();
0 ignored issues
show
Bug introduced by
The method getExtraVars cannot be called on $oDocument (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
63
		if($oDocument->isGranted())
0 ignored issues
show
Bug introduced by
The method isGranted cannot be called on $oDocument (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
64
		{
65
			$oDocument->add('extra_vars',$this->arrangeExtraVars($extra_vars));
0 ignored issues
show
Bug introduced by
The method add cannot be called on $oDocument (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
66
		}
67
		$oModule->add('oDocument',$this->arrangeContent($oDocument));
68
	}
69
70
71
	/**
72
	 * @brief contents file list
73
	 **/
74
	function dispBoardContentFileList(&$oModule) {
75
		$oDocument = Context::get('oDocument');
76
		if($oDocument->isAccessible())
0 ignored issues
show
Bug introduced by
The method isAccessible cannot be called on $oDocument (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
77
		{
78
			$oModule->add('file_list', $this->arrangeFile(Context::get('file_list')));
79
		}
80
		else
81
		{
82
			$oModule->add('file_list', array());
83
		}
84
	}
85
86
87
	/**
88
	 * @brief tag list
89
	 **/
90
	function dispBoardTagList(&$oModule) {
91
		$oModule->add('tag_list',Context::get('tag_list'));
92
	}
93
94
	/**
95
	 * @brief comments list
96
	 **/
97
	function dispBoardContentCommentList(&$oModule) {
98
		$oModule->add('comment_list',$this->arrangeComment(Context::get('comment_list')));
99
	}
100
101 View Code Duplication
	function arrangeContentList($content_list) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
102
		$output = array();
103
		if(count($content_list)) {
104
			foreach($content_list as $key => $val) $output[] = $this->arrangeContent($val);
105
		}
106
		return $output;
107
	}
108
109
110
	function arrangeContent($content) {
111
		$oBoardView = getView('board');
0 ignored issues
show
Unused Code introduced by
$oBoardView 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...
112
		$output = new stdClass;
113
		if($content){
114
			$output = $content->gets('document_srl','category_srl','member_srl','nick_name','title','content','tags','readed_count','voted_count','blamed_count','comment_count','regdate','last_update','extra_vars','status');
115
116
			$output->content = $content->getContent(false, false, true, false, true);
117
118
			$t_width  = Context::get('thumbnail_width');
119
			$t_height = Context::get('thumbnail_height');
120
			$t_type   = Context::get('thumbnail_type');
121
122
			if ($t_width && $t_height && $t_type && $content->thumbnailExists($t_width, $t_height, $t_type)) {
123
				$output->thumbnail_src = $content->getThumbnail($t_width, $t_height, $t_type);
124
			}
125
		}
126
		return $output;
127
	}
128
129
	function arrangeComment($comment_list) {
130
		$output = array();
131
		if(count($comment_list) > 0 ) {
132
			foreach($comment_list as $key => $val){
133
				$item = null;
0 ignored issues
show
Unused Code introduced by
$item 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...
134
				$item = $val->gets('comment_srl','parent_srl','depth','nick_name','content','is_secret','voted_count','blamed_count','regdate','last_update');
135
136
				$item->content = $val->getContent(false, false, false);
137
138
				$output[] = $item;
139
			}
140
		}
141
		return $output;
142
	}
143
144
145
	function arrangeFile($file_list) {
146
		$output = array();
147
		if(count($file_list) > 0) {
148
			foreach($file_list as $key => $val){
149
				$item = new stdClass;
150
				$item->download_count = $val->download_count;
151
				$item->source_filename = $val->source_filename;
152
				$item->file_size = $val->file_size;
153
				$item->regdate = $val->regdate;
154
				$output[] = $item;
155
			}
156
		}
157
		return $output;
158
	}
159
160
	function arrangeExtraVars($list) {
161
		$output = array();
162
		if(count($list)) {
163
			foreach($list as $key => $val){
164
				$item = new stdClass;
165
				$item->name = $val->name;
166
				$item->type = $val->type;
167
				$item->desc = $val->desc;
168
				$item->value = $val->value;
169
				$output[] = $item;
170
			}
171
		}
172
		return $output;
173
	}
174
}
175