php cs fixer

This commit is contained in:
Dennis Eichhorn 2019-04-27 12:05:33 +02:00
parent 6926c00775
commit 3d65a24d33
15 changed files with 136 additions and 138 deletions

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
use Modules\Media\Controller\ApiController; use Modules\Media\Controller\ApiController;
use Modules\Media\Models\PermissionState; use Modules\Media\Models\PermissionState;
@ -18,7 +18,7 @@ return [
'data' => [ 'data' => [
'field_name' => [ 'field_name' => [
'type' => 'string', 'default' => 'Hello', 'validation' => '[\\w]*', 'required' => false,'annotation' => [], 'type' => 'string', 'default' => 'Hello', 'validation' => '[\\w]*', 'required' => false,'annotation' => [],
] ],
], ],
], ],
], ],

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
use Modules\Media\Controller\BackendController; use Modules\Media\Controller\BackendController;
use Modules\Media\Models\PermissionState; use Modules\Media\Models\PermissionState;

View File

@ -16,8 +16,6 @@ namespace Modules\Media\Controller;
use Modules\Media\Models\Media; use Modules\Media\Models\Media;
use Modules\Media\Models\MediaMapper; use Modules\Media\Models\MediaMapper;
use Modules\Media\Models\Collection;
use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\UploadFile; use Modules\Media\Models\UploadFile;
use Modules\Media\Models\UploadStatus; use Modules\Media\Models\UploadStatus;
use phpOMS\Message\NotificationLevel; use phpOMS\Message\NotificationLevel;
@ -128,7 +126,7 @@ final class ApiController extends Controller
*/ */
public static function createMediaPath(string $basePath = 'Modules/Media/Files') : string public static function createMediaPath(string $basePath = 'Modules/Media/Files') : string
{ {
$rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT); $rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT);
return $basePath . '/' . $rndPath[0] . $rndPath[1] . '/' . $rndPath[2] . $rndPath[3]; return $basePath . '/' . $rndPath[0] . $rndPath[1] . '/' . $rndPath[2] . $rndPath[3];
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -101,7 +101,7 @@ class UploadFile
{ {
$result = []; $result = [];
if (\count($files) === \count($files, COUNT_RECURSIVE)) { if (\count($files) === \count($files, \COUNT_RECURSIVE)) {
$files = [$files]; $files = [$files];
} }
@ -120,7 +120,7 @@ class UploadFile
$result[$key]['status'] = UploadStatus::WRONG_PARAMETERS; $result[$key]['status'] = UploadStatus::WRONG_PARAMETERS;
return $result; return $result;
} elseif ($f['error'] !== UPLOAD_ERR_OK) { } elseif ($f['error'] !== \UPLOAD_ERR_OK) {
$result[$key]['status'] = $this->getUploadError($f['error']); $result[$key]['status'] = $this->getUploadError($f['error']);
return $result; return $result;
@ -223,7 +223,7 @@ class UploadFile
$sha .= '.' . $extension; $sha .= '.' . $extension;
$fileName = $sha; $fileName = $sha;
$rnd = \mt_rand(); $rnd = \mt_rand();
$limit++; ++$limit;
} while (\file_exists($path . '/' . $fileName) && $limit < self::PATH_GENERATION_LIMIT); } while (\file_exists($path . '/' . $fileName) && $limit < self::PATH_GENERATION_LIMIT);
if ($limit >= self::PATH_GENERATION_LIMIT) { if ($limit >= self::PATH_GENERATION_LIMIT) {
@ -282,7 +282,7 @@ class UploadFile
private function findOutputDir(array $files) : string private function findOutputDir(array $files) : string
{ {
do { do {
$rndPath = \str_pad(\dechex(\rand(0, 65535)), 4, '0', STR_PAD_LEFT); $rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT);
} while (\file_exists($this->outputDir . '/' . $rndPath)); } while (\file_exists($this->outputDir . '/' . $rndPath));
return $this->outputDir . '/' . $rndPath; return $this->outputDir . '/' . $rndPath;
@ -300,11 +300,11 @@ class UploadFile
private function getUploadError($error) : int private function getUploadError($error) : int
{ {
switch ($error) { switch ($error) {
case UPLOAD_ERR_NO_FILE: case \UPLOAD_ERR_NO_FILE:
// TODO: no file sent // TODO: no file sent
return UploadStatus::NOTHING_UPLOADED; return UploadStatus::NOTHING_UPLOADED;
case UPLOAD_ERR_INI_SIZE: case \UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE: case \UPLOAD_ERR_FORM_SIZE:
return UploadStatus::UPLOAD_SIZE; return UploadStatus::UPLOAD_SIZE;
default: default:
return UploadStatus::UNKNOWN_ERROR; return UploadStatus::UNKNOWN_ERROR;

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/** /**
* Orange Management * Orange Management
* *
@ -19,7 +19,7 @@ include __DIR__ . '/template-functions.php';
/** /**
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var $media \Modules\Media\Models\Media * @var $media \Modules\Media\Models\Media
*/ */
$media = $this->getData('media'); $media = $this->getData('media');
echo $this->getData('nav')->render(); echo $this->getData('nav')->render();

View File

@ -1,30 +1,30 @@
<?php <?php declare(strict_types=1);
use \phpOMS\System\File\ExtensionType; use \phpOMS\System\File\ExtensionType;
$fileIconFunction = function (int $extensionType) : string $fileIconFunction = function (int $extensionType) : string
{ {
if ($extensionType === ExtensionType::CODE) { if ($extensionType === ExtensionType::CODE) {
return 'file-code-o'; return 'file-code-o';
} elseif ($extensionType === ExtensionType::TEXT) { } elseif ($extensionType === ExtensionType::TEXT) {
return 'file-text-o'; return 'file-text-o';
} elseif ($extensionType === ExtensionType::PRESENTATION) { } elseif ($extensionType === ExtensionType::PRESENTATION) {
return 'file-powerpoint-o'; return 'file-powerpoint-o';
} elseif ($extensionType === ExtensionType::PDF) { } elseif ($extensionType === ExtensionType::PDF) {
return 'file-pdf-o'; return 'file-pdf-o';
} elseif ($extensionType === ExtensionType::ARCHIVE) { } elseif ($extensionType === ExtensionType::ARCHIVE) {
return 'file-zip-o'; return 'file-zip-o';
} elseif ($extensionType === ExtensionType::AUDIO) { } elseif ($extensionType === ExtensionType::AUDIO) {
return 'file-audio-o'; return 'file-audio-o';
} elseif ($extensionType === ExtensionType::VIDEO) { } elseif ($extensionType === ExtensionType::VIDEO) {
return 'file-video-o'; return 'file-video-o';
} elseif ($extensionType === ExtensionType::IMAGE) { } elseif ($extensionType === ExtensionType::IMAGE) {
return 'file-image-o'; return 'file-image-o';
} elseif ($extensionType === ExtensionType::SPREADSHEET) { } elseif ($extensionType === ExtensionType::SPREADSHEET) {
return 'file-excel-o'; return 'file-excel-o';
} elseif ($extensionType === 'collection') { } elseif ($extensionType === 'collection') {
return 'folder-open-o'; return 'folder-open-o';
} }
return 'file-o'; return 'file-o';
}; };

View File

@ -1,85 +1,85 @@
<?php <?php
/** /**
* Orange Management * Orange Management
* *
* PHP Version 7.2 * PHP Version 7.2
* *
* @package Modules\Media\Views * @package Modules\Media\Views
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 1.0 * @license OMS License 1.0
* @version 1.0.0 * @version 1.0.0
* @link http://website.orange-management.de * @link http://website.orange-management.de
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace Modules\Media\Views; namespace Modules\Media\Views;
use Modules\Media\Models\Media; use Modules\Media\Models\Media;
use phpOMS\System\File\ExtensionType; use phpOMS\System\File\ExtensionType;
use phpOMS\System\File\FileUtils; use phpOMS\System\File\FileUtils;
use phpOMS\System\File\Local\File; use phpOMS\System\File\Local\File;
use phpOMS\Utils\StringUtils; use phpOMS\Utils\StringUtils;
use phpOMS\Views\View; use phpOMS\Views\View;
/** /**
* Media view. * Media view.
* *
* @package Modules\Media\Views * @package Modules\Media\Views
* @license OMS License 1.0 * @license OMS License 1.0
* @link http://website.orange-management.de * @link http://website.orange-management.de
* @since 1.0.0 * @since 1.0.0
*/ */
class MediaView extends View class MediaView extends View
{ {
protected function filePathFunction(Media $media, string $sub) : string protected function filePathFunction(Media $media, string $sub) : string
{ {
if (\is_file($media->getPath() . $sub) if (\is_file($media->getPath() . $sub)
&& StringUtils::startsWith( && StringUtils::startsWith(
\str_replace('\\', '/', \realpath($media->getPath() . $sub)), \str_replace('\\', '/', \realpath($media->getPath() . $sub)),
$media->getPath() $media->getPath()
) )
) { ) {
return $media->getPath() . $sub; return $media->getPath() . $sub;
} }
return $media->getPath(); return $media->getPath();
} }
protected function dirPathFunction(Media $media, string $sub) : string protected function dirPathFunction(Media $media, string $sub) : string
{ {
if (\is_dir($media->getPath() . $sub) if (\is_dir($media->getPath() . $sub)
&& StringUtils::startsWith( && StringUtils::startsWith(
\str_replace('\\', '/', \realpath($media->getPath() . $sub)), \str_replace('\\', '/', \realpath($media->getPath() . $sub)),
$media->getPath() $media->getPath()
) )
) { ) {
return $media->getPath() . $sub; return $media->getPath() . $sub;
} }
return $media->getPath(); return $media->getPath();
} }
protected function isCollectionFunction(Media $media, string $sub) : bool protected function isCollectionFunction(Media $media, string $sub) : bool
{ {
return ($media->getExtension() === 'collection' return ($media->getExtension() === 'collection'
&& !\is_file($media->getPath() . $sub)) && !\is_file($media->getPath() . $sub))
|| (\is_dir($media->getPath()) || (\is_dir($media->getPath())
&& ($sub === null || \is_dir($media->getPath() . $sub)) && ($sub === null || \is_dir($media->getPath() . $sub))
); );
} }
protected function lineContentFunction(string $path) : array protected function lineContentFunction(string $path) : array
{ {
$output = \file_get_contents($path); $output = \file_get_contents($path);
$output = \str_replace(["\r\n", "\r"], "\n", $output); $output = \str_replace(["\r\n", "\r"], "\n", $output);
return \explode("\n", $output); return \explode("\n", $output);
} }
protected function isImageFunction(Media $media, string $path) : bool protected function isImageFunction(Media $media, string $path) : bool
{ {
return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE
|| FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE; || FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE;
} }
} }