Completed
Push — dev ( 6a93ce...82e8fe )
by Zach
03:22
created

PageImageController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 45
loc 45
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A index() 4 4 1
A store() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Larafolio\Http\Controllers;
4
5
use Larafolio\Models\Page;
6
use Illuminate\Http\Request;
7
use Larafolio\Http\Content\ContentImages;
8
9 View Code Duplication
class PageImageController extends Controller
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * Service class for content images.
13
     *
14
     * @var Larafolio\Http\Content\ContentImages
15
     */
16
    protected $contentImages;
17
18
    /**
19
     * Construct.
20
     *
21
     * @param Larafolio\Http\Content\ContentImages $contentImages Service class for content images.
22
     */
23
    public function __construct(ContentImages $contentImages)
24
    {
25
        parent::__construct();
26
27
        $this->contentImages = $contentImages;
0 ignored issues
show
Documentation Bug introduced by
It seems like $contentImages of type object<Larafolio\Http\Content\ContentImages> is incompatible with the declared type object<Larafolio\Http\Co...\Content\ContentImages> of property $contentImages.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
    }
29
30
    /**
31
     * Show images for project.
32
     *
33
     * @param \Illuminate\Http\Request $request Request from user.
34
     * @param Larafolio\Models\Page    $page    Page to show.
35
     *
36
     * @return \Illuminate\Http\Response
37
     */
38
    public function index(Request $request, Page $page)
39
    {
40
        return $this->contentImages->getImages($request, $page, 'page');
41
    }
42
43
    /**
44
     * Add a new page image.
45
     *
46
     * @param \Illuminate\Http\Request $request Form request.
47
     * @param Larafolio\Models\Page    $page    The page to add the image too.
48
     */
49
    public function store(Request $request, Page $page)
50
    {
51
        $this->contentImages->store($request, $page, $this->user);
52
    }
53
}
54