| Conditions | 10 |
| Paths | 70 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 10 |
| 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 |
||
| 53 | 9 | public function __construct(array $data) |
|
| 54 | { |
||
| 55 | 9 | $this->file_id = isset($data['file_id']) ? $data['file_id'] : null; |
|
| 56 | 9 | if (empty($this->file_id)) { |
|
| 57 | 1 | throw new TelegramException('file_id is empty!'); |
|
| 58 | } |
||
| 59 | |||
| 60 | 8 | $this->duration = isset($data['duration']) ? $data['duration'] : null; |
|
| 61 | 8 | if ($this->duration === '' || $this->duration === null) { |
|
| 62 | 1 | throw new TelegramException('duration is empty!'); |
|
| 63 | } |
||
| 64 | |||
| 65 | 7 | $this->performer = isset($data['performer']) ? $data['performer'] : null; |
|
| 66 | |||
| 67 | 7 | $this->title = isset($data['title']) ? $data['title'] : null; |
|
| 68 | 7 | $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null; |
|
| 69 | 7 | $this->file_size = isset($data['file_size']) ? $data['file_size'] : null; |
|
| 70 | 7 | } |
|
| 71 | |||
| 132 |