public function hasAccessPermissions($user, $environment = null, $modify = null)
{
$scope = $this->getScope();
if ($modify) {
if (!$environment) {
$result = $scope === $this::SCOPE_ACCOUNT && $this->accountId == $user->accountId || $scope === $this::SCOPE_ENVIRONMENT && $user->hasAccessToEnvironment($this->envId);
} else {
$result = $scope === $this::SCOPE_ENVIRONMENT && $this->envId == $environment->id;
}
} else {
if (!$environment) {
$result = $scope === $this::SCOPE_SCALR || $scope === $this::SCOPE_ACCOUNT && $this->accountId == $user->accountId || $scope === $this::SCOPE_ENVIRONMENT && $user->hasAccessToEnvironment($this->envId);
} else {
$result = $scope === $this::SCOPE_SCALR || $scope === $this::SCOPE_ACCOUNT && $this->accountId == $user->accountId || $scope === $this::SCOPE_ENVIRONMENT && $this->envId == $environment->id;
}
}
return $result;
}