Skip to content

Commit

Permalink
update to version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywhalecc committed Nov 3, 2020
1 parent 48d2922 commit b080f2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/ZM/ConnectionManager/ConnectionObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
class ConnectionObject
{
private $fd;
private $name;
private $options;
private $str_fd;

public function __construct($fd, $obj) {
public function __construct($fd) {
$this->fd = intval($fd);
$this->name = $obj["name"];
$this->options = $obj;
$this->str_fd = strval($fd);
}

/**
Expand All @@ -27,25 +25,25 @@ public function getFd(): int {
* @return mixed
*/
public function getName() {
return $this->name;
return SharedTable::$table->get($this->str_fd, 'name');
}

/**
* @return mixed
*/
public function getOptions() {
return $this->options;
return SharedTable::$table->get($this->str_fd);
}

public function getOption($key) {
return $this->options[$key] ?? null;
return $this->getOptions()[$key] ?? null;
}

public function setName(string $name) {
return SharedTable::$table->set(strval($this->fd), ['name' => $name]);
return SharedTable::$table->set($this->str_fd, ['name' => $name]);
}

public function setOption($key, $value) {
return SharedTable::$table->set(strval($this->fd), [$key => $value]);
return SharedTable::$table->set($this->str_fd, [$key => $value]);
}
}
4 changes: 2 additions & 2 deletions src/ZM/ConnectionManager/ManagerGM.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function setOption($fd, $key, $value)
public static function get($fd)
{
$r = SharedTable::$table->get(strval($fd));
return $r !== false ? new ConnectionObject($fd, $r) : null;
return $r !== false ? new ConnectionObject($fd) : null;
}

/**
Expand All @@ -72,7 +72,7 @@ public static function getAllByName($name = "default")
$obj = [];
foreach (SharedTable::$table as $k => $v) {
if ($v["name"] == $name) {
$obj[] = new ConnectionObject($k, $v);
$obj[] = new ConnectionObject($k);
}
}
return $obj;
Expand Down

0 comments on commit b080f2e

Please sign in to comment.