/** * calculate section score * @param wtb_seo_box_section $section * @return float */ protected function calcScore($section) { $maxAvailable = 0; $score = 0; // keyword in title 25% if ($section->isParamAllowed('title')) { $maxAvailable += 25; $score += !empty($section->parameters['title']) ? 25 : 0; } // keyword in H1 21% if ($section->isParamAllowed('h1')) { $maxAvailable += 21; $score += !empty($section->parameters['h1']) ? 21 : 0; } // keyword in H2 8% if ($section->isParamAllowed('h2')) { $maxAvailable += 8; $score += !empty($section->parameters['h2']) ? 8 : 0; } // keyword in H3 5% if ($section->isParamAllowed('h3')) { $maxAvailable += 5; $score += !empty($section->parameters['h3']) ? 5 : 0; } // keyword in bold 3% if ($section->isParamAllowed('bold')) { $maxAvailable += 3; $score += !empty($section->parameters['bold']) ? 3 : 0; } // keyword in italic 3% if ($section->isParamAllowed('italic')) { $maxAvailable += 3; $score += !empty($section->parameters['italic']) ? 3 : 0; } // keyword in underline 3% if ($section->isParamAllowed('underline')) { $maxAvailable += 3; $score += !empty($section->parameters['underline']) ? 3 : 0; } // keyword in alt 2% if ($section->isParamAllowed('alt')) { $maxAvailable += 2; $score += !empty($section->parameters['alt']) ? 2 : 0; } // keyword desnsity 15% $maxAvailable += 15; if ($section->density >= $section->perfectDensity * 1.27) { $score += 0; } else { if ($section->density >= $section->perfectDensity * 1.23) { $score += 6; } else { if ($section->density >= $section->perfectDensity * 1.16) { $score += 9; } else { if ($section->density >= $section->perfectDensity * 1.1) { $score += 13; } else { if ($section->density > $section->perfectDensity) { $score += 15; } else { if ($section->perfectDensity != 0) { $score += number_format(15 * $section->density / $section->perfectDensity, 2); } } } } } } // lenght 15% $maxAvailable += 15; if ($this->getTotalWordCount() >= $this->idealPostLenght) { $score += 15; } else { if ($this->idealPostLenght != 0) { $score += 15 * $this->getTotalWordCount() / $this->idealPostLenght; } } return $score * 100 / $maxAvailable; }