Completed
Push — feature/fixing_cost ( f58af6...414fbf )
by Laurent
01:41
created

DamageController::view()   A

Complexity

Conditions 2
Paths 5

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 5
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
4
namespace FlightLog\Http\Web\Controller;
5
6
7
use FlightLog\Infrastructure\Damage\Query\Repository\GetDamageQueryRepository;
8
use Form;
9
10
final class DamageController extends WebController
11
{
12
13
    /**
14
     * @return GetDamageQueryRepository
15
     */
16
    private function getDamageRepository(){
17
        return new GetDamageQueryRepository($this->db);
18
    }
19
20
    public function view(){
21
        $damageId = $this->request->getParam('id');
22
23
        try{
24
            $damage = $this->getDamageRepository()->query($damageId);
25
26
            $flight = new \Bbcvols($this->db);
27
            $flight->fetch($damage->getFlightId());
28
29
            $this->render('damage/view.php', [
30
                'damage' => $damage,
31
                'form' => new Form($this->db),
32
                'flight' => $flight
33
            ]);
34
        }catch (\Exception $e){
35
            echo $e->getMessage();
36
        }
37
    }
38
39
    public function invoice(){
40
        $damageId = $this->request->getParam('id');
41
42
43
44
        $this->redirect($_SERVER["PHP_SELF"].'?id='.$damageId);
45
        exit;
46
    }
47
}