| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| 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 declare(strict_types=1); |
||
| 9 | public static function create(array $data): \One\Model\Livereport |
||
| 10 | { |
||
| 11 | $data = self::validateArray($data); |
||
| 12 | $uniqueId = self::validateString( |
||
| 13 | (string) self::checkData($data, 'unique_id', '') |
||
| 14 | ); |
||
| 15 | $title = self::validateString( |
||
| 16 | (string) self::checkData($data, 'title', '') |
||
| 17 | ); |
||
| 18 | $shortDesc = self::validateString( |
||
| 19 | (string) self::checkData($data, 'short_desc', '') |
||
| 20 | ); |
||
| 21 | $publishDate = self::validateString( |
||
| 22 | (string) self::checkData($data, 'publish_date', '') |
||
| 23 | ); |
||
| 24 | $endDate = self::validateString( |
||
| 25 | (string) self::checkData($data, 'end_date', '') |
||
| 26 | ); |
||
| 27 | $tag = self::validateString( |
||
| 28 | (string) self::checkData($data, 'tag', '') |
||
| 29 | ); |
||
| 30 | $isHeadline = (bool) self::checkData($data, 'is_headline', false); |
||
|
|
|||
| 31 | $published = (bool) self::checkData($data, 'published', false); |
||
| 32 | $livereportChild = self::validateString( |
||
| 33 | (string) self::checkData($data, 'livereport_child', '') |
||
| 34 | ); |
||
| 35 | $imageThumbnail = self::validateString( |
||
| 36 | (string) self::checkData($data, 'image_thumbnail', '') |
||
| 37 | ); |
||
| 38 | $reporterName = self::validateString( |
||
| 39 | (string) self::checkData($data, 'reporter_name', '') |
||
| 40 | ); |
||
| 41 | $reporterAvatar = self::validateString( |
||
| 42 | (string) self::checkData($data, 'reporter_avatar', '') |
||
| 43 | ); |
||
| 44 | $editorName = self::validateString( |
||
| 45 | (string) self::checkData($data, 'editor_name', '') |
||
| 46 | ); |
||
| 47 | $editorAvatar = self::validateString( |
||
| 48 | (string) self::checkData($data, 'editor_avatar', '') |
||
| 49 | ); |
||
| 50 | $identifier = self::validateInteger( |
||
| 51 | (int) self::checkData($data, 'identifier', null) |
||
| 52 | ); |
||
| 53 | |||
| 54 | return self::createLivereport( |
||
| 55 | $uniqueId, |
||
| 56 | $title, |
||
| 57 | $shortDesc, |
||
| 58 | $publishDate, |
||
| 59 | $endDate, |
||
| 60 | $tag, |
||
| 61 | $isHeadline, |
||
| 62 | $published, |
||
| 63 | $livereportChild, |
||
| 64 | $imageThumbnail, |
||
| 65 | $reporterName, |
||
| 66 | $reporterAvatar, |
||
| 67 | $editorName, |
||
| 68 | $editorAvatar, |
||
| 69 | $identifier |
||
| 70 | ); |
||
| 154 |