Passed
Pull Request — master (#1027)
by
unknown
03:53
created

RotateController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRotate() 0 6 1
A getRotateimage() 0 20 1
1
<?php
2
3
namespace UniSharp\LaravelFilemanager\Controllers;
4
5
use Intervention\Image\Facades\Image;
6
use UniSharp\LaravelFilemanager\Events\ImageIsRotating;
7
use UniSharp\LaravelFilemanager\Events\ImageWasRotated;
8
9
class RotateController extends LfmController
10
{
11
    /**
12
     * Show rotate page.
13
     *
14
     * @return mixed
15
     */
16
    public function getRotate()
17
    {
18
        return view('laravel-filemanager::rotate')
0 ignored issues
show
Bug introduced by
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        return /** @scrutinizer ignore-call */ view('laravel-filemanager::rotate')
Loading history...
19
            ->with([
20
                'working_dir' => request('working_dir'),
0 ignored issues
show
Bug introduced by
The function request was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
                'working_dir' => /** @scrutinizer ignore-call */ request('working_dir'),
Loading history...
21
                'img' => $this->lfm->pretty(request('img'))
0 ignored issues
show
Bug Best Practice introduced by
The property lfm does not exist on UniSharp\LaravelFilemana...ollers\RotateController. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method pretty() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
                'img' => $this->lfm->/** @scrutinizer ignore-call */ pretty(request('img'))

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22
            ]);
23
    }
24
25
    /**
26
     * rotate the image (called via ajax).
27
     */
28
    public function getRotateimage()
29
    {
30
        $image_name = request('img');
0 ignored issues
show
Bug introduced by
The function request was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $image_name = /** @scrutinizer ignore-call */ request('img');
Loading history...
31
        $image_path = $this->lfm->setName($image_name)->path('absolute');
0 ignored issues
show
Bug Best Practice introduced by
The property lfm does not exist on UniSharp\LaravelFilemana...ollers\RotateController. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
        $rotate_path = $image_path;
33
        $angle = request('angle');
34
35
        event(new ImageIsRotating($image_path));
0 ignored issues
show
Bug introduced by
The function event was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        /** @scrutinizer ignore-call */ 
36
        event(new ImageIsRotating($image_path));
Loading history...
36
37
        // rotate the image
38
        Image::make($image_path)
39
            ->orientate()
40
            ->rotate($angle)
41
            ->save($rotate_path);
42
43
44
        event(new ImageWasRotated($image_path));
45
46
        // make new thumbnail
47
        $this->lfm->makeThumbnail($image_name);
48
    }
49
}
50