CachingRegionsRepository::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Yajra\Address\Repositories\Regions;
4
5
use Illuminate\Contracts\Cache\Repository as Cache;
6
7
class CachingRegionsRepository extends RegionsRepositoryEloquent implements RegionsRepository
8
{
9
    /**
10
     * @var RegionsRepository
11
     */
12
    protected $repository;
13
14
    /**
15
     * @var Cache
16
     */
17
    protected $cache;
18
19
    /**
20
     * CachingRegionsRepository constructor.
21
     *
22
     * @param RegionsRepository $repository
23
     * @param Cache             $cache
24
     */
25
    public function __construct(RegionsRepository $repository, Cache $cache)
26
    {
27
28
        $this->repository = $repository;
29
        $this->cache      = $cache;
30
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Get all records.
36
     *
37
     * @return \Illuminate\Database\Eloquent\Collection
38
     */
39
    public function all()
40
    {
41
        return $this->cache->rememberForever('regions.all', function () {
42
            return $this->repository->getModel()->query()->orderBy('region_id', 'asc')->get();
0 ignored issues
show
Bug introduced by
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
43
        });
44
    }
45
}
46