Completed
Push — master ( 071f6e...2ed909 )
by Seth
25:30
created

constructSearchDomains()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 4
nop 1
1
<?php
2
3
namespace smtech\StMarksSearch\Canvas\Courses;
4
5
use smtech\StMarksSearch\AbstractSearchDomain;
6
use smtech\StMarksSearch\AbstractSearchDomainFactory;
7
use smtech\StMarksSearch\Canvas\Courses\Announcements\AnnouncementsSearch;
8
use smtech\StMarksSearch\Canvas\Courses\Pages\PagesSearch;
9
10
/**
11
 * Search a Canvas course
12
 *
13
 * @author Seth Battis <[email protected]>
14
 */
15
class CourseSearchDomainFactory extends AbstractSearchDomainFactory
16
{
17
    const ANNOUNCEMENTS = 'announcements';
18
    const PAGES = 'pages';
19
20
    /**
21
     * Construct course-related search domains
22
     *
23
     * @param mixed[string] $params
1 ignored issue
show
Documentation introduced by
The doc-type mixed[string] could not be parsed: Expected "]" at position 2, but found "string". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
24
     * @return AbstractSearchDomain[]
25
     */
26
    public static function constructSearchDomains($params)
27
    {
28
        $domains = [];
29
30
        $consumedParams = [self::ANNOUNCEMENTS, self::PAGES];
31
32
        $params[self::PAGES] = static::forceBooleanParameter($params, self::PAGES);
33
        $params[self::ANNOUNCEMENTS] = static::forceBooleanParameter($params, self::ANNOUNCEMENTS);
34
35
        if ($params[self::PAGES]) {
36
            $domains[] = new PagesSearch(static::consumeParameters($params, $consumedParams));
37
        }
38
39
        if ($params[self::ANNOUNCEMENTS]) {
40
            $domains[] = new AnnouncementsSearch(static::consumeParameters($params, $consumedParams));
41
        }
42
43
        return $domains;
44
    }
45
}
46