File yf_assets.class.php
has 1901 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
// TODO: compare versions with require_php_lib('php_semver')
// TODO: decide with images: jpeg, png, gif, sprites
// TODO: requirejs integration, auto-generate its config with switcher on/off
yf_assets
has 81 functions (exceeds 20 allowed). Consider refactoring. Open
class yf_assets
{
/** @array */
public $supported_asset_types = [
'jquery', 'js', 'css', 'less', 'sass', 'coffee', 'bundle', 'asset', /*, 'img', 'font'*/
Function add
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
public function add($content, $asset_type = 'bundle', $content_type_hint = 'auto', $params = [])
{
if (DEBUG_MODE) {
$trace = main()->trace_string();
}
- 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 show
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public function show($out_type, $params = [])
{
if ( ! $out_type || ! in_array($out_type, $this->supported_out_types)) {
throw new Exception('Assets: unsupported out content type: ' . $out_type);
return null;
- 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_all_content_for_out
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
public function _get_all_content_for_out($out_type, $params = [])
{
$is_ajax = main()->is_ajax();
// Move down inlined content
$all_content = $this->get_content($out_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
Function html_out
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
public function html_out($out_type, $content_type, $str, $params = [])
{
if ( ! $out_type || ! $content_type || ! strlen($str)) {
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 get_asset_from_bower
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function get_asset_from_bower($name, $version = 'master', $asset_data = [], $asset_type)
{
if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
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 show
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function show($out_type, $params = [])
{
if ( ! $out_type || ! in_array($out_type, $this->supported_out_types)) {
throw new Exception('Assets: unsupported out content type: ' . $out_type);
return null;
Method add
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add($content, $asset_type = 'bundle', $content_type_hint = 'auto', $params = [])
{
if (DEBUG_MODE) {
$trace = main()->trace_string();
}
Function _add_bundle
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function _add_bundle($_content, $_params = [])
{
if ( ! $_content) {
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 html_out
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function html_out($out_type, $content_type, $str, $params = [])
{
if ( ! $out_type || ! $content_type || ! strlen($str)) {
return false;
}
Function get_asset
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function get_asset($name, $asset_type, $version = '')
{
if ( ! $name) {
return null;
}
- 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 _combine_content
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function _combine_content(array $out, $out_type, array $to_combine, $combined_file, array $md5_inside_combined)
{
if ( ! file_exists($combined_file)) {
$divider = PHP_EOL;
if ($out_type === 'js') {
- 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_all_content_for_out
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _get_all_content_for_out($out_type, $params = [])
{
$is_ajax = main()->is_ajax();
// Move down inlined content
$all_content = $this->get_content($out_type);
Method _css_urls_rewrite_and_save
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _css_urls_rewrite_and_save($content, $content_url, $cache_path, $content_type = 'url', $orig_content = '')
{
$_this = $this;
$self_func = __FUNCTION__;
return preg_replace_callback('~url\([\'"\s]*(?P<url>[^\'"\)]+?)[\'"\s]*\)~ims', function ($m) use ($_this, $content_url, $cache_path, $content_type, $orig_content, $self_func) {
Function _add_asset
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function _add_asset($_content, $asset_type, $_params = [])
{
if ( ! $_content) {
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 get_asset_from_bower
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_asset_from_bower($name, $version = 'master', $asset_data = [], $asset_type)
{
if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
return false;
}
Method _add_bundle
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _add_bundle($_content, $_params = [])
{
if ( ! $_content) {
return false;
}
Method _combine_content
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _combine_content(array $out, $out_type, array $to_combine, $combined_file, array $md5_inside_combined)
{
if ( ! file_exists($combined_file)) {
$divider = PHP_EOL;
if ($out_type === 'js') {
Method _add_asset
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _add_asset($_content, $asset_type, $_params = [])
{
if ( ! $_content) {
return false;
}
Function _sub_add
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function _sub_add($info, $asset_type, $_params = [])
{
if ( ! $info) {
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 _url_control
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function _url_control()
{
if ( ! $this->ALLOW_URL_CONTROL) {
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 set_cache
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set_cache($out_type, $md5, $data = [])
{
if ( ! $this->USE_CACHE) {
return false;
}
Function filters_process_input
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function filters_process_input($in, $filters = [], $params = [])
{
if (is_array($in)) {
$out = [];
$func = __FUNCTION__;
- 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_asset
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_asset($name, $asset_type, $version = '')
{
if ( ! $name) {
return null;
}
Method _url_control
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _url_control()
{
if ( ! $this->ALLOW_URL_CONTROL) {
return false;
}
Function detect_content_type
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function detect_content_type($asset_type, $content = '')
{
$content = trim($content);
$type = false;
if (isset($this->assets[$content])) {
- 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_asset_from_github
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function get_asset_from_github($name, $version = 'master', $asset_data = [], $asset_type)
{
if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
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 get_asset_from_cdn
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function get_asset_from_cdn($name, $version = 'master', $asset_data = [], $asset_type)
{
if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type]) || ! $asset_data['url']) {
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 set_cache
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function set_cache($out_type, $md5, $data = [])
{
if ( ! $this->USE_CACHE) {
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 load_predefined_assets
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function load_predefined_assets($force = false)
{
// Cleanup previously filled assets
if ($force) {
$this->assets = [];
Method _cache_dir
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _cache_dir($out_type, $asset_name = '', $version = '')
{
if ( ! is_string($this->CACHE_DIR_TPL) && is_callable($this->CACHE_DIR_TPL)) {
$func = $this->CACHE_DIR_TPL;
$cache_dir = $func($out_type, $asset_name, $version, $this);
Consider simplifying this complex logical expression. Open
if ($method == 'bower' && $this->ALLOW_GET_FROM_BOWER && $_files) {
return $this->get_asset_from_bower($_name, $_version, $data, $asset_type);
} elseif ($method == 'github' && $this->ALLOW_GET_FROM_GITHUB && $_files) {
return $this->get_asset_from_github($_name, $_version, $data, $asset_type);
} elseif ($method == 'cdn' && $this->ALLOW_GET_FROM_CDN && isset($asset_data[$method]) && isset($asset_data[$method][$asset_type])) {
Method filters_get_avail
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filters_get_avail()
{
if (isset($this->_avail_filters)) {
return $this->_avail_filters;
}
Method _sub_add
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _sub_add($info, $asset_type, $_params = [])
{
if ( ! $info) {
return false;
}
Method get_asset_from_cdn
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_asset_from_cdn($name, $version = 'master', $asset_data = [], $asset_type)
{
if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type]) || ! $asset_data['url']) {
return false;
}
Function _url_get_contents
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function _url_get_contents($url)
{
if ( ! strlen($url)) {
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 filters_get_avail
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function filters_get_avail()
{
if (isset($this->_avail_filters)) {
return $this->_avail_filters;
}
- 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_asset_from_github
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_asset_from_github($name, $version = 'master', $asset_data = [], $asset_type)
{
if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
return false;
}
Method _get_combined_version
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _get_combined_version($out_type = '')
{
if ( ! is_string($this->COMBINED_VERSION_TPL) && is_callable($this->COMBINED_VERSION_TPL)) {
$func = $this->COMBINED_VERSION_TPL;
$version = $func($out_type, $this);
Method _url_get_contents
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _url_get_contents($url)
{
if ( ! strlen($url)) {
return false;
}
Method filters_process_input
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filters_process_input($in, $filters = [], $params = [])
{
if (is_array($in)) {
$out = [];
$func = __FUNCTION__;
Function set_content
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function set_content($asset_type, $md5, $content_type, $content, $params = [])
{
if (isset($this->content[$asset_type][$md5])) {
return $this->content[$asset_type][$md5];
}
- 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 _cached_url_get_mtime
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function _cached_url_get_mtime($str = '')
{
$url_param = 'yfmt';
if ( ! $this->CACHE_OUT_ADD_MTIME || ! strlen($str) || false !== strpos($str, $url_param . '=')) {
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 set_content
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set_content($asset_type, $md5, $content_type, $content, $params = [])
{
if (isset($this->content[$asset_type][$md5])) {
return $this->content[$asset_type][$md5];
}
Function filters_process_added
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function filters_process_added($asset_type, $params = [])
{
if ( ! $asset_type) {
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 load_predefined_assets
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function load_predefined_assets($force = false)
{
// Cleanup previously filled assets
if ($force) {
$this->assets = [];
- 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 find_asset_type_for_module
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function find_asset_type_for_module($asset_type, $module = '')
{
if ( ! $module) {
$module = $_GET['object'];
}
- 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 _js_map_save
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function _js_map_save($content, $content_url, $cache_path)
{
$map_ext = '.map';
$map_url = '';
// Parse inline map url suggest, example: //# sourceMappingURL=lightbox.min.map
- 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 _combine_content
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _combine_content(array $out, $out_type, array $to_combine, $combined_file, array $md5_inside_combined)
Method set_content
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function set_content($asset_type, $md5, $content_type, $content, $params = [])
Method _css_urls_rewrite_and_save
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _css_urls_rewrite_and_save($content, $content_url, $cache_path, $content_type = 'url', $orig_content = '')
Function _get_absolute_path
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function _get_absolute_path($path)
{
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = [];
foreach ($parts as $part) {
- 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 $data;
Avoid too many return
statements within this method. Open
return $this->get_asset_from_cdn($name, $_version, $data, $asset_type);
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $cache_path;
Avoid too many return
statements within this method. Open
return $content;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $cache[$name];
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return file_put_contents($map_path, $map_content);
Function _cache_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _cache_name($out_type, $md5, $data = [])
{
$content = $data['content'];
$content_type = $data['content_type'];
$_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
foreach ((array) $files as $from => $to) {
if (is_numeric($from)) {
$from = $to;
}
$to_path = rtrim($target_dir, '/') . '/' . ltrim($to, '/');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 233.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
foreach ((array) $files as $from => $to) {
if (is_numeric($from)) {
$from = $to;
}
$to_path = rtrim($target_dir, '/') . '/' . ltrim($to, '/');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 233.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function init_css($force = false)
{
if ($this->_init_css_done && ! $force) {
return false;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 189.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function init_js($force = false)
{
if ($this->_init_js_done && ! $force) {
return false;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 189.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function _strip_js_input($str)
{
// Extracting url from <script src="path.to/scripts.js"></script>
$str = preg_replace_callback('~<script[\s]+[^>]*src=["\']([^"\']+?)["\'][^>]*>~ims', function ($m) {
return $m[1];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 127.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function _strip_css_input($str)
{
// Extracting url from <link rel="stylesheet" href="path.to/style.css">
$str = preg_replace_callback('~<link[\s]+[^>]*href=["\']([^"\']+?)["\'][^>]*>~ims', function ($m) {
return $m[1];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 127.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($this->INLINE_ASSETS_USE_DATA_URI && $content_type === 'inline') {
$content_type = 'url';
$params['href'] = 'data:' . $params['type'] . ';base64,' . base64_encode($this->_strip_css_input($str));
} elseif ($this->FILE_ASSETS_USE_DATA_URI && strlen($str) <= $this->FILE_ASSETS_DATA_URI_MAX_SIZE) {
$content_type = 'url';
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 126.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($this->INLINE_ASSETS_USE_DATA_URI && $content_type === 'inline') {
$content_type = 'url';
$params['src'] = 'data:' . $params['type'] . ';base64,' . base64_encode($this->_strip_js_input($str));
} elseif ($this->FILE_ASSETS_USE_DATA_URI && strlen($str) <= $this->FILE_ASSETS_DATA_URI_MAX_SIZE) {
$content_type = 'url';
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 126.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function get_less_content($params = [])
{
if ( ! $this->ALLOW_CONTENT_LESS) {
return [];
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 122.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function get_sass_content($params = [])
{
if ( ! $this->ALLOW_CONTENT_SASS) {
return [];
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 122.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76