features/search/lib.php

Summary

Maintainability
A
1 hr
Test Coverage

Method perform has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static function perform($terms){
        
        $terms = Search::split_terms($terms);
        $terms_db = Search::db_escape_terms($terms);
        $terms_rx = Search::rx_escape_terms($terms);
Severity: Minor
Found in features/search/lib.php - About 1 hr to fix

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class Search {
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::transform_term" is not in camel caps format
    Open

        static function transform_term($term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The static declaration must come after the visibility declaration
    Open

        static private function pretty_terms($terms_html){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Each PHP statement must be on a line by itself
    Open

            $term = preg_replace_callback("/(\s)/", function($m) {return '{WHITESPACE-'.ord($m[1]).'}';}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Each PHP statement must be on a line by itself
    Open

            $terms = preg_replace_callback("/\"(.*?)\"/", function($m) {return Search::transform_term($m[1]);}, $terms);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FUNCTION keyword; 0 found
    Open

            $terms = preg_replace_callback("/\"(.*?)\"/", function($m) {return Search::transform_term($m[1]);}, $terms);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Visibility must be declared on method "perform"
    Open

        static function perform($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The static declaration must come after the visibility declaration
    Open

        static private function rx_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The closing brace for the class must go on the next line after the body
    Open

    }
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The static declaration must come after the visibility declaration
    Open

        static private function html_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Visibility must be declared on method "transform_term"
    Open

        static function transform_term($term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FUNCTION keyword; 0 found
    Open

            $term = preg_replace_callback("/(\s)/", function($m) {return '{WHITESPACE-'.ord($m[1]).'}';}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::escape_rlike" is not in camel caps format
    Open

        static private function escape_rlike($string){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The static declaration must come after the visibility declaration
    Open

        static private function db_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::rx_escape_terms" is not in camel caps format
    Open

        static private function rx_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The static declaration must come after the visibility declaration
    Open

        static private function escape_rlike($string){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Visibility must be declared on method "sort_results"
    Open

        static function sort_results($a, $b){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::sort_results" is not in camel caps format
    Open

        static function sort_results($a, $b){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace of a class must be on the line after the definition
    Open

    class Search {
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::split_terms" is not in camel caps format
    Open

        static private function split_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::html_escape_terms" is not in camel caps format
    Open

        static private function html_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::pretty_terms" is not in camel caps format
    Open

        static private function pretty_terms($terms_html){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Blank line found at start of control structure
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FUNCTION keyword; 0 found
    Open

                $term = preg_replace_callback("/\{WHITESPACE-([0-9]+)\}/", function($m) {return chr($m[1]);}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Each PHP statement must be on a line by itself
    Open

                $term = preg_replace_callback("/\{WHITESPACE-([0-9]+)\}/", function($m) {return chr($m[1]);}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    The static declaration must come after the visibility declaration
    Open

        static private function split_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Blank line found at start of control structure
    Open

            while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Method name "Search::db_escape_terms" is not in camel caps format
    Open

        static private function db_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace must be the last content on the line
    Open

            $terms = preg_replace_callback("/\"(.*?)\"/", function($m) {return Search::transform_term($m[1]);}, $terms);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Closing brace must be on a line by itself
    Open

            $terms = preg_replace_callback("/\"(.*?)\"/", function($m) {return Search::transform_term($m[1]);}, $terms);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static function perform($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FOREACH keyword; 0 found
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Closing brace must be on a line by itself
    Open

            $term = preg_replace_callback("/(\s)/", function($m) {return '{WHITESPACE-'.ord($m[1]).'}';}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static private function db_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Closing brace must be on a line by itself
    Open

                $term = preg_replace_callback("/\{WHITESPACE-([0-9]+)\}/", function($m) {return chr($m[1]);}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Newline required after opening brace
    Open

            if ($ax == $bx){ return 0; }
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Closing brace must be on a line by itself
    Open

            if ($ax == $bx){ return 0; }
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing brace; 0 found
    Open

                }else{
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace must be the last content on the line
    Open

                $term = preg_replace_callback("/\{WHITESPACE-([0-9]+)\}/", function($m) {return chr($m[1]);}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            foreach($terms_db as $term_db){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FOREACH keyword; 0 found
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FOREACH keyword; 0 found
    Open

                foreach($terms_rx as $term_rx){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

                foreach($terms_rx as $term_rx){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static function sort_results($a, $b){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FOREACH keyword; 0 found
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static private function rx_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

                if (preg_match("/\s|,/", $term)){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after ELSE keyword; 0 found
    Open

                }else{
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FOREACH keyword; 0 found
    Open

            foreach($terms_db as $term_db){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            if (count($terms_html) == 1){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace must be the last content on the line
    Open

            $term = preg_replace_callback("/(\s)/", function($m) {return '{WHITESPACE-'.ord($m[1]).'}';}, $term);
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static private function escape_rlike($string){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static function transform_term($term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

            while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static private function html_escape_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static private function pretty_terms($terms_html){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after FOREACH keyword; 0 found
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            if ($ax == $bx){ return 0; }
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static private function split_terms($terms){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

            foreach($terms as $term){
    Severity: Minor
    Found in features/search/lib.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status