ListCitiesUseCase::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace OpenTribes\Core\UseCase;
4
5
6
use OpenTribes\Core\Repository\CityRepository;
7
use OpenTribes\Core\Request\ListCitiesRequest;
8
use OpenTribes\Core\Response\ListCitiesResponse;
9
use OpenTribes\Core\View\CityListView;
10
11
class ListCitiesUseCase
12
{
13
    /**
14
     * @var CityRepository
15
     */
16
    private $userCityRepository;
17
18 2
    public function __construct(CityRepository $userCityRepository)
19
    {
20 2
        $this->userCityRepository = $userCityRepository;
21 2
    }
22
23 2
    public function process(ListCitiesRequest $request,ListCitiesResponse $response){
24 2
        $cities = $this->userCityRepository->findAllByUsername($request->getUsername());
25 2
        if(count($cities) < 1){
26 1
            return;
27
        }
28 1
        foreach($cities as $city){
29 1
            $cityListView = new CityListView($city);
30 1
            $response->addCity($cityListView);
31 1
        }
32
    }
33
}