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 |
|---|---|---|---|---|---|---|---|---|---|---|
theofidry/AliceDataFixtures | src/Loader/PurgerLoader.php | PurgerLoader.load | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
if (null === $purgeMode) {
$purgeMode = $this->defaultPurgeMode;
}
if ($purgeMode != PurgeMode::createNoPurgeMode()) {
$this->logger->info(
sprintf(
'Purging database with purge mode "%s".',
(string) $purgeMode
)
);
$purger = $this->purgerFactory->create($purgeMode);
$purger->purge();
}
return $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode);
} | php | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
if (null === $purgeMode) {
$purgeMode = $this->defaultPurgeMode;
}
if ($purgeMode != PurgeMode::createNoPurgeMode()) {
$this->logger->info(
sprintf(
'Purging database with purge mode "%s".',
(string) $purgeMode
)
);
$purger = $this->purgerFactory->create($purgeMode);
$purger->purge();
}
return $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"fixturesFiles",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"objects",
"=",
"[",
"]",
",",
"PurgeMode",
"$",
"purgeMode",
"=",
"null",
")",
":",
"array",
"{",
"if",
"(",
"null",... | Pre process, persist and post process each object loaded.
{@inheritdoc} | [
"Pre",
"process",
"persist",
"and",
"post",
"process",
"each",
"object",
"loaded",
"."
] | train | https://github.com/theofidry/AliceDataFixtures/blob/6fac234c054f053e3b1de66f00d7cb3c6f6d3058/src/Loader/PurgerLoader.php#L101-L120 |
theofidry/AliceDataFixtures | src/Exception/MaxPassReachedException.php | MaxPassReachedException.createForLimit | public static function createForLimit(
int $limit,
FileTracker $fileTracker,
ErrorTracker $errorTracker,
int $code = 0,
Throwable $previous = null
) {
return new static(
static::createMessage($limit, $fileTracker, $errorTracker),
$code,
$previous,
$errorTracker
);
} | php | public static function createForLimit(
int $limit,
FileTracker $fileTracker,
ErrorTracker $errorTracker,
int $code = 0,
Throwable $previous = null
) {
return new static(
static::createMessage($limit, $fileTracker, $errorTracker),
$code,
$previous,
$errorTracker
);
} | [
"public",
"static",
"function",
"createForLimit",
"(",
"int",
"$",
"limit",
",",
"FileTracker",
"$",
"fileTracker",
",",
"ErrorTracker",
"$",
"errorTracker",
",",
"int",
"$",
"code",
"=",
"0",
",",
"Throwable",
"$",
"previous",
"=",
"null",
")",
"{",
"retu... | @param int $limit
@param FileTracker $fileTracker
@param ErrorTracker $errorTracker
@param int $code
@param Throwable|null $previous
@return static | [
"@param",
"int",
"$limit",
"@param",
"FileTracker",
"$fileTracker",
"@param",
"ErrorTracker",
"$errorTracker",
"@param",
"int",
"$code",
"@param",
"Throwable|null",
"$previous"
] | train | https://github.com/theofidry/AliceDataFixtures/blob/6fac234c054f053e3b1de66f00d7cb3c6f6d3058/src/Exception/MaxPassReachedException.php#L54-L67 |
theofidry/AliceDataFixtures | src/Loader/FileResolverLoader.php | FileResolverLoader.load | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
$this->logger->info('Resolving fixture files.');
$fixturesFiles = $this->fileResolver->resolve($fixturesFiles);
return $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode);
} | php | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
$this->logger->info('Resolving fixture files.');
$fixturesFiles = $this->fileResolver->resolve($fixturesFiles);
return $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"fixturesFiles",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"objects",
"=",
"[",
"]",
",",
"PurgeMode",
"$",
"purgeMode",
"=",
"null",
")",
":",
"array",
"{",
"$",
"this",
"->",... | Resolves the given files before loading them.
{@inheritdoc} | [
"Resolves",
"the",
"given",
"files",
"before",
"loading",
"them",
"."
] | train | https://github.com/theofidry/AliceDataFixtures/blob/6fac234c054f053e3b1de66f00d7cb3c6f6d3058/src/Loader/FileResolverLoader.php#L67-L74 |
theofidry/AliceDataFixtures | src/Loader/MultiPassLoader.php | MultiPassLoader.load | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
$errorTracker = new ErrorTracker();
$filesTracker = new FileTracker(...$fixturesFiles);
$attempts = 0;
$set = new ObjectSet(
new ParameterBag($parameters),
new ObjectBag($objects)
);
while (true) {
$set = $this->tryToLoadFiles($filesTracker, $errorTracker, $set);
if ($filesTracker->allFilesHaveBeenLoaded()) {
break;
}
if ($this->maxPass <= $attempts) {
throw MaxPassReachedException::createForLimit($this->maxPass, $filesTracker, $errorTracker);
}
++$attempts;
}
return $set->getObjects();
} | php | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
$errorTracker = new ErrorTracker();
$filesTracker = new FileTracker(...$fixturesFiles);
$attempts = 0;
$set = new ObjectSet(
new ParameterBag($parameters),
new ObjectBag($objects)
);
while (true) {
$set = $this->tryToLoadFiles($filesTracker, $errorTracker, $set);
if ($filesTracker->allFilesHaveBeenLoaded()) {
break;
}
if ($this->maxPass <= $attempts) {
throw MaxPassReachedException::createForLimit($this->maxPass, $filesTracker, $errorTracker);
}
++$attempts;
}
return $set->getObjects();
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"fixturesFiles",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"objects",
"=",
"[",
"]",
",",
"PurgeMode",
"$",
"purgeMode",
"=",
"null",
")",
":",
"array",
"{",
"$",
"errorTracker",... | Try to load the set of files in multiple passes by loading as many files as possible. The result of each loading
is passed to the next. After the first pass, if some files could not be reloaded, another attempt is made until
all files are loaded or the maximum number of pass is reached.
{@inheritdoc}
@throws MaxPassReachedException | [
"Try",
"to",
"load",
"the",
"set",
"of",
"files",
"in",
"multiple",
"passes",
"by",
"loading",
"as",
"many",
"files",
"as",
"possible",
".",
"The",
"result",
"of",
"each",
"loading",
"is",
"passed",
"to",
"the",
"next",
".",
"After",
"the",
"first",
"p... | train | https://github.com/theofidry/AliceDataFixtures/blob/6fac234c054f053e3b1de66f00d7cb3c6f6d3058/src/Loader/MultiPassLoader.php#L66-L88 |
theofidry/AliceDataFixtures | src/Loader/PersisterLoader.php | PersisterLoader.load | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
$objects = $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode);
$this->logger->info('Pre-processing objects.');
foreach ($objects as $id => $object) {
foreach ($this->processors as $processor) {
$processor->preProcess($id, $object);
}
$this->persister->persist($object);
}
$this->logger->info('Flushing objects.');
$this->persister->flush();
$this->logger->info('Post-processing objects.');
foreach ($objects as $id => $object) {
foreach ($this->processors as $processor) {
$processor->postProcess($id, $object);
}
}
$this->logger->info('Done.');
return $objects;
} | php | public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
{
$objects = $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode);
$this->logger->info('Pre-processing objects.');
foreach ($objects as $id => $object) {
foreach ($this->processors as $processor) {
$processor->preProcess($id, $object);
}
$this->persister->persist($object);
}
$this->logger->info('Flushing objects.');
$this->persister->flush();
$this->logger->info('Post-processing objects.');
foreach ($objects as $id => $object) {
foreach ($this->processors as $processor) {
$processor->postProcess($id, $object);
}
}
$this->logger->info('Done.');
return $objects;
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"fixturesFiles",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"objects",
"=",
"[",
"]",
",",
"PurgeMode",
"$",
"purgeMode",
"=",
"null",
")",
":",
"array",
"{",
"$",
"objects",
"=... | Pre process, persist and post process each object loaded.
{@inheritdoc} | [
"Pre",
"process",
"persist",
"and",
"post",
"process",
"each",
"object",
"loaded",
"."
] | train | https://github.com/theofidry/AliceDataFixtures/blob/6fac234c054f053e3b1de66f00d7cb3c6f6d3058/src/Loader/PersisterLoader.php#L81-L110 |
theofidry/AliceDataFixtures | src/Bridge/Symfony/DependencyInjection/FidryAliceDataFixturesExtension.php | FidryAliceDataFixturesExtension.registerConfig | private function registerConfig(
string $driver,
string $bundle,
array $bundles,
array $configs,
LoaderInterface $loader
) {
/** @var bool|null $isEnabled */
$isEnabled = $configs['db_drivers'][$driver];
if (false === $isEnabled) {
return;
}
$bundleIsRegistered = array_key_exists($bundle, $bundles);
if ($isEnabled && false === $bundleIsRegistered) {
throw new LogicException(
sprintf(
'Cannot enable "%s" driver as the bundle "%s" is missing',
$driver,
$bundle
)
);
}
if ($bundleIsRegistered) {
$loader->load($driver.'.xml');
}
} | php | private function registerConfig(
string $driver,
string $bundle,
array $bundles,
array $configs,
LoaderInterface $loader
) {
/** @var bool|null $isEnabled */
$isEnabled = $configs['db_drivers'][$driver];
if (false === $isEnabled) {
return;
}
$bundleIsRegistered = array_key_exists($bundle, $bundles);
if ($isEnabled && false === $bundleIsRegistered) {
throw new LogicException(
sprintf(
'Cannot enable "%s" driver as the bundle "%s" is missing',
$driver,
$bundle
)
);
}
if ($bundleIsRegistered) {
$loader->load($driver.'.xml');
}
} | [
"private",
"function",
"registerConfig",
"(",
"string",
"$",
"driver",
",",
"string",
"$",
"bundle",
",",
"array",
"$",
"bundles",
",",
"array",
"$",
"configs",
",",
"LoaderInterface",
"$",
"loader",
")",
"{",
"/** @var bool|null $isEnabled */",
"$",
"isEnabled"... | Registers driver configuration.
@param string $driver The driver name to register (doctrine_orm, eloquent_orm, ...).
@param string $bundle The bundle that should be checked for existence.
@param Bundle[] $bundles The bundles registered in current kernel.
@param array $configs The processed config array.
@param LoaderInterface $loader Config file loader | [
"Registers",
"driver",
"configuration",
"."
] | train | https://github.com/theofidry/AliceDataFixtures/blob/6fac234c054f053e3b1de66f00d7cb3c6f6d3058/src/Bridge/Symfony/DependencyInjection/FidryAliceDataFixturesExtension.php#L82-L109 |
true/php-punycode | src/Punycode.php | Punycode.encode | public function encode($input)
{
$input = mb_strtolower($input, $this->encoding);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$length = strlen($part);
if ($length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
$part = $this->encodePart($part);
}
$output = implode('.', $parts);
$length = strlen($output);
if ($length > 255) {
throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
}
return $output;
} | php | public function encode($input)
{
$input = mb_strtolower($input, $this->encoding);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$length = strlen($part);
if ($length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
$part = $this->encodePart($part);
}
$output = implode('.', $parts);
$length = strlen($output);
if ($length > 255) {
throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
}
return $output;
} | [
"public",
"function",
"encode",
"(",
"$",
"input",
")",
"{",
"$",
"input",
"=",
"mb_strtolower",
"(",
"$",
"input",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"input",
")",
";",
"foreach",
"(",... | Encode a domain to its Punycode version
@param string $input Domain name in Unicode to be encoded
@return string Punycode representation in ASCII | [
"Encode",
"a",
"domain",
"to",
"its",
"Punycode",
"version"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L77-L95 |
true/php-punycode | src/Punycode.php | Punycode.decode | public function decode($input)
{
$input = strtolower($input);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$length = strlen($part);
if ($length > 63 || $length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
if (strpos($part, static::PREFIX) !== 0) {
continue;
}
$part = substr($part, strlen(static::PREFIX));
$part = $this->decodePart($part);
}
$output = implode('.', $parts);
$length = strlen($output);
if ($length > 255) {
throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
}
return $output;
} | php | public function decode($input)
{
$input = strtolower($input);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$length = strlen($part);
if ($length > 63 || $length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
if (strpos($part, static::PREFIX) !== 0) {
continue;
}
$part = substr($part, strlen(static::PREFIX));
$part = $this->decodePart($part);
}
$output = implode('.', $parts);
$length = strlen($output);
if ($length > 255) {
throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
}
return $output;
} | [
"public",
"function",
"decode",
"(",
"$",
"input",
")",
"{",
"$",
"input",
"=",
"strtolower",
"(",
"$",
"input",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"input",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"&",
"$",
"part"... | Decode a Punycode domain name to its Unicode counterpart
@param string $input Domain name in Punycode
@return string Unicode domain name | [
"Decode",
"a",
"Punycode",
"domain",
"name",
"to",
"its",
"Unicode",
"counterpart"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L176-L199 |
true/php-punycode | src/Punycode.php | Punycode.decodePart | protected function decodePart($input)
{
$n = static::INITIAL_N;
$i = 0;
$bias = static::INITIAL_BIAS;
$output = '';
$pos = strrpos($input, static::DELIMITER);
if ($pos !== false) {
$output = substr($input, 0, $pos++);
} else {
$pos = 0;
}
$outputLength = strlen($output);
$inputLength = strlen($input);
while ($pos < $inputLength) {
$oldi = $i;
$w = 1;
for ($k = static::BASE;; $k += static::BASE) {
$digit = static::$decodeTable[$input[$pos++]];
$i = $i + ($digit * $w);
$t = $this->calculateThreshold($k, $bias);
if ($digit < $t) {
break;
}
$w = $w * (static::BASE - $t);
}
$bias = $this->adapt($i - $oldi, ++$outputLength, ($oldi === 0));
$n = $n + (int) ($i / $outputLength);
$i = $i % ($outputLength);
$output = mb_substr($output, 0, $i, $this->encoding) . $this->codePointToChar($n) . mb_substr($output, $i, $outputLength - 1, $this->encoding);
$i++;
}
return $output;
} | php | protected function decodePart($input)
{
$n = static::INITIAL_N;
$i = 0;
$bias = static::INITIAL_BIAS;
$output = '';
$pos = strrpos($input, static::DELIMITER);
if ($pos !== false) {
$output = substr($input, 0, $pos++);
} else {
$pos = 0;
}
$outputLength = strlen($output);
$inputLength = strlen($input);
while ($pos < $inputLength) {
$oldi = $i;
$w = 1;
for ($k = static::BASE;; $k += static::BASE) {
$digit = static::$decodeTable[$input[$pos++]];
$i = $i + ($digit * $w);
$t = $this->calculateThreshold($k, $bias);
if ($digit < $t) {
break;
}
$w = $w * (static::BASE - $t);
}
$bias = $this->adapt($i - $oldi, ++$outputLength, ($oldi === 0));
$n = $n + (int) ($i / $outputLength);
$i = $i % ($outputLength);
$output = mb_substr($output, 0, $i, $this->encoding) . $this->codePointToChar($n) . mb_substr($output, $i, $outputLength - 1, $this->encoding);
$i++;
}
return $output;
} | [
"protected",
"function",
"decodePart",
"(",
"$",
"input",
")",
"{",
"$",
"n",
"=",
"static",
"::",
"INITIAL_N",
";",
"$",
"i",
"=",
"0",
";",
"$",
"bias",
"=",
"static",
"::",
"INITIAL_BIAS",
";",
"$",
"output",
"=",
"''",
";",
"$",
"pos",
"=",
"... | Decode a part of domain name, such as tld
@param string $input Part of a domain name
@return string Unicode domain part | [
"Decode",
"a",
"part",
"of",
"domain",
"name",
"such",
"as",
"tld"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L207-L248 |
true/php-punycode | src/Punycode.php | Punycode.calculateThreshold | protected function calculateThreshold($k, $bias)
{
if ($k <= $bias + static::TMIN) {
return static::TMIN;
} elseif ($k >= $bias + static::TMAX) {
return static::TMAX;
}
return $k - $bias;
} | php | protected function calculateThreshold($k, $bias)
{
if ($k <= $bias + static::TMIN) {
return static::TMIN;
} elseif ($k >= $bias + static::TMAX) {
return static::TMAX;
}
return $k - $bias;
} | [
"protected",
"function",
"calculateThreshold",
"(",
"$",
"k",
",",
"$",
"bias",
")",
"{",
"if",
"(",
"$",
"k",
"<=",
"$",
"bias",
"+",
"static",
"::",
"TMIN",
")",
"{",
"return",
"static",
"::",
"TMIN",
";",
"}",
"elseif",
"(",
"$",
"k",
">=",
"$... | Calculate the bias threshold to fall between TMIN and TMAX
@param integer $k
@param integer $bias
@return integer | [
"Calculate",
"the",
"bias",
"threshold",
"to",
"fall",
"between",
"TMIN",
"and",
"TMAX"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L257-L265 |
true/php-punycode | src/Punycode.php | Punycode.adapt | protected function adapt($delta, $numPoints, $firstTime)
{
$delta = (int) (
($firstTime)
? $delta / static::DAMP
: $delta / 2
);
$delta += (int) ($delta / $numPoints);
$k = 0;
while ($delta > ((static::BASE - static::TMIN) * static::TMAX) / 2) {
$delta = (int) ($delta / (static::BASE - static::TMIN));
$k = $k + static::BASE;
}
$k = $k + (int) (((static::BASE - static::TMIN + 1) * $delta) / ($delta + static::SKEW));
return $k;
} | php | protected function adapt($delta, $numPoints, $firstTime)
{
$delta = (int) (
($firstTime)
? $delta / static::DAMP
: $delta / 2
);
$delta += (int) ($delta / $numPoints);
$k = 0;
while ($delta > ((static::BASE - static::TMIN) * static::TMAX) / 2) {
$delta = (int) ($delta / (static::BASE - static::TMIN));
$k = $k + static::BASE;
}
$k = $k + (int) (((static::BASE - static::TMIN + 1) * $delta) / ($delta + static::SKEW));
return $k;
} | [
"protected",
"function",
"adapt",
"(",
"$",
"delta",
",",
"$",
"numPoints",
",",
"$",
"firstTime",
")",
"{",
"$",
"delta",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"firstTime",
")",
"?",
"$",
"delta",
"/",
"static",
"::",
"DAMP",
":",
"$",
"delta",
"... | Bias adaptation
@param integer $delta
@param integer $numPoints
@param boolean $firstTime
@return integer | [
"Bias",
"adaptation"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L275-L292 |
true/php-punycode | src/Punycode.php | Punycode.listCodePoints | protected function listCodePoints($input)
{
$codePoints = array(
'all' => array(),
'basic' => array(),
'nonBasic' => array(),
);
$length = mb_strlen($input, $this->encoding);
for ($i = 0; $i < $length; $i++) {
$char = mb_substr($input, $i, 1, $this->encoding);
$code = $this->charToCodePoint($char);
if ($code < 128) {
$codePoints['all'][] = $codePoints['basic'][] = $code;
} else {
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
}
}
return $codePoints;
} | php | protected function listCodePoints($input)
{
$codePoints = array(
'all' => array(),
'basic' => array(),
'nonBasic' => array(),
);
$length = mb_strlen($input, $this->encoding);
for ($i = 0; $i < $length; $i++) {
$char = mb_substr($input, $i, 1, $this->encoding);
$code = $this->charToCodePoint($char);
if ($code < 128) {
$codePoints['all'][] = $codePoints['basic'][] = $code;
} else {
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
}
}
return $codePoints;
} | [
"protected",
"function",
"listCodePoints",
"(",
"$",
"input",
")",
"{",
"$",
"codePoints",
"=",
"array",
"(",
"'all'",
"=>",
"array",
"(",
")",
",",
"'basic'",
"=>",
"array",
"(",
")",
",",
"'nonBasic'",
"=>",
"array",
"(",
")",
",",
")",
";",
"$",
... | List code points for a given input
@param string $input
@return array Multi-dimension array with basic, non-basic and aggregated code points | [
"List",
"code",
"points",
"for",
"a",
"given",
"input"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L300-L320 |
true/php-punycode | src/Punycode.php | Punycode.charToCodePoint | protected function charToCodePoint($char)
{
$code = ord($char[0]);
if ($code < 128) {
return $code;
} elseif ($code < 224) {
return (($code - 192) * 64) + (ord($char[1]) - 128);
} elseif ($code < 240) {
return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128);
} else {
return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128);
}
} | php | protected function charToCodePoint($char)
{
$code = ord($char[0]);
if ($code < 128) {
return $code;
} elseif ($code < 224) {
return (($code - 192) * 64) + (ord($char[1]) - 128);
} elseif ($code < 240) {
return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128);
} else {
return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128);
}
} | [
"protected",
"function",
"charToCodePoint",
"(",
"$",
"char",
")",
"{",
"$",
"code",
"=",
"ord",
"(",
"$",
"char",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"code",
"<",
"128",
")",
"{",
"return",
"$",
"code",
";",
"}",
"elseif",
"(",
"$",
"code... | Convert a single or multi-byte character to its code point
@param string $char
@return integer | [
"Convert",
"a",
"single",
"or",
"multi",
"-",
"byte",
"character",
"to",
"its",
"code",
"point"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L328-L340 |
true/php-punycode | src/Punycode.php | Punycode.codePointToChar | protected function codePointToChar($code)
{
if ($code <= 0x7F) {
return chr($code);
} elseif ($code <= 0x7FF) {
return chr(($code >> 6) + 192) . chr(($code & 63) + 128);
} elseif ($code <= 0xFFFF) {
return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
} else {
return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
}
} | php | protected function codePointToChar($code)
{
if ($code <= 0x7F) {
return chr($code);
} elseif ($code <= 0x7FF) {
return chr(($code >> 6) + 192) . chr(($code & 63) + 128);
} elseif ($code <= 0xFFFF) {
return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
} else {
return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
}
} | [
"protected",
"function",
"codePointToChar",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"$",
"code",
"<=",
"0x7F",
")",
"{",
"return",
"chr",
"(",
"$",
"code",
")",
";",
"}",
"elseif",
"(",
"$",
"code",
"<=",
"0x7FF",
")",
"{",
"return",
"chr",
"(",
"... | Convert a code point to its single or multi-byte character
@param integer $code
@return string | [
"Convert",
"a",
"code",
"point",
"to",
"its",
"single",
"or",
"multi",
"-",
"byte",
"character"
] | train | https://github.com/true/php-punycode/blob/a4d0c11a36dd7f4e7cd7096076cab6d3378a071e/src/Punycode.php#L348-L359 |
eyewitness/eye | app/Queue/Handlers/SqsQueue.php | SqsQueue.pendingJobsCount | public function pendingJobsCount($tube)
{
try {
$result = $this->queue->getSqs()->getQueueAttributes([
'QueueUrl' => $this->queue->getQueue($tube),
'AttributeNames' => ['ApproximateNumberOfMessages']
]);
$count = $result['Attributes']['ApproximateNumberOfMessages'];
} catch (SqsException $e) {
$count = 0;
}
return $count;
} | php | public function pendingJobsCount($tube)
{
try {
$result = $this->queue->getSqs()->getQueueAttributes([
'QueueUrl' => $this->queue->getQueue($tube),
'AttributeNames' => ['ApproximateNumberOfMessages']
]);
$count = $result['Attributes']['ApproximateNumberOfMessages'];
} catch (SqsException $e) {
$count = 0;
}
return $count;
} | [
"public",
"function",
"pendingJobsCount",
"(",
"$",
"tube",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"queue",
"->",
"getSqs",
"(",
")",
"->",
"getQueueAttributes",
"(",
"[",
"'QueueUrl'",
"=>",
"$",
"this",
"->",
"queue",
"->",
"get... | Return the number of pending jobs for the tube.
@param string $tube
@return int | [
"Return",
"the",
"number",
"of",
"pending",
"jobs",
"for",
"the",
"tube",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/Handlers/SqsQueue.php#L27-L41 |
eyewitness/eye | app/Commands/Monitors/SslCommand.php | SslCommand.handle | public function handle()
{
if ($this->option('result')) {
$this->eye->ssl()->result();
} else {
$this->eye->ssl()->poll();
}
$this->info('Eyewitness SSL poll complete.');
} | php | public function handle()
{
if ($this->option('result')) {
$this->eye->ssl()->result();
} else {
$this->eye->ssl()->poll();
}
$this->info('Eyewitness SSL poll complete.');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'result'",
")",
")",
"{",
"$",
"this",
"->",
"eye",
"->",
"ssl",
"(",
")",
"->",
"result",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"eye",
... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/Monitors/SslCommand.php#L56-L65 |
eyewitness/eye | app/Http/Controllers/DashboardController.php | DashboardController.index | public function index()
{
return view('eyewitness::dashboard.index')->withEye(app(Eye::class))
->withTransformer(new ChartTransformer)
->withNotifications(History::orderBy('acknowledged')->orderBy('created_at', 'desc')->get())
->withStatuses(Statuses::all())
->withQueues(Queue::all())
->withSchedulers(Scheduler::all());
} | php | public function index()
{
return view('eyewitness::dashboard.index')->withEye(app(Eye::class))
->withTransformer(new ChartTransformer)
->withNotifications(History::orderBy('acknowledged')->orderBy('created_at', 'desc')->get())
->withStatuses(Statuses::all())
->withQueues(Queue::all())
->withSchedulers(Scheduler::all());
} | [
"public",
"function",
"index",
"(",
")",
"{",
"return",
"view",
"(",
"'eyewitness::dashboard.index'",
")",
"->",
"withEye",
"(",
"app",
"(",
"Eye",
"::",
"class",
")",
")",
"->",
"withTransformer",
"(",
"new",
"ChartTransformer",
")",
"->",
"withNotifications"... | The main Eyewitness dashboard.
@return \Illuminate\Http\Response | [
"The",
"main",
"Eyewitness",
"dashboard",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/DashboardController.php#L20-L28 |
eyewitness/eye | app/Notifications/Messages/BaseMessage.php | BaseMessage.getSeverity | protected function getSeverity($default)
{
if ($severity = Severity::where('namespace', $this->safeType())->where('notification', get_class($this))->first()) {
return $severity->severity;
}
app(Eye::class)->logger()->debug('Default Notification not found in database', get_class($this));
return $default;
} | php | protected function getSeverity($default)
{
if ($severity = Severity::where('namespace', $this->safeType())->where('notification', get_class($this))->first()) {
return $severity->severity;
}
app(Eye::class)->logger()->debug('Default Notification not found in database', get_class($this));
return $default;
} | [
"protected",
"function",
"getSeverity",
"(",
"$",
"default",
")",
"{",
"if",
"(",
"$",
"severity",
"=",
"Severity",
"::",
"where",
"(",
"'namespace'",
",",
"$",
"this",
"->",
"safeType",
"(",
")",
")",
"->",
"where",
"(",
"'notification'",
",",
"get_clas... | The severity level for this message.
@return string | [
"The",
"severity",
"level",
"for",
"this",
"message",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/BaseMessage.php#L54-L63 |
eyewitness/eye | app/Http/Controllers/DebugController.php | DebugController.index | public function index()
{
if (! config('eyewitness.debug')) {
return redirect(route('eyewitness.dashboard').'#overview')->withError('Sorry, but you need to enable eyewitness.debug mode to be able to view the debug page');
}
// Get all application config
$config = Config::all();
// Strip known sensitive config
$config['services'] = null;
$config['mail'] = null;
$config['filesystems']['disks'] = null;
// Now try to strip anything that might be senstive
$this->recursive_unset($config, 'key');
$this->recursive_unset($config, 'secret');
$this->recursive_unset($config, 'password');
return view('eyewitness::debug.index')->withEye(app(Eye::class))->withConfig($config);
} | php | public function index()
{
if (! config('eyewitness.debug')) {
return redirect(route('eyewitness.dashboard').'#overview')->withError('Sorry, but you need to enable eyewitness.debug mode to be able to view the debug page');
}
// Get all application config
$config = Config::all();
// Strip known sensitive config
$config['services'] = null;
$config['mail'] = null;
$config['filesystems']['disks'] = null;
// Now try to strip anything that might be senstive
$this->recursive_unset($config, 'key');
$this->recursive_unset($config, 'secret');
$this->recursive_unset($config, 'password');
return view('eyewitness::debug.index')->withEye(app(Eye::class))->withConfig($config);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"if",
"(",
"!",
"config",
"(",
"'eyewitness.debug'",
")",
")",
"{",
"return",
"redirect",
"(",
"route",
"(",
"'eyewitness.dashboard'",
")",
".",
"'#overview'",
")",
"->",
"withError",
"(",
"'Sorry, but you need to ... | A method to help debug Eyewitness issues remotely.
@return \Illuminate\Http\Response | [
"A",
"method",
"to",
"help",
"debug",
"Eyewitness",
"issues",
"remotely",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/DebugController.php#L16-L36 |
eyewitness/eye | app/Http/Controllers/DebugController.php | DebugController.recursive_unset | protected function recursive_unset(&$array, $unwanted_key)
{
unset($array[$unwanted_key]);
foreach ($array as &$value) {
if (is_array($value)) {
$this->recursive_unset($value, $unwanted_key);
}
}
} | php | protected function recursive_unset(&$array, $unwanted_key)
{
unset($array[$unwanted_key]);
foreach ($array as &$value) {
if (is_array($value)) {
$this->recursive_unset($value, $unwanted_key);
}
}
} | [
"protected",
"function",
"recursive_unset",
"(",
"&",
"$",
"array",
",",
"$",
"unwanted_key",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"unwanted_key",
"]",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
... | A method to recursively remove a given key from the array.
https://stackoverflow.com/a/1708914/1317935
@param array &$array
@param string $unwanted_key
@return array | [
"A",
"method",
"to",
"recursively",
"remove",
"a",
"given",
"key",
"from",
"the",
"array",
".",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"1708914",
"/",
"1317935"
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/DebugController.php#L46-L54 |
eyewitness/eye | app/Monitors/Queue.php | Queue.poll | public function poll()
{
try {
foreach ($this->getMonitoredQueues() as $queue) {
$this->storeTubeStats($queue);
$this->deploySonar($queue);
if (! $this->isQueueOnline($queue)) {
continue;
}
if (! $this->isWaitTimeOk($queue)) {
continue;
}
if (! $this->isPendingCountOk($queue)) {
continue;
}
if (! $this->isFailedCountOk($queue)) {
continue;
}
}
} catch (Exception $e) {
$this->eye->logger()->error('Error during queue poll process', $e);
}
} | php | public function poll()
{
try {
foreach ($this->getMonitoredQueues() as $queue) {
$this->storeTubeStats($queue);
$this->deploySonar($queue);
if (! $this->isQueueOnline($queue)) {
continue;
}
if (! $this->isWaitTimeOk($queue)) {
continue;
}
if (! $this->isPendingCountOk($queue)) {
continue;
}
if (! $this->isFailedCountOk($queue)) {
continue;
}
}
} catch (Exception $e) {
$this->eye->logger()->error('Error during queue poll process', $e);
}
} | [
"public",
"function",
"poll",
"(",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getMonitoredQueues",
"(",
")",
"as",
"$",
"queue",
")",
"{",
"$",
"this",
"->",
"storeTubeStats",
"(",
"$",
"queue",
")",
";",
"$",
"this",
"->",
"deploySona... | Poll the Queue monitor for all checks.
@return void | [
"Poll",
"the",
"Queue",
"monitor",
"for",
"all",
"checks",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L32-L58 |
eyewitness/eye | app/Monitors/Queue.php | Queue.deploySonar | public function deploySonar(QueueRepo $queue)
{
if (! Cache::has('eyewitness_q_sonar_deployed_'.$queue->id)) {
Cache::put('eyewitness_q_sonar_deployed_'.$queue->id, time(), 180);
if ($this->eye->laravelVersionIs('>=', '5.2.0')) {
QueueFacade::connection($queue->connection)->pushOn($queue->tube, new Sonar($queue->id, $queue->connection, $queue->tube));
} else {
QueueFacade::connection($queue->connection)->pushOn($queue->tube, new SonarLegacy($queue->id, $queue->connection, $queue->tube));
}
}
} | php | public function deploySonar(QueueRepo $queue)
{
if (! Cache::has('eyewitness_q_sonar_deployed_'.$queue->id)) {
Cache::put('eyewitness_q_sonar_deployed_'.$queue->id, time(), 180);
if ($this->eye->laravelVersionIs('>=', '5.2.0')) {
QueueFacade::connection($queue->connection)->pushOn($queue->tube, new Sonar($queue->id, $queue->connection, $queue->tube));
} else {
QueueFacade::connection($queue->connection)->pushOn($queue->tube, new SonarLegacy($queue->id, $queue->connection, $queue->tube));
}
}
} | [
"public",
"function",
"deploySonar",
"(",
"QueueRepo",
"$",
"queue",
")",
"{",
"if",
"(",
"!",
"Cache",
"::",
"has",
"(",
"'eyewitness_q_sonar_deployed_'",
".",
"$",
"queue",
"->",
"id",
")",
")",
"{",
"Cache",
"::",
"put",
"(",
"'eyewitness_q_sonar_deployed... | Send a sonar tracking job on the queue for each connection and tube.
@param \Eyewitness\Eye\Repo\Queue $queue
@return void | [
"Send",
"a",
"sonar",
"tracking",
"job",
"on",
"the",
"queue",
"for",
"each",
"connection",
"and",
"tube",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L66-L77 |
eyewitness/eye | app/Monitors/Queue.php | Queue.storeTubeStats | public function storeTubeStats(QueueRepo $queue)
{
$history = History::firstOrNew(['date' => date('Y-m-d'),
'hour' => date('H'),
'queue_id' => $queue->id]);
$history->pending_count = $this->getPendingJobsCount($queue);
$history->failed_count = $this->getFailedJobsCount($queue);
$history->exception_count += Cache::pull('eyewitness_q_exception_count_'.$queue->id);
$history->process_count += Cache::pull('eyewitness_q_process_count_'.$queue->id);
$history->process_time += Cache::pull('eyewitness_q_process_time_'.$queue->id);
$history->sonar_time += Cache::pull('eyewitness_q_sonar_time_'.$queue->id);
$history->sonar_count += Cache::pull('eyewitness_q_sonar_count_'.$queue->id);
$history->idle_time += Cache::pull('eyewitness_q_idle_time_'.$queue->id);
$deploy = Cache::get('eyewitness_q_sonar_deployed_'.$queue->id, null);
if (is_null($deploy)) {
$history->sonar_deployed = null;
} else {
$history->sonar_deployed = time()-$deploy;
}
$history->save();
} | php | public function storeTubeStats(QueueRepo $queue)
{
$history = History::firstOrNew(['date' => date('Y-m-d'),
'hour' => date('H'),
'queue_id' => $queue->id]);
$history->pending_count = $this->getPendingJobsCount($queue);
$history->failed_count = $this->getFailedJobsCount($queue);
$history->exception_count += Cache::pull('eyewitness_q_exception_count_'.$queue->id);
$history->process_count += Cache::pull('eyewitness_q_process_count_'.$queue->id);
$history->process_time += Cache::pull('eyewitness_q_process_time_'.$queue->id);
$history->sonar_time += Cache::pull('eyewitness_q_sonar_time_'.$queue->id);
$history->sonar_count += Cache::pull('eyewitness_q_sonar_count_'.$queue->id);
$history->idle_time += Cache::pull('eyewitness_q_idle_time_'.$queue->id);
$deploy = Cache::get('eyewitness_q_sonar_deployed_'.$queue->id, null);
if (is_null($deploy)) {
$history->sonar_deployed = null;
} else {
$history->sonar_deployed = time()-$deploy;
}
$history->save();
} | [
"public",
"function",
"storeTubeStats",
"(",
"QueueRepo",
"$",
"queue",
")",
"{",
"$",
"history",
"=",
"History",
"::",
"firstOrNew",
"(",
"[",
"'date'",
"=>",
"date",
"(",
"'Y-m-d'",
")",
",",
"'hour'",
"=>",
"date",
"(",
"'H'",
")",
",",
"'queue_id'",
... | Get the queue stats for a specific tube.
@param \Eyewitness\Eye\Repo\Queue $queue
@return void | [
"Get",
"the",
"queue",
"stats",
"for",
"a",
"specific",
"tube",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L85-L109 |
eyewitness/eye | app/Monitors/Queue.php | Queue.failedQueue | public function failedQueue($connection, $name, $tube)
{
if (Cache::has('eyewitness_debounce_failed_queue')) {
return;
}
Cache::add('eyewitness_debounce_failed_queue', 1, 3);
$this->eye->notifier()->alert(new Failed(['connection' => $connection,
'tube' => $tube,
'job' => $name]));
} | php | public function failedQueue($connection, $name, $tube)
{
if (Cache::has('eyewitness_debounce_failed_queue')) {
return;
}
Cache::add('eyewitness_debounce_failed_queue', 1, 3);
$this->eye->notifier()->alert(new Failed(['connection' => $connection,
'tube' => $tube,
'job' => $name]));
} | [
"public",
"function",
"failedQueue",
"(",
"$",
"connection",
",",
"$",
"name",
",",
"$",
"tube",
")",
"{",
"if",
"(",
"Cache",
"::",
"has",
"(",
"'eyewitness_debounce_failed_queue'",
")",
")",
"{",
"return",
";",
"}",
"Cache",
"::",
"add",
"(",
"'eyewitn... | Handle a failing queue notification.
@param string $connection
@param string $name
@param string $tube | [
"Handle",
"a",
"failing",
"queue",
"notification",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L118-L129 |
eyewitness/eye | app/Monitors/Queue.php | Queue.getFailedJobs | public function getFailedJobs($queue)
{
try {
$list = collect(app('queue.failer')->all())->where('queue', $queue->tube)
->where('connection', $queue->connection);
$list->map(function ($job) {
$job = $this->mapJob($job);
});
return $list;
} catch (Exception $e) {
$this->eye->logger()->error('Unable to get Queue Failed Jobs', $e, $queue->id);
}
return collect([]);
} | php | public function getFailedJobs($queue)
{
try {
$list = collect(app('queue.failer')->all())->where('queue', $queue->tube)
->where('connection', $queue->connection);
$list->map(function ($job) {
$job = $this->mapJob($job);
});
return $list;
} catch (Exception $e) {
$this->eye->logger()->error('Unable to get Queue Failed Jobs', $e, $queue->id);
}
return collect([]);
} | [
"public",
"function",
"getFailedJobs",
"(",
"$",
"queue",
")",
"{",
"try",
"{",
"$",
"list",
"=",
"collect",
"(",
"app",
"(",
"'queue.failer'",
")",
"->",
"all",
"(",
")",
")",
"->",
"where",
"(",
"'queue'",
",",
"$",
"queue",
"->",
"tube",
")",
"-... | Get a list of failed jobs for a given queue.
@param \Eyewitness\Eye\Repo\Queue $queue
@return collection | [
"Get",
"a",
"list",
"of",
"failed",
"jobs",
"for",
"a",
"given",
"queue",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L137-L153 |
eyewitness/eye | app/Monitors/Queue.php | Queue.getFailedJob | public function getFailedJob($job_id)
{
try {
$job = app('queue.failer')->find($job_id);
$job = $this->mapJob($job);
return $job;
} catch (Exception $e) {
$this->eye->logger()->error('Unable to get Queue Failed Job', $e, $job_id);
}
return null;
} | php | public function getFailedJob($job_id)
{
try {
$job = app('queue.failer')->find($job_id);
$job = $this->mapJob($job);
return $job;
} catch (Exception $e) {
$this->eye->logger()->error('Unable to get Queue Failed Job', $e, $job_id);
}
return null;
} | [
"public",
"function",
"getFailedJob",
"(",
"$",
"job_id",
")",
"{",
"try",
"{",
"$",
"job",
"=",
"app",
"(",
"'queue.failer'",
")",
"->",
"find",
"(",
"$",
"job_id",
")",
";",
"$",
"job",
"=",
"$",
"this",
"->",
"mapJob",
"(",
"$",
"job",
")",
";... | Get a specific failed jobs for a given queue.
@param integer $job_id
@return array|null | [
"Get",
"a",
"specific",
"failed",
"jobs",
"for",
"a",
"given",
"queue",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L161-L174 |
eyewitness/eye | app/Monitors/Queue.php | Queue.getPendingJobsCount | public function getPendingJobsCount($queue)
{
$driver_class = "\\Eyewitness\\Eye\\Queue\\Handlers\\".ucfirst(strtolower($queue->driver)).'Queue';
if (! class_exists($driver_class)) {
$this->eye->logger()->error('Queue Driver does not exist', $driver_class);
return 0;
}
try {
$qm = app(QueueManager::class)->connection($queue->connection);
return (new $driver_class($qm, $queue))->pendingJobsCount($queue->tube);
} catch (Exception $e) {
$this->eye->logger()->debug('Unable to find Queue connection', ['exception' => $e->getMessage(), 'connection' => $queue->connection]);
}
return -1;
} | php | public function getPendingJobsCount($queue)
{
$driver_class = "\\Eyewitness\\Eye\\Queue\\Handlers\\".ucfirst(strtolower($queue->driver)).'Queue';
if (! class_exists($driver_class)) {
$this->eye->logger()->error('Queue Driver does not exist', $driver_class);
return 0;
}
try {
$qm = app(QueueManager::class)->connection($queue->connection);
return (new $driver_class($qm, $queue))->pendingJobsCount($queue->tube);
} catch (Exception $e) {
$this->eye->logger()->debug('Unable to find Queue connection', ['exception' => $e->getMessage(), 'connection' => $queue->connection]);
}
return -1;
} | [
"public",
"function",
"getPendingJobsCount",
"(",
"$",
"queue",
")",
"{",
"$",
"driver_class",
"=",
"\"\\\\Eyewitness\\\\Eye\\\\Queue\\\\Handlers\\\\\"",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"queue",
"->",
"driver",
")",
")",
".",
"'Queue'",
";",
"if",
"... | Get the number of pending jobs for this queue tube.
@param \Eyewitness\Eye\Repo\Queue $queue
@return int | [
"Get",
"the",
"number",
"of",
"pending",
"jobs",
"for",
"this",
"queue",
"tube",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L193-L211 |
eyewitness/eye | app/Monitors/Queue.php | Queue.resolveLegacyName | public function resolveLegacyName($job)
{
try {
$payload = json_decode($job->getRawBody(), true);
$name = $payload['job'];
if (! empty($payload['displayName'])) {
return $payload['displayName'];
}
if ($name === 'Illuminate\Queue\CallQueuedHandler@call') {
return get_class(unserialize($data['data']['command']));
}
if ($name === 'Illuminate\Events\CallQueuedHandler@call') {
return $payload['data']['class'].'@'.$payload['data']['method'];
}
} catch (Exception $e) {
$this->eye->logger()->error('Unable to resolve Legacy Name', $e);
$name = 'Unknown';
}
return $name;
} | php | public function resolveLegacyName($job)
{
try {
$payload = json_decode($job->getRawBody(), true);
$name = $payload['job'];
if (! empty($payload['displayName'])) {
return $payload['displayName'];
}
if ($name === 'Illuminate\Queue\CallQueuedHandler@call') {
return get_class(unserialize($data['data']['command']));
}
if ($name === 'Illuminate\Events\CallQueuedHandler@call') {
return $payload['data']['class'].'@'.$payload['data']['method'];
}
} catch (Exception $e) {
$this->eye->logger()->error('Unable to resolve Legacy Name', $e);
$name = 'Unknown';
}
return $name;
} | [
"public",
"function",
"resolveLegacyName",
"(",
"$",
"job",
")",
"{",
"try",
"{",
"$",
"payload",
"=",
"json_decode",
"(",
"$",
"job",
"->",
"getRawBody",
"(",
")",
",",
"true",
")",
";",
"$",
"name",
"=",
"$",
"payload",
"[",
"'job'",
"]",
";",
"i... | Get the resolved name of the queued job class.
@param array $job
@return string | [
"Get",
"the",
"resolved",
"name",
"of",
"the",
"queued",
"job",
"class",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L219-L242 |
eyewitness/eye | app/Monitors/Queue.php | Queue.isQueueOnline | public function isQueueOnline($queue)
{
if ($queue->alert_heartbeat_greater_than < 1) {
return true;
}
if (Carbon::now()->diffInSeconds($queue->last_heartbeat) <= $queue->alert_heartbeat_greater_than) {
if ($this->eye->status()->isSick('queue_online_'.$queue->id)) {
$this->eye->notifier()->alert(new Online(['queue' => $queue]));
}
$this->eye->status()->setHealthy('queue_online_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_online_'.$queue->id)) {
$this->eye->notifier()->alert(new Offline(['queue' => $queue]));
}
$this->eye->status()->setSick('queue_online_'.$queue->id);
return false;
} | php | public function isQueueOnline($queue)
{
if ($queue->alert_heartbeat_greater_than < 1) {
return true;
}
if (Carbon::now()->diffInSeconds($queue->last_heartbeat) <= $queue->alert_heartbeat_greater_than) {
if ($this->eye->status()->isSick('queue_online_'.$queue->id)) {
$this->eye->notifier()->alert(new Online(['queue' => $queue]));
}
$this->eye->status()->setHealthy('queue_online_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_online_'.$queue->id)) {
$this->eye->notifier()->alert(new Offline(['queue' => $queue]));
}
$this->eye->status()->setSick('queue_online_'.$queue->id);
return false;
} | [
"public",
"function",
"isQueueOnline",
"(",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"queue",
"->",
"alert_heartbeat_greater_than",
"<",
"1",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"Carbon",
"::",
"now",
"(",
")",
"->",
"diffInSeconds",
"(",
"... | Check if the queue is online.
@param \Eyewitness\Eye\Repo\Queue $queue
@return bool | [
"Check",
"if",
"the",
"queue",
"is",
"online",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L260-L283 |
eyewitness/eye | app/Monitors/Queue.php | Queue.isWaitTimeOk | public function isWaitTimeOk($queue)
{
if ($queue->alert_wait_time_greater_than < 1) {
return true;
}
if ($queue->current_wait_time <= $queue->alert_wait_time_greater_than) {
if ($this->eye->status()->isSick('queue_wait_time_'.$queue->id)) {
$this->eye->notifier()->alert(new WaitOk(['queue' => $queue]));
}
$this->eye->status()->setHealthy('queue_wait_time_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_wait_time_'.$queue->id)) {
$this->eye->notifier()->alert(new WaitLong(['queue' => $queue]));
}
$this->eye->status()->setSick('queue_wait_time_'.$queue->id);
return false;
} | php | public function isWaitTimeOk($queue)
{
if ($queue->alert_wait_time_greater_than < 1) {
return true;
}
if ($queue->current_wait_time <= $queue->alert_wait_time_greater_than) {
if ($this->eye->status()->isSick('queue_wait_time_'.$queue->id)) {
$this->eye->notifier()->alert(new WaitOk(['queue' => $queue]));
}
$this->eye->status()->setHealthy('queue_wait_time_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_wait_time_'.$queue->id)) {
$this->eye->notifier()->alert(new WaitLong(['queue' => $queue]));
}
$this->eye->status()->setSick('queue_wait_time_'.$queue->id);
return false;
} | [
"public",
"function",
"isWaitTimeOk",
"(",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"queue",
"->",
"alert_wait_time_greater_than",
"<",
"1",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"queue",
"->",
"current_wait_time",
"<=",
"$",
"queue",
"->"... | Check if the queue wait time is ok.
@param \Eyewitness\Eye\Repo\Queue $queue
@return bool | [
"Check",
"if",
"the",
"queue",
"wait",
"time",
"is",
"ok",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L291-L314 |
eyewitness/eye | app/Monitors/Queue.php | Queue.isFailedCountOk | public function isFailedCountOk($queue)
{
if ($queue->alert_failed_jobs_greater_than < 1) {
return true;
}
if ($this->getFailedJobsCount($queue) <= $queue->alert_failed_jobs_greater_than) {
if ($this->eye->status()->isSick('queue_failed_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new FailedCountOk(['queue' => $queue, 'failed_job_count' => $this->getFailedJobsCount($queue)]));
}
$this->eye->status()->setHealthy('queue_failed_jobs_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_failed_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new FailedCountExceeded(['queue' => $queue, 'failed_job_count' => $this->getFailedJobsCount($queue)]));
}
$this->eye->status()->setSick('queue_failed_jobs_'.$queue->id);
return false;
} | php | public function isFailedCountOk($queue)
{
if ($queue->alert_failed_jobs_greater_than < 1) {
return true;
}
if ($this->getFailedJobsCount($queue) <= $queue->alert_failed_jobs_greater_than) {
if ($this->eye->status()->isSick('queue_failed_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new FailedCountOk(['queue' => $queue, 'failed_job_count' => $this->getFailedJobsCount($queue)]));
}
$this->eye->status()->setHealthy('queue_failed_jobs_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_failed_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new FailedCountExceeded(['queue' => $queue, 'failed_job_count' => $this->getFailedJobsCount($queue)]));
}
$this->eye->status()->setSick('queue_failed_jobs_'.$queue->id);
return false;
} | [
"public",
"function",
"isFailedCountOk",
"(",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"queue",
"->",
"alert_failed_jobs_greater_than",
"<",
"1",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getFailedJobsCount",
"(",
"$",
"queue",
... | Check if the queue failed count is ok.
@param \Eyewitness\Eye\Repo\Queue $queue
@return bool | [
"Check",
"if",
"the",
"queue",
"failed",
"count",
"is",
"ok",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L322-L345 |
eyewitness/eye | app/Monitors/Queue.php | Queue.isPendingCountOk | public function isPendingCountOk($queue)
{
if ($queue->alert_pending_jobs_greater_than < 1) {
return true;
}
if ($this->getPendingJobsCount($queue) <= $queue->alert_pending_jobs_greater_than) {
if ($this->eye->status()->isSick('queue_pending_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new PendingCountOk(['queue' => $queue, 'pending_job_count' => $this->getPendingJobsCount($queue)]));
}
$this->eye->status()->setHealthy('queue_pending_jobs_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_pending_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new PendingCountExceeded(['queue' => $queue, 'pending_job_count' => $this->getPendingJobsCount($queue)]));
}
$this->eye->status()->setSick('queue_pending_jobs_'.$queue->id);
return false;
} | php | public function isPendingCountOk($queue)
{
if ($queue->alert_pending_jobs_greater_than < 1) {
return true;
}
if ($this->getPendingJobsCount($queue) <= $queue->alert_pending_jobs_greater_than) {
if ($this->eye->status()->isSick('queue_pending_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new PendingCountOk(['queue' => $queue, 'pending_job_count' => $this->getPendingJobsCount($queue)]));
}
$this->eye->status()->setHealthy('queue_pending_jobs_'.$queue->id);
return true;
}
if ($this->eye->status()->isHealthy('queue_pending_jobs_'.$queue->id)) {
$this->eye->notifier()->alert(new PendingCountExceeded(['queue' => $queue, 'pending_job_count' => $this->getPendingJobsCount($queue)]));
}
$this->eye->status()->setSick('queue_pending_jobs_'.$queue->id);
return false;
} | [
"public",
"function",
"isPendingCountOk",
"(",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"queue",
"->",
"alert_pending_jobs_greater_than",
"<",
"1",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getPendingJobsCount",
"(",
"$",
"queue",... | Check if the queue pending count is ok.
@param \Eyewitness\Eye\Repo\Queue $queue
@return bool | [
"Check",
"if",
"the",
"queue",
"pending",
"count",
"is",
"ok",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L353-L376 |
eyewitness/eye | app/Monitors/Queue.php | Queue.mapJob | protected function mapJob($job)
{
try {
$payload = json_decode($job->payload);
$job->job = isset($payload->displayName) ? $payload->displayName : (isset($payload->job) ? $payload->job : 'Unknown');
$job->attempts = isset($payload->attempts) ? $payload->attempts : null;
$job->maxTries = isset($payload->maxTries) ? $payload->maxTries : null;
$job->timeout = isset($payload->timeout) ? $payload->timeout : null;
$job->job_id = isset($payload->id) ? $payload->id : null;
if (config('eyewitness.allow_failed_job_exception_data', true)) {
$job->exception = isset($job->exception) ? $job->exception : null;
} else {
$job->exception = null;
}
if (config('eyewitness.allow_failed_job_payload_data', true)) {
try {
$job->payload = isset($payload->data->command) ? $payload->data->command : (isset($payload->data) ? $payload->data : $job->payload);
$job->payload = get_object_vars(unserialize($job->payload));
} catch (Exception $e) {
$this->eye->logger()->debug('Unable to decode payload', ['exception' => $e->getMessage()]);
}
} else {
$job->payload = null;
}
return $job;
} catch (Exception $e) {
$this->eye->logger()->error('Unable to map the Failed Job', $e);
}
return null;
} | php | protected function mapJob($job)
{
try {
$payload = json_decode($job->payload);
$job->job = isset($payload->displayName) ? $payload->displayName : (isset($payload->job) ? $payload->job : 'Unknown');
$job->attempts = isset($payload->attempts) ? $payload->attempts : null;
$job->maxTries = isset($payload->maxTries) ? $payload->maxTries : null;
$job->timeout = isset($payload->timeout) ? $payload->timeout : null;
$job->job_id = isset($payload->id) ? $payload->id : null;
if (config('eyewitness.allow_failed_job_exception_data', true)) {
$job->exception = isset($job->exception) ? $job->exception : null;
} else {
$job->exception = null;
}
if (config('eyewitness.allow_failed_job_payload_data', true)) {
try {
$job->payload = isset($payload->data->command) ? $payload->data->command : (isset($payload->data) ? $payload->data : $job->payload);
$job->payload = get_object_vars(unserialize($job->payload));
} catch (Exception $e) {
$this->eye->logger()->debug('Unable to decode payload', ['exception' => $e->getMessage()]);
}
} else {
$job->payload = null;
}
return $job;
} catch (Exception $e) {
$this->eye->logger()->error('Unable to map the Failed Job', $e);
}
return null;
} | [
"protected",
"function",
"mapJob",
"(",
"$",
"job",
")",
"{",
"try",
"{",
"$",
"payload",
"=",
"json_decode",
"(",
"$",
"job",
"->",
"payload",
")",
";",
"$",
"job",
"->",
"job",
"=",
"isset",
"(",
"$",
"payload",
"->",
"displayName",
")",
"?",
"$"... | Map the job to a standard format.
@param array $job
@return mised | [
"Map",
"the",
"job",
"to",
"a",
"standard",
"format",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Queue.php#L384-L417 |
eyewitness/eye | app/Commands/DebugCommand.php | DebugCommand.whoAmI | protected function whoAmI()
{
$this->info('______________________________________');
$this->info(' ');
$this->info('According to the currently loaded configuration on this server - your Eyewitness.io details are:');
$this->info(' ');
$this->table(
['Eyewitness', 'Value'],
[
['App Token', config('eyewitness.app_token')],
['Secret Key', config('eyewitness.secret_key')]
]
);
$this->info(' ');
} | php | protected function whoAmI()
{
$this->info('______________________________________');
$this->info(' ');
$this->info('According to the currently loaded configuration on this server - your Eyewitness.io details are:');
$this->info(' ');
$this->table(
['Eyewitness', 'Value'],
[
['App Token', config('eyewitness.app_token')],
['Secret Key', config('eyewitness.secret_key')]
]
);
$this->info(' ');
} | [
"protected",
"function",
"whoAmI",
"(",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"'______________________________________'",
")",
";",
"$",
"this",
"->",
"info",
"(",
"' '",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'According to the currently loaded configura... | Show the current Eyewitness.io credentials being used. This is useful to help some users
forget to reload their config cache.
@return void | [
"Show",
"the",
"current",
"Eyewitness",
".",
"io",
"credentials",
"being",
"used",
".",
"This",
"is",
"useful",
"to",
"help",
"some",
"users",
"forget",
"to",
"reload",
"their",
"config",
"cache",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/DebugCommand.php#L62-L76 |
eyewitness/eye | app/Notifications/Notifier.php | Notifier.alert | public function alert(MessageInterface $message)
{
(new Database)->fire(new Recipient, $message);
if (Cache::has('eyewitness_debounce_'.$message->safeType().'_'.strtolower(class_basename($message)))) {
return;
}
foreach (Recipient::where($message->severity(), true)->get() as $recipient) {
$this->sendTo($recipient, $message);
}
Cache::add('eyewitness_debounce_'.$message->safeType().'_'.strtolower(class_basename($message)), 1, 1);
} | php | public function alert(MessageInterface $message)
{
(new Database)->fire(new Recipient, $message);
if (Cache::has('eyewitness_debounce_'.$message->safeType().'_'.strtolower(class_basename($message)))) {
return;
}
foreach (Recipient::where($message->severity(), true)->get() as $recipient) {
$this->sendTo($recipient, $message);
}
Cache::add('eyewitness_debounce_'.$message->safeType().'_'.strtolower(class_basename($message)), 1, 1);
} | [
"public",
"function",
"alert",
"(",
"MessageInterface",
"$",
"message",
")",
"{",
"(",
"new",
"Database",
")",
"->",
"fire",
"(",
"new",
"Recipient",
",",
"$",
"message",
")",
";",
"if",
"(",
"Cache",
"::",
"has",
"(",
"'eyewitness_debounce_'",
".",
"$",... | Send the notification with the given message.
@param \Eyewitness\Eye\Notifications\Messages\MessageInterface $message
@return void | [
"Send",
"the",
"notification",
"with",
"the",
"given",
"message",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Notifier.php#L19-L32 |
eyewitness/eye | app/Notifications/Notifier.php | Notifier.sendTo | public function sendTo(Recipient $recipient, MessageInterface $message)
{
$driver = "\\Eyewitness\\Eye\\Notifications\\Drivers\\".ucfirst(strtolower($recipient->type));
if (class_exists($driver)) {
$channel = app($driver);
$channel->fire($recipient, $message);
} else {
app(Eye::class)->logger()->debug('Notification Driver does not exist', $driver);
}
} | php | public function sendTo(Recipient $recipient, MessageInterface $message)
{
$driver = "\\Eyewitness\\Eye\\Notifications\\Drivers\\".ucfirst(strtolower($recipient->type));
if (class_exists($driver)) {
$channel = app($driver);
$channel->fire($recipient, $message);
} else {
app(Eye::class)->logger()->debug('Notification Driver does not exist', $driver);
}
} | [
"public",
"function",
"sendTo",
"(",
"Recipient",
"$",
"recipient",
",",
"MessageInterface",
"$",
"message",
")",
"{",
"$",
"driver",
"=",
"\"\\\\Eyewitness\\\\Eye\\\\Notifications\\\\Drivers\\\\\"",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"recipient",
"->",
"t... | Send an alert notification with the given message to a specific recipient.
@param \Eyewitness\Eye\Repo\Notifications\Recipient $recipient
@param \Eyewitness\Eye\Notifications\Messages\MessageInterface $message
@return void | [
"Send",
"an",
"alert",
"notification",
"with",
"the",
"given",
"message",
"to",
"a",
"specific",
"recipient",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Notifier.php#L41-L51 |
eyewitness/eye | app/Queue/Handlers/BeanstalkdQueue.php | BeanstalkdQueue.pendingJobsCount | public function pendingJobsCount($tube)
{
try {
$count = $this->queue->statsTube($tube)->{'current-jobs-ready'};
} catch (ServerException $e) {
$count = 0;
}
return $count;
} | php | public function pendingJobsCount($tube)
{
try {
$count = $this->queue->statsTube($tube)->{'current-jobs-ready'};
} catch (ServerException $e) {
$count = 0;
}
return $count;
} | [
"public",
"function",
"pendingJobsCount",
"(",
"$",
"tube",
")",
"{",
"try",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"queue",
"->",
"statsTube",
"(",
"$",
"tube",
")",
"->",
"{",
"'current-jobs-ready'",
"}",
";",
"}",
"catch",
"(",
"ServerException",
... | Return the number of pending jobs for the tube.
@param string $tube
@return int | [
"Return",
"the",
"number",
"of",
"pending",
"jobs",
"for",
"the",
"tube",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/Handlers/BeanstalkdQueue.php#L27-L36 |
eyewitness/eye | app/Monitors/Application.php | Application.settings | public function settings()
{
if (is_null($this->settings)) {
$this->settings['version_php'] = $this->getPhpVersion();
$this->settings['version_laravel'] = app()->version();
$this->settings['cache_config'] = app()->configurationIsCached();
$this->settings['cache_route'] = app()->routesAreCached();
$this->settings['timezone'] = config('app.timezone');
$this->settings['debug'] = config('app.debug');
$this->settings['eyewitness_debug'] = config('eyewitness.debug');
$this->settings['env'] = config('app.env');
$this->settings['name'] = config('app.name', 'Laravel App');
$this->settings['maintenance_mode'] = app()->isDownForMaintenance();
}
return $this->settings;
} | php | public function settings()
{
if (is_null($this->settings)) {
$this->settings['version_php'] = $this->getPhpVersion();
$this->settings['version_laravel'] = app()->version();
$this->settings['cache_config'] = app()->configurationIsCached();
$this->settings['cache_route'] = app()->routesAreCached();
$this->settings['timezone'] = config('app.timezone');
$this->settings['debug'] = config('app.debug');
$this->settings['eyewitness_debug'] = config('eyewitness.debug');
$this->settings['env'] = config('app.env');
$this->settings['name'] = config('app.name', 'Laravel App');
$this->settings['maintenance_mode'] = app()->isDownForMaintenance();
}
return $this->settings;
} | [
"public",
"function",
"settings",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"settings",
")",
")",
"{",
"$",
"this",
"->",
"settings",
"[",
"'version_php'",
"]",
"=",
"$",
"this",
"->",
"getPhpVersion",
"(",
")",
";",
"$",
"this",
... | Get all the application settings.
@return array | [
"Get",
"all",
"the",
"application",
"settings",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Application.php#L19-L35 |
eyewitness/eye | app/Monitors/Application.php | Application.find | public function find($filter)
{
if (is_null($this->settings)) {
$this->settings();
}
return $this->settings[$filter];
} | php | public function find($filter)
{
if (is_null($this->settings)) {
$this->settings();
}
return $this->settings[$filter];
} | [
"public",
"function",
"find",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"settings",
")",
")",
"{",
"$",
"this",
"->",
"settings",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"settings",
"[",
"$",
"filter",
"... | Get a specifc application result.
@param string $filter
@return array | [
"Get",
"a",
"specifc",
"application",
"result",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Application.php#L43-L50 |
eyewitness/eye | app/Scheduling/CallbackEvent.php | CallbackEvent.run | public function run(Container $container)
{
if ((! $this->ignoreMutex) && $this->description && $this->withoutOverlapping && (! $this->setMutex())) {
return;
}
$this->runCommandInForeground($container);
return $this->exitcode;
} | php | public function run(Container $container)
{
if ((! $this->ignoreMutex) && $this->description && $this->withoutOverlapping && (! $this->setMutex())) {
return;
}
$this->runCommandInForeground($container);
return $this->exitcode;
} | [
"public",
"function",
"run",
"(",
"Container",
"$",
"container",
")",
"{",
"if",
"(",
"(",
"!",
"$",
"this",
"->",
"ignoreMutex",
")",
"&&",
"$",
"this",
"->",
"description",
"&&",
"$",
"this",
"->",
"withoutOverlapping",
"&&",
"(",
"!",
"$",
"this",
... | Run the given event.
@param \Illuminate\Contracts\Container\Container $container
@return mixed
@throws \Exception | [
"Run",
"the",
"given",
"event",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/CallbackEvent.php#L48-L57 |
eyewitness/eye | app/Scheduling/CallbackEvent.php | CallbackEvent.runForegroundProcess | protected function runForegroundProcess($container)
{
try {
$container->call($this->callback, $this->parameters);
} catch (Exception $e) {
echo(' [Exception] '.$e->getMessage());
$this->exitcode = 1;
throw $e;
}
$this->exitcode = 0;
} | php | protected function runForegroundProcess($container)
{
try {
$container->call($this->callback, $this->parameters);
} catch (Exception $e) {
echo(' [Exception] '.$e->getMessage());
$this->exitcode = 1;
throw $e;
}
$this->exitcode = 0;
} | [
"protected",
"function",
"runForegroundProcess",
"(",
"$",
"container",
")",
"{",
"try",
"{",
"$",
"container",
"->",
"call",
"(",
"$",
"this",
"->",
"callback",
",",
"$",
"this",
"->",
"parameters",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
... | Run the foreground process.
@param \Illuminate\Contracts\Container\Container $container
@return void | [
"Run",
"the",
"foreground",
"process",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/CallbackEvent.php#L65-L76 |
eyewitness/eye | app/Queue/WorkerTrait.php | WorkerTrait.getNextJob | protected function getNextJob($connection, $queue)
{
if ($this->cache) {
foreach ($this->eyeQueues as $queue) {
$this->eyewitnessHeartbeat($queue);
}
}
foreach ($this->eyeQueues as $queue) {
$this->currentQueue = $queue;
$job = parent::getNextJob($connection, $queue->tube);
if (! is_null($job)) {
$this->eyeTube = $queue->tube;
return $job;
}
}
} | php | protected function getNextJob($connection, $queue)
{
if ($this->cache) {
foreach ($this->eyeQueues as $queue) {
$this->eyewitnessHeartbeat($queue);
}
}
foreach ($this->eyeQueues as $queue) {
$this->currentQueue = $queue;
$job = parent::getNextJob($connection, $queue->tube);
if (! is_null($job)) {
$this->eyeTube = $queue->tube;
return $job;
}
}
} | [
"protected",
"function",
"getNextJob",
"(",
"$",
"connection",
",",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"eyeQueues",
"as",
"$",
"queue",
")",
"{",
"$",
"this",
"->",
"eyewitnessH... | Extend the worker and place a heartbeat as it is processing. Then simply "feed"
the tubes into the next job parent. This provides the exact same functionality,
but this way we know exactly which tube is processing the job.
@param \Illuminate\Contracts\Queue\Queue $connection
@param string $queue
@return \Illuminate\Contracts\Queue\Job|null | [
"Extend",
"the",
"worker",
"and",
"place",
"a",
"heartbeat",
"as",
"it",
"is",
"processing",
".",
"Then",
"simply",
"feed",
"the",
"tubes",
"into",
"the",
"next",
"job",
"parent",
".",
"This",
"provides",
"the",
"exact",
"same",
"functionality",
"but",
"th... | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/WorkerTrait.php#L32-L50 |
eyewitness/eye | app/Queue/WorkerTrait.php | WorkerTrait.eyewitnessHeartbeat | protected function eyewitnessHeartbeat($queue)
{
if (! $this->cache->has('eyewitness_q_heartbeat_'.$queue->id)) {
$this->cache->add('eyewitness_q_heartbeat_'.$queue->id, 1, 1);
$queue->heartbeat();
}
} | php | protected function eyewitnessHeartbeat($queue)
{
if (! $this->cache->has('eyewitness_q_heartbeat_'.$queue->id)) {
$this->cache->add('eyewitness_q_heartbeat_'.$queue->id, 1, 1);
$queue->heartbeat();
}
} | [
"protected",
"function",
"eyewitnessHeartbeat",
"(",
"$",
"queue",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"'eyewitness_q_heartbeat_'",
".",
"$",
"queue",
"->",
"id",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"add... | Check if we have stored a recent heartbeart. Only update the database if the cache has
expired.
@param \Eyewitness\Eye\Repo\Queue $queue
@return void | [
"Check",
"if",
"we",
"have",
"stored",
"a",
"recent",
"heartbeart",
".",
"Only",
"update",
"the",
"database",
"if",
"the",
"cache",
"has",
"expired",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/WorkerTrait.php#L59-L65 |
eyewitness/eye | app/Queue/WorkerTrait.php | WorkerTrait.recordJobEnd | public function recordJobEnd($startTime, $jobName)
{
$endTime = round((microtime(true) - $startTime)*1000);
$this->cache->add('eyewitness_q_process_time_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_time_'.$this->currentQueue->id, $endTime);
if ($jobName !== "Eyewitness\\Eye\\Queue\\Jobs\\Sonar") {
$this->cache->add('eyewitness_q_process_count_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_count_'.$this->currentQueue->id);
}
} | php | public function recordJobEnd($startTime, $jobName)
{
$endTime = round((microtime(true) - $startTime)*1000);
$this->cache->add('eyewitness_q_process_time_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_time_'.$this->currentQueue->id, $endTime);
if ($jobName !== "Eyewitness\\Eye\\Queue\\Jobs\\Sonar") {
$this->cache->add('eyewitness_q_process_count_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_count_'.$this->currentQueue->id);
}
} | [
"public",
"function",
"recordJobEnd",
"(",
"$",
"startTime",
",",
"$",
"jobName",
")",
"{",
"$",
"endTime",
"=",
"round",
"(",
"(",
"microtime",
"(",
"true",
")",
"-",
"$",
"startTime",
")",
"*",
"1000",
")",
";",
"$",
"this",
"->",
"cache",
"->",
... | Record the end of the job details. Ignore the sonar job from artifically inflating
the queue counters.
@param float $startTime
@param string $jobName
@return void | [
"Record",
"the",
"end",
"of",
"the",
"job",
"details",
".",
"Ignore",
"the",
"sonar",
"job",
"from",
"artifically",
"inflating",
"the",
"queue",
"counters",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/WorkerTrait.php#L75-L86 |
eyewitness/eye | app/Queue/WorkerTrait.php | WorkerTrait.recordJobException | public function recordJobException($exception)
{
$this->cache->add('eyewitness_q_exception_count_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_exception_count_'.$this->currentQueue->id);
throw $exception;
} | php | public function recordJobException($exception)
{
$this->cache->add('eyewitness_q_exception_count_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_exception_count_'.$this->currentQueue->id);
throw $exception;
} | [
"public",
"function",
"recordJobException",
"(",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"add",
"(",
"'eyewitness_q_exception_count_'",
".",
"$",
"this",
"->",
"currentQueue",
"->",
"id",
",",
"0",
",",
"180",
")",
";",
"$",
"this",
... | Record the exeception count.
@param string $exception
@return void
@throws \Throwable | [
"Record",
"the",
"exeception",
"count",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/WorkerTrait.php#L96-L102 |
eyewitness/eye | app/Queue/WorkerTrait.php | WorkerTrait.sleep | public function sleep($seconds)
{
foreach ($this->eyeQueues as $queue) {
$this->cache->add('eyewitness_q_idle_time_'.$queue->id, 0, 180);
if ($seconds < 1) {
$this->cache->increment('eyewitness_q_idle_time_'.$queue->id, 1);
} else {
$this->cache->increment('eyewitness_q_idle_time_'.$queue->id, round($seconds));
}
}
parent::sleep($seconds);
} | php | public function sleep($seconds)
{
foreach ($this->eyeQueues as $queue) {
$this->cache->add('eyewitness_q_idle_time_'.$queue->id, 0, 180);
if ($seconds < 1) {
$this->cache->increment('eyewitness_q_idle_time_'.$queue->id, 1);
} else {
$this->cache->increment('eyewitness_q_idle_time_'.$queue->id, round($seconds));
}
}
parent::sleep($seconds);
} | [
"public",
"function",
"sleep",
"(",
"$",
"seconds",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"eyeQueues",
"as",
"$",
"queue",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"add",
"(",
"'eyewitness_q_idle_time_'",
".",
"$",
"queue",
"->",
"id",
",",
... | Capture how long a worker is sleeping for. We need to cycle all tubes this worker checks to
give each of them credit for the sleep. This allows us to handle different worker configurations
and should cover all situations.
@param int|float $seconds
@return void | [
"Capture",
"how",
"long",
"a",
"worker",
"is",
"sleeping",
"for",
".",
"We",
"need",
"to",
"cycle",
"all",
"tubes",
"this",
"worker",
"checks",
"to",
"give",
"each",
"of",
"them",
"credit",
"for",
"the",
"sleep",
".",
"This",
"allows",
"us",
"to",
"han... | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/WorkerTrait.php#L112-L125 |
eyewitness/eye | app/Monitors/Database.php | Database.poll | public function poll()
{
foreach($this->getDatabases() as $db)
{
$this->handleStatusAlerts($db);
if ($db['status']) {
$this->handleSizeAlerts($db);
History::create(['type' => 'database',
'meta' => $db['connection'],
'record' => [],
'value' => $db['size']]);
}
}
} | php | public function poll()
{
foreach($this->getDatabases() as $db)
{
$this->handleStatusAlerts($db);
if ($db['status']) {
$this->handleSizeAlerts($db);
History::create(['type' => 'database',
'meta' => $db['connection'],
'record' => [],
'value' => $db['size']]);
}
}
} | [
"public",
"function",
"poll",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"db",
")",
"{",
"$",
"this",
"->",
"handleStatusAlerts",
"(",
"$",
"db",
")",
";",
"if",
"(",
"$",
"db",
"[",
"'status'",
"]",
")... | Perform poll for each database.
@return array | [
"Perform",
"poll",
"for",
"each",
"database",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L21-L36 |
eyewitness/eye | app/Monitors/Database.php | Database.handleStatusAlerts | protected function handleStatusAlerts($db)
{
if ($db['status']) {
if ($this->eye->status()->isSick('database_status_'.$db['connection'])) {
$this->eye->notifier()->alert(new Online($db));
}
$this->eye->status()->setHealthy('database_status_'.$db['connection']);
} else {
if ($this->eye->status()->isHealthy('database_status_'.$db['connection'])) {
$this->eye->notifier()->alert(new Offline($db));
}
$this->eye->status()->setSick('database_status_'.$db['connection']);
}
} | php | protected function handleStatusAlerts($db)
{
if ($db['status']) {
if ($this->eye->status()->isSick('database_status_'.$db['connection'])) {
$this->eye->notifier()->alert(new Online($db));
}
$this->eye->status()->setHealthy('database_status_'.$db['connection']);
} else {
if ($this->eye->status()->isHealthy('database_status_'.$db['connection'])) {
$this->eye->notifier()->alert(new Offline($db));
}
$this->eye->status()->setSick('database_status_'.$db['connection']);
}
} | [
"protected",
"function",
"handleStatusAlerts",
"(",
"$",
"db",
")",
"{",
"if",
"(",
"$",
"db",
"[",
"'status'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"eye",
"->",
"status",
"(",
")",
"->",
"isSick",
"(",
"'database_status_'",
".",
"$",
"db",
... | Handle any status issues.
@param string $db
@return void | [
"Handle",
"any",
"status",
"issues",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L44-L60 |
eyewitness/eye | app/Monitors/Database.php | Database.handleSizeAlerts | protected function handleSizeAlerts($db)
{
if (($db['alert_greater_than_mb'] > 0) && ($db['size'] > $db['alert_greater_than_mb'])) {
if ($this->eye->status()->isHealthy('database_size_'.$db['connection'])) {
$this->eye->notifier()->alert(new SizeLarge($db));
}
$this->eye->status()->setSick('database_size_'.$db['connection']);
} elseif (($db['alert_less_than_mb'] > 0) && ($db['size'] < $db['alert_less_than_mb'])) {
if ($this->eye->status()->isHealthy('database_size_'.$db['connection'])) {
$this->eye->notifier()->alert(new SizeSmall($db));
}
$this->eye->status()->setSick('database_size_'.$db['connection']);
} else {
if ($this->eye->status()->isSick('database_size_'.$db['connection'])) {
$this->eye->notifier()->alert(new SizeOk($db));
}
$this->eye->status()->setHealthy('database_size_'.$db['connection']);
}
} | php | protected function handleSizeAlerts($db)
{
if (($db['alert_greater_than_mb'] > 0) && ($db['size'] > $db['alert_greater_than_mb'])) {
if ($this->eye->status()->isHealthy('database_size_'.$db['connection'])) {
$this->eye->notifier()->alert(new SizeLarge($db));
}
$this->eye->status()->setSick('database_size_'.$db['connection']);
} elseif (($db['alert_less_than_mb'] > 0) && ($db['size'] < $db['alert_less_than_mb'])) {
if ($this->eye->status()->isHealthy('database_size_'.$db['connection'])) {
$this->eye->notifier()->alert(new SizeSmall($db));
}
$this->eye->status()->setSick('database_size_'.$db['connection']);
} else {
if ($this->eye->status()->isSick('database_size_'.$db['connection'])) {
$this->eye->notifier()->alert(new SizeOk($db));
}
$this->eye->status()->setHealthy('database_size_'.$db['connection']);
}
} | [
"protected",
"function",
"handleSizeAlerts",
"(",
"$",
"db",
")",
"{",
"if",
"(",
"(",
"$",
"db",
"[",
"'alert_greater_than_mb'",
"]",
">",
"0",
")",
"&&",
"(",
"$",
"db",
"[",
"'size'",
"]",
">",
"$",
"db",
"[",
"'alert_greater_than_mb'",
"]",
")",
... | Handle any size issues.
@param string $db
@return void | [
"Handle",
"any",
"size",
"issues",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L68-L90 |
eyewitness/eye | app/Monitors/Database.php | Database.getDatabases | public function getDatabases()
{
$data = [];
foreach ($this->getMonitoredDatabases() as $db) {
$data[] = ['connection' => $db['connection'],
'alert_greater_than_mb' => $db['alert_greater_than_mb'],
'alert_less_than_mb' => $db['alert_less_than_mb'],
'driver' => $this->getDriverName($db['connection']),
'status' => $this->checkDatabaseStatus($db['connection']),
'size' => $this->getDatabaseSize($db['connection'])];
}
return $data;
} | php | public function getDatabases()
{
$data = [];
foreach ($this->getMonitoredDatabases() as $db) {
$data[] = ['connection' => $db['connection'],
'alert_greater_than_mb' => $db['alert_greater_than_mb'],
'alert_less_than_mb' => $db['alert_less_than_mb'],
'driver' => $this->getDriverName($db['connection']),
'status' => $this->checkDatabaseStatus($db['connection']),
'size' => $this->getDatabaseSize($db['connection'])];
}
return $data;
} | [
"public",
"function",
"getDatabases",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getMonitoredDatabases",
"(",
")",
"as",
"$",
"db",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"[",
"'connection'",
"=>",
"$",
"db",... | Perform poll for each database.
@return array | [
"Perform",
"poll",
"for",
"each",
"database",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L97-L111 |
eyewitness/eye | app/Monitors/Database.php | Database.checkDatabaseStatus | protected function checkDatabaseStatus($connection)
{
try {
DB::connection($connection)->getPdo();
} catch (Exception $e) {
$this->eye->logger()->error('DB status failed', $e, $connection);
return false;
}
return true;
} | php | protected function checkDatabaseStatus($connection)
{
try {
DB::connection($connection)->getPdo();
} catch (Exception $e) {
$this->eye->logger()->error('DB status failed', $e, $connection);
return false;
}
return true;
} | [
"protected",
"function",
"checkDatabaseStatus",
"(",
"$",
"connection",
")",
"{",
"try",
"{",
"DB",
"::",
"connection",
"(",
"$",
"connection",
")",
"->",
"getPdo",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
... | Check if the database connection is working.
@param string $connection
@return bool | [
"Check",
"if",
"the",
"database",
"connection",
"is",
"working",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L119-L129 |
eyewitness/eye | app/Monitors/Database.php | Database.getDatabaseSize | protected function getDatabaseSize($connection)
{
switch ($this->getDriverName($connection)) {
case 'mysql':
$size = $this->checkMySqlDatabaseSize($connection);
break;
case 'sqlite':
$size = $this->checkSqLiteDatabaseSize($connection);
break;
case 'pgsql':
$size = $this->checkPostgresDatabaseSize($connection);
break;
case 'sqlsrv':
$size = $this->checkSqlServerDatabaseSize($connection);
break;
default:
$this->eye->logger()->debug('Unable to find DB driver for size', $connection);
return -1;
}
return round($size/1024/1024, 2);
} | php | protected function getDatabaseSize($connection)
{
switch ($this->getDriverName($connection)) {
case 'mysql':
$size = $this->checkMySqlDatabaseSize($connection);
break;
case 'sqlite':
$size = $this->checkSqLiteDatabaseSize($connection);
break;
case 'pgsql':
$size = $this->checkPostgresDatabaseSize($connection);
break;
case 'sqlsrv':
$size = $this->checkSqlServerDatabaseSize($connection);
break;
default:
$this->eye->logger()->debug('Unable to find DB driver for size', $connection);
return -1;
}
return round($size/1024/1024, 2);
} | [
"protected",
"function",
"getDatabaseSize",
"(",
"$",
"connection",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getDriverName",
"(",
"$",
"connection",
")",
")",
"{",
"case",
"'mysql'",
":",
"$",
"size",
"=",
"$",
"this",
"->",
"checkMySqlDatabaseSize",
"... | Get the size of the database.
@param string $connection
@return int | [
"Get",
"the",
"size",
"of",
"the",
"database",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L137-L158 |
eyewitness/eye | app/Monitors/Database.php | Database.checkMySqlDatabaseSize | protected function checkMySqlDatabaseSize($connection)
{
try {
$result = (array) DB::connection($connection)
->table('information_schema.TABLES')
->select(DB::raw("sum( data_length + index_length ) AS size"))
->where('table_schema', DB::connection($connection)->getConfig('database'))
->first();
return $result['size'];
} catch (Exception $e) {
$this->eye->logger()->debug('Error during mySQL DB size check', ['exception' => $e->getMessage(), 'connection' => $connection]);
}
return -1;
} | php | protected function checkMySqlDatabaseSize($connection)
{
try {
$result = (array) DB::connection($connection)
->table('information_schema.TABLES')
->select(DB::raw("sum( data_length + index_length ) AS size"))
->where('table_schema', DB::connection($connection)->getConfig('database'))
->first();
return $result['size'];
} catch (Exception $e) {
$this->eye->logger()->debug('Error during mySQL DB size check', ['exception' => $e->getMessage(), 'connection' => $connection]);
}
return -1;
} | [
"protected",
"function",
"checkMySqlDatabaseSize",
"(",
"$",
"connection",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"(",
"array",
")",
"DB",
"::",
"connection",
"(",
"$",
"connection",
")",
"->",
"table",
"(",
"'information_schema.TABLES'",
")",
"->",
"sele... | Return the size of the mySql database.
@param string $connection
@return int | [
"Return",
"the",
"size",
"of",
"the",
"mySql",
"database",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L166-L181 |
eyewitness/eye | app/Monitors/Database.php | Database.checkSqLiteDatabaseSize | protected function checkSqLiteDatabaseSize($connection)
{
try {
$path = realpath(DB::connection($connection)->getConfig('database'));
if ($path !== false) {
return filesize($path);
}
} catch (Exception $e) {
$this->eye->logger()->debug('Error during sqLite DB size check', ['exception' => $e->getMessage(), 'connection' => $connection]);
}
return -1;
} | php | protected function checkSqLiteDatabaseSize($connection)
{
try {
$path = realpath(DB::connection($connection)->getConfig('database'));
if ($path !== false) {
return filesize($path);
}
} catch (Exception $e) {
$this->eye->logger()->debug('Error during sqLite DB size check', ['exception' => $e->getMessage(), 'connection' => $connection]);
}
return -1;
} | [
"protected",
"function",
"checkSqLiteDatabaseSize",
"(",
"$",
"connection",
")",
"{",
"try",
"{",
"$",
"path",
"=",
"realpath",
"(",
"DB",
"::",
"connection",
"(",
"$",
"connection",
")",
"->",
"getConfig",
"(",
"'database'",
")",
")",
";",
"if",
"(",
"$... | Return the size of the Sqlite database.
@param string $connection
@return int | [
"Return",
"the",
"size",
"of",
"the",
"Sqlite",
"database",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L189-L201 |
eyewitness/eye | app/Monitors/Database.php | Database.getDriverName | protected function getDriverName($connection)
{
try {
return DB::connection($connection)->getDriverName();
} catch (Exception $e) {
$this->eye->logger()->debug('Unable to find DB driver', $connection);
}
return 'unknown';
} | php | protected function getDriverName($connection)
{
try {
return DB::connection($connection)->getDriverName();
} catch (Exception $e) {
$this->eye->logger()->debug('Unable to find DB driver', $connection);
}
return 'unknown';
} | [
"protected",
"function",
"getDriverName",
"(",
"$",
"connection",
")",
"{",
"try",
"{",
"return",
"DB",
"::",
"connection",
"(",
"$",
"connection",
")",
"->",
"getDriverName",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"thi... | Get the name of the database driver.
@param string $connection
@return string | [
"Get",
"the",
"name",
"of",
"the",
"database",
"driver",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Database.php#L251-L260 |
eyewitness/eye | app/Http/Controllers/FailedJobController.php | FailedJobController.show | public function show($queue_id, $job_id)
{
$queue = Queue::findOrFail($queue_id);
$job = $this->eye->queue()->getFailedJob($job_id);
return view('eyewitness::queue.failed_job')->withJob($job)->withQueue($queue);
} | php | public function show($queue_id, $job_id)
{
$queue = Queue::findOrFail($queue_id);
$job = $this->eye->queue()->getFailedJob($job_id);
return view('eyewitness::queue.failed_job')->withJob($job)->withQueue($queue);
} | [
"public",
"function",
"show",
"(",
"$",
"queue_id",
",",
"$",
"job_id",
")",
"{",
"$",
"queue",
"=",
"Queue",
"::",
"findOrFail",
"(",
"$",
"queue_id",
")",
";",
"$",
"job",
"=",
"$",
"this",
"->",
"eye",
"->",
"queue",
"(",
")",
"->",
"getFailedJo... | Show the given job.
@param integer $queue_id
@param integer $job_id
@return \Illuminate\Http\Response | [
"Show",
"the",
"given",
"job",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/FailedJobController.php#L39-L45 |
eyewitness/eye | app/Http/Controllers/FailedJobController.php | FailedJobController.retry | public function retry($queue_id, $job_id)
{
try {
Artisan::call('queue:retry', ['id' => [$job_id]]);
} catch (Exception $e) {
$this->eye->logger()->error('Retry of failed job unsuccessful', $e, ['job_id' => $job_id, 'queue_id' => $queue_id]);
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withError('Sorry - we could not retry that job. Please check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('The job has been pushed back onto the queue to be tried again.');
} | php | public function retry($queue_id, $job_id)
{
try {
Artisan::call('queue:retry', ['id' => [$job_id]]);
} catch (Exception $e) {
$this->eye->logger()->error('Retry of failed job unsuccessful', $e, ['job_id' => $job_id, 'queue_id' => $queue_id]);
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withError('Sorry - we could not retry that job. Please check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('The job has been pushed back onto the queue to be tried again.');
} | [
"public",
"function",
"retry",
"(",
"$",
"queue_id",
",",
"$",
"job_id",
")",
"{",
"try",
"{",
"Artisan",
"::",
"call",
"(",
"'queue:retry'",
",",
"[",
"'id'",
"=>",
"[",
"$",
"job_id",
"]",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
... | Retry the given job.
@param integer $queue_id
@param integer $job_id
@return \Illuminate\Http\Response | [
"Retry",
"the",
"given",
"job",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/FailedJobController.php#L54-L64 |
eyewitness/eye | app/Http/Controllers/FailedJobController.php | FailedJobController.destroy | public function destroy($queue_id, $job_id)
{
try {
if (app('queue.failer')->forget($job_id)) {
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('The job has been deleted from the failed table.');
}
} catch (Exception $e) {
$this->eye->logger()->error('Delete of failed job unsuccessful', $e, ['job_id' => $job_id, 'queue_id' => $queue_id]);
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withError('Sorry - we could not delete that job. Please check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withError('Sorry - we could not find that job in the list. Perhaps it was already deleted?');
} | php | public function destroy($queue_id, $job_id)
{
try {
if (app('queue.failer')->forget($job_id)) {
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('The job has been deleted from the failed table.');
}
} catch (Exception $e) {
$this->eye->logger()->error('Delete of failed job unsuccessful', $e, ['job_id' => $job_id, 'queue_id' => $queue_id]);
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withError('Sorry - we could not delete that job. Please check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withError('Sorry - we could not find that job in the list. Perhaps it was already deleted?');
} | [
"public",
"function",
"destroy",
"(",
"$",
"queue_id",
",",
"$",
"job_id",
")",
"{",
"try",
"{",
"if",
"(",
"app",
"(",
"'queue.failer'",
")",
"->",
"forget",
"(",
"$",
"job_id",
")",
")",
"{",
"return",
"redirect",
"(",
"route",
"(",
"'eyewitness.queu... | Delete a specific failed job.
@param integer $queue_id
@param integer $job_id
@return \Illuminate\Http\Response | [
"Delete",
"a",
"specific",
"failed",
"job",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/FailedJobController.php#L73-L85 |
eyewitness/eye | app/Http/Controllers/FailedJobController.php | FailedJobController.retryAll | public function retryAll($queue_id)
{
$queue = Queue::findOrFail($queue_id);
$jobs = $this->eye->queue()->getFailedJobs($queue);
$failed = false;
foreach ($jobs as $job) {
try {
Artisan::call('queue:retry', ['id' => [$job->id]]);
} catch (Exception $e) {
$this->eye->logger()->error('Retry of failed job unsuccessful', $e, ['job_id' => $job->id, 'queue_id' => $queue_id]);
$failed = true;
}
}
if ($failed) {
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withWarning('Some of the jobs did not get retried successfully. You should check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('All the jobs have been pushed back onto the queue to be tried again.');
} | php | public function retryAll($queue_id)
{
$queue = Queue::findOrFail($queue_id);
$jobs = $this->eye->queue()->getFailedJobs($queue);
$failed = false;
foreach ($jobs as $job) {
try {
Artisan::call('queue:retry', ['id' => [$job->id]]);
} catch (Exception $e) {
$this->eye->logger()->error('Retry of failed job unsuccessful', $e, ['job_id' => $job->id, 'queue_id' => $queue_id]);
$failed = true;
}
}
if ($failed) {
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withWarning('Some of the jobs did not get retried successfully. You should check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('All the jobs have been pushed back onto the queue to be tried again.');
} | [
"public",
"function",
"retryAll",
"(",
"$",
"queue_id",
")",
"{",
"$",
"queue",
"=",
"Queue",
"::",
"findOrFail",
"(",
"$",
"queue_id",
")",
";",
"$",
"jobs",
"=",
"$",
"this",
"->",
"eye",
"->",
"queue",
"(",
")",
"->",
"getFailedJobs",
"(",
"$",
... | Retry all the jobs on this queue.
@param integer $queue_id
@return \Illuminate\Http\Response | [
"Retry",
"all",
"the",
"jobs",
"on",
"this",
"queue",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/FailedJobController.php#L93-L113 |
eyewitness/eye | app/Http/Controllers/FailedJobController.php | FailedJobController.destroyAll | public function destroyAll($queue_id)
{
$queue = Queue::findOrFail($queue_id);
$jobs = $this->eye->queue()->getFailedJobs($queue);
$failed = false;
foreach ($jobs as $job) {
try {
app('queue.failer')->forget($job->id);
} catch (Exception $e) {
$this->eye->logger()->error('Delete of failed job unsuccessful', $e, ['job_id' => $job->id, 'queue_id' => $queue_id]);
$failed = true;
}
}
if ($failed) {
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withWarning('Some of the jobs did not get deleted successfully. You should check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('All the jobs have been deleted from the failed table.');
} | php | public function destroyAll($queue_id)
{
$queue = Queue::findOrFail($queue_id);
$jobs = $this->eye->queue()->getFailedJobs($queue);
$failed = false;
foreach ($jobs as $job) {
try {
app('queue.failer')->forget($job->id);
} catch (Exception $e) {
$this->eye->logger()->error('Delete of failed job unsuccessful', $e, ['job_id' => $job->id, 'queue_id' => $queue_id]);
$failed = true;
}
}
if ($failed) {
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withWarning('Some of the jobs did not get deleted successfully. You should check your logs for further information.');
}
return redirect(route('eyewitness.queues.show', $queue_id).'#failed')->withSuccess('All the jobs have been deleted from the failed table.');
} | [
"public",
"function",
"destroyAll",
"(",
"$",
"queue_id",
")",
"{",
"$",
"queue",
"=",
"Queue",
"::",
"findOrFail",
"(",
"$",
"queue_id",
")",
";",
"$",
"jobs",
"=",
"$",
"this",
"->",
"eye",
"->",
"queue",
"(",
")",
"->",
"getFailedJobs",
"(",
"$",
... | Delete a specific failed job.
@param integer $queue_id
@return \Illuminate\Http\Response | [
"Delete",
"a",
"specific",
"failed",
"job",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/FailedJobController.php#L121-L141 |
eyewitness/eye | app/Commands/Framework/ScheduleRunCommand.php | ScheduleRunCommand.runScheduledEvents | protected function runScheduledEvents()
{
foreach ($this->schedule->dueEvents($this->laravel) as $event) {
$event = $this->convertEvent($event);
if ($this->canAccessFiltersPass($event) && (! $event->filtersPass($this->laravel))) {
continue;
}
if ($event->onOneServer) {
$this->runSingleServerEvent($event);
} else {
$this->runEvent($event);
}
}
} | php | protected function runScheduledEvents()
{
foreach ($this->schedule->dueEvents($this->laravel) as $event) {
$event = $this->convertEvent($event);
if ($this->canAccessFiltersPass($event) && (! $event->filtersPass($this->laravel))) {
continue;
}
if ($event->onOneServer) {
$this->runSingleServerEvent($event);
} else {
$this->runEvent($event);
}
}
} | [
"protected",
"function",
"runScheduledEvents",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schedule",
"->",
"dueEvents",
"(",
"$",
"this",
"->",
"laravel",
")",
"as",
"$",
"event",
")",
"{",
"$",
"event",
"=",
"$",
"this",
"->",
"convertEvent",
... | Run the scheduled events. This is an extension of the original run command
but allows us to insert our custom event and tracking.
@return void | [
"Run",
"the",
"scheduled",
"events",
".",
"This",
"is",
"an",
"extension",
"of",
"the",
"original",
"run",
"command",
"but",
"allows",
"us",
"to",
"insert",
"our",
"custom",
"event",
"and",
"tracking",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/Framework/ScheduleRunCommand.php#L40-L55 |
eyewitness/eye | app/Commands/Framework/ScheduleRunCommand.php | ScheduleRunCommand.runEvent | public function runEvent($event)
{
$this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
$event->run($this->laravel);
$this->eventsRan = true;
} | php | public function runEvent($event)
{
$this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
$event->run($this->laravel);
$this->eventsRan = true;
} | [
"public",
"function",
"runEvent",
"(",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"'<info>Running scheduled command:</info> '",
".",
"$",
"event",
"->",
"getSummaryForDisplay",
"(",
")",
")",
";",
"$",
"event",
"->",
"run",
"(",
"$",
"this",
"... | Run the given event.
@param \Illuminate\Support\Collection $event
@return void | [
"Run",
"the",
"given",
"event",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/Framework/ScheduleRunCommand.php#L86-L91 |
eyewitness/eye | app/Scheduling/CustomEvents.php | CustomEvents.convertEvent | protected function convertEvent($event)
{
if ($event instanceof OriginalCallbackEvent) {
return new CallbackEvent($event);
}
if ($event instanceof OriginalEvent) {
return new Event($event);
}
return $event;
} | php | protected function convertEvent($event)
{
if ($event instanceof OriginalCallbackEvent) {
return new CallbackEvent($event);
}
if ($event instanceof OriginalEvent) {
return new Event($event);
}
return $event;
} | [
"protected",
"function",
"convertEvent",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"instanceof",
"OriginalCallbackEvent",
")",
"{",
"return",
"new",
"CallbackEvent",
"(",
"$",
"event",
")",
";",
"}",
"if",
"(",
"$",
"event",
"instanceof",
"Orig... | Try and convert the current event object to a custom one.
https://stackoverflow.com/a/4722587/1317935
@param $event
@return mixed | [
"Try",
"and",
"convert",
"the",
"current",
"event",
"object",
"to",
"a",
"custom",
"one",
".",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"4722587",
"/",
"1317935"
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/CustomEvents.php#L20-L31 |
eyewitness/eye | app/Scheduling/CustomEvents.php | CustomEvents.findEventMutex | protected function findEventMutex($mutex)
{
return collect($this->schedule->events())->filter(function ($value) use ($mutex) {
if (Eye::laravelVersionIs('<', '5.4.0')) {
$value = $this->convertEvent($value);
}
return $value->mutexName() === $mutex;
})->first();
} | php | protected function findEventMutex($mutex)
{
return collect($this->schedule->events())->filter(function ($value) use ($mutex) {
if (Eye::laravelVersionIs('<', '5.4.0')) {
$value = $this->convertEvent($value);
}
return $value->mutexName() === $mutex;
})->first();
} | [
"protected",
"function",
"findEventMutex",
"(",
"$",
"mutex",
")",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"schedule",
"->",
"events",
"(",
")",
")",
"->",
"filter",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"mutex",
")",
"{... | Find the event that matches the mutex.
@param $mutex
@return mixd | [
"Find",
"the",
"event",
"that",
"matches",
"the",
"mutex",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/CustomEvents.php#L39-L48 |
eyewitness/eye | app/Scheduling/CustomEvents.php | CustomEvents.runEvent | protected function runEvent($event, $force = true)
{
$this->convertEvent($event)
->ignoreMutex($force)
->runInForeground()
->run($this->laravel);
} | php | protected function runEvent($event, $force = true)
{
$this->convertEvent($event)
->ignoreMutex($force)
->runInForeground()
->run($this->laravel);
} | [
"protected",
"function",
"runEvent",
"(",
"$",
"event",
",",
"$",
"force",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"convertEvent",
"(",
"$",
"event",
")",
"->",
"ignoreMutex",
"(",
"$",
"force",
")",
"->",
"runInForeground",
"(",
")",
"->",
"run",
... | Run an event.
@param $event
@param $force
@return mixd | [
"Run",
"an",
"event",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/CustomEvents.php#L57-L63 |
eyewitness/eye | app/Tools/BladeDirectives.php | BladeDirectives.registerNotificationDirectives | public function registerNotificationDirectives()
{
Blade::directive('eyewitness_error', function($message) {
return $this->baseNotification($message, 'bg-red', 'bold-remove', 'svgcolor-red');
});
Blade::directive('eyewitness_success', function($message) {
return $this->baseNotification($message, 'bg-green', 'check-simple', 'svgcolor-green');
});
Blade::directive('eyewitness_warning', function($message) {
return $this->baseNotification($message, 'bg-orange', 'alert-exc', 'svgcolor-orange');
});
Blade::directive('eyewitness_info', function($message) {
return $this->baseNotification($message, 'bg-blue', 'alert-i', 'svgcolor-blue');
});
Blade::directive('eyewitness_error_no_escape', function($message) {
return $this->baseNotification($message, 'bg-red', 'bold-remove', 'svgcolor-red', false);
});
Blade::directive('eyewitness_success_no_escape', function($message) {
return $this->baseNotification($message, 'bg-green', 'check-simple', 'svgcolor-green', false);
});
Blade::directive('eyewitness_warning_no_escape', function($message) {
return $this->baseNotification($message, 'bg-orange', 'alert-exc', 'svgcolor-orange', false);
});
Blade::directive('eyewitness_info_no_escape', function($message) {
return $this->baseNotification($message, 'bg-blue', 'alert-i', 'svgcolor-blue', false);
});
Blade::directive('eyewitness_tutorial', function($message) {
$s = "<?php if (config('eyewitness.display_helpers', true)): ?>";
$s .= $this->baseNotification($message, 'bg-blue', 'alert-i', 'svgcolor-blue');
$s .= "<?php endif; ?>";
return $s;
});
} | php | public function registerNotificationDirectives()
{
Blade::directive('eyewitness_error', function($message) {
return $this->baseNotification($message, 'bg-red', 'bold-remove', 'svgcolor-red');
});
Blade::directive('eyewitness_success', function($message) {
return $this->baseNotification($message, 'bg-green', 'check-simple', 'svgcolor-green');
});
Blade::directive('eyewitness_warning', function($message) {
return $this->baseNotification($message, 'bg-orange', 'alert-exc', 'svgcolor-orange');
});
Blade::directive('eyewitness_info', function($message) {
return $this->baseNotification($message, 'bg-blue', 'alert-i', 'svgcolor-blue');
});
Blade::directive('eyewitness_error_no_escape', function($message) {
return $this->baseNotification($message, 'bg-red', 'bold-remove', 'svgcolor-red', false);
});
Blade::directive('eyewitness_success_no_escape', function($message) {
return $this->baseNotification($message, 'bg-green', 'check-simple', 'svgcolor-green', false);
});
Blade::directive('eyewitness_warning_no_escape', function($message) {
return $this->baseNotification($message, 'bg-orange', 'alert-exc', 'svgcolor-orange', false);
});
Blade::directive('eyewitness_info_no_escape', function($message) {
return $this->baseNotification($message, 'bg-blue', 'alert-i', 'svgcolor-blue', false);
});
Blade::directive('eyewitness_tutorial', function($message) {
$s = "<?php if (config('eyewitness.display_helpers', true)): ?>";
$s .= $this->baseNotification($message, 'bg-blue', 'alert-i', 'svgcolor-blue');
$s .= "<?php endif; ?>";
return $s;
});
} | [
"public",
"function",
"registerNotificationDirectives",
"(",
")",
"{",
"Blade",
"::",
"directive",
"(",
"'eyewitness_error'",
",",
"function",
"(",
"$",
"message",
")",
"{",
"return",
"$",
"this",
"->",
"baseNotification",
"(",
"$",
"message",
",",
"'bg-red'",
... | Register notification directives.
@return void | [
"Register",
"notification",
"directives",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/BladeDirectives.php#L44-L84 |
eyewitness/eye | app/Tools/BladeDirectives.php | BladeDirectives.baseNotification | protected function baseNotification($message, $bgColor, $icon, $iconColor, $escape = true)
{
$s = "<?php echo '<div class=\"flex ".$bgColor." bg-circuit bg-md rounded text-center text-white text-sm font-bold mb-6 px-4 py-3 shadow\" role=\"alert\">";
$s .= '<div class="bg-white rounded shadow-lg -mt-6 w-8 h-8">';
$s .= '<div class="h-full flex justify-center items-center '.$iconColor.'">';
$s .= $this->getIconString($icon, '', 24, 24);
$s .= '</div></div>';
if ($escape) {
$s .= "<p class=\"ml-3\">'.e($message).'</p>";
} else {
$s .= "<p class=\"ml-3\">'.$message.'</p>";
}
$s .= "</div>'; ?>";
return $s;
} | php | protected function baseNotification($message, $bgColor, $icon, $iconColor, $escape = true)
{
$s = "<?php echo '<div class=\"flex ".$bgColor." bg-circuit bg-md rounded text-center text-white text-sm font-bold mb-6 px-4 py-3 shadow\" role=\"alert\">";
$s .= '<div class="bg-white rounded shadow-lg -mt-6 w-8 h-8">';
$s .= '<div class="h-full flex justify-center items-center '.$iconColor.'">';
$s .= $this->getIconString($icon, '', 24, 24);
$s .= '</div></div>';
if ($escape) {
$s .= "<p class=\"ml-3\">'.e($message).'</p>";
} else {
$s .= "<p class=\"ml-3\">'.$message.'</p>";
}
$s .= "</div>'; ?>";
return $s;
} | [
"protected",
"function",
"baseNotification",
"(",
"$",
"message",
",",
"$",
"bgColor",
",",
"$",
"icon",
",",
"$",
"iconColor",
",",
"$",
"escape",
"=",
"true",
")",
"{",
"$",
"s",
"=",
"\"<?php echo '<div class=\\\"flex \"",
".",
"$",
"bgColor",
".",
"\" ... | The base notification to use.
@param string $message
@param string $bgColor
@param string $icon
@param string $iconColor
@param bool $escape
@return string | [
"The",
"base",
"notification",
"to",
"use",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/BladeDirectives.php#L96-L111 |
eyewitness/eye | app/Tools/BladeDirectives.php | BladeDirectives.registerSvgDirectives | public function registerSvgDirectives()
{
Blade::directive('eyewitness_svg', function($arguments) {
$arguments = trim(trim($arguments, "("), ")");
$arguments = explode(',', $arguments.',');
$icon = trim($arguments[0], "' ");
$class = trim(isset($arguments[1]) ? $arguments[1] : '', "' ");
$width = trim(isset($arguments[2]) ? $arguments[2] : '', "' ");
$height = trim(isset($arguments[3]) ? $arguments[3] : '', "' ");
return $this->getIconString($icon, $class, $width, $height);
});
} | php | public function registerSvgDirectives()
{
Blade::directive('eyewitness_svg', function($arguments) {
$arguments = trim(trim($arguments, "("), ")");
$arguments = explode(',', $arguments.',');
$icon = trim($arguments[0], "' ");
$class = trim(isset($arguments[1]) ? $arguments[1] : '', "' ");
$width = trim(isset($arguments[2]) ? $arguments[2] : '', "' ");
$height = trim(isset($arguments[3]) ? $arguments[3] : '', "' ");
return $this->getIconString($icon, $class, $width, $height);
});
} | [
"public",
"function",
"registerSvgDirectives",
"(",
")",
"{",
"Blade",
"::",
"directive",
"(",
"'eyewitness_svg'",
",",
"function",
"(",
"$",
"arguments",
")",
"{",
"$",
"arguments",
"=",
"trim",
"(",
"trim",
"(",
"$",
"arguments",
",",
"\"(\"",
")",
",",
... | Register svg directives.
To be used @eyewitness_svg('icon_name', 'class', 'width', 'height')
@return void | [
"Register",
"svg",
"directives",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/BladeDirectives.php#L120-L133 |
eyewitness/eye | app/Tools/BladeDirectives.php | BladeDirectives.registerImageDirectives | public function registerImageDirectives()
{
Blade::directive('eyewitness_img', function($file) {
$file = trim(trim($file, "("), ")");
$string = $this->loadFile(__DIR__.'/../../resources/assets/images/'.trim($file, "'"));
return '<img src="data:image/x-icon;base64,'.base64_encode($string).'"/>';
});
Blade::directive('eyewitness_img_raw_base64', function($file) {
$file = trim(trim($file, "("), ")");
$string = $this->loadFile(__DIR__.'/../../resources/assets/images/'.trim($file, "'"));
return base64_encode($string);
});
} | php | public function registerImageDirectives()
{
Blade::directive('eyewitness_img', function($file) {
$file = trim(trim($file, "("), ")");
$string = $this->loadFile(__DIR__.'/../../resources/assets/images/'.trim($file, "'"));
return '<img src="data:image/x-icon;base64,'.base64_encode($string).'"/>';
});
Blade::directive('eyewitness_img_raw_base64', function($file) {
$file = trim(trim($file, "("), ")");
$string = $this->loadFile(__DIR__.'/../../resources/assets/images/'.trim($file, "'"));
return base64_encode($string);
});
} | [
"public",
"function",
"registerImageDirectives",
"(",
")",
"{",
"Blade",
"::",
"directive",
"(",
"'eyewitness_img'",
",",
"function",
"(",
"$",
"file",
")",
"{",
"$",
"file",
"=",
"trim",
"(",
"trim",
"(",
"$",
"file",
",",
"\"(\"",
")",
",",
"\")\"",
... | Register image directives.
To be used @eyewitness_img('image_name.ext')
@return void | [
"Register",
"image",
"directives",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/BladeDirectives.php#L142-L155 |
eyewitness/eye | app/Tools/BladeDirectives.php | BladeDirectives.getIconString | public function getIconString($icon, $class = '', $width = '', $height = '')
{
$string = $this->loadFile(__DIR__.'/../../resources/assets/icons/'.$icon.'.svg');
$string = substr_replace($string, ' class="'.$class.'"', 4, 0);
if ($width) {
$string = substr_replace($string, 'width="'.$width.'"', strpos($string, 'width='), 10);
$string = substr_replace($string, 'height="'.$height.'"', strpos($string, 'height='), 11);
}
return $string;
} | php | public function getIconString($icon, $class = '', $width = '', $height = '')
{
$string = $this->loadFile(__DIR__.'/../../resources/assets/icons/'.$icon.'.svg');
$string = substr_replace($string, ' class="'.$class.'"', 4, 0);
if ($width) {
$string = substr_replace($string, 'width="'.$width.'"', strpos($string, 'width='), 10);
$string = substr_replace($string, 'height="'.$height.'"', strpos($string, 'height='), 11);
}
return $string;
} | [
"public",
"function",
"getIconString",
"(",
"$",
"icon",
",",
"$",
"class",
"=",
"''",
",",
"$",
"width",
"=",
"''",
",",
"$",
"height",
"=",
"''",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"loadFile",
"(",
"__DIR__",
".",
"'/../../resources/a... | The icon svg as a string.
@param string $icon
@param string $class
@param int $width
@param int $height
@return string | [
"The",
"icon",
"svg",
"as",
"a",
"string",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/BladeDirectives.php#L166-L177 |
eyewitness/eye | app/Queue/WorkerLegacy.php | WorkerLegacy.process | public function process($connection, Job $job, $maxTries = 0, $delay = 0)
{
$startTime = microtime(true);
$result = null;
try {
$result = parent::process($connection, $job, $maxTries, $delay);
} catch (Exception $e) {
$this->recordJobException($e);
} catch (Throwable $e) {
$this->recordJobException($e);
} finally {
$this->recordJobEnd($startTime, $job->resolveName());
return $result;
}
} | php | public function process($connection, Job $job, $maxTries = 0, $delay = 0)
{
$startTime = microtime(true);
$result = null;
try {
$result = parent::process($connection, $job, $maxTries, $delay);
} catch (Exception $e) {
$this->recordJobException($e);
} catch (Throwable $e) {
$this->recordJobException($e);
} finally {
$this->recordJobEnd($startTime, $job->resolveName());
return $result;
}
} | [
"public",
"function",
"process",
"(",
"$",
"connection",
",",
"Job",
"$",
"job",
",",
"$",
"maxTries",
"=",
"0",
",",
"$",
"delay",
"=",
"0",
")",
"{",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"result",
"=",
"null",
";",
"t... | We wrap the standard job processor, and add our tracking code around it.
@param string $connection
@param \Illuminate\Contracts\Queue\Job $job
@param int $maxTries
@param int $delay
@return array|null
@throws \Throwable | [
"We",
"wrap",
"the",
"standard",
"job",
"processor",
"and",
"add",
"our",
"tracking",
"code",
"around",
"it",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/WorkerLegacy.php#L25-L40 |
eyewitness/eye | database/migrations/2018_05_12_000001_modify_eyewitness_io_schedulers_table.php | ModifyEyewitnessIoSchedulersTable.up | public function up()
{
Schema::connection(config('eyewitness.eyewitness_database_connection'))->table('eyewitness_io_schedulers', function (Blueprint $table) {
$table->timestamp('last_run')->nullable()->default(null)->index();
$table->integer('alert_last_run_greater_than')->default(0)->index();
});
} | php | public function up()
{
Schema::connection(config('eyewitness.eyewitness_database_connection'))->table('eyewitness_io_schedulers', function (Blueprint $table) {
$table->timestamp('last_run')->nullable()->default(null)->index();
$table->integer('alert_last_run_greater_than')->default(0)->index();
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"connection",
"(",
"config",
"(",
"'eyewitness.eyewitness_database_connection'",
")",
")",
"->",
"table",
"(",
"'eyewitness_io_schedulers'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$"... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2018_05_12_000001_modify_eyewitness_io_schedulers_table.php#L14-L20 |
eyewitness/eye | database/migrations/2018_05_12_000001_modify_eyewitness_io_schedulers_table.php | ModifyEyewitnessIoSchedulersTable.down | public function down()
{
Schema::connection(config('eyewitness.eyewitness_database_connection'))->table('eyewitness_io_schedulers', function (Blueprint $table) {
$table->dropColumn('last_run');
});
Schema::connection(config('eyewitness.eyewitness_database_connection'))->table('eyewitness_io_schedulers', function (Blueprint $table) {
$table->dropColumn('alert_last_run_greater_than');
});
} | php | public function down()
{
Schema::connection(config('eyewitness.eyewitness_database_connection'))->table('eyewitness_io_schedulers', function (Blueprint $table) {
$table->dropColumn('last_run');
});
Schema::connection(config('eyewitness.eyewitness_database_connection'))->table('eyewitness_io_schedulers', function (Blueprint $table) {
$table->dropColumn('alert_last_run_greater_than');
});
} | [
"public",
"function",
"down",
"(",
")",
"{",
"Schema",
"::",
"connection",
"(",
"config",
"(",
"'eyewitness.eyewitness_database_connection'",
")",
")",
"->",
"table",
"(",
"'eyewitness_io_schedulers'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"... | Reverse the migrations.
@return void | [
"Reverse",
"the",
"migrations",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2018_05_12_000001_modify_eyewitness_io_schedulers_table.php#L27-L35 |
eyewitness/eye | database/migrations/2017_12_01_000008_create_eyewitness_io_queues_table.php | CreateEyewitnessIoQueuesTable.up | public function up()
{
Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_queues', function (Blueprint $table) {
$table->increments('id');
$table->string('connection', 191);
$table->string('tube', 191);
$table->string('driver', 191);
$table->decimal('current_wait_time', 10, 2)->default(0);
$table->boolean('healthy')->nullable()->default(null)->index();
$table->boolean('alert_on_failed_job')->default(true);
$table->integer('alert_heartbeat_greater_than')->default(120);
$table->integer('alert_pending_jobs_greater_than')->default(0);
$table->integer('alert_failed_jobs_greater_than')->default(0);
$table->integer('alert_wait_time_greater_than')->default(0);
$table->timestamp('last_heartbeat')->nullable()->default(null)->index();
$table->timestamp('created_at')->useCurrent();
});
} | php | public function up()
{
Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_queues', function (Blueprint $table) {
$table->increments('id');
$table->string('connection', 191);
$table->string('tube', 191);
$table->string('driver', 191);
$table->decimal('current_wait_time', 10, 2)->default(0);
$table->boolean('healthy')->nullable()->default(null)->index();
$table->boolean('alert_on_failed_job')->default(true);
$table->integer('alert_heartbeat_greater_than')->default(120);
$table->integer('alert_pending_jobs_greater_than')->default(0);
$table->integer('alert_failed_jobs_greater_than')->default(0);
$table->integer('alert_wait_time_greater_than')->default(0);
$table->timestamp('last_heartbeat')->nullable()->default(null)->index();
$table->timestamp('created_at')->useCurrent();
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"connection",
"(",
"config",
"(",
"'eyewitness.eyewitness_database_connection'",
")",
")",
"->",
"create",
"(",
"'eyewitness_io_queues'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2017_12_01_000008_create_eyewitness_io_queues_table.php#L14-L31 |
eyewitness/eye | app/Api.php | Api.sslStart | public function sslStart($domain, $ip = null, $token = null)
{
$headers = [
'connect_timeout' => 60,
'timeout' => 60,
'debug' => false,
'form_params' => [
'domain' => $domain.':443',
'show_test_results' => 'false',
'recheck' => 'true',
'verbosity' => '0'
]
];
if ((! is_null($ip)) && (! is_null($token))) {
$headers['form_params']['choosen_ip'] = $ip[0];
$headers['form_params']['token'] = $token;
}
try {
$response = $this->client->post('https://www.htbridge.com/ssl/api/v1/check/'.time().'.html', $headers);
return json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
app(Eye::class)->logger()->error('Unable to start SSL scan', $e, $domain);
}
return null;
} | php | public function sslStart($domain, $ip = null, $token = null)
{
$headers = [
'connect_timeout' => 60,
'timeout' => 60,
'debug' => false,
'form_params' => [
'domain' => $domain.':443',
'show_test_results' => 'false',
'recheck' => 'true',
'verbosity' => '0'
]
];
if ((! is_null($ip)) && (! is_null($token))) {
$headers['form_params']['choosen_ip'] = $ip[0];
$headers['form_params']['token'] = $token;
}
try {
$response = $this->client->post('https://www.htbridge.com/ssl/api/v1/check/'.time().'.html', $headers);
return json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
app(Eye::class)->logger()->error('Unable to start SSL scan', $e, $domain);
}
return null;
} | [
"public",
"function",
"sslStart",
"(",
"$",
"domain",
",",
"$",
"ip",
"=",
"null",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"headers",
"=",
"[",
"'connect_timeout'",
"=>",
"60",
",",
"'timeout'",
"=>",
"60",
",",
"'debug'",
"=>",
"false",
",",
... | Start an SSL API check from the wonderful people at htbridge.com and their API.
@param string $domain
@param string|null $ip
@param string|null $token
@return mixed | [
"Start",
"an",
"SSL",
"API",
"check",
"from",
"the",
"wonderful",
"people",
"at",
"htbridge",
".",
"com",
"and",
"their",
"API",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Api.php#L101-L128 |
eyewitness/eye | app/Api.php | Api.sslResult | public function sslResult($job_id)
{
$headers = [
'connect_timeout' => 60,
'timeout' => 60,
'debug' => false,
'form_params' => [
'job_id' => $job_id,
]
];
try {
$response = $this->client->post('https://www.htbridge.com/ssl/api/v1/get_result//'.time().'.html', $headers);
return json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
app(Eye::class)->logger()->error('Unable to get SSL results', $e);
}
return null;
} | php | public function sslResult($job_id)
{
$headers = [
'connect_timeout' => 60,
'timeout' => 60,
'debug' => false,
'form_params' => [
'job_id' => $job_id,
]
];
try {
$response = $this->client->post('https://www.htbridge.com/ssl/api/v1/get_result//'.time().'.html', $headers);
return json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
app(Eye::class)->logger()->error('Unable to get SSL results', $e);
}
return null;
} | [
"public",
"function",
"sslResult",
"(",
"$",
"job_id",
")",
"{",
"$",
"headers",
"=",
"[",
"'connect_timeout'",
"=>",
"60",
",",
"'timeout'",
"=>",
"60",
",",
"'debug'",
"=>",
"false",
",",
"'form_params'",
"=>",
"[",
"'job_id'",
"=>",
"$",
"job_id",
","... | Get the SSL API results from the wonderful people at htbridge.com and their API.
@param string $job_id
@return mixed | [
"Get",
"the",
"SSL",
"API",
"results",
"from",
"the",
"wonderful",
"people",
"at",
"htbridge",
".",
"com",
"and",
"their",
"API",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Api.php#L136-L155 |
eyewitness/eye | app/Api.php | Api.composer | public function composer()
{
$this->headers['headers'] = ['Accept' => 'application/json'];
try {
if ($this->isRunningGuzzle5()) {
$this->headers['body'] = ['lock' => fopen(config('eyewitness.composer_lock_file_location'), 'r')];
} else {
$this->headers['multipart'] = [['name' => 'lock', 'contents' => fopen(config('eyewitness.composer_lock_file_location'), 'r')]];
}
$response = $this->client->post('https://security.sensiolabs.org/check_lock', $this->headers);
return json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
app(Eye::class)->logger()->error('SensioLabs Composer Lock check failed', $e);
}
return null;
} | php | public function composer()
{
$this->headers['headers'] = ['Accept' => 'application/json'];
try {
if ($this->isRunningGuzzle5()) {
$this->headers['body'] = ['lock' => fopen(config('eyewitness.composer_lock_file_location'), 'r')];
} else {
$this->headers['multipart'] = [['name' => 'lock', 'contents' => fopen(config('eyewitness.composer_lock_file_location'), 'r')]];
}
$response = $this->client->post('https://security.sensiolabs.org/check_lock', $this->headers);
return json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
app(Eye::class)->logger()->error('SensioLabs Composer Lock check failed', $e);
}
return null;
} | [
"public",
"function",
"composer",
"(",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"'headers'",
"]",
"=",
"[",
"'Accept'",
"=>",
"'application/json'",
"]",
";",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"isRunningGuzzle5",
"(",
")",
")",
"{",
"$",
"... | Run a check for the composer lock against the SensioLabs API.
@return json | [
"Run",
"a",
"check",
"for",
"the",
"composer",
"lock",
"against",
"the",
"SensioLabs",
"API",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Api.php#L162-L179 |
eyewitness/eye | app/Api.php | Api.ping | protected function ping($route, $data = [])
{
if (! config('eyewitness.api_enabled', false)) {
return [false, 'Api Disabled'];
}
$data['app_token'] = config('eyewitness.app_token');
$data['secret_key'] = config('eyewitness.secret_key');
$data['application_environment'] = app()->environment();
$data['eyewitness_version'] = $this->eye->version();
$this->headers['json'] = $data;
for ($i=0; $i<3; $i++) {
sleep($i);
try {
$response = $this->client->post($this->api."/$route", $this->headers);
$result = [$response->getStatusCode(), $response->getReasonPhrase()];
if ($result[0] == "200") {
return $result;
}
} catch (Exception $e) {
$result = [false, $e->getMessage()];
}
}
return $result;
} | php | protected function ping($route, $data = [])
{
if (! config('eyewitness.api_enabled', false)) {
return [false, 'Api Disabled'];
}
$data['app_token'] = config('eyewitness.app_token');
$data['secret_key'] = config('eyewitness.secret_key');
$data['application_environment'] = app()->environment();
$data['eyewitness_version'] = $this->eye->version();
$this->headers['json'] = $data;
for ($i=0; $i<3; $i++) {
sleep($i);
try {
$response = $this->client->post($this->api."/$route", $this->headers);
$result = [$response->getStatusCode(), $response->getReasonPhrase()];
if ($result[0] == "200") {
return $result;
}
} catch (Exception $e) {
$result = [false, $e->getMessage()];
}
}
return $result;
} | [
"protected",
"function",
"ping",
"(",
"$",
"route",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"config",
"(",
"'eyewitness.api_enabled'",
",",
"false",
")",
")",
"{",
"return",
"[",
"false",
",",
"'Api Disabled'",
"]",
";",
"}",
"$",
... | Send the ping notification to the Eyewitness.io API. Includes a 'backoff' retry
attempt if the inital pings fails.
@param string $route
@param array $data
@return mixed | [
"Send",
"the",
"ping",
"notification",
"to",
"the",
"Eyewitness",
".",
"io",
"API",
".",
"Includes",
"a",
"backoff",
"retry",
"attempt",
"if",
"the",
"inital",
"pings",
"fails",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Api.php#L189-L216 |
eyewitness/eye | app/Scheduling/Event.php | Event.run | public function run(Container $container)
{
if ((! $this->ignoreMutex) && $this->withoutOverlapping && (! $this->setMutex())) {
return;
}
((! $this->forceRunInForeground) && $this->runInBackground)
? $this->newCommandInBackground($container)
: $this->runCommandInForeground($container);
} | php | public function run(Container $container)
{
if ((! $this->ignoreMutex) && $this->withoutOverlapping && (! $this->setMutex())) {
return;
}
((! $this->forceRunInForeground) && $this->runInBackground)
? $this->newCommandInBackground($container)
: $this->runCommandInForeground($container);
} | [
"public",
"function",
"run",
"(",
"Container",
"$",
"container",
")",
"{",
"if",
"(",
"(",
"!",
"$",
"this",
"->",
"ignoreMutex",
")",
"&&",
"$",
"this",
"->",
"withoutOverlapping",
"&&",
"(",
"!",
"$",
"this",
"->",
"setMutex",
"(",
")",
")",
")",
... | Run the given event.
@param \Illuminate\Contracts\Container\Container $container
@return void | [
"Run",
"the",
"given",
"event",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L47-L56 |
eyewitness/eye | app/Scheduling/Event.php | Event.runForegroundProcess | protected function runForegroundProcess(Container $container)
{
$this->exitcode = (new Process($this->buildForegroundCommand(), base_path(), null, null, null))->run();
} | php | protected function runForegroundProcess(Container $container)
{
$this->exitcode = (new Process($this->buildForegroundCommand(), base_path(), null, null, null))->run();
} | [
"protected",
"function",
"runForegroundProcess",
"(",
"Container",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"exitcode",
"=",
"(",
"new",
"Process",
"(",
"$",
"this",
"->",
"buildForegroundCommand",
"(",
")",
",",
"base_path",
"(",
")",
",",
"null",
"... | Run the foreground process.
@param \Illuminate\Contracts\Container\Container $container
@return void | [
"Run",
"the",
"foreground",
"process",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L64-L67 |
eyewitness/eye | app/Scheduling/Event.php | Event.newCommandInBackground | protected function newCommandInBackground(Container $container)
{
(new Process($this->buildBackgroundCommand(), base_path(), null, null, null))->run();
} | php | protected function newCommandInBackground(Container $container)
{
(new Process($this->buildBackgroundCommand(), base_path(), null, null, null))->run();
} | [
"protected",
"function",
"newCommandInBackground",
"(",
"Container",
"$",
"container",
")",
"{",
"(",
"new",
"Process",
"(",
"$",
"this",
"->",
"buildBackgroundCommand",
"(",
")",
",",
"base_path",
"(",
")",
",",
"null",
",",
"null",
",",
"null",
")",
")",... | Run the command in the background.
@param \Illuminate\Contracts\Container\Container $container
@return void | [
"Run",
"the",
"command",
"in",
"the",
"background",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L75-L78 |
eyewitness/eye | app/Scheduling/Event.php | Event.buildForegroundCommand | public function buildForegroundCommand()
{
if (Eye::laravelVersionIs('<', '5.5.26')) {
$output = SymfonyProcessUtils::escapeArgument($this->output);
} else {
$output = LaravelProcessUtils::escapeArgument($this->output);
}
return $this->ensureCorrectUser($this->command.$this->getAppendOutput().$output.' 2>&1');
} | php | public function buildForegroundCommand()
{
if (Eye::laravelVersionIs('<', '5.5.26')) {
$output = SymfonyProcessUtils::escapeArgument($this->output);
} else {
$output = LaravelProcessUtils::escapeArgument($this->output);
}
return $this->ensureCorrectUser($this->command.$this->getAppendOutput().$output.' 2>&1');
} | [
"public",
"function",
"buildForegroundCommand",
"(",
")",
"{",
"if",
"(",
"Eye",
"::",
"laravelVersionIs",
"(",
"'<'",
",",
"'5.5.26'",
")",
")",
"{",
"$",
"output",
"=",
"SymfonyProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"output",
")",
... | Build the command for running the event in the foreground.
@return string | [
"Build",
"the",
"command",
"for",
"running",
"the",
"event",
"in",
"the",
"foreground",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L85-L94 |
eyewitness/eye | app/Scheduling/Event.php | Event.buildBackgroundCommand | public function buildBackgroundCommand()
{
$background = $this->formatCommandString('eyewitness:background').' "'.$this->mutexName().'" --force';
if (Eye::laravelVersionIs('<', '5.5.26')) {
$output = SymfonyProcessUtils::escapeArgument($this->getDefaultOutput());
} else {
$output = LaravelProcessUtils::escapeArgument($this->getDefaultOutput());
}
return $this->ensureCorrectUser('('.$background.' > '.$output.' 2>&1) > '.$output.' 2>&1 &');
} | php | public function buildBackgroundCommand()
{
$background = $this->formatCommandString('eyewitness:background').' "'.$this->mutexName().'" --force';
if (Eye::laravelVersionIs('<', '5.5.26')) {
$output = SymfonyProcessUtils::escapeArgument($this->getDefaultOutput());
} else {
$output = LaravelProcessUtils::escapeArgument($this->getDefaultOutput());
}
return $this->ensureCorrectUser('('.$background.' > '.$output.' 2>&1) > '.$output.' 2>&1 &');
} | [
"public",
"function",
"buildBackgroundCommand",
"(",
")",
"{",
"$",
"background",
"=",
"$",
"this",
"->",
"formatCommandString",
"(",
"'eyewitness:background'",
")",
".",
"' \"'",
".",
"$",
"this",
"->",
"mutexName",
"(",
")",
".",
"'\" --force'",
";",
"if",
... | Build the command for running the event in the background.
This is modified from the original, to send the full mutex to the Eyewitness background
command, which will send the whole event back to the scheduler for processing as a
foreground command (but on a seperate process).
Best of both worlds :)
@return string | [
"Build",
"the",
"command",
"for",
"running",
"the",
"event",
"in",
"the",
"background",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L121-L132 |
eyewitness/eye | app/Scheduling/Event.php | Event.ensureOutputIsBeingCapturedForEyewitness | protected function ensureOutputIsBeingCapturedForEyewitness()
{
if (! config('eyewitness.capture_cron_output')) {
return;
}
if ($this->outputNotBeingCaptured()) {
$this->output = storage_path('logs/eyewitness-cron-'.sha1($this->mutexName()).'.cron.log');
}
} | php | protected function ensureOutputIsBeingCapturedForEyewitness()
{
if (! config('eyewitness.capture_cron_output')) {
return;
}
if ($this->outputNotBeingCaptured()) {
$this->output = storage_path('logs/eyewitness-cron-'.sha1($this->mutexName()).'.cron.log');
}
} | [
"protected",
"function",
"ensureOutputIsBeingCapturedForEyewitness",
"(",
")",
"{",
"if",
"(",
"!",
"config",
"(",
"'eyewitness.capture_cron_output'",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"outputNotBeingCaptured",
"(",
")",
")",
"{",
... | Ensure that output is being captured if not already set by the event.
@return void | [
"Ensure",
"that",
"output",
"is",
"being",
"captured",
"if",
"not",
"already",
"set",
"by",
"the",
"event",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L150-L159 |
eyewitness/eye | app/Scheduling/Event.php | Event.retrieveOutput | protected function retrieveOutput()
{
if ((! config('eyewitness.capture_cron_output')) || (! file_exists($this->output))) {
return null;
}
$text = file_get_contents($this->output);
if (str_contains($this->output, 'eyewitness_cron_') && file_exists($this->output)) {
unlink($this->output);
}
return substr($text, 0, 15000);
} | php | protected function retrieveOutput()
{
if ((! config('eyewitness.capture_cron_output')) || (! file_exists($this->output))) {
return null;
}
$text = file_get_contents($this->output);
if (str_contains($this->output, 'eyewitness_cron_') && file_exists($this->output)) {
unlink($this->output);
}
return substr($text, 0, 15000);
} | [
"protected",
"function",
"retrieveOutput",
"(",
")",
"{",
"if",
"(",
"(",
"!",
"config",
"(",
"'eyewitness.capture_cron_output'",
")",
")",
"||",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"output",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
... | Get the output from the last scheduled job. Only remove the file if we created
it specifically for Eyewitness - otherwise leave it alone for the framework
to handle as normal.
@return mixed | [
"Get",
"the",
"output",
"from",
"the",
"last",
"scheduled",
"job",
".",
"Only",
"remove",
"the",
"file",
"if",
"we",
"created",
"it",
"specifically",
"for",
"Eyewitness",
"-",
"otherwise",
"leave",
"it",
"alone",
"for",
"the",
"framework",
"to",
"handle",
... | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/Event.php#L168-L181 |
eyewitness/eye | app/Scheduling/RunDue.php | RunDue.getNextRunDue | public function getNextRunDue($schedule, $timezone)
{
return Carbon::instance(CronExpression::factory($schedule)->getNextRunDate('now', 0, false, $timezone));
} | php | public function getNextRunDue($schedule, $timezone)
{
return Carbon::instance(CronExpression::factory($schedule)->getNextRunDate('now', 0, false, $timezone));
} | [
"public",
"function",
"getNextRunDue",
"(",
"$",
"schedule",
",",
"$",
"timezone",
")",
"{",
"return",
"Carbon",
"::",
"instance",
"(",
"CronExpression",
"::",
"factory",
"(",
"$",
"schedule",
")",
"->",
"getNextRunDate",
"(",
"'now'",
",",
"0",
",",
"fals... | Determine when the next occurance of the scheduler is due to run.
@param string $schedule
@param string $timezone
@return \Carbon\Carbon | [
"Determine",
"when",
"the",
"next",
"occurance",
"of",
"the",
"scheduler",
"is",
"due",
"to",
"run",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/RunDue.php#L17-L20 |
eyewitness/eye | app/Scheduling/RunDue.php | RunDue.getNextCheckDue | public function getNextCheckDue($schedule, $timezone, $extra_seconds = 0)
{
return $this->getNextRunDue($schedule, $timezone)->addMinutes(5)->addSeconds($extra_seconds);
} | php | public function getNextCheckDue($schedule, $timezone, $extra_seconds = 0)
{
return $this->getNextRunDue($schedule, $timezone)->addMinutes(5)->addSeconds($extra_seconds);
} | [
"public",
"function",
"getNextCheckDue",
"(",
"$",
"schedule",
",",
"$",
"timezone",
",",
"$",
"extra_seconds",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"getNextRunDue",
"(",
"$",
"schedule",
",",
"$",
"timezone",
")",
"->",
"addMinutes",
"(",
"5... | Determine when the next check of the scheduler is due.
@param string $schedule
@param string $timezone
@param int $extra_seconds
@return \Carbon\Carbon | [
"Determine",
"when",
"the",
"next",
"check",
"of",
"the",
"scheduler",
"is",
"due",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/RunDue.php#L30-L33 |
eyewitness/eye | app/Scheduling/RunDue.php | RunDue.setNextSchedule | public function setNextSchedule($scheduler)
{
$scheduler->next_run_due = $this->getNextRunDue($scheduler->schedule, $scheduler->timezone);
$scheduler->next_check_due = $this->getNextCheckDue($scheduler->schedule, $scheduler->timezone, $scheduler->alert_run_time_greater_than);
$scheduler->save();
} | php | public function setNextSchedule($scheduler)
{
$scheduler->next_run_due = $this->getNextRunDue($scheduler->schedule, $scheduler->timezone);
$scheduler->next_check_due = $this->getNextCheckDue($scheduler->schedule, $scheduler->timezone, $scheduler->alert_run_time_greater_than);
$scheduler->save();
} | [
"public",
"function",
"setNextSchedule",
"(",
"$",
"scheduler",
")",
"{",
"$",
"scheduler",
"->",
"next_run_due",
"=",
"$",
"this",
"->",
"getNextRunDue",
"(",
"$",
"scheduler",
"->",
"schedule",
",",
"$",
"scheduler",
"->",
"timezone",
")",
";",
"$",
"sch... | Set the next checks for the scheduler.
@param \Eyewitness\Eye\Repo\Scheduler $scheduler
@return void | [
"Set",
"the",
"next",
"checks",
"for",
"the",
"scheduler",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/RunDue.php#L41-L46 |
eyewitness/eye | app/Queue/Worker.php | Worker.process | public function process($connectionName, $job, WorkerOptions $options)
{
$startTime = microtime(true);
try {
parent::process($connectionName, $job, $options);
} catch (Exception $e) {
$this->recordJobException($e);
} catch (Throwable $e) {
$this->recordJobException($e);
} finally {
$this->recordJobEnd($startTime, $job->resolveName());
}
} | php | public function process($connectionName, $job, WorkerOptions $options)
{
$startTime = microtime(true);
try {
parent::process($connectionName, $job, $options);
} catch (Exception $e) {
$this->recordJobException($e);
} catch (Throwable $e) {
$this->recordJobException($e);
} finally {
$this->recordJobEnd($startTime, $job->resolveName());
}
} | [
"public",
"function",
"process",
"(",
"$",
"connectionName",
",",
"$",
"job",
",",
"WorkerOptions",
"$",
"options",
")",
"{",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"try",
"{",
"parent",
"::",
"process",
"(",
"$",
"connectionName",
",... | We wrap the standard job processor, and add our tracking code around it.
@param string $connectionName
@param \Illuminate\Contracts\Queue\Job $job
@param \Illuminate\Queue\WorkerOptions $options
@return void
@throws \Throwable | [
"We",
"wrap",
"the",
"standard",
"job",
"processor",
"and",
"add",
"our",
"tracking",
"code",
"around",
"it",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/Worker.php#L24-L37 |
eyewitness/eye | app/Http/Controllers/DnsController.php | DnsController.show | public function show(Request $request)
{
$this->validate($request, [
'domain' => 'required|string'
]);
$dns = DNS::where('meta', $request->domain)->orderBy('created_at', 'desc')->get();
if (! count($dns)) {
return redirect(route('eyewitness.dashboard').'#dns')->withError('Sorry - we could not find any DNS history for that domain. If you have just added the record, you should wait for the first test to run (usaully within an hour).');
}
return view('eyewitness::dns.show')->withEye(app(Eye::class))
->withDomain($request->domain)
->withDns($dns);
} | php | public function show(Request $request)
{
$this->validate($request, [
'domain' => 'required|string'
]);
$dns = DNS::where('meta', $request->domain)->orderBy('created_at', 'desc')->get();
if (! count($dns)) {
return redirect(route('eyewitness.dashboard').'#dns')->withError('Sorry - we could not find any DNS history for that domain. If you have just added the record, you should wait for the first test to run (usaully within an hour).');
}
return view('eyewitness::dns.show')->withEye(app(Eye::class))
->withDomain($request->domain)
->withDns($dns);
} | [
"public",
"function",
"show",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
",",
"[",
"'domain'",
"=>",
"'required|string'",
"]",
")",
";",
"$",
"dns",
"=",
"DNS",
"::",
"where",
"(",
"'meta'",
",",
"$"... | Show the DNS history.
@param Request $request
@return \Illuminate\Http\Response | [
"Show",
"the",
"DNS",
"history",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/DnsController.php#L21-L36 |
eyewitness/eye | app/Notifications/Drivers/Slack.php | Slack.parseMeta | protected function parseMeta($meta)
{
$fields = [];
foreach ($meta as $key => $value) {
$fields[] = [
'title' => $key,
'value' => $value,
];
}
return $fields;
} | php | protected function parseMeta($meta)
{
$fields = [];
foreach ($meta as $key => $value) {
$fields[] = [
'title' => $key,
'value' => $value,
];
}
return $fields;
} | [
"protected",
"function",
"parseMeta",
"(",
"$",
"meta",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"meta",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"$",
"key",
",... | Format the meta content for Slack attachments.
@param array $meta
@return array | [
"Format",
"the",
"meta",
"content",
"for",
"Slack",
"attachments",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Drivers/Slack.php#L55-L67 |
eyewitness/eye | app/Notifications/Messages/Scheduler/Overdue.php | Overdue.meta | public function meta()
{
return [
'Command' => e($this->meta['scheduler']->command),
'Schedule' => e($this->meta['scheduler']->schedule),
'Started at' => e($this->meta['scheduler']->last_run->diffForHumans()),
'Your alert threshold' => e($this->meta['scheduler']->alert_run_time_greater_than).' seconds',
];
} | php | public function meta()
{
return [
'Command' => e($this->meta['scheduler']->command),
'Schedule' => e($this->meta['scheduler']->schedule),
'Started at' => e($this->meta['scheduler']->last_run->diffForHumans()),
'Your alert threshold' => e($this->meta['scheduler']->alert_run_time_greater_than).' seconds',
];
} | [
"public",
"function",
"meta",
"(",
")",
"{",
"return",
"[",
"'Command'",
"=>",
"e",
"(",
"$",
"this",
"->",
"meta",
"[",
"'scheduler'",
"]",
"->",
"command",
")",
",",
"'Schedule'",
"=>",
"e",
"(",
"$",
"this",
"->",
"meta",
"[",
"'scheduler'",
"]",
... | Any meta information for the message.
@return array | [
"Any",
"meta",
"information",
"for",
"the",
"message",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Scheduler/Overdue.php#L34-L42 |
eyewitness/eye | app/Scheduling/ApplicationBackport.php | ApplicationBackport.formatCommandString | protected function formatCommandString($string)
{
if (Eye::laravelVersionIs('>=', '5.4.0')) {
return Application::formatCommandString($string);
}
return sprintf('%s %s %s', $this->phpBinary(), $this->artisanBinary(), $string);
} | php | protected function formatCommandString($string)
{
if (Eye::laravelVersionIs('>=', '5.4.0')) {
return Application::formatCommandString($string);
}
return sprintf('%s %s %s', $this->phpBinary(), $this->artisanBinary(), $string);
} | [
"protected",
"function",
"formatCommandString",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"Eye",
"::",
"laravelVersionIs",
"(",
"'>='",
",",
"'5.4.0'",
")",
")",
"{",
"return",
"Application",
"::",
"formatCommandString",
"(",
"$",
"string",
")",
";",
"}",
"... | Finalize the event's command syntax with the correct user.
@param string $command
@return string | [
"Finalize",
"the",
"event",
"s",
"command",
"syntax",
"with",
"the",
"correct",
"user",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/ApplicationBackport.php#L20-L27 |
eyewitness/eye | app/Scheduling/ApplicationBackport.php | ApplicationBackport.phpBinary | public static function phpBinary()
{
if (Eye::laravelVersionIs('<', '5.5.26')) {
return SymfonyProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
}
return LaravelProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
} | php | public static function phpBinary()
{
if (Eye::laravelVersionIs('<', '5.5.26')) {
return SymfonyProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
}
return LaravelProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
} | [
"public",
"static",
"function",
"phpBinary",
"(",
")",
"{",
"if",
"(",
"Eye",
"::",
"laravelVersionIs",
"(",
"'<'",
",",
"'5.5.26'",
")",
")",
"{",
"return",
"SymfonyProcessUtils",
"::",
"escapeArgument",
"(",
"(",
"new",
"PhpExecutableFinder",
")",
"->",
"f... | Determine the proper PHP executable.
https://github.com/laravel/framework/pull/22448
@return string | [
"Determine",
"the",
"proper",
"PHP",
"executable",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/ApplicationBackport.php#L36-L43 |
eyewitness/eye | app/Scheduling/ApplicationBackport.php | ApplicationBackport.artisanBinary | public static function artisanBinary()
{
if (Eye::laravelVersionIs('<', '5.5.26')) {
return defined('ARTISAN_BINARY') ? SymfonyProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
}
return defined('ARTISAN_BINARY') ? LaravelProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
} | php | public static function artisanBinary()
{
if (Eye::laravelVersionIs('<', '5.5.26')) {
return defined('ARTISAN_BINARY') ? SymfonyProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
}
return defined('ARTISAN_BINARY') ? LaravelProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
} | [
"public",
"static",
"function",
"artisanBinary",
"(",
")",
"{",
"if",
"(",
"Eye",
"::",
"laravelVersionIs",
"(",
"'<'",
",",
"'5.5.26'",
")",
")",
"{",
"return",
"defined",
"(",
"'ARTISAN_BINARY'",
")",
"?",
"SymfonyProcessUtils",
"::",
"escapeArgument",
"(",
... | Determine the proper Artisan executable.
@return string | [
"Determine",
"the",
"proper",
"Artisan",
"executable",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/ApplicationBackport.php#L50-L57 |
eyewitness/eye | app/Commands/PruneCommand.php | PruneCommand.handle | public function handle()
{
$date = Carbon::now()->subDays(config('eyewitness.days_to_keep_history'));
\Eyewitness\Eye\Repo\History\Scheduler::where('created_at', '<', $date)->delete();
\Eyewitness\Eye\Repo\History\Database::where('created_at', '<', $date)->delete();
\Eyewitness\Eye\Repo\History\Custom::where('created_at', '<', $date)->delete();
\Eyewitness\Eye\Repo\History\Queue::where('date', '<', $date)->delete();
\Eyewitness\Eye\Repo\Notifications\History::where('created_at', '<', $date)->delete();
$this->info('Eyewitness prune complete.');
} | php | public function handle()
{
$date = Carbon::now()->subDays(config('eyewitness.days_to_keep_history'));
\Eyewitness\Eye\Repo\History\Scheduler::where('created_at', '<', $date)->delete();
\Eyewitness\Eye\Repo\History\Database::where('created_at', '<', $date)->delete();
\Eyewitness\Eye\Repo\History\Custom::where('created_at', '<', $date)->delete();
\Eyewitness\Eye\Repo\History\Queue::where('date', '<', $date)->delete();
\Eyewitness\Eye\Repo\Notifications\History::where('created_at', '<', $date)->delete();
$this->info('Eyewitness prune complete.');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"date",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"subDays",
"(",
"config",
"(",
"'eyewitness.days_to_keep_history'",
")",
")",
";",
"\\",
"Eyewitness",
"\\",
"Eye",
"\\",
"Repo",
"\\",
"History",
"\\... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/PruneCommand.php#L36-L47 |
eyewitness/eye | app/Http/Controllers/AuthController.php | AuthController.login | public function login(Request $request)
{
if ($request->session()->has('eyewitness:auth') || Eye::check($request)) {
return redirect(route('eyewitness.dashboard').'#overview');
}
if (config('eyewitness.login_disabled', false)) {
return redirect('/');
}
return view('eyewitness::login');
} | php | public function login(Request $request)
{
if ($request->session()->has('eyewitness:auth') || Eye::check($request)) {
return redirect(route('eyewitness.dashboard').'#overview');
}
if (config('eyewitness.login_disabled', false)) {
return redirect('/');
}
return view('eyewitness::login');
} | [
"public",
"function",
"login",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"has",
"(",
"'eyewitness:auth'",
")",
"||",
"Eye",
"::",
"check",
"(",
"$",
"request",
")",
")",
"{",
"return",
"redi... | Get login page.
@return \Illuminate\Http\Response | [
"Get",
"login",
"page",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/AuthController.php#L16-L27 |
eyewitness/eye | app/Http/Controllers/AuthController.php | AuthController.authenticate | public function authenticate(Request $request)
{
if (config('eyewitness.login_disabled', false)) {
return redirect('/');
}
if (! app(Eye::class)->checkConfig()) {
return redirect()->route('eyewitness.login')->withError('Eyewitness has not been configured correctly. Login has been disabled for your security. Please run "php artisan eyewitness:debug" to determine the issue.');
}
if ($request->app_token !== config('eyewitness.app_token') ||
$request->secret_key !== config('eyewitness.secret_key')) {
return redirect()->route('eyewitness.login')->withError('Incorrect credentials.');
}
$request->session()->put('eyewitness:auth', 1);
return redirect(route('eyewitness.dashboard').'#overview');
} | php | public function authenticate(Request $request)
{
if (config('eyewitness.login_disabled', false)) {
return redirect('/');
}
if (! app(Eye::class)->checkConfig()) {
return redirect()->route('eyewitness.login')->withError('Eyewitness has not been configured correctly. Login has been disabled for your security. Please run "php artisan eyewitness:debug" to determine the issue.');
}
if ($request->app_token !== config('eyewitness.app_token') ||
$request->secret_key !== config('eyewitness.secret_key')) {
return redirect()->route('eyewitness.login')->withError('Incorrect credentials.');
}
$request->session()->put('eyewitness:auth', 1);
return redirect(route('eyewitness.dashboard').'#overview');
} | [
"public",
"function",
"authenticate",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"config",
"(",
"'eyewitness.login_disabled'",
",",
"false",
")",
")",
"{",
"return",
"redirect",
"(",
"'/'",
")",
";",
"}",
"if",
"(",
"!",
"app",
"(",
"Eye",
":... | Attempt to authenticate.
@return \Illuminate\Http\Response | [
"Attempt",
"to",
"authenticate",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/AuthController.php#L34-L52 |
eyewitness/eye | app/Notifications/Messages/Queue/Offline.php | Offline.meta | public function meta()
{
return [
'Connection' => e($this->meta['queue']->connection),
'Queue' => e($this->meta['queue']->tube),
'Driver' => e($this->meta['queue']->driver),
'Your threshold' => e($this->meta['queue']->alert_heartbeat_greater_than).'s',
'Last heartbeat' => e($this->meta['queue']->last_heartbeat),
];
} | php | public function meta()
{
return [
'Connection' => e($this->meta['queue']->connection),
'Queue' => e($this->meta['queue']->tube),
'Driver' => e($this->meta['queue']->driver),
'Your threshold' => e($this->meta['queue']->alert_heartbeat_greater_than).'s',
'Last heartbeat' => e($this->meta['queue']->last_heartbeat),
];
} | [
"public",
"function",
"meta",
"(",
")",
"{",
"return",
"[",
"'Connection'",
"=>",
"e",
"(",
"$",
"this",
"->",
"meta",
"[",
"'queue'",
"]",
"->",
"connection",
")",
",",
"'Queue'",
"=>",
"e",
"(",
"$",
"this",
"->",
"meta",
"[",
"'queue'",
"]",
"->... | Any meta information for the message.
@return array | [
"Any",
"meta",
"information",
"for",
"the",
"message",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Queue/Offline.php#L44-L53 |
eyewitness/eye | app/Notifications/Drivers/Email.php | Email.fire | public function fire($recipient, $message)
{
// because we cant use "$message" on Laravel emails
$msg = $message;
try {
Mail::send('eyewitness::email.notification', ['recipient' => $recipient, 'msg' => $msg], function ($m) use ($recipient, $msg) {
$m->to($recipient->address);
$m->subject($msg->title());
});
} catch (Exception $e) {
app(Eye::class)->logger()->error('Unable to send Email noitification', $e);
}
} | php | public function fire($recipient, $message)
{
// because we cant use "$message" on Laravel emails
$msg = $message;
try {
Mail::send('eyewitness::email.notification', ['recipient' => $recipient, 'msg' => $msg], function ($m) use ($recipient, $msg) {
$m->to($recipient->address);
$m->subject($msg->title());
});
} catch (Exception $e) {
app(Eye::class)->logger()->error('Unable to send Email noitification', $e);
}
} | [
"public",
"function",
"fire",
"(",
"$",
"recipient",
",",
"$",
"message",
")",
"{",
"// because we cant use \"$message\" on Laravel emails",
"$",
"msg",
"=",
"$",
"message",
";",
"try",
"{",
"Mail",
"::",
"send",
"(",
"'eyewitness::email.notification'",
",",
"[",
... | Fire a notification.
@param \Eyewitness\Eye\Repo\Notifications\Recipient $recipient
@param \Eyewitness\Eye\Notifications\Messages\MessageInterface $message
@return void | [
"Fire",
"a",
"notification",
"."
] | train | https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Drivers/Email.php#L18-L31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.