public function getChannelOrCreate($name, &$created) { $created = false; $chan = $this->getChannelByName($name); if (!$chan) { // Channel does not exist or has currently no active users (destructed) $ch = $this->db->getChannelInfo($name); if (!$ch) { // Channel does not exist, create it if (!$this->db->createChannel($name)) { return null; } $chan = new Channel($name, $this); $created = true; } else { // Channel exists but is destructed $chan = new Channel($ch['name'], $this); $chan->setTopic($ch['topic']); $chan->addMode($ch['modes']); $chan->setUserLimit($ch['userlimit']); $chan->setPassword($ch['password']); } $this->channels->attach($chan); } return $chan; }