I think it's better to have a conditional when there's no cover from an empty album.
if ($obj->Cover) {
$cover = $obj->Cover->toArray();
// foreach($cover['metas'] as $k => $v){
// $name = strtolower(str_replace(' ','',$v['name']));
// $cover['cover.'. $name] = $v['value'];
// }
// unset($cover['id']);
// unset($cover['metas']);
$phs = array_merge($phs, $cover);
}
On https://github.com/argnist/Cliche/blob/master/core/components/cliche/controllers/web/Albums.php#L119
I think it's better to have a conditional when there's no cover from an empty album.