That reads badly. Maybe

````php
$document = $this->documentHasValidClassName($document, $className) ? $document : null;
return $document;
````

I initially didn't see the ternary operators and thought you were returning a `boolean` or the method was badly named..