ListCitiesUseCase   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 1
cbo 4
dl 0
loc 23
rs 10
ccs 12
cts 12
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 10 3
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
}