Completed
Push — master ( 1d790a...bb9b7d )
by Seth
02:11
created

RequireCanvasPestParameter::getApi()   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 0
1
<?php
2
3
namespace smtech\StMarksSearch\Canvas;
4
5
use Exception;
6
use smtech\CanvasPest\CanvasPest;
7
use smtech\StMarksSearch\RequireParameter;
8
9
/**
10
 * Require and manage a CanvasPest parameter
11
 *
12
 * @author Seth Battis <[email protected]>
13
 */
14
trait RequireCanvasPestParameter
15
{
16
    use RequireParameter;
17
18
    /**
19
     * API access object
20
     * @var CanvasPest
21
     */
22
    protected $api;
23
24
    /**
25
     * Require and store a CanvasPest parameter
26
     *
27
     * @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...
28
     * @param string $key (Optional, defaults to `'api'`)
29
     * @return void
30
     */
31
    protected function requireCanvasPestParameter($params, $key = 'api')
32
    {
33
        $this->requireParameter($params, $key, CanvasPest::class);
34
        $this->setApi($params[$key]);
35
    }
36
37
    /**
38
     * Update the `$api` field
39
     *
40
     * @param CanvasPest $api
41
     */
42
    protected function setApi(CanvasPest $api)
43
    {
44
        assert($api !== null, new Exception('Initialized CanvasPest object required'));
45
        $this->api = $api;
46
    }
47
48
    /**
49
     * Get the Canvas API field
50
     *
51
     * @return CanvasPest
52
     */
53
    protected function getApi()
54
    {
55
        return $this->api;
56
    }
57
}
58