| Conditions | 13 |
| Paths | 16 |
| Total Lines | 33 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 namespace CalDAVClient\Facade\Responses; |
||
| 41 | protected function parse() |
||
| 42 | { |
||
| 43 | |||
| 44 | if (!$this->isValid()) throw new NotValidGenericSingleCalDAVResponseException(); |
||
| 45 | if (!isset($this->content['response']['propstat'])) return $this; |
||
| 46 | if (isset($this->content['response']['propstat']['prop']) && isset($this->content['response']['propstat']['status'])) { |
||
| 47 | // all props found |
||
| 48 | $status = $this->content['response']['propstat']['status']; |
||
| 49 | if ($this->statusMatches($status, AbstractCalDAVResponse::HttpOKStatus)) { |
||
| 50 | $this->found_props = $this->content['response']['propstat']['prop']; |
||
| 51 | $this->not_found_props = null; |
||
| 52 | } |
||
| 53 | if ($this->statusMatches($status, AbstractCalDAVResponse::HttpNotFoundStatus)) { |
||
| 54 | $this->not_found_props = $this->content['response']['propstat']['prop']; |
||
| 55 | $this->found_props = null; |
||
| 56 | } |
||
| 57 | if ($this->statusMatches($status, AbstractCalDAVResponse::HttpForbiddenStatus)) { |
||
| 58 | throw new ForbiddenQueryException(); |
||
| 59 | } |
||
| 60 | return $this; |
||
| 61 | } |
||
| 62 | // multi props ( found or not found) |
||
| 63 | foreach ($this->content['response']['propstat'] as $propstat) { |
||
| 64 | |||
| 65 | if (!isset($propstat['status']) || !isset($propstat['prop'])) continue; |
||
| 66 | |||
| 67 | if ($this->statusMatches($propstat['status'], AbstractCalDAVResponse::HttpOKStatus)) |
||
| 68 | $this->found_props = $propstat['prop']; |
||
| 69 | |||
| 70 | if ($this->statusMatches($propstat['status'], AbstractCalDAVResponse::HttpNotFoundStatus)) |
||
| 71 | $this->not_found_props = $propstat['prop']; |
||
| 72 | } |
||
| 73 | return $this; |
||
| 74 | } |
||
| 110 |