/** * Create the album * * @param int $albumId * @param bool $includeVideos * @param string $sorting * @param string $direction * * @return Album|null */ public function createAlbum($albumId, $includeVideos = false, $sorting = null, $direction = null) { if (($data = $this->dataProvider->getAlbum($albumId)) === null) { return null; } $videos = []; if ($includeVideos) { if (($videosData = $this->dataProvider->getAlbumVideos($albumId, $sorting, $direction)) === null) { return null; } foreach ($videosData as $videoData) { if (($video = $this->createVideo($this->dataProvider->extractVideoId($videoData), false)) !== null) { $videos[] = $video; } } } return new Album($albumId, $data, $videos); }