Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit 210f630

Browse files
committed
PEAR formatting
1 parent 906f717 commit 210f630

File tree

2 files changed

+82
-70
lines changed

2 files changed

+82
-70
lines changed

src/BatchedDogStatsd.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class BatchedDogStatsd extends DogStatsd
2121

2222
public function __construct(array $config = array())
2323
{
24-
# by default the telemetry is enabled for BatchedDogStatsd
24+
// by default the telemetry is enabled for BatchedDogStatsd
2525
if (!isset($config["disable_telemetry"])) {
2626
$config["disable_telemetry"] = false;
2727
}

src/DogStatsd.php

+81-69
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ public function __construct(array $config = array())
108108
$this->submitEventsOver = 'TCP';
109109
}
110110

111-
# by default the telemetry is disable
111+
// by default the telemetry is disable
112112
$this->disable_telemetry = isset($config["disable_telemetry"]) ? $config["disable_telemetry"] : true;
113113
$transport_type = !is_null($this->socketPath) ? "uds" : "udp";
114-
$this->telemetry_tags = $this->serializeTags(array(
114+
$this->telemetry_tags = $this->serializeTags(
115+
array(
115116
"client" => "php",
116117
"client_version" => self::$version,
117-
"client_transport" => $transport_type));
118+
"client_transport" => $transport_type)
119+
);
118120

