Passed
Push — master ( 4a884d...c9d1fc )
by Jeff
12:14
created

StateCityController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 27
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A index() 0 8 1
1
<?php
2
3
namespace App\Http\Controllers\Front\Addresses;
4
5
use App\Http\Controllers\Controller;
6
use App\Shop\States\Repositories\StateRepository;
7
use App\Shop\States\Repositories\StateRepositoryInterface;
8
9
class StateCityController extends Controller
10
{
11
    private $stateRepo;
12
13
    /**
14
     * StateCityController constructor.
15
     *
16
     * @param StateRepositoryInterface $stateRepository
17
     */
18
    public function __construct(StateRepositoryInterface $stateRepository)
19
    {
20
        $this->stateRepo = $stateRepository;
21
    }
22
23
    /**
24
     * @param $state_code
25
     *
26
     * @return \Illuminate\Http\JsonResponse
27
     */
28
    public function index($state_code)
29
    {
30
        $state = $this->stateRepo->findOneBy(compact('state_code'));
31
32
        $stateRepo = new StateRepository($state);
33
        $data = $stateRepo->listCities();
34
35
        return response()->json(compact('data'));
36
    }
37
}