Created
August 8, 2014 14:50
-
-
Save phuedx/20969b90532d66642845 to your computer and use it in GitHub Desktop.
If you're in any doubt, then write an API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_instance_of( $item ) { | |
return "CLAIM[31:{$item}]"; | |
} | |
function is_instance_of_band() { | |
return is_instance_of( '215380' ); | |
} | |
function has_musicbrainz_artist_id() { | |
return "CLAIM[434]"; | |
} | |
function notº( $claim ) { | |
return "NO{$claim}"; | |
} | |
function andº( /* .... */ ) { | |
$args = func_get_args(); | |
return join( ' AND ', $args ); | |
} | |
function execute( $query ) { | |
// That's close enough. | |
echo sprintf( "http://wdq.wmflabs.org/api?q={%s}\n", urlencode( $query ) ); | |
} | |
execute( andº( is_instance_of_band(), notº( has_musicbrainz_artist_id() ) ) ); | |
// => http://wdq.wmflabs.org/api?q=CLAIM%5B31%3A215380%5D+AND+NOCLAIM%5B434%5D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment