Skip to content

Commit

Permalink
Consistency and encoding cleanup
Browse files Browse the repository at this point in the history
As mentioned in issue #18 there's absolutely no need to have additional UTF-8 encoding, and thus should be removed.
If some encoding conversion should be done, the best way (assuming users have mbstring installed) would be using mb_convert_encoding($str, 'UTF-8', 'Windows-1252') which will properly convert extended latin variations.
  • Loading branch information
FrittenKeeZ committed Apr 30, 2014
1 parent eab0090 commit ff9f1b0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/HipChat/HipChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function __construct($auth_token, $api_target = self::DEFAULT_TARGET,
* @see http://api.hipchat.com/docs/api/method/rooms/show
*/
public function get_room($room_id) {
$response = $this->make_request("rooms/show", array(
$response = $this->make_request('rooms/show', array(
'room_id' => $room_id
));
return $response->room;
Expand Down Expand Up @@ -124,12 +124,12 @@ public function message_room($room_id, $from, $message, $notify = false,
$args = array(
'room_id' => $room_id,
'from' => $from,
'message' => utf8_encode($message),
'message' => $message,
'notify' => (int)$notify,
'color' => $color,
'message_format' => $message_format
);
$response = $this->make_request("rooms/message", $args, 'POST');
$response = $this->make_request('rooms/message', $args, 'POST');
return ($response->status == 'sent');
}

Expand All @@ -154,14 +154,14 @@ public function get_rooms_history($room_id, $date = 'recent') {
public function set_room_topic($room_id, $topic, $from = null) {
$args = array(
'room_id' => $room_id,
'topic' => utf8_encode($topic),
'topic' => $topic,
);

if ($from) {
$args['from'] = utf8_encode($from);
$args['from'] = $from;
}

$response = $this->make_request("rooms/topic", $args, 'POST');
$response = $this->make_request('rooms/topic', $args, 'POST');
return ($response->status == 'ok');
}

Expand All @@ -184,15 +184,15 @@ public function create_room($name, $owner_user_id = null, $privacy = null, $topi
}

if ($topic) {
$args['topic'] = utf8_encode($topic);
$args['topic'] = $topic;
}

if ($guest_access) {
$args['guest_access'] = (int) $guest_access;
$args['guest_access'] = (int)$guest_access;
}

// Return the std object
return $this->make_request("rooms/create", $args, 'POST');
return $this->make_request('rooms/create', $args, 'POST');
}

/**
Expand All @@ -205,7 +205,7 @@ public function delete_room($room_id){
'room_id' => $room_id
);

$response = $this->make_request("rooms/delete", $args, 'POST');
$response = $this->make_request('rooms/delete', $args, 'POST');

return ($response->deleted == 'true');
}
Expand All @@ -220,7 +220,7 @@ public function delete_room($room_id){
* @see http://api.hipchat.com/docs/api/method/users/show
*/
public function get_user($user_id) {
$response = $this->make_request("users/show", array(
$response = $this->make_request('users/show', array(
'user_id' => $user_id
));
return $response->user;
Expand Down Expand Up @@ -253,7 +253,7 @@ public function get_users() {
public function curl_request($url, $post_data = null) {

if (is_array($post_data)) {
$post_data = array_map(array($this, "sanitize_curl_parameter"), $post_data);
$post_data = array_map(array($this, 'sanitize_curl_parameter'), $post_data);
}

$ch = curl_init($url);
Expand Down Expand Up @@ -303,7 +303,7 @@ public function curl_request($url, $post_data = null) {
*/
private function sanitize_curl_parameter ($value) {

if ((strlen($value) > 0) && ($value[0] === "@")) {
if ((strlen($value) > 0) && ($value[0] === '@')) {
return substr_replace($value, '@', 0, 1);
}

Expand All @@ -329,7 +329,7 @@ public function make_request($api_method, $args = array(),

// add args to url for GET
if ($http_method == 'GET') {
$url .= '?'.http_build_query($args);
$url .= '?' . http_build_query($args);
} else {
$post_data = $args;
}
Expand Down

0 comments on commit ff9f1b0

Please sign in to comment.