Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Feb 12, 2025
1 parent ca72b6d commit 79a319b
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 36 deletions.
10 changes: 5 additions & 5 deletions src/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class ConfigFactory
/**
* Retrieves and merges the configuration for the specified documentation.
*
* @param string|null $documentation The name of the documentation configuration to retrieve. If null, the default documentation configuration is used.
* @param string|null $documentation The name of the documentation configuration to retrieve. If null, the default documentation configuration is used.
* @return array The merged configuration for the specified documentation.
*
* @throws L5SwaggerException If the specified documentation configuration is not found.
*/
public function documentationConfig(?string $documentation = null): array
Expand All @@ -29,13 +30,12 @@ public function documentationConfig(?string $documentation = null): array
return $this->mergeConfig($defaults, $documentations[$documentation]);
}


/**
* Merges two configuration arrays recursively, with the values from the second array
* overriding those in the first array when keys overlap.
*
* @param array $defaults The default configuration array.
* @param array $config The configuration array to merge into the defaults.
* @param array $defaults The default configuration array.
* @param array $config The configuration array to merge into the defaults.
* @return array The merged configuration array.
*/
private function mergeConfig(array $defaults, array $config): array
Expand All @@ -60,7 +60,7 @@ private function mergeConfig(array $defaults, array $config): array
/**
* Determines whether a given value is an associative array.
*
* @param mixed $value The value to be checked.
* @param mixed $value The value to be checked.
* @return bool True if the value is an associative array, false otherwise.
*/
private function isAssociativeArray(mixed $value): bool
Expand Down
7 changes: 4 additions & 3 deletions src/Console/GenerateDocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct()
protected $description = 'Regenerate docs';

