Completed
Push — master ( 0765b1...3d50cd )
by Seth
03:43 queued 01:43
created

AbstractLibAppsSearchDomain::setApi()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace smtech\StMarksSearch\LibApps;
4
5
use Exception;
6
use smtech\StMarksSearch\AbstractSearchDomain;
7
8
abstract class AbstractLibAppsSearchDomain extends AbstractSearchDomain
9
{
10
    /**
11
     * API access object
12
     * @var LibGuidesPest
13
     */
14
    protected $api;
15
16
    public function __construct($params)
17
    {
18
        if (!isset($params['icon'])) {
19
            $params['icon'] = 'https://stmarksschool-ma.libapps.com/favicon.ico';
20
        }
21
22
        parent::__construct($params);
23
24
        assert(
25
            !empty($params['site_id']) && is_numeric($params['site_id']),
26
            new Exception('`site_id` parameter must be a valid numeric LibApps ID')
27
        );
28
        assert(
29
            !empty($params['key']),
30
            new Exception('`key` parameter must not be empty')
31
        );
32
33
        $this->setApi($params['site_id'], $params['key']);
34
    }
35
36
    protected function setApi($siteId, $key)
37
    {
38
        $this->api = new LibAppsPest($siteId, $key);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \smtech\StMarksSearc...AppsPest($siteId, $key) of type object<smtech\StMarksSearch\LibApps\LibAppsPest> is incompatible with the declared type object<smtech\StMarksSea...\LibApps\LibGuidesPest> of property $api.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
39
    }
40
41
    public function getApi()
42
    {
43
        return $this->api;
44
    }
45
}
46