using something like 
```php
if($storage instanceof \OC\Files\Storage\Home)
    $user = $storage->getUser()->getUID(); //getUser() would need to be added
````

would simplify this whole bit