File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,5 @@ interface Institution
88 * Define the name used to identify this Schools entry in the config.
99 */
1010 public function getConfigName (): string ;
11+ public static function default (): Institution ;
1112}
Original file line number Diff line number Diff line change @@ -16,25 +16,44 @@ abstract class Endpoint
1616 /**
1717 * @var Guzzle
1818 */
19- protected $ guzzle ;
19+ protected Guzzle $ guzzle ;
2020
2121 /**
2222 * @var Institution
2323 */
24- protected $ institution ;
24+ protected Institution $ institution ;
2525
2626 /**
2727 * @var string
2828 */
29- protected $ endpoint ;
29+ protected string $ endpoint ;
3030
31- public function __construct (Institution $ institution )
31+ /**
32+ * @throws Exception
33+ */
34+ public function __construct (?Institution $ institution = null )
3235 {
33- $ this ->institution = $ institution ;
36+ $ this ->setInstitution ( $ institution) ;
3437 $ this ->setGuzzle ();
3538 $ this ->setEndpoint ();
3639 }
3740
41+ /**
42+ * @throws Exception
43+ */
44+ protected function setInstitution (Institution $ institution ): void
45+ {
46+ $ this ->institution = $ institution ;
47+
48+ if ($ this ->institution === null ) {
49+ if (function_exists ('defaultIsamsInstitution ' )) {
50+ $ this ->institution = defaultIsamsInstitution ();
51+ } else {
52+ throw new Exception ('No Institution provided and no default Institution set. ' );
53+ }
54+ }
55+ }
56+
3857 /**
3958 * Instantiate Guzzle.
4059 *
You can’t perform that action at this time.
0 commit comments