ForumSearch   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set_search_engine() 0 16 3
A get_search_engine() 0 4 1
1
<?php
2
3
/**
4
 * Forum Search.
5
 *
6
 * Wrapper for providing search functionality
7
 *
8
 * @package forum
9
 */
10
11
class ForumSearch
12
{
13
    
14
    /**
15
     * The search class engine to use for the forum. By default use the standard
16
     * Database Search but optionally allow other search engines. Must implement
17
     * the {@link ForumSearch} interface.
18
     *
19
     * @var String
20
     */
21
    private static $search_engine = 'ForumDatabaseSearch';
22
    
23
    /**
24
     * Set the search class to use for the Forum search. Must implement the
25
     * {@link ForumSearch} interface
26
     *
27
     * @param String
28
     *
29
     * @return The result of load() on the engine
30
     */
31
    public static function set_search_engine($engine)
32
    {
33
        if (!$engine) {
34
            $engine = 'ForumDatabaseSearch';
35
        }
36
        
37
        $search = new $engine();
38
        
39
        if ($search instanceof ForumSearchProvider) {
40
            self::$search_engine = $engine;
41
            
42
            return $search->load();
43
        } else {
44
            user_error("$engine must implement the ForumSearchProvider interface");
45
        }
46
    }
47
    
48
    /**
49
     * Return the search class for the forum search
50
     *
51
     * @return String
52
     */
53
    public static function get_search_engine()
54
    {
55
        return self::$search_engine;
56
    }
57
}
58