Completed
Push — master ( 478235...2430ac )
by Seth
02:01
created

CourseSearch::__construct()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 25
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 25
rs 8.8571
c 1
b 0
f 0
cc 3
eloc 14
nc 4
nop 1
1
<?php
2
3
namespace smtech\StMarksSearch\Canvas\Courses;
4
5
use smtech\CanvasPest\CanvasPest;
6
use smtech\StMarksSearch\RequireParameter;
7
use smtech\StMarksSearch\SearchEngine;
8
use smtech\StMarksSearch\Canvas\AbstractCanvasSearch;
9
use smtech\StMarksSearch\Canvas\Courses\Announcements\AnnouncementsSearch;
10
use smtech\StMarksSearch\Canvas\Courses\Pages\PagesSearch;
11
12
/**
13
 * Search a Canvas course
14
 *
15
 * @author Seth Battis <[email protected]>
16
 */
17
class CourseSearch extends AbstractCanvasSearch
18
{
19
    use RequireParameter;
20
    use DeriveCourseUrlFromId;
21
22
    /**
23
     * Construct a CourseSearch: may have a `pages` field to indicate that
24
     * course pages should be searched.
25
     *
26
     * @inheritdoc
27
     *
28
     * @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...
29
     */
30
    public function __construct($params)
31
    {
32
        $this->requireParameter($params, 'id');
33
34
        parent::__construct($params);
35
36
        $this->setId($params['id']);
37
        $this->setUrl(
38
            $this->deriveCourseUrl(
39
                $this->getUrl(),
40
                $this->getApi()
41
            )
42
        );
43
44
        $params['pages'] = $this->forceBooleanParameter($params, 'pages');
45
        $params['announcements'] = $this->forceBooleanParameter($params, 'announcements');
46
47
        if ($params['pages']) {
48
            $this->addDomain(new PagesSearch($params));
49
        }
50
51
        if ($params['announcements']) {
52
            $this->addDomain(new AnnouncementsSearch($params));
53
        }
54
    }
55
}
56