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

CountryStateController   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 index() 0 8 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Http\Controllers\Front\Addresses;
4
5
use App\Http\Controllers\Controller;
6
use App\Shop\Countries\Repositories\CountryRepository;
7
use App\Shop\Countries\Repositories\Interfaces\CountryRepositoryInterface;
8
9
class CountryStateController extends Controller
10
{
11
    private $countryRepo;
12
13
    /**
14
     * CountryStateController constructor.
15
     *
16
     * @param CountryRepositoryInterface $countryRepository
17
     */
18
    public function __construct(CountryRepositoryInterface $countryRepository)
19
    {
20
        $this->countryRepo = $countryRepository;
21
    }
22
23
    /**
24
     * @param $countryId
25
     *
26
     * @return \Illuminate\Http\JsonResponse
27
     */
28
    public function index($countryId)
29
    {
30
        $country = $this->countryRepo->findCountryById($countryId);
31
32
        $countryRepo = new CountryRepository($country);
33
        $data = $countryRepo->listStates();
34
35
        return response()->json(compact('data'));
36
    }
37
}