當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Artist::build方法代碼示例

本文整理匯總了PHP中Artist::build方法的典型用法代碼示例。如果您正苦於以下問題:PHP Artist::build方法的具體用法?PHP Artist::build怎麽用?PHP Artist::build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Artist的用法示例。


在下文中一共展示了Artist::build方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: extractInfos

 /**
  * Extract Album informations from object
  * @access public
  * @static
  * @param  \stdClass $album Object represent Album
  * @return Album
  */
 public static function extractInfos($album)
 {
     // create Album instance
     $albumItem = new self();
     // update informations
     $albumItem->setUri((string) isset($album->href) ? $album->href : '');
     $albumItem->setName((string) isset($album->name) ? $album->name : '');
     // is popularity available ?
     if (isset($album->popularity)) {
         // update popularity
         $albumItem->setPopularity((double) $album->popularity);
     }
     // is released date available ?
     if (isset($album->released)) {
         // update released dates
         $albumItem->setReleased((string) $album->released);
     }
     // is teritories availabality available ?
     if (isset($album->availability) && isset($album->availability->territories)) {
         // update territories availability
         $albumItem->setTerritories(explode(' ', $album->availability->territories));
     }
     // is artists available (from search service) ?
     if (isset($album->artists) && is_array($album->artists)) {
         // setup artists container
         $artists = array();
         // iterate artists
         foreach ($album->artists as $artist) {
             // create Artist and store on container
             $artists[] = Artist::extractInfos($artist);
         }
         // set artists of album
         $albumItem->setArtists($artists);
     }
     // is artists available (from lookup service) ?
     if (isset($album->{'artist-id'}) && isset($album->artist)) {
         // create and store principal artist
         $albumItem->setArtist(Artist::build($album->{'artist-id'}, $album->artist));
     }
     // is tracks available ?
     if (isset($album->tracks) && is_array($album->tracks)) {
         // setup tracks container
         $tracks = array();
         // iterate external ids
         foreach ($album->tracks as $track) {
             // create Track and store on container
             $tracks[] = Track::extractInfos($track);
         }
         // set albums tracks
         $albumItem->setTracks($tracks);
     }
     // is external ids available ?
     if (isset($album->{'external-ids'}) && is_array($album->{'external-ids'})) {
         // setup external ids container
         $externalIds = array();
         // iterate external ids
         foreach ($album->{'external-ids'} as $externalId) {
             // create ExternalId and store on container
             $externalIds[] = ExternalId::extractInfos($externalId);
         }
         // set external ids of album
         $albumItem->setExternalIds($externalIds);
     }
     // return album instance
     return $albumItem;
 }
開發者ID:ze-pequeno,項目名稱:pequeno-spotify-module,代碼行數:73,代碼來源:Album.php


注:本文中的Artist::build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。