Fit   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 2
lcom 1
cbo 1
dl 23
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 8 8 2

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 namespace Modules\Media\Image\Intervention\Manipulations;
2
3
use Modules\Media\Image\ImageHandlerInterface;
4
5 View Code Duplication
class Fit implements ImageHandlerInterface
6
{
7
    private $defaults = [
8
        'width' => 100,
9
        'height' => null,
10
        'position' => 'center',
11
    ];
12
13
    /**
14
     * Handle the image manipulation request
15
     * @param  \Intervention\Image\Image $image
16
     * @param  array                     $options
17
     * @return \Intervention\Image\Image
18
     */
19
    public function handle($image, $options)
20
    {
21
        $options = array_merge($this->defaults, $options);
22
23
        $callback = isset($options['callback']) ? $options['callback'] : null;
24
25
        return $image->fit($options['width'], $options['height'], $callback, $options['position']);
26
    }
27
}
28