public function setCapacity($capacity)
    {
        if ($capacity !== NULL) {
            if (!is_float($capacity) && !is_int($capacity)) {
                throw new InvalidArgumentException('Invalid capacity given - must be numeric');
            }
            if ($capacity < 0) {
                throw new InvalidArgumentException('Capacity must not be negative');
            }
            if ($this->flow !== NULL && $this->flow > $capacity) {
                throw new RangeException('Current flow of ' . $this->flow . ' exceeds new capacity');
            }
        }
        $this->capacity = $capacity;

        return $this;
    }