CitiesRepositoryEloquent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getByProvinceAndRegion() 0 9 1
A getModel() 0 6 1
A getByRegion() 0 8 1
A getByProvince() 0 8 1
1
<?php
2
3
namespace Yajra\Address\Repositories\Cities;
4
5
use Yajra\Address\Entities\City;
6
use Yajra\Address\Repositories\EloquentBaseRepository;
7
8
class CitiesRepositoryEloquent extends EloquentBaseRepository implements CitiesRepository
9
{
10
    /**
11
     * Get cities by region ID and province ID.
12
     *
13
     * @param int $regionId
14
     * @param int $provinceId
15
     * @return \Illuminate\Database\Eloquent\Collection
16
     */
17
    public function getByProvinceAndRegion($regionId, $provinceId)
18
    {
19
        return $this->getModel()
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...
20
                    ->newQuery()
21
                    ->where('region_id', $regionId)
22
                    ->where('province_id', $provinceId)
23
                    ->orderBy('name', 'asc')
24
                    ->get();
25
    }
26
27
    /**
28
     * Get repository model.
29
     *
30
     * @return City
31
     */
32
    public function getModel()
33
    {
34
        $model = config('address.models.city', City::class);
35
36
        return new $model;
37
    }
38
39
    /**
40
     * Get cities by region.
41
     *
42
     * @param int $regionId
43
     * @return \Illuminate\Database\Eloquent\Collection
44
     */
45
    public function getByRegion($regionId)
46
    {
47
        return $this->getModel()
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...
48
                    ->newQuery()
49
                    ->where('region_id', $regionId)
50
                    ->orderBy('name', 'asc')
51
                    ->get();
52
    }
53
54
    /**
55
     * Get cities by province.
56
     *
57
     * @param int $provinceId
58
     * @return \Illuminate\Database\Eloquent\Collection
59
     */
60
    public function getByProvince($provinceId)
61
    {
62
        return $this->getModel()
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...
63
                    ->newQuery()
64
                    ->where('province_id', $provinceId)
65
                    ->orderBy('name', 'asc')
66
                    ->get();
67
    }
68
}
69