Skip to content

Instantly share code, notes, and snippets.

@killerwolf
Created August 7, 2015 19:39
Show Gist options
  • Save killerwolf/eb3e5132136b83a613ae to your computer and use it in GitHub Desktop.
Save killerwolf/eb3e5132136b83a613ae to your computer and use it in GitHub Desktop.
S.O.L.I.D for Dummies
<?php
class APICall{
const API_ENDPOINT = "http://api.example.org/v1/en/users.json";
public $query = [];
public function buildQuery(array $query)
{
return http_build_query($query);
}
public function setQuery()
{
$this->query = $query;
}
public function getData(){
return json_decode(file_get_contents(sprintf('%s?%s',API_ENDPOINT,$this->buildQuery($query))));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment