| Conditions | 12 |
| Paths | 257 |
| Total Lines | 18 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 62 | public function __construct(array $artist, MusicBrainz $brainz) |
||
| 63 | { |
||
| 64 | if (!isset($artist['id']) || isset($artist['id']) && !$brainz->isValidMBID($artist['id'])) { |
||
| 65 | throw new Exception('Can not create artist object. Missing valid MBID'); |
||
| 66 | } |
||
| 67 | |||
| 68 | $this->data = $artist; |
||
| 69 | $this->brainz = $brainz; |
||
| 70 | |||
| 71 | $this->id = isset($artist['id']) ? (string)$artist['id'] : ''; |
||
| 72 | $this->type = isset($artist['type']) ? (string)$artist['type'] : ''; |
||
| 73 | $this->name = isset($artist['name']) ? (string)$artist['name'] : ''; |
||
| 74 | $this->sortName = isset($artist['sort-name']) ? (string)$artist['sort-name'] : ''; |
||
| 75 | $this->gender = isset($artist['gender']) ? (string)$artist['gender'] : ''; |
||
| 76 | $this->country = isset($artist['country']) ? (string)$artist['country'] : ''; |
||
| 77 | $this->beginDate = isset($artist['life-span']['begin']) ? $artist['life-span']['begin'] : NULL; |
||
| 78 | $this->endDate = isset($artist['life-span']['ended']) ? $artist['life-span']['ended'] : NULL; |
||
| 79 | } |
||
| 80 | |||
| 126 |