public static function factory($artistOrMBID, $limit = 30) { if ($limit < 0) { $limit = 30; } $a = new self(); if (preg_match('/^[a-z0-9]+-[a-z0-9]+-[a-z0-9]+-[a-z0-9]+-[a-z0-9]+$/', $artistOrMBID)) { // Id $a->getArtistInfoFromMusicBrainzId($artistOrMBID); // similar artists $a->getSimilarArtists($limit); } else { // Name // Need to find ID $a->getArtistInfoFromName($artistOrMBID); $nameSimilarity = 0.0; similar_text(strtolower($a->name), strtolower($artistOrMBID), $nameSimilarity); $isNotMultiArtists = $nameSimilarity >= 65; //strcasecmp($a->name, $artistOrMBID) === 0; // Check if multiple artists in one artist name (eg. Frank Sinatra & Elivs Presley) $names = preg_split("/[\\s]*[\\/\\,\\&]+[\\s]*/", $artistOrMBID); if (!$isNotMultiArtists && count($names) >= 2 && !(count($names) == 2 && strcasecmp("the", $names[count($names) - 1]) === 0)) { return self::createVariousArtistsInfo($names, $limit); } else { // similar artists for this artist $a->getSimilarArtists($limit); } } return $a; }