setAPIKey($this->generateAPIKey()) ->setSecretKey($this->generateSecretKey()); // set date created $this->date_create = new DateTime(); $this->metadata = []; } public function getID() { return $this->id; } public function setAPIKey($api_key) { $this->api_key = $api_key; return $this; } public function getAPIKey() { return $this->api_key; } public function setSecretKey($key) { $this->secret_key = $key; return $this; } public function getSecretKey() { return $this->secret_key; } public function setName($name) { $this->name = $name; return $this; } public function getName() { return $this->name; } public function getDateCreate() { return $this->date_create; } public function getPassword() { // we don't need this for API return 'notneeded'; } public function getSalt() { return null; } public function getUsername() { // since it's an api, the api key IS the username return $this->api_key; } public function eraseCredentials() { return; } public function generateAPIKey() { return $this->generateKey('api'); } public function generateSecretKey() { return $this->generateKey('secret'); } public function setMetadata($meta) { $this->metadata = $meta; return $this; } public function getMetadata() { if ($this->metadata == null) return []; return $this->metadata; } protected function generateKey($prefix = '') { return md5(uniqid($prefix, true)); } }