type = $type; $this->userId = $userId; } static public function fromJson($jsonId) { if (in_array(substr($jsonId, 1), UserId::$types)) { return new UserId(substr($jsonId, 1), null); } return new UserId('userId', $jsonId); } public function getUserId(SecurityToken $token) { switch ($this->type) { case 'viewer': case 'me': return $token->getViewerId(); break; case 'owner': return $token->getOwnerId(); break; case 'userId': return $this->userId; break; default: throw new Exception("The type field is not a valid enum: {$this->type}"); break; } } public function getType() { return $this->type; } }