File yf_template_editor.class.php
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Templates handling class.
*
Method edit_stpl
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function edit_stpl()
{
$theme_name = $_GET['theme'];
$stpl_name = $_GET['name'];
if ( ! validate([$theme_name, $stpl_name], 'trim|required')) {
Function _show_stpls_list
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function _show_stpls_list($files_array = [], $level = 0)
{
asort($files_array);
$body = [];
foreach ((array) $files_array as $cur_file_path => $file_name) {
- 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 edit_stpl
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function edit_stpl()
{
$theme_name = $_GET['theme'];
$stpl_name = $_GET['name'];
if ( ! validate([$theme_name, $stpl_name], 'trim|required')) {
- 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 _show_themes
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _show_themes()
{
$themes = $this->_get_themes();
$num_stpls_array = cache_get($this->CACHE_NAME, 60);
Function _show_themes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function _show_themes()
{
$themes = $this->_get_themes();
$num_stpls_array = cache_get($this->CACHE_NAME, 60);
- 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 _get_stpls_for_type
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _get_stpls_for_type($type = 'user')
{
$theme_name = $type == 'admin' ? 'admin' : 'user';
$CACHE_NAME = 'stpls_list_for_' . $type;
Function show
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function show()
{
$deepness = 3;
$ext = '.stpl';
$ext_len = strlen($ext);
- 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 _get_stpls_for_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function _get_stpls_for_type($type = 'user')
{
$theme_name = $type == 'admin' ? 'admin' : 'user';
$CACHE_NAME = 'stpls_list_for_' . $type;
- 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 '<h4>edit: ' . $replace['stpl_name'] . ' for theme: ' . $replace['theme_name'] . ', inside: ' . $replace['location'] . '</h4>' .
form($replace, [
'data-onsubmit' => '$(this).find("#' . $hidden_id . '").val( $("#' . $div_id . '").data("ace_editor").session.getValue() );',
])
->container('<div id="' . $div_id . '" style="width: 90%; height: 500px;">' . $stpl_text . '</div>', '', [
Function _get_themes_for_select
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _get_themes_for_select()
{
$cache_name = 'themes_for_select';
$data = cache_get($cache_name);
if ( ! $data) {
- 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 edit_theme
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function edit_theme()
{
if (false !== strpos($_GET['location'], 'framework')) {
return $this->_framework_warning();
}
- 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 _get_themes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _get_themes()
{
$themes = [];
foreach ((array) $this->_dir_array as $glob_name => $glob) {
foreach (glob($glob . '*/', GLOB_ONLYDIR) as $path) {
- 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"