Completed
Push — master ( f426cf...89f4ba )
by Dan Michael O.
03:59 queued 01:41
created

CoverCache   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A url() 0 8 1
A putUrl() 0 7 1
A putBlob() 0 7 1
1
<?php
2
3
namespace Colligator;
4
5
class CoverCache
6
{
7
    /**
8
     * @param string $key
9
     *
10
     * @return string
11
     */
12
    public function url($key)
13
    {
14
        return sprintf('https://s3.%s.amazonaws.com/%s/%s',
15
            \Config::get('filesystems.disks.s3.region'),
16
            \Config::get('filesystems.disks.s3.bucket'),
17
            $key
18
        );
19
    }
20
21
    /**
22
     * @param string $url
23
     * @param int    $maxHeight
24
     *
25
     * @throws \ErrorException
26
     *
27
     * @return CachedImage
28
     */
29
    public function putUrl($url, $maxHeight = 0)
30
    {
31
        $item = new CachedImage($url, $maxHeight);
32
        $item->store();
33
34
        return $item;
35
    }
36
37
    /**
38
     * @param binary $blob
39
     * @param int    $maxHeight
40
     *
41
     * @throws \ErrorException
42
     *
43
     * @return CachedImage
44
     */
45
    public function putBlob($blob, $maxHeight = 0)
46
    {
47
        $item = new CachedImage(null, $maxHeight);
48
        $item->store($blob);
49
50
        return $item;
51
    }
52
}
53