Completed
Push — develop ( b91125...52c290 )
by Seth
03:00
created

Syncable::getApi()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace smtech\CanvasICSSync\SyncIntoCanvas;
4
5
use mysqli;
6
use smtech\CanvasPest\CanvasPest;
7
8
/**
9
 * A syncable object
10
 *
11
 * @author Seth Battis <[email protected]>
12
 */
13
abstract class Syncable
14
{
15
    /**
16
     * MySQL connection
17
     *
18
     * @var mysqli|null
19
     */
20
    protected static $mysql;
21
22
    /**
23
     * Canvas API connection
24
     *
25
     * @var CanvasPest|null
26
     */
27
    protected static $api;
28
29
    /**
30
     * Update the MySQL connection
31
     *
32
     * @param mysqli $mysql
33
     * @throws Exception If `$mysql` is null
34
     */
35
    public static function setMySql(mysqli $mysql)
36
    {
37
        if (empty($mysql)) {
38
            throw new Exception(
39
                'A non-null MySQL connection is required'
40
            );
41
        } else {
42
            static::$mysql = $mysql;
43
        }
44
    }
45
46
    /**
47
     * Get the MySQL connection
48
     *
49
     * @return mysqli
50
     */
51
    public static function getMySql()
52
    {
53
        return static::$mysql;
54
    }
55
56
    /**
57
     * Update the API connection
58
     *
59
     * @param CanvasPest $api
60
     * @throws Exception if `$api` is null
61
     */
62
    public static function setApi(CanvasPest $api)
63
    {
64
        if (empty($api)) {
65
            throw new Exception(
66
                'A non-null API connection is required'
67
            );
68
        } else {
69
            static::$api = $api;
70
        }
71
    }
72
73
    /**
74
     * Get the API connection
75
     *
76
     * @return CanvasPest|null
77
     */
78
    public static function getApi()
79
    {
80
        return static::$api;
81
    }
82
83
    /**
84
     * Save the syncable object to the MySQL database
85
     *
86
     * @return [type] [description]
0 ignored issues
show
Documentation introduced by
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(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...
87
     */
88
    abstract public function save();
89
90
    /**
91
     * Load a syncable object from the MySQL database
92
     *
93
     * @param int $id
94
     * @return Syncable
95
     */
96
    abstract public static function load($id);
97
}
98