Code Duplication    Length = 12-12 lines in 3 locations

src/WordPress/Pages/PagesSearch.php 1 location

@@ 62-73 (lines=12) @@
59
     * @param string $query
60
     * @return Relevance
61
     */
62
    protected function relevance($page, $query)
63
    {
64
        $relevance = new Relevance();
65
66
        $relevance->add(Relevance::stringProportion($page['title']['rendered'], $query), 'title match');
67
68
        if (($count = substr_count(strtolower($page['content']['rendered']), strtolower($query))) > 0) {
69
            $relevance->add($count * 0.01, "$count occurrences in body");
70
        }
71
72
        return $relevance;
73
    }
74
}
75

src/WordPress/Posts/PostsSearch.php 1 location

@@ 62-73 (lines=12) @@
59
     * @param string $query
60
     * @return Relevance
61
     */
62
    protected function relevance($post, $query)
63
    {
64
        $relevance = new Relevance();
65
66
        $relevance->add(Relevance::stringProportion($post['title']['rendered'], $query), 'title match');
67
68
        if (($count = substr_count(strtolower($post['content']['rendered']), strtolower($query))) > 0) {
69
            $relevance->add($count * 0.01, "$count occurrences in body");
70
        }
71
72
        return $relevance;
73
    }
74
}
75

src/LibApps/LibGuides/LibGuidesSearch.php 1 location

@@ 57-68 (lines=12) @@
54
     * @param string $query
55
     * @return Relevance
56
     */
57
    protected function relevance($guide, $query)
58
    {
59
        $relevance = new Relevance();
60
61
        $relevance->add(Relevance::stringProportion($guide['name'], $query), 'title match');
62
63
        if (($count = substr_count(strtolower($guide['description']), strtolower($query))) > 0) {
64
            $relevance->add($count * 0.01, "$count occurrences in description");
65
        }
66
67
        return $relevance;
68
    }
69
}
70