Completed
Push — master ( 7888b2...3ffd2a )
by Dan Michael O.
02:27
created

CoverCache::putBlob()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
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
     *
24
     * @return CachedImage
25
     */
26
    public function get($url)
27
    {
28
        return new CachedImage($url);
29
    }
30
31
    /**
32
     * @param string $url
33
     * @param int    $maxHeight
34
     *
35
     * @throws \ErrorException
36
     *
37
     * @return CachedImage
38
     */
39
    public function putUrl($url, $maxHeight = 0)
40
    {
41
        $item = new CachedImage($url, $maxHeight);
42
        $item->store();
43
44
        return $item;
45
    }
46
47
    /**
48
     * @param binary $blob
49
     * @param int    $maxHeight
50
     *
51
     * @throws \ErrorException
52
     *
53
     * @return CachedImage
54
     */
55
    public function putBlob($blob, $maxHeight = 0)
56
    {
57
        $item = new CachedImage(null, $maxHeight);
58
        $item->store($blob);
59
60
        return $item;
61
    }
62
}
63