当前位置: 首页>>代码示例>>PHP>>正文


PHP Artist::extractInfos方法代码示例

本文整理汇总了PHP中Artist::extractInfos方法的典型用法代码示例。如果您正苦于以下问题:PHP Artist::extractInfos方法的具体用法?PHP Artist::extractInfos怎么用?PHP Artist::extractInfos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Artist的用法示例。


在下文中一共展示了Artist::extractInfos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例2: extractInfos

 /**
  * Extract Track informations from object
  * @access public
  * @static
  * @param  \stdClass $track Object represent Track
  * @return Track
  */
 public static function extractInfos($track)
 {
     // create Track instance
     $trackItem = new self();
     // update informations
     $trackItem->setUri((string) $track->href);
     $trackItem->setName((string) $track->name);
     // is popularity available ?
     if (isset($track->popularity)) {
         // update popularity
         $trackItem->setPopularity((double) $track->popularity);
     }
     // is disc number available ?
     if (isset($track->{'disc-number'})) {
         // update disc number
         $trackItem->setDiscNumber($track->{'disc-number'});
     }
     // is track number available ?
     if (isset($track->{'track-number'})) {
         // update track number
         $trackItem->setTrackNumber($track->{'track-number'});
     }
     // is track length available ?
     if (isset($track->length)) {
         // update track length
         $trackItem->setLength($track->length);
     }
     // is track albul available ?
     if (isset($track->album)) {
         // update track album
         $trackItem->setAlbum(Album::extractInfos($track->album));
     }
     // is artists available ?
     if (isset($track->artists) && is_array($track->artists)) {
         // setup artists container
         $artists = array();
         // iterate artists
         foreach ($track->artists as $artist) {
             // create Artist and store on container
             $artists[] = Artist::extractInfos($artist);
         }
         // set artists of track
         $trackItem->setArtists($artists);
     }
     // is external ids available ?
     if (isset($track->{'external-ids'}) && is_array($track->{'external-ids'})) {
         // setup external ids container
         $externalIds = array();
         // iterate external ids
         foreach ($track->{'external-ids'} as $externalId) {
             // create ExternalId and store on container
             $externalIds[] = ExternalId::extractInfos($externalId);
         }
         // set external ids of track
         $trackItem->setExternalIds($externalIds);
     }
     // is teritories availabality available ?
     if (isset($track->availability) && isset($track->availability->territories)) {
         // update territories availability
         $trackItem->setTerritories(explode(' ', $track->availability->territories));
     }
     // on retourne l'instance de la piste
     return $trackItem;
 }
开发者ID:ze-pequeno,项目名称:pequeno-spotify-module,代码行数:71,代码来源:Track.php


注:本文中的Artist::extractInfos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。