Skip to content

Commit 62c4e23

Browse files
committed
feat: make class argument optional
1 parent 615e0aa commit 62c4e23

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Model/OneRoster.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@ protected static function httpGet($route)
143143
* @param $class the type of the object wanted
144144
* @return mixed
145145
*/
146-
protected static function get($route, $class) {
146+
protected static function get($route, $class = null) {
147147
$header = self::generateHeader();
148+
if ($class == null) {
149+
$class = get_called_class();
150+
}
148151
$json = OpenLRW::httpGet(self::PREFIX . $route, $header);
149152
if (count($json) < 2 ) {
150-
return new static ((array)$json[0]);
153+
return new $class((array)$json[0]);
151154
} else {
152155
$results = [];
153156
foreach ($json as $item) {

0 commit comments

Comments
 (0)