/** * Returns the name of an adapter class by $name. * * @param string $name * @param string $namespace * @throws Adapter\Exception * @return string */ protected static function getAdapterName($name) { $path = self::getFilePath(__NAMESPACE__ . '\\Adapter\\'); $scan = scandir($path); foreach ($scan as $node) { $file = Helper\String::factory($node)->toLower(); if ($file->startsWith($name) && $file->endsWith(".php")) { return __NAMESPACE__ . '\\Adapter\\' . str_replace(".php", "", $node); } } throw new Adapter\Exception("adapter '" . $name . "' does not exist"); }
/** * Returns the name of an adapter class by $name. * * @param string $name * @param string $namespace * @throws TeamSpeak3_Adapter_Exception * @return string */ protected static function getAdapterName($name, $namespace = "TeamSpeak3_Adapter_") { $path = self::getFilePath($namespace); $scan = scandir($path); foreach ($scan as $node) { $file = Helper\String::factory($node)->toLower(); if ($file->startsWith($name) && $file->endsWith(".php")) { return $namespace . str_replace(".php", "", $node); } } throw new Exception("adapter '" . $name . "' does not exist"); }
/** * Returns the applications host address. * * @return TeamSpeak3_Helper_String */ public static function getHostUri() { $sheme = self::getHostParam("HTTPS") == "on" ? "https" : "http"; $serverName = new Helper\String(self::getHostParam("HTTP_HOST")); $serverPort = self::getHostParam("SERVER_PORT"); $serverPort = $serverPort != 80 && $serverPort != 443 ? ":" . $serverPort : ""; if ($serverName->endsWith($serverPort)) { $serverName = $serverName->replace($serverPort, ""); } return new Helper\String($sheme . "://" . $serverName . $serverPort); }
/** * Prepares a custom error message by replacing pre-defined signs with given values. * * @param TeamSpeak3_Helper_String $mesg * @return TeamSpeak3_Helper_String */ protected function prepareCustomMessage(Helper\String $mesg) { $args = array("code" => $this->getCode(), "mesg" => $this->getMessage(), "line" => $this->getLine(), "file" => $this->getFile()); return $mesg->arg($args)->toString(); }