public function getScope()
{
switch ($this->level) {
case self::LEVEL_ENVIRONMENT:
return self::SCOPE_ENVIRONMENT;
case self::LEVEL_ACCOUNT:
return self::SCOPE_ACCOUNT;
case self::LEVEL_SCALR:
return self::SCOPE_SCALR;
default:
throw new \UnexpectedValueException(sprintf("Unknown level type: %d in %s::%s", $this->level, get_class($this), __FUNCTION__));
}
}
/** * @param WebhookEndpoint $endpoint * @throws Exception */ private function canEditEndpoint($endpoint) { return $this->request->getScope() == $endpoint->getScope() && ($endpoint->getScope() == WebhookEndpoint::SCOPE_SCALR || $endpoint->getScope() == WebhookEndpoint::SCOPE_ACCOUNT && $endpoint->accountId == $this->user->getAccountId() || $endpoint->getScope() == WebhookEndpoint::SCOPE_ENVIRONMENT && $endpoint->envId == $this->getEnvironmentId() && $endpoint->accountId == $this->user->getAccountId()); }