119121
$this->resetTelemetry();
120122
}
@@ -153,10 +155,10 @@ private function flushTelemetry()
153155
/**
154156
* Log timing information
155157
*
156-
* @param string $stat The metric to in log timing info for.
157-
* @param float $time The elapsed time (ms) to log
158-
* @param float $sampleRate the rate (0-1) for sampling.
159-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
158+
* @param string $stat The metric to in log timing info for.
159+
* @param float $time The elapsed time (ms) to log
160+
* @param float $sampleRate the rate (0-1) for sampling.
161+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
160162
* @return void
161163
*/
162164
public function timing($stat, $time, $sampleRate = 1.0, $tags = null)
@@ -168,10 +170,10 @@ public function timing($stat, $time, $sampleRate = 1.0, $tags = null)
168170
/**
169171
* A convenient alias for the timing function when used with micro-timing
170172
*
171-
* @param string $stat The metric name
172-
* @param float $time The elapsed time to log, IN SECONDS
173-
* @param float $sampleRate the rate (0-1) for sampling.
174-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
173+
* @param string $stat The metric name
174+
* @param float $time The elapsed time to log, IN SECONDS
175+
* @param float $sampleRate the rate (0-1) for sampling.
176+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
175177
* @return void
176178
**/
177179
public function microtiming($stat, $time, $sampleRate = 1.0, $tags = null)
@@ -182,10 +184,10 @@ public function microtiming($stat, $time, $sampleRate = 1.0, $tags = null)
182184
/**
183185
* Gauge
184186
*
185-
* @param string $stat The metric
186-
* @param float $value The value
187-
* @param float $sampleRate the rate (0-1) for sampling.
188-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
187+
* @param string $stat The metric
188+
* @param float $value The value
189+
* @param float $sampleRate the rate (0-1) for sampling.
190+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
189191
* @return void
190192
**/
191193
public function gauge($stat, $value, $sampleRate = 1.0, $tags = null)
@@ -197,10 +199,10 @@ public function gauge($stat, $value, $sampleRate = 1.0, $tags = null)
197199
/**
198200
* Histogram
199201
*
200-
* @param string $stat The metric
201-
* @param float $value The value
202-
* @param float $sampleRate the rate (0-1) for sampling.
203-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
202+
* @param string $stat The metric
203+
* @param float $value The value
204+
* @param float $sampleRate the rate (0-1) for sampling.
205+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
204206
* @return void
205207
**/
206208
public function histogram($stat, $value, $sampleRate = 1.0, $tags = null)
@@ -212,10 +214,10 @@ public function histogram($stat, $value, $sampleRate = 1.0, $tags = null)
212214
/**
213215
* Distribution
214216
*
215-
* @param string $stat The metric
216-
* @param float $value The value
217-
* @param float $sampleRate the rate (0-1) for sampling.
218-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
217+
* @param string $stat The metric
218+
* @param float $value The value
219+
* @param float $sampleRate the rate (0-1) for sampling.
220+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
219221
* @return void
220222
**/
221223
public function distribution($stat, $value, $sampleRate = 1.0, $tags = null)
@@ -227,10 +229,10 @@ public function distribution($stat, $value, $sampleRate = 1.0, $tags = null)
227229
/**
228230
* Set
229231
*
230-
* @param string $stat The metric
231-
* @param float $value The value
232-
* @param float $sampleRate the rate (0-1) for sampling.
233-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
232+
* @param string $stat The metric
233+
* @param float $value The value
234+
* @param float $sampleRate the rate (0-1) for sampling.
235+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
234236
* @return void
235237
**/
236238
public function set($stat, $value, $sampleRate = 1.0, $tags = null)
@@ -243,10 +245,10 @@ public function set($stat, $value, $sampleRate = 1.0, $tags = null)
243245
/**
244246
* Increments one or more stats counters
245247
*
246-
* @param string|array $stats The metric(s) to increment.
247-
* @param float $sampleRate the rate (0-1) for sampling.
248-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
249-
* @param int $value the amount to increment by (default 1)
248+
* @param string|array $stats The metric(s) to increment.
249+
* @param float $sampleRate the rate (0-1) for sampling.
250+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
251+
* @param int $value the amount to increment by (default 1)
250252
* @return void
251253
**/
252254
public function increment($stats, $sampleRate = 1.0, $tags = null, $value = 1)
@@ -257,10 +259,10 @@ public function increment($stats, $sampleRate = 1.0, $tags = null, $value = 1)
257259
/**
258260
* Decrements one or more stats counters.
259261
*
260-
* @param string|array $stats The metric(s) to decrement.
261-
* @param float $sampleRate the rate (0-1) for sampling.
262-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
263-
* @param int $value the amount to decrement by (default -1)
262+
* @param string|array $stats The metric(s) to decrement.
263+
* @param float $sampleRate the rate (0-1) for sampling.
264+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
265+
* @param int $value the amount to decrement by (default -1)
264266
* @return void
265267
**/
266268
public function decrement($stats, $sampleRate = 1.0, $tags = null, $value = -1)
@@ -274,10 +276,10 @@ public function decrement($stats, $sampleRate = 1.0, $tags = null, $value = -1)
274276
/**
275277
* Updates one or more stats counters by arbitrary amounts.
276278
*
277-
* @param string|array $stats The metric(s) to update. Should be either a string or array of metrics.
278-
* @param int $delta The amount to increment/decrement each metric by.
279-
* @param float $sampleRate the rate (0-1) for sampling.
280-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
279+
* @param string|array $stats The metric(s) to update. Should be either a string or array of metrics.
280+
* @param int $delta The amount to increment/decrement each metric by.
281+
* @param float $sampleRate the rate (0-1) for sampling.
282+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
281283
* @return void
282284
**/
283285
public function updateStats($stats, $delta = 1, $sampleRate = 1.0, $tags = null)
@@ -296,7 +298,7 @@ public function updateStats($stats, $delta = 1, $sampleRate = 1.0, $tags = null)
296298
/**
297299
* Serialize tags to StatsD protocol
298300
*
299-
* @param string|array $tags The tags to be serialize
301+
* @param string|array $tags The tags to be serialize
300302
* @return string
301303
**/
302304
private function serializeTags($tags)
@@ -323,7 +325,7 @@ private function serializeTags($tags)
323325
/**
324326
* Turns tags in any format into an array of tags
325327
*
326-
* @param mixed $tags The tags to normalize
328+
* @param mixed $tags The tags to normalize
327329
* @return array
328330
*/
329331
private function normalizeTags($tags)
@@ -358,9 +360,10 @@ private function normalizeTags($tags)
358360

