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 Nov 22, 2024
1 parent e1f130e commit e690f78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Driver/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace FoF\S3Assets\Driver;

use Flarum\Foundation\ValidationException;
use Flarum\Settings\SettingsRepositoryInterface;
use FoF\S3Assets\Validator\S3DiskConfigValidator;
use Illuminate\Validation\ValidationException as IlluminateValidationException;
Expand All @@ -23,7 +22,8 @@ public function __construct(
protected SettingsRepositoryInterface $settings,
protected S3DiskConfigValidator $validator,
protected LoggerInterface $logger,
) {}
) {
}

public function config(): array
{
Expand Down Expand Up @@ -58,6 +58,7 @@ public function config(): array
$this->validator->assertValid($config);
} catch (IlluminateValidationException $e) {
$this->logger->error('[fof-s3-assets] Invalid S3 disk configuration', ['errors' => $e->errors()]);

return [];
}

Expand Down
3 changes: 1 addition & 2 deletions src/Driver/S3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ public function build(
Config $config,
array $localConfig
): Cloud {

if (empty($this->config->config())) {
return $this->manager->createLocalDriver($localConfig);

Check failure on line 40 in src/Driver/S3Driver.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.0

Method FoF\S3Assets\Driver\S3Driver::build() should return Illuminate\Contracts\Filesystem\Cloud but returns Illuminate\Contracts\Filesystem\Filesystem.
}

$root = Arr::get($localConfig, 'root');
$root = str_replace($this->paths->public, '', $root);

Expand Down
13 changes: 11 additions & 2 deletions src/Validator/S3DiskConfigValidator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/s3-assets.
*
* Copyright (c) FriendsOfFlarum
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace FoF\S3Assets\Validator;

use Flarum\Foundation\AbstractValidator;
Expand All @@ -8,11 +17,11 @@ class S3DiskConfigValidator extends AbstractValidator
{
protected $rules = [
'driver' => ['required', 'string', 'in:s3'],
'key' => ['required', 'string'],
'key' => ['required', 'string'],
'secret' => ['required', 'string'],
'region' => ['required', 'string'],
'bucket' => ['required', 'string'],
'url' => ['url'],
'url' => ['url'],
//'endpoint' => ['url'],
'use_path_style_endpoint' => ['required', 'bool'],
//'options.ACL' => ['string'],
Expand Down

0 comments on commit e690f78

Please sign in to comment.