/** * Creates a channel if it does not exist and returns it. * If channel exists it is just returned. * * @param string $channelName * * @return WiseChatChannel */ public function createAndGetChannel($channelName) { $channel = $this->channelsDAO->getByName($channelName); if ($channel === null) { $channel = new WiseChatChannel(); $channel->setName($channelName); $this->channelsDAO->save($channel); } return $channel; }
/** * Converts raw object into WiseChatChannel object. * * @param stdClass $rawChannelData * * @return WiseChatChannel */ private function populateChannelData($rawChannelData) { $channel = new WiseChatChannel(); if ($rawChannelData->id > 0) { $channel->setId(intval($rawChannelData->id)); } $channel->setName($rawChannelData->name); $channel->setPassword($rawChannelData->password); return $channel; }