| Total Complexity | 12 |
| Total Lines | 100 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 27 | class Examples extends GvController |
||
| 28 | { |
||
| 29 | /** |
||
| 30 | * @OA\Get( |
||
| 31 | * path="/examples", |
||
| 32 | * @OA\Response(response="200", description="An example resource") |
||
| 33 | * ) |
||
| 34 | */ |
||
| 35 | public function index() |
||
| 36 | { |
||
| 37 | $this->viewParams = ['csrf' => $this->generateCSRFToken()]; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @throws NotFoundException |
||
| 42 | * @throws \ReflectionException |
||
| 43 | */ |
||
| 44 | public function login() |
||
| 45 | { |
||
| 46 | $this->httpRequest->validate(); |
||
| 47 | $loginCommand = $this->getLoginCommand(); |
||
|
1 ignored issue
–
show
|
|||
| 48 | $loginCommand->setUsername($this->httpRequest->getParameter('username')); |
||
| 49 | $loginCommand->setPassword($this->httpRequest->getParameter('password')); |
||
| 50 | |||
| 51 | $loginCommand->execute(); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function logout() |
||
| 55 | { |
||
| 56 | $userService = $this->getUserService(); |
||
|
1 ignored issue
–
show
|
|||
| 57 | $userService->logout(); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function asd() |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @throws \Doctrine\ORM\OptimisticLockException |
||
| 67 | * @throws \Exception |
||
| 68 | * @httpMethod("POST") |
||
| 69 | */ |
||
| 70 | public function qwe() |
||
| 71 | { |
||
| 72 | $this->validateCSRFToken($this->httpRequest->getParameter('csrf')); |
||
| 73 | $registerUserCommand = $this->getCreateNewUserCommand(); |
||
|
1 ignored issue
–
show
|
|||
| 74 | $registerUserCommand |
||
| 75 | ->setName($this->httpRequest->getParameter('username')) |
||
| 76 | ->setEmail($this->httpRequest->getParameter('email')) |
||
| 77 | ->setPassword($this->httpRequest->getParameter('password')); |
||
| 78 | |||
| 79 | $registerUserCommand->execute(); |
||
| 80 | |||
| 81 | $file = $this->httpRequest->getFileByPropertyName("avatar-pic"); |
||
| 82 | |||
| 83 | $this->httpRequest->moveFileToDirectory("/tmp/", $file); |
||
| 84 | } |
||
| 85 | |||
| 86 | public function lorep() |
||
| 87 | { |
||
| 88 | $this->httpResponse->response(Locale::getLocale("Hello world")); |
||
| 89 | } |
||
| 90 | |||
| 91 | public function authorization() |
||
| 92 | { |
||
| 93 | $user = $this->getEntityManager()->getRepository(User::class)->findOneBy(['username' => 'mod']); |
||
| 94 | $service = $this->getUserService(); |
||
| 95 | $this->httpResponse->response(new JSONResponse(['can all' => $service->userCan($user, 'all')])); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @throws NotImplementedMethodException |
||
| 100 | */ |
||
| 101 | public function transformer() |
||
| 102 | { |
||
| 103 | $entityManager = $this->getEntityManager(); |
||
| 104 | $repository = $entityManager->getRepository(User::class); |
||
| 105 | $user = $repository->findOneBy(['username' => 'asda']); |
||
| 106 | |||
| 107 | $this->httpResponse->response(new TransformerResponse(new UserTransformer($user))); |
||
| 108 | } |
||
| 109 | |||
| 110 | public function basicAuth() |
||
| 111 | { |
||
| 112 | try { |
||
| 113 | $this->mustPassBasicAuthentication(); |
||
| 114 | } catch (\Throwable $e) { |
||
| 115 | $content = ['message' => $e->getMessage()]; |
||
| 116 | $this->httpResponse->response(new JSONResponse($content, Response::HTTP_RESPONSE_UNAUTHORIZED)); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | public function jwt() |
||
| 127 | } |
||
| 128 | } |
||
| 129 | } |
||
| 130 |