You can simplify it

```php
if ($services->has('Zend\Authentication\AuthenticationService')) {
    $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
}
```