protected function applyAccessMode(int $mode): void
    {
        if ($this->mode === self::MODE_CLOSED) {

            // set new mode
            $this->mode = $mode;
            return;
        } elseif ($mode === $this->mode) {

            // nothing to do
            return;
        }

        // mode-switching detected
        throw new AccessDeniedException('unable to switch access-mode for existing binary file handle', 500);
    }