turnaev /
monitor-bundle
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * This file is part of the `tvi/monitor-bundle` project. |
||||||
| 5 | * |
||||||
| 6 | * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
||||||
| 7 | * |
||||||
| 8 | * For the full copyright and license information, please view the LICENSE.md |
||||||
| 9 | * file that was distributed with this source code. |
||||||
| 10 | */ |
||||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||||
| 11 | |||||||
| 12 | namespace Tvi\MonitorBundle\Controller; |
||||||
| 13 | |||||||
| 14 | use Symfony\Component\HttpFoundation\Request; |
||||||
| 15 | use Symfony\Component\HttpFoundation\Response; |
||||||
| 16 | use JMS\Serializer\Serializer; |
||||||
| 17 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||||||
| 18 | use Tvi\MonitorBundle\Exception\HttpException; |
||||||
| 19 | use Tvi\MonitorBundle\Reporter\ReporterManager; |
||||||
| 20 | use Tvi\MonitorBundle\Runner\RunnerManager; |
||||||
| 21 | |||||||
| 22 | /** |
||||||
|
0 ignored issues
–
show
|
|||||||
| 23 | * @property RunnerManager $runnerManager |
||||||
| 24 | * @property ReporterManager $reporterManager |
||||||
| 25 | * @property Serializer $serializer |
||||||
| 26 | * |
||||||
| 27 | * @author Vladimir Turnaev <[email protected]> |
||||||
| 28 | */ |
||||||
|
0 ignored issues
–
show
|
|||||||
| 29 | trait TraitApiInfoGroup |
||||||
| 30 | { |
||||||
| 31 | 4 | public function groupInfoAction(Request $request, string $id, string $version): Response |
|||||
|
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$version is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 32 | { |
||||||
| 33 | try { |
||||||
| 34 | 4 | $groups = $this->runnerManager->findGroups($id); |
|||||
| 35 | |||||||
| 36 | 3 | if (1 === \count($groups)) { |
|||||
| 37 | 2 | $group = current($groups); |
|||||
| 38 | |||||||
| 39 | 2 | return $this->creatResponse($group, Response::HTTP_OK, true); |
|||||
|
0 ignored issues
–
show
It seems like
creatResponse() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | 1 | throw new NotFoundHttpException(sprintf('Group "%s" not found', $id)); |
|||||
| 43 | 2 | } catch (NotFoundHttpException $e) { |
|||||
| 44 | 1 | $e = new HttpException($e->getStatusCode(), $e->getMessage()); |
|||||
| 45 | |||||||
| 46 | 1 | return $this->creatResponse($e->toArray(), $e->getStatusCode(), true); |
|||||
| 47 | 1 | } catch (\Exception $e) { |
|||||
| 48 | 1 | return $this->creatResponse($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR); |
|||||
| 49 | } |
||||||
| 50 | } |
||||||
| 51 | |||||||
| 52 | 7 | public function groupInfosAction(Request $request, string $version): Response |
|||||
|
0 ignored issues
–
show
The parameter
$version is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 53 | { |
||||||
| 54 | try { |
||||||
| 55 | 7 | list($ids, $_, $groups, $_) = $this->getFilterParams($request); |
|||||
|
0 ignored issues
–
show
It seems like
getFilterParams() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 56 | 7 | $groups = $groups ? $groups : $ids; |
|||||
| 57 | |||||||
| 58 | 7 | $groups = array_values($this->runnerManager->findGroups($groups)); |
|||||
| 59 | |||||||
| 60 | 6 | return $this->creatResponse($groups, Response::HTTP_OK, true); |
|||||
| 61 | 1 | } catch (\Exception $e) { |
|||||
| 62 | 1 | return $this->creatResponse($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR); |
|||||
| 63 | } |
||||||
| 64 | } |
||||||
| 65 | } |
||||||
| 66 |