Conditions | 28 |
Paths | 3200 |
Total Lines | 85 |
Code Lines | 54 |
Lines | 6 |
Ratio | 7.06 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
98 | public function normalize() { |
||
99 | if ($this->is_atom()): |
||
|
|||
100 | if (empty($this->channel['tagline'])) { |
||
101 | /* ATOM */ |
||
102 | $this->channel['tagline'] = @$this->channel['subtitle']; |
||
103 | unset($this->channel['subtitle']); |
||
104 | } |
||
105 | for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
||
106 | // ATOM time |
||
107 | if ($date = @$this->items[$i]['modified']) { |
||
108 | continue; |
||
109 | } |
||
110 | if (empty($date)) { |
||
111 | $date = @$this->items[$i]['updated']; |
||
112 | } |
||
113 | if (empty($date)) { |
||
114 | $date = @$this->items[$i]['issued']; |
||
115 | } |
||
116 | if (empty($date)) { |
||
117 | $date = @$this->items[$i]['created']; |
||
118 | } |
||
119 | if (empty($date)) { |
||
120 | $date = @$this->items[$i]['created']; |
||
121 | } |
||
122 | $this->items[$i]['modified'] = $date; |
||
123 | } |
||
124 | elseif ($this->is_rss() !== '1.0'): |
||
125 | for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
||
126 | if ($date = @$this->items[$i]['pubdate']) { |
||
127 | continue; |
||
128 | } |
||
129 | $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date']; |
||
130 | } |
||
131 | endif; |
||
132 | parent::normalize(); |
||
133 | /* ATOM */ |
||
134 | if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) { |
||
135 | $this->channel['language'] = $this->channel['dc']['language']; |
||
136 | unset($this->channel['dc']['language']); |
||
137 | } |
||
138 | View Code Duplication | if (empty($this->channel['language']) |
|
139 | && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match) |
||
140 | ) { |
||
141 | $this->channel['language'] = $match[1]; |
||
142 | } |
||
143 | View Code Duplication | if (empty($this->channel['language']) |
|
144 | && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match) |
||
145 | ) { |
||
146 | $this->channel['language'] = $match[1]; |
||
147 | } |
||
148 | /* remove to avoid redundant encoding conversion */ |
||
149 | if (!empty($this->channel['tagline'])) { |
||
150 | unset($this->channel['tagline']); |
||
151 | } |
||
152 | |||
153 | for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
||
154 | if ($date_timestamp = @$this->items[$i]['date_timestamp']) { |
||
155 | continue; |
||
156 | } |
||
157 | if ($date_timestamp = @$this->items[$i]['pubdate']) { |
||
158 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
||
159 | } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) { |
||
160 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
||
161 | } else { |
||
162 | $this->items[$i]['date_timestamp'] = time(); |
||
163 | } |
||
164 | if (!is_numeric($this->items[$i]['date_timestamp'])) { |
||
165 | if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) { |
||
166 | $this->items[$i]['date_timestamp'] = $date; |
||
167 | } elseif ($date = strtotime($this->items[$i]['date_timestamp'])) { |
||
168 | $this->items[$i]['date_timestamp'] = $date; |
||
169 | } |
||
170 | } |
||
171 | |||
172 | /* remove to avoid redundant encoding conversion */ |
||
173 | if (isset($this->items[$i]['summary'])) { |
||
174 | unset($this->items[$i]['summary']); |
||
175 | } |
||
176 | if (isset($this->items[$i]['atom_content'])) { |
||
177 | unset($this->items[$i]['atom_content']); |
||
178 | } |
||
179 | } |
||
180 | |||
181 | return; |
||
182 | } |
||
183 | |||
212 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: