Skip to content

Commit dc0811a

Browse files
committed
Lint fixes
1 parent 8421555 commit dc0811a

31 files changed

+359
-326
lines changed

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
}
1010
],
1111
"scripts": {
12-
"analyze": "./vendor/bin/phpcs",
13-
"analyze-fix": "./vendor/bin/phpcbf"
12+
"lint:fix": "./vendor/bin/php-cs-fixer fix --config=.php_cs --using-cache false",
13+
"lint:check": "./vendor/bin/phplint",
14+
"lint": "composer run-script lint-fix && composer run-script lint-check"
1415
},
1516
"require": {
1617
"illuminate/http": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
@@ -22,7 +23,8 @@
2223
"laravel/laravel": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
2324
"phpunit/phpunit": "5.7 || 6.0 || 7.0",
2425
"mockery/mockery": "^0.9.9",
25-
"squizlabs/php_codesniffer": "^3.2"
26+
"friendsofphp/php-cs-fixer": "^2.12",
27+
"overtrue/phplint": "^1.1"
2628
},
2729
"autoload": {
2830
"psr-4": {

config/chunk-upload.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<?php
2-
return [
32

4-
/**
3+
return [
4+
/*
55
* The storage config
66
*/
7-
"storage" => [
8-
/**
7+
'storage' => [
8+
/*
99
* Returns the folder name of the chunks. The location is in storage/app/{folder_name}
1010
*/
11-
"chunks" => "chunks",
12-
"disk" => "local"
11+
'chunks' => 'chunks',
12+
'disk' => 'local',
1313
],
14-
"clear" => [
15-
/**
14+
'clear' => [
15+
/*
1616
* How old chunks we should delete
1717
*/
18-
"timestamp" => "-3 HOURS",
19-
"schedule" => [
20-
"enabled" => true,
21-
"cron" => "25 * * * *" // run every hour on the 25th minute
22-
]
18+
'timestamp' => '-3 HOURS',
19+
'schedule' => [
20+
'enabled' => true,
21+
'cron' => '25 * * * *', // run every hour on the 25th minute
22+
],
2323
],
24-
"chunk" => [
24+
'chunk' => [
2525
// setup for the chunk naming setup to ensure same name upload at same time
26-
"name" => [
27-
"use" => [
28-
"session" => true, // should the chunk name use the session id? The uploader must send cookie!,
29-
"browser" => false // instead of session we can use the ip and browser?
30-
]
31-
]
32-
]
26+
'name' => [
27+
'use' => [
28+
'session' => true, // should the chunk name use the session id? The uploader must send cookie!,
29+
'browser' => false, // instead of session we can use the ip and browser?
30+
],
31+
],
32+
],
3333
];

src/ChunkFile.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
2+
23
namespace Pion\Laravel\ChunkUpload;
34

45
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;
56

67
/**
7-
* Class Chunk
8-
*
9-
* @package Pion\Laravel\ChunkUpload
8+
* Class Chunk.
109
*/
1110
class ChunkFile
1211
{
@@ -21,18 +20,18 @@ class ChunkFile
2120
protected $modifiedTime;
2221

2322
/**
24-
* The chunk storage
23+
* The chunk storage.
2524
*
2625
* @var ChunkStorage
2726
*/
2827
protected $storage;
2928

3029
/**
31-
* Creates the chunk file
30+
* Creates the chunk file.
3231
*
33-
* @param string $path
34-
* @param int $modifiedTime
35-
* @param ChunkStorage $storage
32+
* @param string $path
33+
* @param int $modifiedTime
34+
* @param ChunkStorage $storage
3635
*/
3736
public function __construct($path, $modifiedTime, $storage)
3837
{
@@ -63,7 +62,7 @@ public function getModifiedTime()
6362
}
6463

6564
/**
66-
* Moves the chunk file to given relative path (within the disk)
65+
* Moves the chunk file to given relative path (within the disk).
6766
*
6867
* @param string $pathTo
6968
*
@@ -75,7 +74,8 @@ public function move($pathTo)
7574
}
7675

7776
/**
78-
* Deletes the chunk file
77+
* Deletes the chunk file.
78+
*
7979
* @return bool
8080
*/
8181
public function delete()
@@ -87,10 +87,11 @@ public function delete()
8787
* The __toString method allows a class to decide how it will react when it is converted to a string.
8888
*
8989
* @return string
90-
* @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
90+
*
91+
* @see http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
9192
*/
9293
public function __toString()
9394
{
94-
return sprintf("ChunkFile %s uploaded at %s", $this->getPath(), date("Y-m-d H:i:s", $this->getModifiedTime()));
95+
return sprintf('ChunkFile %s uploaded at %s', $this->getPath(), date('Y-m-d H:i:s', $this->getModifiedTime()));
9596
}
9697
}

src/Commands/ClearChunksCommand.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Pion\Laravel\ChunkUpload\Commands;
34

45
use Illuminate\Console\Command;
@@ -23,9 +24,8 @@ class ClearChunksCommand extends Command
2324
*/
2425
protected $description = 'Clears the chunks upload directory. Deletes only .part objects.';
2526

26-
2727
/**
28-
* Clears the chunks upload directory
28+
* Clears the chunks upload directory.
2929
*
3030
* @param ChunkStorage $storage injected chunk storage
3131
*/
@@ -35,28 +35,29 @@ public function handle(ChunkStorage $storage)
3535

3636
// try to get the old chunk files
3737
$oldFiles = $storage->oldChunkFiles();
38-
38+
3939
if ($oldFiles->isEmpty()) {
40-
$this->warn("Chunks: no old files");
40+
$this->warn('Chunks: no old files');
41+
4142
return;
4243
}
43-
44-
$this->info(sprintf("Found %d chunk files", $oldFiles->count()), $verbouse);
44+
45+
$this->info(sprintf('Found %d chunk files', $oldFiles->count()), $verbouse);
4546
$deleted = 0;
4647

4748
/** @var ChunkFile $file */
4849
foreach ($oldFiles as $file) {
4950
// debug the file info
50-
$this->comment("> ".$file, $verbouse);
51+
$this->comment('> '.$file, $verbouse);
5152

5253
// delete the file
5354
if ($file->delete()) {
54-
$deleted++;
55+
++$deleted;
5556
} else {
56-
$this->error("> chunk not deleted: ".$file);
57+
$this->error('> chunk not deleted: '.$file);
5758
}
5859
}
5960

60-
$this->info("Chunks: cleared ".$deleted." ".Str::plural("file", $deleted));
61+
$this->info('Chunks: cleared '.$deleted.' '.Str::plural('file', $deleted));
6162
}
6263
}

src/Config/AbstractConfig.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
23
namespace Pion\Laravel\ChunkUpload\Config;
34

45
abstract class AbstractConfig
56
{
67
/**
7-
* Returns the config from the application container
8+
* Returns the config from the application container.
89
*
910
* @return AbstractConfig
1011
*
@@ -16,42 +17,44 @@ public static function config()
1617
}
1718

1819
/**
19-
* Returns the disk name to use for the chunk storage
20+
* Returns the disk name to use for the chunk storage.
21+
*
2022
* @return string
2123
*/
2224
abstract public function chunksDiskName();
2325

2426
/**
25-
* The storage path for the chunks
27+
* The storage path for the chunks.
2628
*
2729
* @return string the full path to the storage
2830
*/
2931
abstract public function chunksStorageDirectory();
3032

3133
/**
32-
* Returns the time stamp string for clear command
34+
* Returns the time stamp string for clear command.
35+
*
3336
* @return string
3437
*/
3538
abstract public function clearTimestampString();
3639

3740
/**
38-
* Returns the schedule config array
41+
* Returns the schedule config array.
42+
*
3943
* @return array<enable,cron>
4044
*/
4145
abstract public function scheduleConfig();
4246

4347
/**
4448
* Should the chunk name add a session?
4549
*
46-
* @return boolean
50+
* @return bool
4751
*/
4852
abstract public function chunkUseSessionForName();
4953

50-
5154
/**
5255
* Should the chunk name add a ip address?
5356
*
54-
* @return boolean
57+
* @return bool
5558
*/
5659
abstract public function chunkUseBrowserInfoForName();
5760
}

src/Config/FileConfig.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,95 @@
11
<?php
2+
23
namespace Pion\Laravel\ChunkUpload\Config;
34

45
/**
5-
* Class FileConfig
6+
* Class FileConfig.
67
*
78
* Enables loading a config settings from the Laravel Config facade.
8-
*
9-
* @package Pion\Laravel\ChunkUpload\Config
109
*/
1110
class FileConfig extends AbstractConfig
1211
{
1312
/**
14-
* The file name of the config
13+
* The file name of the config.
1514
*/
16-
const FILE_NAME = "chunk-upload";
15+
const FILE_NAME = 'chunk-upload';
1716

1817
/**
19-
* Returns the disk name to use for the chunk storage
18+
* Returns the disk name to use for the chunk storage.
2019
*
2120
* @return string
2221
*/
2322
public function chunksDiskName()
2423
{
25-
return $this->get("storage.disk");
24+
return $this->get('storage.disk');
2625
}
2726

28-
2927
/**
30-
* The storage path for the chunks
28+
* The storage path for the chunks.
3129
*
3230
* @return string the full path to the storage
3331
*
3432
* @see FileConfig::get()
3533
*/
3634
public function chunksStorageDirectory()
3735
{
38-
return $this->get("storage.chunks");
36+
return $this->get('storage.chunks');
3937
}
4038

4139
/**
42-
* Returns the time stamp string for clear command
40+
* Returns the time stamp string for clear command.
4341
*
4442
* @return string
4543
*
4644
* @see FileConfig::get()
4745
*/
4846
public function clearTimestampString()
4947
{
50-
return $this->get("clear.timestamp");
48+
return $this->get('clear.timestamp');
5149
}
5250

5351
/**
54-
* Returns the shedule config array
52+
* Returns the shedule config array.
53+
*
5554
* @return array<enable,cron>
5655
*/
5756
public function scheduleConfig()
5857
{
59-
return $this->get("clear.schedule");
58+
return $this->get('clear.schedule');
6059
}
6160

6261
/**
6362
* Should the chunk name add a session?
6463
*
65-
* @return boolean
64+
* @return bool
6665
*/
6766
public function chunkUseSessionForName()
6867
{
69-
return $this->get("chunk.name.use.session", true);
68+
return $this->get('chunk.name.use.session', true);
7069
}
7170

7271
/**
7372
* Should the chunk name add a ip address?
7473
*
75-
* @return boolean
74+
* @return bool
7675
*/
7776
public function chunkUseBrowserInfoForName()
7877
{
79-
return $this->get("chunk.name.use.browser", false);
78+
return $this->get('chunk.name.use.browser', false);
8079
}
8180

8281
/**
83-
* Returns a chunks config value
84-
*
85-
* @param string $key the config name is prepended to the key value
82+
* Returns a chunks config value.
8683
*
84+
* @param string $key the config name is prepended to the key value
8785
* @param mixed|null $default
8886
*
8987
* @return mixed
88+
*
9089
* @see \Config::get()
9190
*/
9291
public function get($key, $default = null)
9392
{
94-
return config(self::FILE_NAME.".".$key, $default);
93+
return config(self::FILE_NAME.'.'.$key, $default);
9594
}
9695
}

src/Exceptions/ChunkInvalidValueException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use Exception;
66

77
/**
8-
* Class ChunkInvalidValueException
9-
*
10-
* @package Pion\Laravel\ChunkUpload\Exception
8+
* Class ChunkInvalidValueException.
119
*/
1210
class ChunkInvalidValueException extends \Exception
1311
{

0 commit comments

Comments
 (0)