dinel / metadiscourse-annotator

0 stars 0 forks source link

[Insight] Usage of a function in loops should be avoided - in src/AppBundle/Twig/AppExtension.php, line 31 #51

Closed dinel closed 6 years ago

dinel commented 6 years ago

in src/AppBundle/Twig/AppExtension.php, line 31

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

        if($pos !== false) {
            $string = substr($string, $pos + 1);
        }
        $md5str = md5($string);
        $ret = "";
        for($i = 0; $i < strlen($md5str); $i++) {
            if(ctype_alpha($md5str[$i])) {
                $ret .= $md5str[$i];
            }
        }

Posted from SensioLabsInsight