protected function ensureParameter($name)
    {
        if (!isset($this->$name)) {
            throw new \InvalidArgumentException(get_class($this) . ' is missing parameter: ' . $name);
        }

        return $this->$name;
    }