ListDirectionsUseCase::__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
namespace OpenTribes\Core\UseCase;
3
4
use OpenTribes\Core\Repository\DirectionRepository;
5
use OpenTribes\Core\Request\ListDirectionsRequest;
6
use OpenTribes\Core\Response\ListDirectionsResponse;
7
use OpenTribes\Core\View\DirectionView;
8
9
class ListDirectionsUseCase {
10
    private $directionRepository;
11
12 6
    public function __construct(DirectionRepository $directionRepository)
13
    {
14 6
        $this->directionRepository = $directionRepository;
15 6
    }
16
17 3
    public function process(ListDirectionsRequest $request,ListDirectionsResponse $response){
18 3
        $directions = $this->directionRepository->findAll();
19 3
        foreach($directions as $direction){
20 3
            $directionView = new DirectionView($direction);
21 3
            if($request->getDirection() === $direction->getName()){
22 1
                $directionView->select();
23 1
            }
24 3
            $response->addDirection($directionView);
25 3
        }
26
27
    }
28
}