File BaseFileSystemStorage.php
has 421 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace luya\admin\storage;
use luya\admin\events\FileEvent;
BaseFileSystemStorage
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class BaseFileSystemStorage extends Component
{
use CacheableTrait;
/**
Method createImage
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createImage($fileId, $filterId)
{
gc_collect_cycles();
$image = StorageImage::find()->where(['file_id' => $fileId, 'filter_id' => $filterId])->one();
Method addFile
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addFile($fileSource, $fileName, $folderId = 0, $isHidden = false)
{
// ensure the file upload
$fileData = $this->ensureFileUpload($fileSource, $fileName);
// generate md5 hash from file source
Method ensureFileUpload
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function ensureFileUpload($fileSource, $fileName)
{
// throw exception if source or name is empty
if (empty($fileSource) || empty($fileName)) {
throw new Exception("Filename and source can not be empty.");
Function addImage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function addImage($fileId, $filterId = 0, $throwException = false)
{
try {
// if the filterId is provded as a string the filter will be looked up by its name in the get filters array list.
if (is_string($filterId) && !is_numeric($filterId)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ensureFileUpload
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function ensureFileUpload($fileSource, $fileName)
{
// throw exception if source or name is empty
if (empty($fileSource) || empty($fileName)) {
throw new Exception("Filename and source can not be empty.");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function createImage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function createImage($fileId, $filterId)
{
gc_collect_cycles();
$image = StorageImage::find()->where(['file_id' => $fileId, 'filter_id' => $filterId])->one();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addImage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addImage($fileId, $filterId = 0, $throwException = false)
{
try {
// if the filterId is provded as a string the filter will be looked up by its name in the get filters array list.
if (is_string($filterId) && !is_numeric($filterId)) {
Function addFile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addFile($fileSource, $fileName, $folderId = 0, $isHidden = false)
{
// ensure the file upload
$fileData = $this->ensureFileUpload($fileSource, $fileName);
// generate md5 hash from file source
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function processThumbnails
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function processThumbnails()
{
foreach ($this->findFiles(['is_hidden' => false, 'is_deleted' => false]) as $file) {
if ($file->isImage) {
// create tiny thumbnail
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $image;
Avoid too many return
statements within this method. Open
return $image;
Avoid too many return
statements within this method. Open
return false;