| Conditions | 2 |
| Paths | 2 |
| Total Lines | 34 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 43 | protected function ResampleImage($parent, $imgs, $k, $data) |
||
| 44 | { |
||
| 45 | \Storage::disk($parent->storageDisk)->put($parent->local_path.'word/media/'.$imgs[$k]['img_file_src'], $data); |
||
| 46 | |||
| 47 | //rework img to new size and jpg format |
||
| 48 | $img_rework = \Image::make($parent->storagePath($parent->local_path.'word/media/'.$imgs[$k]['img_file_src'])); |
||
| 49 | |||
| 50 | $w = $imgs[$k]['width']; |
||
| 51 | $h = $imgs[$k]['height']; |
||
| 52 | |||
| 53 | if ($w > $h) |
||
| 54 | { |
||
| 55 | $h = null; |
||
| 56 | } else |
||
| 57 | { |
||
| 58 | $w = null; |
||
| 59 | } |
||
| 60 | |||
| 61 | $img_rework->resize($w, $h, function($constraint) { |
||
| 62 | $constraint->aspectRatio(); |
||
| 63 | $constraint->upsize(); |
||
| 64 | }); |
||
| 65 | |||
| 66 | $new_height = $img_rework->height(); |
||
| 67 | $new_width = $img_rework->width(); |
||
| 68 | $img_rework->save($parent->storagePath($parent->local_path.'word/media/'.$imgs[$k]['img_file_dest'])); |
||
| 69 | |||
| 70 | $parent->zipper->folder('word/media')->add($parent->storagePath($parent->local_path.'word/media/'.$imgs[$k]['img_file_dest'])); |
||
| 71 | |||
| 72 | return array( |
||
| 73 | 'height' => $new_height, |
||
| 74 | 'width' => $new_width, |
||
| 75 | ); |
||
| 76 | } |
||
| 77 | } |
||
| 78 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: