Showing 53 of 55 total issues
Function fuzzy_ago
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
public function fuzzy_ago( $seconds, $dictionary = 'english' ) {
if ( $seconds < 0 ) {
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 Filter
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public static function Filter( $haystack, $needle, $key = false, $options = [] ) {
// Set the defaults if not already set
$max = ( isset( $options['max_results'] ) ) ? $options['max_results'] : false;
$fold_diacritics = ( isset( $options['fold'] ) ) ? $options['fold'] : true;
$match_type = ( isset( $options['match_type'] ) ) ? $options['match_type'] : MATCH_ALL;
- 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 convert_number_to_words
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function convert_number_to_words( $number, $dictionary = 'english' ) {
// This is a complex function, but I'm not sure if it can be simplified.
// adapted from http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/
$hyphen = '-';
$conjunction = ' and ';
Function create_request
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
if ( $cache_ttl > 0 ) {
// Create an object with caching on
$request = new Alphred\Request( $url, [ 'cache' => true,
- 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 fuzzy_ago
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fuzzy_ago( $seconds, $dictionary = 'english' ) {
if ( $seconds < 0 ) {
return false;
}
Alphred
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class Alphred {
/**
* Initializes the wrapper object
*
Function execute
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $code = false ) {
// Set a preliminary HTTP response code of 0 (not defined)
$this->code = 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
Function filter_item
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private static function filter_item( $value, $query, $match_on, $fold_diacritics ) {
$query = strtolower( $query );
if ( $fold_diacritics ) {
$value = self::convert( $value );
- 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
Request
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class Request {
/**
* The internal cURL handler
* @var Resource
Method filter_item
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function filter_item( $value, $query, $match_on, $fold_diacritics ) {
$query = strtolower( $query );
if ( $fold_diacritics ) {
$value = self::convert( $value );
Function write_item
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function write_item( $item ) {
// The information we need is stored in the sub variable, so let's just get that
$item = $item->data;
// These go in the 'item' part as an attribute
$attributes = [ 'uid', 'arg', 'autocomplete' ];
- 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
File Date.php
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Contains Date class for Alphred
*
* PHP version 5
Function create
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function create( $start, $options, $selections ) {
// The beginning of the script
$script = "osascript -e '{$start}";
- 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 convert_number_to_words
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function convert_number_to_words( $number, $dictionary = 'english' ) {
// This is a complex function, but I'm not sure if it can be simplified.
// adapted from http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/
$hyphen = '-';
$conjunction = ' and ';
- 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 __call
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function __call( $called, $arguments ) {
// Make sure that the method is supposed to exist
if ( 0 !== strpos( $called, 'set_' ) ) {
// We should raise an exception here instead.
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 Filter
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function Filter( $haystack, $needle, $key = false, $options = [] ) {
// Set the defaults if not already set
$max = ( isset( $options['max_results'] ) ) ? $options['max_results'] : false;
$fold_diacritics = ( isset( $options['fold'] ) ) ? $options['fold'] : true;
$match_type = ( isset( $options['match_type'] ) ) ? $options['match_type'] : MATCH_ALL;
Method execute
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $code = false ) {
// Set a preliminary HTTP response code of 0 (not defined)
$this->code = 0;
Function flatten_array
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function flatten_array( $array, $prefix = '' ) {
if ( ! is_array( $array ) ) {
return $array;
}
if ( ! self::is_assoc( $array ) ) {
- 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 add_commas_to_list
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function add_commas_to_list( $list, $suffix = false ) {
// We want a string, so let's convert it to one with an Oxford Comma
$string = '';
$count = 1;
foreach ( $list as $unit => $value ) :
- 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 add_header
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function add_header( $header ) {
// Check the variable. We expect string, but let's be sure.
if ( is_string( $header ) ) {
// Since it's a string, just push it into the headers array.
array_push( $this->headers, $header );
- 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"