repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
humbug/php-scoper | src/PhpParser/NodeVisitor/ConstStmtReplacer.php | ConstStmtReplacer.enterNode | public function enterNode(Node $node): Node
{
if (false === ($node instanceof Const_)) {
return $node;
}
foreach ($node->consts as $constant) {
/** @var Node\Const_ $constant */
$resolvedConstantName = $this->nameResolver->resolveName(
new... | php | public function enterNode(Node $node): Node
{
if (false === ($node instanceof Const_)) {
return $node;
}
foreach ($node->consts as $constant) {
/** @var Node\Const_ $constant */
$resolvedConstantName = $this->nameResolver->resolveName(
new... | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
":",
"Node",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"node",
"instanceof",
"Const_",
")",
")",
"{",
"return",
"$",
"node",
";",
"}",
"foreach",
"(",
"$",
"node",
"->",
"consts",
"a... | {@inheritdoc}
@param Const_ $node | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/humbug/php-scoper/blob/5e099a8346db2f14473ed884670d6ff34886ca9e/src/PhpParser/NodeVisitor/ConstStmtReplacer.php#L64-L105 |
humbug/php-scoper | src/Scoper/Symfony/XmlScoper.php | XmlScoper.scope | public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string
{
if (1 !== preg_match(self::FILE_PATH_PATTERN, $filePath)) {
return $this->decoratedScoper->scope(...func_get_args());
}
$contents = $this->scopeClasses($con... | php | public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string
{
if (1 !== preg_match(self::FILE_PATH_PATTERN, $filePath)) {
return $this->decoratedScoper->scope(...func_get_args());
}
$contents = $this->scopeClasses($con... | [
"public",
"function",
"scope",
"(",
"string",
"$",
"filePath",
",",
"string",
"$",
"contents",
",",
"string",
"$",
"prefix",
",",
"array",
"$",
"patchers",
",",
"Whitelist",
"$",
"whitelist",
")",
":",
"string",
"{",
"if",
"(",
"1",
"!==",
"preg_match",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/humbug/php-scoper/blob/5e099a8346db2f14473ed884670d6ff34886ca9e/src/Scoper/Symfony/XmlScoper.php#L44-L54 |
antonioribeiro/health | src/Checkers/SecurityChecker.php | SecurityChecker.check | public function check()
{
$checker = new SensioLabsSecurityChecker();
$alerts = $checker->check(base_path('composer.lock'));
if (count($alerts) == 0) {
return $this->makeHealthyResult();
}
$problems = collect($alerts)
->keys()
->implode(... | php | public function check()
{
$checker = new SensioLabsSecurityChecker();
$alerts = $checker->check(base_path('composer.lock'));
if (count($alerts) == 0) {
return $this->makeHealthyResult();
}
$problems = collect($alerts)
->keys()
->implode(... | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"checker",
"=",
"new",
"SensioLabsSecurityChecker",
"(",
")",
";",
"$",
"alerts",
"=",
"$",
"checker",
"->",
"check",
"(",
"base_path",
"(",
"'composer.lock'",
")",
")",
";",
"if",
"(",
"count",
"(",
"... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/SecurityChecker.php#L15-L33 |
antonioribeiro/health | src/Checkers/Writable.php | Writable.check | public function check()
{
foreach ($this->target->paths as $path) {
if (! $this->getFilesystem()->isWritable($path)) {
return $this->makeResult(
false,
sprintf($this->target->getErrorMessage(), $path)
);
}
... | php | public function check()
{
foreach ($this->target->paths as $path) {
if (! $this->getFilesystem()->isWritable($path)) {
return $this->makeResult(
false,
sprintf($this->target->getErrorMessage(), $path)
);
}
... | [
"public",
"function",
"check",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"target",
"->",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getFilesystem",
"(",
")",
"->",
"isWritable",
"(",
"$",
"path",
")",
")",
"... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Writable.php#L17-L29 |
antonioribeiro/health | src/Support/Traits/ImportProperties.php | ImportProperties.importProperties | public function importProperties($data)
{
$data->each(function ($value, $key) {
$key = camel_case($key);
if (! property_exists($this, $key)) {
$this->$key = $value;
}
});
} | php | public function importProperties($data)
{
$data->each(function ($value, $key) {
$key = camel_case($key);
if (! property_exists($this, $key)) {
$this->$key = $value;
}
});
} | [
"public",
"function",
"importProperties",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"->",
"each",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"camel_case",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"property_exis... | Import all collection items to object properties.
@param $data | [
"Import",
"all",
"collection",
"items",
"to",
"object",
"properties",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Traits/ImportProperties.php#L12-L21 |
antonioribeiro/health | src/Checkers/Expression.php | Expression.check | public function check()
{
return $this->expressionIsOk()
? $this->makeHealthyResult()
: $this->makeResult(false, $this->target->getErrorMessage());
} | php | public function check()
{
return $this->expressionIsOk()
? $this->makeHealthyResult()
: $this->makeResult(false, $this->target->getErrorMessage());
} | [
"public",
"function",
"check",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"expressionIsOk",
"(",
")",
"?",
"$",
"this",
"->",
"makeHealthyResult",
"(",
")",
":",
"$",
"this",
"->",
"makeResult",
"(",
"false",
",",
"$",
"this",
"->",
"target",
"->",
... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Expression.php#L14-L19 |
antonioribeiro/health | src/Checkers/Base.php | Base.checkAndStoreTime | protected function checkAndStoreTime()
{
Timer::start();
$result = $this->check();
$result->elapsedTime = Timer::stop();
return $result;
} | php | protected function checkAndStoreTime()
{
Timer::start();
$result = $this->check();
$result->elapsedTime = Timer::stop();
return $result;
} | [
"protected",
"function",
"checkAndStoreTime",
"(",
")",
"{",
"Timer",
"::",
"start",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"check",
"(",
")",
";",
"$",
"result",
"->",
"elapsedTime",
"=",
"Timer",
"::",
"stop",
"(",
")",
";",
"return"... | Check target and store elapsed time. | [
"Check",
"target",
"and",
"store",
"elapsed",
"time",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Base.php#L22-L31 |
antonioribeiro/health | src/Checkers/Base.php | Base.makeDir | protected function makeDir($fileName)
{
$dir = dirname($fileName);
if (! file_exists($dir)) {
mkdir($dir, 0775, true);
}
} | php | protected function makeDir($fileName)
{
$dir = dirname($fileName);
if (! file_exists($dir)) {
mkdir($dir, 0775, true);
}
} | [
"protected",
"function",
"makeDir",
"(",
"$",
"fileName",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"fileName",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"mkdir",
"(",
"$",
"dir",
",",
"0775",
",",
"true",
")"... | Create base directory for files.
@param $fileName | [
"Create",
"base",
"directory",
"for",
"files",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Base.php#L38-L45 |
antonioribeiro/health | src/Checkers/Base.php | Base.load | public function load()
{
if (! file_exists($file = $this->getFileName())) {
return collect();
}
return collect(json_decode(file_get_contents($file), true));
} | php | public function load()
{
if (! file_exists($file = $this->getFileName())) {
return collect();
}
return collect(json_decode(file_get_contents($file), true));
} | [
"public",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
")",
"{",
"return",
"collect",
"(",
")",
";",
"}",
"return",
"collect",
"(",
"json_decode",
"(",
"fi... | Load cache.
@return \Illuminate\Support\Collection | [
"Load",
"cache",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Base.php#L144-L151 |
antonioribeiro/health | src/Checkers/Base.php | Base.persist | public function persist($data = null)
{
if (is_null($data)) {
$data = $this->database->toArray();
}
if (! is_array($data)) {
$data = $data->toArray();
}
$this->makeDir($this->getFileName());
file_put_contents($this->getFileName(), json_encod... | php | public function persist($data = null)
{
if (is_null($data)) {
$data = $this->database->toArray();
}
if (! is_array($data)) {
$data = $data->toArray();
}
$this->makeDir($this->getFileName());
file_put_contents($this->getFileName(), json_encod... | [
"public",
"function",
"persist",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"database",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"... | Persist to database cache file.
@param $data | [
"Persist",
"to",
"database",
"cache",
"file",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Base.php#L158-L171 |
antonioribeiro/health | src/Checkers/DirectoryAndFilePresence.php | DirectoryAndFilePresence.check | public function check()
{
list($messages, $result) = $this->checkPresence();
if ($result->count() == 0) {
return $this->makeHealthyResult();
}
return $this->makeResult(
false,
$this->target->getErrorMessage().' - '.implode(' ', $messages)
... | php | public function check()
{
list($messages, $result) = $this->checkPresence();
if ($result->count() == 0) {
return $this->makeHealthyResult();
}
return $this->makeResult(
false,
$this->target->getErrorMessage().' - '.implode(' ', $messages)
... | [
"public",
"function",
"check",
"(",
")",
"{",
"list",
"(",
"$",
"messages",
",",
"$",
"result",
")",
"=",
"$",
"this",
"->",
"checkPresence",
"(",
")",
";",
"if",
"(",
"$",
"result",
"->",
"count",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
... | Checker.
@return Result | [
"Checker",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/DirectoryAndFilePresence.php#L34-L46 |
antonioribeiro/health | src/Checkers/DirectoryAndFilePresence.php | DirectoryAndFilePresence.checkPresence | protected function checkPresence()
{
$messages = [];
$result = collect($this->getFiles())
->map(function ($files, $type) use (&$messages) {
$isGood = true;
$files = collect($files);
foreach ($files as $file) {
if (! i... | php | protected function checkPresence()
{
$messages = [];
$result = collect($this->getFiles())
->map(function ($files, $type) use (&$messages) {
$isGood = true;
$files = collect($files);
foreach ($files as $file) {
if (! i... | [
"protected",
"function",
"checkPresence",
"(",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"collect",
"(",
"$",
"this",
"->",
"getFiles",
"(",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"files",
",",
"$",
"type",
")",
... | Check file or dir presence.
@return static | [
"Check",
"file",
"or",
"dir",
"presence",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/DirectoryAndFilePresence.php#L53-L81 |
antonioribeiro/health | src/Checkers/DirectoryAndFilePresence.php | DirectoryAndFilePresence.getCheckers | public function getCheckers($checker)
{
switch ($checker) {
case static::FILE_EXISTS:
return [$this->buildFileExistsChecker()];
case static::FILE_DOES_NOT_EXISTS:
return [$this->buildFileDoesNotExistsChecker()];
case static::DIRECTORY_EXIST... | php | public function getCheckers($checker)
{
switch ($checker) {
case static::FILE_EXISTS:
return [$this->buildFileExistsChecker()];
case static::FILE_DOES_NOT_EXISTS:
return [$this->buildFileDoesNotExistsChecker()];
case static::DIRECTORY_EXIST... | [
"public",
"function",
"getCheckers",
"(",
"$",
"checker",
")",
"{",
"switch",
"(",
"$",
"checker",
")",
"{",
"case",
"static",
"::",
"FILE_EXISTS",
":",
"return",
"[",
"$",
"this",
"->",
"buildFileExistsChecker",
"(",
")",
"]",
";",
"case",
"static",
"::... | Get checkers.
@return array | [
"Get",
"checkers",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/DirectoryAndFilePresence.php#L134-L154 |
antonioribeiro/health | src/Checkers/Process.php | Process.check | public function check()
{
$message = $this->checkMinMax($this->getProcessesRunningCount());
if (! empty($message)) {
return $this->makeResult(false, $message);
}
return $this->makeHealthyResult();
} | php | public function check()
{
$message = $this->checkMinMax($this->getProcessesRunningCount());
if (! empty($message)) {
return $this->makeResult(false, $message);
}
return $this->makeHealthyResult();
} | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"checkMinMax",
"(",
"$",
"this",
"->",
"getProcessesRunningCount",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"return",
"$",
... | Check target.
@return Result | [
"Check",
"target",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Process.php#L19-L28 |
antonioribeiro/health | src/Checkers/ServerLoad.php | ServerLoad.check | public function check()
{
$current = $this->getCurrentUptime();
$inTrouble =
$current['load_1'] > $this->target->maxLoad['load_1'] ||
$current['load_5'] > $this->target->maxLoad['load_5'] ||
$current['load_15'] > $this->target->maxLoad['load_15'];
return... | php | public function check()
{
$current = $this->getCurrentUptime();
$inTrouble =
$current['load_1'] > $this->target->maxLoad['load_1'] ||
$current['load_5'] > $this->target->maxLoad['load_5'] ||
$current['load_15'] > $this->target->maxLoad['load_15'];
return... | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"getCurrentUptime",
"(",
")",
";",
"$",
"inTrouble",
"=",
"$",
"current",
"[",
"'load_1'",
"]",
">",
"$",
"this",
"->",
"target",
"->",
"maxLoad",
"[",
"'load_1'",
... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/ServerLoad.php#L14-L24 |
antonioribeiro/health | src/Support/Traits/Database.php | Database.__load | public function __load()
{
if (! file_exists($file = $this->getDatabaseFileName())) {
return collect();
}
return collect(json_decode(file_get_contents($file), true));
} | php | public function __load()
{
if (! file_exists($file = $this->getDatabaseFileName())) {
return collect();
}
return collect(json_decode(file_get_contents($file), true));
} | [
"public",
"function",
"__load",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"getDatabaseFileName",
"(",
")",
")",
")",
"{",
"return",
"collect",
"(",
")",
";",
"}",
"return",
"collect",
"(",
"json_decode",
... | Load cache.
@return \Illuminate\Support\Collection | [
"Load",
"cache",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Traits/Database.php#L21-L28 |
antonioribeiro/health | src/Checkers/NotInDebugMode.php | NotInDebugMode.executeUptimeCommand | private function executeUptimeCommand()
{
$error = exec($this->resource->command, $system_string, $output);
if ($output !== 0) {
throw new DomainException((string) $error);
}
return (! is_array($system_string) || empty($system_string))
? ''
: $sy... | php | private function executeUptimeCommand()
{
$error = exec($this->resource->command, $system_string, $output);
if ($output !== 0) {
throw new DomainException((string) $error);
}
return (! is_array($system_string) || empty($system_string))
? ''
: $sy... | [
"private",
"function",
"executeUptimeCommand",
"(",
")",
"{",
"$",
"error",
"=",
"exec",
"(",
"$",
"this",
"->",
"resource",
"->",
"command",
",",
"$",
"system_string",
",",
"$",
"output",
")",
";",
"if",
"(",
"$",
"output",
"!==",
"0",
")",
"{",
"th... | Execute command to get an uptime string.
@return mixed|string
@throws Exception | [
"Execute",
"command",
"to",
"get",
"an",
"uptime",
"string",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/NotInDebugMode.php#L38-L49 |
antonioribeiro/health | src/Checkers/NotInDebugMode.php | NotInDebugMode.normalizeMatches | protected function normalizeMatches($matches)
{
return collect($matches)
->filter(function ($item, $key) {
return ! is_numeric($key);
})
->map(function ($item, $key) {
$return = $item[0];
if (starts_with($key, 'load')) {
... | php | protected function normalizeMatches($matches)
{
return collect($matches)
->filter(function ($item, $key) {
return ! is_numeric($key);
})
->map(function ($item, $key) {
$return = $item[0];
if (starts_with($key, 'load')) {
... | [
"protected",
"function",
"normalizeMatches",
"(",
"$",
"matches",
")",
"{",
"return",
"collect",
"(",
"$",
"matches",
")",
"->",
"filter",
"(",
"function",
"(",
"$",
"item",
",",
"$",
"key",
")",
"{",
"return",
"!",
"is_numeric",
"(",
"$",
"key",
")",
... | Normalize uptime matches.
@param $matches
@return \Illuminate\Support\Collection | [
"Normalize",
"uptime",
"matches",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/NotInDebugMode.php#L68-L88 |
antonioribeiro/health | src/Checkers/NotInDebugMode.php | NotInDebugMode.parseUptimeString | protected function parseUptimeString($system_string)
{
$matches = [];
preg_match(
$this->resource['regex'],
$system_string,
$matches,
PREG_OFFSET_CAPTURE
);
$matches = $this->normalizeMatches($matches);
$matches['uptime_strin... | php | protected function parseUptimeString($system_string)
{
$matches = [];
preg_match(
$this->resource['regex'],
$system_string,
$matches,
PREG_OFFSET_CAPTURE
);
$matches = $this->normalizeMatches($matches);
$matches['uptime_strin... | [
"protected",
"function",
"parseUptimeString",
"(",
"$",
"system_string",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"preg_match",
"(",
"$",
"this",
"->",
"resource",
"[",
"'regex'",
"]",
",",
"$",
"system_string",
",",
"$",
"matches",
",",
"PREG_OFFSET_... | Parse the uptime string.
@param $system_string
@return array | [
"Parse",
"the",
"uptime",
"string",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/NotInDebugMode.php#L96-L112 |
antonioribeiro/health | src/Checkers/NotInDebugMode.php | NotInDebugMode.uptimeInSeconds | protected function uptimeInSeconds($date)
{
return
(isset($date['up_days']) ? $date['up_days'] * 24 * 60 : 0) +
(isset($date['up_hours']) ? $date['up_hours'] * 60 : 0) +
(isset($date['up_minutes']) ? $date['up_minutes'] : 0);
} | php | protected function uptimeInSeconds($date)
{
return
(isset($date['up_days']) ? $date['up_days'] * 24 * 60 : 0) +
(isset($date['up_hours']) ? $date['up_hours'] * 60 : 0) +
(isset($date['up_minutes']) ? $date['up_minutes'] : 0);
} | [
"protected",
"function",
"uptimeInSeconds",
"(",
"$",
"date",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"date",
"[",
"'up_days'",
"]",
")",
"?",
"$",
"date",
"[",
"'up_days'",
"]",
"*",
"24",
"*",
"60",
":",
"0",
")",
"+",
"(",
"isset",
"(",
"$... | Convert uptime to seconds.
@param $date
@return int | [
"Convert",
"uptime",
"to",
"seconds",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/NotInDebugMode.php#L120-L126 |
antonioribeiro/health | src/Checkers/NotInDebugMode.php | NotInDebugMode.makeMessage | protected function makeMessage($current, $saved = null)
{
$current = $this->toUptimeString($current);
$saved = $this->toUptimeString($saved);
return sprintf($this->target->getErrorMessage(), $current, $saved);
} | php | protected function makeMessage($current, $saved = null)
{
$current = $this->toUptimeString($current);
$saved = $this->toUptimeString($saved);
return sprintf($this->target->getErrorMessage(), $current, $saved);
} | [
"protected",
"function",
"makeMessage",
"(",
"$",
"current",
",",
"$",
"saved",
"=",
"null",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"toUptimeString",
"(",
"$",
"current",
")",
";",
"$",
"saved",
"=",
"$",
"this",
"->",
"toUptimeString",
"(",... | Make uptime message.
@param $current
@param $saved
@return string | [
"Make",
"uptime",
"message",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/NotInDebugMode.php#L135-L142 |
antonioribeiro/health | src/Checkers/NotInDebugMode.php | NotInDebugMode.toUptimeString | public function toUptimeString($uptime)
{
return (string) CarbonInterval::days(
isset($uptime['up_days']) ? $uptime['up_days'] : 0
)
->hours(isset($uptime['up_hours']) ? $uptime['up_hours'] : 0)
->minutes(isset($uptime['up_minutes']) ? $uptime['up_minutes'] : 0);
... | php | public function toUptimeString($uptime)
{
return (string) CarbonInterval::days(
isset($uptime['up_days']) ? $uptime['up_days'] : 0
)
->hours(isset($uptime['up_hours']) ? $uptime['up_hours'] : 0)
->minutes(isset($uptime['up_minutes']) ? $uptime['up_minutes'] : 0);
... | [
"public",
"function",
"toUptimeString",
"(",
"$",
"uptime",
")",
"{",
"return",
"(",
"string",
")",
"CarbonInterval",
"::",
"days",
"(",
"isset",
"(",
"$",
"uptime",
"[",
"'up_days'",
"]",
")",
"?",
"$",
"uptime",
"[",
"'up_days'",
"]",
":",
"0",
")",
... | Convert uptime to human readable string.
@param $uptime
@return string | [
"Convert",
"uptime",
"to",
"human",
"readable",
"string",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/NotInDebugMode.php#L150-L157 |
antonioribeiro/health | src/Checkers/Http.php | Http.check | public function check()
{
try {
$health = [];
foreach ($this->getResourceUrlArray() as $url) {
list($healthy, $message) = $this->checkWebPage(
$this->makeUrlWithScheme($url, $this->secure),
$this->secure
);
... | php | public function check()
{
try {
$health = [];
foreach ($this->getResourceUrlArray() as $url) {
list($healthy, $message) = $this->checkWebPage(
$this->makeUrlWithScheme($url, $this->secure),
$this->secure
);
... | [
"public",
"function",
"check",
"(",
")",
"{",
"try",
"{",
"$",
"health",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getResourceUrlArray",
"(",
")",
"as",
"$",
"url",
")",
"{",
"list",
"(",
"$",
"healthy",
",",
"$",
"message",
")",
"=... | HTTP Checker.
@return Result | [
"HTTP",
"Checker",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Http.php#L37-L59 |
antonioribeiro/health | src/Checkers/Http.php | Http.getResourceUrlArray | private function getResourceUrlArray()
{
if (is_a($this->target->urls, Collection::class)) {
return $this->target->urls->toArray();
}
return (array) $this->target->urls;
} | php | private function getResourceUrlArray()
{
if (is_a($this->target->urls, Collection::class)) {
return $this->target->urls->toArray();
}
return (array) $this->target->urls;
} | [
"private",
"function",
"getResourceUrlArray",
"(",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"this",
"->",
"target",
"->",
"urls",
",",
"Collection",
"::",
"class",
")",
")",
"{",
"return",
"$",
"this",
"->",
"target",
"->",
"urls",
"->",
"toArray",
"(",
... | Get array of resource urls.
@return array | [
"Get",
"array",
"of",
"resource",
"urls",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Http.php#L66-L73 |
antonioribeiro/health | src/Checkers/Http.php | Http.checkWebPage | private function checkWebPage($url, $ssl = false)
{
$success = $this->requestSuccessful($url, $ssl);
return [$success, $success ? '' : $this->getErrorMessage()];
} | php | private function checkWebPage($url, $ssl = false)
{
$success = $this->requestSuccessful($url, $ssl);
return [$success, $success ? '' : $this->getErrorMessage()];
} | [
"private",
"function",
"checkWebPage",
"(",
"$",
"url",
",",
"$",
"ssl",
"=",
"false",
")",
"{",
"$",
"success",
"=",
"$",
"this",
"->",
"requestSuccessful",
"(",
"$",
"url",
",",
"$",
"ssl",
")",
";",
"return",
"[",
"$",
"success",
",",
"$",
"succ... | Check web pages.
@param $url
@param bool $ssl
@return mixed | [
"Check",
"web",
"pages",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Http.php#L82-L87 |
antonioribeiro/health | src/Checkers/Http.php | Http.fetchResponse | private function fetchResponse($url, $ssl)
{
$this->url = $url;
return (new Guzzle())->request(
'GET',
$this->url,
$this->getConnectionOptions($ssl)
);
} | php | private function fetchResponse($url, $ssl)
{
$this->url = $url;
return (new Guzzle())->request(
'GET',
$this->url,
$this->getConnectionOptions($ssl)
);
} | [
"private",
"function",
"fetchResponse",
"(",
"$",
"url",
",",
"$",
"ssl",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"(",
"new",
"Guzzle",
"(",
")",
")",
"->",
"request",
"(",
"'GET'",
",",
"$",
"this",
"->",
"url",
",",
... | Send an http request and fetch the response.
@param $url
@param $ssl
@return mixed|\Psr\Http\Message\ResponseInterface
@throws \GuzzleHttp\Exception\GuzzleException | [
"Send",
"an",
"http",
"request",
"and",
"fetch",
"the",
"response",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Http.php#L97-L106 |
antonioribeiro/health | src/Checkers/Http.php | Http.getErrorMessage | private function getErrorMessage()
{
$message = $this->target->resource->timeoutMessage;
return sprintf(
$message,
$this->url,
$this->totalTime,
$this->getRoundtripTimeout()
);
} | php | private function getErrorMessage()
{
$message = $this->target->resource->timeoutMessage;
return sprintf(
$message,
$this->url,
$this->totalTime,
$this->getRoundtripTimeout()
);
} | [
"private",
"function",
"getErrorMessage",
"(",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"target",
"->",
"resource",
"->",
"timeoutMessage",
";",
"return",
"sprintf",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"url",
",",
"$",
"this",
"->",
"... | Get the error message.
@return string | [
"Get",
"the",
"error",
"message",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Http.php#L129-L139 |
antonioribeiro/health | src/Checkers/Http.php | Http.requestSuccessful | private function requestSuccessful($url, $ssl)
{
return
$this->fetchResponse($url, $ssl)->getStatusCode() == 200 &&
! $this->requestTimedout();
} | php | private function requestSuccessful($url, $ssl)
{
return
$this->fetchResponse($url, $ssl)->getStatusCode() == 200 &&
! $this->requestTimedout();
} | [
"private",
"function",
"requestSuccessful",
"(",
"$",
"url",
",",
"$",
"ssl",
")",
"{",
"return",
"$",
"this",
"->",
"fetchResponse",
"(",
"$",
"url",
",",
"$",
"ssl",
")",
"->",
"getStatusCode",
"(",
")",
"==",
"200",
"&&",
"!",
"$",
"this",
"->",
... | Send a request and get the result.
@param $url
@param $ssl
@return bool
@internal param $response | [
"Send",
"a",
"request",
"and",
"get",
"the",
"result",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Http.php#L197-L202 |
antonioribeiro/health | src/Support/Resource.php | Resource.factory | public static function factory(Collection $data)
{
$instance = new static();
$instance->id = (string) Uuid::uuid4();
$instance->name = $data['name'];
$instance->slug = str_slug($data['name']);
$instance->graphEnabled = isset($data['graph_enabled'])
? $data['gr... | php | public static function factory(Collection $data)
{
$instance = new static();
$instance->id = (string) Uuid::uuid4();
$instance->name = $data['name'];
$instance->slug = str_slug($data['name']);
$instance->graphEnabled = isset($data['graph_enabled'])
? $data['gr... | [
"public",
"static",
"function",
"factory",
"(",
"Collection",
"$",
"data",
")",
"{",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"$",
"instance",
"->",
"id",
"=",
"(",
"string",
")",
"Uuid",
"::",
"uuid4",
"(",
")",
";",
"$",
"instance",
... | Resource factory.
@param Collection $data
@return resource
@throws \Exception | [
"Resource",
"factory",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Resource.php#L93-L131 |
antonioribeiro/health | src/Support/Resource.php | Resource.instantiateTargets | public function instantiateTargets(Collection $targets)
{
if ($targets->isEmpty()) {
return collect([Target::factory($this, $targets)]);
}
$current = collect();
$targets = $targets
->map(function (Collection $targetList) {
return $targetList-... | php | public function instantiateTargets(Collection $targets)
{
if ($targets->isEmpty()) {
return collect([Target::factory($this, $targets)]);
}
$current = collect();
$targets = $targets
->map(function (Collection $targetList) {
return $targetList-... | [
"public",
"function",
"instantiateTargets",
"(",
"Collection",
"$",
"targets",
")",
"{",
"if",
"(",
"$",
"targets",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"collect",
"(",
"[",
"Target",
"::",
"factory",
"(",
"$",
"this",
",",
"$",
"targets",
")... | Instantiate all checkers for a resource.
@param Collection $targets
@return Collection|\IlluminateAgnostic\Arr\Support\Collection|\IlluminateAgnostic\Collection\Support\Collection|\IlluminateAgnostic\Str\Support\Collection|mixed|\Tightenco\Collect\Support\Collection|\Vanilla\Support\Collection | [
"Instantiate",
"all",
"checkers",
"for",
"a",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Resource.php#L139-L162 |
antonioribeiro/health | src/Support/Resource.php | Resource.check | public function check($action = 'resource')
{
$this->setCurrentAction($action)->targets->each(function (
Target $target
) {
$target->check($target);
});
$this->notify();
return $this;
} | php | public function check($action = 'resource')
{
$this->setCurrentAction($action)->targets->each(function (
Target $target
) {
$target->check($target);
});
$this->notify();
return $this;
} | [
"public",
"function",
"check",
"(",
"$",
"action",
"=",
"'resource'",
")",
"{",
"$",
"this",
"->",
"setCurrentAction",
"(",
"$",
"action",
")",
"->",
"targets",
"->",
"each",
"(",
"function",
"(",
"Target",
"$",
"target",
")",
"{",
"$",
"target",
"->",... | Check all targets for a resource.
@param string $action
@return resource | [
"Check",
"all",
"targets",
"for",
"a",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Resource.php#L181-L192 |
antonioribeiro/health | src/Support/Resource.php | Resource.isHealthy | public function isHealthy()
{
return $this->targets->reduce(function ($carry, $target) {
return $carry && $target->result->healthy;
}, true);
} | php | public function isHealthy()
{
return $this->targets->reduce(function ($carry, $target) {
return $carry && $target->result->healthy;
}, true);
} | [
"public",
"function",
"isHealthy",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"targets",
"->",
"reduce",
"(",
"function",
"(",
"$",
"carry",
",",
"$",
"target",
")",
"{",
"return",
"$",
"carry",
"&&",
"$",
"target",
"->",
"result",
"->",
"healthy",
... | Check if is healthy.
@return mixed | [
"Check",
"if",
"is",
"healthy",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Resource.php#L210-L215 |
antonioribeiro/health | src/Support/Resource.php | Resource.sendNotifications | protected function sendNotifications()
{
return collect(config('health.notifications.channels'))->each(function (
$channel
) {
try {
event(new RaiseHealthIssue($this, $channel));
} catch (\Exception $exception) {
report($exception);... | php | protected function sendNotifications()
{
return collect(config('health.notifications.channels'))->each(function (
$channel
) {
try {
event(new RaiseHealthIssue($this, $channel));
} catch (\Exception $exception) {
report($exception);... | [
"protected",
"function",
"sendNotifications",
"(",
")",
"{",
"return",
"collect",
"(",
"config",
"(",
"'health.notifications.channels'",
")",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"channel",
")",
"{",
"try",
"{",
"event",
"(",
"new",
"RaiseHealthIssue"... | Send notifications.
@return static | [
"Send",
"notifications",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Resource.php#L239-L250 |
antonioribeiro/health | src/Support/ResourceChecker.php | ResourceChecker.checkResources | public function checkResources($force = false)
{
if (! ($resources = $this->getCachedResources($force))->isEmpty()) {
return $resources;
}
if (! $this->allResourcesAreGood()) {
return $this->resources = collect();
}
$resources = $this->sortResources(... | php | public function checkResources($force = false)
{
if (! ($resources = $this->getCachedResources($force))->isEmpty()) {
return $resources;
}
if (! $this->allResourcesAreGood()) {
return $this->resources = collect();
}
$resources = $this->sortResources(... | [
"public",
"function",
"checkResources",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"resources",
"=",
"$",
"this",
"->",
"getCachedResources",
"(",
"$",
"force",
")",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"$",
... | Check all resources.
@param bool $force
@return \Illuminate\Support\Collection
@throws Exception | [
"Check",
"all",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceChecker.php#L80-L105 |
antonioribeiro/health | src/Support/ResourceChecker.php | ResourceChecker.checkResource | public function checkResource($resource)
{
$resource =
$resource instanceof Resource
? $resource
: $this->getResourceBySlug($resource);
$checked = $this->cache->remember($resource->slug, function () use (
$resource
) {
retu... | php | public function checkResource($resource)
{
$resource =
$resource instanceof Resource
? $resource
: $this->getResourceBySlug($resource);
$checked = $this->cache->remember($resource->slug, function () use (
$resource
) {
retu... | [
"public",
"function",
"checkResource",
"(",
"$",
"resource",
")",
"{",
"$",
"resource",
"=",
"$",
"resource",
"instanceof",
"Resource",
"?",
"$",
"resource",
":",
"$",
"this",
"->",
"getResourceBySlug",
"(",
"$",
"resource",
")",
";",
"$",
"checked",
"=",
... | Check a resource.
@param $resource
@return array
@throws Exception | [
"Check",
"a",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceChecker.php#L114-L130 |
antonioribeiro/health | src/Support/ResourceChecker.php | ResourceChecker.getCachedResources | protected function getCachedResources($force = false)
{
if ($force) {
return collect();
}
if ($this->checked) {
return $this->getResources();
}
return $this->resources = $this->cache->getCachedResources();
} | php | protected function getCachedResources($force = false)
{
if ($force) {
return collect();
}
if ($this->checked) {
return $this->getResources();
}
return $this->resources = $this->cache->getCachedResources();
} | [
"protected",
"function",
"getCachedResources",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"force",
")",
"{",
"return",
"collect",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"checked",
")",
"{",
"return",
"$",
"this",
"->",
"g... | Get cached resources.
@param bool $force
@return \Illuminate\Support\Collection
@throws Exception | [
"Get",
"cached",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceChecker.php#L139-L150 |
antonioribeiro/health | src/Support/ResourceChecker.php | ResourceChecker.makeResult | protected function makeResult($exception, $resourceChecker)
{
$message = $exception->getMessage()
? $exception->getMessage()
: static::UNKNOWN_ERROR;
if (! isset($resourceChecker)) {
return [
null,
[
'healthy' =... | php | protected function makeResult($exception, $resourceChecker)
{
$message = $exception->getMessage()
? $exception->getMessage()
: static::UNKNOWN_ERROR;
if (! isset($resourceChecker)) {
return [
null,
[
'healthy' =... | [
"protected",
"function",
"makeResult",
"(",
"$",
"exception",
",",
"$",
"resourceChecker",
")",
"{",
"$",
"message",
"=",
"$",
"exception",
"->",
"getMessage",
"(",
")",
"?",
"$",
"exception",
"->",
"getMessage",
"(",
")",
":",
"static",
"::",
"UNKNOWN_ERR... | Make the result array.
@param $exception
@param $resourceChecker
@return array | [
"Make",
"the",
"result",
"array",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceChecker.php#L224-L243 |
antonioribeiro/health | src/Support/ResourceChecker.php | ResourceChecker.loadResources | public function loadResources()
{
if (is_null($this->resources) || $this->resources->isEmpty()) {
$this->resources = $this->resourceLoader->loadResources()->map(
function ($resource) {
return $this->handleExceptions(function () use ($resource) {
... | php | public function loadResources()
{
if (is_null($this->resources) || $this->resources->isEmpty()) {
$this->resources = $this->resourceLoader->loadResources()->map(
function ($resource) {
return $this->handleExceptions(function () use ($resource) {
... | [
"public",
"function",
"loadResources",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"resources",
")",
"||",
"$",
"this",
"->",
"resources",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"this",
"->",
"resources",
"=",
"$",
"this",
"->",
... | Load all resources.
@return \Illuminate\Support\Collection
@throws Exception | [
"Load",
"all",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceChecker.php#L282-L295 |
antonioribeiro/health | src/Support/ResourceChecker.php | ResourceChecker.sortResources | protected function sortResources($resources)
{
if ($sortBy = config('health.sort_by')) {
return $resources->sortBy(function ($resource) use ($sortBy) {
return $this->handleExceptions(function () use (
$resource,
$sortBy
) {
... | php | protected function sortResources($resources)
{
if ($sortBy = config('health.sort_by')) {
return $resources->sortBy(function ($resource) use ($sortBy) {
return $this->handleExceptions(function () use (
$resource,
$sortBy
) {
... | [
"protected",
"function",
"sortResources",
"(",
"$",
"resources",
")",
"{",
"if",
"(",
"$",
"sortBy",
"=",
"config",
"(",
"'health.sort_by'",
")",
")",
"{",
"return",
"$",
"resources",
"->",
"sortBy",
"(",
"function",
"(",
"$",
"resource",
")",
"use",
"("... | Sort resources.
@param $resources
@return \Illuminate\Support\Collection | [
"Sort",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceChecker.php#L319-L334 |
antonioribeiro/health | src/Checkers/Ping.php | Ping.check | public function check()
{
$this->pingBinFactory();
$ipAddress = ip_address_from_hostname($this->target->hostname);
$latency = $this->ping($ipAddress);
$latencyFormatted = $latency ? "{$latency}ms" : 'error!';
$this->target->setDisplay(
"{$this->target->name} (... | php | public function check()
{
$this->pingBinFactory();
$ipAddress = ip_address_from_hostname($this->target->hostname);
$latency = $this->ping($ipAddress);
$latencyFormatted = $latency ? "{$latency}ms" : 'error!';
$this->target->setDisplay(
"{$this->target->name} (... | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"this",
"->",
"pingBinFactory",
"(",
")",
";",
"$",
"ipAddress",
"=",
"ip_address_from_hostname",
"(",
"$",
"this",
"->",
"target",
"->",
"hostname",
")",
";",
"$",
"latency",
"=",
"$",
"this",
"->",
"... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Ping.php#L20-L49 |
antonioribeiro/health | src/Support/Cache.php | Cache.flush | public function flush($force = false, $key = null)
{
if (! isset($this->flushed[$key]) && ($force || $this->needsToFlush())) {
try {
$this->forceFlush($key);
} catch (Exception $exception) {
report($exception);
}
$this->flushed... | php | public function flush($force = false, $key = null)
{
if (! isset($this->flushed[$key]) && ($force || $this->needsToFlush())) {
try {
$this->forceFlush($key);
} catch (Exception $exception) {
report($exception);
}
$this->flushed... | [
"public",
"function",
"flush",
"(",
"$",
"force",
"=",
"false",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"flushed",
"[",
"$",
"key",
"]",
")",
"&&",
"(",
"$",
"force",
"||",
"$",
"this",
"->",
"... | Flush cache.
@param bool $force
@param null $key | [
"Flush",
"cache",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Cache.php#L30-L41 |
antonioribeiro/health | src/Support/Cache.php | Cache.getCachedResources | public function getCachedResources()
{
$this->flush();
return $this->cacheIsEnabled()
? IlluminateCache::get(config('health.cache.key'), collect())
: collect();
} | php | public function getCachedResources()
{
$this->flush();
return $this->cacheIsEnabled()
? IlluminateCache::get(config('health.cache.key'), collect())
: collect();
} | [
"public",
"function",
"getCachedResources",
"(",
")",
"{",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"cacheIsEnabled",
"(",
")",
"?",
"IlluminateCache",
"::",
"get",
"(",
"config",
"(",
"'health.cache.key'",
")",
",",
"collect... | Get cached resources.
@return \Illuminate\Support\Collection | [
"Get",
"cached",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Cache.php#L78-L85 |
antonioribeiro/health | src/Support/Cache.php | Cache.cacheResources | public function cacheResources($resources)
{
if ($this->cacheIsEnabled()) {
IlluminateCache::put(
config('health.cache.key'),
$resources,
$this->getMinutes()
);
}
return $resources;
} | php | public function cacheResources($resources)
{
if ($this->cacheIsEnabled()) {
IlluminateCache::put(
config('health.cache.key'),
$resources,
$this->getMinutes()
);
}
return $resources;
} | [
"public",
"function",
"cacheResources",
"(",
"$",
"resources",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheIsEnabled",
"(",
")",
")",
"{",
"IlluminateCache",
"::",
"put",
"(",
"config",
"(",
"'health.cache.key'",
")",
",",
"$",
"resources",
",",
"$",
"... | Cache all resources.
@param Collection $resources
@return Collection | [
"Cache",
"all",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Cache.php#L104-L115 |
antonioribeiro/health | src/Support/Cache.php | Cache.remember | public function remember($key, \Closure $callback)
{
if (! $this->cacheIsEnabled()) {
return $callback();
}
$key = config('health.cache.key').$key;
$this->flush(false, $key);
return IlluminateCache::remember($key, $this->getMinutes(), $callback);
} | php | public function remember($key, \Closure $callback)
{
if (! $this->cacheIsEnabled()) {
return $callback();
}
$key = config('health.cache.key').$key;
$this->flush(false, $key);
return IlluminateCache::remember($key, $this->getMinutes(), $callback);
} | [
"public",
"function",
"remember",
"(",
"$",
"key",
",",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cacheIsEnabled",
"(",
")",
")",
"{",
"return",
"$",
"callback",
"(",
")",
";",
"}",
"$",
"key",
"=",
"config",
... | Get an item from the cache, or store the default value.
@param string $key
@param \Closure $callback
@return mixed | [
"Get",
"an",
"item",
"from",
"the",
"cache",
"or",
"store",
"the",
"default",
"value",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Cache.php#L124-L135 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.configurePaths | private function configurePaths()
{
$this->publishes(
[
__DIR__.'/config/health.php' => config_path(
'health/config.php'
),
__DIR__.'/config/resources/' => config_path(
'health/resources/'
),
... | php | private function configurePaths()
{
$this->publishes(
[
__DIR__.'/config/health.php' => config_path(
'health/config.php'
),
__DIR__.'/config/resources/' => config_path(
'health/resources/'
),
... | [
"private",
"function",
"configurePaths",
"(",
")",
"{",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/config/health.php'",
"=>",
"config_path",
"(",
"'health/config.php'",
")",
",",
"__DIR__",
".",
"'/config/resources/'",
"=>",
"config_path",
"(",
... | Configure package paths. | [
"Configure",
"package",
"paths",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L80-L111 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.createHealthService | private function createHealthService()
{
$resourceChecker = call_user_func($this->resourceCheckerClosure);
$cache = call_user_func($this->cacheClosure);
$this->healthServiceClosure = function () use (
$resourceChecker,
$cache
) {
return $this->in... | php | private function createHealthService()
{
$resourceChecker = call_user_func($this->resourceCheckerClosure);
$cache = call_user_func($this->cacheClosure);
$this->healthServiceClosure = function () use (
$resourceChecker,
$cache
) {
return $this->in... | [
"private",
"function",
"createHealthService",
"(",
")",
"{",
"$",
"resourceChecker",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"resourceCheckerClosure",
")",
";",
"$",
"cache",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"cacheClosure",
")",
";",
"$",
... | Create health service. | [
"Create",
"health",
"service",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L127-L141 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.createResourceChecker | private function createResourceChecker()
{
$this->resourceLoader = new ResourceLoader(new Yaml());
$this->cacheClosure = $this->getCacheClosure();
$this->resourceCheckerClosure = $this->getResourceCheckerClosure(
$this->resourceLoader,
call_user_func($this->cacheClo... | php | private function createResourceChecker()
{
$this->resourceLoader = new ResourceLoader(new Yaml());
$this->cacheClosure = $this->getCacheClosure();
$this->resourceCheckerClosure = $this->getResourceCheckerClosure(
$this->resourceLoader,
call_user_func($this->cacheClo... | [
"private",
"function",
"createResourceChecker",
"(",
")",
"{",
"$",
"this",
"->",
"resourceLoader",
"=",
"new",
"ResourceLoader",
"(",
"new",
"Yaml",
"(",
")",
")",
";",
"$",
"this",
"->",
"cacheClosure",
"=",
"$",
"this",
"->",
"getCacheClosure",
"(",
")"... | Create resource checker. | [
"Create",
"resource",
"checker",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L146-L156 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.getResourceCheckerClosure | private function getResourceCheckerClosure($resourceLoader, $cache)
{
$resourceCheckerInstance = function () use ($resourceLoader, $cache) {
return new ResourceChecker($resourceLoader, $cache);
};
return $resourceCheckerInstance;
} | php | private function getResourceCheckerClosure($resourceLoader, $cache)
{
$resourceCheckerInstance = function () use ($resourceLoader, $cache) {
return new ResourceChecker($resourceLoader, $cache);
};
return $resourceCheckerInstance;
} | [
"private",
"function",
"getResourceCheckerClosure",
"(",
"$",
"resourceLoader",
",",
"$",
"cache",
")",
"{",
"$",
"resourceCheckerInstance",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"resourceLoader",
",",
"$",
"cache",
")",
"{",
"return",
"new",
"ResourceCh... | Get the resource checker closure for instantiation.
@param $resourceLoader
@param $cache
@return \Closure | [
"Get",
"the",
"resource",
"checker",
"closure",
"for",
"instantiation",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L179-L186 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.mergeConfig | private function mergeConfig()
{
if (file_exists(config_path('/health/config.php'))) {
$this->mergeConfigFrom(config_path('/health/config.php'), 'health');
}
$this->mergeConfigFrom(__DIR__.'/config/health.php', 'health');
$this->addDistPathToConfig();
} | php | private function mergeConfig()
{
if (file_exists(config_path('/health/config.php'))) {
$this->mergeConfigFrom(config_path('/health/config.php'), 'health');
}
$this->mergeConfigFrom(__DIR__.'/config/health.php', 'health');
$this->addDistPathToConfig();
} | [
"private",
"function",
"mergeConfig",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"config_path",
"(",
"'/health/config.php'",
")",
")",
")",
"{",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"config_path",
"(",
"'/health/config.php'",
")",
",",
"'health'",
")"... | Merge configuration. | [
"Merge",
"configuration",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L225-L234 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
$this->mergeConfig();
$this->configureViews();
$this->configurePaths();
$this->registerServices();
$this->registerRoutes();
$this->registerTasks();
$this->registerEventListeners();
$this->registerConsoleCommands();
... | php | public function register()
{
$this->mergeConfig();
$this->configureViews();
$this->configurePaths();
$this->registerServices();
$this->registerRoutes();
$this->registerTasks();
$this->registerEventListeners();
$this->registerConsoleCommands();
... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfig",
"(",
")",
";",
"$",
"this",
"->",
"configureViews",
"(",
")",
";",
"$",
"this",
"->",
"configurePaths",
"(",
")",
";",
"$",
"this",
"->",
"registerServices",
"(",
")",
... | Register any application services.
@return void | [
"Register",
"any",
"application",
"services",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L241-L258 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.registerRoutes | private function registerRoutes()
{
collect(($routes = $this->getRoutes()))->each(function ($route) {
$this->registerRoute($route);
});
$this->registerResourcesRoutes();
} | php | private function registerRoutes()
{
collect(($routes = $this->getRoutes()))->each(function ($route) {
$this->registerRoute($route);
});
$this->registerResourcesRoutes();
} | [
"private",
"function",
"registerRoutes",
"(",
")",
"{",
"collect",
"(",
"(",
"$",
"routes",
"=",
"$",
"this",
"->",
"getRoutes",
"(",
")",
")",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"route",
")",
"{",
"$",
"this",
"->",
"registerRoute",
"(",
... | Register routes. | [
"Register",
"routes",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L293-L300 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.registerServices | private function registerServices()
{
$this->createServices();
$this->app->singleton('pragmarx.health.cache', $this->cacheClosure);
$this->app->singleton(
'pragmarx.health.resource.checker',
$this->resourceCheckerClosure
);
$this->app->singleton('pr... | php | private function registerServices()
{
$this->createServices();
$this->app->singleton('pragmarx.health.cache', $this->cacheClosure);
$this->app->singleton(
'pragmarx.health.resource.checker',
$this->resourceCheckerClosure
);
$this->app->singleton('pr... | [
"private",
"function",
"registerServices",
"(",
")",
"{",
"$",
"this",
"->",
"createServices",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'pragmarx.health.cache'",
",",
"$",
"this",
"->",
"cacheClosure",
")",
";",
"$",
"this",
"->",
... | Register service. | [
"Register",
"service",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L305-L322 |
antonioribeiro/health | src/ServiceProvider.php | ServiceProvider.registerTasks | private function registerTasks()
{
if (
config('health.scheduler.enabled') &&
($frequency = config('health.scheduler.frequency')) &&
config('health.notifications.enabled')
) {
$scheduler = instantiate(Schedule::class);
$scheduler
... | php | private function registerTasks()
{
if (
config('health.scheduler.enabled') &&
($frequency = config('health.scheduler.frequency')) &&
config('health.notifications.enabled')
) {
$scheduler = instantiate(Schedule::class);
$scheduler
... | [
"private",
"function",
"registerTasks",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'health.scheduler.enabled'",
")",
"&&",
"(",
"$",
"frequency",
"=",
"config",
"(",
"'health.scheduler.frequency'",
")",
")",
"&&",
"config",
"(",
"'health.notifications.enabled'",
")... | Register scheduled tasks. | [
"Register",
"scheduled",
"tasks",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/ServiceProvider.php#L337-L350 |
antonioribeiro/health | src/Checkers/ServerUptime.php | ServerUptime.check | public function check()
{
$this->loadDatabase();
$current = $this->getCurrentUptime();
$this->persist($current);
$rebooted =
($cs = $this->uptimeInSeconds($current)) <
($ss = $this->uptimeInSeconds($this->database));
return $this->makeResult(
... | php | public function check()
{
$this->loadDatabase();
$current = $this->getCurrentUptime();
$this->persist($current);
$rebooted =
($cs = $this->uptimeInSeconds($current)) <
($ss = $this->uptimeInSeconds($this->database));
return $this->makeResult(
... | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"this",
"->",
"loadDatabase",
"(",
")",
";",
"$",
"current",
"=",
"$",
"this",
"->",
"getCurrentUptime",
"(",
")",
";",
"$",
"this",
"->",
"persist",
"(",
"$",
"current",
")",
";",
"$",
"rebooted",
... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/ServerUptime.php#L19-L35 |
antonioribeiro/health | src/Checkers/ServerUptime.php | ServerUptime.parseUptimeString | protected function parseUptimeString($system_string)
{
$matches = [];
preg_match(
$this->target->regex,
$system_string,
$matches,
PREG_OFFSET_CAPTURE
);
$matches = $this->normalizeMatches($matches);
$matches['uptime_string'] ... | php | protected function parseUptimeString($system_string)
{
$matches = [];
preg_match(
$this->target->regex,
$system_string,
$matches,
PREG_OFFSET_CAPTURE
);
$matches = $this->normalizeMatches($matches);
$matches['uptime_string'] ... | [
"protected",
"function",
"parseUptimeString",
"(",
"$",
"system_string",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"preg_match",
"(",
"$",
"this",
"->",
"target",
"->",
"regex",
",",
"$",
"system_string",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
... | Parse the uptime string.
@param $system_string
@return array | [
"Parse",
"the",
"uptime",
"string",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/ServerUptime.php#L101-L117 |
antonioribeiro/health | src/Support/ResourceLoader.php | ResourceLoader.getEnabledResources | private function getEnabledResources($resources)
{
if (
is_array($filters = config($configKey = 'health.resources.enabled'))
) {
return collect($resources)->filter(function ($resource, $name) use (
$filters
) {
foreach ($filters as ... | php | private function getEnabledResources($resources)
{
if (
is_array($filters = config($configKey = 'health.resources.enabled'))
) {
return collect($resources)->filter(function ($resource, $name) use (
$filters
) {
foreach ($filters as ... | [
"private",
"function",
"getEnabledResources",
"(",
"$",
"resources",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"filters",
"=",
"config",
"(",
"$",
"configKey",
"=",
"'health.resources.enabled'",
")",
")",
")",
"{",
"return",
"collect",
"(",
"$",
"resources"... | Get enabled resources.
@param $resources
@return \Illuminate\Support\Collection
@throws \Exception | [
"Get",
"enabled",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceLoader.php#L40-L59 |
antonioribeiro/health | src/Support/ResourceLoader.php | ResourceLoader.load | public function load()
{
if (! empty($this->resources)) {
return $this->resources;
}
return $this->resources = $this->sanitizeResources(
$this->getEnabledResources($this->loadResourceFiles())
);
} | php | public function load()
{
if (! empty($this->resources)) {
return $this->resources;
}
return $this->resources = $this->sanitizeResources(
$this->getEnabledResources($this->loadResourceFiles())
);
} | [
"public",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"resources",
")",
")",
"{",
"return",
"$",
"this",
"->",
"resources",
";",
"}",
"return",
"$",
"this",
"->",
"resources",
"=",
"$",
"this",
"->",
"sanitiz... | Load all resources.
@return \Illuminate\Support\Collection
@throws \Exception | [
"Load",
"all",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceLoader.php#L80-L89 |
antonioribeiro/health | src/Support/ResourceLoader.php | ResourceLoader.loadResourceFiles | private function loadResourceFiles()
{
return $this->replaceExecutableCode(
$this->loadResourcesFiles()
)->mapWithKeys(function ($value, $key) {
return [$this->removeExtension($key) => $value];
});
} | php | private function loadResourceFiles()
{
return $this->replaceExecutableCode(
$this->loadResourcesFiles()
)->mapWithKeys(function ($value, $key) {
return [$this->removeExtension($key) => $value];
});
} | [
"private",
"function",
"loadResourceFiles",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"replaceExecutableCode",
"(",
"$",
"this",
"->",
"loadResourcesFiles",
"(",
")",
")",
"->",
"mapWithKeys",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{"... | Load resources in files.
@return \Illuminate\Support\Collection | [
"Load",
"resources",
"in",
"files",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceLoader.php#L96-L103 |
antonioribeiro/health | src/Support/ResourceLoader.php | ResourceLoader.replaceExecutableCode | private function replaceExecutableCode($files)
{
return $files->map(function ($item) {
return collect($item)
->map(function ($value) {
return (new Resolver())->recursivelyFindAndReplaceExecutableCode(
$value
);
... | php | private function replaceExecutableCode($files)
{
return $files->map(function ($item) {
return collect($item)
->map(function ($value) {
return (new Resolver())->recursivelyFindAndReplaceExecutableCode(
$value
);
... | [
"private",
"function",
"replaceExecutableCode",
"(",
"$",
"files",
")",
"{",
"return",
"$",
"files",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"collect",
"(",
"$",
"item",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
... | Replace executable code.
@return \Illuminate\Support\Collection | [
"Replace",
"executable",
"code",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceLoader.php#L110-L121 |
antonioribeiro/health | src/Support/ResourceLoader.php | ResourceLoader.loadResourcesFiles | private function loadResourcesFiles()
{
$files = $this->yaml->loadFromDirectory(
config('health.resources.path')
);
$files =
$files->count() == 0
? $this->yaml->loadFromDirectory(package_resources_dir())
: $files;
return $file... | php | private function loadResourcesFiles()
{
$files = $this->yaml->loadFromDirectory(
config('health.resources.path')
);
$files =
$files->count() == 0
? $this->yaml->loadFromDirectory(package_resources_dir())
: $files;
return $file... | [
"private",
"function",
"loadResourcesFiles",
"(",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"yaml",
"->",
"loadFromDirectory",
"(",
"config",
"(",
"'health.resources.path'",
")",
")",
";",
"$",
"files",
"=",
"$",
"files",
"->",
"count",
"(",
")",
"... | Load resource files.
@return \Illuminate\Support\Collection | [
"Load",
"resource",
"files",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceLoader.php#L139-L151 |
antonioribeiro/health | src/Support/ResourceLoader.php | ResourceLoader.sanitizeResources | private function sanitizeResources($resources)
{
return $resources->map(function ($resource) {
return collect($resource)->mapWithKeys(function ($value, $key) {
return [$this->sanitizeKey($key) => $value];
});
});
} | php | private function sanitizeResources($resources)
{
return $resources->map(function ($resource) {
return collect($resource)->mapWithKeys(function ($value, $key) {
return [$this->sanitizeKey($key) => $value];
});
});
} | [
"private",
"function",
"sanitizeResources",
"(",
"$",
"resources",
")",
"{",
"return",
"$",
"resources",
"->",
"map",
"(",
"function",
"(",
"$",
"resource",
")",
"{",
"return",
"collect",
"(",
"$",
"resource",
")",
"->",
"mapWithKeys",
"(",
"function",
"("... | Sanitize resources.
@param $resources
@return \Illuminate\Support\Collection | [
"Sanitize",
"resources",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/ResourceLoader.php#L181-L188 |
antonioribeiro/health | src/Support/Target.php | Target.factory | public static function factory($resource, $data, $name = null)
{
$instance = new static();
$instance->id = (string) Uuid::uuid4();
$instance->name = self::makeName($data, $name);
$instance->display = $instance->name;
$instance->resource = $resource;
$instance->im... | php | public static function factory($resource, $data, $name = null)
{
$instance = new static();
$instance->id = (string) Uuid::uuid4();
$instance->name = self::makeName($data, $name);
$instance->display = $instance->name;
$instance->resource = $resource;
$instance->im... | [
"public",
"static",
"function",
"factory",
"(",
"$",
"resource",
",",
"$",
"data",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"$",
"instance",
"->",
"id",
"=",
"(",
"string",
")",
"Uuid",
"::",
... | Target factory.
@param $resource
@param $data
@return Target | [
"Target",
"factory",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Target.php#L68-L83 |
antonioribeiro/health | src/Support/Target.php | Target.check | public function check()
{
try {
try {
$this->result(
$this->resource->checker->setTarget($this)->checkTarget(
$this
)
);
} catch (\Exception $exception) {
report($exception... | php | public function check()
{
try {
try {
$this->result(
$this->resource->checker->setTarget($this)->checkTarget(
$this
)
);
} catch (\Exception $exception) {
report($exception... | [
"public",
"function",
"check",
"(",
")",
"{",
"try",
"{",
"try",
"{",
"$",
"this",
"->",
"result",
"(",
"$",
"this",
"->",
"resource",
"->",
"checker",
"->",
"setTarget",
"(",
"$",
"this",
")",
"->",
"checkTarget",
"(",
"$",
"this",
")",
")",
";",
... | Check a resource target.
@return Target | [
"Check",
"a",
"resource",
"target",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Target.php#L90-L113 |
antonioribeiro/health | src/Support/Target.php | Target.moveChecksBackToTarget | protected function moveChecksBackToTarget()
{
if (isset($this->result->checks)) {
$this->checks = $this->result->checks;
unset($this->result->checks);
}
} | php | protected function moveChecksBackToTarget()
{
if (isset($this->result->checks)) {
$this->checks = $this->result->checks;
unset($this->result->checks);
}
} | [
"protected",
"function",
"moveChecksBackToTarget",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"result",
"->",
"checks",
")",
")",
"{",
"$",
"this",
"->",
"checks",
"=",
"$",
"this",
"->",
"result",
"->",
"checks",
";",
"unset",
"(",
"... | Move checks to target object. | [
"Move",
"checks",
"to",
"target",
"object",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Target.php#L162-L169 |
antonioribeiro/health | src/Support/Target.php | Target.result | protected function result($result)
{
$this->result =
$result instanceof Result
? $result
: new Result($result['healthy'], $result['exception_message']);
return $this->result;
} | php | protected function result($result)
{
$this->result =
$result instanceof Result
? $result
: new Result($result['healthy'], $result['exception_message']);
return $this->result;
} | [
"protected",
"function",
"result",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"result",
"=",
"$",
"result",
"instanceof",
"Result",
"?",
"$",
"result",
":",
"new",
"Result",
"(",
"$",
"result",
"[",
"'healthy'",
"]",
",",
"$",
"result",
"[",
"'... | Make a result.
@param $result
@return Result | [
"Make",
"a",
"result",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Target.php#L177-L185 |
antonioribeiro/health | src/Checkers/Horizon.php | Horizon.check | public function check()
{
return $this->horizonIsRunning()
? $this->makeHealthyResult()
: $this->makeResult(false, $this->target->getErrorMessage());
} | php | public function check()
{
return $this->horizonIsRunning()
? $this->makeHealthyResult()
: $this->makeResult(false, $this->target->getErrorMessage());
} | [
"public",
"function",
"check",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"horizonIsRunning",
"(",
")",
"?",
"$",
"this",
"->",
"makeHealthyResult",
"(",
")",
":",
"$",
"this",
"->",
"makeResult",
"(",
"false",
",",
"$",
"this",
"->",
"target",
"->",
... | Check resource.
@return \PragmaRX\Health\Support\Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Horizon.php#L14-L19 |
antonioribeiro/health | src/Checkers/Horizon.php | Horizon.horizonIsRunning | protected function horizonIsRunning()
{
if (! $masters = app(MasterSupervisorRepository::class)->all()) {
return false;
}
return collect($masters)->contains(function ($master) {
return $master->status === 'paused';
})
? false
: true;
... | php | protected function horizonIsRunning()
{
if (! $masters = app(MasterSupervisorRepository::class)->all()) {
return false;
}
return collect($masters)->contains(function ($master) {
return $master->status === 'paused';
})
? false
: true;
... | [
"protected",
"function",
"horizonIsRunning",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"masters",
"=",
"app",
"(",
"MasterSupervisorRepository",
"::",
"class",
")",
"->",
"all",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"collect",
"(",
"$",
... | Check if Horizon is up.
@return bool | [
"Check",
"if",
"Horizon",
"is",
"up",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Horizon.php#L26-L37 |
antonioribeiro/health | src/Checkers/DiskSpace.php | DiskSpace.check | public function check()
{
$free = disk_free_space($this->target->path);
if (! $this->isEnough($free, $this->target->minimum)) {
return $this->makeResult(
false,
sprintf(
$this->target->message,
$this->target->path,
... | php | public function check()
{
$free = disk_free_space($this->target->path);
if (! $this->isEnough($free, $this->target->minimum)) {
return $this->makeResult(
false,
sprintf(
$this->target->message,
$this->target->path,
... | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"free",
"=",
"disk_free_space",
"(",
"$",
"this",
"->",
"target",
"->",
"path",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnough",
"(",
"$",
"free",
",",
"$",
"this",
"->",
"target",
"->",
... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/DiskSpace.php#L14-L31 |
antonioribeiro/health | src/Checkers/Composer.php | Composer.check | public function check()
{
$outdated = $this->executeCommand();
if ($outdated->count() > $this->target->resource->shouldCountAtMost) {
return $this->makeResult(
false,
sprintf($this->target->getErrorMessage(), $outdated->count())
);
}
... | php | public function check()
{
$outdated = $this->executeCommand();
if ($outdated->count() > $this->target->resource->shouldCountAtMost) {
return $this->makeResult(
false,
sprintf($this->target->getErrorMessage(), $outdated->count())
);
}
... | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"outdated",
"=",
"$",
"this",
"->",
"executeCommand",
"(",
")",
";",
"if",
"(",
"$",
"outdated",
"->",
"count",
"(",
")",
">",
"$",
"this",
"->",
"target",
"->",
"resource",
"->",
"shouldCountAtMost",
... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Composer.php#L15-L27 |
antonioribeiro/health | src/Checkers/Composer.php | Composer.outputToCollection | protected function outputToCollection(string $output)
{
if ($this->target->resource->jsonResult) {
return collect(json_decode($output, true) ?? collect([]));
}
return $output;
} | php | protected function outputToCollection(string $output)
{
if ($this->target->resource->jsonResult) {
return collect(json_decode($output, true) ?? collect([]));
}
return $output;
} | [
"protected",
"function",
"outputToCollection",
"(",
"string",
"$",
"output",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"target",
"->",
"resource",
"->",
"jsonResult",
")",
"{",
"return",
"collect",
"(",
"json_decode",
"(",
"$",
"output",
",",
"true",
")",
... | Convert output to array.
@param string $output
@return \Illuminate\Support\Collection|mixed | [
"Convert",
"output",
"to",
"array",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Composer.php#L35-L42 |
antonioribeiro/health | src/Checkers/Composer.php | Composer.makeCommand | protected function makeCommand()
{
return sprintf(
'%s %s',
$this->target->resource->binary,
$this->target->resource->command
);
} | php | protected function makeCommand()
{
return sprintf(
'%s %s',
$this->target->resource->binary,
$this->target->resource->command
);
} | [
"protected",
"function",
"makeCommand",
"(",
")",
"{",
"return",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"this",
"->",
"target",
"->",
"resource",
"->",
"binary",
",",
"$",
"this",
"->",
"target",
"->",
"resource",
"->",
"command",
")",
";",
"}"
] | Get the ping binary. | [
"Get",
"the",
"ping",
"binary",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Composer.php#L47-L54 |
antonioribeiro/health | src/Checkers/Composer.php | Composer.executeCommand | protected function executeCommand()
{
$process = new SymfonyProcess(
$this->makeCommand(),
$this->target->workingDir
);
$process->run();
$output = $this->outputToCollection($process->getOutput());
if ($output->count() == 0) {
return $out... | php | protected function executeCommand()
{
$process = new SymfonyProcess(
$this->makeCommand(),
$this->target->workingDir
);
$process->run();
$output = $this->outputToCollection($process->getOutput());
if ($output->count() == 0) {
return $out... | [
"protected",
"function",
"executeCommand",
"(",
")",
"{",
"$",
"process",
"=",
"new",
"SymfonyProcess",
"(",
"$",
"this",
"->",
"makeCommand",
"(",
")",
",",
"$",
"this",
"->",
"target",
"->",
"workingDir",
")",
";",
"$",
"process",
"->",
"run",
"(",
"... | Execute the Composer command.
@return \Illuminate\Support\Collection|mixed | [
"Execute",
"the",
"Composer",
"command",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Composer.php#L61-L81 |
antonioribeiro/health | src/Checkers/Redis.php | Redis.check | public function check()
{
IlluminateRedis::set(
$key = $this->target->key,
$number = random_bytes(80)
);
$result = IlluminateRedis::get($key);
return $this->makeResult(
$number == $result,
$number !== $result ? $this->target->key : ''... | php | public function check()
{
IlluminateRedis::set(
$key = $this->target->key,
$number = random_bytes(80)
);
$result = IlluminateRedis::get($key);
return $this->makeResult(
$number == $result,
$number !== $result ? $this->target->key : ''... | [
"public",
"function",
"check",
"(",
")",
"{",
"IlluminateRedis",
"::",
"set",
"(",
"$",
"key",
"=",
"$",
"this",
"->",
"target",
"->",
"key",
",",
"$",
"number",
"=",
"random_bytes",
"(",
"80",
")",
")",
";",
"$",
"result",
"=",
"IlluminateRedis",
":... | Check resource.
@return Result
@throws \Exception | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Redis.php#L16-L29 |
antonioribeiro/health | src/database/migrations/2018_09_09_000001_create_table_health_checks.php | CreateTableHealthChecks.up | public function up()
{
Schema::create('health_checks', function (Blueprint $table) {
$table->increments('id');
$table->string('resource_name');
$table->string('resource_slug')->index();
$table->string('target_name');
$table->string('target_slug... | php | public function up()
{
Schema::create('health_checks', function (Blueprint $table) {
$table->increments('id');
$table->string('resource_name');
$table->string('resource_slug')->index();
$table->string('target_name');
$table->string('target_slug... | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'health_checks'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'resour... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/database/migrations/2018_09_09_000001_create_table_health_checks.php#L13-L40 |
antonioribeiro/health | src/Checkers/Queue.php | Queue.check | public function check()
{
app('queue')->pushOn(
$this->target->name,
instantiate($this->target->testJob)
);
$worker = app('queue.worker');
$connection = $this->target->connection
?: app('config')['queue.default'];
$queue = app('config')-... | php | public function check()
{
app('queue')->pushOn(
$this->target->name,
instantiate($this->target->testJob)
);
$worker = app('queue.worker');
$connection = $this->target->connection
?: app('config')['queue.default'];
$queue = app('config')-... | [
"public",
"function",
"check",
"(",
")",
"{",
"app",
"(",
"'queue'",
")",
"->",
"pushOn",
"(",
"$",
"this",
"->",
"target",
"->",
"name",
",",
"instantiate",
"(",
"$",
"this",
"->",
"target",
"->",
"testJob",
")",
")",
";",
"$",
"worker",
"=",
"app... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Queue.php#L16-L38 |
antonioribeiro/health | src/Checkers/Health.php | Health.check | public function check()
{
$healthy = $this->isHealthy();
return $this->makeResult(
$healthy,
$healthy ? '' : $this->target->getErrorMessage()
);
} | php | public function check()
{
$healthy = $this->isHealthy();
return $this->makeResult(
$healthy,
$healthy ? '' : $this->target->getErrorMessage()
);
} | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"healthy",
"=",
"$",
"this",
"->",
"isHealthy",
"(",
")",
";",
"return",
"$",
"this",
"->",
"makeResult",
"(",
"$",
"healthy",
",",
"$",
"healthy",
"?",
"''",
":",
"$",
"this",
"->",
"target",
"->"... | Check health.
@return Result | [
"Check",
"health",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Health.php#L14-L22 |
antonioribeiro/health | src/Checkers/Health.php | Health.computeHealth | private function computeHealth($previous, $resource)
{
return $resource->isGlobal
? $previous
: $previous && $this->computeHealthForAllTargets($resource);
} | php | private function computeHealth($previous, $resource)
{
return $resource->isGlobal
? $previous
: $previous && $this->computeHealthForAllTargets($resource);
} | [
"private",
"function",
"computeHealth",
"(",
"$",
"previous",
",",
"$",
"resource",
")",
"{",
"return",
"$",
"resource",
"->",
"isGlobal",
"?",
"$",
"previous",
":",
"$",
"previous",
"&&",
"$",
"this",
"->",
"computeHealthForAllTargets",
"(",
"$",
"resource"... | Compute health.
@param $previous
@param $resource
@return bool | [
"Compute",
"health",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Health.php#L31-L36 |
antonioribeiro/health | src/Checkers/Health.php | Health.computeHealthForAllTargets | private function computeHealthForAllTargets($resource)
{
return $resource->targets->reduce(function ($carry, $target) {
return $target->result->healthy;
}, true);
} | php | private function computeHealthForAllTargets($resource)
{
return $resource->targets->reduce(function ($carry, $target) {
return $target->result->healthy;
}, true);
} | [
"private",
"function",
"computeHealthForAllTargets",
"(",
"$",
"resource",
")",
"{",
"return",
"$",
"resource",
"->",
"targets",
"->",
"reduce",
"(",
"function",
"(",
"$",
"carry",
",",
"$",
"target",
")",
"{",
"return",
"$",
"target",
"->",
"result",
"->"... | Compute health for targets.
@param $resource
@return bool | [
"Compute",
"health",
"for",
"targets",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Health.php#L44-L49 |
antonioribeiro/health | src/Checkers/Health.php | Health.isHealthy | protected function isHealthy()
{
$healthy = $this->target->resource->resources->reduce(function (
$carry,
$item
) {
return $this->computeHealth($carry, $item);
},
true);
return $healthy;
} | php | protected function isHealthy()
{
$healthy = $this->target->resource->resources->reduce(function (
$carry,
$item
) {
return $this->computeHealth($carry, $item);
},
true);
return $healthy;
} | [
"protected",
"function",
"isHealthy",
"(",
")",
"{",
"$",
"healthy",
"=",
"$",
"this",
"->",
"target",
"->",
"resource",
"->",
"resources",
"->",
"reduce",
"(",
"function",
"(",
"$",
"carry",
",",
"$",
"item",
")",
"{",
"return",
"$",
"this",
"->",
"... | Check if the resource is healty.
@return mixed | [
"Check",
"if",
"the",
"resource",
"is",
"healty",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Health.php#L56-L67 |
antonioribeiro/health | src/Checkers/PortCheck.php | PortCheck.check | public function check()
{
if (
$this->portIsNotConnectable(
$ipAddress = ip_address_from_hostname($this->target->hostname)
)
) {
return $this->makeFinalResult($ipAddress);
}
return $this->makeHealthyResult();
} | php | public function check()
{
if (
$this->portIsNotConnectable(
$ipAddress = ip_address_from_hostname($this->target->hostname)
)
) {
return $this->makeFinalResult($ipAddress);
}
return $this->makeHealthyResult();
} | [
"public",
"function",
"check",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"portIsNotConnectable",
"(",
"$",
"ipAddress",
"=",
"ip_address_from_hostname",
"(",
"$",
"this",
"->",
"target",
"->",
"hostname",
")",
")",
")",
"{",
"return",
"$",
"this",
"->... | Check the target.
@return Result | [
"Check",
"the",
"target",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/PortCheck.php#L14-L25 |
antonioribeiro/health | src/Checkers/PortCheck.php | PortCheck.makeFinalResult | protected function makeFinalResult($ipAddress)
{
return $this->target->setResult(
$this->makeResult(
false,
sprintf(
$this->target->getErrorMessage(),
$this->hosnameAndIp($this->target->hostname, $ipAddress),
... | php | protected function makeFinalResult($ipAddress)
{
return $this->target->setResult(
$this->makeResult(
false,
sprintf(
$this->target->getErrorMessage(),
$this->hosnameAndIp($this->target->hostname, $ipAddress),
... | [
"protected",
"function",
"makeFinalResult",
"(",
"$",
"ipAddress",
")",
"{",
"return",
"$",
"this",
"->",
"target",
"->",
"setResult",
"(",
"$",
"this",
"->",
"makeResult",
"(",
"false",
",",
"sprintf",
"(",
"$",
"this",
"->",
"target",
"->",
"getErrorMess... | Make the result.
@param bool $ipAddress
@return Result | [
"Make",
"the",
"result",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/PortCheck.php#L44-L56 |
antonioribeiro/health | src/Support/Traits/ToArray.php | ToArray.__toArray | public function __toArray($subject, $maxDepth = 3)
{
static::$__depth = 0;
static::$__maxDepth = $maxDepth;
return $this->___toArray($subject, $maxDepth);
} | php | public function __toArray($subject, $maxDepth = 3)
{
static::$__depth = 0;
static::$__maxDepth = $maxDepth;
return $this->___toArray($subject, $maxDepth);
} | [
"public",
"function",
"__toArray",
"(",
"$",
"subject",
",",
"$",
"maxDepth",
"=",
"3",
")",
"{",
"static",
"::",
"$",
"__depth",
"=",
"0",
";",
"static",
"::",
"$",
"__maxDepth",
"=",
"$",
"maxDepth",
";",
"return",
"$",
"this",
"->",
"___toArray",
... | Reset depth and convert object to array.
@param $subject
@param int $maxDepth
@return array|null | [
"Reset",
"depth",
"and",
"convert",
"object",
"to",
"array",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Traits/ToArray.php#L20-L27 |
antonioribeiro/health | src/Support/Traits/ToArray.php | ToArray.__getToArrayCallBack | public function __getToArrayCallBack()
{
return function ($subject) {
static::$__depth++;
if ($subject instanceof Arrayable) {
$subject = $subject->toArray();
}
if (is_object($subject)) {
$subject = get_object_vars($subject);
... | php | public function __getToArrayCallBack()
{
return function ($subject) {
static::$__depth++;
if ($subject instanceof Arrayable) {
$subject = $subject->toArray();
}
if (is_object($subject)) {
$subject = get_object_vars($subject);
... | [
"public",
"function",
"__getToArrayCallBack",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"subject",
")",
"{",
"static",
"::",
"$",
"__depth",
"++",
";",
"if",
"(",
"$",
"subject",
"instanceof",
"Arrayable",
")",
"{",
"$",
"subject",
"=",
"$",
"subjec... | Generate a callback to transform object to array.
@return \Closure | [
"Generate",
"a",
"callback",
"to",
"transform",
"object",
"to",
"array",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Support/Traits/ToArray.php#L47-L75 |
antonioribeiro/health | src/Checkers/Broadcasting.php | Broadcasting.check | public function check()
{
$this->loadDatabase();
$this->bootRouter();
$isHealthy = ! $this->pingTimedout();
$this->createPing();
$this->dispatchEvent();
return $this->makeResult($isHealthy, $this->target->getErrorMessage());
} | php | public function check()
{
$this->loadDatabase();
$this->bootRouter();
$isHealthy = ! $this->pingTimedout();
$this->createPing();
$this->dispatchEvent();
return $this->makeResult($isHealthy, $this->target->getErrorMessage());
} | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"this",
"->",
"loadDatabase",
"(",
")",
";",
"$",
"this",
"->",
"bootRouter",
"(",
")",
";",
"$",
"isHealthy",
"=",
"!",
"$",
"this",
"->",
"pingTimedout",
"(",
")",
";",
"$",
"this",
"->",
"create... | Check resource.
@return Result | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Broadcasting.php#L27-L40 |
antonioribeiro/health | src/Checkers/Broadcasting.php | Broadcasting.dispatchEvent | protected function dispatchEvent()
{
event(
new HealthPing(
$this->target->channel,
route($this->target->routeName, [$this->target->secret]),
$this->target
)
);
} | php | protected function dispatchEvent()
{
event(
new HealthPing(
$this->target->channel,
route($this->target->routeName, [$this->target->secret]),
$this->target
)
);
} | [
"protected",
"function",
"dispatchEvent",
"(",
")",
"{",
"event",
"(",
"new",
"HealthPing",
"(",
"$",
"this",
"->",
"target",
"->",
"channel",
",",
"route",
"(",
"$",
"this",
"->",
"target",
"->",
"routeName",
",",
"[",
"$",
"this",
"->",
"target",
"->... | Dispatch event. | [
"Dispatch",
"event",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Broadcasting.php#L45-L54 |
antonioribeiro/health | src/Checkers/Broadcasting.php | Broadcasting.pong | public function pong($secret)
{
$this->database = $this->database->map(function ($item) use ($secret) {
if ($item['secret'] == $secret) {
$item['ponged_at'] = Carbon::now();
}
return $item;
});
$this->persist();
} | php | public function pong($secret)
{
$this->database = $this->database->map(function ($item) use ($secret) {
if ($item['secret'] == $secret) {
$item['ponged_at'] = Carbon::now();
}
return $item;
});
$this->persist();
} | [
"public",
"function",
"pong",
"(",
"$",
"secret",
")",
"{",
"$",
"this",
"->",
"database",
"=",
"$",
"this",
"->",
"database",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"secret",
")",
"{",
"if",
"(",
"$",
"item",
"[",
... | Create and persist pong.
@param $secret | [
"Create",
"and",
"persist",
"pong",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Broadcasting.php#L96-L107 |
antonioribeiro/health | src/Checkers/Broadcasting.php | Broadcasting.pingTimedout | protected function pingTimedout()
{
$timedout = false;
$this->database = $this->database->filter(function ($item) use (
&$timedout
) {
if (! $item['ponged_at']) {
if (
Carbon::now()->diffInSeconds(
$this->pa... | php | protected function pingTimedout()
{
$timedout = false;
$this->database = $this->database->filter(function ($item) use (
&$timedout
) {
if (! $item['ponged_at']) {
if (
Carbon::now()->diffInSeconds(
$this->pa... | [
"protected",
"function",
"pingTimedout",
"(",
")",
"{",
"$",
"timedout",
"=",
"false",
";",
"$",
"this",
"->",
"database",
"=",
"$",
"this",
"->",
"database",
"->",
"filter",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"&",
"$",
"timedout",
"... | Check if a ping timed out.
@return bool | [
"Check",
"if",
"a",
"ping",
"timed",
"out",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Broadcasting.php#L114-L139 |
antonioribeiro/health | src/Checkers/Mail.php | Mail.checkMail | private function checkMail()
{
$this->configureMail();
try {
$this->sendMail();
$result = $this->makeHealthyResult();
} catch (\Exception $exception) {
report($exception);
$result = $this->makeResultFromException($exception);
}
... | php | private function checkMail()
{
$this->configureMail();
try {
$this->sendMail();
$result = $this->makeHealthyResult();
} catch (\Exception $exception) {
report($exception);
$result = $this->makeResultFromException($exception);
}
... | [
"private",
"function",
"checkMail",
"(",
")",
"{",
"$",
"this",
"->",
"configureMail",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"sendMail",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"makeHealthyResult",
"(",
")",
";",
"}",
"catch",
... | Send a test e-mail. | [
"Send",
"a",
"test",
"e",
"-",
"mail",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Mail.php#L40-L57 |
antonioribeiro/health | src/Checkers/Mail.php | Mail.sendMail | private function sendMail()
{
IlluminateMail::send($this->target->view, [], function ($message) {
$fromAddress = array_get($this->target->config, 'from.address');
$message->returnPath($fromAddress);
$message->cc($fromAddress);
$message->bcc($fromAddress);
... | php | private function sendMail()
{
IlluminateMail::send($this->target->view, [], function ($message) {
$fromAddress = array_get($this->target->config, 'from.address');
$message->returnPath($fromAddress);
$message->cc($fromAddress);
$message->bcc($fromAddress);
... | [
"private",
"function",
"sendMail",
"(",
")",
"{",
"IlluminateMail",
"::",
"send",
"(",
"$",
"this",
"->",
"target",
"->",
"view",
",",
"[",
"]",
",",
"function",
"(",
"$",
"message",
")",
"{",
"$",
"fromAddress",
"=",
"array_get",
"(",
"$",
"this",
"... | Send a test e-mail message. | [
"Send",
"a",
"test",
"e",
"-",
"mail",
"message",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Mail.php#L70-L87 |
antonioribeiro/health | src/Notifications/HealthStatus.php | HealthStatus.toSlack | public function toSlack($notifiable)
{
return (new SlackMessage())
->error()
->from(
config('health.notifications.from.name'),
config('health.notifications.from.icon_emoji')
)
->content($this->getMessage())
->attachm... | php | public function toSlack($notifiable)
{
return (new SlackMessage())
->error()
->from(
config('health.notifications.from.name'),
config('health.notifications.from.icon_emoji')
)
->content($this->getMessage())
->attachm... | [
"public",
"function",
"toSlack",
"(",
"$",
"notifiable",
")",
"{",
"return",
"(",
"new",
"SlackMessage",
"(",
")",
")",
"->",
"error",
"(",
")",
"->",
"from",
"(",
"config",
"(",
"'health.notifications.from.name'",
")",
",",
"config",
"(",
"'health.notificat... | Create Slack message.
@param $notifiable
@return SlackMessage | [
"Create",
"Slack",
"message",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Notifications/HealthStatus.php#L97-L111 |
antonioribeiro/health | src/Notifications/HealthStatus.php | HealthStatus.toMail | public function toMail($notifiable)
{
return (new MailMessage())
->line($this->getMessage($notifiable))
->from(
config('health.notifications.from.address'),
config('health.notifications.from.name')
)
->action($this->getActionTit... | php | public function toMail($notifiable)
{
return (new MailMessage())
->line($this->getMessage($notifiable))
->from(
config('health.notifications.from.address'),
config('health.notifications.from.name')
)
->action($this->getActionTit... | [
"public",
"function",
"toMail",
"(",
"$",
"notifiable",
")",
"{",
"return",
"(",
"new",
"MailMessage",
"(",
")",
")",
"->",
"line",
"(",
"$",
"this",
"->",
"getMessage",
"(",
"$",
"notifiable",
")",
")",
"->",
"from",
"(",
"config",
"(",
"'health.notif... | Create Mail message.
@param $notifiable
@return MailMessage | [
"Create",
"Mail",
"message",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Notifications/HealthStatus.php#L119-L128 |
antonioribeiro/health | src/Notifications/HealthStatus.php | HealthStatus.getMessage | protected function getMessage()
{
$domain = Request::server('SERVER_NAME');
return sprintf(
$this->getActionMessage($this),
studly_case($this->resource->name),
$domain ? " in {$domain}." : '.'
);
} | php | protected function getMessage()
{
$domain = Request::server('SERVER_NAME');
return sprintf(
$this->getActionMessage($this),
studly_case($this->resource->name),
$domain ? " in {$domain}." : '.'
);
} | [
"protected",
"function",
"getMessage",
"(",
")",
"{",
"$",
"domain",
"=",
"Request",
"::",
"server",
"(",
"'SERVER_NAME'",
")",
";",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"getActionMessage",
"(",
"$",
"this",
")",
",",
"studly_case",
"(",
"$",
"th... | Get failing message.
@return string | [
"Get",
"failing",
"message",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Notifications/HealthStatus.php#L158-L167 |
antonioribeiro/health | src/Checkers/Artisan.php | Artisan.check | public function check()
{
return $this->executeAndCheck()
? $this->makeHealthyResult()
: $this->makeResult(false, $this->target->getErrorMessage());
} | php | public function check()
{
return $this->executeAndCheck()
? $this->makeHealthyResult()
: $this->makeResult(false, $this->target->getErrorMessage());
} | [
"public",
"function",
"check",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"executeAndCheck",
"(",
")",
"?",
"$",
"this",
"->",
"makeHealthyResult",
"(",
")",
":",
"$",
"this",
"->",
"makeResult",
"(",
"false",
",",
"$",
"this",
"->",
"target",
"->",
... | Check resource.
@return bool | [
"Check",
"resource",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Checkers/Artisan.php#L14-L19 |
antonioribeiro/health | src/Listeners/NotifyHealthIssue.php | NotifyHealthIssue.handle | public function handle(RaiseHealthIssue $event)
{
try {
$event->failure->targets->each(function ($target) use ($event) {
if (! $target->result->healthy) {
Notification::send(
$this->getNotifiableUsers(),
new Heal... | php | public function handle(RaiseHealthIssue $event)
{
try {
$event->failure->targets->each(function ($target) use ($event) {
if (! $target->result->healthy) {
Notification::send(
$this->getNotifiableUsers(),
new Heal... | [
"public",
"function",
"handle",
"(",
"RaiseHealthIssue",
"$",
"event",
")",
"{",
"try",
"{",
"$",
"event",
"->",
"failure",
"->",
"targets",
"->",
"each",
"(",
"function",
"(",
"$",
"target",
")",
"use",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"!",
... | Handle the event.
@param RaiseHealthIssue $event
@return void | [
"Handle",
"the",
"event",
"."
] | train | https://github.com/antonioribeiro/health/blob/ad5be8c18a5599cd874af7ad97bdc63c4f3709fc/src/Listeners/NotifyHealthIssue.php#L35-L51 |
ErickTamayo/laravel-scout-elastic | src/ElasticsearchProvider.php | ElasticsearchProvider.boot | public function boot()
{
app(EngineManager::class)->extend('elasticsearch', function($app) {
return new ElasticsearchEngine(ElasticBuilder::create()
->setHosts(config('scout.elasticsearch.hosts'))
->build(),
config('scout.elasticsearch.index')
... | php | public function boot()
{
app(EngineManager::class)->extend('elasticsearch', function($app) {
return new ElasticsearchEngine(ElasticBuilder::create()
->setHosts(config('scout.elasticsearch.hosts'))
->build(),
config('scout.elasticsearch.index')
... | [
"public",
"function",
"boot",
"(",
")",
"{",
"app",
"(",
"EngineManager",
"::",
"class",
")",
"->",
"extend",
"(",
"'elasticsearch'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"ElasticsearchEngine",
"(",
"ElasticBuilder",
"::",
"create",
... | Bootstrap the application services. | [
"Bootstrap",
"the",
"application",
"services",
"."
] | train | https://github.com/ErickTamayo/laravel-scout-elastic/blob/fb5b843c0091972153cf36e009d53a631b2ec9da/src/ElasticsearchProvider.php#L14-L23 |
ErickTamayo/laravel-scout-elastic | src/ElasticsearchEngine.php | ElasticsearchEngine.update | public function update($models)
{
$params['body'] = [];
$models->each(function($model) use (&$params)
{
$params['body'][] = [
'update' => [
'_id' => $model->getKey(),
'_index' => $this->index,
'_type' =>... | php | public function update($models)
{
$params['body'] = [];
$models->each(function($model) use (&$params)
{
$params['body'][] = [
'update' => [
'_id' => $model->getKey(),
'_index' => $this->index,
'_type' =>... | [
"public",
"function",
"update",
"(",
"$",
"models",
")",
"{",
"$",
"params",
"[",
"'body'",
"]",
"=",
"[",
"]",
";",
"$",
"models",
"->",
"each",
"(",
"function",
"(",
"$",
"model",
")",
"use",
"(",
"&",
"$",
"params",
")",
"{",
"$",
"params",
... | Update the given model in the index.
@param Collection $models
@return void | [
"Update",
"the",
"given",
"model",
"in",
"the",
"index",
"."
] | train | https://github.com/ErickTamayo/laravel-scout-elastic/blob/fb5b843c0091972153cf36e009d53a631b2ec9da/src/ElasticsearchEngine.php#L45-L65 |
ErickTamayo/laravel-scout-elastic | src/ElasticsearchEngine.php | ElasticsearchEngine.delete | public function delete($models)
{
$params['body'] = [];
$models->each(function($model) use (&$params)
{
$params['body'][] = [
'delete' => [
'_id' => $model->getKey(),
'_index' => $this->index,
'_type' =>... | php | public function delete($models)
{
$params['body'] = [];
$models->each(function($model) use (&$params)
{
$params['body'][] = [
'delete' => [
'_id' => $model->getKey(),
'_index' => $this->index,
'_type' =>... | [
"public",
"function",
"delete",
"(",
"$",
"models",
")",
"{",
"$",
"params",
"[",
"'body'",
"]",
"=",
"[",
"]",
";",
"$",
"models",
"->",
"each",
"(",
"function",
"(",
"$",
"model",
")",
"use",
"(",
"&",
"$",
"params",
")",
"{",
"$",
"params",
... | Remove the given model from the index.
@param Collection $models
@return void | [
"Remove",
"the",
"given",
"model",
"from",
"the",
"index",
"."
] | train | https://github.com/ErickTamayo/laravel-scout-elastic/blob/fb5b843c0091972153cf36e009d53a631b2ec9da/src/ElasticsearchEngine.php#L73-L89 |
ErickTamayo/laravel-scout-elastic | src/ElasticsearchEngine.php | ElasticsearchEngine.paginate | public function paginate(Builder $builder, $perPage, $page)
{
$result = $this->performSearch($builder, [
'numericFilters' => $this->filters($builder),
'from' => (($page * $perPage) - $perPage),
'size' => $perPage,
]);
$result['nbPages'] = $result['hits']['... | php | public function paginate(Builder $builder, $perPage, $page)
{
$result = $this->performSearch($builder, [
'numericFilters' => $this->filters($builder),
'from' => (($page * $perPage) - $perPage),
'size' => $perPage,
]);
$result['nbPages'] = $result['hits']['... | [
"public",
"function",
"paginate",
"(",
"Builder",
"$",
"builder",
",",
"$",
"perPage",
",",
"$",
"page",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"performSearch",
"(",
"$",
"builder",
",",
"[",
"'numericFilters'",
"=>",
"$",
"this",
"->",
"filt... | Perform the given search on the engine.
@param Builder $builder
@param int $perPage
@param int $page
@return mixed | [
"Perform",
"the",
"given",
"search",
"on",
"the",
"engine",
"."
] | train | https://github.com/ErickTamayo/laravel-scout-elastic/blob/fb5b843c0091972153cf36e009d53a631b2ec9da/src/ElasticsearchEngine.php#L113-L124 |
ErickTamayo/laravel-scout-elastic | src/ElasticsearchEngine.php | ElasticsearchEngine.performSearch | protected function performSearch(Builder $builder, array $options = [])
{
$params = [
'index' => $this->index,
'type' => $builder->index ?: $builder->model->searchableAs(),
'body' => [
'query' => [
'bool' => [
'm... | php | protected function performSearch(Builder $builder, array $options = [])
{
$params = [
'index' => $this->index,
'type' => $builder->index ?: $builder->model->searchableAs(),
'body' => [
'query' => [
'bool' => [
'm... | [
"protected",
"function",
"performSearch",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"[",
"'index'",
"=>",
"$",
"this",
"->",
"index",
",",
"'type'",
"=>",
"$",
"builder",
"->",
"index",
... | Perform the given search on the engine.
@param Builder $builder
@param array $options
@return mixed | [
"Perform",
"the",
"given",
"search",
"on",
"the",
"engine",
"."
] | train | https://github.com/ErickTamayo/laravel-scout-elastic/blob/fb5b843c0091972153cf36e009d53a631b2ec9da/src/ElasticsearchEngine.php#L133-L174 |
ErickTamayo/laravel-scout-elastic | src/ElasticsearchEngine.php | ElasticsearchEngine.map | public function map(Builder $builder, $results, $model)
{
if ($results['hits']['total'] === 0) {
return Collection::make();
}
$keys = collect($results['hits']['hits'])
->pluck('_id')->values()->all();
$models = $model->getScoutModelsByIds(
... | php | public function map(Builder $builder, $results, $model)
{
if ($results['hits']['total'] === 0) {
return Collection::make();
}
$keys = collect($results['hits']['hits'])
->pluck('_id')->values()->all();
$models = $model->getScoutModelsByIds(
... | [
"public",
"function",
"map",
"(",
"Builder",
"$",
"builder",
",",
"$",
"results",
",",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"results",
"[",
"'hits'",
"]",
"[",
"'total'",
"]",
"===",
"0",
")",
"{",
"return",
"Collection",
"::",
"make",
"(",
")",... | Map the given results to instances of the given model.
@param \Laravel\Scout\Builder $builder
@param mixed $results
@param \Illuminate\Database\Eloquent\Model $model
@return Collection | [
"Map",
"the",
"given",
"results",
"to",
"instances",
"of",
"the",
"given",
"model",
"."
] | train | https://github.com/ErickTamayo/laravel-scout-elastic/blob/fb5b843c0091972153cf36e009d53a631b2ec9da/src/ElasticsearchEngine.php#L212-L230 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.