Skip to content

Commit ac74117

Browse files
committed
simplify
1 parent 6ac918a commit ac74117

1 file changed

Lines changed: 14 additions & 26 deletions

File tree

src/DogStatsd.php

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ class DogStatsd
6363
* @var (callable(\Throwable, string))|null The closure which is executed when there is a failure flushing metrics.
6464
*/
6565
private $flushFailureHandler = null;
66-
/**
67-
* @var bool Whether the PHP Version of the app has the Throwable interface (>7.0))
68-
*/
69-
private $phpVersionHasThrowableInterface = false;
7066

7167
// Telemetry
7268
private $disable_telemetry;
@@ -195,8 +191,6 @@ public function __construct(array $config = array())
195191
$this->flushFailureHandler = isset($config['flush_failure_handler'])
196192
? $config['flush_failure_handler']
197193
: null;
198-
199-
$this->phpVersionHasThrowableInterface = version_compare(PHP_VERSION, '7.0.0', '>=');
200194
}
201195

202196
/**
@@ -667,27 +661,21 @@ public function flush($message)
667661
{
668662
$message .= $this->flushTelemetry();
669663

670-
if ($this->phpVersionHasThrowableInterface) {
671-
try {
672-
$res = $this->writeToSocket($message);
673-
} catch (\Throwable $e) {
674-
if ($this->flushFailureHandler === null) {
675-
throw $e;
676-
} else {
677-
call_user_func($this->flushFailureHandler, $e, $message);
678-
$res = false;
679-
}
664+
try {
665+
$res = $this->writeToSocket($message);
666+
} catch (\Throwable $e) {
667+
if ($this->flushFailureHandler === null) {
668+
throw $e;
669+
} else {
670+
call_user_func($this->flushFailureHandler, $e, $message);
671+
$res = false;
680672
}
681-
} else {
682-
try {
683-
$res = $this->writeToSocket($message);
684-
} catch (Exception $e) {
685-
if ($this->flushFailureHandler === null) {
686-
throw $e;
687-
} else {
688-
call_user_func($this->flushFailureHandler, $e, $message);
689-
$res = false;
690-
}
673+
} catch (Exception $e) {
674+
if ($this->flushFailureHandler === null) {
675+
throw $e;
676+
} else {
677+
call_user_func($this->flushFailureHandler, $e, $message);
678+
$res = false;
691679
}
692680
}
693681

0 commit comments

Comments
 (0)