ArtificerImage::path()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
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
}