Skip to content

Commit c5eb76f

Browse files
committed
phpcs client
1 parent afff11a commit c5eb76f

28 files changed

Lines changed: 58 additions & 156 deletions

src/Keboola/StorageApi/ABSUploader.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
99
use MicrosoftAzure\Storage\Blob\Models\CommitBlobBlocksOptions;
1010
use MicrosoftAzure\Storage\Blob\Models\CreateBlockBlobOptions;
11-
use MicrosoftAzure\Storage\Common\Models\ServiceOptions;
1211

1312
/** @internal class used by the client for uploading files to file storage */
1413
class ABSUploader
1514
{
16-
const CHUNK_SIZE = 4 * 1024 * 1024; // 4MiB
17-
const MAX_PARALLEL_CHUNKS = 125;
18-
const PADLENGTH = 5; // Size of the string used for the block ID, modify if needed.
15+
public const CHUNK_SIZE = 4 * 1024 * 1024; // 4MiB
16+
public const MAX_PARALLEL_CHUNKS = 125;
17+
public const PADLENGTH = 5; // Size of the string used for the block ID, modify if needed.
1918

2019
/** @var BlobRestProxy */
2120
private $blobClient;
@@ -75,7 +74,7 @@ private function uploadAsync($container, $file, $blobName, $parallel, $options =
7574
$options = new CommitBlobBlocksOptions();
7675
}
7776
$promise = new Promise(\Closure::bind(function () use (&$promise, $container, $blobName, $file, $options) {
78-
list($promises, $blockIds) = $this->uploadByBlocks($container, $blobName, $file);
77+
[$promises, $blockIds] = $this->uploadByBlocks($container, $blobName, $file);
7978
PromiseHelper::all($promises);
8079
$promise->resolve($this->blobClient->commitBlobBlocks($container, $blobName, $blockIds, $options));
8180
}, $this));

src/Keboola/StorageApi/BranchAwareClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class BranchAwareClient extends Client
2525
*/
2626
private array $config;
2727

28-
/**
29-
* @param array $config
30-
*/
3128
public function __construct(int|string $branchId, array $config = [])
3229
{
3330
parent::__construct($config);

src/Keboola/StorageApi/Client.php

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@
4646
class Client
4747
{
4848
// Request options
49-
const ALLOWED_REQUEST_OPTIONS = [
49+
public const ALLOWED_REQUEST_OPTIONS = [
5050
Client::REQUEST_OPTION_EXTENDED_TIMEOUT,
5151
Client::REQUEST_OPTION_HEADERS,
5252
];
53-
const REQUEST_OPTION_EXTENDED_TIMEOUT = 'isExtendedTimeout';
53+
public const REQUEST_OPTION_EXTENDED_TIMEOUT = 'isExtendedTimeout';
5454
public const REQUEST_OPTION_HEADERS = 'headers';
5555

5656
// Stage names
57-
const DEFAULT_RETRIES_COUNT = 15;
58-
const STAGE_IN = 'in';
59-
const STAGE_OUT = 'out';
60-
const STAGE_SYS = 'sys';
61-
const API_VERSION = 'v2';
57+
public const DEFAULT_RETRIES_COUNT = 15;
58+
public const STAGE_IN = 'in';
59+
public const STAGE_OUT = 'out';
60+
public const STAGE_SYS = 'sys';
61+
public const API_VERSION = 'v2';
6262

63-
const VERSION = '14';
63+
public const VERSION = '14';
6464

65-
const FILE_PROVIDER_AWS = 'aws';
66-
const FILE_PROVIDER_AZURE = 'azure';
67-
const FILE_PROVIDER_GCP = 'gcp';
65+
public const FILE_PROVIDER_AWS = 'aws';
66+
public const FILE_PROVIDER_AZURE = 'azure';
67+
public const FILE_PROVIDER_GCP = 'gcp';
6868

6969
// Errors
70-
const ERROR_CANNOT_DOWNLOAD_FILE = 'Cannot download file "%s" (ID %s) from Storage, please verify the contents of the file and that the file has not expired.';
70+
public const ERROR_CANNOT_DOWNLOAD_FILE = 'Cannot download file "%s" (ID %s) from Storage, please verify the contents of the file and that the file has not expired.';
7171

7272
// Token string
7373
public $token;
@@ -926,7 +926,7 @@ public function createTableDefinition($bucketId, $data = [])
926926
public function updateTableColumnDefinition(
927927
string $tableId,
928928
string $columnName,
929-
array $columnDefinition
929+
array $columnDefinition,
930930
): array {
931931
/** @var array $updatedTable */
932932
$updatedTable = $this->apiPutJson("tables/{$tableId}/columns/{$columnName}/definition", $columnDefinition);
@@ -1875,7 +1875,7 @@ public function uploadFile(
18751875
private function uploadFileToGcs(
18761876
array $prepareResult,
18771877
string $filePath,
1878-
bool $isPermanent
1878+
bool $isPermanent,
18791879
): void {
18801880
$refreshCallableWrapper = new RefreshFileCredentialsWrapper($this, $prepareResult['id']);
18811881
$gcsUploader = new GCSUploader([
@@ -1901,7 +1901,7 @@ private function uploadFileToGcs(
19011901
*/
19021902
private function uploadFileToAbs(
19031903
array $prepareResult,
1904-
$filePath
1904+
$filePath,
19051905
) {
19061906
$blobClient = BlobClientFactory::createClientFromConnectionString(
19071907
$prepareResult['absUploadParams']['absCredentials']['SASConnectionString'],
@@ -1939,7 +1939,7 @@ private function uploadFileToS3(
19391939
array $prepareResult,
19401940
$filePath,
19411941
FileUploadOptions $newOptions,
1942-
?FileUploadTransferOptions $transferOptions = null
1942+
?FileUploadTransferOptions $transferOptions = null,
19431943
) {
19441944
$uploadParams = $prepareResult['uploadParams'];
19451945
$s3options = [
@@ -2081,7 +2081,7 @@ public function uploadSlicedFile(
20812081

20822082
private function uploadSlicedFileToAbs(
20832083
array $prepareResult,
2084-
array $slices
2084+
array $slices,
20852085
) {
20862086
$blobClient = BlobClientFactory::createClientFromConnectionString(
20872087
$prepareResult['absUploadParams']['absCredentials']['SASConnectionString'],
@@ -2116,7 +2116,7 @@ private function uploadSlicedFileToS3(
21162116
array $preparedFileResult,
21172117
array $slices,
21182118
FileUploadOptions $newOptions,
2119-
?FileUploadTransferOptions $transferOptions = null
2119+
?FileUploadTransferOptions $transferOptions = null,
21202120
) {
21212121
$uploadParams = $preparedFileResult['uploadParams'];
21222122
$options = [
@@ -3035,9 +3035,6 @@ private function log($message, $context = [])
30353035
$this->logger->debug($message, $context);
30363036
}
30373037

3038-
/**
3039-
* @param LoggerInterface $logger
3040-
*/
30413038
private function setLogger(LoggerInterface $logger)
30423039
{
30433040
$this->logger = $logger;
@@ -3334,7 +3331,7 @@ private function getAuthTokenClass(array $credentials): FetchAuthTokenInterface
33343331
private array $creds;
33353332

33363333
public function __construct(
3337-
array $creds
3334+
array $creds,
33383335
) {
33393336
$this->creds = $creds;
33403337
}

src/Keboola/StorageApi/Client/RequestTimeoutMiddleware.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
class RequestTimeoutMiddleware
99
{
10-
const REQUEST_TIMEOUT_DEFAULT = 120;
11-
const REQUEST_TIMEOUT_EXTENDED = 7200;
10+
public const REQUEST_TIMEOUT_DEFAULT = 120;
11+
public const REQUEST_TIMEOUT_EXTENDED = 7200;
1212

1313
/** @var callable */
1414
private $nextHandler;
1515

1616
private function __construct(
17-
callable $nextHandler
17+
callable $nextHandler,
1818
) {
1919
$this->nextHandler = $nextHandler;
2020
}
@@ -34,7 +34,7 @@ public static function factory()
3434
*/
3535
public function __invoke(
3636
RequestInterface $request,
37-
array $options
37+
array $options,
3838
) {
3939
$nextHander = $this->nextHandler;
4040

src/Keboola/StorageApi/DevBranches.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function createBranch($branchName, $branchDescription = '')
3737
public function updateBranch(
3838
$branchId,
3939
$branchName = '',
40-
$branchDescription = ''
40+
$branchDescription = '',
4141
) {
4242
$params = [];
4343
if ($branchName) {
@@ -79,9 +79,6 @@ public function listBranches()
7979
return $result;
8080
}
8181

82-
/**
83-
* @return array
84-
*/
8582
public function getDefaultBranch(): array
8683
{
8784
$branches = $this->listBranches();

src/Keboola/StorageApi/Downloader/BlobClientFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BlobClientFactory
1111
* @return BlobRestProxy
1212
*/
1313
public static function createClientFromConnectionString(
14-
$connectionString
14+
$connectionString,
1515
) {
1616
$client = BlobRestProxy::createBlobService($connectionString, [
1717
'http' => [

src/Keboola/StorageApi/Downloader/BlobStorageRetryMiddleware.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class BlobStorageRetryMiddleware
1010
{
1111
//The interval will be increased linearly, the nth retry will have a
1212
//wait time equal to n * interval.
13-
const LINEAR_INTERVAL_ACCUMULATION = 'Linear';
13+
public const LINEAR_INTERVAL_ACCUMULATION = 'Linear';
1414
//The interval will be increased exponentially, the nth retry will have a
1515
//wait time equal to pow(2, n) * interval.
16-
const EXPONENTIAL_INTERVAL_ACCUMULATION = 'Exponential';
16+
public const EXPONENTIAL_INTERVAL_ACCUMULATION = 'Exponential';
1717
//This is for the general type of logic that handles retry.
18-
const GENERAL_RETRY_TYPE = 'General';
19-
const DEFAULT_NUMBER_OF_RETRIES = 5;
20-
const DEFAULT_RETRY_INTERVAL = Resources::DEFAULT_RETRY_INTERVAL;
18+
public const GENERAL_RETRY_TYPE = 'General';
19+
public const DEFAULT_NUMBER_OF_RETRIES = 5;
20+
public const DEFAULT_RETRY_INTERVAL = Resources::DEFAULT_RETRY_INTERVAL;
2121

2222
/**
2323
* @param int $numberOfRetries The maximum number of retries.
@@ -34,7 +34,7 @@ class BlobStorageRetryMiddleware
3434
public static function create(
3535
$numberOfRetries = self::DEFAULT_NUMBER_OF_RETRIES,
3636
$interval = self::DEFAULT_RETRY_INTERVAL,
37-
$accumulationMethod = self::EXPONENTIAL_INTERVAL_ACCUMULATION
37+
$accumulationMethod = self::EXPONENTIAL_INTERVAL_ACCUMULATION,
3838
) {
3939
//Validate the input parameters
4040
//numberOfRetries
@@ -127,9 +127,9 @@ protected static function createRetryDecider($maxRetries)
127127
$request,
128128
$response = null,
129129
$exception = null,
130-
$isSecondary = false
130+
$isSecondary = false,
131131
) use (
132-
$maxRetries
132+
$maxRetries,
133133
) {
134134
//Exceeds the retry limit. No retry.
135135
if ($retries >= $maxRetries) {

src/Keboola/StorageApi/Downloader/GcsClientFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class GcsClientFactory
1313
* @return StorageClient
1414
*/
1515
public static function createClientFromCredentialsArray(
16-
$fileResponse
16+
$fileResponse,
1717
) {
1818
$options = [
1919
'credentials' => [
@@ -28,7 +28,7 @@ public static function createClientFromCredentialsArray(
2828
private array $creds;
2929

3030
public function __construct(
31-
array $creds
31+
array $creds,
3232
) {
3333
$this->creds = $creds;
3434
}

src/Keboola/StorageApi/Event.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
<?php
2-
/**
3-
*
4-
* User: Martin Halamíček
5-
* Date: 30.11.12
6-
* Time: 16:12
7-
*
8-
*/
92

103
namespace Keboola\StorageApi;
114

125
class Event
136
{
14-
const TYPE_INFO = 'info';
15-
const TYPE_SUCCESS = 'success';
16-
const TYPE_WARN = 'warn';
17-
const TYPE_ERROR = 'error';
7+
public const TYPE_INFO = 'info';
8+
public const TYPE_SUCCESS = 'success';
9+
public const TYPE_WARN = 'warn';
10+
public const TYPE_ERROR = 'error';
1811

1912
/**
2013
* @var

src/Keboola/StorageApi/GCSUploader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434
array $options,
3535
RefreshFileCredentialsWrapper $refreshFileCredentialsWrapper,
3636
?LoggerInterface $logger = null,
37-
?FileUploadTransferOptions $transferOptions = null
37+
?FileUploadTransferOptions $transferOptions = null,
3838
) {
3939
$this->gcsClient = $this->initClient($options);
4040
$this->refreshFileCredentialsWrapper = $refreshFileCredentialsWrapper;
@@ -53,7 +53,7 @@ public function __construct(
5353

5454
private function getFailedUploads(
5555
array $preparedSlices,
56-
Bucket $bucket
56+
Bucket $bucket,
5757
): array {
5858
$failedUploads = [];
5959
foreach ($preparedSlices as $filePath => $blobName) {
@@ -231,7 +231,7 @@ private function initClient(array $options): GoogleStorageClient
231231
private array $creds;
232232

233233
public function __construct(
234-
array $creds
234+
array $creds,
235235
) {
236236
$this->creds = $creds;
237237
}

0 commit comments

Comments
 (0)