359361
/**
360362
* Squirt the metrics over UDP
361-
* @param array $data Incoming Data
362-
* @param float $sampleRate the rate (0-1) for sampling.
363-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
363+
*
364+
* @param array $data Incoming Data
365+
* @param float $sampleRate the rate (0-1) for sampling.
366+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
364367
* @return void
365368
**/
366369
public function send($data, $sampleRate = 1.0, $tags = null)
@@ -392,13 +395,13 @@ public function send($data, $sampleRate = 1.0, $tags = null)
392395
* @deprecated service_check will be removed in future versions in favor of serviceCheck
393396
*
394397
* Send a custom service check status over UDP
395-
* @param string $name service check name
396-
* @param int $status service check status code (see OK, WARNING,...)
397-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
398-
* @param string $hostname hostname to associate with this service check status
399-
* @param string $message message to associate with this service check status
400-
* @param int $timestamp timestamp for the service check status (defaults to now)
401-
* @return void
398+
* @param string $name service check name
399+
* @param int $status service check status code (see OK, WARNING,...)
400+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
401+
* @param string $hostname hostname to associate with this service check status
402+
* @param string $message message to associate with this service check status
403+
* @param int $timestamp timestamp for the service check status (defaults to now)
404+
* @return void
402405
**/
403406
public function service_check( // phpcs:ignore
404407
$name,
@@ -413,12 +416,13 @@ public function service_check( // phpcs:ignore
413416

414417
/**
415418
* Send a custom service check status over UDP
416-
* @param string $name service check name
417-
* @param int $status service check status code (see OK, WARNING,...)
418-
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
419-
* @param string $hostname hostname to associate with this service check status
420-
* @param string $message message to associate with this service check status
421-
* @param int $timestamp timestamp for the service check status (defaults to now)
419+
*
420+
* @param string $name service check name
421+
* @param int $status service check status code (see OK, WARNING,...)
422+
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
423+
* @param string $hostname hostname to associate with this service check status
424+
* @param string $message message to associate with this service check status
425+
* @param int $timestamp timestamp for the service check status (defaults to now)
422426
* @return void
423427
**/
424428
public function serviceCheck(
@@ -488,9 +492,10 @@ public function flush($message)
488492
* making many call in a row if you don't want to stall your app.
489493
* Requires PHP >= 5.3.0
490494
*
491-
* @param string $title Title of the event
492-
* @param array $vals Optional values of the event. See
493-
* https://docs.datadoghq.com/api/?lang=bash#post-an-event for the valid keys
495+
* @param string $title Title of the event
496+
* @param array $vals Optional values of the event. See
497+
* https://docs.datadoghq.com/api/?lang=bash#post-an-event
498+
* for the valid keys
494499
* @return null
495500
**/
496501
public function event($title, $vals = array())
@@ -500,7 +505,7 @@ public function event($title, $vals = array())
500505
$vals['title'] = $title;
501506

502507
// If sending events via UDP
503-
if ($this->submitEventsOver === 'UDP') { # FIX
508+
if ($this->submitEventsOver === 'UDP') { // FIX
504509
return $this->eventUdp($vals);
505510
}
506511

@@ -541,8 +546,10 @@ public function event($title, $vals = array())
541546

542547
// Check response code is 202
543548
if ($response_code !== 200 && $response_code !== 202) {
544-
throw new \Exception('Datadog event API call HTTP response not OK - '
545-
. $response_code . '; response body: ' . $response_body);
549+
throw new \Exception(
550+
'Datadog event API call HTTP response not OK - '
551+
. $response_code . '; response body: ' . $response_body
552+
);
546553
}
547554

548555
// Check for empty response body
@@ -552,14 +559,18 @@ public function event($title, $vals = array())
552559

553560
// Decode JSON response
554561
if (!$decodedJson = json_decode($response_body, true)) {
555-
throw new \Exception('Datadog event API call did not return a body'
556-
. ' that could be decoded via json_decode');
562+
throw new \Exception(
563+
'Datadog event API call did not return a body'
564+
. ' that could be decoded via json_decode'
565+
);
557566
}
558567

559568
// Check JSON decoded "status" is OK from the Datadog API
560569
if ($decodedJson['status'] !== 'ok') {
561-
throw new \Exception('Datadog event API response status not "ok"; response body: '
562-
. $response_body);
570+
throw new \Exception(
571+
'Datadog event API response status not "ok"; response body: '
572+
. $response_body
573+
);
563574
}
564575
} catch (\Exception $e) {
565576
$success = false;
@@ -574,8 +585,9 @@ public function event($title, $vals = array())
574585

575586
/**
576587
* Formats $vals array into event for submission to Datadog via UDP
577-
* @param array $vals Optional values of the event. See
578-
* https://docs.datadoghq.com/api/?lang=bash#post-an-event for the valid keys
588+
*
589+
* @param array $vals Optional values of the event. See
590+
* https://docs.datadoghq.com/api/?lang=bash#post-an-event for the valid keys
579591
* @return null
580592
*/
581593
private function eventUdp($vals)

0 commit comments

Comments
 (0)