In that case, you save a comparison with something like;

```php
    public function toArray()
    {
        $filtered = array();

        if ($this->_query !== null) {
            $filtered['query'] = $this->_query->toArray();
        }

        if ($this->_filter !== null) {
            $filtered['filter'] = $this->_filter->toArray();
        }

        if (empty($filtered)) {
            throw new NotFoundException('A query and/or filter is required');
        }

        return array('filtered' => $filtered);
    }
```