1 | <?php |
||
5 | class CalendarContext |
||
6 | { |
||
7 | /** |
||
8 | * The canonical URL for this context in Canvas |
||
9 | * @var string |
||
10 | */ |
||
11 | protected $canonicalUrl; |
||
12 | |||
13 | /** |
||
14 | * The context for this calendar in Canvas (user, group, course) |
||
15 | * @var CanvasContext |
||
16 | */ |
||
17 | protected $context; |
||
18 | |||
19 | /** |
||
20 | * Unique ID for this Canvas context |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $id; |
||
24 | |||
25 | /** |
||
26 | * URL to verify this context against API |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $verificationUrl; |
||
30 | |||
31 | /** |
||
32 | * Compute the calendar context for the canvas object based on its URL |
||
33 | * |
||
34 | * @param string $canvasUrl URL to the context for a calendar on this |
||
35 | * Canvas instance |
||
36 | * @throws Exception If `$canvasInstance` is not a URL on this Canvas |
||
37 | * instance |
||
38 | * @throws Exception if `$canvasInstance` is not a URL to a recognizable |
||
39 | * calendar context |
||
40 | */ |
||
41 | public function __construct($canvasUrl) |
||
89 | |||
90 | public function getCanonicalUrl() |
||
94 | |||
95 | public function getContext() |
||
99 | |||
100 | public function getId() |
||
104 | |||
105 | public function getVerificationUrl() |
||
109 | } |
||
110 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: