src/Dcarrith/LxMPD/LxMPD.php
public function reportOnMissingTags( $command, $tracks ) {

		// getEssentialTags combines the essential ID3 as well as MPD-specific tags
		$essentialTags = $this->getEssentialTags();

		// Loop through the tracks array so we can replace each track with a simple array of missing tags
		$incompleteTracks = array_filter( array_map( function( $track ) use ( $essentialTags ) {

			// Flip the essential tags array so the values are keys.
			// Take the diff_key of that and $track so we're left with only tags that are in the essentialTags array, but not in $track.
			// Flip the result of that back around so the keys are values again.
			$missingTags = array_flip( array_diff_key( array_flip( $essentialTags ), $track ));

			// If there are missing tags, then return the array element using the MPD track Id as the key so we can retrieve more info later.
			return (count($missingTags) ? (array($track['Id'] => $missingTags)) : array());

		}, $tracks), function( $missing ) {

			// Filter out any empty arrays so we're only left with the arrays of the incomplete tracks
			return (count($missing));
		});

		// If we have any tracks that are missing essential tags, then throw an exception to alert the user
		if( count($incompleteTracks) ) {

			$detailedMessage = "";

			// Loop through the incomplete tracks so we can retrieve more info about each track and build the exception message
			foreach( $incompleteTracks as $incompleteTrack ) {

				// Get the id from the incompleteTrack array
				$id = key($incompleteTrack);

				// Retrieve more information about the track that's missing tags
				$track = $this->playlistid( $id );

				// Get the name of the artist
				$artist = $track['Artist'];

				// Get the name of the album
				$album = $track['Album'];

				// Complile a detailed message about the track
				$detailedMessage .= "Track #".$id." from the artist '".$artist.",' specifically, the album '".$album."', is missing tag".((count($incompleteTrack) > 1) ? "s: " : ": ").implode( ", ", current($incompleteTrack) ).".  ";
			}

			// There must be some essential tags missing from one or more tracks in the playlist
			throw new MPDException( 'The command "'.$command.'" has retrieved some tracks that are missing essential tag elements.  Please clean up any deficient id3 tags and try again.  The essentials tags are as follows: '.implode(", ", $essentialID3Tags).'.  Details: '.$detailedMessage, self::ESSENTIAL_TAGS_MISSING );
		}
	}
public function reportOnMissingTags( $command, $tracks ) {

		// getEssentialTags combines the essential ID3 as well as MPD-specific tags
		$essentialTags = $this->getEssentialTags();

		// Loop through the tracks array so we can replace each track with a simple array of missing tags
		$incompleteTracks = array_filter( array_map( function( $track ) use ( $essentialTags ) {

			// Flip the essential tags array so the values are keys.
			// Take the diff_key of that and $track so we're left with only tags that are in the essentialTags array, but not in $track.
			// Flip the result of that back around so the keys are values again.
			$missingTags = array_flip( array_diff_key( array_flip( $essentialTags ), $track ));

			// If there are missing tags, then return the array element using the MPD track Id as the key so we can retrieve more info later.
			return (count($missingTags) ? (array($track['Id'] => $missingTags)) : array());

		}, $tracks), function( $missing ) {

			// Filter out any empty arrays so we're only left with the arrays of the incomplete tracks
			return (count($missing));
		});

		// If we have any tracks that are missing essential tags, then throw an exception to alert the user
		if( count($incompleteTracks) ) {

			$detailedMessage = "";

			// Loop through the incomplete tracks so we can retrieve more info about each track and build the exception message
			foreach( $incompleteTracks as $incompleteTrack ) {

				// Get the id from the incompleteTrack array
				$id = key($incompleteTrack);

				// Retrieve more information about the track that's missing tags
				$track = $this->playlistid( $id );

				// Get the name of the artist
				$artist = $track['Artist'];

				// Get the name of the album
				$album = $track['Album'];

				// Complile a detailed message about the track
				$detailedMessage .= "Track #".$id." from the artist '".$artist.",' specifically, the album '".$album."', is missing tag".((count($incompleteTrack) > 1) ? "s: " : ": ").implode( ", ", current($incompleteTrack) ).".  ";
			}

			// There must be some essential tags missing from one or more tracks in the playlist
			throw new MPDException( 'The command "'.$command.'" has retrieved some tracks that are missing essential tag elements.  Please clean up any deficient id3 tags and try again.  The essentials tags are as follows: '.implode(", ", $essentialID3Tags).'.  Details: '.$detailedMessage, self::ESSENTIAL_TAGS_MISSING );
		}
	}
public function reportOnMissingTags ( $ command , $ tracks ) { // getEssentialTags combines the essential ID3 as well as MPD-specific tags $ essentialTags = $ this -> getEssentialTags ( ) ; // Loop through the tracks array so we can replace each track with a simple array of missing tags $ incompleteTracks = array_filter ( array_map ( function ( $ track ) use ( $ essentialTags ) { // Flip the essential tags array so the values are keys. // Take the diff_key of that and $track so we're left with only tags that are in the essentialTags array, but not in $track. // Flip the result of that back around so the keys are values again. $ missingTags = array_flip ( array_diff_key ( array_flip ( $ essentialTags ) , $ track ) ) ; // If there are missing tags, then return the array element using the MPD track Id as the key so we can retrieve more info later. return ( count ( $ missingTags ) ? ( array ( $ track [ 'Id' ] => $ missingTags ) ) : array ( ) ) ; } , $ tracks ) , function ( $ missing ) { // Filter out any empty arrays so we're only left with the arrays of the incomplete tracks return ( count ( $ missing ) ) ; } ) ; // If we have any tracks that are missing essential tags, then throw an exception to alert the user if ( count ( $ incompleteTracks ) ) { $ detailedMessage = "" ; // Loop through the incomplete tracks so we can retrieve more info about each track and build the exception message foreach ( $ incompleteTracks as $ incompleteTrack ) { // Get the id from the incompleteTrack array $ id = key ( $ incompleteTrack ) ; // Retrieve more information about the track that's missing tags $ track = $ this -> playlistid ( $ id ) ; // Get the name of the artist $ artist = $ track [ 'Artist' ] ; // Get the name of the album $ album = $ track [ 'Album' ] ; // Complile a detailed message about the track $ detailedMessage .= "Track #" . $ id . " from the artist '" . $ artist . ",' specifically, the album '" . $ album . "', is missing tag" . ( ( count ( $ incompleteTrack ) > 1 ) ? "s: " : ": " ) . implode ( ", " , current ( $ incompleteTrack ) ) . ".  " ; } // There must be some essential tags missing from one or more tracks in the playlist throw new MPDException ( 'The command "' . $ command . '" has retrieved some tracks that are missing essential tag elements.  Please clean up any deficient id3 tags and try again.  The essentials tags are as follows: ' . implode ( ", " , $ essentialID3Tags ) . '.  Details: ' . $ detailedMessage , self :: ESSENTIAL_TAGS_MISSING ) ; } }
reportOnMissingTags will find any tracks that are missing essentials tags and throws an exception
that contains enough information to track down the missing tags so the user can fill them in
with the id3 editor of their choice
@param string $command is the command that was run which we want to pass through to the exception message
@param array $tracks is the array of tracks to loop through
@throws MPDException
@return void
reportOnMissingTags will find any tracks that are missing essentials tags and throws an exception that contains enough information to track down the missing tags so the user can fill them in with the id3 editor of their choice