ousername = $oname; $this->owner = $owner; parent::__construct($api_url, $api_token); } protected function set_scope(string $method) { switch ($method) { case "create": if ($this->owner == null) throw new Exception\InvalidMethodRequestException("Cant create organization without a related User"); $this->scope = "/admin/users/" . $this->owner->uusername . "/orgs"; return true; case "get": $this->scope = "/orgs/" . $this->uusername; return true; } } public function search(string $q) { $searchable = sprintf("%s %s %s", $this->ufull_name, $this->uusername, $this->udescription); return stripos($searchable, $q) !== false; } public function create(...$args) { $params = array( "username" => isset($args[0]) && is_string($args[0]) ? $args[0] : null, "ufull_name" => isset($args[1]) && is_string($args[1]) ? $args[1] : null, "description" => isset($args[2]) && is_string($args[2]) ? $args[2] : null, "website" => isset($args[3]) && is_string($args[3]) ? $args[3] : null, "location" => isset($args[4]) && is_string($args[4]) ? $args[4] : null ); $params = array_filter($params, function($val) { return $val != null; }); parent::create($params); } } } ?>