public static function createFromResponse(\SimpleXMLElement $response)
 {
     $artist = new Artist();
     $artist->setRawResponse($response->asXML());
     $artist->setName((string) $response->name);
     $artist->setMbid((string) $response->mbid);
     $artist->setUrl((string) $response->url);
     $images = array();
     if (!empty($response->image)) {
         foreach ($response->image as $image) {
             $imageAttributes = $image->attributes();
             if (!empty($imageAttributes->size)) {
                 $images[(string) $imageAttributes->size] = (string) $image;
             }
         }
     }
     $artist->setImages($images);
     $artist->setStreamable((int) $response->streamable);
     if (!empty($response->stats)) {
         $artist->setListeners((int) $response->stats->listeners);
         $artist->setPlayCount((int) $response->stats->playcount);
     } elseif (isset($response->listeners)) {
         $artist->setListeners((int) $response->listeners);
     }
     $similar = array();
     if (!empty($response->similar->artist)) {
         foreach ($response->similar->artist as $similarArtistXML) {
             $similarArtist = self::createFromResponse($similarArtistXML);
             if (!empty($similarArtist)) {
                 $similar[$similarArtist->getName()] = $similarArtist;
             }
         }
     }
     $artist->setSimilar($similar);
     $tags = array();
     if (!empty($response->tags->tag)) {
         foreach ($response->tags->tag as $tag) {
             $tags[] = Tag::createFromResponse($tag);
         }
     }
     $artist->setTags($tags);
     $bio = array();
     if (!empty($response->bio)) {
         $bio['published'] = (string) $response->bio->published;
         $bio['summary'] = (string) $response->bio->summary;
         $bio['content'] = (string) $response->bio->content;
     }
     $artist->setBio($bio);
     $artist->setWeight((int) $response->weight);
     return $artist;
 }
 public static function createFromResponse(\SimpleXMLElement $response)
 {
     $album = new Album();
     $album->setRawResponse($response);
     $album->setId((int) $response->id);
     $album->setName((string) $response->name);
     $artisNodeCount = count($response->artist->children());
     if (!empty($artisNodeCount)) {
         $artist = Artist::createFromResponse($response->artist);
     } else {
         $artist = new Artist();
         $artist->setName((string) $response->artist);
     }
     $album->setArtist($artist);
     $album->setUrl((string) $response->url);
     $images = array();
     foreach ($response->image as $image) {
         $images[] = (string) $image;
     }
     $album->setImages($images);
     $album->setStreamable((bool) $response->streamable);
     $album->setMbid((string) $response->mbid);
     $album->setReleaseDate((string) $response->releasedate);
     $album->setListeners((int) $response->listeners);
     $album->setPlayCount((int) $response->playcount);
     $album->setStreamable((int) $response->streamable);
     $topTags = array();
     foreach ($response->toptags as $topTag) {
         $topTags[] = $topTag;
     }
     $album->setTopTags($topTags);
     $tracks = array();
     if (!empty($response->tracks->track)) {
         foreach ($response->tracks->track as $track) {
             $tracks[] = Track::createFromResponse($track);
         }
         $album->setTracks($tracks);
     }
     return $album;
 }