Completed
Push — master ( 03ba26...623769 )
by Jacob
34s
created

AssetManager::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the limit0/assets package.
5
 *
6
 * (c) Limit Zero, LLC <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Limit0\Assets;
13
14
/**
15
 * The AssetManager provides a wrapper for your configured storage engine.
16
 *
17
 * @author  Josh Worden <[email protected]>
18
 */
19
class AssetManager
20
{
21
    /**
22
     * @var     StorageEngineInterface
23
     */
24
    private $storageEngine;
25
26
    /**
27
     * Returns the storage engine
28
     *
29
     * @throws  Exception\ManagerException
30
     * @return  StorageEngineInterface
31
     */
32
    public function getStorageEngine()
33
    {
34
        if (null === $this->storageEngine) {
35
            throw Exception\ManagerException::missingStorageEngine();
36
        }
37
        return $this->storageEngine;
38
    }
39
40
    /**
41
     * Removes an asset
42
     *
43
     * @param   string  $identifier
44
     */
45
    public function remove($identifier)
46
    {
47
        return $this->getStorageEngine()->remove($identifier);
48
    }
49
50
    /**
51
     * Retrieves an asset
52
     *
53
     * @param   string  $identifier
54
     * @return  Asset
55
     */
56
    public function retrieve($identifier)
57
    {
58
        return $this->getStorageEngine()->retrieve($identifier);
59
    }
60
61
    /**
62
     * Stores an asset
63
     *
64
     * @param   Asset   $asset
65
     * @return  Asset
66
     */
67
    public function store(Asset $asset, $path = null, $filename = null)
68
    {
69
        return $this->getStorageEngine()->store($asset, $path, $filename);
70
    }
71
72
    /**
73
     * Sets the storage engine
74
     *
75
     * @param   StorageEngineInterface
76
     */
77
    public function setStorageEngine(StorageEngineInterface $storageEngine)
78
    {
79
        $this->storageEngine = $storageEngine;
80
        return $this;
81
    }
82
}
83