/** * @param array $artist * @param MusicBrainz $brainz * * @throws Exception */ public function __construct(array $artist, MusicBrainz $brainz) { if (!isset($artist['id']) || isset($artist['id']) && !$brainz->isValidMBID($artist['id'])) { throw new Exception('Can not create artist object. Missing valid MBID'); } $this->data = $artist; $this->brainz = $brainz; $this->id = isset($artist['id']) ? (string) $artist['id'] : ''; $this->type = isset($artist['type']) ? (string) $artist['type'] : ''; $this->name = isset($artist['name']) ? (string) $artist['name'] : ''; $this->sortName = isset($artist['sort-name']) ? (string) $artist['sort-name'] : ''; $this->gender = isset($artist['gender']) ? (string) $artist['gender'] : ''; $this->country = isset($artist['country']) ? (string) $artist['country'] : ''; $this->beginDate = isset($artist['life-span']['begin']) ? $artist['life-span']['begin'] : null; $this->endDate = isset($artist['life-span']['ended']) ? $artist['life-span']['ended'] : null; }