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
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.wait
public static function wait(callable $onExit) { $status = null; //pid<0:子进程都没了 //pid>0:捕获到一个子进程退出的情况 //pid=0:没有捕获到退出的子进程 while (($pid = pcntl_waitpid(-1, $status, WNOHANG)) >= 0) { if ($pid) { // ... (callback, pid, exitCode, status) $onExit($pid, pcntl_wexitstatus($status), $status); } else { usleep(50000); } } return true; }
php
public static function wait(callable $onExit) { $status = null; //pid<0:子进程都没了 //pid>0:捕获到一个子进程退出的情况 //pid=0:没有捕获到退出的子进程 while (($pid = pcntl_waitpid(-1, $status, WNOHANG)) >= 0) { if ($pid) { // ... (callback, pid, exitCode, status) $onExit($pid, pcntl_wexitstatus($status), $status); } else { usleep(50000); } } return true; }
[ "public", "static", "function", "wait", "(", "callable", "$", "onExit", ")", "{", "$", "status", "=", "null", ";", "//pid<0:子进程都没了", "//pid>0:捕获到一个子进程退出的情况", "//pid=0:没有捕获到退出的子进程", "while", "(", "(", "$", "pid", "=", "pcntl_waitpid", "(", "-", "1", ",", "$", "status", ",", "WNOHANG", ")", ")", ">=", "0", ")", "{", "if", "(", "$", "pid", ")", "{", "// ... (callback, pid, exitCode, status)", "$", "onExit", "(", "$", "pid", ",", "pcntl_wexitstatus", "(", "$", "status", ")", ",", "$", "status", ")", ";", "}", "else", "{", "usleep", "(", "50000", ")", ";", "}", "}", "return", "true", ";", "}" ]
wait child exit. @param callable $onExit @return bool
[ "wait", "child", "exit", "." ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L115-L132
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.stopChildren
public static function stopChildren(array $children, $signal = SIGTERM, array $events = []) { if (!$children) { return false; } $events = array_merge([ 'beforeStops' => null, 'beforeStop' => null, ], $events); $signals = [ SIGINT => 'SIGINT(Ctrl+C)', SIGTERM => 'SIGTERM', SIGKILL => 'SIGKILL', ]; if ($cb = $events['beforeStops']) { $cb($signal, $signals[$signal]); } foreach ($children as $pid => $child) { if ($cb = $events['beforeStop']) { $cb($pid, $child); } // send exit signal. self::sendSignal($pid, $signal); } return true; }
php
public static function stopChildren(array $children, $signal = SIGTERM, array $events = []) { if (!$children) { return false; } $events = array_merge([ 'beforeStops' => null, 'beforeStop' => null, ], $events); $signals = [ SIGINT => 'SIGINT(Ctrl+C)', SIGTERM => 'SIGTERM', SIGKILL => 'SIGKILL', ]; if ($cb = $events['beforeStops']) { $cb($signal, $signals[$signal]); } foreach ($children as $pid => $child) { if ($cb = $events['beforeStop']) { $cb($pid, $child); } // send exit signal. self::sendSignal($pid, $signal); } return true; }
[ "public", "static", "function", "stopChildren", "(", "array", "$", "children", ",", "$", "signal", "=", "SIGTERM", ",", "array", "$", "events", "=", "[", "]", ")", "{", "if", "(", "!", "$", "children", ")", "{", "return", "false", ";", "}", "$", "events", "=", "array_merge", "(", "[", "'beforeStops'", "=>", "null", ",", "'beforeStop'", "=>", "null", ",", "]", ",", "$", "events", ")", ";", "$", "signals", "=", "[", "SIGINT", "=>", "'SIGINT(Ctrl+C)'", ",", "SIGTERM", "=>", "'SIGTERM'", ",", "SIGKILL", "=>", "'SIGKILL'", ",", "]", ";", "if", "(", "$", "cb", "=", "$", "events", "[", "'beforeStops'", "]", ")", "{", "$", "cb", "(", "$", "signal", ",", "$", "signals", "[", "$", "signal", "]", ")", ";", "}", "foreach", "(", "$", "children", "as", "$", "pid", "=>", "$", "child", ")", "{", "if", "(", "$", "cb", "=", "$", "events", "[", "'beforeStop'", "]", ")", "{", "$", "cb", "(", "$", "pid", ",", "$", "child", ")", ";", "}", "// send exit signal.", "self", "::", "sendSignal", "(", "$", "pid", ",", "$", "signal", ")", ";", "}", "return", "true", ";", "}" ]
Stops all running children @param array $children [ 'pid' => [ 'id' => worker id ], ... ... ] @param int $signal @param array $events [ 'beforeStops' => function ($sigText) { echo "Stopping processes({$sigText}) ...\n"; }, 'beforeStop' => function ($pid, $info) { echo "Stopping process(PID:$pid)\n"; } ] @return bool
[ "Stops", "all", "running", "children" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L155-L185
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.kill
public static function kill($pid, $force = false, $timeout = 3) { return self::sendSignal($pid, $force ? SIGKILL : SIGTERM, $timeout); }
php
public static function kill($pid, $force = false, $timeout = 3) { return self::sendSignal($pid, $force ? SIGKILL : SIGTERM, $timeout); }
[ "public", "static", "function", "kill", "(", "$", "pid", ",", "$", "force", "=", "false", ",", "$", "timeout", "=", "3", ")", "{", "return", "self", "::", "sendSignal", "(", "$", "pid", ",", "$", "force", "?", "SIGKILL", ":", "SIGTERM", ",", "$", "timeout", ")", ";", "}" ]
send kill signal to the process @param int $pid @param bool $force @param int $timeout @return bool
[ "send", "kill", "signal", "to", "the", "process" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L198-L201
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.killAndWait
public static function killAndWait($pid, $signal = SIGTERM, $name = 'process', $waitTime = 30) { // do stop if (!self::kill($signal)) { Cli::stderr("Send stop signal to the $name(PID:$pid) failed!"); return false; } // not wait, only send signal if ($waitTime <= 0) { Cli::stdout("The $name process stopped"); return true; } $startTime = time(); Cli::stdout('Stopping .', false); // wait exit while (true) { if (!self::isRunning($pid)) { break; } if (time() - $startTime > $waitTime) { Cli::stderr("Stop the $name(PID:$pid) failed(timeout)!"); break; } Cli::stdout('.', false); sleep(1); } return true; }
php
public static function killAndWait($pid, $signal = SIGTERM, $name = 'process', $waitTime = 30) { // do stop if (!self::kill($signal)) { Cli::stderr("Send stop signal to the $name(PID:$pid) failed!"); return false; } // not wait, only send signal if ($waitTime <= 0) { Cli::stdout("The $name process stopped"); return true; } $startTime = time(); Cli::stdout('Stopping .', false); // wait exit while (true) { if (!self::isRunning($pid)) { break; } if (time() - $startTime > $waitTime) { Cli::stderr("Stop the $name(PID:$pid) failed(timeout)!"); break; } Cli::stdout('.', false); sleep(1); } return true; }
[ "public", "static", "function", "killAndWait", "(", "$", "pid", ",", "$", "signal", "=", "SIGTERM", ",", "$", "name", "=", "'process'", ",", "$", "waitTime", "=", "30", ")", "{", "// do stop", "if", "(", "!", "self", "::", "kill", "(", "$", "signal", ")", ")", "{", "Cli", "::", "stderr", "(", "\"Send stop signal to the $name(PID:$pid) failed!\"", ")", ";", "return", "false", ";", "}", "// not wait, only send signal", "if", "(", "$", "waitTime", "<=", "0", ")", "{", "Cli", "::", "stdout", "(", "\"The $name process stopped\"", ")", ";", "return", "true", ";", "}", "$", "startTime", "=", "time", "(", ")", ";", "Cli", "::", "stdout", "(", "'Stopping .'", ",", "false", ")", ";", "// wait exit", "while", "(", "true", ")", "{", "if", "(", "!", "self", "::", "isRunning", "(", "$", "pid", ")", ")", "{", "break", ";", "}", "if", "(", "time", "(", ")", "-", "$", "startTime", ">", "$", "waitTime", ")", "{", "Cli", "::", "stderr", "(", "\"Stop the $name(PID:$pid) failed(timeout)!\"", ")", ";", "break", ";", "}", "Cli", "::", "stdout", "(", "'.'", ",", "false", ")", ";", "sleep", "(", "1", ")", ";", "}", "return", "true", ";", "}" ]
Do shutdown process and wait it exit. @param int $pid Master Pid @param int $signal @param string $name @param int $waitTime @return bool
[ "Do", "shutdown", "process", "and", "wait", "it", "exit", "." ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L211-L246
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.sendSignal
public static function sendSignal($pid, $signal, $timeout = 0) { if ($pid <= 0) { return false; } // do send if ($ret = posix_kill($pid, $signal)) { return true; } // don't want retry if ($timeout <= 0) { return $ret; } // failed, try again ... $timeout = $timeout > 0 && $timeout < 10 ? $timeout : 3; $startTime = time(); // retry stop if not stopped. while (true) { // success if (!$isRunning = @posix_kill($pid, 0)) { break; } // have been timeout if ((time() - $startTime) >= $timeout) { return false; } // try again kill $ret = posix_kill($pid, $signal); usleep(10000); } return $ret; }
php
public static function sendSignal($pid, $signal, $timeout = 0) { if ($pid <= 0) { return false; } // do send if ($ret = posix_kill($pid, $signal)) { return true; } // don't want retry if ($timeout <= 0) { return $ret; } // failed, try again ... $timeout = $timeout > 0 && $timeout < 10 ? $timeout : 3; $startTime = time(); // retry stop if not stopped. while (true) { // success if (!$isRunning = @posix_kill($pid, 0)) { break; } // have been timeout if ((time() - $startTime) >= $timeout) { return false; } // try again kill $ret = posix_kill($pid, $signal); usleep(10000); } return $ret; }
[ "public", "static", "function", "sendSignal", "(", "$", "pid", ",", "$", "signal", ",", "$", "timeout", "=", "0", ")", "{", "if", "(", "$", "pid", "<=", "0", ")", "{", "return", "false", ";", "}", "// do send", "if", "(", "$", "ret", "=", "posix_kill", "(", "$", "pid", ",", "$", "signal", ")", ")", "{", "return", "true", ";", "}", "// don't want retry", "if", "(", "$", "timeout", "<=", "0", ")", "{", "return", "$", "ret", ";", "}", "// failed, try again ...", "$", "timeout", "=", "$", "timeout", ">", "0", "&&", "$", "timeout", "<", "10", "?", "$", "timeout", ":", "3", ";", "$", "startTime", "=", "time", "(", ")", ";", "// retry stop if not stopped.", "while", "(", "true", ")", "{", "// success", "if", "(", "!", "$", "isRunning", "=", "@", "posix_kill", "(", "$", "pid", ",", "0", ")", ")", "{", "break", ";", "}", "// have been timeout", "if", "(", "(", "time", "(", ")", "-", "$", "startTime", ")", ">=", "$", "timeout", ")", "{", "return", "false", ";", "}", "// try again kill", "$", "ret", "=", "posix_kill", "(", "$", "pid", ",", "$", "signal", ")", ";", "usleep", "(", "10000", ")", ";", "}", "return", "$", "ret", ";", "}" ]
send signal to the process @param int $pid @param int $signal @param int $timeout @return bool
[ "send", "signal", "to", "the", "process" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L268-L307
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.changeScriptOwner
public static function changeScriptOwner($user, $group = '') { $uInfo = posix_getpwnam($user); if (!$uInfo || !isset($uInfo['uid'])) { throw new \RuntimeException("User ({$user}) not found."); } $uid = (int)$uInfo['uid']; // Get gid. if ($group) { if (!$gInfo = posix_getgrnam($group)) { throw new \RuntimeException("Group {$group} not exists", -300); } $gid = (int)$gInfo['gid']; } else { $gid = (int)$uInfo['gid']; } if (!posix_initgroups($uInfo['name'], $gid)) { throw new \RuntimeException("The user [{$user}] is not in the user group ID [GID:{$gid}]", -300); } posix_setgid($gid); if (posix_geteuid() !== $gid) { throw new \RuntimeException("Unable to change group to {$user} (UID: {$gid}).", -300); } posix_setuid($uid); if (posix_geteuid() !== $uid) { throw new \RuntimeException("Unable to change user to {$user} (UID: {$uid}).", -300); } }
php
public static function changeScriptOwner($user, $group = '') { $uInfo = posix_getpwnam($user); if (!$uInfo || !isset($uInfo['uid'])) { throw new \RuntimeException("User ({$user}) not found."); } $uid = (int)$uInfo['uid']; // Get gid. if ($group) { if (!$gInfo = posix_getgrnam($group)) { throw new \RuntimeException("Group {$group} not exists", -300); } $gid = (int)$gInfo['gid']; } else { $gid = (int)$uInfo['gid']; } if (!posix_initgroups($uInfo['name'], $gid)) { throw new \RuntimeException("The user [{$user}] is not in the user group ID [GID:{$gid}]", -300); } posix_setgid($gid); if (posix_geteuid() !== $gid) { throw new \RuntimeException("Unable to change group to {$user} (UID: {$gid}).", -300); } posix_setuid($uid); if (posix_geteuid() !== $uid) { throw new \RuntimeException("Unable to change user to {$user} (UID: {$uid}).", -300); } }
[ "public", "static", "function", "changeScriptOwner", "(", "$", "user", ",", "$", "group", "=", "''", ")", "{", "$", "uInfo", "=", "posix_getpwnam", "(", "$", "user", ")", ";", "if", "(", "!", "$", "uInfo", "||", "!", "isset", "(", "$", "uInfo", "[", "'uid'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"User ({$user}) not found.\"", ")", ";", "}", "$", "uid", "=", "(", "int", ")", "$", "uInfo", "[", "'uid'", "]", ";", "// Get gid.", "if", "(", "$", "group", ")", "{", "if", "(", "!", "$", "gInfo", "=", "posix_getgrnam", "(", "$", "group", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Group {$group} not exists\"", ",", "-", "300", ")", ";", "}", "$", "gid", "=", "(", "int", ")", "$", "gInfo", "[", "'gid'", "]", ";", "}", "else", "{", "$", "gid", "=", "(", "int", ")", "$", "uInfo", "[", "'gid'", "]", ";", "}", "if", "(", "!", "posix_initgroups", "(", "$", "uInfo", "[", "'name'", "]", ",", "$", "gid", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"The user [{$user}] is not in the user group ID [GID:{$gid}]\"", ",", "-", "300", ")", ";", "}", "posix_setgid", "(", "$", "gid", ")", ";", "if", "(", "posix_geteuid", "(", ")", "!==", "$", "gid", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Unable to change group to {$user} (UID: {$gid}).\"", ",", "-", "300", ")", ";", "}", "posix_setuid", "(", "$", "uid", ")", ";", "if", "(", "posix_geteuid", "(", ")", "!==", "$", "uid", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Unable to change user to {$user} (UID: {$uid}).\"", ",", "-", "300", ")", ";", "}", "}" ]
Set unix user and group for current process script. @param string $user @param string $group @throws \RuntimeException
[ "Set", "unix", "user", "and", "group", "for", "current", "process", "script", "." ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L421-L457
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.runtime
public static function runtime($startTime, $startMem) { // 显示运行时间 $return['time'] = number_format(microtime(true) - $startTime, 4) . 's'; $startMem = (int)array_sum(explode(' ', $startMem)); $endMem = array_sum(explode(' ', memory_get_usage())); $return['memory'] = number_format(($endMem - $startMem) / 1024) . 'kb'; return $return; }
php
public static function runtime($startTime, $startMem) { // 显示运行时间 $return['time'] = number_format(microtime(true) - $startTime, 4) . 's'; $startMem = (int)array_sum(explode(' ', $startMem)); $endMem = array_sum(explode(' ', memory_get_usage())); $return['memory'] = number_format(($endMem - $startMem) / 1024) . 'kb'; return $return; }
[ "public", "static", "function", "runtime", "(", "$", "startTime", ",", "$", "startMem", ")", "{", "// 显示运行时间", "$", "return", "[", "'time'", "]", "=", "number_format", "(", "microtime", "(", "true", ")", "-", "$", "startTime", ",", "4", ")", ".", "'s'", ";", "$", "startMem", "=", "(", "int", ")", "array_sum", "(", "explode", "(", "' '", ",", "$", "startMem", ")", ")", ";", "$", "endMem", "=", "array_sum", "(", "explode", "(", "' '", ",", "memory_get_usage", "(", ")", ")", ")", ";", "$", "return", "[", "'memory'", "]", "=", "number_format", "(", "(", "$", "endMem", "-", "$", "startMem", ")", "/", "1024", ")", ".", "'kb'", ";", "return", "$", "return", ";", "}" ]
获取资源消耗 @param int $startTime @param int $startMem @return array
[ "获取资源消耗" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L465-L474
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.getPidFromFile
public static function getPidFromFile($pidFile, $check = false) { if ($pidFile && file_exists($pidFile)) { $pid = (int)file_get_contents($pidFile); // check if ($check && self::isRunning($pid)) { return $pid; } unlink($pidFile); } return 0; }
php
public static function getPidFromFile($pidFile, $check = false) { if ($pidFile && file_exists($pidFile)) { $pid = (int)file_get_contents($pidFile); // check if ($check && self::isRunning($pid)) { return $pid; } unlink($pidFile); } return 0; }
[ "public", "static", "function", "getPidFromFile", "(", "$", "pidFile", ",", "$", "check", "=", "false", ")", "{", "if", "(", "$", "pidFile", "&&", "file_exists", "(", "$", "pidFile", ")", ")", "{", "$", "pid", "=", "(", "int", ")", "file_get_contents", "(", "$", "pidFile", ")", ";", "// check", "if", "(", "$", "check", "&&", "self", "::", "isRunning", "(", "$", "pid", ")", ")", "{", "return", "$", "pid", ";", "}", "unlink", "(", "$", "pidFile", ")", ";", "}", "return", "0", ";", "}" ]
get Pid from File @param string $pidFile @param bool $check @return int
[ "get", "Pid", "from", "File" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L482-L496
odiaseo/pagebuilder
src/PageBuilder/Model/SiteRankModel.php
SiteRankModel.getReportQuery
public function getReportQuery($siteId, $fromDate, $toDate, $filter, $limit = null) { $siteList = []; $filter = strtolower($filter); if (empty($fromDate)) { $fromDate = (new DateTime('first day of the year'))->format('Y-m-d'); } if (empty($toDate)) { $toDate = (new DateTime('last day of this month'))->format('Y-m-d'); } $builder = $this->getEntityManager()->createQuerybuilder(); $query = $builder->select( [ '(e.popularity) total', 'DATE(e.rankedAt) regDay', 's.domain domain', '1 valid', 'e.rankedAt createdAt', ] )->from($this->getEntity(), 'e') ->innerJoin('e.site', 's') ->where('e.rankedAt >= :start') ->andWhere('e.rankedAt <= :end') //->andWhere('s.siteType = :siteType') ->addOrderBy('e.rankedAt') ->addOrderBy('e.popularity') ->addGroupBy('e.site') ->setParameters( [ ':start' => $fromDate, ':end' => $toDate, // ':siteType' => 1, ] ); if ($siteId) { $siteList = array_filter(array_unique(array_merge($siteList, (array)$siteId))); } elseif ($limit) { $subQueryBuilder = $builder = $this->getEntityManager()->createQuerybuilder(); $subQuery = $subQueryBuilder->select('f.id, s.id site_id') ->from($this->getEntity(), 'f') ->innerJoin('f.site', 's') ->groupBy('s.id') ->orderBy('f.popularity', 'ASC') ->setMaxResults($limit); foreach ($subQuery->getQuery()->getArrayResult() as $item) { $siteList[] = $item['site_id']; } } if ($siteList) { $query->andWhere($builder->expr()->in('s.id', $siteList)); } switch ($filter) { case 'year': $query->addSelect('YEAR(e.rankedAt) regYear') ->addGroupBy('regYear'); break; case 'month': $query->addSelect('Month(e.rankedAt) regMonth') ->addGroupBy('regMonth'); break; case 'week': $query->addSelect('WEEK(e.rankedAt) regWeek') ->addGroupBy('regWeek'); break; case 'hour': $query->addSelect('HOUR(e.rankedAt) regHour') ->addGroupBy('regHour'); break; case 'day': default: $query->addGroupBy('regDay'); } return $query->getQuery()->getArrayResult(); }
php
public function getReportQuery($siteId, $fromDate, $toDate, $filter, $limit = null) { $siteList = []; $filter = strtolower($filter); if (empty($fromDate)) { $fromDate = (new DateTime('first day of the year'))->format('Y-m-d'); } if (empty($toDate)) { $toDate = (new DateTime('last day of this month'))->format('Y-m-d'); } $builder = $this->getEntityManager()->createQuerybuilder(); $query = $builder->select( [ '(e.popularity) total', 'DATE(e.rankedAt) regDay', 's.domain domain', '1 valid', 'e.rankedAt createdAt', ] )->from($this->getEntity(), 'e') ->innerJoin('e.site', 's') ->where('e.rankedAt >= :start') ->andWhere('e.rankedAt <= :end') //->andWhere('s.siteType = :siteType') ->addOrderBy('e.rankedAt') ->addOrderBy('e.popularity') ->addGroupBy('e.site') ->setParameters( [ ':start' => $fromDate, ':end' => $toDate, // ':siteType' => 1, ] ); if ($siteId) { $siteList = array_filter(array_unique(array_merge($siteList, (array)$siteId))); } elseif ($limit) { $subQueryBuilder = $builder = $this->getEntityManager()->createQuerybuilder(); $subQuery = $subQueryBuilder->select('f.id, s.id site_id') ->from($this->getEntity(), 'f') ->innerJoin('f.site', 's') ->groupBy('s.id') ->orderBy('f.popularity', 'ASC') ->setMaxResults($limit); foreach ($subQuery->getQuery()->getArrayResult() as $item) { $siteList[] = $item['site_id']; } } if ($siteList) { $query->andWhere($builder->expr()->in('s.id', $siteList)); } switch ($filter) { case 'year': $query->addSelect('YEAR(e.rankedAt) regYear') ->addGroupBy('regYear'); break; case 'month': $query->addSelect('Month(e.rankedAt) regMonth') ->addGroupBy('regMonth'); break; case 'week': $query->addSelect('WEEK(e.rankedAt) regWeek') ->addGroupBy('regWeek'); break; case 'hour': $query->addSelect('HOUR(e.rankedAt) regHour') ->addGroupBy('regHour'); break; case 'day': default: $query->addGroupBy('regDay'); } return $query->getQuery()->getArrayResult(); }
[ "public", "function", "getReportQuery", "(", "$", "siteId", ",", "$", "fromDate", ",", "$", "toDate", ",", "$", "filter", ",", "$", "limit", "=", "null", ")", "{", "$", "siteList", "=", "[", "]", ";", "$", "filter", "=", "strtolower", "(", "$", "filter", ")", ";", "if", "(", "empty", "(", "$", "fromDate", ")", ")", "{", "$", "fromDate", "=", "(", "new", "DateTime", "(", "'first day of the year'", ")", ")", "->", "format", "(", "'Y-m-d'", ")", ";", "}", "if", "(", "empty", "(", "$", "toDate", ")", ")", "{", "$", "toDate", "=", "(", "new", "DateTime", "(", "'last day of this month'", ")", ")", "->", "format", "(", "'Y-m-d'", ")", ";", "}", "$", "builder", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQuerybuilder", "(", ")", ";", "$", "query", "=", "$", "builder", "->", "select", "(", "[", "'(e.popularity) total'", ",", "'DATE(e.rankedAt) regDay'", ",", "'s.domain domain'", ",", "'1 valid'", ",", "'e.rankedAt createdAt'", ",", "]", ")", "->", "from", "(", "$", "this", "->", "getEntity", "(", ")", ",", "'e'", ")", "->", "innerJoin", "(", "'e.site'", ",", "'s'", ")", "->", "where", "(", "'e.rankedAt >= :start'", ")", "->", "andWhere", "(", "'e.rankedAt <= :end'", ")", "//->andWhere('s.siteType = :siteType')", "->", "addOrderBy", "(", "'e.rankedAt'", ")", "->", "addOrderBy", "(", "'e.popularity'", ")", "->", "addGroupBy", "(", "'e.site'", ")", "->", "setParameters", "(", "[", "':start'", "=>", "$", "fromDate", ",", "':end'", "=>", "$", "toDate", ",", "// ':siteType' => 1,", "]", ")", ";", "if", "(", "$", "siteId", ")", "{", "$", "siteList", "=", "array_filter", "(", "array_unique", "(", "array_merge", "(", "$", "siteList", ",", "(", "array", ")", "$", "siteId", ")", ")", ")", ";", "}", "elseif", "(", "$", "limit", ")", "{", "$", "subQueryBuilder", "=", "$", "builder", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQuerybuilder", "(", ")", ";", "$", "subQuery", "=", "$", "subQueryBuilder", "->", "select", "(", "'f.id, s.id site_id'", ")", "->", "from", "(", "$", "this", "->", "getEntity", "(", ")", ",", "'f'", ")", "->", "innerJoin", "(", "'f.site'", ",", "'s'", ")", "->", "groupBy", "(", "'s.id'", ")", "->", "orderBy", "(", "'f.popularity'", ",", "'ASC'", ")", "->", "setMaxResults", "(", "$", "limit", ")", ";", "foreach", "(", "$", "subQuery", "->", "getQuery", "(", ")", "->", "getArrayResult", "(", ")", "as", "$", "item", ")", "{", "$", "siteList", "[", "]", "=", "$", "item", "[", "'site_id'", "]", ";", "}", "}", "if", "(", "$", "siteList", ")", "{", "$", "query", "->", "andWhere", "(", "$", "builder", "->", "expr", "(", ")", "->", "in", "(", "'s.id'", ",", "$", "siteList", ")", ")", ";", "}", "switch", "(", "$", "filter", ")", "{", "case", "'year'", ":", "$", "query", "->", "addSelect", "(", "'YEAR(e.rankedAt) regYear'", ")", "->", "addGroupBy", "(", "'regYear'", ")", ";", "break", ";", "case", "'month'", ":", "$", "query", "->", "addSelect", "(", "'Month(e.rankedAt) regMonth'", ")", "->", "addGroupBy", "(", "'regMonth'", ")", ";", "break", ";", "case", "'week'", ":", "$", "query", "->", "addSelect", "(", "'WEEK(e.rankedAt) regWeek'", ")", "->", "addGroupBy", "(", "'regWeek'", ")", ";", "break", ";", "case", "'hour'", ":", "$", "query", "->", "addSelect", "(", "'HOUR(e.rankedAt) regHour'", ")", "->", "addGroupBy", "(", "'regHour'", ")", ";", "break", ";", "case", "'day'", ":", "default", ":", "$", "query", "->", "addGroupBy", "(", "'regDay'", ")", ";", "}", "return", "$", "query", "->", "getQuery", "(", ")", "->", "getArrayResult", "(", ")", ";", "}" ]
@param int $siteId @param $fromDate @param $toDate @param $filter @param int $limit @return array
[ "@param", "int", "$siteId", "@param", "$fromDate", "@param", "$toDate", "@param", "$filter", "@param", "int", "$limit" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/SiteRankModel.php#L22-L102
mslib/resource-proxy
Msl/ResourceProxy/Source/Pop.php
Pop.getContentIterator
public function getContentIterator() { // Initializing output array $output = new \ArrayIterator(); // Getting total number of messages $maxMessage = $this->storage->countMessages(); for($i=1; $i<=$maxMessage; $i++) { // Getting the message object $message = $this->storage->getMessage($i); if ($message instanceof \Zend\Mail\Storage\Message) { // Wrapping the result object into an appropriate ResourceInterface instance try { $popMessage = new PopMessage(); $popMessage->init($this->getName(), $i, $message); } catch (\Exception $e) { throw new Exception\SourceGetContentException( sprintf( 'Error while getting the content for the resource unique id \'%s\'. Exception is: \'%s\'.', $i, $e->getMessage() ) ); } // Adding the wrapping object to the result iterator $output->append($popMessage); } } // Returning the result iterator return $output; }
php
public function getContentIterator() { // Initializing output array $output = new \ArrayIterator(); // Getting total number of messages $maxMessage = $this->storage->countMessages(); for($i=1; $i<=$maxMessage; $i++) { // Getting the message object $message = $this->storage->getMessage($i); if ($message instanceof \Zend\Mail\Storage\Message) { // Wrapping the result object into an appropriate ResourceInterface instance try { $popMessage = new PopMessage(); $popMessage->init($this->getName(), $i, $message); } catch (\Exception $e) { throw new Exception\SourceGetContentException( sprintf( 'Error while getting the content for the resource unique id \'%s\'. Exception is: \'%s\'.', $i, $e->getMessage() ) ); } // Adding the wrapping object to the result iterator $output->append($popMessage); } } // Returning the result iterator return $output; }
[ "public", "function", "getContentIterator", "(", ")", "{", "// Initializing output array", "$", "output", "=", "new", "\\", "ArrayIterator", "(", ")", ";", "// Getting total number of messages", "$", "maxMessage", "=", "$", "this", "->", "storage", "->", "countMessages", "(", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "maxMessage", ";", "$", "i", "++", ")", "{", "// Getting the message object", "$", "message", "=", "$", "this", "->", "storage", "->", "getMessage", "(", "$", "i", ")", ";", "if", "(", "$", "message", "instanceof", "\\", "Zend", "\\", "Mail", "\\", "Storage", "\\", "Message", ")", "{", "// Wrapping the result object into an appropriate ResourceInterface instance", "try", "{", "$", "popMessage", "=", "new", "PopMessage", "(", ")", ";", "$", "popMessage", "->", "init", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "i", ",", "$", "message", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "SourceGetContentException", "(", "sprintf", "(", "'Error while getting the content for the resource unique id \\'%s\\'. Exception is: \\'%s\\'.'", ",", "$", "i", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "// Adding the wrapping object to the result iterator", "$", "output", "->", "append", "(", "$", "popMessage", ")", ";", "}", "}", "// Returning the result iterator", "return", "$", "output", ";", "}" ]
Returns an Iterator instance for a list of Resource instances. (in this case, list of emails to be parsed) @throws \Exception @return mixed
[ "Returns", "an", "Iterator", "instance", "for", "a", "list", "of", "Resource", "instances", ".", "(", "in", "this", "case", "list", "of", "emails", "to", "be", "parsed", ")" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Pop.php#L35-L69
mslib/resource-proxy
Msl/ResourceProxy/Source/Pop.php
Pop.toString
public function toString() { return sprintf( 'Pop Source Object [host:\'%s\'][port:\'%s\'][user:\'%s\']', $this->sourceConfig->getHost(), $this->sourceConfig->getPort(), $this->sourceConfig->getUsername() ); }
php
public function toString() { return sprintf( 'Pop Source Object [host:\'%s\'][port:\'%s\'][user:\'%s\']', $this->sourceConfig->getHost(), $this->sourceConfig->getPort(), $this->sourceConfig->getUsername() ); }
[ "public", "function", "toString", "(", ")", "{", "return", "sprintf", "(", "'Pop Source Object [host:\\'%s\\'][port:\\'%s\\'][user:\\'%s\\']'", ",", "$", "this", "->", "sourceConfig", "->", "getHost", "(", ")", ",", "$", "this", "->", "sourceConfig", "->", "getPort", "(", ")", ",", "$", "this", "->", "sourceConfig", "->", "getUsername", "(", ")", ")", ";", "}" ]
Returns a string representation for the source object @return string
[ "Returns", "a", "string", "representation", "for", "the", "source", "object" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Pop.php#L76-L84
hametuha/wpametu
src/WPametu/API/Ajax/AjaxForm.php
AjaxForm.form_open
protected function form_open( array $attributes = [], $echo = true){ $attributes = array_merge([ 'method' => $this->method, 'action' => $this->ajax_url(), ], $attributes); $str = []; foreach( $attributes as $key => $value ){ $str[] = sprintf('%s="%s"', $key, esc_attr($value)); } $str = implode(' ', $str); $html = "<form {$str}>"; $html .= sprintf('<input type="hidden" name="action" value="%s" />', esc_attr($this->action)); $html .= $this->nonce_field('_wpnonce', false, false); if( $echo ){ echo $html; } return $html; }
php
protected function form_open( array $attributes = [], $echo = true){ $attributes = array_merge([ 'method' => $this->method, 'action' => $this->ajax_url(), ], $attributes); $str = []; foreach( $attributes as $key => $value ){ $str[] = sprintf('%s="%s"', $key, esc_attr($value)); } $str = implode(' ', $str); $html = "<form {$str}>"; $html .= sprintf('<input type="hidden" name="action" value="%s" />', esc_attr($this->action)); $html .= $this->nonce_field('_wpnonce', false, false); if( $echo ){ echo $html; } return $html; }
[ "protected", "function", "form_open", "(", "array", "$", "attributes", "=", "[", "]", ",", "$", "echo", "=", "true", ")", "{", "$", "attributes", "=", "array_merge", "(", "[", "'method'", "=>", "$", "this", "->", "method", ",", "'action'", "=>", "$", "this", "->", "ajax_url", "(", ")", ",", "]", ",", "$", "attributes", ")", ";", "$", "str", "=", "[", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "str", "[", "]", "=", "sprintf", "(", "'%s=\"%s\"'", ",", "$", "key", ",", "esc_attr", "(", "$", "value", ")", ")", ";", "}", "$", "str", "=", "implode", "(", "' '", ",", "$", "str", ")", ";", "$", "html", "=", "\"<form {$str}>\"", ";", "$", "html", ".=", "sprintf", "(", "'<input type=\"hidden\" name=\"action\" value=\"%s\" />'", ",", "esc_attr", "(", "$", "this", "->", "action", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "nonce_field", "(", "'_wpnonce'", ",", "false", ",", "false", ")", ";", "if", "(", "$", "echo", ")", "{", "echo", "$", "html", ";", "}", "return", "$", "html", ";", "}" ]
Open form @param array $attributes @param bool $echo @return string
[ "Open", "form" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Ajax/AjaxForm.php#L22-L39
hametuha/wpametu
src/WPametu/API/Ajax/AjaxForm.php
AjaxForm.form
public static function form($slug, $name = '', array $attributes = []){ $class_name = get_called_class(); /** @var AjaxBaseForm $instance */ $instance = $class_name::get_instance(); $instance->form_open($attributes); $args = $instance->form_arguments(); $instance->load_template($slug, $name, $args); $instance->form_close(); }
php
public static function form($slug, $name = '', array $attributes = []){ $class_name = get_called_class(); /** @var AjaxBaseForm $instance */ $instance = $class_name::get_instance(); $instance->form_open($attributes); $args = $instance->form_arguments(); $instance->load_template($slug, $name, $args); $instance->form_close(); }
[ "public", "static", "function", "form", "(", "$", "slug", ",", "$", "name", "=", "''", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "class_name", "=", "get_called_class", "(", ")", ";", "/** @var AjaxBaseForm $instance */", "$", "instance", "=", "$", "class_name", "::", "get_instance", "(", ")", ";", "$", "instance", "->", "form_open", "(", "$", "attributes", ")", ";", "$", "args", "=", "$", "instance", "->", "form_arguments", "(", ")", ";", "$", "instance", "->", "load_template", "(", "$", "slug", ",", "$", "name", ",", "$", "args", ")", ";", "$", "instance", "->", "form_close", "(", ")", ";", "}" ]
Display form control @param string $slug @param string $name @param array $attributes
[ "Display", "form", "control" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Ajax/AjaxForm.php#L62-L70
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.encodeMethod
public function encodeMethod($method, $params) { $string = $this->encoder->encodeMethod($method, $params); return $this->encrypt($string); }
php
public function encodeMethod($method, $params) { $string = $this->encoder->encodeMethod($method, $params); return $this->encrypt($string); }
[ "public", "function", "encodeMethod", "(", "$", "method", ",", "$", "params", ")", "{", "$", "string", "=", "$", "this", "->", "encoder", "->", "encodeMethod", "(", "$", "method", ",", "$", "params", ")", ";", "return", "$", "this", "->", "encrypt", "(", "$", "string", ")", ";", "}" ]
Encode a method call. @param $mixed @return string
[ "Encode", "a", "method", "call", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L55-L60
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.encodeException
public function encodeException(\Exception $exception) { $string = $this->encoder->encodeException($exception); try { return $this->encrypt($string); } catch (\Exception $e) { if ($this->plainExceptions) { return $string; } throw $e; } }
php
public function encodeException(\Exception $exception) { $string = $this->encoder->encodeException($exception); try { return $this->encrypt($string); } catch (\Exception $e) { if ($this->plainExceptions) { return $string; } throw $e; } }
[ "public", "function", "encodeException", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "string", "=", "$", "this", "->", "encoder", "->", "encodeException", "(", "$", "exception", ")", ";", "try", "{", "return", "$", "this", "->", "encrypt", "(", "$", "string", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "plainExceptions", ")", "{", "return", "$", "string", ";", "}", "throw", "$", "e", ";", "}", "}" ]
Encode an exception. @param \Exception $exception @return string
[ "Encode", "an", "exception", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L69-L82
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.encodeResult
public function encodeResult($result) { $string = $this->encoder->encodeResult($result); return $this->encrypt($string); }
php
public function encodeResult($result) { $string = $this->encoder->encodeResult($result); return $this->encrypt($string); }
[ "public", "function", "encodeResult", "(", "$", "result", ")", "{", "$", "string", "=", "$", "this", "->", "encoder", "->", "encodeResult", "(", "$", "result", ")", ";", "return", "$", "this", "->", "encrypt", "(", "$", "string", ")", ";", "}" ]
Encode a result from the method call. @param mixed $result @return string
[ "Encode", "a", "result", "from", "the", "method", "call", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L91-L96
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.decodeMethod
public function decodeMethod($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeMethod($string); }
php
public function decodeMethod($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeMethod($string); }
[ "public", "function", "decodeMethod", "(", "$", "crypt", ")", "{", "$", "string", "=", "$", "this", "->", "decrypt", "(", "$", "crypt", ")", ";", "return", "$", "this", "->", "encoder", "->", "decodeMethod", "(", "$", "string", ")", ";", "}" ]
Decode an encoded method. @param $string @return array An array with 2 elements: [<method name>, <method params>] @throws Throw an exception, if $string is an error or contains an error.
[ "Decode", "an", "encoded", "method", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L107-L112
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.decodeResult
public function decodeResult($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeResult($string); }
php
public function decodeResult($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeResult($string); }
[ "public", "function", "decodeResult", "(", "$", "crypt", ")", "{", "$", "string", "=", "$", "this", "->", "decrypt", "(", "$", "crypt", ")", ";", "return", "$", "this", "->", "encoder", "->", "decodeResult", "(", "$", "string", ")", ";", "}" ]
Decode an encoded result. @param $string @return mixed @throws Throw an exception, if $string is an error or contains an error.
[ "Decode", "an", "encoded", "result", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L123-L128
ekuiter/feature-php
FeaturePhp/File/ChunkFile.php
ChunkFile.fromSpecification
public static function fromSpecification($chunkSpecification) { return new self($chunkSpecification->getTarget(), $chunkSpecification->getHeader(), $chunkSpecification->getFooter(), $chunkSpecification->getNewline()); }
php
public static function fromSpecification($chunkSpecification) { return new self($chunkSpecification->getTarget(), $chunkSpecification->getHeader(), $chunkSpecification->getFooter(), $chunkSpecification->getNewline()); }
[ "public", "static", "function", "fromSpecification", "(", "$", "chunkSpecification", ")", "{", "return", "new", "self", "(", "$", "chunkSpecification", "->", "getTarget", "(", ")", ",", "$", "chunkSpecification", "->", "getHeader", "(", ")", ",", "$", "chunkSpecification", "->", "getFooter", "(", ")", ",", "$", "chunkSpecification", "->", "getNewline", "(", ")", ")", ";", "}" ]
Creates a chunked file from a chunk specification. See {@see \FeaturePhp\Specification\ChunkSpecification} for details. @param \FeaturePhp\Specification\ChunkSpecification $chunkSpecification @return ChunkFile
[ "Creates", "a", "chunked", "file", "from", "a", "chunk", "specification", ".", "See", "{" ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/ChunkFile.php#L51-L56
ekuiter/feature-php
FeaturePhp/File/ChunkFile.php
ChunkFile.extend
public function extend($chunkSpecification) { $linesBefore = count(explode("\n", $this->content)); $this->append($chunkSpecification->getText() . $this->newline); $linesAfter = count(explode("\n", $this->content)); return array(new fphp\Artifact\ChunkPlace( $chunkSpecification->getTarget(), $linesBefore, $linesAfter - 1)); }
php
public function extend($chunkSpecification) { $linesBefore = count(explode("\n", $this->content)); $this->append($chunkSpecification->getText() . $this->newline); $linesAfter = count(explode("\n", $this->content)); return array(new fphp\Artifact\ChunkPlace( $chunkSpecification->getTarget(), $linesBefore, $linesAfter - 1)); }
[ "public", "function", "extend", "(", "$", "chunkSpecification", ")", "{", "$", "linesBefore", "=", "count", "(", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "content", ")", ")", ";", "$", "this", "->", "append", "(", "$", "chunkSpecification", "->", "getText", "(", ")", ".", "$", "this", "->", "newline", ")", ";", "$", "linesAfter", "=", "count", "(", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "content", ")", ")", ";", "return", "array", "(", "new", "fphp", "\\", "Artifact", "\\", "ChunkPlace", "(", "$", "chunkSpecification", "->", "getTarget", "(", ")", ",", "$", "linesBefore", ",", "$", "linesAfter", "-", "1", ")", ")", ";", "}" ]
Adds a chunk to the chunked file. This is expected to be called only be a {@see \FeaturePhp\Generator\ChunkGenerator}. Only uses the text of the chunk specification. @param \FeaturePhp\Specification\ChunkSpecification $chunkSpecification @return \FeaturePhp\Place\Place[]
[ "Adds", "a", "chunk", "to", "the", "chunked", "file", ".", "This", "is", "expected", "to", "be", "called", "only", "be", "a", "{" ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/ChunkFile.php#L65-L71
ekuiter/feature-php
FeaturePhp/File/ChunkFile.php
ChunkFile.getContent
public function getContent() { return new TextFileContent( $this->content . ($this->footer === "" ? "" : $this->footer . $this->newline)); }
php
public function getContent() { return new TextFileContent( $this->content . ($this->footer === "" ? "" : $this->footer . $this->newline)); }
[ "public", "function", "getContent", "(", ")", "{", "return", "new", "TextFileContent", "(", "$", "this", "->", "content", ".", "(", "$", "this", "->", "footer", "===", "\"\"", "?", "\"\"", ":", "$", "this", "->", "footer", ".", "$", "this", "->", "newline", ")", ")", ";", "}" ]
Returns the chunked file's content. The content consists of the header, then every chunk and then the footer. @return TextFileContent
[ "Returns", "the", "chunked", "file", "s", "content", ".", "The", "content", "consists", "of", "the", "header", "then", "every", "chunk", "and", "then", "the", "footer", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/ChunkFile.php#L78-L81
ciaranmcnulty/behat-localwebserverextension
src/ServiceContainer/LocalWebserverExtension.php
LocalWebserverExtension.process
public function process(ContainerBuilder $container) { if ($container->hasParameter('mink.base_url')) { $definition = new Definition('Cjm\Behat\LocalWebserverExtension\Webserver\MinkConfiguration', array( '%cjm.local_webserver.configuration.host%', '%cjm.local_webserver.configuration.port%', '%cjm.local_webserver.configuration.docroot%', '%mink.base_url%', '%cjm.local_webserver.configuration.router%' )); $container->setDefinition('cjm.local_webserver.configuration.mink', $definition); $container->setAlias('cjm.local_webserver.configuration.inner', new Alias('cjm.local_webserver.configuration.mink')); } else { $container->setAlias('cjm.local_webserver.configuration.inner', new Alias('cjm.local_webserver.configuration.basic')); } }
php
public function process(ContainerBuilder $container) { if ($container->hasParameter('mink.base_url')) { $definition = new Definition('Cjm\Behat\LocalWebserverExtension\Webserver\MinkConfiguration', array( '%cjm.local_webserver.configuration.host%', '%cjm.local_webserver.configuration.port%', '%cjm.local_webserver.configuration.docroot%', '%mink.base_url%', '%cjm.local_webserver.configuration.router%' )); $container->setDefinition('cjm.local_webserver.configuration.mink', $definition); $container->setAlias('cjm.local_webserver.configuration.inner', new Alias('cjm.local_webserver.configuration.mink')); } else { $container->setAlias('cjm.local_webserver.configuration.inner', new Alias('cjm.local_webserver.configuration.basic')); } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "$", "container", "->", "hasParameter", "(", "'mink.base_url'", ")", ")", "{", "$", "definition", "=", "new", "Definition", "(", "'Cjm\\Behat\\LocalWebserverExtension\\Webserver\\MinkConfiguration'", ",", "array", "(", "'%cjm.local_webserver.configuration.host%'", ",", "'%cjm.local_webserver.configuration.port%'", ",", "'%cjm.local_webserver.configuration.docroot%'", ",", "'%mink.base_url%'", ",", "'%cjm.local_webserver.configuration.router%'", ")", ")", ";", "$", "container", "->", "setDefinition", "(", "'cjm.local_webserver.configuration.mink'", ",", "$", "definition", ")", ";", "$", "container", "->", "setAlias", "(", "'cjm.local_webserver.configuration.inner'", ",", "new", "Alias", "(", "'cjm.local_webserver.configuration.mink'", ")", ")", ";", "}", "else", "{", "$", "container", "->", "setAlias", "(", "'cjm.local_webserver.configuration.inner'", ",", "new", "Alias", "(", "'cjm.local_webserver.configuration.basic'", ")", ")", ";", "}", "}" ]
You can modify the container here before it is dumped to PHP code. @param ContainerBuilder $container @api
[ "You", "can", "modify", "the", "container", "here", "before", "it", "is", "dumped", "to", "PHP", "code", "." ]
train
https://github.com/ciaranmcnulty/behat-localwebserverextension/blob/0ac9cfbf608134e19d67b7856bb42854f1bc80dc/src/ServiceContainer/LocalWebserverExtension.php#L24-L41
ciaranmcnulty/behat-localwebserverextension
src/ServiceContainer/LocalWebserverExtension.php
LocalWebserverExtension.configure
public function configure(ArrayNodeDefinition $builder) { $builder ->children() ->scalarNode('host') ->defaultNull() ->end() ->scalarNode('port') ->defaultNull() ->end() ->scalarNode('docroot') ->defaultNull() ->end() ->arrayNode('suites') ->prototype('scalar')->end() ->end() ->scalarNode('router') ->defaultNull() ->end() ->end() ->end(); }
php
public function configure(ArrayNodeDefinition $builder) { $builder ->children() ->scalarNode('host') ->defaultNull() ->end() ->scalarNode('port') ->defaultNull() ->end() ->scalarNode('docroot') ->defaultNull() ->end() ->arrayNode('suites') ->prototype('scalar')->end() ->end() ->scalarNode('router') ->defaultNull() ->end() ->end() ->end(); }
[ "public", "function", "configure", "(", "ArrayNodeDefinition", "$", "builder", ")", "{", "$", "builder", "->", "children", "(", ")", "->", "scalarNode", "(", "'host'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'port'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'docroot'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'suites'", ")", "->", "prototype", "(", "'scalar'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'router'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Setups configuration for the extension. @param ArrayNodeDefinition $builder
[ "Setups", "configuration", "for", "the", "extension", "." ]
train
https://github.com/ciaranmcnulty/behat-localwebserverextension/blob/0ac9cfbf608134e19d67b7856bb42854f1bc80dc/src/ServiceContainer/LocalWebserverExtension.php#L72-L93
ciaranmcnulty/behat-localwebserverextension
src/ServiceContainer/LocalWebserverExtension.php
LocalWebserverExtension.load
public function load(ContainerBuilder $container, array $config) { $container->setParameter('cjm.local_webserver.configuration.host', $config['host']); $container->setParameter('cjm.local_webserver.configuration.port', $config['port']); $container->setParameter('cjm.local_webserver.configuration.docroot', $config['docroot']); $container->setParameter('cjm.local_webserver.configuration.suites', $config['suites']); $container->setParameter('cjm.local_webserver.configuration.router', $config['router']); $this->loadEventSubscribers($container); $this->loadWebserverController($container); $this->loadWebserverConfiguration($container, $config); }
php
public function load(ContainerBuilder $container, array $config) { $container->setParameter('cjm.local_webserver.configuration.host', $config['host']); $container->setParameter('cjm.local_webserver.configuration.port', $config['port']); $container->setParameter('cjm.local_webserver.configuration.docroot', $config['docroot']); $container->setParameter('cjm.local_webserver.configuration.suites', $config['suites']); $container->setParameter('cjm.local_webserver.configuration.router', $config['router']); $this->loadEventSubscribers($container); $this->loadWebserverController($container); $this->loadWebserverConfiguration($container, $config); }
[ "public", "function", "load", "(", "ContainerBuilder", "$", "container", ",", "array", "$", "config", ")", "{", "$", "container", "->", "setParameter", "(", "'cjm.local_webserver.configuration.host'", ",", "$", "config", "[", "'host'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'cjm.local_webserver.configuration.port'", ",", "$", "config", "[", "'port'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'cjm.local_webserver.configuration.docroot'", ",", "$", "config", "[", "'docroot'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'cjm.local_webserver.configuration.suites'", ",", "$", "config", "[", "'suites'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'cjm.local_webserver.configuration.router'", ",", "$", "config", "[", "'router'", "]", ")", ";", "$", "this", "->", "loadEventSubscribers", "(", "$", "container", ")", ";", "$", "this", "->", "loadWebserverController", "(", "$", "container", ")", ";", "$", "this", "->", "loadWebserverConfiguration", "(", "$", "container", ",", "$", "config", ")", ";", "}" ]
Loads extension services into temporary container. @param ContainerBuilder $container @param array $config
[ "Loads", "extension", "services", "into", "temporary", "container", "." ]
train
https://github.com/ciaranmcnulty/behat-localwebserverextension/blob/0ac9cfbf608134e19d67b7856bb42854f1bc80dc/src/ServiceContainer/LocalWebserverExtension.php#L101-L112
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.getImageConvertExecutable
public static function getImageConvertExecutable() { if ( !is_null( self::$imageConvert ) ) { return self::$imageConvert; } return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) ); }
php
public static function getImageConvertExecutable() { if ( !is_null( self::$imageConvert ) ) { return self::$imageConvert; } return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) ); }
[ "public", "static", "function", "getImageConvertExecutable", "(", ")", "{", "if", "(", "!", "is_null", "(", "self", "::", "$", "imageConvert", ")", ")", "{", "return", "self", "::", "$", "imageConvert", ";", "}", "return", "(", "self", "::", "$", "imageConvert", "=", "self", "::", "findExecutableInPath", "(", "'convert'", ")", ")", ";", "}" ]
Returns the path to the ImageMagick convert utility. On Linux, Unix,... it will return something like: /usr/bin/convert On Windows it will return something like: C:\Windows\System32\convert.exe @return string
[ "Returns", "the", "path", "to", "the", "ImageMagick", "convert", "utility", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L109-L116
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.getImageIdentifyExecutable
public static function getImageIdentifyExecutable() { if ( !is_null( self::$imageIdentify ) ) { return self::$imageIdentify; } return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) ); }
php
public static function getImageIdentifyExecutable() { if ( !is_null( self::$imageIdentify ) ) { return self::$imageIdentify; } return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) ); }
[ "public", "static", "function", "getImageIdentifyExecutable", "(", ")", "{", "if", "(", "!", "is_null", "(", "self", "::", "$", "imageIdentify", ")", ")", "{", "return", "self", "::", "$", "imageIdentify", ";", "}", "return", "(", "self", "::", "$", "imageIdentify", "=", "self", "::", "findExecutableInPath", "(", "'identify'", ")", ")", ";", "}" ]
Returns the path to the ImageMagick identify utility. On Linux, Unix,... it will return something like: /usr/bin/identify On Windows it will return something like: C:\Windows\System32\identify.exe @return string
[ "Returns", "the", "path", "to", "the", "ImageMagick", "identify", "utility", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L136-L143
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.hasExtensionSupport
public static function hasExtensionSupport( $extension, $version = null ) { if ( is_null( $version ) ) { return extension_loaded( $extension ); } return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ; }
php
public static function hasExtensionSupport( $extension, $version = null ) { if ( is_null( $version ) ) { return extension_loaded( $extension ); } return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ; }
[ "public", "static", "function", "hasExtensionSupport", "(", "$", "extension", ",", "$", "version", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "version", ")", ")", "{", "return", "extension_loaded", "(", "$", "extension", ")", ";", "}", "return", "extension_loaded", "(", "$", "extension", ")", "&&", "version_compare", "(", "phpversion", "(", "$", "extension", ")", ",", "$", "version", ",", "\">=\"", ")", ";", "}" ]
Determines if the specified extension is loaded. If $version is specified, the specified extension will be tested also against the version of the loaded extension. Examples: <code> hasExtensionSupport( 'gzip' ); </code> will return true if gzip extension is loaded. <code> hasExtensionSupport( 'pdo_mysql', '1.0.2' ); </code> will return true if pdo_mysql extension is loaded and its version is at least 1.0.2. @param string $extension @param string $version @return bool
[ "Determines", "if", "the", "specified", "extension", "is", "loaded", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L166-L173
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.classExists
public static function classExists( $className, $autoload = true ) { try { if ( class_exists( $className, $autoload ) ) { return true; } return false; } catch ( ezcBaseAutoloadException $e ) { return false; } }
php
public static function classExists( $className, $autoload = true ) { try { if ( class_exists( $className, $autoload ) ) { return true; } return false; } catch ( ezcBaseAutoloadException $e ) { return false; } }
[ "public", "static", "function", "classExists", "(", "$", "className", ",", "$", "autoload", "=", "true", ")", "{", "try", "{", "if", "(", "class_exists", "(", "$", "className", ",", "$", "autoload", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "catch", "(", "ezcBaseAutoloadException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Returns if a given class exists. Checks for a given class name and returns if this class exists or not. Catches the ezcBaseAutoloadException and returns false, if it was thrown. @param string $className The class to check for. @param bool $autoload True to use __autoload(), otherwise false. @return bool True if the class exists. Otherwise false.
[ "Returns", "if", "a", "given", "class", "exists", ".", "Checks", "for", "a", "given", "class", "name", "and", "returns", "if", "this", "class", "exists", "or", "not", ".", "Catches", "the", "ezcBaseAutoloadException", "and", "returns", "false", "if", "it", "was", "thrown", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L202-L216
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.os
public static function os() { if ( is_null( self::$os ) ) { $uname = php_uname( 's' ); if ( substr( $uname, 0, 7 ) == 'Windows' ) { self::$os = 'Windows'; } elseif ( substr( $uname, 0, 3 ) == 'Mac' ) { self::$os = 'Mac'; } elseif ( strtolower( $uname ) == 'linux' ) { self::$os = 'Linux'; } elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' ) { self::$os = 'FreeBSD'; } else { self::$os = PHP_OS; } } return self::$os; }
php
public static function os() { if ( is_null( self::$os ) ) { $uname = php_uname( 's' ); if ( substr( $uname, 0, 7 ) == 'Windows' ) { self::$os = 'Windows'; } elseif ( substr( $uname, 0, 3 ) == 'Mac' ) { self::$os = 'Mac'; } elseif ( strtolower( $uname ) == 'linux' ) { self::$os = 'Linux'; } elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' ) { self::$os = 'FreeBSD'; } else { self::$os = PHP_OS; } } return self::$os; }
[ "public", "static", "function", "os", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "os", ")", ")", "{", "$", "uname", "=", "php_uname", "(", "'s'", ")", ";", "if", "(", "substr", "(", "$", "uname", ",", "0", ",", "7", ")", "==", "'Windows'", ")", "{", "self", "::", "$", "os", "=", "'Windows'", ";", "}", "elseif", "(", "substr", "(", "$", "uname", ",", "0", ",", "3", ")", "==", "'Mac'", ")", "{", "self", "::", "$", "os", "=", "'Mac'", ";", "}", "elseif", "(", "strtolower", "(", "$", "uname", ")", "==", "'linux'", ")", "{", "self", "::", "$", "os", "=", "'Linux'", ";", "}", "elseif", "(", "strtolower", "(", "substr", "(", "$", "uname", ",", "0", ",", "7", ")", ")", "==", "'freebsd'", ")", "{", "self", "::", "$", "os", "=", "'FreeBSD'", ";", "}", "else", "{", "self", "::", "$", "os", "=", "PHP_OS", ";", "}", "}", "return", "self", "::", "$", "os", ";", "}" ]
Returns the operating system on which PHP is running. This method returns a sanitized form of the OS name, example return values are "Windows", "Mac", "Linux" and "FreeBSD". In all other cases it returns the value of the internal PHP constant PHP_OS. @return string
[ "Returns", "the", "operating", "system", "on", "which", "PHP", "is", "running", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L228-L255
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.findExecutableInPath
public static function findExecutableInPath( $fileName ) { if ( array_key_exists( 'PATH', $_ENV ) ) { $envPath = trim( $_ENV['PATH'] ); } else if ( ( $envPath = getenv( 'PATH' ) ) !== false ) { $envPath = trim( $envPath ); } if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 ) { $envPath = false; } switch ( self::os() ) { case 'Unix': case 'FreeBSD': case 'Mac': case 'MacOS': case 'Darwin': case 'Linux': case 'SunOS': if ( $envPath ) { $dirs = explode( ':', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( file_exists( "{$dir}/{$fileName}" ) ) { return "{$dir}/{$fileName}"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "./{$fileName}" ) ) { return $fileName; } break; case 'Windows': if ( $envPath ) { $dirs = explode( ';', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( @file_exists( "{$dir}\\{$fileName}.exe" ) ) { return "{$dir}\\{$fileName}.exe"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "{$fileName}.exe" ) ) { return "{$fileName}.exe"; } break; } return null; }
php
public static function findExecutableInPath( $fileName ) { if ( array_key_exists( 'PATH', $_ENV ) ) { $envPath = trim( $_ENV['PATH'] ); } else if ( ( $envPath = getenv( 'PATH' ) ) !== false ) { $envPath = trim( $envPath ); } if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 ) { $envPath = false; } switch ( self::os() ) { case 'Unix': case 'FreeBSD': case 'Mac': case 'MacOS': case 'Darwin': case 'Linux': case 'SunOS': if ( $envPath ) { $dirs = explode( ':', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( file_exists( "{$dir}/{$fileName}" ) ) { return "{$dir}/{$fileName}"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "./{$fileName}" ) ) { return $fileName; } break; case 'Windows': if ( $envPath ) { $dirs = explode( ';', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( @file_exists( "{$dir}\\{$fileName}.exe" ) ) { return "{$dir}\\{$fileName}.exe"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "{$fileName}.exe" ) ) { return "{$fileName}.exe"; } break; } return null; }
[ "public", "static", "function", "findExecutableInPath", "(", "$", "fileName", ")", "{", "if", "(", "array_key_exists", "(", "'PATH'", ",", "$", "_ENV", ")", ")", "{", "$", "envPath", "=", "trim", "(", "$", "_ENV", "[", "'PATH'", "]", ")", ";", "}", "else", "if", "(", "(", "$", "envPath", "=", "getenv", "(", "'PATH'", ")", ")", "!==", "false", ")", "{", "$", "envPath", "=", "trim", "(", "$", "envPath", ")", ";", "}", "if", "(", "is_string", "(", "$", "envPath", ")", "&&", "strlen", "(", "trim", "(", "$", "envPath", ")", ")", "==", "0", ")", "{", "$", "envPath", "=", "false", ";", "}", "switch", "(", "self", "::", "os", "(", ")", ")", "{", "case", "'Unix'", ":", "case", "'FreeBSD'", ":", "case", "'Mac'", ":", "case", "'MacOS'", ":", "case", "'Darwin'", ":", "case", "'Linux'", ":", "case", "'SunOS'", ":", "if", "(", "$", "envPath", ")", "{", "$", "dirs", "=", "explode", "(", "':'", ",", "$", "envPath", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "// The @-operator is used here mainly to avoid", "// open_basedir warnings. If open_basedir (or any other", "// circumstance) prevents the desired file from being", "// accessed, it is fine for file_exists() to return", "// false, since it is useless for use then, anyway.", "if", "(", "file_exists", "(", "\"{$dir}/{$fileName}\"", ")", ")", "{", "return", "\"{$dir}/{$fileName}\"", ";", "}", "}", "}", "// The @-operator is used here mainly to avoid open_basedir", "// warnings. If open_basedir (or any other circumstance)", "// prevents the desired file from being accessed, it is fine", "// for file_exists() to return false, since it is useless for", "// use then, anyway.", "elseif", "(", "@", "file_exists", "(", "\"./{$fileName}\"", ")", ")", "{", "return", "$", "fileName", ";", "}", "break", ";", "case", "'Windows'", ":", "if", "(", "$", "envPath", ")", "{", "$", "dirs", "=", "explode", "(", "';'", ",", "$", "envPath", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "// The @-operator is used here mainly to avoid", "// open_basedir warnings. If open_basedir (or any other", "// circumstance) prevents the desired file from being", "// accessed, it is fine for file_exists() to return", "// false, since it is useless for use then, anyway.", "if", "(", "@", "file_exists", "(", "\"{$dir}\\\\{$fileName}.exe\"", ")", ")", "{", "return", "\"{$dir}\\\\{$fileName}.exe\"", ";", "}", "}", "}", "// The @-operator is used here mainly to avoid open_basedir", "// warnings. If open_basedir (or any other circumstance)", "// prevents the desired file from being accessed, it is fine", "// for file_exists() to return false, since it is useless for", "// use then, anyway.", "elseif", "(", "@", "file_exists", "(", "\"{$fileName}.exe\"", ")", ")", "{", "return", "\"{$fileName}.exe\"", ";", "}", "break", ";", "}", "return", "null", ";", "}" ]
Returns the path of the specified executable, if it can be found in the system's path. It scans the PATH enviroment variable based on the OS to find the $fileName. For Windows, the path is with \, not /. If $fileName is not found, it returns null. @todo consider using getenv( 'PATH' ) instead of $_ENV['PATH'] (but that won't work under IIS) @param string $fileName @return string
[ "Returns", "the", "path", "of", "the", "specified", "executable", "if", "it", "can", "be", "found", "in", "the", "system", "s", "path", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L270-L349
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.reset
public static function reset() { self::$imageIdentify = null; self::$imageConvert = null; self::$os = null; }
php
public static function reset() { self::$imageIdentify = null; self::$imageConvert = null; self::$os = null; }
[ "public", "static", "function", "reset", "(", ")", "{", "self", "::", "$", "imageIdentify", "=", "null", ";", "self", "::", "$", "imageConvert", "=", "null", ";", "self", "::", "$", "os", "=", "null", ";", "}" ]
Reset the cached information. @return void @access private @ignore
[ "Reset", "the", "cached", "information", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L358-L363
kenphp/ken
src/Log/Targets/FileTarget.php
FileTarget.collect
public function collect(array $messages) { $logMessages = ''; foreach ($messages as $value) { $logMessages .= $this->_formatter->formatLog($value) . "\n"; } $this->writeLog($logMessages); }
php
public function collect(array $messages) { $logMessages = ''; foreach ($messages as $value) { $logMessages .= $this->_formatter->formatLog($value) . "\n"; } $this->writeLog($logMessages); }
[ "public", "function", "collect", "(", "array", "$", "messages", ")", "{", "$", "logMessages", "=", "''", ";", "foreach", "(", "$", "messages", "as", "$", "value", ")", "{", "$", "logMessages", ".=", "$", "this", "->", "_formatter", "->", "formatLog", "(", "$", "value", ")", ".", "\"\\n\"", ";", "}", "$", "this", "->", "writeLog", "(", "$", "logMessages", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/Targets/FileTarget.php#L54-L63
kenphp/ken
src/Log/Targets/FileTarget.php
FileTarget.writeLog
private function writeLog($log) { $fh = fopen($this->_filepath, 'a'); fwrite($fh, $log); fclose($fh); }
php
private function writeLog($log) { $fh = fopen($this->_filepath, 'a'); fwrite($fh, $log); fclose($fh); }
[ "private", "function", "writeLog", "(", "$", "log", ")", "{", "$", "fh", "=", "fopen", "(", "$", "this", "->", "_filepath", ",", "'a'", ")", ";", "fwrite", "(", "$", "fh", ",", "$", "log", ")", ";", "fclose", "(", "$", "fh", ")", ";", "}" ]
Writes log to media. @param string $log
[ "Writes", "log", "to", "media", "." ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/Targets/FileTarget.php#L70-L76
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Aspect/PublishingAspect.php
PublishingAspect.publishEventAdvice
public function publishEventAdvice(JoinPointInterface $joinPoint) { $event = array_values($joinPoint->getMethodArguments())[0]; $this->broker->queueEvent($event); }
php
public function publishEventAdvice(JoinPointInterface $joinPoint) { $event = array_values($joinPoint->getMethodArguments())[0]; $this->broker->queueEvent($event); }
[ "public", "function", "publishEventAdvice", "(", "JoinPointInterface", "$", "joinPoint", ")", "{", "$", "event", "=", "array_values", "(", "$", "joinPoint", "->", "getMethodArguments", "(", ")", ")", "[", "0", "]", ";", "$", "this", "->", "broker", "->", "queueEvent", "(", "$", "event", ")", ";", "}" ]
Publishes an event as soon as a method with an event annotation is called. @param JoinPointInterface $joinPoint The join point. @return void @Flow\After("methodAnnotatedWith(Helmich\EventBroker\Annotations\Event)")
[ "Publishes", "an", "event", "as", "soon", "as", "a", "method", "with", "an", "event", "annotation", "is", "called", "." ]
train
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Aspect/PublishingAspect.php#L47-L51
inhere/php-librarys
src/Traits/OptionsTrait.php
OptionsTrait.getOption
public function getOption(string $name, $default = null) { $value = array_key_exists($name, $this->options) ? $this->options[$name] : $default; if ($value && ($value instanceof \Closure)) { $value = $value(); } return $value; }
php
public function getOption(string $name, $default = null) { $value = array_key_exists($name, $this->options) ? $this->options[$name] : $default; if ($value && ($value instanceof \Closure)) { $value = $value(); } return $value; }
[ "public", "function", "getOption", "(", "string", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "options", ")", "?", "$", "this", "->", "options", "[", "$", "name", "]", ":", "$", "default", ";", "if", "(", "$", "value", "&&", "(", "$", "value", "instanceof", "\\", "Closure", ")", ")", "{", "$", "value", "=", "$", "value", "(", ")", ";", "}", "return", "$", "value", ";", "}" ]
Method to get property Options @param string $name @param mixed $default @return mixed
[ "Method", "to", "get", "property", "Options" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/OptionsTrait.php#L37-L46
hametuha/wpametu
src/WPametu/Utility/WPametuCommand.php
WPametuCommand.assets
public function assets( $args, $assoc_args ) { list( $type ) = $args; $global = self::get_flag( 'global', $assoc_args ); if ( false === array_search( $type, [ 'css', 'js' ] ) ) { self::e( $this->__( 'Only css and js are supported.' ) ); } $header = [ 'Handle', 'Source', 'Dependency', 'Version', 'css' === $type ? 'Media' : 'Footer', ]; $rows = []; if ( $global ) { switch ( $type ) { case 'js': break; case 'css': break; default: // Do nothing break; } } else { $assets = Library::all_assets()[ $type ]; foreach ( $assets as $handle => $asset ) { $rows[] = array_merge( [ $handle ], array_map( function ( $var ) { if ( is_bool( $var ) ) { return $var ? 'Yes' : 'No'; } elseif ( is_array( $var ) ) { return empty( $var ) ? '-' : implode( ', ', $var ); } elseif ( is_null( $var ) ) { return '-'; } else { return $var; } }, $asset ) ); } } self::table( $header, $rows ); self::l( '' ); self::s( sprintf( '%d %s are available on WPametu.', count( $rows ), $type ) ); }
php
public function assets( $args, $assoc_args ) { list( $type ) = $args; $global = self::get_flag( 'global', $assoc_args ); if ( false === array_search( $type, [ 'css', 'js' ] ) ) { self::e( $this->__( 'Only css and js are supported.' ) ); } $header = [ 'Handle', 'Source', 'Dependency', 'Version', 'css' === $type ? 'Media' : 'Footer', ]; $rows = []; if ( $global ) { switch ( $type ) { case 'js': break; case 'css': break; default: // Do nothing break; } } else { $assets = Library::all_assets()[ $type ]; foreach ( $assets as $handle => $asset ) { $rows[] = array_merge( [ $handle ], array_map( function ( $var ) { if ( is_bool( $var ) ) { return $var ? 'Yes' : 'No'; } elseif ( is_array( $var ) ) { return empty( $var ) ? '-' : implode( ', ', $var ); } elseif ( is_null( $var ) ) { return '-'; } else { return $var; } }, $asset ) ); } } self::table( $header, $rows ); self::l( '' ); self::s( sprintf( '%d %s are available on WPametu.', count( $rows ), $type ) ); }
[ "public", "function", "assets", "(", "$", "args", ",", "$", "assoc_args", ")", "{", "list", "(", "$", "type", ")", "=", "$", "args", ";", "$", "global", "=", "self", "::", "get_flag", "(", "'global'", ",", "$", "assoc_args", ")", ";", "if", "(", "false", "===", "array_search", "(", "$", "type", ",", "[", "'css'", ",", "'js'", "]", ")", ")", "{", "self", "::", "e", "(", "$", "this", "->", "__", "(", "'Only css and js are supported.'", ")", ")", ";", "}", "$", "header", "=", "[", "'Handle'", ",", "'Source'", ",", "'Dependency'", ",", "'Version'", ",", "'css'", "===", "$", "type", "?", "'Media'", ":", "'Footer'", ",", "]", ";", "$", "rows", "=", "[", "]", ";", "if", "(", "$", "global", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'js'", ":", "break", ";", "case", "'css'", ":", "break", ";", "default", ":", "// Do nothing", "break", ";", "}", "}", "else", "{", "$", "assets", "=", "Library", "::", "all_assets", "(", ")", "[", "$", "type", "]", ";", "foreach", "(", "$", "assets", "as", "$", "handle", "=>", "$", "asset", ")", "{", "$", "rows", "[", "]", "=", "array_merge", "(", "[", "$", "handle", "]", ",", "array_map", "(", "function", "(", "$", "var", ")", "{", "if", "(", "is_bool", "(", "$", "var", ")", ")", "{", "return", "$", "var", "?", "'Yes'", ":", "'No'", ";", "}", "elseif", "(", "is_array", "(", "$", "var", ")", ")", "{", "return", "empty", "(", "$", "var", ")", "?", "'-'", ":", "implode", "(", "', '", ",", "$", "var", ")", ";", "}", "elseif", "(", "is_null", "(", "$", "var", ")", ")", "{", "return", "'-'", ";", "}", "else", "{", "return", "$", "var", ";", "}", "}", ",", "$", "asset", ")", ")", ";", "}", "}", "self", "::", "table", "(", "$", "header", ",", "$", "rows", ")", ";", "self", "::", "l", "(", "''", ")", ";", "self", "::", "s", "(", "sprintf", "(", "'%d %s are available on WPametu.'", ",", "count", "(", "$", "rows", ")", ",", "$", "type", ")", ")", ";", "}" ]
Show all asset libraries of WPametu ## OPTIONS <type> : Assets type. 'css', 'js' are supported. [--global] : Show global assets registered without WPametu ## EXAMPLES wp ametu assets css @synopsis <type> [--global]
[ "Show", "all", "asset", "libraries", "of", "WPametu" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/WPametuCommand.php#L41-L87
hametuha/wpametu
src/WPametu/Utility/WPametuCommand.php
WPametuCommand.akismet
public function akismet() { try { if ( ! class_exists( 'Akismet' ) ) { throw new \Exception( 'Akismet is not installed.' ); } if ( ! ( $key = \Akismet::get_api_key() ) ) { throw new \Exception( 'Akismet API key is not set.' ); } if ( 'valid' !== \Akismet::verify_key( $key ) ) { throw new \Exception( 'Akismet API key is invalid.' ); } static::s( 'Akismet is available!' ); } catch ( \Exception $e ) { static::e( $e->getMessage() ); } }
php
public function akismet() { try { if ( ! class_exists( 'Akismet' ) ) { throw new \Exception( 'Akismet is not installed.' ); } if ( ! ( $key = \Akismet::get_api_key() ) ) { throw new \Exception( 'Akismet API key is not set.' ); } if ( 'valid' !== \Akismet::verify_key( $key ) ) { throw new \Exception( 'Akismet API key is invalid.' ); } static::s( 'Akismet is available!' ); } catch ( \Exception $e ) { static::e( $e->getMessage() ); } }
[ "public", "function", "akismet", "(", ")", "{", "try", "{", "if", "(", "!", "class_exists", "(", "'Akismet'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Akismet is not installed.'", ")", ";", "}", "if", "(", "!", "(", "$", "key", "=", "\\", "Akismet", "::", "get_api_key", "(", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Akismet API key is not set.'", ")", ";", "}", "if", "(", "'valid'", "!==", "\\", "Akismet", "::", "verify_key", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Akismet API key is invalid.'", ")", ";", "}", "static", "::", "s", "(", "'Akismet is available!'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "static", "::", "e", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Check if akismet is available ## OPTIONS ## EXAMPLES wp ametu akismet @synopsis
[ "Check", "if", "akismet", "is", "available" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/WPametuCommand.php#L100-L115
phpinnacle/identity
src/UUID.php
UUID.url
public static function url(string $value): self { return new self(Implementation::uuid5(Implementation::NAMESPACE_URL, $value)->toString()); }
php
public static function url(string $value): self { return new self(Implementation::uuid5(Implementation::NAMESPACE_URL, $value)->toString()); }
[ "public", "static", "function", "url", "(", "string", "$", "value", ")", ":", "self", "{", "return", "new", "self", "(", "Implementation", "::", "uuid5", "(", "Implementation", "::", "NAMESPACE_URL", ",", "$", "value", ")", "->", "toString", "(", ")", ")", ";", "}" ]
@param string $value @return self
[ "@param", "string", "$value" ]
train
https://github.com/phpinnacle/identity/blob/2c535ec25ee6eab76704c6a7b0a9e2e5437af9ad/src/UUID.php#L57-L60
kecik-framework/kecik
Kecik/Config.php
Config.get
public static function get( $key ) { if ( isset( self::$config[ strtolower( $key ) ] ) ) { return self::$config[ strtolower( $key ) ]; } else { return ''; } }
php
public static function get( $key ) { if ( isset( self::$config[ strtolower( $key ) ] ) ) { return self::$config[ strtolower( $key ) ]; } else { return ''; } }
[ "public", "static", "function", "get", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "config", "[", "strtolower", "(", "$", "key", ")", "]", ")", ")", "{", "return", "self", "::", "$", "config", "[", "strtolower", "(", "$", "key", ")", "]", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Get configuration @param $key @return string
[ "Get", "configuration" ]
train
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Config.php#L49-L57
kecik-framework/kecik
Kecik/Config.php
Config.delete
public static function delete( $key ) { if ( isset( self::$config[ strtolower( $key ) ] ) ) { unset( self::$config[ strtolower( $key ) ] ); } }
php
public static function delete( $key ) { if ( isset( self::$config[ strtolower( $key ) ] ) ) { unset( self::$config[ strtolower( $key ) ] ); } }
[ "public", "static", "function", "delete", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "config", "[", "strtolower", "(", "$", "key", ")", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "config", "[", "strtolower", "(", "$", "key", ")", "]", ")", ";", "}", "}" ]
Delete configuration @param $key
[ "Delete", "configuration" ]
train
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Config.php#L64-L70
php-lug/lug
src/Bundle/GridBundle/Behat/Context/GridWebContext.php
GridWebContext.findBatch
public function findBatch($cell = null) { if ($cell === null) { \PHPUnit_Framework_Assert::assertNotNull( $batch = $this->findHeader(1)->find('xpath', '/input'), 'The grid toggle batch checkbox could not be found.' ); return $batch; } $xpath = '/../td[1]/input'; \PHPUnit_Framework_Assert::assertNotNull( $batch = $this->findCell(null, null, $cell)->find('xpath', $xpath), sprintf('The grid column batch checkbox of the cell "%s" could not be found.', $cell) ); return $batch; }
php
public function findBatch($cell = null) { if ($cell === null) { \PHPUnit_Framework_Assert::assertNotNull( $batch = $this->findHeader(1)->find('xpath', '/input'), 'The grid toggle batch checkbox could not be found.' ); return $batch; } $xpath = '/../td[1]/input'; \PHPUnit_Framework_Assert::assertNotNull( $batch = $this->findCell(null, null, $cell)->find('xpath', $xpath), sprintf('The grid column batch checkbox of the cell "%s" could not be found.', $cell) ); return $batch; }
[ "public", "function", "findBatch", "(", "$", "cell", "=", "null", ")", "{", "if", "(", "$", "cell", "===", "null", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotNull", "(", "$", "batch", "=", "$", "this", "->", "findHeader", "(", "1", ")", "->", "find", "(", "'xpath'", ",", "'/input'", ")", ",", "'The grid toggle batch checkbox could not be found.'", ")", ";", "return", "$", "batch", ";", "}", "$", "xpath", "=", "'/../td[1]/input'", ";", "\\", "PHPUnit_Framework_Assert", "::", "assertNotNull", "(", "$", "batch", "=", "$", "this", "->", "findCell", "(", "null", ",", "null", ",", "$", "cell", ")", "->", "find", "(", "'xpath'", ",", "$", "xpath", ")", ",", "sprintf", "(", "'The grid column batch checkbox of the cell \"%s\" could not be found.'", ",", "$", "cell", ")", ")", ";", "return", "$", "batch", ";", "}" ]
@param string|null $cell @return NodeElement
[ "@param", "string|null", "$cell" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Behat/Context/GridWebContext.php#L266-L285
php-lug/lug
src/Bundle/GridBundle/Behat/Context/GridWebContext.php
GridWebContext.findHeaderIndex
public function findHeaderIndex($header) { $xpath = $this->findHeader($header)->getXpath().'/preceding::*'; return count($this->getPage()->findAll('xpath', $xpath)) + 1; }
php
public function findHeaderIndex($header) { $xpath = $this->findHeader($header)->getXpath().'/preceding::*'; return count($this->getPage()->findAll('xpath', $xpath)) + 1; }
[ "public", "function", "findHeaderIndex", "(", "$", "header", ")", "{", "$", "xpath", "=", "$", "this", "->", "findHeader", "(", "$", "header", ")", "->", "getXpath", "(", ")", ".", "'/preceding::*'", ";", "return", "count", "(", "$", "this", "->", "getPage", "(", ")", "->", "findAll", "(", "'xpath'", ",", "$", "xpath", ")", ")", "+", "1", ";", "}" ]
@param string $header @return int
[ "@param", "string", "$header" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Behat/Context/GridWebContext.php#L292-L297
php-lug/lug
src/Bundle/GridBundle/Behat/Context/GridWebContext.php
GridWebContext.findHeader
public function findHeader($header) { $xpath = '/thead/tr/th'.(is_int($header) ? '['.$header.']' : '[contains(text(), "'.$header.'")]'); \PHPUnit_Framework_Assert::assertNotNull( $node = $this->findGrid()->find('xpath', $xpath), sprintf('The grid header "%s" could not be found.', $header) ); return $node; }
php
public function findHeader($header) { $xpath = '/thead/tr/th'.(is_int($header) ? '['.$header.']' : '[contains(text(), "'.$header.'")]'); \PHPUnit_Framework_Assert::assertNotNull( $node = $this->findGrid()->find('xpath', $xpath), sprintf('The grid header "%s" could not be found.', $header) ); return $node; }
[ "public", "function", "findHeader", "(", "$", "header", ")", "{", "$", "xpath", "=", "'/thead/tr/th'", ".", "(", "is_int", "(", "$", "header", ")", "?", "'['", ".", "$", "header", ".", "']'", ":", "'[contains(text(), \"'", ".", "$", "header", ".", "'\")]'", ")", ";", "\\", "PHPUnit_Framework_Assert", "::", "assertNotNull", "(", "$", "node", "=", "$", "this", "->", "findGrid", "(", ")", "->", "find", "(", "'xpath'", ",", "$", "xpath", ")", ",", "sprintf", "(", "'The grid header \"%s\" could not be found.'", ",", "$", "header", ")", ")", ";", "return", "$", "node", ";", "}" ]
@param string|int $header @return NodeElement
[ "@param", "string|int", "$header" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Behat/Context/GridWebContext.php#L304-L314
php-lug/lug
src/Bundle/GridBundle/Behat/Context/GridWebContext.php
GridWebContext.findCell
public function findCell($row = null, $column = null, $value = null) { $rowXPath = $row; $columnXPath = $column; $valueXPath = $value; if ($row !== null) { $rowXPath = '['.$row.']'; } if ($column !== null) { $columnXPath = '['.$column.']'; } if ($value !== null) { $valueXPath = '[contains(text(), "'.$value.'")]'; } $xpath = '/tbody/tr'.$rowXPath.'/td'.$columnXPath.$valueXPath; if ($value !== null || ($row !== null && $column !== null)) { \PHPUnit_Framework_Assert::assertNotNull( $cell = $this->findGrid()->find('xpath', $xpath), sprintf( 'The grid cell could not be found (row: %s, column: %s, value: %s).', $row !== null ? $row : 'none', $column !== null ? $column : 'none', $value !== null ? $value : 'none' ) ); return $cell; } return $this->findGrid()->findAll('xpath', $xpath); }
php
public function findCell($row = null, $column = null, $value = null) { $rowXPath = $row; $columnXPath = $column; $valueXPath = $value; if ($row !== null) { $rowXPath = '['.$row.']'; } if ($column !== null) { $columnXPath = '['.$column.']'; } if ($value !== null) { $valueXPath = '[contains(text(), "'.$value.'")]'; } $xpath = '/tbody/tr'.$rowXPath.'/td'.$columnXPath.$valueXPath; if ($value !== null || ($row !== null && $column !== null)) { \PHPUnit_Framework_Assert::assertNotNull( $cell = $this->findGrid()->find('xpath', $xpath), sprintf( 'The grid cell could not be found (row: %s, column: %s, value: %s).', $row !== null ? $row : 'none', $column !== null ? $column : 'none', $value !== null ? $value : 'none' ) ); return $cell; } return $this->findGrid()->findAll('xpath', $xpath); }
[ "public", "function", "findCell", "(", "$", "row", "=", "null", ",", "$", "column", "=", "null", ",", "$", "value", "=", "null", ")", "{", "$", "rowXPath", "=", "$", "row", ";", "$", "columnXPath", "=", "$", "column", ";", "$", "valueXPath", "=", "$", "value", ";", "if", "(", "$", "row", "!==", "null", ")", "{", "$", "rowXPath", "=", "'['", ".", "$", "row", ".", "']'", ";", "}", "if", "(", "$", "column", "!==", "null", ")", "{", "$", "columnXPath", "=", "'['", ".", "$", "column", ".", "']'", ";", "}", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "valueXPath", "=", "'[contains(text(), \"'", ".", "$", "value", ".", "'\")]'", ";", "}", "$", "xpath", "=", "'/tbody/tr'", ".", "$", "rowXPath", ".", "'/td'", ".", "$", "columnXPath", ".", "$", "valueXPath", ";", "if", "(", "$", "value", "!==", "null", "||", "(", "$", "row", "!==", "null", "&&", "$", "column", "!==", "null", ")", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotNull", "(", "$", "cell", "=", "$", "this", "->", "findGrid", "(", ")", "->", "find", "(", "'xpath'", ",", "$", "xpath", ")", ",", "sprintf", "(", "'The grid cell could not be found (row: %s, column: %s, value: %s).'", ",", "$", "row", "!==", "null", "?", "$", "row", ":", "'none'", ",", "$", "column", "!==", "null", "?", "$", "column", ":", "'none'", ",", "$", "value", "!==", "null", "?", "$", "value", ":", "'none'", ")", ")", ";", "return", "$", "cell", ";", "}", "return", "$", "this", "->", "findGrid", "(", ")", "->", "findAll", "(", "'xpath'", ",", "$", "xpath", ")", ";", "}" ]
@param int|null $row @param int|null $column @param string|null $value @return NodeElement|NodeElement[]
[ "@param", "int|null", "$row", "@param", "int|null", "$column", "@param", "string|null", "$value" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Behat/Context/GridWebContext.php#L323-L358
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.regexVerify
public static function regexVerify($value, $rule) { $value = trim($value); $validate = array( 'require' => '/\S+/', 'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', // 'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/', 'url' => '/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', 'currency' => '/^\d+(\.\d+)?$/', # 货币 'number' => '/^\d+$/', 'zip' => '/^\d{6}$/', 'integer' => '/^[-\+]?\d+$/', 'double' => '/^[-\+]?\d+(\.\d+)?$/', 'english' => '/^[A-Za-z]+$/', ); // 检查是否有内置的正则表达式 if (isset($validate[strtolower($rule)])) { $rule = $validate[strtolower($rule)]; } return preg_match($rule, $value) === 1; }
php
public static function regexVerify($value, $rule) { $value = trim($value); $validate = array( 'require' => '/\S+/', 'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', // 'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/', 'url' => '/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', 'currency' => '/^\d+(\.\d+)?$/', # 货币 'number' => '/^\d+$/', 'zip' => '/^\d{6}$/', 'integer' => '/^[-\+]?\d+$/', 'double' => '/^[-\+]?\d+(\.\d+)?$/', 'english' => '/^[A-Za-z]+$/', ); // 检查是否有内置的正则表达式 if (isset($validate[strtolower($rule)])) { $rule = $validate[strtolower($rule)]; } return preg_match($rule, $value) === 1; }
[ "public", "static", "function", "regexVerify", "(", "$", "value", ",", "$", "rule", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "$", "validate", "=", "array", "(", "'require'", "=>", "'/\\S+/'", ",", "'email'", "=>", "'/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/'", ",", "// 'url' => '/^http(s?):\\/\\/(?:[A-za-z0-9-]+\\.)+[A-za-z]{2,4}(?:[\\/\\?#][\\/=\\?%\\-&~`@[\\]\\':+!\\.#\\w]*)?$/',", "'url'", "=>", "'/^(http|https|ftp):\\/\\/([A-Z0-9][A-Z0-9_-]*(?:\\.[A-Z0-9][A-Z0-9_-]*)+):?(\\d+)?\\/?/i'", ",", "'currency'", "=>", "'/^\\d+(\\.\\d+)?$/'", ",", "# 货币", "'number'", "=>", "'/^\\d+$/'", ",", "'zip'", "=>", "'/^\\d{6}$/'", ",", "'integer'", "=>", "'/^[-\\+]?\\d+$/'", ",", "'double'", "=>", "'/^[-\\+]?\\d+(\\.\\d+)?$/'", ",", "'english'", "=>", "'/^[A-Za-z]+$/'", ",", ")", ";", "// 检查是否有内置的正则表达式", "if", "(", "isset", "(", "$", "validate", "[", "strtolower", "(", "$", "rule", ")", "]", ")", ")", "{", "$", "rule", "=", "$", "validate", "[", "strtolower", "(", "$", "rule", ")", "]", ";", "}", "return", "preg_match", "(", "$", "rule", ",", "$", "value", ")", "===", "1", ";", "}" ]
使用正则验证数据 @access public @param string $value 要验证的数据 @param string $rule 验证规则 require email url currency number integer english @return boolean
[ "使用正则验证数据" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L20-L43
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.length
public static function length($str) { if (empty($str)) { return '0'; } if ((string)$str === '0') { return '1'; } if (\function_exists('mb_strlen')) { return mb_strlen($str, 'utf-8'); } preg_match_all('/./u', $str, $arr); return \count($arr[0]); }
php
public static function length($str) { if (empty($str)) { return '0'; } if ((string)$str === '0') { return '1'; } if (\function_exists('mb_strlen')) { return mb_strlen($str, 'utf-8'); } preg_match_all('/./u', $str, $arr); return \count($arr[0]); }
[ "public", "static", "function", "length", "(", "$", "str", ")", "{", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "return", "'0'", ";", "}", "if", "(", "(", "string", ")", "$", "str", "===", "'0'", ")", "{", "return", "'1'", ";", "}", "if", "(", "\\", "function_exists", "(", "'mb_strlen'", ")", ")", "{", "return", "mb_strlen", "(", "$", "str", ",", "'utf-8'", ")", ";", "}", "preg_match_all", "(", "'/./u'", ",", "$", "str", ",", "$", "arr", ")", ";", "return", "\\", "count", "(", "$", "arr", "[", "0", "]", ")", ";", "}" ]
计算字符长度 @param [type] $str @return int|string [type]
[ "计算字符长度" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L62-L79
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.random
public static function random($length, array $param = []) { $param = array_merge([ 'prefix' => '', 'suffix' => '', 'chars' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ], $param); $chars = $param['chars']; $max = \strlen($chars) - 1; //strlen($chars) 计算字符串的长度 $str = ''; for ($i = 0; $i < $length; $i++) { $str .= $chars[random_int(0, $max)]; } return $param['prefix'] . $str . $param['suffix']; }
php
public static function random($length, array $param = []) { $param = array_merge([ 'prefix' => '', 'suffix' => '', 'chars' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ], $param); $chars = $param['chars']; $max = \strlen($chars) - 1; //strlen($chars) 计算字符串的长度 $str = ''; for ($i = 0; $i < $length; $i++) { $str .= $chars[random_int(0, $max)]; } return $param['prefix'] . $str . $param['suffix']; }
[ "public", "static", "function", "random", "(", "$", "length", ",", "array", "$", "param", "=", "[", "]", ")", "{", "$", "param", "=", "array_merge", "(", "[", "'prefix'", "=>", "''", ",", "'suffix'", "=>", "''", ",", "'chars'", "=>", "'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'", "]", ",", "$", "param", ")", ";", "$", "chars", "=", "$", "param", "[", "'chars'", "]", ";", "$", "max", "=", "\\", "strlen", "(", "$", "chars", ")", "-", "1", ";", "//strlen($chars) 计算字符串的长度", "$", "str", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "$", "str", ".=", "$", "chars", "[", "random_int", "(", "0", ",", "$", "max", ")", "]", ";", "}", "return", "$", "param", "[", "'prefix'", "]", ".", "$", "str", ".", "$", "param", "[", "'suffix'", "]", ";", "}" ]
********************** 生成一定长度的随机字符串函数 ********************** @param $length - 随机字符串长度 @param array|string $param - @internal param string $chars @return string
[ "**********************", "生成一定长度的随机字符串函数", "**********************" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L194-L211
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.genUUID
public static function genUUID($version = 1, $node = null, $ns = null) { return UUID::generate($version, $node, $ns); }
php
public static function genUUID($version = 1, $node = null, $ns = null) { return UUID::generate($version, $node, $ns); }
[ "public", "static", "function", "genUUID", "(", "$", "version", "=", "1", ",", "$", "node", "=", "null", ",", "$", "ns", "=", "null", ")", "{", "return", "UUID", "::", "generate", "(", "$", "version", ",", "$", "node", ",", "$", "ns", ")", ";", "}" ]
gen UUID @param int $version @param null $node @param null $ns @return UUID @throws \Inhere\Exceptions\InvalidArgumentException
[ "gen", "UUID" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L243-L246
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.str2array
public static function str2array($str, $sep = ',') { $str = trim($str, "$sep "); if (!$str) { return []; } return preg_split("/\s*$sep\s*/", $str, -1, PREG_SPLIT_NO_EMPTY); }
php
public static function str2array($str, $sep = ',') { $str = trim($str, "$sep "); if (!$str) { return []; } return preg_split("/\s*$sep\s*/", $str, -1, PREG_SPLIT_NO_EMPTY); }
[ "public", "static", "function", "str2array", "(", "$", "str", ",", "$", "sep", "=", "','", ")", "{", "$", "str", "=", "trim", "(", "$", "str", ",", "\"$sep \"", ")", ";", "if", "(", "!", "$", "str", ")", "{", "return", "[", "]", ";", "}", "return", "preg_split", "(", "\"/\\s*$sep\\s*/\"", ",", "$", "str", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "}" ]
var_dump(str2array('34,56,678, 678, 89, ')); @param string $str @param string $sep @return array
[ "var_dump", "(", "str2array", "(", "34", "56", "678", "678", "89", "))", ";" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L377-L386
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.truncate
public static function truncate($str, $max_length, $suffix = '...') { if (self::strlen($str) <= $max_length) { return $str; } $str = utf8_decode($str); return utf8_encode(substr($str, 0, $max_length - self::strlen($suffix)) . $suffix); }
php
public static function truncate($str, $max_length, $suffix = '...') { if (self::strlen($str) <= $max_length) { return $str; } $str = utf8_decode($str); return utf8_encode(substr($str, 0, $max_length - self::strlen($suffix)) . $suffix); }
[ "public", "static", "function", "truncate", "(", "$", "str", ",", "$", "max_length", ",", "$", "suffix", "=", "'...'", ")", "{", "if", "(", "self", "::", "strlen", "(", "$", "str", ")", "<=", "$", "max_length", ")", "{", "return", "$", "str", ";", "}", "$", "str", "=", "utf8_decode", "(", "$", "str", ")", ";", "return", "utf8_encode", "(", "substr", "(", "$", "str", ",", "0", ",", "$", "max_length", "-", "self", "::", "strlen", "(", "$", "suffix", ")", ")", ".", "$", "suffix", ")", ";", "}" ]
/* CAUTION : Use it only on module hookEvents. * For other purposes use the smarty function instead
[ "/", "*", "CAUTION", ":", "Use", "it", "only", "on", "module", "hookEvents", ".", "*", "For", "other", "purposes", "use", "the", "smarty", "function", "instead" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L407-L416
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.truncate_two
public static function truncate_two($str, $start, $length = null) { if (!$length) { $length = $start; $start = 0; } if (\strlen($str) <= $length) { return $str; } if (\function_exists('mb_substr')) { $str = mb_substr(strip_tags($str), $start, $length, 'utf-8'); } else { $str = substr($str, $start, $length) . '...'; } return $str; }
php
public static function truncate_two($str, $start, $length = null) { if (!$length) { $length = $start; $start = 0; } if (\strlen($str) <= $length) { return $str; } if (\function_exists('mb_substr')) { $str = mb_substr(strip_tags($str), $start, $length, 'utf-8'); } else { $str = substr($str, $start, $length) . '...'; } return $str; }
[ "public", "static", "function", "truncate_two", "(", "$", "str", ",", "$", "start", ",", "$", "length", "=", "null", ")", "{", "if", "(", "!", "$", "length", ")", "{", "$", "length", "=", "$", "start", ";", "$", "start", "=", "0", ";", "}", "if", "(", "\\", "strlen", "(", "$", "str", ")", "<=", "$", "length", ")", "{", "return", "$", "str", ";", "}", "if", "(", "\\", "function_exists", "(", "'mb_substr'", ")", ")", "{", "$", "str", "=", "mb_substr", "(", "strip_tags", "(", "$", "str", ")", ",", "$", "start", ",", "$", "length", ",", "'utf-8'", ")", ";", "}", "else", "{", "$", "str", "=", "substr", "(", "$", "str", ",", "$", "start", ",", "$", "length", ")", ".", "'...'", ";", "}", "return", "$", "str", ";", "}" ]
字符截断输出 @param string $str @param int $start @param null|int $length @return string
[ "字符截断输出" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L425-L443
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.toCamelCase
public static function toCamelCase($str, $upperFirstChar = false) { $str = self::strtolower($str); if ($upperFirstChar) { $str = self::ucfirst($str); } return preg_replace_callback('/_+([a-z])/', function ($c) { return strtoupper($c[1]); }, $str); }
php
public static function toCamelCase($str, $upperFirstChar = false) { $str = self::strtolower($str); if ($upperFirstChar) { $str = self::ucfirst($str); } return preg_replace_callback('/_+([a-z])/', function ($c) { return strtoupper($c[1]); }, $str); }
[ "public", "static", "function", "toCamelCase", "(", "$", "str", ",", "$", "upperFirstChar", "=", "false", ")", "{", "$", "str", "=", "self", "::", "strtolower", "(", "$", "str", ")", ";", "if", "(", "$", "upperFirstChar", ")", "{", "$", "str", "=", "self", "::", "ucfirst", "(", "$", "str", ")", ";", "}", "return", "preg_replace_callback", "(", "'/_+([a-z])/'", ",", "function", "(", "$", "c", ")", "{", "return", "strtoupper", "(", "$", "c", "[", "1", "]", ")", ";", "}", ",", "$", "str", ")", ";", "}" ]
Translates a string with underscores into camel case (e.g. first_name -> firstName) @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false]) @param $str @param bool $upperFirstChar @return mixed
[ "Translates", "a", "string", "with", "underscores", "into", "camel", "case", "(", "e", ".", "g", ".", "first_name", "-", ">", "firstName", ")" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L591-L602
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.toSnakeCase
public static function toSnakeCase($str, $sep = '_') { // 'CMSCategories' => 'cms_categories' // 'RangePrice' => 'range_price' return self::strtolower(trim(preg_replace('/([A-Z][a-z])/', $sep . '$1', $str), $sep)); }
php
public static function toSnakeCase($str, $sep = '_') { // 'CMSCategories' => 'cms_categories' // 'RangePrice' => 'range_price' return self::strtolower(trim(preg_replace('/([A-Z][a-z])/', $sep . '$1', $str), $sep)); }
[ "public", "static", "function", "toSnakeCase", "(", "$", "str", ",", "$", "sep", "=", "'_'", ")", "{", "// 'CMSCategories' => 'cms_categories'", "// 'RangePrice' => 'range_price'", "return", "self", "::", "strtolower", "(", "trim", "(", "preg_replace", "(", "'/([A-Z][a-z])/'", ",", "$", "sep", ".", "'$1'", ",", "$", "str", ")", ",", "$", "sep", ")", ")", ";", "}" ]
Transform a CamelCase string to underscore_case string @param string $str @param string $sep @return string
[ "Transform", "a", "CamelCase", "string", "to", "underscore_case", "string" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L615-L620
inhere/php-librarys
src/Helpers/StringHelper.php
StringHelper.format
public static function format($str, array $replaceParams = [], array $pregParams = []) { if (!\is_string($str) || !$str || (!$replaceParams && !$pregParams)) { return $str; } if ($replaceParams && \count($replaceParams) === 2) { list($search, $replace) = $replaceParams; $str = str_replace($search, $replace, $str); } if ($pregParams && \count($pregParams) === 2) { list($pattern, $replace) = $pregParams; $str = preg_replace($pattern, $replace, $str); } return trim($str); }
php
public static function format($str, array $replaceParams = [], array $pregParams = []) { if (!\is_string($str) || !$str || (!$replaceParams && !$pregParams)) { return $str; } if ($replaceParams && \count($replaceParams) === 2) { list($search, $replace) = $replaceParams; $str = str_replace($search, $replace, $str); } if ($pregParams && \count($pregParams) === 2) { list($pattern, $replace) = $pregParams; $str = preg_replace($pattern, $replace, $str); } return trim($str); }
[ "public", "static", "function", "format", "(", "$", "str", ",", "array", "$", "replaceParams", "=", "[", "]", ",", "array", "$", "pregParams", "=", "[", "]", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "str", ")", "||", "!", "$", "str", "||", "(", "!", "$", "replaceParams", "&&", "!", "$", "pregParams", ")", ")", "{", "return", "$", "str", ";", "}", "if", "(", "$", "replaceParams", "&&", "\\", "count", "(", "$", "replaceParams", ")", "===", "2", ")", "{", "list", "(", "$", "search", ",", "$", "replace", ")", "=", "$", "replaceParams", ";", "$", "str", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "str", ")", ";", "}", "if", "(", "$", "pregParams", "&&", "\\", "count", "(", "$", "pregParams", ")", "===", "2", ")", "{", "list", "(", "$", "pattern", ",", "$", "replace", ")", "=", "$", "pregParams", ";", "$", "str", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replace", ",", "$", "str", ")", ";", "}", "return", "trim", "(", "$", "str", ")", ";", "}" ]
[format description] @param $str @param array $replaceParams 用于 str_replace('search','replace',$str ) @example $replaceParams = [ 'xx', //'search' 'yy', //'replace' ] $replaceParams = [ ['xx','xx2'], //'search' ['yy','yy2'], //'replace' ] @param array $pregParams 用于 preg_replace('pattern','replace',$str) @example $pregParams = [ 'xx', //'pattern' 'yy', //'replace' ] * $pregParams = [ ['xx','xx2'], //'pattern' ['yy','yy2'], //'replace' ] @return string [type] [description]
[ "[", "format", "description", "]" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/StringHelper.php#L679-L696
heidelpay/PhpDoc
src/phpDocumentor/Parser/File.php
File.parse
public function parse($filename, ProjectDescriptorBuilder $builder) { if (class_exists('phpDocumentor\Event\Dispatcher')) { Dispatcher::getInstance()->dispatch( 'parser.file.pre', PreFileEvent::createInstance($this)->setFile($filename) ); } $this->log('Starting to parse file: ' . $filename); try { $file = $this->createFileReflector($builder, $filename); if (!$file) { $this->log('>> Skipped file ' . $filename . ' as no modifications were detected'); return; } $file->process(); $builder->buildFileUsingSourceData($file); $this->logErrorsForDescriptor($builder->getProjectDescriptor()->getFiles()->get($file->getFilename())); } catch (Exception $e) { $this->log( ' Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(), LogLevel::ALERT ); } }
php
public function parse($filename, ProjectDescriptorBuilder $builder) { if (class_exists('phpDocumentor\Event\Dispatcher')) { Dispatcher::getInstance()->dispatch( 'parser.file.pre', PreFileEvent::createInstance($this)->setFile($filename) ); } $this->log('Starting to parse file: ' . $filename); try { $file = $this->createFileReflector($builder, $filename); if (!$file) { $this->log('>> Skipped file ' . $filename . ' as no modifications were detected'); return; } $file->process(); $builder->buildFileUsingSourceData($file); $this->logErrorsForDescriptor($builder->getProjectDescriptor()->getFiles()->get($file->getFilename())); } catch (Exception $e) { $this->log( ' Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(), LogLevel::ALERT ); } }
[ "public", "function", "parse", "(", "$", "filename", ",", "ProjectDescriptorBuilder", "$", "builder", ")", "{", "if", "(", "class_exists", "(", "'phpDocumentor\\Event\\Dispatcher'", ")", ")", "{", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "'parser.file.pre'", ",", "PreFileEvent", "::", "createInstance", "(", "$", "this", ")", "->", "setFile", "(", "$", "filename", ")", ")", ";", "}", "$", "this", "->", "log", "(", "'Starting to parse file: '", ".", "$", "filename", ")", ";", "try", "{", "$", "file", "=", "$", "this", "->", "createFileReflector", "(", "$", "builder", ",", "$", "filename", ")", ";", "if", "(", "!", "$", "file", ")", "{", "$", "this", "->", "log", "(", "'>> Skipped file '", ".", "$", "filename", ".", "' as no modifications were detected'", ")", ";", "return", ";", "}", "$", "file", "->", "process", "(", ")", ";", "$", "builder", "->", "buildFileUsingSourceData", "(", "$", "file", ")", ";", "$", "this", "->", "logErrorsForDescriptor", "(", "$", "builder", "->", "getProjectDescriptor", "(", ")", "->", "getFiles", "(", ")", "->", "get", "(", "$", "file", "->", "getFilename", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "log", "(", "' Unable to parse file \"'", ".", "$", "filename", ".", "'\", an error was detected: '", ".", "$", "e", "->", "getMessage", "(", ")", ",", "LogLevel", "::", "ALERT", ")", ";", "}", "}" ]
Parses the file identified by the given filename and passes the resulting FileDescriptor to the ProjectBuilder. @param string $filename @param ProjectDescriptorBuilder $builder @return void
[ "Parses", "the", "file", "identified", "by", "the", "given", "filename", "and", "passes", "the", "resulting", "FileDescriptor", "to", "the", "ProjectBuilder", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L49-L75
heidelpay/PhpDoc
src/phpDocumentor/Parser/File.php
File.createFileReflector
protected function createFileReflector(ProjectDescriptorBuilder $builder, $filename) { $file = new FileReflector($filename, $this->parser->doValidation(), $this->parser->getEncoding()); $file->setDefaultPackageName($this->parser->getDefaultPackageName()); $file->setMarkers($this->parser->getMarkers()); $file->setFilename($this->getRelativeFilename($filename)); $cachedFiles = $builder->getProjectDescriptor()->getFiles(); $hash = $cachedFiles->get($file->getFilename()) ? $cachedFiles->get($file->getFilename())->getHash() : null; return $hash === $file->getHash() && !$this->parser->isForced() ? null : $file; }
php
protected function createFileReflector(ProjectDescriptorBuilder $builder, $filename) { $file = new FileReflector($filename, $this->parser->doValidation(), $this->parser->getEncoding()); $file->setDefaultPackageName($this->parser->getDefaultPackageName()); $file->setMarkers($this->parser->getMarkers()); $file->setFilename($this->getRelativeFilename($filename)); $cachedFiles = $builder->getProjectDescriptor()->getFiles(); $hash = $cachedFiles->get($file->getFilename()) ? $cachedFiles->get($file->getFilename())->getHash() : null; return $hash === $file->getHash() && !$this->parser->isForced() ? null : $file; }
[ "protected", "function", "createFileReflector", "(", "ProjectDescriptorBuilder", "$", "builder", ",", "$", "filename", ")", "{", "$", "file", "=", "new", "FileReflector", "(", "$", "filename", ",", "$", "this", "->", "parser", "->", "doValidation", "(", ")", ",", "$", "this", "->", "parser", "->", "getEncoding", "(", ")", ")", ";", "$", "file", "->", "setDefaultPackageName", "(", "$", "this", "->", "parser", "->", "getDefaultPackageName", "(", ")", ")", ";", "$", "file", "->", "setMarkers", "(", "$", "this", "->", "parser", "->", "getMarkers", "(", ")", ")", ";", "$", "file", "->", "setFilename", "(", "$", "this", "->", "getRelativeFilename", "(", "$", "filename", ")", ")", ";", "$", "cachedFiles", "=", "$", "builder", "->", "getProjectDescriptor", "(", ")", "->", "getFiles", "(", ")", ";", "$", "hash", "=", "$", "cachedFiles", "->", "get", "(", "$", "file", "->", "getFilename", "(", ")", ")", "?", "$", "cachedFiles", "->", "get", "(", "$", "file", "->", "getFilename", "(", ")", ")", "->", "getHash", "(", ")", ":", "null", ";", "return", "$", "hash", "===", "$", "file", "->", "getHash", "(", ")", "&&", "!", "$", "this", "->", "parser", "->", "isForced", "(", ")", "?", "null", ":", "$", "file", ";", "}" ]
Creates a new FileReflector for the given filename or null if the file contains no modifications. @param ProjectDescriptorBuilder $builder @param string $filename @return FileReflector|null Returns a new FileReflector or null if no modifications were detected for the given filename.
[ "Creates", "a", "new", "FileReflector", "for", "the", "given", "filename", "or", "null", "if", "the", "file", "contains", "no", "modifications", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L86-L101
heidelpay/PhpDoc
src/phpDocumentor/Parser/File.php
File.logErrorsForDescriptor
protected function logErrorsForDescriptor(FileDescriptor $fileDescriptor) { $errors = $fileDescriptor->getAllErrors(); /** @var Error $error */ foreach ($errors as $error) { $this->log($error->getCode(), $error->getSeverity(), $error->getContext()); } }
php
protected function logErrorsForDescriptor(FileDescriptor $fileDescriptor) { $errors = $fileDescriptor->getAllErrors(); /** @var Error $error */ foreach ($errors as $error) { $this->log($error->getCode(), $error->getSeverity(), $error->getContext()); } }
[ "protected", "function", "logErrorsForDescriptor", "(", "FileDescriptor", "$", "fileDescriptor", ")", "{", "$", "errors", "=", "$", "fileDescriptor", "->", "getAllErrors", "(", ")", ";", "/** @var Error $error */", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "this", "->", "log", "(", "$", "error", "->", "getCode", "(", ")", ",", "$", "error", "->", "getSeverity", "(", ")", ",", "$", "error", "->", "getContext", "(", ")", ")", ";", "}", "}" ]
Writes the errors found in the Descriptor to the log. @param FileDescriptor $fileDescriptor @return void
[ "Writes", "the", "errors", "found", "in", "the", "Descriptor", "to", "the", "log", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L110-L118
heidelpay/PhpDoc
src/phpDocumentor/Parser/File.php
File.getRelativeFilename
public function getRelativeFilename($filename) { // strip path from filename $result = ltrim(substr($filename, strlen($this->parser->getPath())), DIRECTORY_SEPARATOR); if ($result === '') { throw new \InvalidArgumentException( 'File is not present in the given project path: ' . $filename ); } return $result; }
php
public function getRelativeFilename($filename) { // strip path from filename $result = ltrim(substr($filename, strlen($this->parser->getPath())), DIRECTORY_SEPARATOR); if ($result === '') { throw new \InvalidArgumentException( 'File is not present in the given project path: ' . $filename ); } return $result; }
[ "public", "function", "getRelativeFilename", "(", "$", "filename", ")", "{", "// strip path from filename", "$", "result", "=", "ltrim", "(", "substr", "(", "$", "filename", ",", "strlen", "(", "$", "this", "->", "parser", "->", "getPath", "(", ")", ")", ")", ",", "DIRECTORY_SEPARATOR", ")", ";", "if", "(", "$", "result", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'File is not present in the given project path: '", ".", "$", "filename", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the filename, relative to the root of the project directory. @param string $filename The filename to make relative. @throws \InvalidArgumentException if file is not in the project root. @return string
[ "Returns", "the", "filename", "relative", "to", "the", "root", "of", "the", "project", "directory", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L129-L140
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/init.php
ezcBaseInit.setCallback
public static function setCallback( $identifier, $callbackClassname ) { if ( array_key_exists( $identifier, self::$callbackMap ) ) { throw new ezcBaseInitCallbackConfiguredException( $identifier, self::$callbackMap[$identifier] ); } else { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $callbackClassname, true ) ) { throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcBaseConfigurationInitializer', class_implements( $callbackClassname ) ) ) { throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname ); } self::$callbackMap[$identifier] = $callbackClassname; } }
php
public static function setCallback( $identifier, $callbackClassname ) { if ( array_key_exists( $identifier, self::$callbackMap ) ) { throw new ezcBaseInitCallbackConfiguredException( $identifier, self::$callbackMap[$identifier] ); } else { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $callbackClassname, true ) ) { throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcBaseConfigurationInitializer', class_implements( $callbackClassname ) ) ) { throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname ); } self::$callbackMap[$identifier] = $callbackClassname; } }
[ "public", "static", "function", "setCallback", "(", "$", "identifier", ",", "$", "callbackClassname", ")", "{", "if", "(", "array_key_exists", "(", "$", "identifier", ",", "self", "::", "$", "callbackMap", ")", ")", "{", "throw", "new", "ezcBaseInitCallbackConfiguredException", "(", "$", "identifier", ",", "self", "::", "$", "callbackMap", "[", "$", "identifier", "]", ")", ";", "}", "else", "{", "// Check if the passed classname actually exists", "if", "(", "!", "ezcBaseFeatures", "::", "classExists", "(", "$", "callbackClassname", ",", "true", ")", ")", "{", "throw", "new", "ezcBaseInitInvalidCallbackClassException", "(", "$", "callbackClassname", ")", ";", "}", "// Check if the passed classname actually implements the interface.", "if", "(", "!", "in_array", "(", "'ezcBaseConfigurationInitializer'", ",", "class_implements", "(", "$", "callbackClassname", ")", ")", ")", "{", "throw", "new", "ezcBaseInitInvalidCallbackClassException", "(", "$", "callbackClassname", ")", ";", "}", "self", "::", "$", "callbackMap", "[", "$", "identifier", "]", "=", "$", "callbackClassname", ";", "}", "}" ]
Adds the classname $callbackClassname as callback for the identifier $identifier. @param string $identifier @param string $callbackClassname
[ "Adds", "the", "classname", "$callbackClassname", "as", "callback", "for", "the", "identifier", "$identifier", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/init.php#L81-L103
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/init.php
ezcBaseInit.fetchConfig
public static function fetchConfig( $identifier, $object ) { if ( isset( self::$callbackMap[$identifier] ) ) { $callbackClassname = self::$callbackMap[$identifier]; return call_user_func( array( $callbackClassname, 'configureObject' ), $object ); } return null; }
php
public static function fetchConfig( $identifier, $object ) { if ( isset( self::$callbackMap[$identifier] ) ) { $callbackClassname = self::$callbackMap[$identifier]; return call_user_func( array( $callbackClassname, 'configureObject' ), $object ); } return null; }
[ "public", "static", "function", "fetchConfig", "(", "$", "identifier", ",", "$", "object", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "callbackMap", "[", "$", "identifier", "]", ")", ")", "{", "$", "callbackClassname", "=", "self", "::", "$", "callbackMap", "[", "$", "identifier", "]", ";", "return", "call_user_func", "(", "array", "(", "$", "callbackClassname", ",", "'configureObject'", ")", ",", "$", "object", ")", ";", "}", "return", "null", ";", "}" ]
Uses the configured callback belonging to $identifier to configure the $object. The method will return the return value of the callback method, or null in case there was no callback set for the specified $identifier. @param string $identifier @param object $object @return mixed
[ "Uses", "the", "configured", "callback", "belonging", "to", "$identifier", "to", "configure", "the", "$object", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/init.php#L115-L123
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/replacement_strategies/lru.php
ezcCacheStackLruReplacementStrategy.store
public static function store( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemData, $itemAttributes = array() ) { self::checkMetaData( $metaData ); return parent::store( $conf, $metaData, $itemId, $itemData, $itemAttributes ); }
php
public static function store( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemData, $itemAttributes = array() ) { self::checkMetaData( $metaData ); return parent::store( $conf, $metaData, $itemId, $itemData, $itemAttributes ); }
[ "public", "static", "function", "store", "(", "ezcCacheStackStorageConfiguration", "$", "conf", ",", "ezcCacheStackMetaData", "$", "metaData", ",", "$", "itemId", ",", "$", "itemData", ",", "$", "itemAttributes", "=", "array", "(", ")", ")", "{", "self", "::", "checkMetaData", "(", "$", "metaData", ")", ";", "return", "parent", "::", "store", "(", "$", "conf", ",", "$", "metaData", ",", "$", "itemId", ",", "$", "itemData", ",", "$", "itemAttributes", ")", ";", "}" ]
Stores the given $itemData in the given storage. This method stores the given $itemData under the given $itemId and assigns the given $itemAttributes to it in the {@link ezcCacheStackableStorage} configured in $conf. The storing results in an update of $metaData, reflecting that the item with $itemId was recently used. In case the number of items in the storage exceeds $conf->itemLimit, items will be deleted from the storage. First all outdated items will be removed using {@link ezcCacheStackableStorage::purge()}. If this does not free the desired $conf->freeRate fraction of $conf->itemLimit, those items that have been used least recently will be deleted. The changes of freeing items are recorded in $metaData. @param ezcCacheStackStorageConfiguration $conf @param ezcCacheStackMetaData $metaData @param string $itemId @param mixed $itemData @param array(string=>string) $itemAttributes @see ezcCacheStackReplacementStrategy::store() @throws ezcCacheInvalidMetaDataException if the given $metaData is not an instance of {@link ezcCacheStackLruMetaData}.
[ "Stores", "the", "given", "$itemData", "in", "the", "given", "storage", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/replacement_strategies/lru.php#L63-L73
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/replacement_strategies/lru.php
ezcCacheStackLruReplacementStrategy.delete
public static function delete( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemAttributes = array(), $search = false ) { self::checkMetaData( $metaData ); return parent::delete( $conf, $metaData, $itemId, $itemAttributes, $search ); }
php
public static function delete( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemAttributes = array(), $search = false ) { self::checkMetaData( $metaData ); return parent::delete( $conf, $metaData, $itemId, $itemAttributes, $search ); }
[ "public", "static", "function", "delete", "(", "ezcCacheStackStorageConfiguration", "$", "conf", ",", "ezcCacheStackMetaData", "$", "metaData", ",", "$", "itemId", ",", "$", "itemAttributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "self", "::", "checkMetaData", "(", "$", "metaData", ")", ";", "return", "parent", "::", "delete", "(", "$", "conf", ",", "$", "metaData", ",", "$", "itemId", ",", "$", "itemAttributes", ",", "$", "search", ")", ";", "}" ]
Deletes the data with the given $itemId from the given $storage. Deletes the desired item with $itemId and optionally $itemAttributes from the {@link ezcCacheStackableStorage} configured in $conf using. The item IDs returned by this call are updated in $metaData, that they are no longer stored in the $storage. @param ezcCacheStackStorageConfiguration $conf @param ezcCacheStackMetaData $metaData @param string $itemId @param array(string=>string) $itemAttributes @param bool $search @see ezcCacheStackReplacementStrategy::delete() @return array(string) Deleted item IDs. @throws ezcCacheInvalidMetaDataException if the given $metaData is not an instance of {@link ezcCacheStackLruMetaData}.
[ "Deletes", "the", "data", "with", "the", "given", "$itemId", "from", "the", "given", "$storage", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/replacement_strategies/lru.php#L136-L146
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata.php
ezcBaseMetaData.getComponentDependencies
public function getComponentDependencies( $componentName = null ) { if ( $componentName === null ) { return $this->reader->getComponentDependencies(); } else { return $this->reader->getComponentDependencies( $componentName ); } }
php
public function getComponentDependencies( $componentName = null ) { if ( $componentName === null ) { return $this->reader->getComponentDependencies(); } else { return $this->reader->getComponentDependencies( $componentName ); } }
[ "public", "function", "getComponentDependencies", "(", "$", "componentName", "=", "null", ")", "{", "if", "(", "$", "componentName", "===", "null", ")", "{", "return", "$", "this", "->", "reader", "->", "getComponentDependencies", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "reader", "->", "getComponentDependencies", "(", "$", "componentName", ")", ";", "}", "}" ]
Returns a list of components that $componentName depends on. If $componentName is left empty, all installed components are returned. The returned array has as keys the component names, and as values the version of the components. @return array(string=>string).
[ "Returns", "a", "list", "of", "components", "that", "$componentName", "depends", "on", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata.php#L108-L118
frdl/webfan
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
Helper.zip
public static function zip($i, $o, $del = false, $afilename = null, $s = 0){ $i = str_replace('\\', '/', $i); $zp = new \ZipArchive(); if(file_exists($o)){ $flags = 0; }else{ $flags = \ZipArchive::CREATE; } $zp->open($o, $flags); $afilename = (is_string($afilename)) ? $afilename : basename($i); $success = $zp->addFile($i, $afilename); $zp->close(); if(true===$del)unlink($afilename); if($success){ if($s > 0){ return self::split($o, $s); } }else{ return false; } }
php
public static function zip($i, $o, $del = false, $afilename = null, $s = 0){ $i = str_replace('\\', '/', $i); $zp = new \ZipArchive(); if(file_exists($o)){ $flags = 0; }else{ $flags = \ZipArchive::CREATE; } $zp->open($o, $flags); $afilename = (is_string($afilename)) ? $afilename : basename($i); $success = $zp->addFile($i, $afilename); $zp->close(); if(true===$del)unlink($afilename); if($success){ if($s > 0){ return self::split($o, $s); } }else{ return false; } }
[ "public", "static", "function", "zip", "(", "$", "i", ",", "$", "o", ",", "$", "del", "=", "false", ",", "$", "afilename", "=", "null", ",", "$", "s", "=", "0", ")", "{", "$", "i", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "i", ")", ";", "$", "zp", "=", "new", "\\", "ZipArchive", "(", ")", ";", "if", "(", "file_exists", "(", "$", "o", ")", ")", "{", "$", "flags", "=", "0", ";", "}", "else", "{", "$", "flags", "=", "\\", "ZipArchive", "::", "CREATE", ";", "}", "$", "zp", "->", "open", "(", "$", "o", ",", "$", "flags", ")", ";", "$", "afilename", "=", "(", "is_string", "(", "$", "afilename", ")", ")", "?", "$", "afilename", ":", "basename", "(", "$", "i", ")", ";", "$", "success", "=", "$", "zp", "->", "addFile", "(", "$", "i", ",", "$", "afilename", ")", ";", "$", "zp", "->", "close", "(", ")", ";", "if", "(", "true", "===", "$", "del", ")", "unlink", "(", "$", "afilename", ")", ";", "if", "(", "$", "success", ")", "{", "if", "(", "$", "s", ">", "0", ")", "{", "return", "self", "::", "split", "(", "$", "o", ",", "$", "s", ")", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Compact a file in multipart zip archive. @param string $i The file to compact. @param string $o The zip archive (*.zip). @param integer $s The mnax size (in byte) for the parts. 0 to no parts. @return boolean Return number of parts created.
[ "Compact", "a", "file", "in", "multipart", "zip", "archive", "." ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L202-L230
frdl/webfan
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
Helper.zipDir
public static function zipDir($sourcePath, $outZipPath, $del = false, $delDir = false) { $pathInfo = pathInfo($sourcePath); $parentPath = $pathInfo['dirname']; $dirName = $pathInfo['basename']; $z = new \ZipArchive(); $z->open($outZipPath, \ZipArchive::CREATE); $z->addEmptyDir($dirName); self::folderToZip($sourcePath, $z, strlen("$parentPath/"), $del); if(true===$delDir)rmdir($sourcePath); $z->close(); }
php
public static function zipDir($sourcePath, $outZipPath, $del = false, $delDir = false) { $pathInfo = pathInfo($sourcePath); $parentPath = $pathInfo['dirname']; $dirName = $pathInfo['basename']; $z = new \ZipArchive(); $z->open($outZipPath, \ZipArchive::CREATE); $z->addEmptyDir($dirName); self::folderToZip($sourcePath, $z, strlen("$parentPath/"), $del); if(true===$delDir)rmdir($sourcePath); $z->close(); }
[ "public", "static", "function", "zipDir", "(", "$", "sourcePath", ",", "$", "outZipPath", ",", "$", "del", "=", "false", ",", "$", "delDir", "=", "false", ")", "{", "$", "pathInfo", "=", "pathInfo", "(", "$", "sourcePath", ")", ";", "$", "parentPath", "=", "$", "pathInfo", "[", "'dirname'", "]", ";", "$", "dirName", "=", "$", "pathInfo", "[", "'basename'", "]", ";", "$", "z", "=", "new", "\\", "ZipArchive", "(", ")", ";", "$", "z", "->", "open", "(", "$", "outZipPath", ",", "\\", "ZipArchive", "::", "CREATE", ")", ";", "$", "z", "->", "addEmptyDir", "(", "$", "dirName", ")", ";", "self", "::", "folderToZip", "(", "$", "sourcePath", ",", "$", "z", ",", "strlen", "(", "\"$parentPath/\"", ")", ",", "$", "del", ")", ";", "if", "(", "true", "===", "$", "delDir", ")", "rmdir", "(", "$", "sourcePath", ")", ";", "$", "z", "->", "close", "(", ")", ";", "}" ]
Zip a folder (include itself). Usage: MultipartCompress::zipDir('/path/to/sourceDir', '/path/to/out.zip'); @param string $sourcePath Path of directory to be zip. @param string $outZipPath Path of output zip file.
[ "Zip", "a", "folder", "(", "include", "itself", ")", ".", "Usage", ":", "MultipartCompress", "::", "zipDir", "(", "/", "path", "/", "to", "/", "sourceDir", "/", "path", "/", "to", "/", "out", ".", "zip", ")", ";" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L242-L254
frdl/webfan
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
Helper.split
protected static function split($i, $s){ $fs = filesize($i); //$bn = basename($i); //$dn = dirname($i).DIRECTORY_SEPARATOR; $p = 1; for($c = 0; $c < $fs; $c = $c + $s){ $data = file_get_contents($i, FILE_BINARY, null, $c, $s); //$fn = "$dn$bn.$p"; $fn = "$i.$p"; file_put_contents($fn, $data); $p++; unset($data); } unlink($i); return $p - 1; }
php
protected static function split($i, $s){ $fs = filesize($i); //$bn = basename($i); //$dn = dirname($i).DIRECTORY_SEPARATOR; $p = 1; for($c = 0; $c < $fs; $c = $c + $s){ $data = file_get_contents($i, FILE_BINARY, null, $c, $s); //$fn = "$dn$bn.$p"; $fn = "$i.$p"; file_put_contents($fn, $data); $p++; unset($data); } unlink($i); return $p - 1; }
[ "protected", "static", "function", "split", "(", "$", "i", ",", "$", "s", ")", "{", "$", "fs", "=", "filesize", "(", "$", "i", ")", ";", "//$bn = basename($i);", "//$dn = dirname($i).DIRECTORY_SEPARATOR;", "$", "p", "=", "1", ";", "for", "(", "$", "c", "=", "0", ";", "$", "c", "<", "$", "fs", ";", "$", "c", "=", "$", "c", "+", "$", "s", ")", "{", "$", "data", "=", "file_get_contents", "(", "$", "i", ",", "FILE_BINARY", ",", "null", ",", "$", "c", ",", "$", "s", ")", ";", "//$fn = \"$dn$bn.$p\";", "$", "fn", "=", "\"$i.$p\"", ";", "file_put_contents", "(", "$", "fn", ",", "$", "data", ")", ";", "$", "p", "++", ";", "unset", "(", "$", "data", ")", ";", "}", "unlink", "(", "$", "i", ")", ";", "return", "$", "p", "-", "1", ";", "}" ]
Split the zip archive. @param string $i The zip archive. @param integer $s The max size for the parts. @return integer Return the number of parts created.
[ "Split", "the", "zip", "archive", "." ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L327-L343
frdl/webfan
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
Helper.unzip
public static function unzip($i, $o, $p = 0){ $success = true; if($p > 0){ $success = self::merge($i, $p); } if($success == false){ return false; } $zp = new \ZipArchive(); $zp->open($i); if($zp->extractTo($o)){ $zp->close(); unset($zp); // unlink($i); return true; }else{ return false; } }
php
public static function unzip($i, $o, $p = 0){ $success = true; if($p > 0){ $success = self::merge($i, $p); } if($success == false){ return false; } $zp = new \ZipArchive(); $zp->open($i); if($zp->extractTo($o)){ $zp->close(); unset($zp); // unlink($i); return true; }else{ return false; } }
[ "public", "static", "function", "unzip", "(", "$", "i", ",", "$", "o", ",", "$", "p", "=", "0", ")", "{", "$", "success", "=", "true", ";", "if", "(", "$", "p", ">", "0", ")", "{", "$", "success", "=", "self", "::", "merge", "(", "$", "i", ",", "$", "p", ")", ";", "}", "if", "(", "$", "success", "==", "false", ")", "{", "return", "false", ";", "}", "$", "zp", "=", "new", "\\", "ZipArchive", "(", ")", ";", "$", "zp", "->", "open", "(", "$", "i", ")", ";", "if", "(", "$", "zp", "->", "extractTo", "(", "$", "o", ")", ")", "{", "$", "zp", "->", "close", "(", ")", ";", "unset", "(", "$", "zp", ")", ";", "// unlink($i);", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Decompact the zip archive. @param string $i The zip archive (*.zip). @param string $o The directory name for extract. @param integer $p Number of parts of the zip archive. @return boolean Return TRUE for success or FALSE for fail.
[ "Decompact", "the", "zip", "archive", "." ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L355-L375
frdl/webfan
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
Helper.merge
protected static function merge($i, $p){ for($c = 1; $c <= $p; $c++){ $data = file_get_contents("$i.$c"); file_put_contents($i, $data, FILE_APPEND); unset($data); } return true; }
php
protected static function merge($i, $p){ for($c = 1; $c <= $p; $c++){ $data = file_get_contents("$i.$c"); file_put_contents($i, $data, FILE_APPEND); unset($data); } return true; }
[ "protected", "static", "function", "merge", "(", "$", "i", ",", "$", "p", ")", "{", "for", "(", "$", "c", "=", "1", ";", "$", "c", "<=", "$", "p", ";", "$", "c", "++", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"$i.$c\"", ")", ";", "file_put_contents", "(", "$", "i", ",", "$", "data", ",", "FILE_APPEND", ")", ";", "unset", "(", "$", "data", ")", ";", "}", "return", "true", ";", "}" ]
Merge the parts of zip archive. @param string $i The zip archive (*.zip). @param integer $p Number of parts of the zip archive. @return boolean Return TRUE for success or FALSE for fail.
[ "Merge", "the", "parts", "of", "zip", "archive", "." ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L383-L390
frdl/webfan
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
Helper.isEncryptedZip
public static function isEncryptedZip( $pathToArchive ) { $fp = @fopen( $pathToArchive, 'r' ); $encrypted = false; if ( $fp && fseek( $fp, 6 ) == 0 ) { $string = fread( $fp, 2 ); if ( false !== $string ) { $data = unpack("vgeneral", $string); $encrypted = $data[ 'general' ] & 0x01 ? true : false; } fclose( $fp ); } return $encrypted; }
php
public static function isEncryptedZip( $pathToArchive ) { $fp = @fopen( $pathToArchive, 'r' ); $encrypted = false; if ( $fp && fseek( $fp, 6 ) == 0 ) { $string = fread( $fp, 2 ); if ( false !== $string ) { $data = unpack("vgeneral", $string); $encrypted = $data[ 'general' ] & 0x01 ? true : false; } fclose( $fp ); } return $encrypted; }
[ "public", "static", "function", "isEncryptedZip", "(", "$", "pathToArchive", ")", "{", "$", "fp", "=", "@", "fopen", "(", "$", "pathToArchive", ",", "'r'", ")", ";", "$", "encrypted", "=", "false", ";", "if", "(", "$", "fp", "&&", "fseek", "(", "$", "fp", ",", "6", ")", "==", "0", ")", "{", "$", "string", "=", "fread", "(", "$", "fp", ",", "2", ")", ";", "if", "(", "false", "!==", "$", "string", ")", "{", "$", "data", "=", "unpack", "(", "\"vgeneral\"", ",", "$", "string", ")", ";", "$", "encrypted", "=", "$", "data", "[", "'general'", "]", "&", "0x01", "?", "true", ":", "false", ";", "}", "fclose", "(", "$", "fp", ")", ";", "}", "return", "$", "encrypted", ";", "}" ]
Check if the file is encrypted Notice: if file doesn't exists or cannot be opened, function also return false. @param string $pathToArchive @return boolean return true if file is encrypted
[ "Check", "if", "the", "file", "is", "encrypted" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L411-L423
jnaxo/country-codes
database/seeds/ChileanCitiesSeeder.php
ChileanCitiesSeeder.run
public function run() { DB::table('ctrystore_cities')->delete(); $today = date('Y-m-d H:i:s'); $data = [ ['aa_id' => 5, 'name' => 'Algarrobo'], ['aa_id' => 13, 'name' => 'Alhue'], ['aa_id' => 8, 'name' => 'Alto BioBío'], ['aa_id' => 3, 'name' => 'Alto del Carmen'], ['aa_id' => 1, 'name' => 'Alto Hospicio'], ['aa_id' => 10, 'name' => 'Ancud'], ['aa_id' => 4, 'name' => 'Andacollo'], ['aa_id' => 9, 'name' => 'Angol'], ['aa_id' => 2, 'name' => 'Antofagasta'], ['aa_id' => 8, 'name' => 'Antuco'], ['aa_id' => 8, 'name' => 'Arauco'], ['aa_id' => 15, 'name' => 'Arica'], ['aa_id' => 13, 'name' => 'Buin'], ['aa_id' => 16, 'name' => 'Bulnes'], ['aa_id' => 5, 'name' => 'Cabildo'], ['aa_id' => 12, 'name' => 'Cabo de Hornos'], ['aa_id' => 8, 'name' => 'Cabrero'], ['aa_id' => 2, 'name' => 'Calama'], ['aa_id' => 10, 'name' => 'Antártica'], ['aa_id' => 10, 'name' => 'Calbuco'], ['aa_id' => 3, 'name' => 'Caldera'], ['aa_id' => 13, 'name' => 'Calera de Tango'], ['aa_id' => 5, 'name' => 'Calle Larga'], ['aa_id' => 15, 'name' => 'Camarones'], ['aa_id' => 1, 'name' => 'Camiña'], ['aa_id' => 4, 'name' => 'Canela'], ['aa_id' => 8, 'name' => 'Cañete'], ['aa_id' => 9, 'name' => 'Carahue'], ['aa_id' => 5, 'name' => 'Carnameena'], ['aa_id' => 5, 'name' => 'Casablanca'], ['aa_id' => 10, 'name' => 'Castro'], ['aa_id' => 5, 'name' => 'Catemu'], ['aa_id' => 7, 'name' => 'Cauquenes'], ['aa_id' => 13, 'name' => 'Cerrillos'], ['aa_id' => 13, 'name' => 'Cerro Navia'], ['aa_id' => 10, 'name' => 'Chaiten'], ['aa_id' => 3, 'name' => 'Chañaral'], ['aa_id' => 7, 'name' => 'Chanco'], ['aa_id' => 6, 'name' => 'Chépica'], ['aa_id' => 8, 'name' => 'Chiguayante'], ['aa_id' => 11, 'name' => 'Chile Chico'], ['aa_id' => 16, 'name' => 'Chillan'], ['aa_id' => 16, 'name' => 'Chillan Viejo'], ['aa_id' => 6, 'name' => 'Chimbarongo'], ['aa_id' => 9, 'name' => 'Cholchol'], ['aa_id' => 10, 'name' => 'Chonchi'], ['aa_id' => 16, 'name' => 'Cobquecura'], ['aa_id' => 10, 'name' => 'Cochamó'], ['aa_id' => 11, 'name' => 'Cochrane'], ['aa_id' => 6, 'name' => 'Codegua'], ['aa_id' => 16, 'name' => 'Coelemu'], ['aa_id' => 16, 'name' => 'Coihueco'], ['aa_id' => 6, 'name' => 'Coinco'], ['aa_id' => 7, 'name' => 'Colbun'], ['aa_id' => 1, 'name' => 'Colchane'], ['aa_id' => 13, 'name' => 'Colina'], ['aa_id' => 9, 'name' => 'Collipulli'], ['aa_id' => 6, 'name' => 'Coltauco'], ['aa_id' => 4, 'name' => 'Combarbalá'], ['aa_id' => 8, 'name' => 'Concepcion'], ['aa_id' => 13, 'name' => 'Conchali'], ['aa_id' => 5, 'name' => 'Concón'], ['aa_id' => 7, 'name' => 'Constitucion'], ['aa_id' => 8, 'name' => 'Contulmo'], ['aa_id' => 3, 'name' => 'Copiapó'], ['aa_id' => 4, 'name' => 'Coquimbo'], ['aa_id' => 8, 'name' => 'Coronel'], ['aa_id' => 11, 'name' => 'Coyhaique'], ['aa_id' => 9, 'name' => 'Cunco'], ['aa_id' => 9, 'name' => 'Curacautin'], ['aa_id' => 13, 'name' => 'Curacavi'], ['aa_id' => 10, 'name' => 'Curaco de Velez'], ['aa_id' => 8, 'name' => 'Curanilahue'], ['aa_id' => 9, 'name' => 'Curarrehue'], ['aa_id' => 7, 'name' => 'Curepto'], ['aa_id' => 7, 'name' => 'Curico'], ['aa_id' => 10, 'name' => 'Dalcahue'], ['aa_id' => 3, 'name' => 'Diego de Almagro'], ['aa_id' => 6, 'name' => 'Doñihue'], ['aa_id' => 13, 'name' => 'El Bosque'], ['aa_id' => 16, 'name' => 'El Carmen'], ['aa_id' => 13, 'name' => 'El Monte'], ['aa_id' => 5, 'name' => 'El Quisco'], ['aa_id' => 5, 'name' => 'El Tabo'], ['aa_id' => 7, 'name' => 'Empedrado'], ['aa_id' => 9, 'name' => 'Ercilla'], ['aa_id' => 13, 'name' => 'Estacion Central'], ['aa_id' => 8, 'name' => 'Florida'], ['aa_id' => 9, 'name' => 'Freire'], ['aa_id' => 3, 'name' => 'Freirina'], ['aa_id' => 10, 'name' => 'Fresia'], ['aa_id' => 10, 'name' => 'Frutillar'], ['aa_id' => 10, 'name' => 'Futaleufu'], ['aa_id' => 9, 'name' => 'Galvarino'], ['aa_id' => 15, 'name' => 'General Lagos'], ['aa_id' => 9, 'name' => 'Gorbea'], ['aa_id' => 6, 'name' => 'Graneros'], ['aa_id' => 11, 'name' => 'Guaitecas'], ['aa_id' => 5, 'name' => 'Hijuelas'], ['aa_id' => 10, 'name' => 'Hualaihue'], ['aa_id' => 11, 'name' => 'Puerto Cisnes'], ['aa_id' => 7, 'name' => 'Hualañé'], ['aa_id' => 8, 'name' => 'Hualpén'], ['aa_id' => 8, 'name' => 'Hualqui'], ['aa_id' => 1, 'name' => 'Huara'], ['aa_id' => 3, 'name' => 'Huasco'], ['aa_id' => 13, 'name' => 'Huechuraba'], ['aa_id' => 4, 'name' => 'Río Hurtado'], ['aa_id' => 4, 'name' => 'Illapel'], ['aa_id' => 13, 'name' => 'Independencia'], ['aa_id' => 1, 'name' => 'Iquique'], ['aa_id' => 13, 'name' => 'Isla de Maipo'], ['aa_id' => 5, 'name' => 'Isla de Pascua'], ['aa_id' => 5, 'name' => 'Juan Fernandez'], ['aa_id' => 5, 'name' => 'La Calera'], ['aa_id' => 13, 'name' => 'La Cisterna'], ['aa_id' => 5, 'name' => 'La Cruz'], ['aa_id' => 6, 'name' => 'La Estrella'], ['aa_id' => 13, 'name' => 'La Florida'], ['aa_id' => 13, 'name' => 'La Granja'], ['aa_id' => 4, 'name' => 'La Higuera'], ['aa_id' => 8, 'name' => 'La Laja'], ['aa_id' => 5, 'name' => 'La Ligua'], ['aa_id' => 13, 'name' => 'La Pintana'], ['aa_id' => 13, 'name' => 'La Reina'], ['aa_id' => 4, 'name' => 'La Serena'], ['aa_id' => 11, 'name' => 'Lago Verde'], ['aa_id' => 12, 'name' => 'Laguna Blanca'], ['aa_id' => 13, 'name' => 'Lampa'], ['aa_id' => 6, 'name' => 'Las Cabras'], ['aa_id' => 13, 'name' => 'Las Condes'], ['aa_id' => 11, 'name' => 'Puerto Aysen'], ['aa_id' => 9, 'name' => 'Lautaro'], ['aa_id' => 8, 'name' => 'Lebu'], ['aa_id' => 7, 'name' => 'Licanten'], ['aa_id' => 5, 'name' => 'Limache'], ['aa_id' => 7, 'name' => 'Linares'], ['aa_id' => 6, 'name' => 'Litueche'], ['aa_id' => 10, 'name' => 'Llanquihue'], ['aa_id' => 13, 'name' => 'Lo Barnechea'], ['aa_id' => 13, 'name' => 'Lo Espejo'], ['aa_id' => 13, 'name' => 'Lo Prado'], ['aa_id' => 6, 'name' => 'Lolol'], ['aa_id' => 9, 'name' => 'Loncoche'], ['aa_id' => 7, 'name' => 'Longavi'], ['aa_id' => 9, 'name' => 'Lonquimay'], ['aa_id' => 8, 'name' => 'Los Alamos'], ['aa_id' => 5, 'name' => 'Los Andes'], ['aa_id' => 8, 'name' => 'Los Angeles'], ['aa_id' => 10, 'name' => 'Los Muermos'], ['aa_id' => 9, 'name' => 'Los Sauces'], ['aa_id' => 4, 'name' => 'Los Vilos'], ['aa_id' => 8, 'name' => 'Lota'], ['aa_id' => 9, 'name' => 'Lumaco'], ['aa_id' => 6, 'name' => 'Machalí'], ['aa_id' => 13, 'name' => 'Macul'], ['aa_id' => 13, 'name' => 'Maipu'], ['aa_id' => 6, 'name' => 'Malloa'], ['aa_id' => 6, 'name' => 'Marchihue'], ['aa_id' => 2, 'name' => 'Maria Elena'], ['aa_id' => 13, 'name' => 'Maria Pinto'], ['aa_id' => 7, 'name' => 'Maule'], ['aa_id' => 10, 'name' => 'Maullin'], ['aa_id' => 2, 'name' => 'Mejillones'], ['aa_id' => 9, 'name' => 'Melipeuco'], ['aa_id' => 13, 'name' => 'Melipilla'], ['aa_id' => 7, 'name' => 'Molina'], ['aa_id' => 4, 'name' => 'Monte Patria'], ['aa_id' => 8, 'name' => 'Mulchen'], ['aa_id' => 8, 'name' => 'Nacimiento'], ['aa_id' => 6, 'name' => 'Nancahua'], ['aa_id' => 6, 'name' => 'Navidad'], ['aa_id' => 8, 'name' => 'Negrete'], ['aa_id' => 16, 'name' => 'Ninhue'], ['aa_id' => 16, 'name' => 'Ñiquén'], ['aa_id' => 5, 'name' => 'Nogales'], ['aa_id' => 9, 'name' => 'Nueva Imperial'], ['aa_id' => 13, 'name' => 'Ñuñoa'], ['aa_id' => 11, 'name' => "O'Higgins"], ['aa_id' => 6, 'name' => 'Olivar'], ['aa_id' => 2, 'name' => 'Ollagüe'], ['aa_id' => 5, 'name' => 'Olmue'], ['aa_id' => 10, 'name' => 'Osorno'], ['aa_id' => 4, 'name' => 'Ovalle'], ['aa_id' => 13, 'name' => 'Padre Hurtado'], ['aa_id' => 9, 'name' => 'Padre Las Casas'], ['aa_id' => 4, 'name' => 'Paiguano'], ['aa_id' => 13, 'name' => 'Paine'], ['aa_id' => 10, 'name' => 'Palena'], ['aa_id' => 6, 'name' => 'Palmilla'], ['aa_id' => 5, 'name' => 'Panquehue'], ['aa_id' => 5, 'name' => 'Papudo'], ['aa_id' => 6, 'name' => 'Paredones'], ['aa_id' => 7, 'name' => 'Parral'], ['aa_id' => 13, 'name' => 'Pedro Aguirre Cerda'], ['aa_id' => 7, 'name' => 'Pelarco'], ['aa_id' => 7, 'name' => 'Pelluhue'], ['aa_id' => 16, 'name' => 'Pemuco'], ['aa_id' => 13, 'name' => 'Peñaflor'], ['aa_id' => 13, 'name' => 'Peñalolen'], ['aa_id' => 7, 'name' => 'Pencahue'], ['aa_id' => 8, 'name' => 'Penco'], ['aa_id' => 6, 'name' => 'Peralillo'], ['aa_id' => 9, 'name' => 'Perquenco'], ['aa_id' => 5, 'name' => 'Petorca'], ['aa_id' => 6, 'name' => 'Peumo'], ['aa_id' => 1, 'name' => 'Pica'], ['aa_id' => 6, 'name' => 'Pichidegua'], ['aa_id' => 6, 'name' => 'Pichilemu'], ['aa_id' => 16, 'name' => 'Pinto'], ['aa_id' => 13, 'name' => 'Pirque'], ['aa_id' => 9, 'name' => 'Pitrufquen'], ['aa_id' => 6, 'name' => 'Placilla'], ['aa_id' => 16, 'name' => 'Portezuelo'], ['aa_id' => 12, 'name' => 'Porvenir'], ['aa_id' => 1, 'name' => 'Pozo Almonte'], ['aa_id' => 12, 'name' => 'Primavera'], ['aa_id' => 13, 'name' => 'Providencia'], ['aa_id' => 5, 'name' => 'Puchuncaví'], ['aa_id' => 9, 'name' => 'Pucon'], ['aa_id' => 9, 'name' => 'Puerto Saavedra'], ['aa_id' => 13, 'name' => 'Pudahuel'], ['aa_id' => 13, 'name' => 'Puente Alto'], ['aa_id' => 10, 'name' => 'Puerto Montt'], ['aa_id' => 12, 'name' => 'Natales'], ['aa_id' => 10, 'name' => 'Puerto Octay'], ['aa_id' => 10, 'name' => 'Puerto Varas'], ['aa_id' => 6, 'name' => 'Pumanque'], ['aa_id' => 4, 'name' => 'Punitaqui'], ['aa_id' => 12, 'name' => 'Punta Arenas'], ['aa_id' => 10, 'name' => 'Puqueldon'], ['aa_id' => 9, 'name' => 'Puren'], ['aa_id' => 10, 'name' => 'Purranque'], ['aa_id' => 5, 'name' => 'Putaendo'], ['aa_id' => 15, 'name' => 'Putre'], ['aa_id' => 10, 'name' => 'Puyehue'], ['aa_id' => 10, 'name' => 'Queilen'], ['aa_id' => 10, 'name' => 'Quellon (Puerto Quellon)'], ['aa_id' => 10, 'name' => 'Quemchi'], ['aa_id' => 8, 'name' => 'Quilaco'], ['aa_id' => 13, 'name' => 'Quilicura'], ['aa_id' => 8, 'name' => 'Quilleco'], ['aa_id' => 16, 'name' => 'Quillon'], ['aa_id' => 5, 'name' => 'Quillota'], ['aa_id' => 5, 'name' => 'Quilpué'], ['aa_id' => 8, 'name' => 'Tucapel'], ['aa_id' => 10, 'name' => 'Quinchao'], ['aa_id' => 6, 'name' => 'Quinta de Tilcoco'], ['aa_id' => 13, 'name' => 'Quinta Normal'], ['aa_id' => 5, 'name' => 'Quintero'], ['aa_id' => 16, 'name' => 'Quirihue'], ['aa_id' => 6, 'name' => 'Rancagua'], ['aa_id' => 16, 'name' => 'Ranquil'], ['aa_id' => 6, 'name' => 'Rapel'], ['aa_id' => 7, 'name' => 'Rauco'], ['aa_id' => 13, 'name' => 'Recoleta'], ['aa_id' => 9, 'name' => 'Renaico'], ['aa_id' => 13, 'name' => 'Renca'], ['aa_id' => 6, 'name' => 'Rengo'], ['aa_id' => 6, 'name' => 'Requinoa'], ['aa_id' => 7, 'name' => 'Retiro'], ['aa_id' => 5, 'name' => 'Rinconada de Los Andes'], ['aa_id' => 7, 'name' => 'Rio Claro'], ['aa_id' => 11, 'name' => 'Rio Ibanez'], ['aa_id' => 10, 'name' => 'Rio Negro'], ['aa_id' => 12, 'name' => 'Rio Verde'], ['aa_id' => 7, 'name' => 'Romeral'], ['aa_id' => 7, 'name' => 'Sagrada Familia'], ['aa_id' => 4, 'name' => 'Salamanca'], ['aa_id' => 5, 'name' => 'San Antonio'], ['aa_id' => 13, 'name' => 'San Bernardo'], ['aa_id' => 16, 'name' => 'San Carlos'], ['aa_id' => 7, 'name' => 'San Clemente'], ['aa_id' => 5, 'name' => 'San Esteban'], ['aa_id' => 16, 'name' => 'San Fabian'], ['aa_id' => 5, 'name' => 'San Felipe'], ['aa_id' => 6, 'name' => 'San Fernando'], ['aa_id' => 12, 'name' => 'San Gregorio'], ['aa_id' => 16, 'name' => 'San Ignacio'], ['aa_id' => 7, 'name' => 'San Javier'], ['aa_id' => 13, 'name' => 'San Joaquin'], ['aa_id' => 13, 'name' => 'San Jose de Maipo'], ['aa_id' => 10, 'name' => 'San Juan de la Costa'], ['aa_id' => 13, 'name' => 'San Miguel'], ['aa_id' => 16, 'name' => 'San Nicolas'], ['aa_id' => 10, 'name' => 'San Pablo'], ['aa_id' => 13, 'name' => 'San Pedro'], ['aa_id' => 2, 'name' => 'San Pedro de Atacama'], ['aa_id' => 8, 'name' => 'San Pedro de la Paz'], ['aa_id' => 7, 'name' => 'San Rafael'], ['aa_id' => 13, 'name' => 'San Ramon'], ['aa_id' => 8, 'name' => 'San Rosendo'], ['aa_id' => 6, 'name' => 'San Vicente de Tagua Tagua'], ['aa_id' => 8, 'name' => 'Santa Barbara'], ['aa_id' => 6, 'name' => 'Santa Cruz'], ['aa_id' => 8, 'name' => 'Santa Juana'], ['aa_id' => 5, 'name' => 'Santa Maria'], ['aa_id' => 13, 'name' => 'Santiago'], ['aa_id' => 5, 'name' => 'Santo Domingo'], ['aa_id' => 2, 'name' => 'Sierra Gorda'], ['aa_id' => 13, 'name' => 'Talagante'], ['aa_id' => 7, 'name' => 'Talca'], ['aa_id' => 8, 'name' => 'Talcahuano'], ['aa_id' => 2, 'name' => 'Taltal'], ['aa_id' => 9, 'name' => 'Temuco'], ['aa_id' => 7, 'name' => 'Teno'], ['aa_id' => 9, 'name' => 'Teodoro Schmidt'], ['aa_id' => 3, 'name' => 'Tierra Amarilla'], ['aa_id' => 13, 'name' => 'Til til'], ['aa_id' => 12, 'name' => 'Timaukel'], ['aa_id' => 8, 'name' => 'Tirúa'], ['aa_id' => 2, 'name' => 'Tocopilla'], ['aa_id' => 9, 'name' => 'Tolten'], ['aa_id' => 8, 'name' => 'Tome'], ['aa_id' => 12, 'name' => 'Torres del Paine'], ['aa_id' => 11, 'name' => 'Tortel'], ['aa_id' => 9, 'name' => 'Traiguen'], ['aa_id' => 16, 'name' => 'Treguaco'], ['aa_id' => 3, 'name' => 'Vallenar'], ['aa_id' => 5, 'name' => 'Valparaiso'], ['aa_id' => 7, 'name' => 'Vichuquen'], ['aa_id' => 9, 'name' => 'Victoria'], ['aa_id' => 4, 'name' => 'Vicuña'], ['aa_id' => 9, 'name' => 'Vilcun'], ['aa_id' => 7, 'name' => 'Villa Alegre'], ['aa_id' => 5, 'name' => 'Villa Alemana'], ['aa_id' => 9, 'name' => 'Villarrica'], ['aa_id' => 5, 'name' => 'Vina del Mar'], ['aa_id' => 13, 'name' => 'Vitacura'], ['aa_id' => 7, 'name' => 'Yerbas Buenas'], ['aa_id' => 8, 'name' => 'Yumbel'], ['aa_id' => 16, 'name' => 'Yungay'], ['aa_id' => 5, 'name' => 'Zapallar'], ['aa_id' => 14, 'name' => 'Corral'], ['aa_id' => 14, 'name' => 'Lanco'], ['aa_id' => 14, 'name' => 'Los Lagos'], ['aa_id' => 14, 'name' => 'Mafil'], ['aa_id' => 14, 'name' => 'Mariquina'], ['aa_id' => 14, 'name' => 'Paillaco'], ['aa_id' => 14, 'name' => 'Panguipulli'], ['aa_id' => 14, 'name' => 'Valdivia'], ['aa_id' => 14, 'name' => 'Futrono'], ['aa_id' => 14, 'name' => 'La Unión'], ['aa_id' => 14, 'name' => 'Lago Ranco'], ['aa_id' => 14, 'name' => 'Rio Bueno'] ]; foreach ($data as $city) { DB::table('ctrystore_cities')->insert([ 'admin_area_id' => $city['aa_id'], 'name' => $city['name'], 'created_at' => $today, 'updated_at' => $today ]); } }
php
public function run() { DB::table('ctrystore_cities')->delete(); $today = date('Y-m-d H:i:s'); $data = [ ['aa_id' => 5, 'name' => 'Algarrobo'], ['aa_id' => 13, 'name' => 'Alhue'], ['aa_id' => 8, 'name' => 'Alto BioBío'], ['aa_id' => 3, 'name' => 'Alto del Carmen'], ['aa_id' => 1, 'name' => 'Alto Hospicio'], ['aa_id' => 10, 'name' => 'Ancud'], ['aa_id' => 4, 'name' => 'Andacollo'], ['aa_id' => 9, 'name' => 'Angol'], ['aa_id' => 2, 'name' => 'Antofagasta'], ['aa_id' => 8, 'name' => 'Antuco'], ['aa_id' => 8, 'name' => 'Arauco'], ['aa_id' => 15, 'name' => 'Arica'], ['aa_id' => 13, 'name' => 'Buin'], ['aa_id' => 16, 'name' => 'Bulnes'], ['aa_id' => 5, 'name' => 'Cabildo'], ['aa_id' => 12, 'name' => 'Cabo de Hornos'], ['aa_id' => 8, 'name' => 'Cabrero'], ['aa_id' => 2, 'name' => 'Calama'], ['aa_id' => 10, 'name' => 'Antártica'], ['aa_id' => 10, 'name' => 'Calbuco'], ['aa_id' => 3, 'name' => 'Caldera'], ['aa_id' => 13, 'name' => 'Calera de Tango'], ['aa_id' => 5, 'name' => 'Calle Larga'], ['aa_id' => 15, 'name' => 'Camarones'], ['aa_id' => 1, 'name' => 'Camiña'], ['aa_id' => 4, 'name' => 'Canela'], ['aa_id' => 8, 'name' => 'Cañete'], ['aa_id' => 9, 'name' => 'Carahue'], ['aa_id' => 5, 'name' => 'Carnameena'], ['aa_id' => 5, 'name' => 'Casablanca'], ['aa_id' => 10, 'name' => 'Castro'], ['aa_id' => 5, 'name' => 'Catemu'], ['aa_id' => 7, 'name' => 'Cauquenes'], ['aa_id' => 13, 'name' => 'Cerrillos'], ['aa_id' => 13, 'name' => 'Cerro Navia'], ['aa_id' => 10, 'name' => 'Chaiten'], ['aa_id' => 3, 'name' => 'Chañaral'], ['aa_id' => 7, 'name' => 'Chanco'], ['aa_id' => 6, 'name' => 'Chépica'], ['aa_id' => 8, 'name' => 'Chiguayante'], ['aa_id' => 11, 'name' => 'Chile Chico'], ['aa_id' => 16, 'name' => 'Chillan'], ['aa_id' => 16, 'name' => 'Chillan Viejo'], ['aa_id' => 6, 'name' => 'Chimbarongo'], ['aa_id' => 9, 'name' => 'Cholchol'], ['aa_id' => 10, 'name' => 'Chonchi'], ['aa_id' => 16, 'name' => 'Cobquecura'], ['aa_id' => 10, 'name' => 'Cochamó'], ['aa_id' => 11, 'name' => 'Cochrane'], ['aa_id' => 6, 'name' => 'Codegua'], ['aa_id' => 16, 'name' => 'Coelemu'], ['aa_id' => 16, 'name' => 'Coihueco'], ['aa_id' => 6, 'name' => 'Coinco'], ['aa_id' => 7, 'name' => 'Colbun'], ['aa_id' => 1, 'name' => 'Colchane'], ['aa_id' => 13, 'name' => 'Colina'], ['aa_id' => 9, 'name' => 'Collipulli'], ['aa_id' => 6, 'name' => 'Coltauco'], ['aa_id' => 4, 'name' => 'Combarbalá'], ['aa_id' => 8, 'name' => 'Concepcion'], ['aa_id' => 13, 'name' => 'Conchali'], ['aa_id' => 5, 'name' => 'Concón'], ['aa_id' => 7, 'name' => 'Constitucion'], ['aa_id' => 8, 'name' => 'Contulmo'], ['aa_id' => 3, 'name' => 'Copiapó'], ['aa_id' => 4, 'name' => 'Coquimbo'], ['aa_id' => 8, 'name' => 'Coronel'], ['aa_id' => 11, 'name' => 'Coyhaique'], ['aa_id' => 9, 'name' => 'Cunco'], ['aa_id' => 9, 'name' => 'Curacautin'], ['aa_id' => 13, 'name' => 'Curacavi'], ['aa_id' => 10, 'name' => 'Curaco de Velez'], ['aa_id' => 8, 'name' => 'Curanilahue'], ['aa_id' => 9, 'name' => 'Curarrehue'], ['aa_id' => 7, 'name' => 'Curepto'], ['aa_id' => 7, 'name' => 'Curico'], ['aa_id' => 10, 'name' => 'Dalcahue'], ['aa_id' => 3, 'name' => 'Diego de Almagro'], ['aa_id' => 6, 'name' => 'Doñihue'], ['aa_id' => 13, 'name' => 'El Bosque'], ['aa_id' => 16, 'name' => 'El Carmen'], ['aa_id' => 13, 'name' => 'El Monte'], ['aa_id' => 5, 'name' => 'El Quisco'], ['aa_id' => 5, 'name' => 'El Tabo'], ['aa_id' => 7, 'name' => 'Empedrado'], ['aa_id' => 9, 'name' => 'Ercilla'], ['aa_id' => 13, 'name' => 'Estacion Central'], ['aa_id' => 8, 'name' => 'Florida'], ['aa_id' => 9, 'name' => 'Freire'], ['aa_id' => 3, 'name' => 'Freirina'], ['aa_id' => 10, 'name' => 'Fresia'], ['aa_id' => 10, 'name' => 'Frutillar'], ['aa_id' => 10, 'name' => 'Futaleufu'], ['aa_id' => 9, 'name' => 'Galvarino'], ['aa_id' => 15, 'name' => 'General Lagos'], ['aa_id' => 9, 'name' => 'Gorbea'], ['aa_id' => 6, 'name' => 'Graneros'], ['aa_id' => 11, 'name' => 'Guaitecas'], ['aa_id' => 5, 'name' => 'Hijuelas'], ['aa_id' => 10, 'name' => 'Hualaihue'], ['aa_id' => 11, 'name' => 'Puerto Cisnes'], ['aa_id' => 7, 'name' => 'Hualañé'], ['aa_id' => 8, 'name' => 'Hualpén'], ['aa_id' => 8, 'name' => 'Hualqui'], ['aa_id' => 1, 'name' => 'Huara'], ['aa_id' => 3, 'name' => 'Huasco'], ['aa_id' => 13, 'name' => 'Huechuraba'], ['aa_id' => 4, 'name' => 'Río Hurtado'], ['aa_id' => 4, 'name' => 'Illapel'], ['aa_id' => 13, 'name' => 'Independencia'], ['aa_id' => 1, 'name' => 'Iquique'], ['aa_id' => 13, 'name' => 'Isla de Maipo'], ['aa_id' => 5, 'name' => 'Isla de Pascua'], ['aa_id' => 5, 'name' => 'Juan Fernandez'], ['aa_id' => 5, 'name' => 'La Calera'], ['aa_id' => 13, 'name' => 'La Cisterna'], ['aa_id' => 5, 'name' => 'La Cruz'], ['aa_id' => 6, 'name' => 'La Estrella'], ['aa_id' => 13, 'name' => 'La Florida'], ['aa_id' => 13, 'name' => 'La Granja'], ['aa_id' => 4, 'name' => 'La Higuera'], ['aa_id' => 8, 'name' => 'La Laja'], ['aa_id' => 5, 'name' => 'La Ligua'], ['aa_id' => 13, 'name' => 'La Pintana'], ['aa_id' => 13, 'name' => 'La Reina'], ['aa_id' => 4, 'name' => 'La Serena'], ['aa_id' => 11, 'name' => 'Lago Verde'], ['aa_id' => 12, 'name' => 'Laguna Blanca'], ['aa_id' => 13, 'name' => 'Lampa'], ['aa_id' => 6, 'name' => 'Las Cabras'], ['aa_id' => 13, 'name' => 'Las Condes'], ['aa_id' => 11, 'name' => 'Puerto Aysen'], ['aa_id' => 9, 'name' => 'Lautaro'], ['aa_id' => 8, 'name' => 'Lebu'], ['aa_id' => 7, 'name' => 'Licanten'], ['aa_id' => 5, 'name' => 'Limache'], ['aa_id' => 7, 'name' => 'Linares'], ['aa_id' => 6, 'name' => 'Litueche'], ['aa_id' => 10, 'name' => 'Llanquihue'], ['aa_id' => 13, 'name' => 'Lo Barnechea'], ['aa_id' => 13, 'name' => 'Lo Espejo'], ['aa_id' => 13, 'name' => 'Lo Prado'], ['aa_id' => 6, 'name' => 'Lolol'], ['aa_id' => 9, 'name' => 'Loncoche'], ['aa_id' => 7, 'name' => 'Longavi'], ['aa_id' => 9, 'name' => 'Lonquimay'], ['aa_id' => 8, 'name' => 'Los Alamos'], ['aa_id' => 5, 'name' => 'Los Andes'], ['aa_id' => 8, 'name' => 'Los Angeles'], ['aa_id' => 10, 'name' => 'Los Muermos'], ['aa_id' => 9, 'name' => 'Los Sauces'], ['aa_id' => 4, 'name' => 'Los Vilos'], ['aa_id' => 8, 'name' => 'Lota'], ['aa_id' => 9, 'name' => 'Lumaco'], ['aa_id' => 6, 'name' => 'Machalí'], ['aa_id' => 13, 'name' => 'Macul'], ['aa_id' => 13, 'name' => 'Maipu'], ['aa_id' => 6, 'name' => 'Malloa'], ['aa_id' => 6, 'name' => 'Marchihue'], ['aa_id' => 2, 'name' => 'Maria Elena'], ['aa_id' => 13, 'name' => 'Maria Pinto'], ['aa_id' => 7, 'name' => 'Maule'], ['aa_id' => 10, 'name' => 'Maullin'], ['aa_id' => 2, 'name' => 'Mejillones'], ['aa_id' => 9, 'name' => 'Melipeuco'], ['aa_id' => 13, 'name' => 'Melipilla'], ['aa_id' => 7, 'name' => 'Molina'], ['aa_id' => 4, 'name' => 'Monte Patria'], ['aa_id' => 8, 'name' => 'Mulchen'], ['aa_id' => 8, 'name' => 'Nacimiento'], ['aa_id' => 6, 'name' => 'Nancahua'], ['aa_id' => 6, 'name' => 'Navidad'], ['aa_id' => 8, 'name' => 'Negrete'], ['aa_id' => 16, 'name' => 'Ninhue'], ['aa_id' => 16, 'name' => 'Ñiquén'], ['aa_id' => 5, 'name' => 'Nogales'], ['aa_id' => 9, 'name' => 'Nueva Imperial'], ['aa_id' => 13, 'name' => 'Ñuñoa'], ['aa_id' => 11, 'name' => "O'Higgins"], ['aa_id' => 6, 'name' => 'Olivar'], ['aa_id' => 2, 'name' => 'Ollagüe'], ['aa_id' => 5, 'name' => 'Olmue'], ['aa_id' => 10, 'name' => 'Osorno'], ['aa_id' => 4, 'name' => 'Ovalle'], ['aa_id' => 13, 'name' => 'Padre Hurtado'], ['aa_id' => 9, 'name' => 'Padre Las Casas'], ['aa_id' => 4, 'name' => 'Paiguano'], ['aa_id' => 13, 'name' => 'Paine'], ['aa_id' => 10, 'name' => 'Palena'], ['aa_id' => 6, 'name' => 'Palmilla'], ['aa_id' => 5, 'name' => 'Panquehue'], ['aa_id' => 5, 'name' => 'Papudo'], ['aa_id' => 6, 'name' => 'Paredones'], ['aa_id' => 7, 'name' => 'Parral'], ['aa_id' => 13, 'name' => 'Pedro Aguirre Cerda'], ['aa_id' => 7, 'name' => 'Pelarco'], ['aa_id' => 7, 'name' => 'Pelluhue'], ['aa_id' => 16, 'name' => 'Pemuco'], ['aa_id' => 13, 'name' => 'Peñaflor'], ['aa_id' => 13, 'name' => 'Peñalolen'], ['aa_id' => 7, 'name' => 'Pencahue'], ['aa_id' => 8, 'name' => 'Penco'], ['aa_id' => 6, 'name' => 'Peralillo'], ['aa_id' => 9, 'name' => 'Perquenco'], ['aa_id' => 5, 'name' => 'Petorca'], ['aa_id' => 6, 'name' => 'Peumo'], ['aa_id' => 1, 'name' => 'Pica'], ['aa_id' => 6, 'name' => 'Pichidegua'], ['aa_id' => 6, 'name' => 'Pichilemu'], ['aa_id' => 16, 'name' => 'Pinto'], ['aa_id' => 13, 'name' => 'Pirque'], ['aa_id' => 9, 'name' => 'Pitrufquen'], ['aa_id' => 6, 'name' => 'Placilla'], ['aa_id' => 16, 'name' => 'Portezuelo'], ['aa_id' => 12, 'name' => 'Porvenir'], ['aa_id' => 1, 'name' => 'Pozo Almonte'], ['aa_id' => 12, 'name' => 'Primavera'], ['aa_id' => 13, 'name' => 'Providencia'], ['aa_id' => 5, 'name' => 'Puchuncaví'], ['aa_id' => 9, 'name' => 'Pucon'], ['aa_id' => 9, 'name' => 'Puerto Saavedra'], ['aa_id' => 13, 'name' => 'Pudahuel'], ['aa_id' => 13, 'name' => 'Puente Alto'], ['aa_id' => 10, 'name' => 'Puerto Montt'], ['aa_id' => 12, 'name' => 'Natales'], ['aa_id' => 10, 'name' => 'Puerto Octay'], ['aa_id' => 10, 'name' => 'Puerto Varas'], ['aa_id' => 6, 'name' => 'Pumanque'], ['aa_id' => 4, 'name' => 'Punitaqui'], ['aa_id' => 12, 'name' => 'Punta Arenas'], ['aa_id' => 10, 'name' => 'Puqueldon'], ['aa_id' => 9, 'name' => 'Puren'], ['aa_id' => 10, 'name' => 'Purranque'], ['aa_id' => 5, 'name' => 'Putaendo'], ['aa_id' => 15, 'name' => 'Putre'], ['aa_id' => 10, 'name' => 'Puyehue'], ['aa_id' => 10, 'name' => 'Queilen'], ['aa_id' => 10, 'name' => 'Quellon (Puerto Quellon)'], ['aa_id' => 10, 'name' => 'Quemchi'], ['aa_id' => 8, 'name' => 'Quilaco'], ['aa_id' => 13, 'name' => 'Quilicura'], ['aa_id' => 8, 'name' => 'Quilleco'], ['aa_id' => 16, 'name' => 'Quillon'], ['aa_id' => 5, 'name' => 'Quillota'], ['aa_id' => 5, 'name' => 'Quilpué'], ['aa_id' => 8, 'name' => 'Tucapel'], ['aa_id' => 10, 'name' => 'Quinchao'], ['aa_id' => 6, 'name' => 'Quinta de Tilcoco'], ['aa_id' => 13, 'name' => 'Quinta Normal'], ['aa_id' => 5, 'name' => 'Quintero'], ['aa_id' => 16, 'name' => 'Quirihue'], ['aa_id' => 6, 'name' => 'Rancagua'], ['aa_id' => 16, 'name' => 'Ranquil'], ['aa_id' => 6, 'name' => 'Rapel'], ['aa_id' => 7, 'name' => 'Rauco'], ['aa_id' => 13, 'name' => 'Recoleta'], ['aa_id' => 9, 'name' => 'Renaico'], ['aa_id' => 13, 'name' => 'Renca'], ['aa_id' => 6, 'name' => 'Rengo'], ['aa_id' => 6, 'name' => 'Requinoa'], ['aa_id' => 7, 'name' => 'Retiro'], ['aa_id' => 5, 'name' => 'Rinconada de Los Andes'], ['aa_id' => 7, 'name' => 'Rio Claro'], ['aa_id' => 11, 'name' => 'Rio Ibanez'], ['aa_id' => 10, 'name' => 'Rio Negro'], ['aa_id' => 12, 'name' => 'Rio Verde'], ['aa_id' => 7, 'name' => 'Romeral'], ['aa_id' => 7, 'name' => 'Sagrada Familia'], ['aa_id' => 4, 'name' => 'Salamanca'], ['aa_id' => 5, 'name' => 'San Antonio'], ['aa_id' => 13, 'name' => 'San Bernardo'], ['aa_id' => 16, 'name' => 'San Carlos'], ['aa_id' => 7, 'name' => 'San Clemente'], ['aa_id' => 5, 'name' => 'San Esteban'], ['aa_id' => 16, 'name' => 'San Fabian'], ['aa_id' => 5, 'name' => 'San Felipe'], ['aa_id' => 6, 'name' => 'San Fernando'], ['aa_id' => 12, 'name' => 'San Gregorio'], ['aa_id' => 16, 'name' => 'San Ignacio'], ['aa_id' => 7, 'name' => 'San Javier'], ['aa_id' => 13, 'name' => 'San Joaquin'], ['aa_id' => 13, 'name' => 'San Jose de Maipo'], ['aa_id' => 10, 'name' => 'San Juan de la Costa'], ['aa_id' => 13, 'name' => 'San Miguel'], ['aa_id' => 16, 'name' => 'San Nicolas'], ['aa_id' => 10, 'name' => 'San Pablo'], ['aa_id' => 13, 'name' => 'San Pedro'], ['aa_id' => 2, 'name' => 'San Pedro de Atacama'], ['aa_id' => 8, 'name' => 'San Pedro de la Paz'], ['aa_id' => 7, 'name' => 'San Rafael'], ['aa_id' => 13, 'name' => 'San Ramon'], ['aa_id' => 8, 'name' => 'San Rosendo'], ['aa_id' => 6, 'name' => 'San Vicente de Tagua Tagua'], ['aa_id' => 8, 'name' => 'Santa Barbara'], ['aa_id' => 6, 'name' => 'Santa Cruz'], ['aa_id' => 8, 'name' => 'Santa Juana'], ['aa_id' => 5, 'name' => 'Santa Maria'], ['aa_id' => 13, 'name' => 'Santiago'], ['aa_id' => 5, 'name' => 'Santo Domingo'], ['aa_id' => 2, 'name' => 'Sierra Gorda'], ['aa_id' => 13, 'name' => 'Talagante'], ['aa_id' => 7, 'name' => 'Talca'], ['aa_id' => 8, 'name' => 'Talcahuano'], ['aa_id' => 2, 'name' => 'Taltal'], ['aa_id' => 9, 'name' => 'Temuco'], ['aa_id' => 7, 'name' => 'Teno'], ['aa_id' => 9, 'name' => 'Teodoro Schmidt'], ['aa_id' => 3, 'name' => 'Tierra Amarilla'], ['aa_id' => 13, 'name' => 'Til til'], ['aa_id' => 12, 'name' => 'Timaukel'], ['aa_id' => 8, 'name' => 'Tirúa'], ['aa_id' => 2, 'name' => 'Tocopilla'], ['aa_id' => 9, 'name' => 'Tolten'], ['aa_id' => 8, 'name' => 'Tome'], ['aa_id' => 12, 'name' => 'Torres del Paine'], ['aa_id' => 11, 'name' => 'Tortel'], ['aa_id' => 9, 'name' => 'Traiguen'], ['aa_id' => 16, 'name' => 'Treguaco'], ['aa_id' => 3, 'name' => 'Vallenar'], ['aa_id' => 5, 'name' => 'Valparaiso'], ['aa_id' => 7, 'name' => 'Vichuquen'], ['aa_id' => 9, 'name' => 'Victoria'], ['aa_id' => 4, 'name' => 'Vicuña'], ['aa_id' => 9, 'name' => 'Vilcun'], ['aa_id' => 7, 'name' => 'Villa Alegre'], ['aa_id' => 5, 'name' => 'Villa Alemana'], ['aa_id' => 9, 'name' => 'Villarrica'], ['aa_id' => 5, 'name' => 'Vina del Mar'], ['aa_id' => 13, 'name' => 'Vitacura'], ['aa_id' => 7, 'name' => 'Yerbas Buenas'], ['aa_id' => 8, 'name' => 'Yumbel'], ['aa_id' => 16, 'name' => 'Yungay'], ['aa_id' => 5, 'name' => 'Zapallar'], ['aa_id' => 14, 'name' => 'Corral'], ['aa_id' => 14, 'name' => 'Lanco'], ['aa_id' => 14, 'name' => 'Los Lagos'], ['aa_id' => 14, 'name' => 'Mafil'], ['aa_id' => 14, 'name' => 'Mariquina'], ['aa_id' => 14, 'name' => 'Paillaco'], ['aa_id' => 14, 'name' => 'Panguipulli'], ['aa_id' => 14, 'name' => 'Valdivia'], ['aa_id' => 14, 'name' => 'Futrono'], ['aa_id' => 14, 'name' => 'La Unión'], ['aa_id' => 14, 'name' => 'Lago Ranco'], ['aa_id' => 14, 'name' => 'Rio Bueno'] ]; foreach ($data as $city) { DB::table('ctrystore_cities')->insert([ 'admin_area_id' => $city['aa_id'], 'name' => $city['name'], 'created_at' => $today, 'updated_at' => $today ]); } }
[ "public", "function", "run", "(", ")", "{", "DB", "::", "table", "(", "'ctrystore_cities'", ")", "->", "delete", "(", ")", ";", "$", "today", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "$", "data", "=", "[", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Algarrobo'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Alhue'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Alto BioBío']", ",", "", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Alto del Carmen'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Alto Hospicio'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Ancud'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Andacollo'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Angol'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Antofagasta'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Antuco'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Arauco'", "]", ",", "[", "'aa_id'", "=>", "15", ",", "'name'", "=>", "'Arica'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Buin'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Bulnes'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Cabildo'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Cabo de Hornos'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Cabrero'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Calama'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Antártica']", ",", "", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Calbuco'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Caldera'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Calera de Tango'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Calle Larga'", "]", ",", "[", "'aa_id'", "=>", "15", ",", "'name'", "=>", "'Camarones'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Camiña']", ",", "", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Canela'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Cañete']", ",", "", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Carahue'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Carnameena'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Casablanca'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Castro'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Catemu'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Cauquenes'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Cerrillos'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Cerro Navia'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Chaiten'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Chañaral']", ",", "", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Chanco'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Chépica']", ",", "", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Chiguayante'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Chile Chico'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Chillan'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Chillan Viejo'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Chimbarongo'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Cholchol'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Chonchi'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Cobquecura'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Cochamó']", ",", "", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Cochrane'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Codegua'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Coelemu'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Coihueco'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Coinco'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Colbun'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Colchane'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Colina'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Collipulli'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Coltauco'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Combarbalá']", ",", "", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Concepcion'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Conchali'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Concón']", ",", "", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Constitucion'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Contulmo'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Copiapó']", ",", "", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Coquimbo'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Coronel'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Coyhaique'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Cunco'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Curacautin'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Curacavi'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Curaco de Velez'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Curanilahue'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Curarrehue'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Curepto'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Curico'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Dalcahue'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Diego de Almagro'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Doñihue']", ",", "", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'El Bosque'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'El Carmen'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'El Monte'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'El Quisco'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'El Tabo'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Empedrado'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Ercilla'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Estacion Central'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Florida'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Freire'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Freirina'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Fresia'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Frutillar'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Futaleufu'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Galvarino'", "]", ",", "[", "'aa_id'", "=>", "15", ",", "'name'", "=>", "'General Lagos'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Gorbea'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Graneros'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Guaitecas'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Hijuelas'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Hualaihue'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Puerto Cisnes'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Hualañé'],", "", "", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Hualpén']", ",", "", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Hualqui'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Huara'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Huasco'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Huechuraba'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Río Hurtado']", ",", "", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Illapel'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Independencia'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Iquique'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Isla de Maipo'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Isla de Pascua'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Juan Fernandez'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'La Calera'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'La Cisterna'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'La Cruz'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'La Estrella'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'La Florida'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'La Granja'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'La Higuera'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'La Laja'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'La Ligua'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'La Pintana'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'La Reina'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'La Serena'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Lago Verde'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Laguna Blanca'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Lampa'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Las Cabras'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Las Condes'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Puerto Aysen'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Lautaro'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Lebu'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Licanten'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Limache'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Linares'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Litueche'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Llanquihue'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Lo Barnechea'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Lo Espejo'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Lo Prado'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Lolol'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Loncoche'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Longavi'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Lonquimay'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Los Alamos'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Los Andes'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Los Angeles'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Los Muermos'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Los Sauces'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Los Vilos'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Lota'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Lumaco'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Machalí']", ",", "", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Macul'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Maipu'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Malloa'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Marchihue'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Maria Elena'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Maria Pinto'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Maule'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Maullin'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Mejillones'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Melipeuco'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Melipilla'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Molina'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Monte Patria'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Mulchen'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Nacimiento'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Nancahua'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Navidad'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Negrete'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Ninhue'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Ñiquén'],", "", "", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Nogales'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Nueva Imperial'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Ñuñoa'],", "", "", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "\"O'Higgins\"", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Olivar'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Ollagüe']", ",", "", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Olmue'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Osorno'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Ovalle'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Padre Hurtado'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Padre Las Casas'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Paiguano'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Paine'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Palena'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Palmilla'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Panquehue'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Papudo'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Paredones'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Parral'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Pedro Aguirre Cerda'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Pelarco'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Pelluhue'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Pemuco'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Peñaflor']", ",", "", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Peñalolen']", ",", "", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Pencahue'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Penco'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Peralillo'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Perquenco'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Petorca'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Peumo'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Pica'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Pichidegua'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Pichilemu'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Pinto'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Pirque'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Pitrufquen'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Placilla'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Portezuelo'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Porvenir'", "]", ",", "[", "'aa_id'", "=>", "1", ",", "'name'", "=>", "'Pozo Almonte'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Primavera'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Providencia'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Puchuncaví']", ",", "", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Pucon'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Puerto Saavedra'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Pudahuel'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Puente Alto'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Puerto Montt'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Natales'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Puerto Octay'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Puerto Varas'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Pumanque'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Punitaqui'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Punta Arenas'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Puqueldon'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Puren'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Purranque'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Putaendo'", "]", ",", "[", "'aa_id'", "=>", "15", ",", "'name'", "=>", "'Putre'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Puyehue'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Queilen'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Quellon (Puerto Quellon)'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Quemchi'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Quilaco'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Quilicura'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Quilleco'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Quillon'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Quillota'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Quilpué']", ",", "", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Tucapel'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Quinchao'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Quinta de Tilcoco'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Quinta Normal'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Quintero'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Quirihue'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Rancagua'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Ranquil'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Rapel'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Rauco'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Recoleta'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Renaico'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Renca'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Rengo'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Requinoa'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Retiro'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Rinconada de Los Andes'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Rio Claro'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Rio Ibanez'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'Rio Negro'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Rio Verde'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Romeral'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Sagrada Familia'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Salamanca'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'San Antonio'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'San Bernardo'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'San Carlos'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'San Clemente'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'San Esteban'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'San Fabian'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'San Felipe'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'San Fernando'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'San Gregorio'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'San Ignacio'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'San Javier'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'San Joaquin'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'San Jose de Maipo'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'San Juan de la Costa'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'San Miguel'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'San Nicolas'", "]", ",", "[", "'aa_id'", "=>", "10", ",", "'name'", "=>", "'San Pablo'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'San Pedro'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'San Pedro de Atacama'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'San Pedro de la Paz'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'San Rafael'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'San Ramon'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'San Rosendo'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'San Vicente de Tagua Tagua'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Santa Barbara'", "]", ",", "[", "'aa_id'", "=>", "6", ",", "'name'", "=>", "'Santa Cruz'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Santa Juana'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Santa Maria'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Santiago'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Santo Domingo'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Sierra Gorda'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Talagante'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Talca'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Talcahuano'", "]", ",", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Taltal'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Temuco'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Teno'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Teodoro Schmidt'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Tierra Amarilla'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Til til'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Timaukel'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Tirúa']", ",", "", "[", "'aa_id'", "=>", "2", ",", "'name'", "=>", "'Tocopilla'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Tolten'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Tome'", "]", ",", "[", "'aa_id'", "=>", "12", ",", "'name'", "=>", "'Torres del Paine'", "]", ",", "[", "'aa_id'", "=>", "11", ",", "'name'", "=>", "'Tortel'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Traiguen'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Treguaco'", "]", ",", "[", "'aa_id'", "=>", "3", ",", "'name'", "=>", "'Vallenar'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Valparaiso'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Vichuquen'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Victoria'", "]", ",", "[", "'aa_id'", "=>", "4", ",", "'name'", "=>", "'Vicuña']", ",", "", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Vilcun'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Villa Alegre'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Villa Alemana'", "]", ",", "[", "'aa_id'", "=>", "9", ",", "'name'", "=>", "'Villarrica'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Vina del Mar'", "]", ",", "[", "'aa_id'", "=>", "13", ",", "'name'", "=>", "'Vitacura'", "]", ",", "[", "'aa_id'", "=>", "7", ",", "'name'", "=>", "'Yerbas Buenas'", "]", ",", "[", "'aa_id'", "=>", "8", ",", "'name'", "=>", "'Yumbel'", "]", ",", "[", "'aa_id'", "=>", "16", ",", "'name'", "=>", "'Yungay'", "]", ",", "[", "'aa_id'", "=>", "5", ",", "'name'", "=>", "'Zapallar'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Corral'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Lanco'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Los Lagos'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Mafil'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Mariquina'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Paillaco'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Panguipulli'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Valdivia'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Futrono'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'La Unión']", ",", "", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Lago Ranco'", "]", ",", "[", "'aa_id'", "=>", "14", ",", "'name'", "=>", "'Rio Bueno'", "]", "]", ";", "foreach", "(", "$", "data", "as", "$", "city", ")", "{", "DB", "::", "table", "(", "'ctrystore_cities'", ")", "->", "insert", "(", "[", "'admin_area_id'", "=>", "$", "city", "[", "'aa_id'", "]", ",", "'name'", "=>", "$", "city", "[", "'name'", "]", ",", "'created_at'", "=>", "$", "today", ",", "'updated_at'", "=>", "$", "today", "]", ")", ";", "}", "}" ]
Run the database seeds. @return void
[ "Run", "the", "database", "seeds", "." ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/database/seeds/ChileanCitiesSeeder.php#L12-L373
odiaseo/pagebuilder
src/PageBuilder/Model/SiteModel.php
SiteModel.getSettingList
public function getSettingList(Site $site) { $settingList = []; /** @var $setting \PageBuilder\Entity\Setting */ foreach ($site->getSettings() as $setting) { $code = $setting->getSettingKey()->getCode(); $value = $setting->getSettingValue() ?: $setting->getSettingKey()->getDefaultValue(); $settingList[$code] = $value; } $locale = $site->getLocale() ?: 'en_GB'; $settingList = array_merge($settingList, \Locale::parseLocale($locale)); $settingList['locale'] = $locale; return $settingList; }
php
public function getSettingList(Site $site) { $settingList = []; /** @var $setting \PageBuilder\Entity\Setting */ foreach ($site->getSettings() as $setting) { $code = $setting->getSettingKey()->getCode(); $value = $setting->getSettingValue() ?: $setting->getSettingKey()->getDefaultValue(); $settingList[$code] = $value; } $locale = $site->getLocale() ?: 'en_GB'; $settingList = array_merge($settingList, \Locale::parseLocale($locale)); $settingList['locale'] = $locale; return $settingList; }
[ "public", "function", "getSettingList", "(", "Site", "$", "site", ")", "{", "$", "settingList", "=", "[", "]", ";", "/** @var $setting \\PageBuilder\\Entity\\Setting */", "foreach", "(", "$", "site", "->", "getSettings", "(", ")", "as", "$", "setting", ")", "{", "$", "code", "=", "$", "setting", "->", "getSettingKey", "(", ")", "->", "getCode", "(", ")", ";", "$", "value", "=", "$", "setting", "->", "getSettingValue", "(", ")", "?", ":", "$", "setting", "->", "getSettingKey", "(", ")", "->", "getDefaultValue", "(", ")", ";", "$", "settingList", "[", "$", "code", "]", "=", "$", "value", ";", "}", "$", "locale", "=", "$", "site", "->", "getLocale", "(", ")", "?", ":", "'en_GB'", ";", "$", "settingList", "=", "array_merge", "(", "$", "settingList", ",", "\\", "Locale", "::", "parseLocale", "(", "$", "locale", ")", ")", ";", "$", "settingList", "[", "'locale'", "]", "=", "$", "locale", ";", "return", "$", "settingList", ";", "}" ]
@param $site @return array
[ "@param", "$site" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/SiteModel.php#L24-L39
odiaseo/pagebuilder
src/PageBuilder/Model/SiteModel.php
SiteModel.findSiteBy
public function findSiteBy(array $params, $mode = AbstractQuery::HYDRATE_OBJECT) { /** @var $query QueryBuilder */ $qb = $this->getFindByQueryBuilder($params, null, 'e'); $qb->addSelect('x,y,z,a,l') ->innerJoin('e.siteType', 'x') ->leftJoin('e.parent', 'z') ->leftJoin('e.subDomains', 'a') ->leftJoin('e.linkedSites', 'l') ->leftJoin('e.rootPage', 'y'); if ($mode != AbstractQuery::HYDRATE_OBJECT) { $qb->setEnableHydrationCache($this->isEnableResultCache()); } $site = $qb->getQuery()->getOneOrNullResult($mode); return $site; }
php
public function findSiteBy(array $params, $mode = AbstractQuery::HYDRATE_OBJECT) { /** @var $query QueryBuilder */ $qb = $this->getFindByQueryBuilder($params, null, 'e'); $qb->addSelect('x,y,z,a,l') ->innerJoin('e.siteType', 'x') ->leftJoin('e.parent', 'z') ->leftJoin('e.subDomains', 'a') ->leftJoin('e.linkedSites', 'l') ->leftJoin('e.rootPage', 'y'); if ($mode != AbstractQuery::HYDRATE_OBJECT) { $qb->setEnableHydrationCache($this->isEnableResultCache()); } $site = $qb->getQuery()->getOneOrNullResult($mode); return $site; }
[ "public", "function", "findSiteBy", "(", "array", "$", "params", ",", "$", "mode", "=", "AbstractQuery", "::", "HYDRATE_OBJECT", ")", "{", "/** @var $query QueryBuilder */", "$", "qb", "=", "$", "this", "->", "getFindByQueryBuilder", "(", "$", "params", ",", "null", ",", "'e'", ")", ";", "$", "qb", "->", "addSelect", "(", "'x,y,z,a,l'", ")", "->", "innerJoin", "(", "'e.siteType'", ",", "'x'", ")", "->", "leftJoin", "(", "'e.parent'", ",", "'z'", ")", "->", "leftJoin", "(", "'e.subDomains'", ",", "'a'", ")", "->", "leftJoin", "(", "'e.linkedSites'", ",", "'l'", ")", "->", "leftJoin", "(", "'e.rootPage'", ",", "'y'", ")", ";", "if", "(", "$", "mode", "!=", "AbstractQuery", "::", "HYDRATE_OBJECT", ")", "{", "$", "qb", "->", "setEnableHydrationCache", "(", "$", "this", "->", "isEnableResultCache", "(", ")", ")", ";", "}", "$", "site", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "getOneOrNullResult", "(", "$", "mode", ")", ";", "return", "$", "site", ";", "}" ]
@param array $params @param int $mode @return mixed @throws \Doctrine\ORM\NonUniqueResultException
[ "@param", "array", "$params", "@param", "int", "$mode" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/SiteModel.php#L48-L66
odiaseo/pagebuilder
src/PageBuilder/Model/SiteModel.php
SiteModel.getActiveDomains
public function getActiveDomains($mode = AbstractQuery::HYDRATE_OBJECT, $siteType = null) { $query = $this->getEntityManager() ->createQueryBuilder() ->select('e') ->from($this->getEntity(), 'e') ->where('e.isActive = :active') ->setParameters( [ ':active' => 1, ] ); if ($siteType) { $query->andWhere('e.siteType = :siteType') ->setParameter(':siteType', $siteType); } else { $query->orderBy('e.siteType'); } return $query->getQuery()->getResult($mode); }
php
public function getActiveDomains($mode = AbstractQuery::HYDRATE_OBJECT, $siteType = null) { $query = $this->getEntityManager() ->createQueryBuilder() ->select('e') ->from($this->getEntity(), 'e') ->where('e.isActive = :active') ->setParameters( [ ':active' => 1, ] ); if ($siteType) { $query->andWhere('e.siteType = :siteType') ->setParameter(':siteType', $siteType); } else { $query->orderBy('e.siteType'); } return $query->getQuery()->getResult($mode); }
[ "public", "function", "getActiveDomains", "(", "$", "mode", "=", "AbstractQuery", "::", "HYDRATE_OBJECT", ",", "$", "siteType", "=", "null", ")", "{", "$", "query", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'e'", ")", "->", "from", "(", "$", "this", "->", "getEntity", "(", ")", ",", "'e'", ")", "->", "where", "(", "'e.isActive = :active'", ")", "->", "setParameters", "(", "[", "':active'", "=>", "1", ",", "]", ")", ";", "if", "(", "$", "siteType", ")", "{", "$", "query", "->", "andWhere", "(", "'e.siteType = :siteType'", ")", "->", "setParameter", "(", "':siteType'", ",", "$", "siteType", ")", ";", "}", "else", "{", "$", "query", "->", "orderBy", "(", "'e.siteType'", ")", ";", "}", "return", "$", "query", "->", "getQuery", "(", ")", "->", "getResult", "(", "$", "mode", ")", ";", "}" ]
@param int $mode @param null $siteType @return array
[ "@param", "int", "$mode", "@param", "null", "$siteType" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/SiteModel.php#L125-L146
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/UrlEntryPoint.php
UrlEntryPoint.getUrlsList
public function getUrlsList($instanceName) { $route = new SplashRoute($this->url, $instanceName, 'action', null, null); return array($route); }
php
public function getUrlsList($instanceName) { $route = new SplashRoute($this->url, $instanceName, 'action', null, null); return array($route); }
[ "public", "function", "getUrlsList", "(", "$", "instanceName", ")", "{", "$", "route", "=", "new", "SplashRoute", "(", "$", "this", "->", "url", ",", "$", "instanceName", ",", "'action'", ",", "null", ",", "null", ")", ";", "return", "array", "(", "$", "route", ")", ";", "}" ]
Returns the list of URLs that can be accessed, and the function/method that should be called when the URL is called. @param string $instanceName The identifier for this object in the container. @return SplashRoute[]
[ "Returns", "the", "list", "of", "URLs", "that", "can", "be", "accessed", "and", "the", "function", "/", "method", "that", "should", "be", "called", "when", "the", "URL", "is", "called", "." ]
train
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/UrlEntryPoint.php#L49-L54
netvlies/NetvliesFormBundle
Admin/FieldAdmin.php
FieldAdmin.generateObjectUrl
public function generateObjectUrl($name, $object, array $parameters = array(), $absolute = false) { if ($name != 'list') { return parent::generateObjectUrl($name, $object, $parameters, $absolute); } return parent::generateObjectUrl($name, $object->getForm(), $parameters, $absolute); }
php
public function generateObjectUrl($name, $object, array $parameters = array(), $absolute = false) { if ($name != 'list') { return parent::generateObjectUrl($name, $object, $parameters, $absolute); } return parent::generateObjectUrl($name, $object->getForm(), $parameters, $absolute); }
[ "public", "function", "generateObjectUrl", "(", "$", "name", ",", "$", "object", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "absolute", "=", "false", ")", "{", "if", "(", "$", "name", "!=", "'list'", ")", "{", "return", "parent", "::", "generateObjectUrl", "(", "$", "name", ",", "$", "object", ",", "$", "parameters", ",", "$", "absolute", ")", ";", "}", "return", "parent", "::", "generateObjectUrl", "(", "$", "name", ",", "$", "object", "->", "getForm", "(", ")", ",", "$", "parameters", ",", "$", "absolute", ")", ";", "}" ]
This is to create the correct route when going back to the form edit instead of the field list. @param string $name @param mixed $object @param array $parameters @return string return a complete url
[ "This", "is", "to", "create", "the", "correct", "route", "when", "going", "back", "to", "the", "form", "edit", "instead", "of", "the", "field", "list", "." ]
train
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/Admin/FieldAdmin.php#L149-L156
netvlies/NetvliesFormBundle
Admin/FieldAdmin.php
FieldAdmin.validate
public function validate(ErrorElement $errorElement, $field) { if ($field->getType() == 'date') { $formatter = new IntlDateFormatter(null, null, null); $formatter->setPattern('d-M-y'); if (!$formatter->parse($field->getDefault())) { $errorElement->with('default')->addViolation('Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar'); } } }
php
public function validate(ErrorElement $errorElement, $field) { if ($field->getType() == 'date') { $formatter = new IntlDateFormatter(null, null, null); $formatter->setPattern('d-M-y'); if (!$formatter->parse($field->getDefault())) { $errorElement->with('default')->addViolation('Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar'); } } }
[ "public", "function", "validate", "(", "ErrorElement", "$", "errorElement", ",", "$", "field", ")", "{", "if", "(", "$", "field", "->", "getType", "(", ")", "==", "'date'", ")", "{", "$", "formatter", "=", "new", "IntlDateFormatter", "(", "null", ",", "null", ",", "null", ")", ";", "$", "formatter", "->", "setPattern", "(", "'d-M-y'", ")", ";", "if", "(", "!", "$", "formatter", "->", "parse", "(", "$", "field", "->", "getDefault", "(", ")", ")", ")", "{", "$", "errorElement", "->", "with", "(", "'default'", ")", "->", "addViolation", "(", "'Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar'", ")", ";", "}", "}", "}" ]
Add specific validation when default for type = date is entered.
[ "Add", "specific", "validation", "when", "default", "for", "type", "=", "date", "is", "entered", "." ]
train
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/Admin/FieldAdmin.php#L161-L171
alevilar/ristorantino-vendor
Acl/Controller/Component/AclReflectorComponent.php
AclReflectorComponent.getPluginName
public function getPluginName($ctrlName = null) { $arr = String::tokenize($ctrlName, '/'); if (count($arr) == 2) { return $arr[0]; } else { return false; } }
php
public function getPluginName($ctrlName = null) { $arr = String::tokenize($ctrlName, '/'); if (count($arr) == 2) { return $arr[0]; } else { return false; } }
[ "public", "function", "getPluginName", "(", "$", "ctrlName", "=", "null", ")", "{", "$", "arr", "=", "String", "::", "tokenize", "(", "$", "ctrlName", ",", "'/'", ")", ";", "if", "(", "count", "(", "$", "arr", ")", "==", "2", ")", "{", "return", "$", "arr", "[", "0", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
*************************************************************************************
[ "*************************************************************************************" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclReflectorComponent.php#L15-L23
alevilar/ristorantino-vendor
Acl/Controller/Component/AclReflectorComponent.php
AclReflectorComponent.get_all_plugins_paths
public function get_all_plugins_paths() { $plugin_names = CakePlugin::loaded(); $plugin_paths = array(); foreach($plugin_names as $plugin_name) { $plugin_paths[] = CakePlugin::path($plugin_name); } return $plugin_paths; }
php
public function get_all_plugins_paths() { $plugin_names = CakePlugin::loaded(); $plugin_paths = array(); foreach($plugin_names as $plugin_name) { $plugin_paths[] = CakePlugin::path($plugin_name); } return $plugin_paths; }
[ "public", "function", "get_all_plugins_paths", "(", ")", "{", "$", "plugin_names", "=", "CakePlugin", "::", "loaded", "(", ")", ";", "$", "plugin_paths", "=", "array", "(", ")", ";", "foreach", "(", "$", "plugin_names", "as", "$", "plugin_name", ")", "{", "$", "plugin_paths", "[", "]", "=", "CakePlugin", "::", "path", "(", "$", "plugin_name", ")", ";", "}", "return", "$", "plugin_paths", ";", "}" ]
*************************************************************************************
[ "*************************************************************************************" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclReflectorComponent.php#L63-L74
alevilar/ristorantino-vendor
Acl/Controller/Component/AclReflectorComponent.php
AclReflectorComponent.get_controller_actions
public function get_controller_actions($controller_classname, $filter_base_methods = true) { $controller_classname = $this->get_controller_classname($controller_classname); $methods = get_class_methods($controller_classname); if(isset($methods) && !empty($methods)) { if($filter_base_methods) { $baseMethods = get_class_methods('Controller'); $ctrl_cleaned_methods = array(); foreach($methods as $method) { if(!in_array($method, $baseMethods) && strpos($method, '_') !== 0) { $ctrl_cleaned_methods[] = $method; } } return $ctrl_cleaned_methods; } else { return $methods; } } else { return array(); } }
php
public function get_controller_actions($controller_classname, $filter_base_methods = true) { $controller_classname = $this->get_controller_classname($controller_classname); $methods = get_class_methods($controller_classname); if(isset($methods) && !empty($methods)) { if($filter_base_methods) { $baseMethods = get_class_methods('Controller'); $ctrl_cleaned_methods = array(); foreach($methods as $method) { if(!in_array($method, $baseMethods) && strpos($method, '_') !== 0) { $ctrl_cleaned_methods[] = $method; } } return $ctrl_cleaned_methods; } else { return $methods; } } else { return array(); } }
[ "public", "function", "get_controller_actions", "(", "$", "controller_classname", ",", "$", "filter_base_methods", "=", "true", ")", "{", "$", "controller_classname", "=", "$", "this", "->", "get_controller_classname", "(", "$", "controller_classname", ")", ";", "$", "methods", "=", "get_class_methods", "(", "$", "controller_classname", ")", ";", "if", "(", "isset", "(", "$", "methods", ")", "&&", "!", "empty", "(", "$", "methods", ")", ")", "{", "if", "(", "$", "filter_base_methods", ")", "{", "$", "baseMethods", "=", "get_class_methods", "(", "'Controller'", ")", ";", "$", "ctrl_cleaned_methods", "=", "array", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "!", "in_array", "(", "$", "method", ",", "$", "baseMethods", ")", "&&", "strpos", "(", "$", "method", ",", "'_'", ")", "!==", "0", ")", "{", "$", "ctrl_cleaned_methods", "[", "]", "=", "$", "method", ";", "}", "}", "return", "$", "ctrl_cleaned_methods", ";", "}", "else", "{", "return", "$", "methods", ";", "}", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Return the methods of a given class name. Depending on the $filter_base_methods parameter, it can return the parent methods. @param string $controller_class_name (eg: 'AcosController') @param boolean $filter_base_methods
[ "Return", "the", "methods", "of", "a", "given", "class", "name", ".", "Depending", "on", "the", "$filter_base_methods", "parameter", "it", "can", "return", "the", "parent", "methods", "." ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclReflectorComponent.php#L248-L280
grozzzny/catalog
models/Properties.php
Properties.getCategory
public function getCategory() { $categoryModel = static::getCategoryModel(); return ($this->type == self::TYPE_CATEGORY) ? $this->hasOne($categoryModel::className(), ['id' => $this->options->category_id]) : null; }
php
public function getCategory() { $categoryModel = static::getCategoryModel(); return ($this->type == self::TYPE_CATEGORY) ? $this->hasOne($categoryModel::className(), ['id' => $this->options->category_id]) : null; }
[ "public", "function", "getCategory", "(", ")", "{", "$", "categoryModel", "=", "static", "::", "getCategoryModel", "(", ")", ";", "return", "(", "$", "this", "->", "type", "==", "self", "::", "TYPE_CATEGORY", ")", "?", "$", "this", "->", "hasOne", "(", "$", "categoryModel", "::", "className", "(", ")", ",", "[", "'id'", "=>", "$", "this", "->", "options", "->", "category_id", "]", ")", ":", "null", ";", "}" ]
Only type "TYPE_CATEGORY" @return null|\yii\db\ActiveQuery
[ "Only", "type", "TYPE_CATEGORY" ]
train
https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/Properties.php#L251-L255
bit3archive/php-remote-objects
src/RemoteObjects/Transport/HttpServer.php
HttpServer.receive
public function receive() { $input = file_get_contents('php://input'); if ( $this->logger !== null && $this->logger->isHandling(Logger::DEBUG) ) { $this->logger->addDebug( 'Receive request', array( 'request' => ctype_print($input) ? $input : 'base64:' . base64_encode($input) ) ); } return $input; }
php
public function receive() { $input = file_get_contents('php://input'); if ( $this->logger !== null && $this->logger->isHandling(Logger::DEBUG) ) { $this->logger->addDebug( 'Receive request', array( 'request' => ctype_print($input) ? $input : 'base64:' . base64_encode($input) ) ); } return $input; }
[ "public", "function", "receive", "(", ")", "{", "$", "input", "=", "file_get_contents", "(", "'php://input'", ")", ";", "if", "(", "$", "this", "->", "logger", "!==", "null", "&&", "$", "this", "->", "logger", "->", "isHandling", "(", "Logger", "::", "DEBUG", ")", ")", "{", "$", "this", "->", "logger", "->", "addDebug", "(", "'Receive request'", ",", "array", "(", "'request'", "=>", "ctype_print", "(", "$", "input", ")", "?", "$", "input", ":", "'base64:'", ".", "base64_encode", "(", "$", "input", ")", ")", ")", ";", "}", "return", "$", "input", ";", "}" ]
Receive the serialized json request. @return stdClass
[ "Receive", "the", "serialized", "json", "request", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Transport/HttpServer.php#L61-L78
bit3archive/php-remote-objects
src/RemoteObjects/Transport/HttpServer.php
HttpServer.respond
public function respond($response) { if ( $this->logger !== null && $this->logger->isHandling(Logger::DEBUG) ) { $this->logger->addDebug( 'Send response', array( 'content-type' => $this->contentType, 'response' => ctype_print($response) ? $response : 'base64:' . base64_encode($response) ) ); } ob_start(); while (ob_end_clean()) { } header('Content-Type: ' . $this->contentType); echo $response; }
php
public function respond($response) { if ( $this->logger !== null && $this->logger->isHandling(Logger::DEBUG) ) { $this->logger->addDebug( 'Send response', array( 'content-type' => $this->contentType, 'response' => ctype_print($response) ? $response : 'base64:' . base64_encode($response) ) ); } ob_start(); while (ob_end_clean()) { } header('Content-Type: ' . $this->contentType); echo $response; }
[ "public", "function", "respond", "(", "$", "response", ")", "{", "if", "(", "$", "this", "->", "logger", "!==", "null", "&&", "$", "this", "->", "logger", "->", "isHandling", "(", "Logger", "::", "DEBUG", ")", ")", "{", "$", "this", "->", "logger", "->", "addDebug", "(", "'Send response'", ",", "array", "(", "'content-type'", "=>", "$", "this", "->", "contentType", ",", "'response'", "=>", "ctype_print", "(", "$", "response", ")", "?", "$", "response", ":", "'base64:'", ".", "base64_encode", "(", "$", "response", ")", ")", ")", ";", "}", "ob_start", "(", ")", ";", "while", "(", "ob_end_clean", "(", ")", ")", "{", "}", "header", "(", "'Content-Type: '", ".", "$", "this", "->", "contentType", ")", ";", "echo", "$", "response", ";", "}" ]
Send response. @param mixed $result @param \Exception $error
[ "Send", "response", "." ]
train
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Transport/HttpServer.php#L86-L106
blast-project/BaseEntitiesBundle
src/EventListener/LabelableListener.php
LabelableListener.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Labelable')) { return; } // return if current entity doesn't use Labelable trait $this->logger->debug('[LabelableListener] Entering LabelableListener for « loadClassMetadata » event'); // setting default mapping configuration for Labelable // name $metadata->mapField([ 'fieldName' => 'label', 'type' => 'string', 'nullable' => true, ]); $this->logger->debug( '[LabelableListener] Added Labelable mapping metadata to Entity', ['class' => $metadata->getName()] ); }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Labelable')) { return; } // return if current entity doesn't use Labelable trait $this->logger->debug('[LabelableListener] Entering LabelableListener for « loadClassMetadata » event'); // setting default mapping configuration for Labelable // name $metadata->mapField([ 'fieldName' => 'label', 'type' => 'string', 'nullable' => true, ]); $this->logger->debug( '[LabelableListener] Added Labelable mapping metadata to Entity', ['class' => $metadata->getName()] ); }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "eventArgs", ")", "{", "/** @var ClassMetadata $metadata */", "$", "metadata", "=", "$", "eventArgs", "->", "getClassMetadata", "(", ")", ";", "$", "reflectionClass", "=", "$", "metadata", "->", "getReflectionClass", "(", ")", ";", "if", "(", "!", "$", "reflectionClass", "||", "!", "$", "this", "->", "hasTrait", "(", "$", "reflectionClass", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Labelable'", ")", ")", "{", "return", ";", "}", "// return if current entity doesn't use Labelable trait", "$", "this", "->", "logger", "->", "debug", "(", "'[LabelableListener] Entering LabelableListener for « loadClassMetadata » event');", "", "", "// setting default mapping configuration for Labelable", "// name", "$", "metadata", "->", "mapField", "(", "[", "'fieldName'", "=>", "'label'", ",", "'type'", "=>", "'string'", ",", "'nullable'", "=>", "true", ",", "]", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'[LabelableListener] Added Labelable mapping metadata to Entity'", ",", "[", "'class'", "=>", "$", "metadata", "->", "getName", "(", ")", "]", ")", ";", "}" ]
define Labelable mapping at runtime. @param LoadClassMetadataEventArgs $eventArgs
[ "define", "Labelable", "mapping", "at", "runtime", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/LabelableListener.php#L43-L69
PHPPowertools/HTML5
src/PowerTools/HTML5/Parser/TreeBuildingRules.php
HTML5_Parser_TreeBuildingRules.evaluate
public function evaluate($new, $current) { switch ($new->tagName) { case 'li': return $this->handleLI($new, $current); case 'dt': case 'dd': return $this->handleDT($new, $current); case 'rt': case 'rp': return $this->handleRT($new, $current); case 'optgroup': return $this->closeIfCurrentMatches($new, $current, array( 'optgroup' )); case 'option': return $this->closeIfCurrentMatches($new, $current, array( 'option', 'optgroup' )); case 'tr': return $this->closeIfCurrentMatches($new, $current, array( 'tr' )); case 'td': case 'th': return $this->closeIfCurrentMatches($new, $current, array( 'th', 'td' )); case 'tbody': case 'thead': case 'tfoot': case 'table': // Spec isn't explicit about this, but it's necessary. return $this->closeIfCurrentMatches($new, $current, array( 'thead', 'tfoot', 'tbody' )); } return $current; }
php
public function evaluate($new, $current) { switch ($new->tagName) { case 'li': return $this->handleLI($new, $current); case 'dt': case 'dd': return $this->handleDT($new, $current); case 'rt': case 'rp': return $this->handleRT($new, $current); case 'optgroup': return $this->closeIfCurrentMatches($new, $current, array( 'optgroup' )); case 'option': return $this->closeIfCurrentMatches($new, $current, array( 'option', 'optgroup' )); case 'tr': return $this->closeIfCurrentMatches($new, $current, array( 'tr' )); case 'td': case 'th': return $this->closeIfCurrentMatches($new, $current, array( 'th', 'td' )); case 'tbody': case 'thead': case 'tfoot': case 'table': // Spec isn't explicit about this, but it's necessary. return $this->closeIfCurrentMatches($new, $current, array( 'thead', 'tfoot', 'tbody' )); } return $current; }
[ "public", "function", "evaluate", "(", "$", "new", ",", "$", "current", ")", "{", "switch", "(", "$", "new", "->", "tagName", ")", "{", "case", "'li'", ":", "return", "$", "this", "->", "handleLI", "(", "$", "new", ",", "$", "current", ")", ";", "case", "'dt'", ":", "case", "'dd'", ":", "return", "$", "this", "->", "handleDT", "(", "$", "new", ",", "$", "current", ")", ";", "case", "'rt'", ":", "case", "'rp'", ":", "return", "$", "this", "->", "handleRT", "(", "$", "new", ",", "$", "current", ")", ";", "case", "'optgroup'", ":", "return", "$", "this", "->", "closeIfCurrentMatches", "(", "$", "new", ",", "$", "current", ",", "array", "(", "'optgroup'", ")", ")", ";", "case", "'option'", ":", "return", "$", "this", "->", "closeIfCurrentMatches", "(", "$", "new", ",", "$", "current", ",", "array", "(", "'option'", ",", "'optgroup'", ")", ")", ";", "case", "'tr'", ":", "return", "$", "this", "->", "closeIfCurrentMatches", "(", "$", "new", ",", "$", "current", ",", "array", "(", "'tr'", ")", ")", ";", "case", "'td'", ":", "case", "'th'", ":", "return", "$", "this", "->", "closeIfCurrentMatches", "(", "$", "new", ",", "$", "current", ",", "array", "(", "'th'", ",", "'td'", ")", ")", ";", "case", "'tbody'", ":", "case", "'thead'", ":", "case", "'tfoot'", ":", "case", "'table'", ":", "// Spec isn't explicit about this, but it's necessary.", "return", "$", "this", "->", "closeIfCurrentMatches", "(", "$", "new", ",", "$", "current", ",", "array", "(", "'thead'", ",", "'tfoot'", ",", "'tbody'", ")", ")", ";", "}", "return", "$", "current", ";", "}" ]
Evaluate the rule for the current tag name. This may modify the existing DOM. @return \DOMElement The new Current DOM element.
[ "Evaluate", "the", "rule", "for", "the", "current", "tag", "name", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/TreeBuildingRules.php#L142-L184
heidelpay/PhpDoc
src/phpDocumentor/Command/Phar/UpdateCommand.php
UpdateCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Looking for updates...'); $manager = $this->createManager($output); $version = $input->getArgument('version') ? $input->getArgument('version') : $this->getApplication()->getVersion(); $allowMajor = $input->getOption('major'); $allowPreRelease = $input->getOption('pre'); if (strpos($version, 'v') === 0) { // strip v tag from phar version for self-update $version = str_replace('v', '', $version); } $this->updateCurrentVersion($manager, $version, $allowMajor, $allowPreRelease, $output); return 0; }
php
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Looking for updates...'); $manager = $this->createManager($output); $version = $input->getArgument('version') ? $input->getArgument('version') : $this->getApplication()->getVersion(); $allowMajor = $input->getOption('major'); $allowPreRelease = $input->getOption('pre'); if (strpos($version, 'v') === 0) { // strip v tag from phar version for self-update $version = str_replace('v', '', $version); } $this->updateCurrentVersion($manager, $version, $allowMajor, $allowPreRelease, $output); return 0; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "'Looking for updates...'", ")", ";", "$", "manager", "=", "$", "this", "->", "createManager", "(", "$", "output", ")", ";", "$", "version", "=", "$", "input", "->", "getArgument", "(", "'version'", ")", "?", "$", "input", "->", "getArgument", "(", "'version'", ")", ":", "$", "this", "->", "getApplication", "(", ")", "->", "getVersion", "(", ")", ";", "$", "allowMajor", "=", "$", "input", "->", "getOption", "(", "'major'", ")", ";", "$", "allowPreRelease", "=", "$", "input", "->", "getOption", "(", "'pre'", ")", ";", "if", "(", "strpos", "(", "$", "version", ",", "'v'", ")", "===", "0", ")", "{", "// strip v tag from phar version for self-update", "$", "version", "=", "str_replace", "(", "'v'", ",", "''", ",", "$", "version", ")", ";", "}", "$", "this", "->", "updateCurrentVersion", "(", "$", "manager", ",", "$", "version", ",", "$", "allowMajor", ",", "$", "allowPreRelease", ",", "$", "output", ")", ";", "return", "0", ";", "}" ]
Executes the business logic involved with this command. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int
[ "Executes", "the", "business", "logic", "involved", "with", "this", "command", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Phar/UpdateCommand.php#L61-L80
heidelpay/PhpDoc
src/phpDocumentor/Command/Phar/UpdateCommand.php
UpdateCommand.createManager
private function createManager(OutputInterface $output) { try { return new Manager(Manifest::loadFile(self::MANIFEST_FILE)); } catch (FileException $e) { $output->writeln('<error>Unable to search for updates.</error>'); exit(1); } }
php
private function createManager(OutputInterface $output) { try { return new Manager(Manifest::loadFile(self::MANIFEST_FILE)); } catch (FileException $e) { $output->writeln('<error>Unable to search for updates.</error>'); exit(1); } }
[ "private", "function", "createManager", "(", "OutputInterface", "$", "output", ")", "{", "try", "{", "return", "new", "Manager", "(", "Manifest", "::", "loadFile", "(", "self", "::", "MANIFEST_FILE", ")", ")", ";", "}", "catch", "(", "FileException", "$", "e", ")", "{", "$", "output", "->", "writeln", "(", "'<error>Unable to search for updates.</error>'", ")", ";", "exit", "(", "1", ")", ";", "}", "}" ]
Returns manager instance or exit with status code 1 on failure. @param OutputInterface $output @return \Herrera\Phar\Update\Manager
[ "Returns", "manager", "instance", "or", "exit", "with", "status", "code", "1", "on", "failure", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Phar/UpdateCommand.php#L89-L98
heidelpay/PhpDoc
src/phpDocumentor/Command/Phar/UpdateCommand.php
UpdateCommand.updateCurrentVersion
private function updateCurrentVersion( Manager $manager, $version, $allowMajor, $allowPreRelease, OutputInterface $output ) { if ($manager->update($version, $allowMajor, $allowPreRelease)) { $output->writeln('<info>Updated to latest version.</info>'); } else { $output->writeln('<comment>Already up-to-date.</comment>'); } }
php
private function updateCurrentVersion( Manager $manager, $version, $allowMajor, $allowPreRelease, OutputInterface $output ) { if ($manager->update($version, $allowMajor, $allowPreRelease)) { $output->writeln('<info>Updated to latest version.</info>'); } else { $output->writeln('<comment>Already up-to-date.</comment>'); } }
[ "private", "function", "updateCurrentVersion", "(", "Manager", "$", "manager", ",", "$", "version", ",", "$", "allowMajor", ",", "$", "allowPreRelease", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "$", "manager", "->", "update", "(", "$", "version", ",", "$", "allowMajor", ",", "$", "allowPreRelease", ")", ")", "{", "$", "output", "->", "writeln", "(", "'<info>Updated to latest version.</info>'", ")", ";", "}", "else", "{", "$", "output", "->", "writeln", "(", "'<comment>Already up-to-date.</comment>'", ")", ";", "}", "}" ]
Updates current version. @param Manager $manager @param string $version @param bool|null $allowMajor @param bool|null $allowPreRelease @param OutputInterface $output @return void
[ "Updates", "current", "version", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Phar/UpdateCommand.php#L111-L123
nabab/bbn
src/bbn/html/input.php
input.html_with_label
public function html_with_label($with_script=1) { $s = $this->html(); if ( !empty($s) ){ if ( BBN_IS_DEV ){ $title = str_replace('"', '', print_r (bbn\str::make_readable($this->cfg), true)); } else if ( isset($this->attr['title']) ){ $title = $this->attr['title']; } else{ $title = isset($this->label) ? $this->label : ''; } if ( !isset($this->cfg['field']) || $this->cfg['field'] !== 'hidden' ){ $s = '<label class="bbn-form-label" title="'.$title.'" for="'.$this->attr['id'].'">'.$this->label.'</label><div class="bbn-form-field">'.$s.'</div>'; } } return $s; }
php
public function html_with_label($with_script=1) { $s = $this->html(); if ( !empty($s) ){ if ( BBN_IS_DEV ){ $title = str_replace('"', '', print_r (bbn\str::make_readable($this->cfg), true)); } else if ( isset($this->attr['title']) ){ $title = $this->attr['title']; } else{ $title = isset($this->label) ? $this->label : ''; } if ( !isset($this->cfg['field']) || $this->cfg['field'] !== 'hidden' ){ $s = '<label class="bbn-form-label" title="'.$title.'" for="'.$this->attr['id'].'">'.$this->label.'</label><div class="bbn-form-field">'.$s.'</div>'; } } return $s; }
[ "public", "function", "html_with_label", "(", "$", "with_script", "=", "1", ")", "{", "$", "s", "=", "$", "this", "->", "html", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "s", ")", ")", "{", "if", "(", "BBN_IS_DEV", ")", "{", "$", "title", "=", "str_replace", "(", "'\"'", ",", "''", ",", "print_r", "(", "bbn", "\\", "str", "::", "make_readable", "(", "$", "this", "->", "cfg", ")", ",", "true", ")", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "this", "->", "attr", "[", "'title'", "]", ")", ")", "{", "$", "title", "=", "$", "this", "->", "attr", "[", "'title'", "]", ";", "}", "else", "{", "$", "title", "=", "isset", "(", "$", "this", "->", "label", ")", "?", "$", "this", "->", "label", ":", "''", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "cfg", "[", "'field'", "]", ")", "||", "$", "this", "->", "cfg", "[", "'field'", "]", "!==", "'hidden'", ")", "{", "$", "s", "=", "'<label class=\"bbn-form-label\" title=\"'", ".", "$", "title", ".", "'\" for=\"'", ".", "$", "this", "->", "attr", "[", "'id'", "]", ".", "'\">'", ".", "$", "this", "->", "label", ".", "'</label><div class=\"bbn-form-field\">'", ".", "$", "s", ".", "'</div>'", ";", "}", "}", "return", "$", "s", ";", "}" ]
Returns the element with its label and inside a div @return string
[ "Returns", "the", "element", "with", "its", "label", "and", "inside", "a", "div" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/input.php#L203-L221
brick/di
src/ValueResolver/ContainerValueResolver.php
ContainerValueResolver.getParameterValue
public function getParameterValue(\ReflectionParameter $parameter) { // Check if an injection key is available for this parameter. $key = $this->injectionPolicy->getParameterKey($parameter); if ($key !== null) { return $this->container->get($key); } // Try to resolve the parameter by type. $class = $parameter->getClass(); if ($class) { $className = $class->getName(); if ($this->container->has($className)) { return $this->container->get($className); } } return $this->defaultValueResolver->getParameterValue($parameter); }
php
public function getParameterValue(\ReflectionParameter $parameter) { // Check if an injection key is available for this parameter. $key = $this->injectionPolicy->getParameterKey($parameter); if ($key !== null) { return $this->container->get($key); } // Try to resolve the parameter by type. $class = $parameter->getClass(); if ($class) { $className = $class->getName(); if ($this->container->has($className)) { return $this->container->get($className); } } return $this->defaultValueResolver->getParameterValue($parameter); }
[ "public", "function", "getParameterValue", "(", "\\", "ReflectionParameter", "$", "parameter", ")", "{", "// Check if an injection key is available for this parameter.", "$", "key", "=", "$", "this", "->", "injectionPolicy", "->", "getParameterKey", "(", "$", "parameter", ")", ";", "if", "(", "$", "key", "!==", "null", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "key", ")", ";", "}", "// Try to resolve the parameter by type.", "$", "class", "=", "$", "parameter", "->", "getClass", "(", ")", ";", "if", "(", "$", "class", ")", "{", "$", "className", "=", "$", "class", "->", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "className", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "className", ")", ";", "}", "}", "return", "$", "this", "->", "defaultValueResolver", "->", "getParameterValue", "(", "$", "parameter", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/ValueResolver/ContainerValueResolver.php#L50-L68
brick/di
src/ValueResolver/ContainerValueResolver.php
ContainerValueResolver.getPropertyValue
public function getPropertyValue(\ReflectionProperty $property) { // Check if an injection key is available for this property. $key = $this->injectionPolicy->getPropertyKey($property); if ($key !== null) { return $this->container->get($key); } // Try to resolve the property by type. $className = $this->reflectionTools->getPropertyClass($property); if ($className !== null) { if ($this->container->has($className)) { return $this->container->get($className); } } return $this->defaultValueResolver->getPropertyValue($property); }
php
public function getPropertyValue(\ReflectionProperty $property) { // Check if an injection key is available for this property. $key = $this->injectionPolicy->getPropertyKey($property); if ($key !== null) { return $this->container->get($key); } // Try to resolve the property by type. $className = $this->reflectionTools->getPropertyClass($property); if ($className !== null) { if ($this->container->has($className)) { return $this->container->get($className); } } return $this->defaultValueResolver->getPropertyValue($property); }
[ "public", "function", "getPropertyValue", "(", "\\", "ReflectionProperty", "$", "property", ")", "{", "// Check if an injection key is available for this property.", "$", "key", "=", "$", "this", "->", "injectionPolicy", "->", "getPropertyKey", "(", "$", "property", ")", ";", "if", "(", "$", "key", "!==", "null", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "key", ")", ";", "}", "// Try to resolve the property by type.", "$", "className", "=", "$", "this", "->", "reflectionTools", "->", "getPropertyClass", "(", "$", "property", ")", ";", "if", "(", "$", "className", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "className", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "className", ")", ";", "}", "}", "return", "$", "this", "->", "defaultValueResolver", "->", "getPropertyValue", "(", "$", "property", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/ValueResolver/ContainerValueResolver.php#L73-L90
GrupaZero/api
src/Gzero/Api/Middleware/AdminApiAccess.php
AdminApiAccess.handle
public function handle($request, Closure $next) { if ($request->user()->hasPermission('admin-api-access') || $request->user()->isSuperAdmin()) { return $next($request); } return abort(404); }
php
public function handle($request, Closure $next) { if ($request->user()->hasPermission('admin-api-access') || $request->user()->isSuperAdmin()) { return $next($request); } return abort(404); }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ")", "{", "if", "(", "$", "request", "->", "user", "(", ")", "->", "hasPermission", "(", "'admin-api-access'", ")", "||", "$", "request", "->", "user", "(", ")", "->", "isSuperAdmin", "(", ")", ")", "{", "return", "$", "next", "(", "$", "request", ")", ";", "}", "return", "abort", "(", "404", ")", ";", "}" ]
Return 404 if user is not authenticated or got no admin rights @param \Illuminate\Http\Request $request Request object @param \Closure $next Next middleware @return mixed
[ "Return", "404", "if", "user", "is", "not", "authenticated", "or", "got", "no", "admin", "rights" ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Middleware/AdminApiAccess.php#L25-L31
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Module/DomainRouting.php
DomainRouting.domainRouting
protected function domainRouting () { $request = & $this->request; if ($this->routeGetRequestsOnly) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; trigger_error("[".$selfClass."] Routing only GET requests with special media " ."site version or localization conditions is not allowed in module router.", E_USER_WARNING); $this->routeGetRequestsOnly = FALSE; } /** @var $route \MvcCore\Ext\Routers\Modules\Route */ $allMatchedParams = []; foreach ($this->domainRoutes as & $route) { $allMatchedParams = $route->Matches($request); if ($allMatchedParams !== NULL) { $this->currentDomainRoute = clone $route; $this->currentModule = $this->currentDomainRoute->GetModule(); $this->currentDomainRoute->SetMatchedParams($allMatchedParams); $this->domainRoutingSetRequestedAndDefaultParams($allMatchedParams); $break = $this->domainRoutingFilterParams($allMatchedParams); $this->domainRoutingSetUpRouterByDomainRoute(); if ($break) break; } } }
php
protected function domainRouting () { $request = & $this->request; if ($this->routeGetRequestsOnly) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; trigger_error("[".$selfClass."] Routing only GET requests with special media " ."site version or localization conditions is not allowed in module router.", E_USER_WARNING); $this->routeGetRequestsOnly = FALSE; } /** @var $route \MvcCore\Ext\Routers\Modules\Route */ $allMatchedParams = []; foreach ($this->domainRoutes as & $route) { $allMatchedParams = $route->Matches($request); if ($allMatchedParams !== NULL) { $this->currentDomainRoute = clone $route; $this->currentModule = $this->currentDomainRoute->GetModule(); $this->currentDomainRoute->SetMatchedParams($allMatchedParams); $this->domainRoutingSetRequestedAndDefaultParams($allMatchedParams); $break = $this->domainRoutingFilterParams($allMatchedParams); $this->domainRoutingSetUpRouterByDomainRoute(); if ($break) break; } } }
[ "protected", "function", "domainRouting", "(", ")", "{", "$", "request", "=", "&", "$", "this", "->", "request", ";", "if", "(", "$", "this", "->", "routeGetRequestsOnly", ")", "{", "$", "selfClass", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.5'", ",", "'>'", ")", "?", "self", "::", "class", ":", "__CLASS__", ";", "trigger_error", "(", "\"[\"", ".", "$", "selfClass", ".", "\"] Routing only GET requests with special media \"", ".", "\"site version or localization conditions is not allowed in module router.\"", ",", "E_USER_WARNING", ")", ";", "$", "this", "->", "routeGetRequestsOnly", "=", "FALSE", ";", "}", "/** @var $route \\MvcCore\\Ext\\Routers\\Modules\\Route */", "$", "allMatchedParams", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "domainRoutes", "as", "&", "$", "route", ")", "{", "$", "allMatchedParams", "=", "$", "route", "->", "Matches", "(", "$", "request", ")", ";", "if", "(", "$", "allMatchedParams", "!==", "NULL", ")", "{", "$", "this", "->", "currentDomainRoute", "=", "clone", "$", "route", ";", "$", "this", "->", "currentModule", "=", "$", "this", "->", "currentDomainRoute", "->", "GetModule", "(", ")", ";", "$", "this", "->", "currentDomainRoute", "->", "SetMatchedParams", "(", "$", "allMatchedParams", ")", ";", "$", "this", "->", "domainRoutingSetRequestedAndDefaultParams", "(", "$", "allMatchedParams", ")", ";", "$", "break", "=", "$", "this", "->", "domainRoutingFilterParams", "(", "$", "allMatchedParams", ")", ";", "$", "this", "->", "domainRoutingSetUpRouterByDomainRoute", "(", ")", ";", "if", "(", "$", "break", ")", "break", ";", "}", "}", "}" ]
Process routing by defined module domain routes. If any module domain route matches the request, complete current domain route property and current domain module property and set up requested domain params and default domain params by matched domain route params. @throws \LogicException Route configuration property is missing. @throws \InvalidArgumentException Wrong route pattern format. @return void
[ "Process", "routing", "by", "defined", "module", "domain", "routes", ".", "If", "any", "module", "domain", "route", "matches", "the", "request", "complete", "current", "domain", "route", "property", "and", "current", "domain", "module", "property", "and", "set", "up", "requested", "domain", "params", "and", "default", "domain", "params", "by", "matched", "domain", "route", "params", "." ]
train
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/DomainRouting.php#L27-L50
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Module/DomainRouting.php
DomainRouting.domainRoutingSetRequestedAndDefaultParams
protected function domainRoutingSetRequestedAndDefaultParams (array & $allMatchedParams) { /** @var $currentRoute \MvcCore\Route */ $currentRoute = & $this->currentDomainRoute; $allMatchedParams[static::URL_PARAM_MODULE] = $currentRoute->GetModule(); $this->defaultParams = array_merge( $currentRoute->GetDefaults(), $allMatchedParams ); $this->requestedDomainParams = array_merge([], $allMatchedParams); }
php
protected function domainRoutingSetRequestedAndDefaultParams (array & $allMatchedParams) { /** @var $currentRoute \MvcCore\Route */ $currentRoute = & $this->currentDomainRoute; $allMatchedParams[static::URL_PARAM_MODULE] = $currentRoute->GetModule(); $this->defaultParams = array_merge( $currentRoute->GetDefaults(), $allMatchedParams ); $this->requestedDomainParams = array_merge([], $allMatchedParams); }
[ "protected", "function", "domainRoutingSetRequestedAndDefaultParams", "(", "array", "&", "$", "allMatchedParams", ")", "{", "/** @var $currentRoute \\MvcCore\\Route */", "$", "currentRoute", "=", "&", "$", "this", "->", "currentDomainRoute", ";", "$", "allMatchedParams", "[", "static", "::", "URL_PARAM_MODULE", "]", "=", "$", "currentRoute", "->", "GetModule", "(", ")", ";", "$", "this", "->", "defaultParams", "=", "array_merge", "(", "$", "currentRoute", "->", "GetDefaults", "(", ")", ",", "$", "allMatchedParams", ")", ";", "$", "this", "->", "requestedDomainParams", "=", "array_merge", "(", "[", "]", ",", "$", "allMatchedParams", ")", ";", "}" ]
If module domain route has been matched, complete requested domain params and set up default params (before normal routing) with params from matched domain route. @param array $allMatchedParams @return void
[ "If", "module", "domain", "route", "has", "been", "matched", "complete", "requested", "domain", "params", "and", "set", "up", "default", "params", "(", "before", "normal", "routing", ")", "with", "params", "from", "matched", "domain", "route", "." ]
train
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/DomainRouting.php#L59-L67
mikebarlow/html-helper
src/Services/CometPHP/Router.php
Router.getUrl
public function getUrl($url) { if (is_array($url) && ! empty($url['route'])) { try { $Comet = \CometPHP\Comet::getInstance(); } catch (\CometPHP\Exceptions\CometNotBooted $e) { return null; } $routeName = $url['route']; unset($url['route']); $generatedUrl = $Comet['routeGenerator']->generate( $routeName, $url ); return $generatedUrl; } return $url; }
php
public function getUrl($url) { if (is_array($url) && ! empty($url['route'])) { try { $Comet = \CometPHP\Comet::getInstance(); } catch (\CometPHP\Exceptions\CometNotBooted $e) { return null; } $routeName = $url['route']; unset($url['route']); $generatedUrl = $Comet['routeGenerator']->generate( $routeName, $url ); return $generatedUrl; } return $url; }
[ "public", "function", "getUrl", "(", "$", "url", ")", "{", "if", "(", "is_array", "(", "$", "url", ")", "&&", "!", "empty", "(", "$", "url", "[", "'route'", "]", ")", ")", "{", "try", "{", "$", "Comet", "=", "\\", "CometPHP", "\\", "Comet", "::", "getInstance", "(", ")", ";", "}", "catch", "(", "\\", "CometPHP", "\\", "Exceptions", "\\", "CometNotBooted", "$", "e", ")", "{", "return", "null", ";", "}", "$", "routeName", "=", "$", "url", "[", "'route'", "]", ";", "unset", "(", "$", "url", "[", "'route'", "]", ")", ";", "$", "generatedUrl", "=", "$", "Comet", "[", "'routeGenerator'", "]", "->", "generate", "(", "$", "routeName", ",", "$", "url", ")", ";", "return", "$", "generatedUrl", ";", "}", "return", "$", "url", ";", "}" ]
base function to return the url for the link method @param mixed url data received from the link method @return string url to pass to href
[ "base", "function", "to", "return", "the", "url", "for", "the", "link", "method" ]
train
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Services/CometPHP/Router.php#L13-L34
hametuha/wpametu
src/WPametu/Assets/Library.php
Library.register_libraries
public function register_libraries() { // Detect Locale $locale = explode( '_', get_locale() ); if ( count( $locale ) === 1 ) { $locale = strtolower( $locale[0] ); } else { $locale = strtolower( $locale[0] ) . '-' . strtoupper( $locale[1] ); } $this->scripts['jquery-ui-datepicker-i18n'] = [ '/assets/js/lib/jquery-ui/ui/i18n/datepicker-' . $locale . '.js', [ 'jquery-ui-datepicker' ], '1.12.1', true, ]; $this->scripts['jquery-ui-timepicker-i18n'] = [ '/assets/js/lib/jquery-ui-timepicker-addon/dist/i18n/jquery-ui-timepicker-' . $locale . '.js', [ 'jquery-ui-timepicker' ], '1.6.3', true, ]; // Register all scripts foreach ( $this->scripts as $handle => list( $src, $deps, $version, $footer ) ) { $src = $this->build_src( $src ); // Google map if ( 'gmap' == $handle ) { $args = [ 'sensor' => 'true' ]; if ( defined( 'WPAMETU_GMAP_KEY' ) ) { $args['key'] = \WPAMETU_GMAP_KEY; } $src = add_query_arg( $args, $src ); } wp_register_script( $handle, $src, $deps, $version, $footer ); $localized = $this->localize( $handle ); if ( ! empty( $localized ) ) { wp_localize_script( $handle, $this->str->hyphen_to_camel( $handle ), $localized ); } } // Register all css foreach ( $this->css as $handle => list( $src, $deps, $version, $media ) ) { $src = $this->build_src( $src ); wp_register_style( $handle, $src, $deps, $version, $media ); } }
php
public function register_libraries() { // Detect Locale $locale = explode( '_', get_locale() ); if ( count( $locale ) === 1 ) { $locale = strtolower( $locale[0] ); } else { $locale = strtolower( $locale[0] ) . '-' . strtoupper( $locale[1] ); } $this->scripts['jquery-ui-datepicker-i18n'] = [ '/assets/js/lib/jquery-ui/ui/i18n/datepicker-' . $locale . '.js', [ 'jquery-ui-datepicker' ], '1.12.1', true, ]; $this->scripts['jquery-ui-timepicker-i18n'] = [ '/assets/js/lib/jquery-ui-timepicker-addon/dist/i18n/jquery-ui-timepicker-' . $locale . '.js', [ 'jquery-ui-timepicker' ], '1.6.3', true, ]; // Register all scripts foreach ( $this->scripts as $handle => list( $src, $deps, $version, $footer ) ) { $src = $this->build_src( $src ); // Google map if ( 'gmap' == $handle ) { $args = [ 'sensor' => 'true' ]; if ( defined( 'WPAMETU_GMAP_KEY' ) ) { $args['key'] = \WPAMETU_GMAP_KEY; } $src = add_query_arg( $args, $src ); } wp_register_script( $handle, $src, $deps, $version, $footer ); $localized = $this->localize( $handle ); if ( ! empty( $localized ) ) { wp_localize_script( $handle, $this->str->hyphen_to_camel( $handle ), $localized ); } } // Register all css foreach ( $this->css as $handle => list( $src, $deps, $version, $media ) ) { $src = $this->build_src( $src ); wp_register_style( $handle, $src, $deps, $version, $media ); } }
[ "public", "function", "register_libraries", "(", ")", "{", "// Detect Locale", "$", "locale", "=", "explode", "(", "'_'", ",", "get_locale", "(", ")", ")", ";", "if", "(", "count", "(", "$", "locale", ")", "===", "1", ")", "{", "$", "locale", "=", "strtolower", "(", "$", "locale", "[", "0", "]", ")", ";", "}", "else", "{", "$", "locale", "=", "strtolower", "(", "$", "locale", "[", "0", "]", ")", ".", "'-'", ".", "strtoupper", "(", "$", "locale", "[", "1", "]", ")", ";", "}", "$", "this", "->", "scripts", "[", "'jquery-ui-datepicker-i18n'", "]", "=", "[", "'/assets/js/lib/jquery-ui/ui/i18n/datepicker-'", ".", "$", "locale", ".", "'.js'", ",", "[", "'jquery-ui-datepicker'", "]", ",", "'1.12.1'", ",", "true", ",", "]", ";", "$", "this", "->", "scripts", "[", "'jquery-ui-timepicker-i18n'", "]", "=", "[", "'/assets/js/lib/jquery-ui-timepicker-addon/dist/i18n/jquery-ui-timepicker-'", ".", "$", "locale", ".", "'.js'", ",", "[", "'jquery-ui-timepicker'", "]", ",", "'1.6.3'", ",", "true", ",", "]", ";", "// Register all scripts", "foreach", "(", "$", "this", "->", "scripts", "as", "$", "handle", "=>", "list", "(", "$", "src", ",", "$", "deps", ",", "$", "version", ",", "$", "footer", ")", ")", "{", "$", "src", "=", "$", "this", "->", "build_src", "(", "$", "src", ")", ";", "// Google map", "if", "(", "'gmap'", "==", "$", "handle", ")", "{", "$", "args", "=", "[", "'sensor'", "=>", "'true'", "]", ";", "if", "(", "defined", "(", "'WPAMETU_GMAP_KEY'", ")", ")", "{", "$", "args", "[", "'key'", "]", "=", "\\", "WPAMETU_GMAP_KEY", ";", "}", "$", "src", "=", "add_query_arg", "(", "$", "args", ",", "$", "src", ")", ";", "}", "wp_register_script", "(", "$", "handle", ",", "$", "src", ",", "$", "deps", ",", "$", "version", ",", "$", "footer", ")", ";", "$", "localized", "=", "$", "this", "->", "localize", "(", "$", "handle", ")", ";", "if", "(", "!", "empty", "(", "$", "localized", ")", ")", "{", "wp_localize_script", "(", "$", "handle", ",", "$", "this", "->", "str", "->", "hyphen_to_camel", "(", "$", "handle", ")", ",", "$", "localized", ")", ";", "}", "}", "// Register all css", "foreach", "(", "$", "this", "->", "css", "as", "$", "handle", "=>", "list", "(", "$", "src", ",", "$", "deps", ",", "$", "version", ",", "$", "media", ")", ")", "{", "$", "src", "=", "$", "this", "->", "build_src", "(", "$", "src", ")", ";", "wp_register_style", "(", "$", "handle", ",", "$", "src", ",", "$", "deps", ",", "$", "version", ",", "$", "media", ")", ";", "}", "}" ]
Register assets
[ "Register", "assets" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Assets/Library.php#L137-L180
hametuha/wpametu
src/WPametu/Assets/Library.php
Library.build_src
private function build_src( $src ) { if ( ! preg_match( '/^(https?:)?\/\//u', $src ) ) { // O.K. This is a library in WPametu! $src = trailingslashit( $this->get_root_uri() ) . ltrim( $src, '/' ); } return $src; }
php
private function build_src( $src ) { if ( ! preg_match( '/^(https?:)?\/\//u', $src ) ) { // O.K. This is a library in WPametu! $src = trailingslashit( $this->get_root_uri() ) . ltrim( $src, '/' ); } return $src; }
[ "private", "function", "build_src", "(", "$", "src", ")", "{", "if", "(", "!", "preg_match", "(", "'/^(https?:)?\\/\\//u'", ",", "$", "src", ")", ")", "{", "// O.K. This is a library in WPametu!", "$", "src", "=", "trailingslashit", "(", "$", "this", "->", "get_root_uri", "(", ")", ")", ".", "ltrim", "(", "$", "src", ",", "'/'", ")", ";", "}", "return", "$", "src", ";", "}" ]
Build URL for library @param string $src @return string
[ "Build", "URL", "for", "library" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Assets/Library.php#L189-L196
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
Dwoo_Template_String.getCachedTemplate
public function getCachedTemplate(Dwoo $dwoo) { if ($this->cacheTime !== null) { $cacheLength = $this->cacheTime; } else { $cacheLength = $dwoo->getCacheTime(); } // file is not cacheable if ($cacheLength === 0) { return false; } $cachedFile = $this->getCacheFilename($dwoo); if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) { // already checked, return cache file return $cachedFile; } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) { // cache is still valid and can be loaded self::$cache['cached'][$this->cacheId] = true; return $cachedFile; } else { // file is cacheable return true; } }
php
public function getCachedTemplate(Dwoo $dwoo) { if ($this->cacheTime !== null) { $cacheLength = $this->cacheTime; } else { $cacheLength = $dwoo->getCacheTime(); } // file is not cacheable if ($cacheLength === 0) { return false; } $cachedFile = $this->getCacheFilename($dwoo); if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) { // already checked, return cache file return $cachedFile; } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) { // cache is still valid and can be loaded self::$cache['cached'][$this->cacheId] = true; return $cachedFile; } else { // file is cacheable return true; } }
[ "public", "function", "getCachedTemplate", "(", "Dwoo", "$", "dwoo", ")", "{", "if", "(", "$", "this", "->", "cacheTime", "!==", "null", ")", "{", "$", "cacheLength", "=", "$", "this", "->", "cacheTime", ";", "}", "else", "{", "$", "cacheLength", "=", "$", "dwoo", "->", "getCacheTime", "(", ")", ";", "}", "// file is not cacheable", "if", "(", "$", "cacheLength", "===", "0", ")", "{", "return", "false", ";", "}", "$", "cachedFile", "=", "$", "this", "->", "getCacheFilename", "(", "$", "dwoo", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "cache", "[", "'cached'", "]", "[", "$", "this", "->", "cacheId", "]", ")", "===", "true", "&&", "file_exists", "(", "$", "cachedFile", ")", ")", "{", "// already checked, return cache file", "return", "$", "cachedFile", ";", "}", "elseif", "(", "$", "this", "->", "compilationEnforced", "!==", "true", "&&", "file_exists", "(", "$", "cachedFile", ")", "&&", "(", "$", "cacheLength", "===", "-", "1", "||", "filemtime", "(", "$", "cachedFile", ")", ">", "(", "$", "_SERVER", "[", "'REQUEST_TIME'", "]", "-", "$", "cacheLength", ")", ")", "&&", "$", "this", "->", "isValidCompiledFile", "(", "$", "this", "->", "getCompiledFilename", "(", "$", "dwoo", ")", ")", ")", "{", "// cache is still valid and can be loaded", "self", "::", "$", "cache", "[", "'cached'", "]", "[", "$", "this", "->", "cacheId", "]", "=", "true", ";", "return", "$", "cachedFile", ";", "}", "else", "{", "// file is cacheable", "return", "true", ";", "}", "}" ]
returns the cached template output file name, true if it's cache-able but not cached or false if it's not cached @param Dwoo $dwoo the dwoo instance that requests it @return string|bool
[ "returns", "the", "cached", "template", "output", "file", "name", "true", "if", "it", "s", "cache", "-", "able", "but", "not", "cached", "or", "false", "if", "it", "s", "not", "cached" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L248-L274
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
Dwoo_Template_String.cache
public function cache(Dwoo $dwoo, $output) { $cacheDir = $dwoo->getCacheDir(); $cachedFile = $this->getCacheFilename($dwoo); // the code below is courtesy of Rasmus Schultz, // thanks for his help on avoiding concurency issues $temp = tempnam($cacheDir, 'temp'); if (!($file = @fopen($temp, 'wb'))) { $temp = $cacheDir . uniqid('temp'); if (!($file = @fopen($temp, 'wb'))) { trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING); return false; } } fwrite($file, $output); fclose($file); $this->makeDirectory(dirname($cachedFile), $cacheDir); if (!@rename($temp, $cachedFile)) { @unlink($cachedFile); @rename($temp, $cachedFile); } if ($this->chmod !== null) { chmod($cachedFile, $this->chmod); } self::$cache['cached'][$this->cacheId] = true; return $cachedFile; }
php
public function cache(Dwoo $dwoo, $output) { $cacheDir = $dwoo->getCacheDir(); $cachedFile = $this->getCacheFilename($dwoo); // the code below is courtesy of Rasmus Schultz, // thanks for his help on avoiding concurency issues $temp = tempnam($cacheDir, 'temp'); if (!($file = @fopen($temp, 'wb'))) { $temp = $cacheDir . uniqid('temp'); if (!($file = @fopen($temp, 'wb'))) { trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING); return false; } } fwrite($file, $output); fclose($file); $this->makeDirectory(dirname($cachedFile), $cacheDir); if (!@rename($temp, $cachedFile)) { @unlink($cachedFile); @rename($temp, $cachedFile); } if ($this->chmod !== null) { chmod($cachedFile, $this->chmod); } self::$cache['cached'][$this->cacheId] = true; return $cachedFile; }
[ "public", "function", "cache", "(", "Dwoo", "$", "dwoo", ",", "$", "output", ")", "{", "$", "cacheDir", "=", "$", "dwoo", "->", "getCacheDir", "(", ")", ";", "$", "cachedFile", "=", "$", "this", "->", "getCacheFilename", "(", "$", "dwoo", ")", ";", "// the code below is courtesy of Rasmus Schultz,", "// thanks for his help on avoiding concurency issues", "$", "temp", "=", "tempnam", "(", "$", "cacheDir", ",", "'temp'", ")", ";", "if", "(", "!", "(", "$", "file", "=", "@", "fopen", "(", "$", "temp", ",", "'wb'", ")", ")", ")", "{", "$", "temp", "=", "$", "cacheDir", ".", "uniqid", "(", "'temp'", ")", ";", "if", "(", "!", "(", "$", "file", "=", "@", "fopen", "(", "$", "temp", ",", "'wb'", ")", ")", ")", "{", "trigger_error", "(", "'Error writing temporary file \\''", ".", "$", "temp", ".", "'\\''", ",", "E_USER_WARNING", ")", ";", "return", "false", ";", "}", "}", "fwrite", "(", "$", "file", ",", "$", "output", ")", ";", "fclose", "(", "$", "file", ")", ";", "$", "this", "->", "makeDirectory", "(", "dirname", "(", "$", "cachedFile", ")", ",", "$", "cacheDir", ")", ";", "if", "(", "!", "@", "rename", "(", "$", "temp", ",", "$", "cachedFile", ")", ")", "{", "@", "unlink", "(", "$", "cachedFile", ")", ";", "@", "rename", "(", "$", "temp", ",", "$", "cachedFile", ")", ";", "}", "if", "(", "$", "this", "->", "chmod", "!==", "null", ")", "{", "chmod", "(", "$", "cachedFile", ",", "$", "this", "->", "chmod", ")", ";", "}", "self", "::", "$", "cache", "[", "'cached'", "]", "[", "$", "this", "->", "cacheId", "]", "=", "true", ";", "return", "$", "cachedFile", ";", "}" ]
caches the provided output into the cache file @param Dwoo $dwoo the dwoo instance that requests it @param string $output the template output @return mixed full path of the cached file or false upon failure
[ "caches", "the", "provided", "output", "into", "the", "cache", "file" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L283-L315
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
Dwoo_Template_String.clearCache
public function clearCache(Dwoo $dwoo, $olderThan = -1) { $cachedFile = $this->getCacheFilename($dwoo); return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile)); }
php
public function clearCache(Dwoo $dwoo, $olderThan = -1) { $cachedFile = $this->getCacheFilename($dwoo); return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile)); }
[ "public", "function", "clearCache", "(", "Dwoo", "$", "dwoo", ",", "$", "olderThan", "=", "-", "1", ")", "{", "$", "cachedFile", "=", "$", "this", "->", "getCacheFilename", "(", "$", "dwoo", ")", ";", "return", "!", "file_exists", "(", "$", "cachedFile", ")", "||", "(", "filectime", "(", "$", "cachedFile", ")", "<", "(", "time", "(", ")", "-", "$", "olderThan", ")", "&&", "unlink", "(", "$", "cachedFile", ")", ")", ";", "}" ]
clears the cached template if it's older than the given time @param Dwoo $dwoo the dwoo instance that was used to cache that template @param int $olderThan minimum time (in seconds) required for the cache to be cleared @return bool true if the cache was not present or if it was deleted, false if it remains there
[ "clears", "the", "cached", "template", "if", "it", "s", "older", "than", "the", "given", "time" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L324-L329
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
Dwoo_Template_String.getCompiledTemplate
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null) { $compiledFile = $this->getCompiledFilename($dwoo); if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) { // already checked, return compiled file } elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) { // template is compiled self::$cache['compiled'][$this->compileId] = true; } else { // compiles the template $this->compilationEnforced = false; if ($compiler === null) { $compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName()); if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); } else { $compiler = call_user_func($compiler); } } $this->compiler = $compiler; $compiler->setCustomPlugins($dwoo->getCustomPlugins()); $compiler->setSecurityPolicy($dwoo->getSecurityPolicy()); $this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir()); file_put_contents($compiledFile, $compiler->compile($dwoo, $this)); if ($this->chmod !== null) { chmod($compiledFile, $this->chmod); } self::$cache['compiled'][$this->compileId] = true; } return $compiledFile; }
php
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null) { $compiledFile = $this->getCompiledFilename($dwoo); if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) { // already checked, return compiled file } elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) { // template is compiled self::$cache['compiled'][$this->compileId] = true; } else { // compiles the template $this->compilationEnforced = false; if ($compiler === null) { $compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName()); if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); } else { $compiler = call_user_func($compiler); } } $this->compiler = $compiler; $compiler->setCustomPlugins($dwoo->getCustomPlugins()); $compiler->setSecurityPolicy($dwoo->getSecurityPolicy()); $this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir()); file_put_contents($compiledFile, $compiler->compile($dwoo, $this)); if ($this->chmod !== null) { chmod($compiledFile, $this->chmod); } self::$cache['compiled'][$this->compileId] = true; } return $compiledFile; }
[ "public", "function", "getCompiledTemplate", "(", "Dwoo", "$", "dwoo", ",", "Dwoo_ICompiler", "$", "compiler", "=", "null", ")", "{", "$", "compiledFile", "=", "$", "this", "->", "getCompiledFilename", "(", "$", "dwoo", ")", ";", "if", "(", "$", "this", "->", "compilationEnforced", "!==", "true", "&&", "isset", "(", "self", "::", "$", "cache", "[", "'compiled'", "]", "[", "$", "this", "->", "compileId", "]", ")", "===", "true", ")", "{", "// already checked, return compiled file", "}", "elseif", "(", "$", "this", "->", "compilationEnforced", "!==", "true", "&&", "$", "this", "->", "isValidCompiledFile", "(", "$", "compiledFile", ")", ")", "{", "// template is compiled", "self", "::", "$", "cache", "[", "'compiled'", "]", "[", "$", "this", "->", "compileId", "]", "=", "true", ";", "}", "else", "{", "// compiles the template", "$", "this", "->", "compilationEnforced", "=", "false", ";", "if", "(", "$", "compiler", "===", "null", ")", "{", "$", "compiler", "=", "$", "dwoo", "->", "getDefaultCompilerFactory", "(", "$", "this", "->", "getResourceName", "(", ")", ")", ";", "if", "(", "$", "compiler", "===", "null", "||", "$", "compiler", "===", "array", "(", "'Dwoo_Compiler'", ",", "'compilerFactory'", ")", ")", "{", "if", "(", "class_exists", "(", "'Dwoo_Compiler'", ",", "false", ")", "===", "false", ")", "{", "include", "DWOO_DIRECTORY", ".", "'Dwoo/Compiler.php'", ";", "}", "$", "compiler", "=", "Dwoo_Compiler", "::", "compilerFactory", "(", ")", ";", "}", "else", "{", "$", "compiler", "=", "call_user_func", "(", "$", "compiler", ")", ";", "}", "}", "$", "this", "->", "compiler", "=", "$", "compiler", ";", "$", "compiler", "->", "setCustomPlugins", "(", "$", "dwoo", "->", "getCustomPlugins", "(", ")", ")", ";", "$", "compiler", "->", "setSecurityPolicy", "(", "$", "dwoo", "->", "getSecurityPolicy", "(", ")", ")", ";", "$", "this", "->", "makeDirectory", "(", "dirname", "(", "$", "compiledFile", ")", ",", "$", "dwoo", "->", "getCompileDir", "(", ")", ")", ";", "file_put_contents", "(", "$", "compiledFile", ",", "$", "compiler", "->", "compile", "(", "$", "dwoo", ",", "$", "this", ")", ")", ";", "if", "(", "$", "this", "->", "chmod", "!==", "null", ")", "{", "chmod", "(", "$", "compiledFile", ",", "$", "this", "->", "chmod", ")", ";", "}", "self", "::", "$", "cache", "[", "'compiled'", "]", "[", "$", "this", "->", "compileId", "]", "=", "true", ";", "}", "return", "$", "compiledFile", ";", "}" ]
returns the compiled template file name @param Dwoo $dwoo the dwoo instance that requests it @param Dwoo_ICompiler $compiler the compiler that must be used @return string
[ "returns", "the", "compiled", "template", "file", "name" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L338-L378