/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $data = json_decode('{ "entry":{ "profileUrl":"http://nk.pl/profile/1", "gender":"male", "hasApp":true, "id":"person.abc", "age":31, "nkFriendsCount":57, "thumbnailUrl":"http://photos.nasza-klasa.pl/125/10/thumb/6646b702e7.jpeg", "name":{ "formatted":"Anna Kowalska (Nowak)", "additionalName":"Kowalska (Nowak)", "familyName":"Kowalska", "givenName":"Anna" }, "urls":[{"value":"http://nk.pl/profile/1","type":"profile"}], "photos":[ { "value":"http://photos.nasza-klasa.pl/125/10/thumb/6646b702e7.jpeg", "type":"thumbnail" }], "displayName":"Mr Sponge", "currentLocation":{ "region":"WrocLove" } } }', true); $this->object = new NKUser(); $this->object->assignData($data['entry']); }
private function people() { $args = func_get_args(); if (0 == count($args)) { throw new BadMethodCallException("Service 'people' require one or more person id as arguments"); } $ids = array(); foreach ($args as $user) { if (true === $user instanceof NKUser) { $ids[] = $user->id(); } else { $ids[] = $user; } } $fields = array('id', 'age', 'name', 'currentLocation', 'displayName', 'gender', 'photos', 'profileUrl', 'thumbnailUrl', 'urls'); if (in_array(NKPermissions::EMAIL_PROFILE, $this->getConfig()->permissions)) { $fields[] = 'emails'; } if (in_array(NKPermissions::BIRTHDAY_PROFILE, $this->getConfig()->permissions)) { $fields[] = 'birthday'; } if (in_array(NKPermissions::PHONE_PROFILE, $this->getConfig()->permissions)) { $fields[] = 'phoneNumbers'; } if (in_array(NKPermissions::PERSON_FRIENDS_COUNT, $this->getConfig()->permissions)) { $fields[] = 'nkFriendsCount'; } $data = $this->call('/people/' . implode(',', $ids), array('fields' => implode(',', $fields))); $result = array(); if (1 === count($data)) { $user = new NKUser(); $user->assignData($data['entry']); $result[$user->id()] = $user; } else { foreach ($data['entry'] as $row) { $user = new NKUser(); $user->assignData($row); $result[$user->id()] = $user; } } return $result; }