public function __toString() { $output = new MString(); $output->append("<html><body>"); $output->append("<h1>Methods definitions</h1>"); foreach ($this->methodDefinitionList as $methodDefinition) { $output->append("<h2>" . $methodDefinition["name"] . "</h2>"); $output->append("<pre>" . $methodDefinition["definition"] . "</pre>"); $output->append("<h3>Request example</h3>"); $output->append("<pre>" . '{"jsonrpc": "2.0", "method": "' . $methodDefinition["name"] . '", "params": {"name_1": value_1, "name_2": value_2, ...}, "id": 3}' . "</pre>"); } $output->append("</body></html>"); return (string) $output; }
public function addJavascript($src) { if (MString::isNullOrEmpty($src) === false) { $this->javascript[] = array("src" => $src); } }
/** * Returns the user info of the URL, or an empty string if the user info is * undefined. * * @return string|null */ public function getUserInfo() { return (MString::isNullOrEmpty($this->user) ? MString::EMPTY_STRING : $this->user) . (MString::isNullOrEmpty($this->password) ? MString::EMPTY_STRING : ':' . $this->password); }
/** * Validate the <i>$route</i>.<br> * If the route has some invalida data, an exception will be throw.<br> * The class name, the type and the role must not be null or empty.<br> * If the type is equal to MRouteType::CONTROLLER, the method property must not be null or empty.<br> * * @param MRoute $route * @throws MInvalidClassNameException * @throws MInvalidMethodNameException * @throws MInvalidRoleException * @throws MInvalidRouteTypeException */ private function validateRoute(MRoute $route) { if (MString::isNullOrEmpty($route->getType())) { throw new MInvalidRouteTypeException(); } if (MString::isNullOrEmpty($route->getClass())) { throw new MInvalidClassNameException(); } if ($route->getType() != MRouteType::CONTROLLER && MString::isNullOrEmpty($route->getMethod())) { throw new MInvalidMethodNameException(); } if (MString::isNullOrEmpty($route->getRole())) { throw new MInvalidRoleException(); } }