You are here

public function InstagramUser::__construct in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.lib.php \InstagramUser::__construct()

Constructor for InstagramUser

File

./drupagram.lib.php, line 587
Classes to implement the full Instagram API

Class

InstagramUser
Class for containing an individual Instagram user.

Code

public function __construct($values = array()) {
  if (!isset($values) || empty($values)) {
    return FALSE;
  }
  if (!is_array($values)) {
    $values = (array) $values;
  }
  $values = array_filter($values);
  foreach ($values as $key => $value) {
    switch ($key) {
      case 'counts':
        if (is_array($values['counts']) && !empty($values['counts'])) {
          $this->media_count = isset($values['counts']['media']) ? (int) $values['counts']['media'] : 0;
          $this->follows_count = isset($values['counts']['follows']) ? (int) $values['counts']['follows'] : 0;
          $this->followed_by_count = isset($values['counts']['followed_by']) ? (int) $values['counts']['followed_by'] : 0;
        }
        break;
      default:
        $this->{$key} = $value;
        break;
    }
  }
}