public function user($data) { if ($data instanceof Client) { $this->user = $data; } if ($this->user instanceof Client) { if ($this->active()) { return $this->user; } if ($this->user->username() && $this->user->password()) { return $this->login($this->user->username(), $this->user->password()); } return $this->user; } $client = Client::createFromArray($data); if ($this->activeClient($client)) { $this->user = $client; } if (!$this->user) { $this->login($client->username(), $client->password()); } return $this->user; }