/**
* @param GeneratorFactory $generatorFactory
* @param GeneratorFactory $generatorFactory
*
* @throws L5SwaggerException
*/
Expand Down Expand Up @@ -58,9 +58,10 @@ public function handle(GeneratorFactory $generatorFactory): void
/**
* Generates documentation using the specified generator factory.
*
* @param GeneratorFactory $generatorFactory The factory used to create the documentation generator.
* @param string $documentation The name or identifier of the documentation to be generated.
* @param GeneratorFactory $generatorFactory The factory used to create the documentation generator.
* @param string $documentation The name or identifier of the documentation to be generated.
* @return void
*
* @throws L5SwaggerException
*/
private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation): void
Expand Down
19 changes: 8 additions & 11 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ class Generator
/**
* Constructor to initialize documentation generation settings and dependencies.
*
* @param array $paths Array of paths including annotations, docs, excluded directories, and base path.
* @param array $constants Array of constants to be used during documentation generation.
* @param bool $yamlCopyRequired Determines if a YAML copy of the documentation is required.
* @param SecurityDefinitions $security Security definitions for the documentation.
* @param array $scanOptions Additional options for scanning files or directories.
* @param Filesystem|null $filesystem Filesystem instance, optional, defaults to a new Filesystem.
*
* @param array $paths Array of paths including annotations, docs, excluded directories, and base path.
* @param array $constants Array of constants to be used during documentation generation.
* @param bool $yamlCopyRequired Determines if a YAML copy of the documentation is required.
* @param SecurityDefinitions $security Security definitions for the documentation.
* @param array $scanOptions Additional options for scanning files or directories.
* @param Filesystem|null $filesystem Filesystem instance, optional, defaults to a new Filesystem.
* @return void
*/
public function __construct(
Expand Down Expand Up @@ -199,8 +198,7 @@ protected function createOpenApiGenerator(): OpenApiGenerator
/**
* Set the processors for the OpenAPI generator.
*
* @param OpenApiGenerator $generator The OpenAPI generator instance to configure.
*
* @param OpenApiGenerator $generator The OpenAPI generator instance to configure.
* @return void
*/
protected function setProcessors(OpenApiGenerator $generator): void
Expand All @@ -227,8 +225,7 @@ function (callable $pipe) use ($processorClasses, &$newPipeLine) {
/**
* Set the analyser for the OpenAPI generator based on scan options.
*
* @param OpenApiGenerator $generator The OpenAPI generator instance.
*
* @param OpenApiGenerator $generator The OpenAPI generator instance.
* @return void
*/
protected function setAnalyser(OpenApiGenerator $generator): void
Expand Down
7 changes: 5 additions & 2 deletions src/GeneratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

class GeneratorFactory
{
public function __construct(private readonly ConfigFactory $configFactory) {}
public function __construct(private readonly ConfigFactory $configFactory)
{
}

/**
* Creates and returns a new Generator instance based on the provided documentation configuration.
*
* @param string $documentation The name or identifier of the documentation to generate.
* @param string $documentation The name or identifier of the documentation to generate.
* @return Generator The configured Generator instance.
*
* @throws L5SwaggerException
*/
public function make(string $documentation): Generator
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/SwaggerAssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/
class SwaggerAssetController extends BaseController
{

/**
* Serves a specific documentation asset for the Swagger UI interface.
*
* @param Request $request The incoming HTTP request, which includes parameters to locate the requested asset.
* @param Request $request The incoming HTTP request, which includes parameters to locate the requested asset.
* @return Response The HTTP response containing the requested asset content or a 404 error if the asset is not found.
*
* @throws FileNotFoundException
*/
public function index(Request $request): Response
Expand Down
14 changes: 7 additions & 7 deletions src/Http/Controllers/SwaggerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ class SwaggerController extends BaseController
public function __construct(
private readonly GeneratorFactory $generatorFactory,
private readonly ConfigFactory $configFactory
) { }
) {
}

/**
* Handles requests for API documentation and returns the corresponding file content.
*
* @param Request $request The HTTP request containing parameters such as documentation and configuration.
* @param Request $request The HTTP request containing parameters such as documentation and configuration.
* @return Response The HTTP response containing the documentation file content with appropriate headers.
*
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException If the documentation file does not exist.
Expand Down Expand Up @@ -84,7 +85,7 @@ public function docs(Request $request): Response
/**
* Handles the API request and renders the Swagger documentation view.
*
* @param Request $request The HTTP request containing necessary parameters such as documentation and configuration details.
* @param Request $request The HTTP request containing necessary parameters such as documentation and configuration details.
* @return Response The HTTP response rendering the Swagger documentation view.
*/
public function api(Request $request): Response
Expand Down Expand Up @@ -131,7 +132,7 @@ public function api(Request $request): Response
/**
* Handles the OAuth2 callback and retrieves the required file for the redirect.
*
* @param Request $request The HTTP request containing necessary parameters.
* @param Request $request The HTTP request containing necessary parameters.
* @return string The content of the OAuth2 redirect file.
*
* @throws FileNotFoundException
Expand All @@ -148,9 +149,8 @@ public function oauth2Callback(Request $request): string
/**
* Generate the URL for accessing the documentation file based on the provided configuration.
*
* @param string $documentation The name of the documentation instance.
* @param array $config The configuration settings for generating the documentation URL.
*
* @param string $documentation The name of the documentation instance.
* @param array $config The configuration settings for generating the documentation URL.
* @return string The generated URL for the documentation file.
*/
protected function generateDocumentationFileURL(string $documentation, array $config): string
Expand Down
8 changes: 5 additions & 3 deletions src/Http/Middleware/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ class Config
{
public function __construct(
private readonly ConfigFactory $configFactory
) {}
) {
}

/**
* Handles the incoming request by extracting documentation configuration and setting it on the request.
*
* @param mixed $request The incoming HTTP request.
* @param Closure $next The next middleware in the pipeline.
* @param mixed $request The incoming HTTP request.
* @param Closure $next The next middleware in the pipeline.
* @return mixed The processed HTTP response after passing through the next middleware.
*
* @throws L5SwaggerException
*/
public function handle(mixed $request, Closure $next): mixed
Expand Down
2 changes: 2 additions & 0 deletions src/L5SwaggerFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class L5SwaggerFacade extends Facade
{
/**
* Get the registered name of the component being accessed through the facade.
*
* @codeCoverageIgnore
*
* @return string The name or class of the underlying component.
*/
protected static function getFacadeAccessor(): string
Expand Down
3 changes: 2 additions & 1 deletion src/SecurityDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class SecurityDefinitions
public function __construct(
private readonly array $securitySchemesConfig = [],

Check notice on line 12 in src/SecurityDefinitions.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/SecurityDefinitions.php#L12

Avoid excessively long variable names like $securitySchemesConfig. Keep variable name length under 20.
private readonly array $securityConfig = []
) {}
) {
}

/**
* Reads in the l5-swagger configuration and appends security settings to documentation.
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/**
* Returns swagger-ui composer dist path.
*
* @param string $documentation
* @param string|null $asset
* @param string $documentation
* @param string|null $asset
* @return false|string
*
* @throws L5SwaggerException
Expand Down

0 comments on commit 79a319b

Please sign in to comment.