Skip to content

Instantly share code, notes, and snippets.

@phuedx
Created August 8, 2014 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phuedx/20969b90532d66642845 to your computer and use it in GitHub Desktop.
Save phuedx/20969b90532d66642845 to your computer and use it in GitHub Desktop.
If you're in any doubt, then write an API.
<?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