File yf_dir.class.php
has 625 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Filesystem utils.
*
Function _skip_by_pattern
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function _skip_by_pattern($path = '', $_is_dir = false, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $path) {
return false;
}
- 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 mkdir_m
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function mkdir_m($dir_name, $dir_mode = 0755, $create_index_htmls = 0, $start_folder = '')
{
if ( ! $dir_name || ! strlen($dir_name)) {
return 0;
}
- 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
yf_dir
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class yf_dir
{
/** @var bool */
public $CHECK_IF_READABLE = true;
/** @var bool */
Method _skip_by_pattern
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _skip_by_pattern($path = '', $_is_dir = false, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $path) {
return false;
}
Function copy_dir
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
{
if ( ! $path1 || ! file_exists($path1)) {
return false;
}
- 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 scan_dir
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function scan_dir($start_dir, $_tmp = 1, $pattern_include = '', $pattern_exclude = '')
{
$func = __FUNCTION__;
// Here we accept several start folders, result will be merged
if (is_array($start_dir)) {
- 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 replace
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function replace($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find, $pattern_replace)
{
$files = [];
if ( ! is_array($start_dirs)) {
$start_dirs = [$start_dirs];
- 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 grep
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function grep($pattern_find, $start_dirs, $pattern_path = '*', $extra = [])
{
if ( ! $pattern_find) {
return false;
}
- 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 move_dir
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function move_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $path1 || ! file_exists($path1)) {
return false;
}
- 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 mkdir_m
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function mkdir_m($dir_name, $dir_mode = 0755, $create_index_htmls = 0, $start_folder = '')
{
if ( ! $dir_name || ! strlen($dir_name)) {
return 0;
}
Function tail
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function tail($file, $lines = 10)
{
if ( ! $file || ! file_exists($file)) {
return false;
}
- 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 search
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function search($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find)
{
if ( ! is_array($start_dirs)) {
$start_dirs = [$start_dirs];
}
- 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 count_files
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function count_files($start_dir, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $start_dir || ! file_exists($start_dir)) {
return false;
}
- 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 dirsize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function dirsize($start_dir, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $start_dir || ! file_exists($start_dir)) {
return false;
}
- 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 replace
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function replace($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find, $pattern_replace)
{
$files = [];
if ( ! is_array($start_dirs)) {
$start_dirs = [$start_dirs];
Method grep
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function grep($pattern_find, $start_dirs, $pattern_path = '*', $extra = [])
{
if ( ! $pattern_find) {
return false;
}
Method copy_dir
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
{
if ( ! $path1 || ! file_exists($path1)) {
return false;
}
Method scan_dir
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function scan_dir($start_dir, $_tmp = 1, $pattern_include = '', $pattern_exclude = '')
{
$func = __FUNCTION__;
// Here we accept several start folders, result will be merged
if (is_array($start_dir)) {
Function delete_dir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function delete_dir($start_dir, $delete_start_dir = false)
{
if ( ! $start_dir || ! file_exists($start_dir)) {
return false;
}
- 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 chmod_dir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function chmod_dir($start_dir, $new_mode = 0755, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $start_dir || ! file_exists($start_dir) || empty($new_mode)) {
return false;
}
- 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 scan_fast
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function scan_fast($start_dir, $pattern = '~.+~')
{
$files = [];
$dh = @opendir($start_dir);
if ( ! $dh) {
- 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 move_dir
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function move_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '')
{
if ( ! $path1 || ! file_exists($path1)) {
return false;
}
Method tail
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function tail($file, $lines = 10)
{
if ( ! $file || ! file_exists($file)) {
return false;
}
Method search
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function search($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find)
{
if ( ! is_array($start_dirs)) {
$start_dirs = [$start_dirs];
}
Method delete_dir
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete_dir($start_dir, $delete_start_dir = false)
{
if ( ! $start_dir || ! file_exists($start_dir)) {
return false;
}
Method replace
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function replace($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find, $pattern_replace)
Method copy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function copy($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
Method copy_dir
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
Method _gen_dir_path
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _gen_dir_path($id, $path = '', $make = false, $dir_mode = 0755, $create_index_htmls = 1)
Function rglob
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function rglob($folder, $pattern = '*')
{
$folder = rtrim($folder, '/');
if (false === strpos($pattern, '[')) {
$pattern = $this->_sql_regcase($pattern);
- 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 0;
Avoid too many return
statements within this method. Open
return -2;