Skip to content

Instantly share code, notes, and snippets.

@trovster
Forked from dannewns/gist:d2408b433ff2371af1f8
Created January 9, 2015 18:20
Show Gist options
  • Save trovster/e0fcbb8fb9caa37223d3 to your computer and use it in GitHub Desktop.
Save trovster/e0fcbb8fb9caa37223d3 to your computer and use it in GitHub Desktop.
#I currently have this method that returns a list of reads from a cube.
/**
* returns the current reads for the device id passed to it
* @param string $device_id the device uid to use
* @return array the device current reads from the API
*/
public function getDeviceCurrentReads($device_id = NULL, $filter = false)
{
if (is_null($device_id)) return NULL;
$reads = $this->get('devices/' . $device_id . '/current');
if ($this->isReturnValid($reads)) {
unset($reads['ok']);
return $this->formatReadResults($reads, $filter);
} else
return NULL;
}
/* now id like to create a method that allows users to just return say the humidity for a cube as i think it might be useful to retriev
one thing so ive written another one where I pass in a device id run the method above and then filter the results
does this seem right to you or should the method just accept the results and then filter so they user would have to run
get current reads and then pass them into another call?
The reason I ask this is because then the method only has one responsibility and thats to filter the results it doenst need to worry about
calling the above method first then filtering.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment