Completed
Push — master ( 12ca16...9348e1 )
by Arjay
12:40
created

FileAssetCacheRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
cc 1
eloc 3
nc 1
nop 2
rs 9.4285
1
<?php
2
3
namespace Yajra\CMS\Repositories\FileAsset;
4
5
use Illuminate\Contracts\Cache\Repository as Cache;
6
7
class FileAssetCacheRepository implements FileAssetRepository
8
{
9
    /**
10
     * @var \Yajra\CMS\Repositories\FileAsset\FileAssetRepository
11
     */
12
    private $repository;
13
14
    /**
15
     * @var \Illuminate\Contracts\Cache\Repository
16
     */
17
    private $cache;
18
19
    /**
20
     * FileAssetCacheRepository constructor.
21
     *
22
     * @param \Yajra\CMS\Repositories\FileAsset\FileAssetRepository $repository
23
     * @param \Illuminate\Contracts\Cache\Repository $cache
24
     */
25
    public function __construct(FileAssetRepository $repository, Cache $cache)
26
    {
27
        $this->repository = $repository;
28
        $this->cache      = $cache;
29
    }
30
31
    /**
32
     * Get all file assets.
33
     *
34
     * @return \Illuminate\Database\Eloquent\Collection|static[]
35
     */
36
    public function all()
37
    {
38
        return $this->cache->rememberForever('fileAssets.all', function () {
39
            return $this->repository->all();
40
        });
41
    }
42
43
    /**
44
     * Register admin required assets.
45
     */
46
    public function registerAdminRequireAssets()
47
    {
48
        return $this->repository->registerAdminRequireAssets();
49
    }
50
51
    /**
52
     * Get file asset by name.
53
     *
54
     * @param string $name
55
     * @return FileAsset
56
     */
57
    public function getByName($name)
58
    {
59
        return $this->repository->getByName($name);
60
    }
61
62
    /**
63
     * Add site asset.
64
     *
65
     * @param string $type
66
     * @return \Roumen\Asset\Asset;
0 ignored issues
show
Documentation introduced by
The doc-type \Roumen\Asset\Asset; could not be parsed: Expected "|" or "end of type", but got ";" at position 19. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
67
     */
68
    public function addAsset($type)
69
    {
70
        return $this->repository->addAsset($type);
71
    }
72
73
    /**
74
     * @param string $str
75
     * @return string
76
     */
77
    public function strParser($str)
78
    {
79
        return $this->repository->strParser($str);
80
    }
81
}