GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EmployeeController::fireAction()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 4
nc 3
nop 2
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the AL labs package
6
 *
7
 * (c) Arnaud Langlade
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Al\ResourceManagement\Infrastructure\UserInterface\Web;
14
15
use Al\ResourceManagement\Application\Command\FireEmployee;
16
use Al\ResourceManagement\Application\Command\HireEmployee;
17
use Al\ResourceManagement\Application\Command\PromoteEmployee;
18
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
19
use Symfony\Component\HttpFoundation\Request;
20
21
class EmployeeController extends Controller
22
{
23
    public function listAction(Request $request)
24
    {
25
        $employees = $this->get('al.employee.query')->findAll(
26
            (int) $request->get('page', 1),
27
            (int) $request->get('limit', 10)
28
        );
29
30
        return $this->render('employee/list.html.twig', [
31
            'employees' => $employees
32
        ]);
33
    }
34
35
    public function hireAction(Request $request)
36
    {
37
        $form = $this->createForm(EmployeeType::class, new HireEmployee());
38
        $form->handleRequest($request);
39
40
        if ($form->isSubmitted() && $form->isValid()) {
41
            /** @var HireEmployee $employeeCommand */
42
            $employeeCommand = $form->getData();
43
44
            try {
45
                $this->get('command_bus')->handle($employeeCommand);
46
            } catch (\Exception $e) {
47
                $this->addFlash('negative', 'An error occurs, please contact an administrator');
48
            }
49
50
            return $this->redirectToRoute('employee_list');
51
        }
52
53
        return $this->render('employee/hire.html.twig', [
54
            'form' => $form->createView()
55
        ]);
56
    }
57
58
    public function promoteAction($employeeId, Request $request)
59
    {
60
        $form = $this->createForm(EmployeeType::class, new PromoteEmployee($employeeId));
61
        $form->handleRequest($request);
62
63
        if ($form->isSubmitted() && $form->isValid()) {
64
            /** @var PromoteEmployee $promotion */
65
            $promotionCommand = $form->getData();
66
67
            try {
68
                $this->get('command_bus')->handle($promotionCommand);
69
            } catch (\Exception $e) {
70
                $this->addFlash('negative', 'An error occurs, please contact an administrator');
71
            }
72
73
            return $this->redirectToRoute('employee_list');
74
        }
75
76
        return $this->render('employee/promote.html.twig', [
77
            'form' => $form->createView()
78
        ]);
79
    }
80
81
    public function fireAction($employeeId, Request $request)
82
    {
83
        $form = $this->createForm(EmployeeType::class, new FireEmployee($employeeId));
84
        $form->handleRequest($request);
85
86
        if ($form->isSubmitted() && $form->isValid()) {
87
            /** @var FireEmployee $firing */
88
            $firingCommand = $form->getData();
89
90
            try {
91
                $this->get('command_bus')->handle($firingCommand);
92
            } catch (\Exception $e) {
93
                $this->addFlash('negative', 'An error occurs, please contact an administrator');
94
            }
95
96
            return $this->redirectToRoute('employee_list');
97
        }
98
99
        return $this->render('employee/fire.html.twig', [
100
            'form' => $form->createView()
101
        ]);
102
    }
103
}
104