GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5119fb...242f35 )
by Andrea
02:50
created

MediaManager::hashName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php namespace Afrittella\BackProject\Services;
2
3
use Illuminate\Support\Facades\Storage;
4
use Illuminate\Http\Request;
5
/**
6
 * Class MediaManager
7
 * @package Afrittella\MediaManager
8
 */
9
class MediaManager {
10
11
    protected $media_path;
12
13
    public function __construct()
14
    {
15
        //@TODO implement google or s3 cloud storage support
16
        //if (config('filesystems.default') == 'google') {
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
17
          //  $this->media_path = Storage::disk()->getDriver()->getAdapter()->getStorageApiUri() . '/' . Storage::disk()->getDriver()->getAdapter()->getBucket()->name();
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
        //} else {
19
        //$this->media_path = Storage::disk()->getDriver()->getAdapter()->getPathPrefix();
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
20
        //}
21
    }
22
23
    public static function hello()
24
    {
25
        return "hello world";
26
    }
27
28
    /*public function getMediaPath()
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
    {
30
        return $this->media_path;
31
    }*/
32
33
    public function addAttachment($model)
34
    {
35
        return $model->addAttachment();
36
    }
37
38
    public function hashName($extension = 'jpg')
39
    {
40
        return str_random(32).'.'.$extension;
41
    }
42
43
    public function getCachedImageUrl($format, $name)
44
    {
45
        $format = $this->chooseFormat($format);
46
47
        return '/'.config('imagecache.route').'/'.$format.'/'.$name;
48
    }
49
50
    public function getCachedImageTag($format, $image, $attributes = "")
51
    {
52
        $format = $this->chooseFormat($format);
53
54
        return '<img src="'.$this->getCachedImageUrl($format, $image->name).'" alt="'.$image->description.'" '.$attributes. '>';
55
    }
56
57
    protected function chooseFormat($format)
58
    {
59
        $templates = array_keys(config('imagecache.templates'));
60
        $format = strtolower($format);
61
62
        if (!in_array($format, $templates)) {
63
            $format = 'original';
64
        }
65
66
        return $format;
67
    }
68
}
69