ArtificerImage   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 19 4
A get() 0 4 1
A path() 0 4 1
1
<?php namespace Mascame\Artificer;
2
3
use File;
4
5
class ArtificerImage
6
{
7
8
    public $image;
9
10
//	public function __construct(\Intervention\Image\Image $image) {
11
//		$this->image = $image;
12
//	}
13
14
    public static function store(\Intervention\Image\Image $image, $path = null, $quality = null)
15
    {
16
        if (!$path) {
17
            $pathinfo = pathinfo($path);
18
            $path = $pathinfo['dirname'];
19
        }
20
21
        if (!file_exists($path)) {
22
            File::makeDirectory($path, 0777, true, true);
23
        }
24
25
        $filename = $path . $image->filename . '.' . $image->extension;
26
27
        if (!file_exists($filename)) {
28
            return $image->save($filename, $quality);
29
        }
30
31
        return false;
32
    }
33
34
    public static function get($image, $layout)
35
    {
36
        return 'uploads/' . $layout . '/' . $image;
37
    }
38
39
    public static function path($image, $layout)
40
    {
41
        return public_path() . 'uploads/' . $layout . '/' . $image;
42
    }
43
44
}