Skip to content

Commit

Permalink
Correctly throw exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacioxd committed Apr 11, 2017
1 parent 906a0a9 commit 0e24fa9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/PupilRemote.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PupilRemote {

public function __construct() {
if(!class_exists('ZMQSocket')) {
throw new Exception("The ZeroMQ extension must be installed");
throw new \Exception("The ZeroMQ extension must be installed");
}
}

Expand All @@ -24,46 +24,46 @@ public function connect($host = "127.0.0.1", $port = 50020, $socketName = "PHPZM

public function getTimebase() {
if(!$this->isConnected) {
throw new Exception("Socket not connected");
throw new \Exception("Socket not connected");
}
$time = $this->socket->send("t")->recv();
return $time;
}

public function setTimebase(float $base) {
if(!$this->isConnected) {
throw new Exception("Socket not connected");
throw new \Exception("Socket not connected");
}
$this->socket->send("T {$base}")->recv();
}

public function startCalibration() {
if(!$this->isConnected) {
throw new Exception("Socket not connected");
throw new \Exception("Socket not connected");
}
$result = $this->socket->send("C")->recv();
return $result === "OK";
}

public function stopCalibration() {
if(!$this->isConnected) {
throw new Exception("Socket not connected");
throw new \Exception("Socket not connected");
}
$result = $this->socket->send("c")->recv();
return $result === "OK";
}

public function startRecording($recordingName = null) {
if(!$this->isConnected) {
throw new Exception("Socket not connected");
throw new \Exception("Socket not connected");
}
$result = $this->socket->send("R" . ($recordingName !== null ? " {$recordingName}" : ""))->recv();
return $result === "OK";
}

public function stopRecording() {
if(!$this->isConnected) {
throw new Exception("Socket not connected");
throw new \Exception("Socket not connected");
}
$result = $this->socket->send("r")->recv();
return $result === "OK";
Expand Down

0 comments on commit 0e24fa9

Please sign in to comment.