/** * Combined getter/setter for API clients. * * @param int $type The "type" of API client to get or set * @param \Desk\Client The new object to use as a client (optional) * * @return \Desk\Client */ public function client($type, $client = null) { if (!Client::isValidType($type)) { throw new Exception\InvalidArgumentException("Invalid Desk API client type \"{$type}\""); } if ($client) { if ($client instanceof Client) { $this->clients[$type] = $client; } else { throw new Exception\InvalidArgumentException('Desk API client is not an instance of \\Desk\\Client'); } } // initialise client if it doesn't exist if (empty($this->clients[$type])) { $this->clients[$type] = Client::factory($type, $this->transport); } return $this->clients[$type]; }