repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
matyhtf/framework | libs/Swoole/Request.php | Request.getClientIP | function getClientIP()
{
if (isset($this->server["HTTP_X_REAL_IP"]) and strcasecmp($this->server["HTTP_X_REAL_IP"], "unknown"))
{
return $this->server["HTTP_X_REAL_IP"];
}
if (isset($this->server["HTTP_CLIENT_IP"]) and strcasecmp($this->server["HTTP_CLIENT_IP"], "unknown"... | php | function getClientIP()
{
if (isset($this->server["HTTP_X_REAL_IP"]) and strcasecmp($this->server["HTTP_X_REAL_IP"], "unknown"))
{
return $this->server["HTTP_X_REAL_IP"];
}
if (isset($this->server["HTTP_CLIENT_IP"]) and strcasecmp($this->server["HTTP_CLIENT_IP"], "unknown"... | [
"function",
"getClientIP",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"\"HTTP_X_REAL_IP\"",
"]",
")",
"and",
"strcasecmp",
"(",
"$",
"this",
"->",
"server",
"[",
"\"HTTP_X_REAL_IP\"",
"]",
",",
"\"unknown\"",
")",
")",
"{",... | 获取客户端IP
@return string | [
"获取客户端IP"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Request.php#L119-L138 |
matyhtf/framework | libs/Swoole/Request.php | Request.getBrowser | function getBrowser()
{
$sys = $this->server['HTTP_USER_AGENT'];
if (stripos($sys, "Firefox/") > 0)
{
preg_match("/Firefox\/([^;)]+)+/i", $sys, $b);
$exp[0] = "Firefox";
$exp[1] = $b[1];
}
elseif (stripos($sys, "Maxthon") > 0)
{
... | php | function getBrowser()
{
$sys = $this->server['HTTP_USER_AGENT'];
if (stripos($sys, "Firefox/") > 0)
{
preg_match("/Firefox\/([^;)]+)+/i", $sys, $b);
$exp[0] = "Firefox";
$exp[1] = $b[1];
}
elseif (stripos($sys, "Maxthon") > 0)
{
... | [
"function",
"getBrowser",
"(",
")",
"{",
"$",
"sys",
"=",
"$",
"this",
"->",
"server",
"[",
"'HTTP_USER_AGENT'",
"]",
";",
"if",
"(",
"stripos",
"(",
"$",
"sys",
",",
"\"Firefox/\"",
")",
">",
"0",
")",
"{",
"preg_match",
"(",
"\"/Firefox\\/([^;)]+)+/i\"... | 获取客户端浏览器信息
@return string | [
"获取客户端浏览器信息"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Request.php#L144-L196 |
matyhtf/framework | libs/Swoole/Request.php | Request.getOS | function getOS()
{
$agent = $this->server['HTTP_USER_AGENT'];
if (preg_match('/win/i', $agent) && strpos($agent, '95'))
{
$os = 'Windows 95';
}
elseif (preg_match('/win 9x/i', $agent) && strpos($agent, '4.90'))
{
$os = 'Windows ME';
}
... | php | function getOS()
{
$agent = $this->server['HTTP_USER_AGENT'];
if (preg_match('/win/i', $agent) && strpos($agent, '95'))
{
$os = 'Windows 95';
}
elseif (preg_match('/win 9x/i', $agent) && strpos($agent, '4.90'))
{
$os = 'Windows ME';
}
... | [
"function",
"getOS",
"(",
")",
"{",
"$",
"agent",
"=",
"$",
"this",
"->",
"server",
"[",
"'HTTP_USER_AGENT'",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/win/i'",
",",
"$",
"agent",
")",
"&&",
"strpos",
"(",
"$",
"agent",
",",
"'95'",
")",
")",
"{",... | 获取客户端操作系统信息
@return string | [
"获取客户端操作系统信息"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Request.php#L201-L322 |
matyhtf/framework | libs/Swoole/Client/Socket.php | Socket.set_error | protected function set_error()
{
$this->errCode = socket_last_error($this->sock);
$this->errMsg = socket_strerror($this->errCode);
socket_clear_error($this->sock);
} | php | protected function set_error()
{
$this->errCode = socket_last_error($this->sock);
$this->errMsg = socket_strerror($this->errCode);
socket_clear_error($this->sock);
} | [
"protected",
"function",
"set_error",
"(",
")",
"{",
"$",
"this",
"->",
"errCode",
"=",
"socket_last_error",
"(",
"$",
"this",
"->",
"sock",
")",
";",
"$",
"this",
"->",
"errMsg",
"=",
"socket_strerror",
"(",
"$",
"this",
"->",
"errCode",
")",
";",
"so... | 错误信息赋值 | [
"错误信息赋值"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/Socket.php#L46-L51 |
matyhtf/framework | libs/Swoole/Client/Socket.php | Socket.set_timeout | function set_timeout($timeout_recv, $timeout_send)
{
$_timeout_recv_sec = (int)$timeout_recv;
$_timeout_send_sec = (int)$timeout_send;
$this->timeout_recv = $timeout_recv;
$this->timeout_send = $timeout_send;
$_timeout_recv = array(
'sec' => $_timeout_recv_sec,
... | php | function set_timeout($timeout_recv, $timeout_send)
{
$_timeout_recv_sec = (int)$timeout_recv;
$_timeout_send_sec = (int)$timeout_send;
$this->timeout_recv = $timeout_recv;
$this->timeout_send = $timeout_send;
$_timeout_recv = array(
'sec' => $_timeout_recv_sec,
... | [
"function",
"set_timeout",
"(",
"$",
"timeout_recv",
",",
"$",
"timeout_send",
")",
"{",
"$",
"_timeout_recv_sec",
"=",
"(",
"int",
")",
"$",
"timeout_recv",
";",
"$",
"_timeout_send_sec",
"=",
"(",
"int",
")",
"$",
"timeout_send",
";",
"$",
"this",
"->",
... | 设置超时
@param float $recv_timeout 接收超时
@param float $send_timeout 发送超时 | [
"设置超时"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/Socket.php#L58-L77 |
matyhtf/framework | libs/Swoole/Client/Socket.php | Socket.set_bufsize | function set_bufsize($sendbuf_size, $recvbuf_size)
{
$this->setopt(SO_SNDBUF, $sendbuf_size);
$this->setopt(SO_RCVBUF, $recvbuf_size);
} | php | function set_bufsize($sendbuf_size, $recvbuf_size)
{
$this->setopt(SO_SNDBUF, $sendbuf_size);
$this->setopt(SO_RCVBUF, $recvbuf_size);
} | [
"function",
"set_bufsize",
"(",
"$",
"sendbuf_size",
",",
"$",
"recvbuf_size",
")",
"{",
"$",
"this",
"->",
"setopt",
"(",
"SO_SNDBUF",
",",
"$",
"sendbuf_size",
")",
";",
"$",
"this",
"->",
"setopt",
"(",
"SO_RCVBUF",
",",
"$",
"recvbuf_size",
")",
";",... | 设置buffer区
@param $sendbuf_size
@param $recvbuf_size | [
"设置buffer区"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/Socket.php#L105-L109 |
matyhtf/framework | libs/Swoole/Console.php | Console.changeUser | static function changeUser($user)
{
if (!function_exists('posix_getpwnam'))
{
trigger_error(__METHOD__ . ": require posix extension.");
return false;
}
$user = posix_getpwnam($user);
if ($user)
{
posix_setuid($user['uid']);
... | php | static function changeUser($user)
{
if (!function_exists('posix_getpwnam'))
{
trigger_error(__METHOD__ . ": require posix extension.");
return false;
}
$user = posix_getpwnam($user);
if ($user)
{
posix_setuid($user['uid']);
... | [
"static",
"function",
"changeUser",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'posix_getpwnam'",
")",
")",
"{",
"trigger_error",
"(",
"__METHOD__",
".",
"\": require posix extension.\"",
")",
";",
"return",
"false",
";",
"}",
"$",
... | 改变进程的用户ID
@param $user
@return bool | [
"改变进程的用户ID"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Console.php#L35-L54 |
matyhtf/framework | libs/Swoole/Console.php | Console.setProcessName | static function setProcessName($name)
{
if (function_exists('cli_set_process_title'))
{
@cli_set_process_title($name);
}
else
{
if (function_exists('swoole_set_process_name'))
{
@swoole_set_process_name($name);
}... | php | static function setProcessName($name)
{
if (function_exists('cli_set_process_title'))
{
@cli_set_process_title($name);
}
else
{
if (function_exists('swoole_set_process_name'))
{
@swoole_set_process_name($name);
}... | [
"static",
"function",
"setProcessName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'cli_set_process_title'",
")",
")",
"{",
"@",
"cli_set_process_title",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"if",
"(",
"function_exists",
"(",
... | 设置进程的名称
@param $name | [
"设置进程的名称"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Console.php#L60-L77 |
matyhtf/framework | libs/Swoole/Database/PdoDB.php | PdoDB.connect | function connect()
{
$db_config = &$this->config;
$dsn = $db_config['dbms'] . ":host=" . $db_config['host'] . ";dbname=" . $db_config['name'];
if (!empty($db_config['persistent']))
{
parent::__construct($dsn, $db_config['user'], $db_config['passwd'], array(\PDO::ATTR_PER... | php | function connect()
{
$db_config = &$this->config;
$dsn = $db_config['dbms'] . ":host=" . $db_config['host'] . ";dbname=" . $db_config['name'];
if (!empty($db_config['persistent']))
{
parent::__construct($dsn, $db_config['user'], $db_config['passwd'], array(\PDO::ATTR_PER... | [
"function",
"connect",
"(",
")",
"{",
"$",
"db_config",
"=",
"&",
"$",
"this",
"->",
"config",
";",
"$",
"dsn",
"=",
"$",
"db_config",
"[",
"'dbms'",
"]",
".",
"\":host=\"",
".",
"$",
"db_config",
"[",
"'host'",
"]",
".",
"\";dbname=\"",
".",
"$",
... | 连接到数据库 | [
"连接到数据库"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/PdoDB.php#L29-L47 |
matyhtf/framework | libs/Swoole/Database/PdoDB.php | PdoDB.query | public final function query($sql)
{
if ($this->debug)
{
echo "$sql<br />\n<hr />";
}
$res = parent::query($sql) or \Swoole\Error::info(
"SQL Error",
implode(", ", $this->errorInfo()) . "<hr />$sql"
);
$this->lastStatement = $res;
... | php | public final function query($sql)
{
if ($this->debug)
{
echo "$sql<br />\n<hr />";
}
$res = parent::query($sql) or \Swoole\Error::info(
"SQL Error",
implode(", ", $this->errorInfo()) . "<hr />$sql"
);
$this->lastStatement = $res;
... | [
"public",
"final",
"function",
"query",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"echo",
"\"$sql<br />\\n<hr />\"",
";",
"}",
"$",
"res",
"=",
"parent",
"::",
"query",
"(",
"$",
"sql",
")",
"or",
"\\",
"Swoole",
"... | 执行一个SQL语句
@param string $sql 执行的SQL语句
@return \PDOStatement | [
"执行一个SQL语句"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/PdoDB.php#L54-L71 |
matyhtf/framework | libs/Swoole/Database/PdoDB.php | PdoDB.queryLine | public final function queryLine($sql, $_)
{
$params = func_get_args();
if ($this->debug)
{
var_dump($params);
}
array_shift($params);
$stm = $this->prepare($sql);
if ($stm->execute($params))
{
$ret = $stm->fetch();
$... | php | public final function queryLine($sql, $_)
{
$params = func_get_args();
if ($this->debug)
{
var_dump($params);
}
array_shift($params);
$stm = $this->prepare($sql);
if ($stm->execute($params))
{
$ret = $stm->fetch();
$... | [
"public",
"final",
"function",
"queryLine",
"(",
"$",
"sql",
",",
"$",
"_",
")",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"var_dump",
"(",
"$",
"params",
")",
";",
"}",
"array_shift",... | 执行一个参数化SQL语句,并返回一行结果
@param string $sql 执行的SQL语句
@param mixed $_ [optional]
@return mixed | [
"执行一个参数化SQL语句",
"并返回一行结果"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/PdoDB.php#L79-L99 |
matyhtf/framework | libs/Swoole/Database/PdoDB.php | PdoDB.execute | public final function execute($sql, $_)
{
$params = func_get_args();
if ($this->debug)
{
var_dump($params);
}
array_shift($params);
$stm = $this->prepare($sql);
if ($stm->execute($params))
{
return $this->lastInsertId();
... | php | public final function execute($sql, $_)
{
$params = func_get_args();
if ($this->debug)
{
var_dump($params);
}
array_shift($params);
$stm = $this->prepare($sql);
if ($stm->execute($params))
{
return $this->lastInsertId();
... | [
"public",
"final",
"function",
"execute",
"(",
"$",
"sql",
",",
"$",
"_",
")",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"var_dump",
"(",
"$",
"params",
")",
";",
"}",
"array_shift",
... | 执行一个参数化SQL语句
@param string $sql 执行的SQL语句
@param mixed $_ [optional]
@return int last insert id | [
"执行一个参数化SQL语句"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/PdoDB.php#L135-L153 |
matyhtf/framework | libs/Swoole/Http/ExtServer.php | ExtServer.assign | function assign(Swoole\Request $request)
{
$_request = $this->getRequest();
if (!empty($_request->get))
{
$request->get = $_request->get;
}
if (!empty($_request->post))
{
$request->post = $_request->post;
}
if (!empty($_request-... | php | function assign(Swoole\Request $request)
{
$_request = $this->getRequest();
if (!empty($_request->get))
{
$request->get = $_request->get;
}
if (!empty($_request->post))
{
$request->post = $_request->post;
}
if (!empty($_request-... | [
"function",
"assign",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"_request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"_request",
"->",
"get",
")",
")",
"{",
"$",
"request",
"->",
... | 将swoole扩展产生的请求对象数据赋值给框架的Request对象
@param Swoole\Request $request | [
"将swoole扩展产生的请求对象数据赋值给框架的Request对象"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/ExtServer.php#L116-L145 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.set_path | function set_path($config_path)
{
if (!empty($config_path)) {
if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
$this->_trigger_error_msg("Bad config file path '$config_path'");
return;
}
if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
$config_path .= D... | php | function set_path($config_path)
{
if (!empty($config_path)) {
if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
$this->_trigger_error_msg("Bad config file path '$config_path'");
return;
}
if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
$config_path .= D... | [
"function",
"set_path",
"(",
"$",
"config_path",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"config_path",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"config_path",
")",
"||",
"!",
"file_exists",
"(",
"$",
"config_path",
")",
"||",
"!",
... | Set the path where configuration files can be found.
@param string $config_path path to the config files | [
"Set",
"the",
"path",
"where",
"configuration",
"files",
"can",
"be",
"found",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L84-L97 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.get | function get($file_name, $section_name = NULL, $var_name = NULL)
{
if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name');
return;
} else {
$file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name]))
$this->load_file($file_name, false);
}
if... | php | function get($file_name, $section_name = NULL, $var_name = NULL)
{
if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name');
return;
} else {
$file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name]))
$this->load_file($file_name, false);
}
if... | [
"function",
"get",
"(",
"$",
"file_name",
",",
"$",
"section_name",
"=",
"NULL",
",",
"$",
"var_name",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"file_name",
")",
")",
"{",
"$",
"this",
"->",
"_trigger_error_msg",
"(",
"'Empty config file name... | Retrieves config info based on the file, section, and variable name.
@param string $file_name config file to get info for
@param string $section_name (optional) section to get info for
@param string $var_name (optional) variable to get info for
@return string|array a value or array of values | [
"Retrieves",
"config",
"info",
"based",
"on",
"the",
"file",
"section",
"and",
"variable",
"name",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L108-L138 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.& | function &get_key($config_key)
{
list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
$result = &$this->get($file_name, $section_name, $var_name);
return $result;
} | php | function &get_key($config_key)
{
list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
$result = &$this->get($file_name, $section_name, $var_name);
return $result;
} | [
"function",
"&",
"get_key",
"(",
"$",
"config_key",
")",
"{",
"list",
"(",
"$",
"file_name",
",",
"$",
"section_name",
",",
"$",
"var_name",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"config_key",
",",
"3",
")",
";",
"$",
"result",
"=",
"&",
"$",
... | Retrieves config info based on the key.
@param $file_name string config key (filename/section/var)
@return string|array same as get()
@uses get() retrieves information from config file and returns it | [
"Retrieves",
"config",
"info",
"based",
"on",
"the",
"key",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L148-L153 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.get_section_names | function get_section_names($file_name)
{
$file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'");
return;
}
return array_keys($this->_config_data[$file_name]["sections"]);
} | php | function get_section_names($file_name)
{
$file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'");
return;
}
return array_keys($this->_config_data[$file_name]["sections"]);
} | [
"function",
"get_section_names",
"(",
"$",
"file_name",
")",
"{",
"$",
"file_name",
"=",
"$",
"this",
"->",
"_config_path",
".",
"$",
"file_name",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_config_data",
"[",
"$",
"file_name",
"]",
")",
")... | Get all section names from a loaded file.
@param string $file_name config file to get section names from
@return array an array of section names from the specified file | [
"Get",
"all",
"section",
"names",
"from",
"a",
"loaded",
"file",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L172-L181 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.get_var_names | function get_var_names($file_name, $section = NULL)
{
if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name');
return;
} else if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'");
return;
}
if (empty($section))
return a... | php | function get_var_names($file_name, $section = NULL)
{
if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name');
return;
} else if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'");
return;
}
if (empty($section))
return a... | [
"function",
"get_var_names",
"(",
"$",
"file_name",
",",
"$",
"section",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"file_name",
")",
")",
"{",
"$",
"this",
"->",
"_trigger_error_msg",
"(",
"'Empty config file name'",
")",
";",
"return",
";",
"... | Get all global or section variable names.
@param string $file_name config file to get info for
@param string $section_name (optional) section to get info for
@return array an array of variables names from the specified file/section | [
"Get",
"all",
"global",
"or",
"section",
"variable",
"names",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L191-L205 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.clear | function clear($file_name = NULL)
{
if ($file_name === NULL)
$this->_config_data = array();
else if (isset($this->_config_data[$file_name]))
$this->_config_data[$file_name] = array();
} | php | function clear($file_name = NULL)
{
if ($file_name === NULL)
$this->_config_data = array();
else if (isset($this->_config_data[$file_name]))
$this->_config_data[$file_name] = array();
} | [
"function",
"clear",
"(",
"$",
"file_name",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"file_name",
"===",
"NULL",
")",
"$",
"this",
"->",
"_config_data",
"=",
"array",
"(",
")",
";",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_config_data",
... | Clear loaded config data for a certain file or all files.
@param string $file_name file to clear config data for | [
"Clear",
"loaded",
"config",
"data",
"for",
"a",
"certain",
"file",
"or",
"all",
"files",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L213-L219 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.load_file | function load_file($file_name, $prepend_path = true)
{
if ($prepend_path && $this->_config_path != "")
$config_file = $this->_config_path . $file_name;
else
$config_file = $file_name;
ini_set('track_errors', true);
$fp = @fopen($config_file, "r");
if (!is_resource($fp)) {
$this->_trigger_error_msg("C... | php | function load_file($file_name, $prepend_path = true)
{
if ($prepend_path && $this->_config_path != "")
$config_file = $this->_config_path . $file_name;
else
$config_file = $file_name;
ini_set('track_errors', true);
$fp = @fopen($config_file, "r");
if (!is_resource($fp)) {
$this->_trigger_error_msg("C... | [
"function",
"load_file",
"(",
"$",
"file_name",
",",
"$",
"prepend_path",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"prepend_path",
"&&",
"$",
"this",
"->",
"_config_path",
"!=",
"\"\"",
")",
"$",
"config_file",
"=",
"$",
"this",
"->",
"_config_path",
".",
... | Load a configuration file manually.
@param string $file_name file name to load
@param boolean $prepend_path whether current config path should be
prepended to the filename | [
"Load",
"a",
"configuration",
"file",
"manually",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L229-L248 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.set_file_contents | function set_file_contents($config_file, $contents)
{
$this->_config_data[$config_file] = $this->parse_contents($contents);
return true;
} | php | function set_file_contents($config_file, $contents)
{
$this->_config_data[$config_file] = $this->parse_contents($contents);
return true;
} | [
"function",
"set_file_contents",
"(",
"$",
"config_file",
",",
"$",
"contents",
")",
"{",
"$",
"this",
"->",
"_config_data",
"[",
"$",
"config_file",
"]",
"=",
"$",
"this",
"->",
"parse_contents",
"(",
"$",
"contents",
")",
";",
"return",
"true",
";",
"}... | Store the contents of a file manually.
@param string $config_file file name of the related contents
@param string $contents the file-contents to parse | [
"Store",
"the",
"contents",
"of",
"a",
"file",
"manually",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L256-L260 |
matyhtf/framework | libs/module/smarty/Config_File.class.php | Config_File.parse_contents | function parse_contents($contents)
{
if($this->fix_newlines) {
// fix mac/dos formatted newlines
$contents = preg_replace('!\r\n?!', "\n", $contents);
}
$config_data = array();
$config_data['sections'] = array();
$config_data['vars'] = array();
/* reference to fill with data */
$vars =& $config_d... | php | function parse_contents($contents)
{
if($this->fix_newlines) {
// fix mac/dos formatted newlines
$contents = preg_replace('!\r\n?!', "\n", $contents);
}
$config_data = array();
$config_data['sections'] = array();
$config_data['vars'] = array();
/* reference to fill with data */
$vars =& $config_d... | [
"function",
"parse_contents",
"(",
"$",
"contents",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fix_newlines",
")",
"{",
"// fix mac/dos formatted newlines",
"$",
"contents",
"=",
"preg_replace",
"(",
"'!\\r\\n?!'",
",",
"\"\\n\"",
",",
"$",
"contents",
")",
";",... | parse the source of a configuration file manually.
@param string $contents the file-contents to parse | [
"parse",
"the",
"source",
"of",
"a",
"configuration",
"file",
"manually",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/smarty/Config_File.class.php#L267-L338 |
matyhtf/framework | libs/Swoole/Database/MySQL.php | MySQL.connect | function connect()
{
$db_config = $this->config;
if (empty($db_config['persistent']))
{
$this->conn = mysql_connect($db_config['host'] . ':' . $db_config['port'],
$db_config['user'],
$db_config['passwd']);
}
else
{
... | php | function connect()
{
$db_config = $this->config;
if (empty($db_config['persistent']))
{
$this->conn = mysql_connect($db_config['host'] . ':' . $db_config['port'],
$db_config['user'],
$db_config['passwd']);
}
else
{
... | [
"function",
"connect",
"(",
")",
"{",
"$",
"db_config",
"=",
"$",
"this",
"->",
"config",
";",
"if",
"(",
"empty",
"(",
"$",
"db_config",
"[",
"'persistent'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"conn",
"=",
"mysql_connect",
"(",
"$",
"db_config",... | 连接数据库
@see Swoole.IDatabase::connect() | [
"连接数据库"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQL.php#L34-L61 |
matyhtf/framework | libs/Swoole/Database/MySQL.php | MySQL.query | function query($sql)
{
$res = false;
for ($i = 0; $i < 2; $i++)
{
$res = mysql_query($sql, $this->conn);
if ($res === false)
{
if (mysql_errno($this->conn) == 2006 or mysql_errno($this->conn) == 2013 or (mysql_errno($this->conn) == 0 and !... | php | function query($sql)
{
$res = false;
for ($i = 0; $i < 2; $i++)
{
$res = mysql_query($sql, $this->conn);
if ($res === false)
{
if (mysql_errno($this->conn) == 2006 or mysql_errno($this->conn) == 2013 or (mysql_errno($this->conn) == 0 and !... | [
"function",
"query",
"(",
"$",
"sql",
")",
"{",
"$",
"res",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"2",
";",
"$",
"i",
"++",
")",
"{",
"$",
"res",
"=",
"mysql_query",
"(",
"$",
"sql",
",",
"$",
"this",
"->"... | 执行一个SQL语句
@param string $sql 执行的SQL语句
@return MySQLRecord | false | [
"执行一个SQL语句"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQL.php#L75-L108 |
matyhtf/framework | libs/Swoole/Network/SelectUDP.php | SelectUDP.run | function run($num=1)
{
//初始化事件系统
if(!($this->protocol instanceof Swoole_UDP_Server_Protocol))
{
return error(902);
}
//建立服务器端Socket
$this->server_sock = $this->create("udp://{$this->host}:{$this->port}");
stream_set_blocking($this->server_sock,$thi... | php | function run($num=1)
{
//初始化事件系统
if(!($this->protocol instanceof Swoole_UDP_Server_Protocol))
{
return error(902);
}
//建立服务器端Socket
$this->server_sock = $this->create("udp://{$this->host}:{$this->port}");
stream_set_blocking($this->server_sock,$thi... | [
"function",
"run",
"(",
"$",
"num",
"=",
"1",
")",
"{",
"//初始化事件系统",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"protocol",
"instanceof",
"Swoole_UDP_Server_Protocol",
")",
")",
"{",
"return",
"error",
"(",
"902",
")",
";",
"}",
"//建立服务器端Socket",
"$",
"th... | 运行服务器程序
@return unknown_type | [
"运行服务器程序"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Network/SelectUDP.php#L34-L48 |
matyhtf/framework | libs/Swoole/Network/SelectUDP.php | SelectUDP.shutdown | function shutdown()
{
//关闭服务器端
\Swoole\Network\Stream::close($this->server_sock);
//关闭事件循环
$this->protocol->onShutdown($this);
} | php | function shutdown()
{
//关闭服务器端
\Swoole\Network\Stream::close($this->server_sock);
//关闭事件循环
$this->protocol->onShutdown($this);
} | [
"function",
"shutdown",
"(",
")",
"{",
"//关闭服务器端",
"\\",
"Swoole",
"\\",
"Network",
"\\",
"Stream",
"::",
"close",
"(",
"$",
"this",
"->",
"server_sock",
")",
";",
"//关闭事件循环",
"$",
"this",
"->",
"protocol",
"->",
"onShutdown",
"(",
"$",
"this",
")",
";... | 关闭服务器程序 | [
"关闭服务器程序"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Network/SelectUDP.php#L53-L59 |
matyhtf/framework | libs/Swoole/Session.php | Session.start | public function start($readonly = false)
{
if (empty(\Swoole::$php->request))
{
throw new SessionException("The method must be used when requested.");
}
$this->isStart = true;
if ($this->use_php_session)
{
session_start();
}
el... | php | public function start($readonly = false)
{
if (empty(\Swoole::$php->request))
{
throw new SessionException("The method must be used when requested.");
}
$this->isStart = true;
if ($this->use_php_session)
{
session_start();
}
el... | [
"public",
"function",
"start",
"(",
"$",
"readonly",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"\\",
"Swoole",
"::",
"$",
"php",
"->",
"request",
")",
")",
"{",
"throw",
"new",
"SessionException",
"(",
"\"The method must be used when requested.\"",
")... | 启动会话
@param bool $readonly
@throws SessionException | [
"启动会话"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Session.php#L100-L128 |
matyhtf/framework | libs/Swoole/Session.php | Session.load | public function load($sessId)
{
$this->sessID = $sessId;
$data = $this->cache->get(self::$cache_prefix . $sessId);
//先读数据,如果没有,就初始化一个
if (!empty($data))
{
return unserialize($data);
}
else
{
return array();
}
} | php | public function load($sessId)
{
$this->sessID = $sessId;
$data = $this->cache->get(self::$cache_prefix . $sessId);
//先读数据,如果没有,就初始化一个
if (!empty($data))
{
return unserialize($data);
}
else
{
return array();
}
} | [
"public",
"function",
"load",
"(",
"$",
"sessId",
")",
"{",
"$",
"this",
"->",
"sessID",
"=",
"$",
"sessId",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"$",
"cache_prefix",
".",
"$",
"sessId",
")",
";",
"//... | 加载Session
@param $sessId
@return array | [
"加载Session"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Session.php#L164-L177 |
matyhtf/framework | libs/Swoole/Session.php | Session.save | public function save()
{
/**
* 使用PHP Sesion,Readonl,未启动 这3种情况下不需要保存
*/
if ($this->use_php_session or !$this->isStart or $this->readonly)
{
return true;
}
//设置为Session关闭状态
$this->isStart = false;
$key = self::$cache_prefix . $this-... | php | public function save()
{
/**
* 使用PHP Sesion,Readonl,未启动 这3种情况下不需要保存
*/
if ($this->use_php_session or !$this->isStart or $this->readonly)
{
return true;
}
//设置为Session关闭状态
$this->isStart = false;
$key = self::$cache_prefix . $this-... | [
"public",
"function",
"save",
"(",
")",
"{",
"/**\n * 使用PHP Sesion,Readonl,未启动 这3种情况下不需要保存\n */",
"if",
"(",
"$",
"this",
"->",
"use_php_session",
"or",
"!",
"$",
"this",
"->",
"isStart",
"or",
"$",
"this",
"->",
"readonly",
")",
"{",
"return",
"... | 保存Session
@return bool | [
"保存Session"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Session.php#L183-L196 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.num2week | static function num2week($num, $two = true)
{
if ($num == '6')
{
$num = '日';
}
else
{
$num = Tool::num2han($num + 1);
}
if ($two)
{
return self::WEEK_TWO . $num;
}
else
{
return se... | php | static function num2week($num, $two = true)
{
if ($num == '6')
{
$num = '日';
}
else
{
$num = Tool::num2han($num + 1);
}
if ($two)
{
return self::WEEK_TWO . $num;
}
else
{
return se... | [
"static",
"function",
"num2week",
"(",
"$",
"num",
",",
"$",
"two",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"num",
"==",
"'6'",
")",
"{",
"$",
"num",
"=",
"'日';",
"",
"}",
"else",
"{",
"$",
"num",
"=",
"Tool",
"::",
"num2han",
"(",
"$",
"num",... | 数字转星期
@param $num
@param bool $two
@return string | [
"数字转星期"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L30-L48 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.readFile | static function readFile($file, $exclusive = false)
{
$fp = fopen($file, 'r');
if (!$fp)
{
return false;
}
$lockType = $exclusive ? LOCK_EX : LOCK_SH;
if (flock($fp, $lockType) === false)
{
fclose($fp);
}
$content = '';
... | php | static function readFile($file, $exclusive = false)
{
$fp = fopen($file, 'r');
if (!$fp)
{
return false;
}
$lockType = $exclusive ? LOCK_EX : LOCK_SH;
if (flock($fp, $lockType) === false)
{
fclose($fp);
}
$content = '';
... | [
"static",
"function",
"readFile",
"(",
"$",
"file",
",",
"$",
"exclusive",
"=",
"false",
")",
"{",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"file",
",",
"'r'",
")",
";",
"if",
"(",
"!",
"$",
"fp",
")",
"{",
"return",
"false",
";",
"}",
"$",
"lockType... | 加锁读取文件
@param $file
@param bool $exclusive
@return bool|string | [
"加锁读取文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L106-L125 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.uri | static public function uri($url)
{
$res = parse_url($url);
$return['protocol'] = $res['scheme'];
$return['host'] = $res['host'];
$return['port'] = $res['port'];
$return['user'] = $res['user'];
$return['pass'] = $res['pass'];
$return['path'] = $res['path'];
... | php | static public function uri($url)
{
$res = parse_url($url);
$return['protocol'] = $res['scheme'];
$return['host'] = $res['host'];
$return['port'] = $res['port'];
$return['user'] = $res['user'];
$return['pass'] = $res['pass'];
$return['path'] = $res['path'];
... | [
"static",
"public",
"function",
"uri",
"(",
"$",
"url",
")",
"{",
"$",
"res",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"return",
"[",
"'protocol'",
"]",
"=",
"$",
"res",
"[",
"'scheme'",
"]",
";",
"$",
"return",
"[",
"'host'",
"]",
"=",
... | 解析URI
@param string $url
@return array $return | [
"解析URI"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L142-L154 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.howLongAgo | static function howLongAgo($datetime)
{
$timestamp = strtotime($datetime);
$seconds = time();
$time = date('Y', $seconds) - date('Y', $timestamp);
if ($time > 0)
{
if ($time == 1)
{
return '去年';
}
else
... | php | static function howLongAgo($datetime)
{
$timestamp = strtotime($datetime);
$seconds = time();
$time = date('Y', $seconds) - date('Y', $timestamp);
if ($time > 0)
{
if ($time == 1)
{
return '去年';
}
else
... | [
"static",
"function",
"howLongAgo",
"(",
"$",
"datetime",
")",
"{",
"$",
"timestamp",
"=",
"strtotime",
"(",
"$",
"datetime",
")",
";",
"$",
"seconds",
"=",
"time",
"(",
")",
";",
"$",
"time",
"=",
"date",
"(",
"'Y'",
",",
"$",
"seconds",
")",
"-",... | 多久之前
@param $datetime
@return string | [
"多久之前"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L192-L253 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.combine_query | static function combine_query($urls)
{
$url = array();
foreach ($urls as $k => $v)
{
if (!empty($k))
{
$url[] = $k . self::$url_key_join . urlencode($v);
}
}
return implode(self::$url_param_join, $url);
} | php | static function combine_query($urls)
{
$url = array();
foreach ($urls as $k => $v)
{
if (!empty($k))
{
$url[] = $k . self::$url_key_join . urlencode($v);
}
}
return implode(self::$url_param_join, $url);
} | [
"static",
"function",
"combine_query",
"(",
"$",
"urls",
")",
"{",
"$",
"url",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"k",
")",
")",
"{",
"$",
"... | 合并URL字串,parse_query的反向函数
@param $urls
@return string | [
"合并URL字串,parse_query的反向函数"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L260-L271 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.url_merge | static function url_merge($key, $value, $ignore = null, $urls = null)
{
$url = array();
if ($urls === null) $urls = $_GET;
$urls = array_merge($urls, array_combine(explode(',', $key), explode(',', $value)));
if ($ignore !== null)
{
$ignores = explode(',', $ignore... | php | static function url_merge($key, $value, $ignore = null, $urls = null)
{
$url = array();
if ($urls === null) $urls = $_GET;
$urls = array_merge($urls, array_combine(explode(',', $key), explode(',', $value)));
if ($ignore !== null)
{
$ignores = explode(',', $ignore... | [
"static",
"function",
"url_merge",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ignore",
"=",
"null",
",",
"$",
"urls",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"urls",
"===",
"null",
")",
"$",
"urls",
... | URL合并
@param $key
@param $value
@param $ignore
@return string | [
"URL合并"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L292-L323 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.url_parse_into | static function url_parse_into($url, &$request)
{
$url = str_replace(self::$url_add_end, '', $url);
if (self::$url_key_join == self::$url_param_join)
{
$urls = explode(self::$url_param_join, $url);
$c = intval(count($urls) / 2);
for ($i = 0; $i < $c; $i++)... | php | static function url_parse_into($url, &$request)
{
$url = str_replace(self::$url_add_end, '', $url);
if (self::$url_key_join == self::$url_param_join)
{
$urls = explode(self::$url_param_join, $url);
$c = intval(count($urls) / 2);
for ($i = 0; $i < $c; $i++)... | [
"static",
"function",
"url_parse_into",
"(",
"$",
"url",
",",
"&",
"$",
"request",
")",
"{",
"$",
"url",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"url_add_end",
",",
"''",
",",
"$",
"url",
")",
";",
"if",
"(",
"self",
"::",
"$",
"url_key_join",
... | URL解析到REQUEST
@param $url
@param $request
@return unknown_type | [
"URL解析到REQUEST"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L331-L352 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.array_iconv | static function array_iconv($in_charset, $out_charset, $data)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
if (is_array($value)) $value = self::array_iconv($in_charset, $out_charset, $value);
else $value = iconv($in_charset, $out_charset, $value);
... | php | static function array_iconv($in_charset, $out_charset, $data)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
if (is_array($value)) $value = self::array_iconv($in_charset, $out_charset, $value);
else $value = iconv($in_charset, $out_charset, $value);
... | [
"static",
"function",
"array_iconv",
"(",
"$",
"in_charset",
",",
"$",
"out_charset",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
... | 数组编码转换
@param $in_charset
@param $out_charset
@param $data
@return $data | [
"数组编码转换"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L361-L371 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.array_fullness | static function array_fullness($array)
{
$nulls = 0;
foreach ($array as $v) if (empty($v) or intval($v) < 0) $nulls++;
return 100 - intval($nulls / count($array) * 100);
} | php | static function array_fullness($array)
{
$nulls = 0;
foreach ($array as $v) if (empty($v) or intval($v) < 0) $nulls++;
return 100 - intval($nulls / count($array) * 100);
} | [
"static",
"function",
"array_fullness",
"(",
"$",
"array",
")",
"{",
"$",
"nulls",
"=",
"0",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"v",
")",
"if",
"(",
"empty",
"(",
"$",
"v",
")",
"or",
"intval",
"(",
"$",
"v",
")",
"<",
"0",
")",
"$... | 数组饱满度
@param $array
@return unknown_type | [
"数组饱满度"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L378-L383 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.get_constellation | static function get_constellation($birth_month, $birth_date)
{
//判断的时候,为避免出现1和true的疑惑,或是判断语句始终为真的问题,这里统一处理成字符串形式
$birth_month = strval($birth_month);
$constellation_name = array('水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座');
if ($birth_date <= 22... | php | static function get_constellation($birth_month, $birth_date)
{
//判断的时候,为避免出现1和true的疑惑,或是判断语句始终为真的问题,这里统一处理成字符串形式
$birth_month = strval($birth_month);
$constellation_name = array('水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座');
if ($birth_date <= 22... | [
"static",
"function",
"get_constellation",
"(",
"$",
"birth_month",
",",
"$",
"birth_date",
")",
"{",
"//判断的时候,为避免出现1和true的疑惑,或是判断语句始终为真的问题,这里统一处理成字符串形式",
"$",
"birth_month",
"=",
"strval",
"(",
"$",
"birth_month",
")",
";",
"$",
"constellation_name",
"=",
"array",
... | 根据生日中的月份和日期来计算所属星座*
@param int $birth_month
@param int $birth_date
@return string | [
"根据生日中的月份和日期来计算所属星座",
"*"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L391-L412 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.get_animal | static function get_animal($birth_year, $format = '1')
{
//1900年是子鼠年
if ($format == '2')
{
$animal = array('子鼠', '丑牛', '寅虎', '卯兔', '辰龙', '巳蛇', '午马', '未羊', '申猴', '酉鸡', '戌狗', '亥猪');
}
elseif ($format == '1')
{
$animal = array('鼠', '牛', '虎', '兔', ... | php | static function get_animal($birth_year, $format = '1')
{
//1900年是子鼠年
if ($format == '2')
{
$animal = array('子鼠', '丑牛', '寅虎', '卯兔', '辰龙', '巳蛇', '午马', '未羊', '申猴', '酉鸡', '戌狗', '亥猪');
}
elseif ($format == '1')
{
$animal = array('鼠', '牛', '虎', '兔', ... | [
"static",
"function",
"get_animal",
"(",
"$",
"birth_year",
",",
"$",
"format",
"=",
"'1'",
")",
"{",
"//1900年是子鼠年",
"if",
"(",
"$",
"format",
"==",
"'2'",
")",
"{",
"$",
"animal",
"=",
"array",
"(",
"'子鼠', '丑",
"牛",
", '寅虎', ",
"'",
"兔', '辰龙'",
",",
... | 根据生日中的年份来计算所属生肖
@param int $birth_year
@return string | [
"根据生日中的年份来计算所属生肖"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L420-L433 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.get_age | static function get_age($birth_year, $birth_month, $birth_date)
{
$now_age = 1; //实际年龄,以出生时为1岁计
$full_age = 0; //周岁,该变量放着,根据具体情况可以随时修改
$now_year = date('Y', time());
$now_date_num = date('z', time()); //该年份中的第几天
$birth_date_num = date('z', mktime(0, 0, 0, $birth_month, $birth... | php | static function get_age($birth_year, $birth_month, $birth_date)
{
$now_age = 1; //实际年龄,以出生时为1岁计
$full_age = 0; //周岁,该变量放着,根据具体情况可以随时修改
$now_year = date('Y', time());
$now_date_num = date('z', time()); //该年份中的第几天
$birth_date_num = date('z', mktime(0, 0, 0, $birth_month, $birth... | [
"static",
"function",
"get_age",
"(",
"$",
"birth_year",
",",
"$",
"birth_month",
",",
"$",
"birth_date",
")",
"{",
"$",
"now_age",
"=",
"1",
";",
"//实际年龄,以出生时为1岁计",
"$",
"full_age",
"=",
"0",
";",
"//周岁,该变量放着,根据具体情况可以随时修改",
"$",
"now_year",
"=",
"date",
"... | 根据生日来计算年龄
用Unix时间戳计算是最准确的,但不太好处理1970年之前出生的情况
而且还要考虑闰年的问题,所以就暂时放弃这种方式的开发,保留思想
@param int $birth_year
@param int $birth_month
@param int $birth_date
@return int | [
"根据生日来计算年龄"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L446-L465 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.sendUDP | static function sendUDP($server_ip, $server_port, $data, $timeout = 30)
{
$client = stream_socket_client("udp://$server_ip:$server_port", $errno, $errstr, $timeout);
if (!$client)
{
echo "ERROR: $errno - $errstr<br />\n";
}
else
{
fwrite($clien... | php | static function sendUDP($server_ip, $server_port, $data, $timeout = 30)
{
$client = stream_socket_client("udp://$server_ip:$server_port", $errno, $errstr, $timeout);
if (!$client)
{
echo "ERROR: $errno - $errstr<br />\n";
}
else
{
fwrite($clien... | [
"static",
"function",
"sendUDP",
"(",
"$",
"server_ip",
",",
"$",
"server_port",
",",
"$",
"data",
",",
"$",
"timeout",
"=",
"30",
")",
"{",
"$",
"client",
"=",
"stream_socket_client",
"(",
"\"udp://$server_ip:$server_port\"",
",",
"$",
"errno",
",",
"$",
... | 发送一个UDP包
@return unknown_type | [
"发送一个UDP包"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L471-L483 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.dir_copy | static function dir_copy($fdir, $tdir)
{
if (is_dir($fdir)) {
if (!is_dir($tdir)) {
mkdir($tdir);
}
$handle = opendir($fdir);
while (false !== ($filename = readdir($handle))) {
if ($filename != "." && $filename != "..") self::di... | php | static function dir_copy($fdir, $tdir)
{
if (is_dir($fdir)) {
if (!is_dir($tdir)) {
mkdir($tdir);
}
$handle = opendir($fdir);
while (false !== ($filename = readdir($handle))) {
if ($filename != "." && $filename != "..") self::di... | [
"static",
"function",
"dir_copy",
"(",
"$",
"fdir",
",",
"$",
"tdir",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"fdir",
")",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"tdir",
")",
")",
"{",
"mkdir",
"(",
"$",
"tdir",
")",
";",
"}",
"$",
... | 复制目录
@param $fdir源目录名(不带/)
@param $tdir目标目录名(不带/)
@return | [
"复制目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L491-L507 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.getHumanTime | static function getHumanTime($n, $round = 3)
{
if ($n > 86400 * 365)
{
return round($n / ( 86400 * 365), $round) . "年";
}
elseif ($n > 86400 * 30)
{
return round($n / (86400 * 30), $round) . "月";
}
elseif ($n > 86400)
{
... | php | static function getHumanTime($n, $round = 3)
{
if ($n > 86400 * 365)
{
return round($n / ( 86400 * 365), $round) . "年";
}
elseif ($n > 86400 * 30)
{
return round($n / (86400 * 30), $round) . "月";
}
elseif ($n > 86400)
{
... | [
"static",
"function",
"getHumanTime",
"(",
"$",
"n",
",",
"$",
"round",
"=",
"3",
")",
"{",
"if",
"(",
"$",
"n",
">",
"86400",
"*",
"365",
")",
"{",
"return",
"round",
"(",
"$",
"n",
"/",
"(",
"86400",
"*",
"365",
")",
",",
"$",
"round",
")",... | 将秒数转为人性化格式
@param $n
@param int $round
@return string | [
"将秒数转为人性化格式"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L557-L583 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.getServer | static function getServer(array $servers)
{
$weight = 0;
//移除不在线的节点
foreach ($servers as $k => $svr)
{
//节点已掉线
if (!empty($svr['status']) and $svr['status'] == 'offline')
{
unset($servers[$k]);
}
else
... | php | static function getServer(array $servers)
{
$weight = 0;
//移除不在线的节点
foreach ($servers as $k => $svr)
{
//节点已掉线
if (!empty($svr['status']) and $svr['status'] == 'offline')
{
unset($servers[$k]);
}
else
... | [
"static",
"function",
"getServer",
"(",
"array",
"$",
"servers",
")",
"{",
"$",
"weight",
"=",
"0",
";",
"//移除不在线的节点",
"foreach",
"(",
"$",
"servers",
"as",
"$",
"k",
"=>",
"$",
"svr",
")",
"{",
"//节点已掉线",
"if",
"(",
"!",
"empty",
"(",
"$",
"svr",
... | 从Server列表中随机选出一个,使用status配置可以实现上线下线管理,weight(0-100)配置权重
@param array $servers
@return mixed | [
"从Server列表中随机选出一个,使用status配置可以实现上线下线管理,weight",
"(",
"0",
"-",
"100",
")",
"配置权重"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L603-L639 |
matyhtf/framework | libs/Swoole/Tool.php | Tool.isPrivateIP | static function isPrivateIP(string $ip)
{
if (strncmp($ip, "10.", 3) == 0 or strncmp($ip, "192.168.", 8) == 0)
{
return true;
}
if (strncmp($ip, "172.", 4) == 0)
{
$arr = explode('.', $ip);
if ($arr[1] >= 16 and $arr[1] <= 31)
{... | php | static function isPrivateIP(string $ip)
{
if (strncmp($ip, "10.", 3) == 0 or strncmp($ip, "192.168.", 8) == 0)
{
return true;
}
if (strncmp($ip, "172.", 4) == 0)
{
$arr = explode('.', $ip);
if ($arr[1] >= 16 and $arr[1] <= 31)
{... | [
"static",
"function",
"isPrivateIP",
"(",
"string",
"$",
"ip",
")",
"{",
"if",
"(",
"strncmp",
"(",
"$",
"ip",
",",
"\"10.\"",
",",
"3",
")",
"==",
"0",
"or",
"strncmp",
"(",
"$",
"ip",
",",
"\"192.168.\"",
",",
"8",
")",
"==",
"0",
")",
"{",
"... | 检查地址是否未私有
@param string $ip
@return bool | [
"检查地址是否未私有"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Tool.php#L725-L740 |
matyhtf/framework | libs/Swoole/Http/Parser.php | Parser.parseHeader | static function parseHeader($data)
{
$header = array();
$header[0] = array();
$meta = &$header[0];
$parts = explode("\r\n\r\n", $data, 2);
// parts[0] = HTTP头;
// parts[1] = HTTP主体,GET请求没有body
$headerLines = explode("\r\n", $parts[0]);
// HTTP协议头,方法,... | php | static function parseHeader($data)
{
$header = array();
$header[0] = array();
$meta = &$header[0];
$parts = explode("\r\n\r\n", $data, 2);
// parts[0] = HTTP头;
// parts[1] = HTTP主体,GET请求没有body
$headerLines = explode("\r\n", $parts[0]);
// HTTP协议头,方法,... | [
"static",
"function",
"parseHeader",
"(",
"$",
"data",
")",
"{",
"$",
"header",
"=",
"array",
"(",
")",
";",
"$",
"header",
"[",
"0",
"]",
"=",
"array",
"(",
")",
";",
"$",
"meta",
"=",
"&",
"$",
"header",
"[",
"0",
"]",
";",
"$",
"parts",
"=... | 头部解析
@param $data
@return array | [
"头部解析"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/Parser.php#L22-L45 |
matyhtf/framework | libs/Swoole/Http/Parser.php | Parser.parseHeaderLine | static function parseHeaderLine($headerLines)
{
if (is_string($headerLines))
{
$headerLines = explode("\r\n", $headerLines);
}
$header = array();
foreach ($headerLines as $_h)
{
$_h = trim($_h);
if (empty($_h)) continue;
... | php | static function parseHeaderLine($headerLines)
{
if (is_string($headerLines))
{
$headerLines = explode("\r\n", $headerLines);
}
$header = array();
foreach ($headerLines as $_h)
{
$_h = trim($_h);
if (empty($_h)) continue;
... | [
"static",
"function",
"parseHeaderLine",
"(",
"$",
"headerLines",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"headerLines",
")",
")",
"{",
"$",
"headerLines",
"=",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"headerLines",
")",
";",
"}",
"$",
"header",
"=",... | 传入一个字符串或者数组
@param $headerLines string/array
@return array | [
"传入一个字符串或者数组"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/Parser.php#L52-L72 |
matyhtf/framework | libs/Swoole/Http/Parser.php | Parser.parseBody | function parseBody(Swoole\Request $request)
{
$cd = strstr($request->header['Content-Type'], 'boundary');
if (isset($request->header['Content-Type']) and $cd !== false)
{
$this->parseFormData($request, $cd);
}
else
{
if (substr($request->header... | php | function parseBody(Swoole\Request $request)
{
$cd = strstr($request->header['Content-Type'], 'boundary');
if (isset($request->header['Content-Type']) and $cd !== false)
{
$this->parseFormData($request, $cd);
}
else
{
if (substr($request->header... | [
"function",
"parseBody",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"cd",
"=",
"strstr",
"(",
"$",
"request",
"->",
"header",
"[",
"'Content-Type'",
"]",
",",
"'boundary'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"request",
"->",
... | 解析Body
@param $request Swoole\Request | [
"解析Body"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/Parser.php#L98-L112 |
matyhtf/framework | libs/Swoole/Http/Parser.php | Parser.parseCookie | function parseCookie(Swoole\Request $request)
{
$request->cookie = self::parseParams($request->header['Cookie']);
} | php | function parseCookie(Swoole\Request $request)
{
$request->cookie = self::parseParams($request->header['Cookie']);
} | [
"function",
"parseCookie",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"request",
"->",
"cookie",
"=",
"self",
"::",
"parseParams",
"(",
"$",
"request",
"->",
"header",
"[",
"'Cookie'",
"]",
")",
";",
"}"
] | 解析Cookies
@param $request Swoole\Request | [
"解析Cookies"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/Parser.php#L117-L120 |
matyhtf/framework | libs/Swoole/Http/Parser.php | Parser.parseFormData | static function parseFormData(Swoole\Request $request, $cd)
{
$cd = '--' . str_replace('boundary=', '', $cd);
$form = explode($cd, rtrim($request->body, "-")); //去掉末尾的--
foreach ($form as $f)
{
if ($f === '')
{
continue;
}
... | php | static function parseFormData(Swoole\Request $request, $cd)
{
$cd = '--' . str_replace('boundary=', '', $cd);
$form = explode($cd, rtrim($request->body, "-")); //去掉末尾的--
foreach ($form as $f)
{
if ($f === '')
{
continue;
}
... | [
"static",
"function",
"parseFormData",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"$",
"cd",
")",
"{",
"$",
"cd",
"=",
"'--'",
".",
"str_replace",
"(",
"'boundary='",
",",
"''",
",",
"$",
"cd",
")",
";",
"$",
"form",
"=",
"explode",
"(",
... | 解析form_data格式文件
@param $part
@param $request Swoole\Request
@param $cd | [
"解析form_data格式文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/Parser.php#L128-L179 |
matyhtf/framework | libs/Swoole/Http/Parser.php | Parser.parse | function parse($data)
{
$_header = strstr($data, self::HTTP_EOF, true);
if ($_header === false)
{
$this->buffer = $data;
}
$header = self::parseHeader($_header);
if ($header === false)
{
$this->isError = true;
}
$this->h... | php | function parse($data)
{
$_header = strstr($data, self::HTTP_EOF, true);
if ($_header === false)
{
$this->buffer = $data;
}
$header = self::parseHeader($_header);
if ($header === false)
{
$this->isError = true;
}
$this->h... | [
"function",
"parse",
"(",
"$",
"data",
")",
"{",
"$",
"_header",
"=",
"strstr",
"(",
"$",
"data",
",",
"self",
"::",
"HTTP_EOF",
",",
"true",
")",
";",
"if",
"(",
"$",
"_header",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"buffer",
"=",
"$",
... | 头部http协议
@param $data
@return array | [
"头部http协议"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/Parser.php#L186-L200 |
nahid/talk | src/TalkServiceProvider.php | TalkServiceProvider.registerTalk | protected function registerTalk()
{
$this->app->singleton('talk', function (Container $app) {
return new Talk($app['config'], $app['talk.broadcast'], $app[ConversationRepository::class], $app[MessageRepository::class]);
});
$this->app->alias('talk', Talk::class);
} | php | protected function registerTalk()
{
$this->app->singleton('talk', function (Container $app) {
return new Talk($app['config'], $app['talk.broadcast'], $app[ConversationRepository::class], $app[MessageRepository::class]);
});
$this->app->alias('talk', Talk::class);
} | [
"protected",
"function",
"registerTalk",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'talk'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"return",
"new",
"Talk",
"(",
"$",
"app",
"[",
"'config'",
"]",
",",
"$",
"ap... | Register Talk class. | [
"Register",
"Talk",
"class",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/TalkServiceProvider.php#L60-L67 |
nahid/talk | src/TalkServiceProvider.php | TalkServiceProvider.registerBroadcast | protected function registerBroadcast()
{
$this->app->singleton('talk.broadcast', function (Container $app) {
return new Live\Broadcast($app['config']);
});
$this->app->alias('talk.broadcast', Live\Broadcast::class);
} | php | protected function registerBroadcast()
{
$this->app->singleton('talk.broadcast', function (Container $app) {
return new Live\Broadcast($app['config']);
});
$this->app->alias('talk.broadcast', Live\Broadcast::class);
} | [
"protected",
"function",
"registerBroadcast",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'talk.broadcast'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"return",
"new",
"Live",
"\\",
"Broadcast",
"(",
"$",
"app",
"[",
... | Register Talk class. | [
"Register",
"Talk",
"class",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/TalkServiceProvider.php#L72-L79 |
nahid/talk | src/Middleware/TalkMiddleware.php | TalkMiddleware.handle | public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
Talk::setAuthUserId(Auth::guard($guard)->user()->id);
}
return $next($request);
} | php | public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
Talk::setAuthUserId(Auth::guard($guard)->user()->id);
}
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
",",
"$",
"guard",
"=",
"null",
")",
"{",
"if",
"(",
"Auth",
"::",
"guard",
"(",
"$",
"guard",
")",
"->",
"check",
"(",
")",
")",
"{",
"Talk",
"::",
"setAuthUserId",
... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Middleware/TalkMiddleware.php#L19-L26 |
nahid/talk | src/Live/Broadcast.php | Broadcast.connectPusher | protected function connectPusher($options = [])
{
if ($this->getConfig('broadcast.enable')) {
$appId = $this->getConfig('broadcast.pusher.app_id');
$appKey = $this->getConfig('broadcast.pusher.app_key');
$appSecret = $this->getConfig('broadcast.pusher.app_secret');
... | php | protected function connectPusher($options = [])
{
if ($this->getConfig('broadcast.enable')) {
$appId = $this->getConfig('broadcast.pusher.app_id');
$appKey = $this->getConfig('broadcast.pusher.app_key');
$appSecret = $this->getConfig('broadcast.pusher.app_secret');
... | [
"protected",
"function",
"connectPusher",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'broadcast.enable'",
")",
")",
"{",
"$",
"appId",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'broadcast.pusher.app_id'"... | Make pusher connection.
@param array $options
@return object | bool | [
"Make",
"pusher",
"connection",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Live/Broadcast.php#L54-L69 |
nahid/talk | src/Live/Broadcast.php | Broadcast.transmission | public function transmission(Message $message)
{
if (!$this->pusher) {
return false;
}
$sender = $message->sender->toArray();
$messageArray = $message->toArray();
$messageArray['sender'] = $sender;
$this->dispatch(new Webcast($messageArray));
} | php | public function transmission(Message $message)
{
if (!$this->pusher) {
return false;
}
$sender = $message->sender->toArray();
$messageArray = $message->toArray();
$messageArray['sender'] = $sender;
$this->dispatch(new Webcast($messageArray));
} | [
"public",
"function",
"transmission",
"(",
"Message",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pusher",
")",
"{",
"return",
"false",
";",
"}",
"$",
"sender",
"=",
"$",
"message",
"->",
"sender",
"->",
"toArray",
"(",
")",
";",
... | Dispatch the job to the queue.
@param \Nahid\Talk\Messages\Message $message | [
"Dispatch",
"the",
"job",
"to",
"the",
"queue",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Live/Broadcast.php#L76-L86 |
nahid/talk | src/Conversations/ConversationRepository.php | ConversationRepository.isExistsAmongTwoUsers | public function isExistsAmongTwoUsers($user1, $user2)
{
$conversation = Conversation::where(
function ($query) use ($user1, $user2) {
$query->where(
function ($q) use ($user1, $user2) {
$q->where('user_one', $user1)
... | php | public function isExistsAmongTwoUsers($user1, $user2)
{
$conversation = Conversation::where(
function ($query) use ($user1, $user2) {
$query->where(
function ($q) use ($user1, $user2) {
$q->where('user_one', $user1)
... | [
"public",
"function",
"isExistsAmongTwoUsers",
"(",
"$",
"user1",
",",
"$",
"user2",
")",
"{",
"$",
"conversation",
"=",
"Conversation",
"::",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"user1",
",",
"$",
"user2",
")",
"{",
"$",... | /*
check this given two users is already make a conversation
@param int $user1
@param int $user2
@return int|bool | [
"/",
"*",
"check",
"this",
"given",
"two",
"users",
"is",
"already",
"make",
"a",
"conversation"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Conversations/ConversationRepository.php#L42-L66 |
nahid/talk | src/Conversations/ConversationRepository.php | ConversationRepository.isUserExists | public function isUserExists($conversationId, $userId)
{
$exists = Conversation::where('id', $conversationId)
->where(
function ($query) use ($userId) {
$query->where('user_one', $userId)->orWhere('user_two', $userId);
}
)
... | php | public function isUserExists($conversationId, $userId)
{
$exists = Conversation::where('id', $conversationId)
->where(
function ($query) use ($userId) {
$query->where('user_one', $userId)->orWhere('user_two', $userId);
}
)
... | [
"public",
"function",
"isUserExists",
"(",
"$",
"conversationId",
",",
"$",
"userId",
")",
"{",
"$",
"exists",
"=",
"Conversation",
"::",
"where",
"(",
"'id'",
",",
"$",
"conversationId",
")",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use"... | /*
check this given user is involved with this given $conversation
@param int $conversationId
@param int $userId
@return bool | [
"/",
"*",
"check",
"this",
"given",
"user",
"is",
"involved",
"with",
"this",
"given",
"$conversation"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Conversations/ConversationRepository.php#L75-L86 |
nahid/talk | src/Conversations/ConversationRepository.php | ConversationRepository.threads | public function threads($user, $order, $offset, $take)
{
$conv = new Conversation();
$conv->authUser = $user;
$msgThread = $conv->with(
[
'messages' => function ($q) use ($user) {
return $q->where(
function ($q) use ($us... | php | public function threads($user, $order, $offset, $take)
{
$conv = new Conversation();
$conv->authUser = $user;
$msgThread = $conv->with(
[
'messages' => function ($q) use ($user) {
return $q->where(
function ($q) use ($us... | [
"public",
"function",
"threads",
"(",
"$",
"user",
",",
"$",
"order",
",",
"$",
"offset",
",",
"$",
"take",
")",
"{",
"$",
"conv",
"=",
"new",
"Conversation",
"(",
")",
";",
"$",
"conv",
"->",
"authUser",
"=",
"$",
"user",
";",
"$",
"msgThread",
... | /*
retrieve all message thread without soft deleted message with latest one message and
sender and receiver user model
@param int $user
@param int $offset
@param int $take
@return collection | [
"/",
"*",
"retrieve",
"all",
"message",
"thread",
"without",
"soft",
"deleted",
"message",
"with",
"latest",
"one",
"message",
"and",
"sender",
"and",
"receiver",
"user",
"model"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Conversations/ConversationRepository.php#L97-L138 |
nahid/talk | src/Conversations/ConversationRepository.php | ConversationRepository.threadsAll | public function threadsAll($user, $offset, $take)
{
$msgThread = Conversation::with(
[
'messages' => function ($q) use ($user) {
return $q->latest();
}, 'userone', 'usertwo'
]
)
->where('user_one', $user)->orWher... | php | public function threadsAll($user, $offset, $take)
{
$msgThread = Conversation::with(
[
'messages' => function ($q) use ($user) {
return $q->latest();
}, 'userone', 'usertwo'
]
)
->where('user_one', $user)->orWher... | [
"public",
"function",
"threadsAll",
"(",
"$",
"user",
",",
"$",
"offset",
",",
"$",
"take",
")",
"{",
"$",
"msgThread",
"=",
"Conversation",
"::",
"with",
"(",
"[",
"'messages'",
"=>",
"function",
"(",
"$",
"q",
")",
"use",
"(",
"$",
"user",
")",
"... | /*
retrieve all message thread with latest one message and sender and receiver user model
@param int $user
@param int $offset
@param int $take
@return collection | [
"/",
"*",
"retrieve",
"all",
"message",
"thread",
"with",
"latest",
"one",
"message",
"and",
"sender",
"and",
"receiver",
"user",
"model"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Conversations/ConversationRepository.php#L148-L169 |
nahid/talk | src/Conversations/ConversationRepository.php | ConversationRepository.getMessagesById | public function getMessagesById($conversationId, $userId, $offset, $take)
{
return Conversation::with(
[
'messages' => function ($query) use ($userId, $offset, $take) {
$query->where(
function ($qr) use ($userId) {
... | php | public function getMessagesById($conversationId, $userId, $offset, $take)
{
return Conversation::with(
[
'messages' => function ($query) use ($userId, $offset, $take) {
$query->where(
function ($qr) use ($userId) {
... | [
"public",
"function",
"getMessagesById",
"(",
"$",
"conversationId",
",",
"$",
"userId",
",",
"$",
"offset",
",",
"$",
"take",
")",
"{",
"return",
"Conversation",
"::",
"with",
"(",
"[",
"'messages'",
"=>",
"function",
"(",
"$",
"query",
")",
"use",
"(",... | /*
get all conversations by given conversation id
@param int $conversationId
@param int $userId
@param int $offset
@param int $take
@return collection | [
"/",
"*",
"get",
"all",
"conversations",
"by",
"given",
"conversation",
"id"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Conversations/ConversationRepository.php#L180-L204 |
nahid/talk | src/Conversations/ConversationRepository.php | ConversationRepository.getMessagesAllById | public function getMessagesAllById($conversationId, $offset, $take)
{
return $this->with(
[
'messages' => function ($q) use ($offset, $take) {
return $q->offset($offset)
->take($take);
}, 'userone', 'usertwo'
... | php | public function getMessagesAllById($conversationId, $offset, $take)
{
return $this->with(
[
'messages' => function ($q) use ($offset, $take) {
return $q->offset($offset)
->take($take);
}, 'userone', 'usertwo'
... | [
"public",
"function",
"getMessagesAllById",
"(",
"$",
"conversationId",
",",
"$",
"offset",
",",
"$",
"take",
")",
"{",
"return",
"$",
"this",
"->",
"with",
"(",
"[",
"'messages'",
"=>",
"function",
"(",
"$",
"q",
")",
"use",
"(",
"$",
"offset",
",",
... | /*
get all conversations with soft deleted message by given conversation id
@param int $conversationId
@param int $offset
@param int $take
@return collection | [
"/",
"*",
"get",
"all",
"conversations",
"with",
"soft",
"deleted",
"message",
"by",
"given",
"conversation",
"id"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Conversations/ConversationRepository.php#L214-L224 |
nahid/talk | src/Talk.php | Talk.getSerializeUser | protected function getSerializeUser($user1, $user2)
{
$user = [];
$user['one'] = ($user1 < $user2) ? $user1 : $user2;
$user['two'] = ($user1 < $user2) ? $user2 : $user1;
return $user;
} | php | protected function getSerializeUser($user1, $user2)
{
$user = [];
$user['one'] = ($user1 < $user2) ? $user1 : $user2;
$user['two'] = ($user1 < $user2) ? $user2 : $user1;
return $user;
} | [
"protected",
"function",
"getSerializeUser",
"(",
"$",
"user1",
",",
"$",
"user2",
")",
"{",
"$",
"user",
"=",
"[",
"]",
";",
"$",
"user",
"[",
"'one'",
"]",
"=",
"(",
"$",
"user1",
"<",
"$",
"user2",
")",
"?",
"$",
"user1",
":",
"$",
"user2",
... | make two users as serialize with ascending order.
@param int $user1
@param int $user2
@return array | [
"make",
"two",
"users",
"as",
"serialize",
"with",
"ascending",
"order",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L78-L85 |
nahid/talk | src/Talk.php | Talk.makeMessage | protected function makeMessage($conversationId, $message)
{
$message = $this->message->create([
'message' => $message,
'conversation_id' => $conversationId,
'user_id' => $this->authUserId,
'is_seen' => 0,
]);
$message->conversation->touch();
... | php | protected function makeMessage($conversationId, $message)
{
$message = $this->message->create([
'message' => $message,
'conversation_id' => $conversationId,
'user_id' => $this->authUserId,
'is_seen' => 0,
]);
$message->conversation->touch();
... | [
"protected",
"function",
"makeMessage",
"(",
"$",
"conversationId",
",",
"$",
"message",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"message",
"->",
"create",
"(",
"[",
"'message'",
"=>",
"$",
"message",
",",
"'conversation_id'",
"=>",
"$",
"convers... | create a new message by using conversationId.
@param int $conversationId
@param string $message
@return \Nahid\Talk\Messages\Message | [
"create",
"a",
"new",
"message",
"by",
"using",
"conversationId",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L95-L109 |
nahid/talk | src/Talk.php | Talk.makeMessageCollection | protected function makeMessageCollection($conversations)
{
if (!$conversations) {
return false;
}
$collection = (object) null;
if ($conversations->user_one == $this->authUserId || $conversations->user_two == $this->authUserId) {
$withUser = ($conversations->u... | php | protected function makeMessageCollection($conversations)
{
if (!$conversations) {
return false;
}
$collection = (object) null;
if ($conversations->user_one == $this->authUserId || $conversations->user_two == $this->authUserId) {
$withUser = ($conversations->u... | [
"protected",
"function",
"makeMessageCollection",
"(",
"$",
"conversations",
")",
"{",
"if",
"(",
"!",
"$",
"conversations",
")",
"{",
"return",
"false",
";",
"}",
"$",
"collection",
"=",
"(",
"object",
")",
"null",
";",
"if",
"(",
"$",
"conversations",
... | /*
Make new message collections to response with formatted data
@param \Talk\Conversations\Conversation $conversations
@return object|bool | [
"/",
"*",
"Make",
"new",
"message",
"collections",
"to",
"response",
"with",
"formatted",
"data"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L117-L133 |
nahid/talk | src/Talk.php | Talk.newConversation | protected function newConversation($receiverId)
{
$conversationId = $this->isConversationExists($receiverId);
$user = $this->getSerializeUser($this->authUserId, $receiverId);
if ($conversationId === false) {
$conversation = $this->conversation->create([
'user_one... | php | protected function newConversation($receiverId)
{
$conversationId = $this->isConversationExists($receiverId);
$user = $this->getSerializeUser($this->authUserId, $receiverId);
if ($conversationId === false) {
$conversation = $this->conversation->create([
'user_one... | [
"protected",
"function",
"newConversation",
"(",
"$",
"receiverId",
")",
"{",
"$",
"conversationId",
"=",
"$",
"this",
"->",
"isConversationExists",
"(",
"$",
"receiverId",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getSerializeUser",
"(",
"$",
"this",
... | make new conversation the given receiverId with currently loggedin user.
@param int $receiverId
@return int | [
"make",
"new",
"conversation",
"the",
"given",
"receiverId",
"with",
"currently",
"loggedin",
"user",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L142-L160 |
nahid/talk | src/Talk.php | Talk.isConversationExists | public function isConversationExists($userId)
{
if (empty($userId)) {
return false;
}
$user = $this->getSerializeUser($this->authUserId, $userId);
return $this->conversation->isExistsAmongTwoUsers($user['one'], $user['two']);
} | php | public function isConversationExists($userId)
{
if (empty($userId)) {
return false;
}
$user = $this->getSerializeUser($this->authUserId, $userId);
return $this->conversation->isExistsAmongTwoUsers($user['one'], $user['two']);
} | [
"public",
"function",
"isConversationExists",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"getSerializeUser",
"(",
"$",
"this",
"->",
"authUserId... | make sure is this conversation exist for this user with currently loggedin user.
@param int $userId
@return bool|int | [
"make",
"sure",
"is",
"this",
"conversation",
"exist",
"for",
"this",
"user",
"with",
"currently",
"loggedin",
"user",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L202-L211 |
nahid/talk | src/Talk.php | Talk.isAuthenticUser | public function isAuthenticUser($conversationId, $userId)
{
if ($conversationId && $userId) {
return $this->conversation->isUserExists($conversationId, $userId);
}
return false;
} | php | public function isAuthenticUser($conversationId, $userId)
{
if ($conversationId && $userId) {
return $this->conversation->isUserExists($conversationId, $userId);
}
return false;
} | [
"public",
"function",
"isAuthenticUser",
"(",
"$",
"conversationId",
",",
"$",
"userId",
")",
"{",
"if",
"(",
"$",
"conversationId",
"&&",
"$",
"userId",
")",
"{",
"return",
"$",
"this",
"->",
"conversation",
"->",
"isUserExists",
"(",
"$",
"conversationId",... | check the given user exist for the given conversation.
@param int $conversationId
@param int $userId
@return bool | [
"check",
"the",
"given",
"user",
"exist",
"for",
"the",
"given",
"conversation",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L221-L228 |
nahid/talk | src/Talk.php | Talk.sendMessage | public function sendMessage($conversatonId, $message)
{
if ($conversatonId && $message) {
if ($this->conversation->existsById($conversatonId)) {
$message = $this->makeMessage($conversatonId, $message);
return $message;
}
}
return fals... | php | public function sendMessage($conversatonId, $message)
{
if ($conversatonId && $message) {
if ($this->conversation->existsById($conversatonId)) {
$message = $this->makeMessage($conversatonId, $message);
return $message;
}
}
return fals... | [
"public",
"function",
"sendMessage",
"(",
"$",
"conversatonId",
",",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"conversatonId",
"&&",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"conversation",
"->",
"existsById",
"(",
"$",
"conversatonId",
"... | send a message by using converstionid.
@param int $conversationId
@param string $message
@return \Nahid\Talk\Messages\Message|bool | [
"send",
"a",
"message",
"by",
"using",
"converstionid",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L238-L249 |
nahid/talk | src/Talk.php | Talk.sendMessageByUserId | public function sendMessageByUserId($receiverId, $message)
{
if ($conversationId = $this->isConversationExists($receiverId)) {
$message = $this->makeMessage($conversationId, $message);
return $message;
}
$convId = $this->newConversation($receiverId);
$messag... | php | public function sendMessageByUserId($receiverId, $message)
{
if ($conversationId = $this->isConversationExists($receiverId)) {
$message = $this->makeMessage($conversationId, $message);
return $message;
}
$convId = $this->newConversation($receiverId);
$messag... | [
"public",
"function",
"sendMessageByUserId",
"(",
"$",
"receiverId",
",",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"conversationId",
"=",
"$",
"this",
"->",
"isConversationExists",
"(",
"$",
"receiverId",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
... | create a new message by using receiverid.
@param int $receiverId
@param string $message
@return \Nahid\Talk\Messages\Message | [
"create",
"a",
"new",
"message",
"by",
"using",
"receiverid",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L259-L271 |
nahid/talk | src/Talk.php | Talk.getInbox | public function getInbox($order = 'desc', $offset = 0, $take = 20)
{
return $this->conversation->threads($this->authUserId, $order, $offset, $take);
} | php | public function getInbox($order = 'desc', $offset = 0, $take = 20)
{
return $this->conversation->threads($this->authUserId, $order, $offset, $take);
} | [
"public",
"function",
"getInbox",
"(",
"$",
"order",
"=",
"'desc'",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"take",
"=",
"20",
")",
"{",
"return",
"$",
"this",
"->",
"conversation",
"->",
"threads",
"(",
"$",
"this",
"->",
"authUserId",
",",
"$",
"... | fetch all inbox for currently loggedin user with pagination.
@param int $offset
@param int $take
@return array | [
"fetch",
"all",
"inbox",
"for",
"currently",
"loggedin",
"user",
"with",
"pagination",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L281-L284 |
nahid/talk | src/Talk.php | Talk.getInboxAll | public function getInboxAll($order = 'desc', $offset = 0, $take = 20)
{
return $this->conversation->threadsAll($this->authUserId, $order, $offset, $take);
} | php | public function getInboxAll($order = 'desc', $offset = 0, $take = 20)
{
return $this->conversation->threadsAll($this->authUserId, $order, $offset, $take);
} | [
"public",
"function",
"getInboxAll",
"(",
"$",
"order",
"=",
"'desc'",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"take",
"=",
"20",
")",
"{",
"return",
"$",
"this",
"->",
"conversation",
"->",
"threadsAll",
"(",
"$",
"this",
"->",
"authUserId",
",",
"$... | fetch all inbox with soft deleted message for currently loggedin user with pagination.
@param int $offset
@param int $take
@return array | [
"fetch",
"all",
"inbox",
"with",
"soft",
"deleted",
"message",
"for",
"currently",
"loggedin",
"user",
"with",
"pagination",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L294-L297 |
nahid/talk | src/Talk.php | Talk.getConversationsById | public function getConversationsById($conversationId, $offset = 0, $take = 20)
{
$conversations = $this->conversation->getMessagesById($conversationId, $this->authUserId, $offset, $take);
return $this->makeMessageCollection($conversations);
} | php | public function getConversationsById($conversationId, $offset = 0, $take = 20)
{
$conversations = $this->conversation->getMessagesById($conversationId, $this->authUserId, $offset, $take);
return $this->makeMessageCollection($conversations);
} | [
"public",
"function",
"getConversationsById",
"(",
"$",
"conversationId",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"take",
"=",
"20",
")",
"{",
"$",
"conversations",
"=",
"$",
"this",
"->",
"conversation",
"->",
"getMessagesById",
"(",
"$",
"conversationId",
... | fetch all conversation by using coversation id.
@param int $conversationId
@param int $offset = 0
@param int $take = 20
@return \Nahid\Talk\Messages\Message | [
"fetch",
"all",
"conversation",
"by",
"using",
"coversation",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L334-L339 |
nahid/talk | src/Talk.php | Talk.getConversationsAllById | public function getConversationsAllById($conversationId, $offset = 0, $take = 20)
{
$conversations = $this->conversation->getMessagesAllById($conversationId, $offset, $take);
return $this->makeMessageCollection($conversations);
} | php | public function getConversationsAllById($conversationId, $offset = 0, $take = 20)
{
$conversations = $this->conversation->getMessagesAllById($conversationId, $offset, $take);
return $this->makeMessageCollection($conversations);
} | [
"public",
"function",
"getConversationsAllById",
"(",
"$",
"conversationId",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"take",
"=",
"20",
")",
"{",
"$",
"conversations",
"=",
"$",
"this",
"->",
"conversation",
"->",
"getMessagesAllById",
"(",
"$",
"conversatio... | fetch all conversation with soft deleted messages by using coversation id.
@param int $conversationId
@param int $offset = 0
@param int $take = 20
@return \Nahid\Talk\Messages\Message | [
"fetch",
"all",
"conversation",
"with",
"soft",
"deleted",
"messages",
"by",
"using",
"coversation",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L350-L355 |
nahid/talk | src/Talk.php | Talk.getConversationsByUserId | public function getConversationsByUserId($senderId, $offset = 0, $take = 20)
{
$conversationId = $this->isConversationExists($senderId, $this->authUserId);
if ($conversationId) {
return $this->getConversationsById($conversationId, $offset, $take);
}
return false;
} | php | public function getConversationsByUserId($senderId, $offset = 0, $take = 20)
{
$conversationId = $this->isConversationExists($senderId, $this->authUserId);
if ($conversationId) {
return $this->getConversationsById($conversationId, $offset, $take);
}
return false;
} | [
"public",
"function",
"getConversationsByUserId",
"(",
"$",
"senderId",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"take",
"=",
"20",
")",
"{",
"$",
"conversationId",
"=",
"$",
"this",
"->",
"isConversationExists",
"(",
"$",
"senderId",
",",
"$",
"this",
"-... | create a new message by using sender id.
@param int $senderId
@param int $offset = 0
@param int $take = 20
@return \Nahid\Talk\Messages\Message|bool | [
"create",
"a",
"new",
"message",
"by",
"using",
"sender",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L366-L374 |
nahid/talk | src/Talk.php | Talk.getConversationsAllByUserId | public function getConversationsAllByUserId($senderId, $offset = 0, $take = 20)
{
$conversationId = $this->isConversationExists($senderId, $this->authUserId);
if ($conversationId) {
return $this->getConversationsAllById($conversationId, $offset, $take);
}
return false;
... | php | public function getConversationsAllByUserId($senderId, $offset = 0, $take = 20)
{
$conversationId = $this->isConversationExists($senderId, $this->authUserId);
if ($conversationId) {
return $this->getConversationsAllById($conversationId, $offset, $take);
}
return false;
... | [
"public",
"function",
"getConversationsAllByUserId",
"(",
"$",
"senderId",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"take",
"=",
"20",
")",
"{",
"$",
"conversationId",
"=",
"$",
"this",
"->",
"isConversationExists",
"(",
"$",
"senderId",
",",
"$",
"this",
... | create a new message by using sender id.
@param int $senderId
@param int $offset = 0
@param int $take = 20
@return \Nahid\Talk\Messages\Message|bool | [
"create",
"a",
"new",
"message",
"by",
"using",
"sender",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L385-L393 |
nahid/talk | src/Talk.php | Talk.readMessage | public function readMessage($messageId = null)
{
if (!is_null($messageId)) {
$message = $this->message->with(['sender', 'conversation'])->find($messageId);
if ($message->coversation->user_one == $this->authUserId || $message->coversation->user_two == $this->authUserId) {
... | php | public function readMessage($messageId = null)
{
if (!is_null($messageId)) {
$message = $this->message->with(['sender', 'conversation'])->find($messageId);
if ($message->coversation->user_one == $this->authUserId || $message->coversation->user_two == $this->authUserId) {
... | [
"public",
"function",
"readMessage",
"(",
"$",
"messageId",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"messageId",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"message",
"->",
"with",
"(",
"[",
"'sender'",
",",
"'conversa... | read a single message by message id.
@param int $messageId
@return \Nahid\Talk\Messages\Message|bool | [
"read",
"a",
"single",
"message",
"by",
"message",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L450-L461 |
nahid/talk | src/Talk.php | Talk.makeSeen | public function makeSeen($messageId)
{
$seen = $this->message->update($messageId, ['is_seen' => 1]);
if ($seen) {
return true;
}
return false;
} | php | public function makeSeen($messageId)
{
$seen = $this->message->update($messageId, ['is_seen' => 1]);
if ($seen) {
return true;
}
return false;
} | [
"public",
"function",
"makeSeen",
"(",
"$",
"messageId",
")",
"{",
"$",
"seen",
"=",
"$",
"this",
"->",
"message",
"->",
"update",
"(",
"$",
"messageId",
",",
"[",
"'is_seen'",
"=>",
"1",
"]",
")",
";",
"if",
"(",
"$",
"seen",
")",
"{",
"return",
... | make a message as seen.
@param int $messageId
@return bool | [
"make",
"a",
"message",
"as",
"seen",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L470-L478 |
nahid/talk | src/Talk.php | Talk.getReceiverInfo | public function getReceiverInfo($conversationId)
{
$conversation = $this->conversation->find($conversationId);
$receiver = '';
if ($conversation->user_one == $this->authUserId) {
$receiver = $conversation->user_two;
} else {
$receiver = $conversation->user_one... | php | public function getReceiverInfo($conversationId)
{
$conversation = $this->conversation->find($conversationId);
$receiver = '';
if ($conversation->user_one == $this->authUserId) {
$receiver = $conversation->user_two;
} else {
$receiver = $conversation->user_one... | [
"public",
"function",
"getReceiverInfo",
"(",
"$",
"conversationId",
")",
"{",
"$",
"conversation",
"=",
"$",
"this",
"->",
"conversation",
"->",
"find",
"(",
"$",
"conversationId",
")",
";",
"$",
"receiver",
"=",
"''",
";",
"if",
"(",
"$",
"conversation",... | get receiver information for this conversation.
@param int $conversationId
@return UserModel
@deprecated since version 2.0.0 Remove it from version 2.0.2 | [
"get",
"receiver",
"information",
"for",
"this",
"conversation",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L489-L503 |
nahid/talk | src/Talk.php | Talk.deleteForever | public function deleteForever($messageId)
{
$deleteMessage = $this->message->delete($messageId);
if ($deleteMessage) {
return true;
}
return false;
} | php | public function deleteForever($messageId)
{
$deleteMessage = $this->message->delete($messageId);
if ($deleteMessage) {
return true;
}
return false;
} | [
"public",
"function",
"deleteForever",
"(",
"$",
"messageId",
")",
"{",
"$",
"deleteMessage",
"=",
"$",
"this",
"->",
"message",
"->",
"delete",
"(",
"$",
"messageId",
")",
";",
"if",
"(",
"$",
"deleteMessage",
")",
"{",
"return",
"true",
";",
"}",
"re... | permanently delete message for this id.
@param int $messageId
@return bool | [
"permanently",
"delete",
"message",
"for",
"this",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L524-L532 |
nahid/talk | src/Talk.php | Talk.deleteConversations | public function deleteConversations($id)
{
$deleteConversation = $this->conversation->delete($id);
if ($deleteConversation) {
return $this->message->deleteMessages($id);
}
return false;
} | php | public function deleteConversations($id)
{
$deleteConversation = $this->conversation->delete($id);
if ($deleteConversation) {
return $this->message->deleteMessages($id);
}
return false;
} | [
"public",
"function",
"deleteConversations",
"(",
"$",
"id",
")",
"{",
"$",
"deleteConversation",
"=",
"$",
"this",
"->",
"conversation",
"->",
"delete",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"deleteConversation",
")",
"{",
"return",
"$",
"this",
"->... | delete message threat or conversation by conversation id.
@param int $id
@return bool | [
"delete",
"message",
"threat",
"or",
"conversation",
"by",
"conversation",
"id",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Talk.php#L541-L549 |
nahid/talk | src/Messages/Message.php | Message.getHumansTimeAttribute | public function getHumansTimeAttribute()
{
$date = $this->created_at;
$now = $date->now();
return $date->diffForHumans($now, true);
} | php | public function getHumansTimeAttribute()
{
$date = $this->created_at;
$now = $date->now();
return $date->diffForHumans($now, true);
} | [
"public",
"function",
"getHumansTimeAttribute",
"(",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"created_at",
";",
"$",
"now",
"=",
"$",
"date",
"->",
"now",
"(",
")",
";",
"return",
"$",
"date",
"->",
"diffForHumans",
"(",
"$",
"now",
",",
"true... | /*
make dynamic attribute for human readable time
@return string | [
"/",
"*",
"make",
"dynamic",
"attribute",
"for",
"human",
"readable",
"time"
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Messages/Message.php#L33-L39 |
nahid/talk | src/Html/HtmlString.php | HtmlString.toHtml | public function toHtml()
{
if (config('talk.oembed.enabled')) {
$parsedUrl = parse_url(config('talk.oembed.url'));
$this->driver->addProvider(
$parsedUrl['host'],
Adapter::class,
[
'api_key' => config('talk.oembed.ke... | php | public function toHtml()
{
if (config('talk.oembed.enabled')) {
$parsedUrl = parse_url(config('talk.oembed.url'));
$this->driver->addProvider(
$parsedUrl['host'],
Adapter::class,
[
'api_key' => config('talk.oembed.ke... | [
"public",
"function",
"toHtml",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'talk.oembed.enabled'",
")",
")",
"{",
"$",
"parsedUrl",
"=",
"parse_url",
"(",
"config",
"(",
"'talk.oembed.url'",
")",
")",
";",
"$",
"this",
"->",
"driver",
"->",
"addProvider",
... | Get content as a string of HTML.
@return string | [
"Get",
"content",
"as",
"a",
"string",
"of",
"HTML",
"."
] | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Html/HtmlString.php#L38-L54 |
nahid/talk | src/Embera/Adapter.php | Adapter.validateUrl | protected function validateUrl()
{
$parsedUrl = parse_url($this->apiUrl);
return preg_match('#' . $parsedUrl['host'] . '#i', (string)$this->url);
} | php | protected function validateUrl()
{
$parsedUrl = parse_url($this->apiUrl);
return preg_match('#' . $parsedUrl['host'] . '#i', (string)$this->url);
} | [
"protected",
"function",
"validateUrl",
"(",
")",
"{",
"$",
"parsedUrl",
"=",
"parse_url",
"(",
"$",
"this",
"->",
"apiUrl",
")",
";",
"return",
"preg_match",
"(",
"'#'",
".",
"$",
"parsedUrl",
"[",
"'host'",
"]",
".",
"'#i'",
",",
"(",
"string",
")",
... | Validates that the url belongs to this service.
Should be implemented on all children and should
return a boolean (preg_match returns 0 or 1 that
is why I'm also allowing 'int' as a return type).
The current url is made available via $this->url
@return bool|int | [
"Validates",
"that",
"the",
"url",
"belongs",
"to",
"this",
"service",
".",
"Should",
"be",
"implemented",
"on",
"all",
"children",
"and",
"should",
"return",
"a",
"boolean",
"(",
"preg_match",
"returns",
"0",
"or",
"1",
"that",
"is",
"why",
"I",
"m",
"a... | train | https://github.com/nahid/talk/blob/832a2daa3c6602cc01654fdde22c7525204daa03/src/Embera/Adapter.php#L46-L51 |
nelmio/NelmioApiDocBundle | ModelDescriber/JMSModelDescriber.php | JMSModelDescriber.describe | public function describe(Model $model, Schema $schema)
{
$className = $model->getType()->getClassName();
$metadata = $this->factory->getMetadataForClass($className);
if (null === $metadata) {
throw new \InvalidArgumentException(sprintf('No metadata found for class %s.', $classNam... | php | public function describe(Model $model, Schema $schema)
{
$className = $model->getType()->getClassName();
$metadata = $this->factory->getMetadataForClass($className);
if (null === $metadata) {
throw new \InvalidArgumentException(sprintf('No metadata found for class %s.', $classNam... | [
"public",
"function",
"describe",
"(",
"Model",
"$",
"model",
",",
"Schema",
"$",
"schema",
")",
"{",
"$",
"className",
"=",
"$",
"model",
"->",
"getType",
"(",
")",
"->",
"getClassName",
"(",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"facto... | {@inheritdoc} | [
"{"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/JMSModelDescriber.php#L62-L119 |
nelmio/NelmioApiDocBundle | ModelDescriber/JMSModelDescriber.php | JMSModelDescriber.supports | public function supports(Model $model): bool
{
$className = $model->getType()->getClassName();
try {
if ($this->factory->getMetadataForClass($className)) {
return true;
}
} catch (\ReflectionException $e) {
}
return false;
} | php | public function supports(Model $model): bool
{
$className = $model->getType()->getClassName();
try {
if ($this->factory->getMetadataForClass($className)) {
return true;
}
} catch (\ReflectionException $e) {
}
return false;
} | [
"public",
"function",
"supports",
"(",
"Model",
"$",
"model",
")",
":",
"bool",
"{",
"$",
"className",
"=",
"$",
"model",
"->",
"getType",
"(",
")",
"->",
"getClassName",
"(",
")",
";",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"factory",
"->",
"ge... | {@inheritdoc} | [
"{"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/JMSModelDescriber.php#L170-L182 |
nelmio/NelmioApiDocBundle | ModelDescriber/JMSModelDescriber.php | JMSModelDescriber.propertyTypeUsesGroups | private function propertyTypeUsesGroups(array $type)
{
if (array_key_exists($type['name'], $this->propertyTypeUseGroupsCache)) {
return $this->propertyTypeUseGroupsCache[$type['name']];
}
try {
$metadata = $this->factory->getMetadataForClass($type['name']);
... | php | private function propertyTypeUsesGroups(array $type)
{
if (array_key_exists($type['name'], $this->propertyTypeUseGroupsCache)) {
return $this->propertyTypeUseGroupsCache[$type['name']];
}
try {
$metadata = $this->factory->getMetadataForClass($type['name']);
... | [
"private",
"function",
"propertyTypeUsesGroups",
"(",
"array",
"$",
"type",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"type",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"propertyTypeUseGroupsCache",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pr... | @param array $type
@return bool|null | [
"@param",
"array",
"$type"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/JMSModelDescriber.php#L256-L280 |
nelmio/NelmioApiDocBundle | DependencyInjection/NelmioApiDocExtension.php | NelmioApiDocExtension.prepend | public function prepend(ContainerBuilder $container)
{
$container->prependExtensionConfig('framework', ['property_info' => ['enabled' => true]]);
$bundles = $container->getParameter('kernel.bundles');
// JMS Serializer support
if (isset($bundles['JMSSerializerBundle'])) {
... | php | public function prepend(ContainerBuilder $container)
{
$container->prependExtensionConfig('framework', ['property_info' => ['enabled' => true]]);
$bundles = $container->getParameter('kernel.bundles');
// JMS Serializer support
if (isset($bundles['JMSSerializerBundle'])) {
... | [
"public",
"function",
"prepend",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"container",
"->",
"prependExtensionConfig",
"(",
"'framework'",
",",
"[",
"'property_info'",
"=>",
"[",
"'enabled'",
"=>",
"true",
"]",
"]",
")",
";",
"$",
"bundles",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/DependencyInjection/NelmioApiDocExtension.php#L38-L48 |
nelmio/NelmioApiDocBundle | DependencyInjection/NelmioApiDocExtension.php | NelmioApiDocExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
// Filter routes
... | php | public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
// Filter routes
... | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"new",
"Configuration",
"(",
")",
",",
"$",
"configs",
")",
";",
"$",
"lo... | {@inheritdoc} | [
"{"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/DependencyInjection/NelmioApiDocExtension.php#L53-L183 |
nelmio/NelmioApiDocBundle | RouteDescriber/RouteDescriberTrait.php | RouteDescriberTrait.getOperations | private function getOperations(Swagger $api, Route $route): array
{
$operations = [];
$path = $api->getPaths()->get($this->normalizePath($route->getPath()));
$methods = $route->getMethods() ?: Swagger::$METHODS;
foreach ($methods as $method) {
$method = strtolower($method... | php | private function getOperations(Swagger $api, Route $route): array
{
$operations = [];
$path = $api->getPaths()->get($this->normalizePath($route->getPath()));
$methods = $route->getMethods() ?: Swagger::$METHODS;
foreach ($methods as $method) {
$method = strtolower($method... | [
"private",
"function",
"getOperations",
"(",
"Swagger",
"$",
"api",
",",
"Route",
"$",
"route",
")",
":",
"array",
"{",
"$",
"operations",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"api",
"->",
"getPaths",
"(",
")",
"->",
"get",
"(",
"$",
"this",
... | @internal
@return Operation[] | [
"@internal"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/RouteDescriber/RouteDescriberTrait.php#L28-L43 |
nelmio/NelmioApiDocBundle | ModelDescriber/Annotations/PropertyPhpDocReader.php | PropertyPhpDocReader.updateProperty | public function updateProperty(\ReflectionProperty $reflectionProperty, Schema $property)
{
try {
$docBlock = $this->docBlockFactory->create($reflectionProperty);
} catch (\Exception $e) {
// ignore
return;
}
if (!$title = $docBlock->getSummary())... | php | public function updateProperty(\ReflectionProperty $reflectionProperty, Schema $property)
{
try {
$docBlock = $this->docBlockFactory->create($reflectionProperty);
} catch (\Exception $e) {
// ignore
return;
}
if (!$title = $docBlock->getSummary())... | [
"public",
"function",
"updateProperty",
"(",
"\\",
"ReflectionProperty",
"$",
"reflectionProperty",
",",
"Schema",
"$",
"property",
")",
"{",
"try",
"{",
"$",
"docBlock",
"=",
"$",
"this",
"->",
"docBlockFactory",
"->",
"create",
"(",
"$",
"reflectionProperty",
... | Update the Swagger information with information from the DocBlock comment. | [
"Update",
"the",
"Swagger",
"information",
"with",
"information",
"from",
"the",
"DocBlock",
"comment",
"."
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/Annotations/PropertyPhpDocReader.php#L36-L63 |
nelmio/NelmioApiDocBundle | ModelDescriber/BazingaHateoasModelDescriber.php | BazingaHateoasModelDescriber.describe | public function describe(Model $model, Schema $schema)
{
$this->JMSModelDescriber->describe($model, $schema);
/**
* @var ClassMetadata
*/
$metadata = $this->getHateoasMetadata($model);
if (null === $metadata) {
return;
}
$schema->setTyp... | php | public function describe(Model $model, Schema $schema)
{
$this->JMSModelDescriber->describe($model, $schema);
/**
* @var ClassMetadata
*/
$metadata = $this->getHateoasMetadata($model);
if (null === $metadata) {
return;
}
$schema->setTyp... | [
"public",
"function",
"describe",
"(",
"Model",
"$",
"model",
",",
"Schema",
"$",
"schema",
")",
"{",
"$",
"this",
"->",
"JMSModelDescriber",
"->",
"describe",
"(",
"$",
"model",
",",
"$",
"schema",
")",
";",
"/**\n * @var ClassMetadata\n */",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/BazingaHateoasModelDescriber.php#L46-L98 |
nelmio/NelmioApiDocBundle | ModelDescriber/BazingaHateoasModelDescriber.php | BazingaHateoasModelDescriber.supports | public function supports(Model $model): bool
{
return $this->JMSModelDescriber->supports($model) || null !== $this->getHateoasMetadata($model);
} | php | public function supports(Model $model): bool
{
return $this->JMSModelDescriber->supports($model) || null !== $this->getHateoasMetadata($model);
} | [
"public",
"function",
"supports",
"(",
"Model",
"$",
"model",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"JMSModelDescriber",
"->",
"supports",
"(",
"$",
"model",
")",
"||",
"null",
"!==",
"$",
"this",
"->",
"getHateoasMetadata",
"(",
"$",
"mode... | {@inheritdoc} | [
"{"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/BazingaHateoasModelDescriber.php#L117-L120 |
nelmio/NelmioApiDocBundle | ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php | SymfonyConstraintAnnotationReader.updateProperty | public function updateProperty(\ReflectionProperty $reflectionProperty, Schema $property)
{
$annotations = $this->annotationsReader->getPropertyAnnotations($reflectionProperty);
foreach ($annotations as $annotation) {
if ($annotation instanceof Assert\NotBlank || $annotation instanceof ... | php | public function updateProperty(\ReflectionProperty $reflectionProperty, Schema $property)
{
$annotations = $this->annotationsReader->getPropertyAnnotations($reflectionProperty);
foreach ($annotations as $annotation) {
if ($annotation instanceof Assert\NotBlank || $annotation instanceof ... | [
"public",
"function",
"updateProperty",
"(",
"\\",
"ReflectionProperty",
"$",
"reflectionProperty",
",",
"Schema",
"$",
"property",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"annotationsReader",
"->",
"getPropertyAnnotations",
"(",
"$",
"reflectionProper... | Update the given property and schema with defined Symfony constraints. | [
"Update",
"the",
"given",
"property",
"and",
"schema",
"with",
"defined",
"Symfony",
"constraints",
"."
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php#L41-L82 |
nelmio/NelmioApiDocBundle | ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php | SymfonyConstraintAnnotationReader.getSchemaPropertyName | private function getSchemaPropertyName(Schema $property)
{
if (null === $this->schema) {
return null;
}
foreach ($this->schema->getProperties() as $name => $schemaProperty) {
if ($schemaProperty === $property) {
return $name;
}
}
... | php | private function getSchemaPropertyName(Schema $property)
{
if (null === $this->schema) {
return null;
}
foreach ($this->schema->getProperties() as $name => $schemaProperty) {
if ($schemaProperty === $property) {
return $name;
}
}
... | [
"private",
"function",
"getSchemaPropertyName",
"(",
"Schema",
"$",
"property",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"schema",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"schema",
"->",
"getProperties",
"("... | Get assigned property name for property schema. | [
"Get",
"assigned",
"property",
"name",
"for",
"property",
"schema",
"."
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php#L92-L105 |
nelmio/NelmioApiDocBundle | ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php | SymfonyConstraintAnnotationReader.appendPattern | private function appendPattern(Schema $property, $newPattern)
{
if (null === $newPattern) {
return;
}
if (null !== $property->getPattern()) {
$property->setPattern(sprintf('%s, %s', $property->getPattern(), $newPattern));
} else {
$property->setPa... | php | private function appendPattern(Schema $property, $newPattern)
{
if (null === $newPattern) {
return;
}
if (null !== $property->getPattern()) {
$property->setPattern(sprintf('%s, %s', $property->getPattern(), $newPattern));
} else {
$property->setPa... | [
"private",
"function",
"appendPattern",
"(",
"Schema",
"$",
"property",
",",
"$",
"newPattern",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"newPattern",
")",
"{",
"return",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"property",
"->",
"getPattern",
"(",
")"... | Append the pattern from the constraint to the existing pattern. | [
"Append",
"the",
"pattern",
"from",
"the",
"constraint",
"to",
"the",
"existing",
"pattern",
"."
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php#L110-L121 |
nelmio/NelmioApiDocBundle | ModelDescriber/FormModelDescriber.php | FormModelDescriber.findFormType | private function findFormType(FormConfigBuilderInterface $config, $property)
{
$type = $config->getType();
if (!$builtinFormType = $this->getBuiltinFormType($type)) {
// if form type is not builtin in Form component.
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, fal... | php | private function findFormType(FormConfigBuilderInterface $config, $property)
{
$type = $config->getType();
if (!$builtinFormType = $this->getBuiltinFormType($type)) {
// if form type is not builtin in Form component.
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, fal... | [
"private",
"function",
"findFormType",
"(",
"FormConfigBuilderInterface",
"$",
"config",
",",
"$",
"property",
")",
"{",
"$",
"type",
"=",
"$",
"config",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"!",
"$",
"builtinFormType",
"=",
"$",
"this",
"->",
"get... | Finds and sets the schema type on $property based on $config info.
Returns true if a native Swagger type was found, false otherwise
@param FormConfigBuilderInterface $config
@param $property | [
"Finds",
"and",
"sets",
"the",
"schema",
"type",
"on",
"$property",
"based",
"on",
"$config",
"info",
"."
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/FormModelDescriber.php#L98-L228 |
nelmio/NelmioApiDocBundle | ModelDescriber/FormModelDescriber.php | FormModelDescriber.getBuiltinFormType | private function getBuiltinFormType(ResolvedFormTypeInterface $type)
{
do {
$class = get_class($type->getInnerType());
if (FormType::class === $class) {
return null;
}
if ('entity' === $type->getBlockPrefix() || 'document' === $type->getBlock... | php | private function getBuiltinFormType(ResolvedFormTypeInterface $type)
{
do {
$class = get_class($type->getInnerType());
if (FormType::class === $class) {
return null;
}
if ('entity' === $type->getBlockPrefix() || 'document' === $type->getBlock... | [
"private",
"function",
"getBuiltinFormType",
"(",
"ResolvedFormTypeInterface",
"$",
"type",
")",
"{",
"do",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"type",
"->",
"getInnerType",
"(",
")",
")",
";",
"if",
"(",
"FormType",
"::",
"class",
"===",
"$",
... | @param ResolvedFormTypeInterface $type
@return ResolvedFormTypeInterface|null | [
"@param",
"ResolvedFormTypeInterface",
"$type"
] | train | https://github.com/nelmio/NelmioApiDocBundle/blob/eb255010a0ba8e83d23dfcf33df9e0af6e7b0533/ModelDescriber/FormModelDescriber.php#L267-L286 |
spatie/laravel-tags | src/HasTags.php | HasTags.scopeWithAllTags | public function scopeWithAllTags(Builder $query, $tags, string $type = null): Builder
{
$tags = static::convertToTags($tags, $type);
collect($tags)->each(function ($tag) use ($query) {
$query->whereIn("{$this->getTable()}.{$this->getKeyName()}", function ($query) use ($tag) {
... | php | public function scopeWithAllTags(Builder $query, $tags, string $type = null): Builder
{
$tags = static::convertToTags($tags, $type);
collect($tags)->each(function ($tag) use ($query) {
$query->whereIn("{$this->getTable()}.{$this->getKeyName()}", function ($query) use ($tag) {
... | [
"public",
"function",
"scopeWithAllTags",
"(",
"Builder",
"$",
"query",
",",
"$",
"tags",
",",
"string",
"$",
"type",
"=",
"null",
")",
":",
"Builder",
"{",
"$",
"tags",
"=",
"static",
"::",
"convertToTags",
"(",
"$",
"tags",
",",
"$",
"type",
")",
"... | @param \Illuminate\Database\Eloquent\Builder $query
@param array|\ArrayAccess|\Spatie\Tags\Tag $tags
@return \Illuminate\Database\Eloquent\Builder | [
"@param",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Eloquent",
"\\",
"Builder",
"$query",
"@param",
"array|",
"\\",
"ArrayAccess|",
"\\",
"Spatie",
"\\",
"Tags",
"\\",
"Tag",
"$tags"
] | train | https://github.com/spatie/laravel-tags/blob/b452ce85a285173028917cbc29dae2d63b184033/src/HasTags.php#L79-L92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.