Conditions | 28 |
Paths | 3200 |
Total Lines | 83 |
Lines | 6 |
Ratio | 7.23 % |
Changes | 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 |
||
100 | public function normalize() |
||
101 | { |
||
102 | if ($this->is_atom()): |
||
|
|||
103 | if (empty($this->channel['tagline'])) { |
||
104 | /* ATOM */ |
||
105 | $this->channel['tagline'] = @$this->channel['subtitle']; |
||
106 | unset($this->channel['subtitle']); |
||
107 | } |
||
108 | for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
||
109 | // ATOM time |
||
110 | if ($date = @$this->items[$i]['modified']) { |
||
111 | continue; |
||
112 | } |
||
113 | if (empty($date)) { |
||
114 | $date = @$this->items[$i]['updated']; |
||
115 | } |
||
116 | if (empty($date)) { |
||
117 | $date = @$this->items[$i]['issued']; |
||
118 | } |
||
119 | if (empty($date)) { |
||
120 | $date = @$this->items[$i]['created']; |
||
121 | } |
||
122 | if (empty($date)) { |
||
123 | $date = @$this->items[$i]['created']; |
||
124 | } |
||
125 | $this->items[$i]['modified'] = $date; |
||
126 | } elseif ('1.0' !== $this->is_rss()): |
||
127 | for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
||
128 | if ($date = @$this->items[$i]['pubdate']) { |
||
129 | continue; |
||
130 | } |
||
131 | $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date']; |
||
132 | } |
||
133 | endif; |
||
134 | parent::normalize(); |
||
135 | /* ATOM */ |
||
136 | if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) { |
||
137 | $this->channel['language'] = $this->channel['dc']['language']; |
||
138 | unset($this->channel['dc']['language']); |
||
139 | } |
||
140 | View Code Duplication | if (empty($this->channel['language']) |
|
141 | && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
||
142 | $this->channel['language'] = $match[1]; |
||
143 | } |
||
144 | View Code Duplication | if (empty($this->channel['language']) |
|
145 | && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
||
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 | |||
214 |
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: