Skip to content

Commit

Permalink
CS: PSR1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Oct 8, 2017
1 parent a061e84 commit 2e19bc3
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Modules/Core/Console/Installers/Scripts/SetAppKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Modules\Core\Console\Installers\Scripts;

use Illuminate\Console\Command;
use Illuminate\Encryption\Encrypter;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Encryption\Encrypter;
use Modules\Core\Console\Installers\SetupScript;

class SetAppKey implements SetupScript
Expand Down Expand Up @@ -40,7 +40,7 @@ public function fire(Command $command)
*/
protected function generateRandomKey()
{
return 'base64:'.base64_encode(
return 'base64:' . base64_encode(
Encrypter::generateKey(config('app.cipher'))
);
}
Expand Down Expand Up @@ -74,7 +74,7 @@ protected function writeNewEnvironmentFileWith($key)
{
file_put_contents(app()->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
'APP_KEY=' . $key,
file_get_contents(app()->environmentFilePath())
));
}
Expand All @@ -86,7 +86,7 @@ protected function writeNewEnvironmentFileWith($key)
*/
protected function keyReplacementPattern()
{
$escaped = preg_quote('='.config('app.key'), '/');
$escaped = preg_quote('=' . config('app.key'), '/');

return "/^APP_KEY{$escaped}/m";
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Media/Events/Handlers/MoveFileOnDisk.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function moveThumbnails($event)
$fromPath = $this->getFilenameFor($event->previousData['path'], $thumbnail);
$toPath = $this->getFilenameFor($event->file->path, $thumbnail);

$this->move($fromPath, $toPath);
$this->move($fromPath, $toPath);
}
}

Expand Down
3 changes: 1 addition & 2 deletions Modules/Media/Http/Controllers/Frontend/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Modules\Media\Http\Controllers\Frontend;

use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use Modules\Media\Repositories\FileRepository;

Expand All @@ -29,7 +28,7 @@ public function show($path)
return Image::make($path)->response();

return response()->file($path, [
"Content-Type:$type"
"Content-Type:$type",
]);
}
}
2 changes: 1 addition & 1 deletion Modules/Media/Http/Requests/UploadDropzoneMediaRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function messages()
$size = $this->getMaxFileSize();

return [
'file.max' => trans('media::media.file too large', ['size' => $size])
'file.max' => trans('media::media.file too large', ['size' => $size]),
];
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Media/Http/Requests/UploadMediaRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function messages()
$size = $this->getMaxFileSize();

return [
'file.max' => trans('media::media.file too large', ['size' => $size])
'file.max' => trans('media::media.file too large', ['size' => $size]),
];
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Media/Providers/MediaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
use Modules\Media\Contracts\DeletingMedia;
use Modules\Media\Contracts\StoringMedia;
use Modules\Media\Entities\File;
use Modules\Media\Events\FileStartedMoving;
use Modules\Media\Events\FolderIsDeleting;
use Modules\Media\Events\FolderWasCreated;
use Modules\Media\Events\FolderWasUpdated;
use Modules\Media\Events\Handlers\CreateFolderOnDisk;
use Modules\Media\Events\Handlers\DeleteAllChildrenOfFolder;
use Modules\Media\Events\Handlers\DeleteFolderOnDisk;
use Modules\Media\Events\FileStartedMoving;
use Modules\Media\Events\Handlers\HandleMediaStorage;
use Modules\Media\Events\Handlers\MoveFileOnDisk;
use Modules\Media\Events\Handlers\RegisterMediaSidebar;
Expand Down
36 changes: 28 additions & 8 deletions Modules/Media/Support/Collection/NestedFoldersCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public function __construct($items = [])
public function nest()
{
$parentColumn = $this->parentColumn;
if ( ! $parentColumn) {
if (! $parentColumn) {
return $this;
}
// Set id as keys.
$this->items = $this->getDictionary();
$keysToDelete = [];
// Add empty collection to each items.
$collection = $this->each(function ($item) {
if ( ! $item->items) {
if (! $item->items) {
$item->items = app(BaseCollection::class);
}
});
Expand All @@ -43,6 +43,7 @@ public function nest()
$collection = $this->reject(function ($item) use ($parentColumn) {
if ($item->$parentColumn) {
$missingAncestor = $this->anAncestorIsMissing($item);

return $missingAncestor;
}
});
Expand All @@ -56,6 +57,7 @@ public function nest()
}
// Delete moved items.
$this->items = array_values(array_except($collection->items, $keysToDelete));

return $this;
}

Expand All @@ -71,7 +73,11 @@ public function nest()
* @return array
*/
public function listsFlattened(
$column = 'title', BaseCollection $collection = null, $level = 0, array &$flattened = [], $indentChars = null,
$column = 'title',
BaseCollection $collection = null,
$level = 0,
array &$flattened = [],
$indentChars = null,
$parent_string = null
) {
$collection = $collection ?: $this;
Expand All @@ -84,10 +90,17 @@ public function listsFlattened(
}
$flattened[$item->id] = $item_string;
if ($item->items) {
$this->listsFlattened($column, $item->items, $level + 1, $flattened, $indentChars,
($parent_string) ? $item_string : null);
$this->listsFlattened(
$column,
$item->items,
$level + 1,
$flattened,
$indentChars,
($parent_string) ? $item_string : null
);
}
}

return $flattened;
}

Expand All @@ -101,7 +114,11 @@ public function listsFlattened(
* @return array
*/
public function listsFlattenedQualified(
$column = 'title', BaseCollection $collection = null, $level = 0, array &$flattened = [], $indentChars = null
$column = 'title',
BaseCollection $collection = null,
$level = 0,
array &$flattened = [],
$indentChars = null
) {
return $this->listsFlattened($column, $collection, $level, $flattened, $indentChars, true);
}
Expand All @@ -114,6 +131,7 @@ public function listsFlattenedQualified(
public function setIndent(string $indentChars)
{
$this->indentChars = $indentChars;

return $this;
}

Expand All @@ -124,6 +142,7 @@ public function setIndent(string $indentChars)
public function noCleaning()
{
$this->removeItemsWithMissingAncestor = false;

return $this;
}

Expand All @@ -135,13 +154,14 @@ public function noCleaning()
public function anAncestorIsMissing($item)
{
$parentColumn = $this->parentColumn;
if ( ! $item->$parentColumn) {
if (! $item->$parentColumn) {
return false;
}
if ( ! $this->has($item->$parentColumn)) {
if (! $this->has($item->$parentColumn)) {
return true;
}
$parent = $this[$item->$parentColumn];

return $this->anAncestorIsMissing($parent);
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Translation/Resources/lang/media/en/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
'create resource' => 'Create media',
'edit resource' => 'Edit media',
'destroy resource' => 'Delete media',
'file too large' => 'File is too large. Must be below :size MB.'
'file too large' => 'File is too large. Must be below :size MB.',
];

0 comments on commit 2e19bc3

Please sign in to comment.