public function setUserId($userId) { if (!is_string($userId) || 0 >= strlen($userId)) { throw new ContextException('userId needs to be a non-empty string'); } $this->userId = $userId; }