private function assertValidWill()
    {
        if ($this->hasWill()) {
            $this->assertValidQosLevel($this->getWillQosLevel(), true);
        } else {
            if ($this->getWillQosLevel() > 0) {
                $this->throwException(
                    sprintf(
                        'Expected a will quality of service level of zero but got %d.',
                        $this->getWillQosLevel()
                    ),
                    true
                );
            }

            if ($this->isWillRetained()) {
                $this->throwException('There is not will but the will retain flag is set.', true);
            }
        }
    }