diff --git a/src/Slave.php b/src/Slave.php index 2f9f058..762783c 100644 --- a/src/Slave.php +++ b/src/Slave.php @@ -29,12 +29,11 @@ public function status() { } else { try { $sss = $this->connection()->query('SHOW SLAVE STATUS')->fetch(); - if ($sss['Slave_IO_Running'] === 'No' || $sss['Slave_SQL_Running'] === 'No') { - // slave is STOPPED - return $this->setSlaveStatus(false, null); - } else { - return $this->setSlaveStatus(true, $sss['Seconds_Behind_Master']); - } + + return $sss['Slave_IO_Running'] === 'No' || $sss['Slave_SQL_Running'] === 'No' + ? $this->setSlaveStatus(false, null) + : $this->setSlaveStatus(true, $sss['Seconds_Behind_Master']); + } catch (\Exception $e) { if (stripos($e->getMessage(), 'Access denied') !== false) { return $this->setSlaveStatus(true, 0); @@ -48,4 +47,4 @@ public function disable() { $this->weight = 0; $this->connection = null; } -} \ No newline at end of file +}