Applied code style rules to src/

This commit is contained in:
Jan Böhmer 2020-01-05 15:46:58 +01:00
parent 700c049d26
commit f861de791f
186 changed files with 1462 additions and 1059 deletions

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -42,7 +45,6 @@ class EntityExporter
/**
* Exports an Entity or an array of entities to multiple file formats.
*
* @param $entity NamedDBElement|NamedDBElement[] The element/elements[] that should be exported
* @param Request $request the request that should be used for option resolving
*
* @return Response the generated response containing the exported data
@ -54,13 +56,13 @@ class EntityExporter
$format = $request->get('format') ?? 'json';
//Check if we have one of the supported formats
if (!\in_array($format, ['json', 'csv', 'yaml', 'xml'])) {
if (! \in_array($format, ['json', 'csv', 'yaml', 'xml'], true)) {
throw new \InvalidArgumentException('Given format is not supported!');
}
//Check export verbosity level
$level = $request->get('level') ?? 'extended';
if (!\in_array($level, ['simple', 'extended', 'full'])) {
if (! \in_array($level, ['simple', 'extended', 'full'], true)) {
throw new \InvalidArgumentException('Given level is not supported!');
}
@ -80,9 +82,11 @@ class EntityExporter
switch ($format) {
case 'xml':
$content_type = 'application/xml';
break;
case 'json':
$content_type = 'application/json';
break;
}
@ -104,7 +108,7 @@ class EntityExporter
$response->headers->set('Content-Type', $content_type);
//If view option is not specified, then download the file.
if (!$request->get('view')) {
if (! $request->get('view')) {
if ($entity instanceof NamedDBElement) {
$entity_name = $entity->getName();
} elseif (\is_array($entity)) {