I think this could be refactored into a single line (to avoid variable assignation in a condition and multiple return statements):

```php
return $this->getCategories() ? $this->getCategories()->first() : null;
```