owner = $owner; parent::__construct($api_url, $api_token); } protected function set_scope(string $method) { switch ($method) { case "get": $this->scope = ($this->owner == null || $this->owner->authenticated() ? "/user" : "/users/" . $this->owner->uusername) . "/orgs"; return true; } } public function create(...$args) { $org = new Org($this->url, $this->token, null, $this->owner); if (count($args) > 0) $org->create(...$args); return $org; } public function get(string $s) { if (($org = $this->by_key($s))) return $org; return new Org($this->url, $this->token, $s, $this->owner); } public function search(array $params = array()) { if (!isset($params["name"]) && !isset($params["q"])) throw new SearchParamException("Missing param |"); $q = isset($params["name"]) ? $params["name"] : $params["q"]; $l = isset($params["limit"]) ? $params["limit"] : 10; $this->load(); $orgs = new CollectionResult(); foreach ($this->all() as $key => $org) { if ($org->search($q)) $orgs->set($org); if ($orgs->len() == $l) break; } return $orgs; } protected function json_set_property($obj) { foreach($obj as $val) { $org = new Org($this->url, $this->token, null, $this->owner); $org->json_set_property($val); $this->add($org, $val->username); } } }