CachingRegionsRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A all() 0 6 1
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