id = isset($row['id']) ? (int)$row['id'] : null; $key->key = (string)($row['api_key'] ?? ''); $key->description = (string)($row['description'] ?? ''); $key->access = (string)($row['access'] ?? self::ACCESS_RO); $key->allowFrom = array_values(array_filter(array_map('trim', explode(',', (string)($row['allow_from'] ?? ''))), 'strlen')); $key->skipIpCheck = (int)($row['skip_ip_check'] ?? 0); $key->service = (int)($row['service'] ?? 0); $key->active = (int)($row['active'] ?? 1); $key->created = isset($row['created']) ? (string)$row['created'] : null; $key->modified = isset($row['modified']) ? (string)$row['modified'] : null; return $key; } /** API representation (GET api-key) */ public function toArray(): array { return [ 'id' => $this->id, 'description' => $this->description, 'access' => $this->access, 'api_key' => $this->key, 'allow_from' => $this->allowFrom, 'skip_ip_check' => $this->skipIpCheck, 'service' => $this->service, 'active' => $this->active, 'created' => $this->created, 'modified' => $this->modified, ]; } }