repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
etechnika/idna-convert | lib/phlylabs/uctc.php | uctc.convert | public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC)
{
self::$safe_mode = ($safe_mode) ? true : false;
self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC;
if (self::$safe_mode) self::$allow_overlong = true;
if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified');
if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified');
if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);');
if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);');
return $data;
} | php | public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC)
{
self::$safe_mode = ($safe_mode) ? true : false;
self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC;
if (self::$safe_mode) self::$allow_overlong = true;
if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified');
if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified');
if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);');
if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);');
return $data;
} | [
"public",
"static",
"function",
"convert",
"(",
"$",
"data",
",",
"$",
"from",
",",
"$",
"to",
",",
"$",
"safe_mode",
"=",
"false",
",",
"$",
"safe_char",
"=",
"0xFFFC",
")",
"{",
"self",
"::",
"$",
"safe_mode",
"=",
"(",
"$",
"safe_mode",
")",
"?"... | The actual conversion routine
@param mixed $data The data to convert, usually a string, array when converting from UCS-4 array
@param string $from Original encoding of the data
@param string $to Target encoding of the data
@param bool $safe_mode SafeMode tries to correct invalid codepoints
@return mixed False on failure, String or array on success, depending on target encoding
@access public
@since 0.0.1 | [
"The",
"actual",
"conversion",
"routine"
] | e6c49ff6f13b18f2f22ed26ba4f6e870788b8033 | https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/lib/phlylabs/uctc.php#L37-L47 | train |
gamajo/genesis-theme-toolkit | src/CustomLogo.php | CustomLogo.inlineLogoMarkup | public function inlineLogoMarkup($title, $inside, $wrap): string
{
if (!$this->hasCustomLogo()) {
return $title;
}
$inside = sprintf(
'<span class="screen-reader-text">%s</span>%s',
esc_html(get_bloginfo('name')),
get_custom_logo()
);
// Build the title.
$title = genesis_markup(array(
'open' => sprintf("<{$wrap} %s>", genesis_attr('site-title')),
'close' => "</{$wrap}>",
'content' => $inside,
'context' => 'site-title',
'echo' => false,
'params' => array(
'wrap' => $wrap,
),
));
return $title;
} | php | public function inlineLogoMarkup($title, $inside, $wrap): string
{
if (!$this->hasCustomLogo()) {
return $title;
}
$inside = sprintf(
'<span class="screen-reader-text">%s</span>%s',
esc_html(get_bloginfo('name')),
get_custom_logo()
);
// Build the title.
$title = genesis_markup(array(
'open' => sprintf("<{$wrap} %s>", genesis_attr('site-title')),
'close' => "</{$wrap}>",
'content' => $inside,
'context' => 'site-title',
'echo' => false,
'params' => array(
'wrap' => $wrap,
),
));
return $title;
} | [
"public",
"function",
"inlineLogoMarkup",
"(",
"$",
"title",
",",
"$",
"inside",
",",
"$",
"wrap",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCustomLogo",
"(",
")",
")",
"{",
"return",
"$",
"title",
";",
"}",
"$",
"inside",
"="... | Add an image inline in the site title element for the logo.
@author @_AlphaBlossom
@author @_neilgee
@author @_JiveDig
@author @_srikat
@param string $title Current markup of title.
@param string $inside Markup inside the title.
@param string $wrap Wrapping element for the title.
@return string Updated site title markup. | [
"Add",
"an",
"image",
"inline",
"in",
"the",
"site",
"title",
"element",
"for",
"the",
"logo",
"."
] | 051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff | https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/CustomLogo.php#L94-L119 | train |
gamajo/genesis-theme-toolkit | src/ThemeSettings.php | ThemeSettings.themeSettingsDefaults | public function themeSettingsDefaults($defaults): array
{
$defaultsConfig = $this->config->getSubConfig(self::DEFAULTS);
foreach ($defaultsConfig->getArrayCopy() as $key => $value) {
$defaults[$key] = $value;
}
return $defaults;
} | php | public function themeSettingsDefaults($defaults): array
{
$defaultsConfig = $this->config->getSubConfig(self::DEFAULTS);
foreach ($defaultsConfig->getArrayCopy() as $key => $value) {
$defaults[$key] = $value;
}
return $defaults;
} | [
"public",
"function",
"themeSettingsDefaults",
"(",
"$",
"defaults",
")",
":",
"array",
"{",
"$",
"defaultsConfig",
"=",
"$",
"this",
"->",
"config",
"->",
"getSubConfig",
"(",
"self",
"::",
"DEFAULTS",
")",
";",
"foreach",
"(",
"$",
"defaultsConfig",
"->",
... | Change the theme settings defaults.
@param array $defaults Existing theme settings defaults.
@return array Theme settings defaults. | [
"Change",
"the",
"theme",
"settings",
"defaults",
"."
] | 051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff | https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/ThemeSettings.php#L121-L129 | train |
gamajo/genesis-theme-toolkit | src/ThemeSettings.php | ThemeSettings.forceValues | public function forceValues()
{
$forceConfig = $this->config->getSubConfig(self::FORCE);
foreach ($forceConfig->getArrayCopy() as $key => $value) {
add_filter("genesis_pre_get_option_{$key}", function () use ($value) {
return $value;
});
}
} | php | public function forceValues()
{
$forceConfig = $this->config->getSubConfig(self::FORCE);
foreach ($forceConfig->getArrayCopy() as $key => $value) {
add_filter("genesis_pre_get_option_{$key}", function () use ($value) {
return $value;
});
}
} | [
"public",
"function",
"forceValues",
"(",
")",
"{",
"$",
"forceConfig",
"=",
"$",
"this",
"->",
"config",
"->",
"getSubConfig",
"(",
"self",
"::",
"FORCE",
")",
";",
"foreach",
"(",
"$",
"forceConfig",
"->",
"getArrayCopy",
"(",
")",
"as",
"$",
"key",
... | Force specific values to be returned. | [
"Force",
"specific",
"values",
"to",
"be",
"returned",
"."
] | 051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff | https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/ThemeSettings.php#L134-L142 | train |
etechnika/idna-convert | lib/phlylabs/idna_convert.class.php | idna_convert._apply_cannonical_ordering | protected function _apply_cannonical_ordering($input)
{
$swap = true;
$size = count($input);
while ($swap) {
$swap = false;
$last = $this->_get_combining_class(intval($input[0]));
for ($i = 0; $i < $size - 1; ++$i) {
$next = $this->_get_combining_class(intval($input[$i + 1]));
if ($next != 0 && $last > $next) {
// Move item leftward until it fits
for ($j = $i + 1; $j > 0; --$j) {
if ($this->_get_combining_class(intval($input[$j - 1])) <= $next) {
break;
}
$t = intval($input[$j]);
$input[$j] = intval($input[$j - 1]);
$input[$j - 1] = $t;
$swap = true;
}
// Reentering the loop looking at the old character again
$next = $last;
}
$last = $next;
}
}
return $input;
} | php | protected function _apply_cannonical_ordering($input)
{
$swap = true;
$size = count($input);
while ($swap) {
$swap = false;
$last = $this->_get_combining_class(intval($input[0]));
for ($i = 0; $i < $size - 1; ++$i) {
$next = $this->_get_combining_class(intval($input[$i + 1]));
if ($next != 0 && $last > $next) {
// Move item leftward until it fits
for ($j = $i + 1; $j > 0; --$j) {
if ($this->_get_combining_class(intval($input[$j - 1])) <= $next) {
break;
}
$t = intval($input[$j]);
$input[$j] = intval($input[$j - 1]);
$input[$j - 1] = $t;
$swap = true;
}
// Reentering the loop looking at the old character again
$next = $last;
}
$last = $next;
}
}
return $input;
} | [
"protected",
"function",
"_apply_cannonical_ordering",
"(",
"$",
"input",
")",
"{",
"$",
"swap",
"=",
"true",
";",
"$",
"size",
"=",
"count",
"(",
"$",
"input",
")",
";",
"while",
"(",
"$",
"swap",
")",
"{",
"$",
"swap",
"=",
"false",
";",
"$",
"la... | Applies the cannonical ordering of a decomposed UCS4 sequence
@param array Decomposed UCS4 sequence
@return array Ordered USC4 sequence | [
"Applies",
"the",
"cannonical",
"ordering",
"of",
"a",
"decomposed",
"UCS4",
"sequence"
] | e6c49ff6f13b18f2f22ed26ba4f6e870788b8033 | https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/lib/phlylabs/idna_convert.class.php#L779-L806 | train |
etechnika/idna-convert | src/Etechnika/IdnaConvert/TranscodeWrapper.php | TranscodeWrapper.encodeUtf8 | public static function encodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false)
{
return encode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false);
} | php | public static function encodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false)
{
return encode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false);
} | [
"public",
"static",
"function",
"encodeUtf8",
"(",
"$",
"strValue",
"=",
"''",
",",
"$",
"strEncoding",
"=",
"'iso-8859-1'",
",",
"$",
"booSafemode",
"=",
"false",
")",
"{",
"return",
"encode_utf8",
"(",
"$",
"strValue",
"=",
"''",
",",
"$",
"strEncoding",... | Convert a string to UTF-8
Return the encoded string or false on failure
@param string $strValue
@param string $strEncoding
@param bool $booSafemode
@return string string|false on failure
@see encode_utf8 | [
"Convert",
"a",
"string",
"to",
"UTF",
"-",
"8"
] | e6c49ff6f13b18f2f22ed26ba4f6e870788b8033 | https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/src/Etechnika/IdnaConvert/TranscodeWrapper.php#L26-L29 | train |
etechnika/idna-convert | src/Etechnika/IdnaConvert/TranscodeWrapper.php | TranscodeWrapper.decodeUtf8 | public static function decodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false)
{
return decode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false);
} | php | public static function decodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false)
{
return decode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false);
} | [
"public",
"static",
"function",
"decodeUtf8",
"(",
"$",
"strValue",
"=",
"''",
",",
"$",
"strEncoding",
"=",
"'iso-8859-1'",
",",
"$",
"booSafemode",
"=",
"false",
")",
"{",
"return",
"decode_utf8",
"(",
"$",
"strValue",
"=",
"''",
",",
"$",
"strEncoding",... | Convert a string from UTF-8 to any of various encodings
Return if set to TRUE, the original string is retunred on errors
@param string $strValue
@param string $strEncoding
@param bool $booSafemode
@return string|false on failure
@see decode_utf8 | [
"Convert",
"a",
"string",
"from",
"UTF",
"-",
"8",
"to",
"any",
"of",
"various",
"encodings"
] | e6c49ff6f13b18f2f22ed26ba4f6e870788b8033 | https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/src/Etechnika/IdnaConvert/TranscodeWrapper.php#L44-L47 | train |
php-yaoi/php-yaoi | src/Database/Entity.php | Entity.table | public static function table($alias = null)
{
$className = get_called_class();
$tableKey = $className . ($alias ? ':' . $alias : '');
$table = &self::$tables[$tableKey];
if (null !== $table) {
return $table;
}
/*
if (isset(self::$settingColumns[$tableKey])) {
throw new Exception('Already setting columns');
}
$columns = new \stdClass();
self::$settingColumns[$tableKey] = $columns;
unset(self::$settingColumns[$tableKey]);
*/
$schemaName = Utils::fromCamelCase(str_replace('\\', '', $className));
$table = new Table(null, self::getDatabase($className), $schemaName);
$table->entityClassName = $className;
$table->alias = $alias;
static::setUpColumns($table->columns);
static::setUpTable($table, $table->columns);
return $table;
} | php | public static function table($alias = null)
{
$className = get_called_class();
$tableKey = $className . ($alias ? ':' . $alias : '');
$table = &self::$tables[$tableKey];
if (null !== $table) {
return $table;
}
/*
if (isset(self::$settingColumns[$tableKey])) {
throw new Exception('Already setting columns');
}
$columns = new \stdClass();
self::$settingColumns[$tableKey] = $columns;
unset(self::$settingColumns[$tableKey]);
*/
$schemaName = Utils::fromCamelCase(str_replace('\\', '', $className));
$table = new Table(null, self::getDatabase($className), $schemaName);
$table->entityClassName = $className;
$table->alias = $alias;
static::setUpColumns($table->columns);
static::setUpTable($table, $table->columns);
return $table;
} | [
"public",
"static",
"function",
"table",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"$",
"tableKey",
"=",
"$",
"className",
".",
"(",
"$",
"alias",
"?",
"':'",
".",
"$",
"alias",
":",
"''",
"... | Method should return table definition of entity
@return Table | [
"Method",
"should",
"return",
"table",
"definition",
"of",
"entity"
] | 5be99ff5757e11af01ed1cc3dbabf0438100f94e | https://github.com/php-yaoi/php-yaoi/blob/5be99ff5757e11af01ed1cc3dbabf0438100f94e/src/Database/Entity.php#L30-L54 | train |
atk4/core | src/Exception.php | Exception.toString | public function toString($val)
{
if (is_object($val) && !$val instanceof \Closure) {
if (isset($val->_trackableTrait)) {
return get_class($val).' ('.$val->name.')';
}
return 'Object '.get_class($val);
}
return json_encode($val);
} | php | public function toString($val)
{
if (is_object($val) && !$val instanceof \Closure) {
if (isset($val->_trackableTrait)) {
return get_class($val).' ('.$val->name.')';
}
return 'Object '.get_class($val);
}
return json_encode($val);
} | [
"public",
"function",
"toString",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"val",
")",
"&&",
"!",
"$",
"val",
"instanceof",
"\\",
"Closure",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"val",
"->",
"_trackableTrait",
")",
")",
"{",
... | Safely converts some value to string.
@param mixed $val
@return string | [
"Safely",
"converts",
"some",
"value",
"to",
"string",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/Exception.php#L373-L384 | train |
atk4/core | src/ContainerTrait.php | ContainerTrait._shorten | protected function _shorten($desired)
{
if (
isset($this->_appScopeTrait) &&
isset($this->app->max_name_length) &&
strlen($desired) > $this->app->max_name_length
) {
/*
* Basic rules: hash is 10 character long (8+2 for separator)
* We need at least 5 characters on the right side. Total must not exceed
* max_name_length. First chop will be max-10, then chop size will increase by
* max-15
*/
$len = strlen($desired);
$left = $len - ($len - 10) % ($this->app->max_name_length - 15) - 5;
$key = substr($desired, 0, $left);
$rest = substr($desired, $left);
if (!isset($this->app->unique_hashes[$key])) {
$this->app->unique_hashes[$key] = '_'.dechex(crc32($key));
}
$desired = $this->app->unique_hashes[$key].'__'.$rest;
}
return $desired;
} | php | protected function _shorten($desired)
{
if (
isset($this->_appScopeTrait) &&
isset($this->app->max_name_length) &&
strlen($desired) > $this->app->max_name_length
) {
/*
* Basic rules: hash is 10 character long (8+2 for separator)
* We need at least 5 characters on the right side. Total must not exceed
* max_name_length. First chop will be max-10, then chop size will increase by
* max-15
*/
$len = strlen($desired);
$left = $len - ($len - 10) % ($this->app->max_name_length - 15) - 5;
$key = substr($desired, 0, $left);
$rest = substr($desired, $left);
if (!isset($this->app->unique_hashes[$key])) {
$this->app->unique_hashes[$key] = '_'.dechex(crc32($key));
}
$desired = $this->app->unique_hashes[$key].'__'.$rest;
}
return $desired;
} | [
"protected",
"function",
"_shorten",
"(",
"$",
"desired",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_appScopeTrait",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"app",
"->",
"max_name_length",
")",
"&&",
"strlen",
"(",
"$",
"desired",
")",... | Method used internally for shortening object names.
@param string $desired Desired name of new object.
@return string Shortened name of new object. | [
"Method",
"used",
"internally",
"for",
"shortening",
"object",
"names",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ContainerTrait.php#L192-L219 | train |
atk4/core | src/ContainerTrait.php | ContainerTrait.hasElement | public function hasElement($short_name)
{
return isset($this->elements[$short_name])
? $this->elements[$short_name]
: false;
} | php | public function hasElement($short_name)
{
return isset($this->elements[$short_name])
? $this->elements[$short_name]
: false;
} | [
"public",
"function",
"hasElement",
"(",
"$",
"short_name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"short_name",
"]",
")",
"?",
"$",
"this",
"->",
"elements",
"[",
"$",
"short_name",
"]",
":",
"false",
";",
"}"
] | Find child element. Use in condition.
@param string $short_name Short name of the child element
@return object|bool | [
"Find",
"child",
"element",
".",
"Use",
"in",
"condition",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ContainerTrait.php#L249-L254 | train |
atk4/core | src/ConfigTrait.php | ConfigTrait.getConfig | public function getConfig($path, $default_value = null)
{
$pos = &$this->_lookupConfigElement($path, false);
// path element don't exist - return default value
if ($pos === false) {
return $default_value;
}
return $pos;
} | php | public function getConfig($path, $default_value = null)
{
$pos = &$this->_lookupConfigElement($path, false);
// path element don't exist - return default value
if ($pos === false) {
return $default_value;
}
return $pos;
} | [
"public",
"function",
"getConfig",
"(",
"$",
"path",
",",
"$",
"default_value",
"=",
"null",
")",
"{",
"$",
"pos",
"=",
"&",
"$",
"this",
"->",
"_lookupConfigElement",
"(",
"$",
"path",
",",
"false",
")",
";",
"// path element don't exist - return default valu... | Get configuration element.
@param string $path Path to configuration element.
@param mixed $default_value Default value returned if element don't exist
@return mixed | [
"Get",
"configuration",
"element",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ConfigTrait.php#L126-L136 | train |
atk4/core | src/ConfigTrait.php | ConfigTrait.& | protected function &_lookupConfigElement($path, $create_elements = false)
{
$path = explode('/', $path);
$pos = &$this->config;
foreach ($path as $el) {
// create empty element if it doesn't exist
if (!array_key_exists($el, $pos) && $create_elements) {
$pos[$el] = [];
}
// if it still doesn't exist, then just return false (no error)
if (!array_key_exists($el, $pos) && !$create_elements) {
// trick to return false because we need reference here
$false = false;
return $false;
}
$pos = &$pos[$el];
}
return $pos;
} | php | protected function &_lookupConfigElement($path, $create_elements = false)
{
$path = explode('/', $path);
$pos = &$this->config;
foreach ($path as $el) {
// create empty element if it doesn't exist
if (!array_key_exists($el, $pos) && $create_elements) {
$pos[$el] = [];
}
// if it still doesn't exist, then just return false (no error)
if (!array_key_exists($el, $pos) && !$create_elements) {
// trick to return false because we need reference here
$false = false;
return $false;
}
$pos = &$pos[$el];
}
return $pos;
} | [
"protected",
"function",
"&",
"_lookupConfigElement",
"(",
"$",
"path",
",",
"$",
"create_elements",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"pos",
"=",
"&",
"$",
"this",
"->",
"config",
";",
... | Internal method to lookup config element by given path.
@param string $path Path to navigate to
@param bool $create_elements Should we create elements it they don't exist
@return &pos|false Pointer to element in $this->config or false is element don't exist and $create_elements===false
Returns false if element don't exist and $create_elements===false | [
"Internal",
"method",
"to",
"lookup",
"config",
"element",
"by",
"given",
"path",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ConfigTrait.php#L147-L168 | train |
atk4/core | src/TrackableTrait.php | TrackableTrait.destroy | public function destroy()
{
if (
isset($this->owner) &&
$this->owner->_containerTrait
) {
$this->owner->removeElement($this->short_name);
}
} | php | public function destroy()
{
if (
isset($this->owner) &&
$this->owner->_containerTrait
) {
$this->owner->removeElement($this->short_name);
}
} | [
"public",
"function",
"destroy",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"owner",
")",
"&&",
"$",
"this",
"->",
"owner",
"->",
"_containerTrait",
")",
"{",
"$",
"this",
"->",
"owner",
"->",
"removeElement",
"(",
"$",
"this",
"->",
... | Removes object from parent, so that PHP's Garbage Collector can
dispose of it. | [
"Removes",
"object",
"from",
"parent",
"so",
"that",
"PHP",
"s",
"Garbage",
"Collector",
"can",
"dispose",
"of",
"it",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/TrackableTrait.php#L50-L58 | train |
atk4/core | src/DebugTrait.php | DebugTrait.debug | public function debug($message = true, array $context = [])
{
// using this to switch on/off the debug for this object
if (is_bool($message)) {
$this->debug = $message;
return $this;
}
// if debug is enabled, then log it
if ($this->debug) {
if (!isset($this->app) || !isset($this->app->logger) || !$this->app->logger instanceof \Psr\Log\LoggerInterface) {
$message = '['.get_class($this).']: '.$message;
}
$this->log(LogLevel::DEBUG, $message, $context);
}
return $this;
} | php | public function debug($message = true, array $context = [])
{
// using this to switch on/off the debug for this object
if (is_bool($message)) {
$this->debug = $message;
return $this;
}
// if debug is enabled, then log it
if ($this->debug) {
if (!isset($this->app) || !isset($this->app->logger) || !$this->app->logger instanceof \Psr\Log\LoggerInterface) {
$message = '['.get_class($this).']: '.$message;
}
$this->log(LogLevel::DEBUG, $message, $context);
}
return $this;
} | [
"public",
"function",
"debug",
"(",
"$",
"message",
"=",
"true",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"// using this to switch on/off the debug for this object",
"if",
"(",
"is_bool",
"(",
"$",
"message",
")",
")",
"{",
"$",
"this",
"->",
... | Send some info to debug stream.
@param bool|string $message
@param array $context
@return $this | [
"Send",
"some",
"info",
"to",
"debug",
"stream",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DebugTrait.php#L42-L60 | train |
atk4/core | src/DebugTrait.php | DebugTrait.log | public function log($level, $message, array $context = [])
{
if (isset($this->app) && isset($this->app->logger) && $this->app->logger instanceof \Psr\Log\LoggerInterface) {
$this->app->logger->log($level, $message, $context);
} else {
$this->_echo_stderr("$message\n");
}
return $this;
} | php | public function log($level, $message, array $context = [])
{
if (isset($this->app) && isset($this->app->logger) && $this->app->logger instanceof \Psr\Log\LoggerInterface) {
$this->app->logger->log($level, $message, $context);
} else {
$this->_echo_stderr("$message\n");
}
return $this;
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"app",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"app",
"->",
"logger",
")... | Output log message.
@param string $level
@param string $message
@param array $context
@return $this | [
"Output",
"log",
"message",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DebugTrait.php#L71-L80 | train |
atk4/core | src/DebugTrait.php | DebugTrait.debugTraceChange | public function debugTraceChange($trace = 'default')
{
$bt = [];
foreach (debug_backtrace() as $line) {
if (isset($line['file'])) {
$bt[] = $line['file'].':'.$line['line'];
}
}
if (isset($this->_prev_bt[$trace]) && array_diff($this->_prev_bt[$trace], $bt)) {
$d1 = array_diff($this->_prev_bt[$trace], $bt);
$d2 = array_diff($bt, $this->_prev_bt[$trace]);
$this->log('debug', 'Call path for '.$trace.' has diverged (was '.implode(', ', $d1).', now '.implode(', ', $d2).")\n");
}
$this->_prev_bt[$trace] = $bt;
} | php | public function debugTraceChange($trace = 'default')
{
$bt = [];
foreach (debug_backtrace() as $line) {
if (isset($line['file'])) {
$bt[] = $line['file'].':'.$line['line'];
}
}
if (isset($this->_prev_bt[$trace]) && array_diff($this->_prev_bt[$trace], $bt)) {
$d1 = array_diff($this->_prev_bt[$trace], $bt);
$d2 = array_diff($bt, $this->_prev_bt[$trace]);
$this->log('debug', 'Call path for '.$trace.' has diverged (was '.implode(', ', $d1).', now '.implode(', ', $d2).")\n");
}
$this->_prev_bt[$trace] = $bt;
} | [
"public",
"function",
"debugTraceChange",
"(",
"$",
"trace",
"=",
"'default'",
")",
"{",
"$",
"bt",
"=",
"[",
"]",
";",
"foreach",
"(",
"debug_backtrace",
"(",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"line",
"[",
"'file'",
"... | Method designed to intercept one of the hardest-to-debug situations within Agile Toolkit.
Suppose you define a hook and the hook needs to be called only once, but somehow it is
being called multiple times. You want to know where and how those calls come through.
Place debugTraceChange inside your hook and give unique $trace identifier. If the method
is invoked through different call paths, this debug info will be logged.
Do not leave this method in production code !!!
@param string $trace | [
"Method",
"designed",
"to",
"intercept",
"one",
"of",
"the",
"hardest",
"-",
"to",
"-",
"debug",
"situations",
"within",
"Agile",
"Toolkit",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DebugTrait.php#L117-L134 | train |
atk4/core | src/DynamicMethodTrait.php | DynamicMethodTrait.tryCall | public function tryCall($method, $arguments)
{
if (isset($this->_hookTrait) && $ret = $this->hook('method-'.$method, $arguments)) {
return $ret;
}
if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) {
array_unshift($arguments, $this);
if ($ret = $this->app->hook('global-method-'.$method, $arguments)) {
return $ret;
}
}
} | php | public function tryCall($method, $arguments)
{
if (isset($this->_hookTrait) && $ret = $this->hook('method-'.$method, $arguments)) {
return $ret;
}
if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) {
array_unshift($arguments, $this);
if ($ret = $this->app->hook('global-method-'.$method, $arguments)) {
return $ret;
}
}
} | [
"public",
"function",
"tryCall",
"(",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_hookTrait",
")",
"&&",
"$",
"ret",
"=",
"$",
"this",
"->",
"hook",
"(",
"'method-'",
".",
"$",
"method",
",",
"$",
... | Tries to call dynamic method.
@param string $name Name of the method
@param array $arguments Array of arguments to pass to this method
@return mixed|null | [
"Tries",
"to",
"call",
"dynamic",
"method",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DynamicMethodTrait.php#L47-L59 | train |
atk4/core | src/DynamicMethodTrait.php | DynamicMethodTrait.hasGlobalMethod | public function hasGlobalMethod($name)
{
return
isset($this->_appScopeTrait) &&
isset($this->app->_hookTrait) &&
$this->app->hookHasCallbacks('global-method-'.$name);
} | php | public function hasGlobalMethod($name)
{
return
isset($this->_appScopeTrait) &&
isset($this->app->_hookTrait) &&
$this->app->hookHasCallbacks('global-method-'.$name);
} | [
"public",
"function",
"hasGlobalMethod",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_appScopeTrait",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"app",
"->",
"_hookTrait",
")",
"&&",
"$",
"this",
"->",
"app",
"->",
"hookHas... | Return true if such global method exists.
@param string $name Name of the method
@return bool | [
"Return",
"true",
"if",
"such",
"global",
"method",
"exists",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DynamicMethodTrait.php#L172-L178 | train |
atk4/core | src/DynamicMethodTrait.php | DynamicMethodTrait.removeGlobalMethod | public function removeGlobalMethod($name)
{
if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) {
$this->app->removeHook('global-method-'.$name);
}
return $this;
} | php | public function removeGlobalMethod($name)
{
if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) {
$this->app->removeHook('global-method-'.$name);
}
return $this;
} | [
"public",
"function",
"removeGlobalMethod",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_appScopeTrait",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"app",
"->",
"_hookTrait",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->"... | Remove dynamically registered global method.
@param string $name Name of the method
@return $this | [
"Remove",
"dynamically",
"registered",
"global",
"method",
"."
] | ec99f0d020056b1eef34796f72df553f12b143bf | https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DynamicMethodTrait.php#L187-L194 | train |
TheDMSGroup/mautic-health | Model/HealthModel.php | HealthModel.getCache | public function getCache()
{
if (!$this->cache) {
$this->cache = new CacheStorageHelper(
CacheStorageHelper::ADAPTOR_DATABASE,
'Health',
$this->em->getConnection()
);
}
return [
'delays' => $this->cache->get('delays'),
'lastCached' => $this->cache->get('lastCached'),
];
} | php | public function getCache()
{
if (!$this->cache) {
$this->cache = new CacheStorageHelper(
CacheStorageHelper::ADAPTOR_DATABASE,
'Health',
$this->em->getConnection()
);
}
return [
'delays' => $this->cache->get('delays'),
'lastCached' => $this->cache->get('lastCached'),
];
} | [
"public",
"function",
"getCache",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"new",
"CacheStorageHelper",
"(",
"CacheStorageHelper",
"::",
"ADAPTOR_DATABASE",
",",
"'Health'",
",",
"$",
"this",
"... | Get last delays from the cache. | [
"Get",
"last",
"delays",
"from",
"the",
"cache",
"."
] | a9be743542d4a889a6cd647b5442d976af8c540d | https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Model/HealthModel.php#L255-L269 | train |
TheDMSGroup/mautic-health | Model/HealthModel.php | HealthModel.setCache | public function setCache()
{
if (!$this->cache) {
$this->cache = new CacheStorageHelper(
CacheStorageHelper::ADAPTOR_DATABASE,
'Health',
$this->em->getConnection()
);
}
usort(
$this->delays,
function ($a, $b) {
return $b['avg_delay_s'] - $a['avg_delay_s'];
}
);
$this->cache->set('delays', $this->delays, null);
$this->cache->set('lastCached', time(), null);
$this->delays = [];
} | php | public function setCache()
{
if (!$this->cache) {
$this->cache = new CacheStorageHelper(
CacheStorageHelper::ADAPTOR_DATABASE,
'Health',
$this->em->getConnection()
);
}
usort(
$this->delays,
function ($a, $b) {
return $b['avg_delay_s'] - $a['avg_delay_s'];
}
);
$this->cache->set('delays', $this->delays, null);
$this->cache->set('lastCached', time(), null);
$this->delays = [];
} | [
"public",
"function",
"setCache",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"new",
"CacheStorageHelper",
"(",
"CacheStorageHelper",
"::",
"ADAPTOR_DATABASE",
",",
"'Health'",
",",
"$",
"this",
"... | Store current delays in the cache and purge. | [
"Store",
"current",
"delays",
"in",
"the",
"cache",
"and",
"purge",
"."
] | a9be743542d4a889a6cd647b5442d976af8c540d | https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Model/HealthModel.php#L274-L292 | train |
TheDMSGroup/mautic-health | Model/HealthModel.php | HealthModel.reportIncidents | public function reportIncidents(OutputInterface $output = null)
{
if (!$this->integration) {
return;
}
if ($this->incidents && !empty($this->settings['statuspage_component_id'])) {
$name = 'Processing Delays';
$body = [];
foreach ($this->incidents as $incident) {
if (!empty($incident['body'])) {
$body[] = $incident['body'];
}
}
$body = implode(' ', $body);
if ($output && $body) {
$output->writeln(
'<info>'.'Notifying Statuspage.io'.'</info>'
);
}
$this->integration->setComponentStatus('monitoring', 'degraded_performance', $name, $body);
} else {
$this->integration->setComponentStatus('resolved', 'operational', null, 'Application is healthy');
}
} | php | public function reportIncidents(OutputInterface $output = null)
{
if (!$this->integration) {
return;
}
if ($this->incidents && !empty($this->settings['statuspage_component_id'])) {
$name = 'Processing Delays';
$body = [];
foreach ($this->incidents as $incident) {
if (!empty($incident['body'])) {
$body[] = $incident['body'];
}
}
$body = implode(' ', $body);
if ($output && $body) {
$output->writeln(
'<info>'.'Notifying Statuspage.io'.'</info>'
);
}
$this->integration->setComponentStatus('monitoring', 'degraded_performance', $name, $body);
} else {
$this->integration->setComponentStatus('resolved', 'operational', null, 'Application is healthy');
}
} | [
"public",
"function",
"reportIncidents",
"(",
"OutputInterface",
"$",
"output",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"integration",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"incidents",
"&&",
"!",
"empty",
"(",
... | If Statuspage is enabled and configured, report incidents.
@param OutputInterface|null $output | [
"If",
"Statuspage",
"is",
"enabled",
"and",
"configured",
"report",
"incidents",
"."
] | a9be743542d4a889a6cd647b5442d976af8c540d | https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Model/HealthModel.php#L385-L408 | train |
TheDMSGroup/mautic-health | Integration/HealthIntegration.php | HealthIntegration.getComponents | private function getComponents()
{
$components = [];
if ($this->isConfigured()) {
$clientIdKey = $this->getClientIdKey();
$cacheKey = 'statuspageComponents'.$this->keys[$clientIdKey];
$cacheExpire = 10;
if (!$components = $this->cache->get($cacheKey, $cacheExpire)) {
$clientSKey = $this->getClientSecretKey();
$state = $this->getAuthLoginState();
$url = $this->getAuthenticationUrl()
.'pages/'.$this->keys[$clientIdKey].'/components.json'
.'?api_key='.$this->keys[$clientSKey]
.'&response_type=code'
.'&state='.$state;
$components = $this->makeRequest($url, ['ignore_event_dispatch' => true]);
if (is_array($components) && count($components)) {
$this->cache->set($cacheKey, $components, $cacheExpire);
}
}
}
return $components;
} | php | private function getComponents()
{
$components = [];
if ($this->isConfigured()) {
$clientIdKey = $this->getClientIdKey();
$cacheKey = 'statuspageComponents'.$this->keys[$clientIdKey];
$cacheExpire = 10;
if (!$components = $this->cache->get($cacheKey, $cacheExpire)) {
$clientSKey = $this->getClientSecretKey();
$state = $this->getAuthLoginState();
$url = $this->getAuthenticationUrl()
.'pages/'.$this->keys[$clientIdKey].'/components.json'
.'?api_key='.$this->keys[$clientSKey]
.'&response_type=code'
.'&state='.$state;
$components = $this->makeRequest($url, ['ignore_event_dispatch' => true]);
if (is_array($components) && count($components)) {
$this->cache->set($cacheKey, $components, $cacheExpire);
}
}
}
return $components;
} | [
"private",
"function",
"getComponents",
"(",
")",
"{",
"$",
"components",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isConfigured",
"(",
")",
")",
"{",
"$",
"clientIdKey",
"=",
"$",
"this",
"->",
"getClientIdKey",
"(",
")",
";",
"$",
"cacheKe... | Get the list of statuspage components to possibly update.
@return array | [
"Get",
"the",
"list",
"of",
"statuspage",
"components",
"to",
"possibly",
"update",
"."
] | a9be743542d4a889a6cd647b5442d976af8c540d | https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Integration/HealthIntegration.php#L111-L134 | train |
TheDMSGroup/mautic-health | Integration/HealthIntegration.php | HealthIntegration.getIncidents | private function getIncidents($componentId = null, $unresolvedOnly = true)
{
$incidents = [];
if ($this->isConfigured()) {
$clientIdKey = $this->getClientIdKey();
$cacheKey = 'statuspageIncidents'.$this->keys[$clientIdKey];
$cacheExpire = 10;
if (!$incidents = $this->cache->get($cacheKey, $cacheExpire)) {
$clientSKey = $this->getClientSecretKey();
$state = $this->getAuthLoginState();
$url = $this->getAuthenticationUrl();
if ($unresolvedOnly) {
$url .= 'pages/'.$this->keys[$clientIdKey].'/incidents/unresolved.json';
} else {
$url .= 'pages/'.$this->keys[$clientIdKey].'/incidents.json';
}
$url .= '?api_key='.$this->keys[$clientSKey]
.'&response_type=code'
.'&state='.$state;
$incidents = $this->makeRequest($url, ['ignore_event_dispatch' => true]);
if (is_array($incidents) && count($incidents)) {
$this->cache->set($cacheKey, $incidents, $cacheExpire);
}
}
}
// Narrow down to just the affected component if specified.
if ($incidents && $componentId) {
$affected = [];
foreach ($incidents as $incident) {
if (!empty($incident['incident_updates'])) {
foreach ($incident['incident_updates'] as $update) {
if (!empty($update['affected_components'])) {
foreach ($update['affected_components'] as $component) {
if (!empty($component['code']) && $component['code'] === $componentId) {
$affected[] = $incident;
continue;
}
}
}
}
}
}
$incidents = $affected;
}
return $incidents;
} | php | private function getIncidents($componentId = null, $unresolvedOnly = true)
{
$incidents = [];
if ($this->isConfigured()) {
$clientIdKey = $this->getClientIdKey();
$cacheKey = 'statuspageIncidents'.$this->keys[$clientIdKey];
$cacheExpire = 10;
if (!$incidents = $this->cache->get($cacheKey, $cacheExpire)) {
$clientSKey = $this->getClientSecretKey();
$state = $this->getAuthLoginState();
$url = $this->getAuthenticationUrl();
if ($unresolvedOnly) {
$url .= 'pages/'.$this->keys[$clientIdKey].'/incidents/unresolved.json';
} else {
$url .= 'pages/'.$this->keys[$clientIdKey].'/incidents.json';
}
$url .= '?api_key='.$this->keys[$clientSKey]
.'&response_type=code'
.'&state='.$state;
$incidents = $this->makeRequest($url, ['ignore_event_dispatch' => true]);
if (is_array($incidents) && count($incidents)) {
$this->cache->set($cacheKey, $incidents, $cacheExpire);
}
}
}
// Narrow down to just the affected component if specified.
if ($incidents && $componentId) {
$affected = [];
foreach ($incidents as $incident) {
if (!empty($incident['incident_updates'])) {
foreach ($incident['incident_updates'] as $update) {
if (!empty($update['affected_components'])) {
foreach ($update['affected_components'] as $component) {
if (!empty($component['code']) && $component['code'] === $componentId) {
$affected[] = $incident;
continue;
}
}
}
}
}
}
$incidents = $affected;
}
return $incidents;
} | [
"private",
"function",
"getIncidents",
"(",
"$",
"componentId",
"=",
"null",
",",
"$",
"unresolvedOnly",
"=",
"true",
")",
"{",
"$",
"incidents",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isConfigured",
"(",
")",
")",
"{",
"$",
"clientIdKey",
... | Get the list of statuspage active incidents.
@param null $componentId
@param bool $unresolvedOnly
@return array|bool|mixed|string | [
"Get",
"the",
"list",
"of",
"statuspage",
"active",
"incidents",
"."
] | a9be743542d4a889a6cd647b5442d976af8c540d | https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Integration/HealthIntegration.php#L152-L198 | train |
TheDMSGroup/mautic-health | Integration/HealthIntegration.php | HealthIntegration.updateIncident | private function updateIncident($incidentId, $incidentStatus = null, $name = null, $body = null, $componentIds = [])
{
$result = [];
if ($this->isConfigured()) {
$clientIdKey = $this->getClientIdKey();
$cacheKey = 'statuspageUpdateIncident'.$this->keys[$clientIdKey].implode('-', $componentIds);
$cacheExpire = 10;
if (!$result = $this->cache->get($cacheKey, $cacheExpire)) {
$clientSKey = $this->getClientSecretKey();
$state = $this->getAuthLoginState();
$url = $this->getAuthenticationUrl()
.'pages/'.$this->keys[$clientIdKey].'/incidents/'.$incidentId.'.json'
.'?api_key='.$this->keys[$clientSKey]
.'&response_type=code'
.'&state='.$state;
if ($body) {
$url .= '&incident[body]='.urlencode($body);
}
if ($incidentStatus) {
$url .= '&incident[status]='.urlencode($incidentStatus);
}
if ($name) {
$url .= '&incident[name]='.urlencode($name);
}
foreach ($componentIds as $componentId) {
$url .= '&incident[component_ids][]='.(int) $componentId;
}
$result = $this->makeRequest($url, ['ignore_event_dispatch' => true], 'PATCH');
if (is_array($result) && count($result)) {
$this->cache->set($cacheKey, $result, $cacheExpire);
}
}
}
return $result;
} | php | private function updateIncident($incidentId, $incidentStatus = null, $name = null, $body = null, $componentIds = [])
{
$result = [];
if ($this->isConfigured()) {
$clientIdKey = $this->getClientIdKey();
$cacheKey = 'statuspageUpdateIncident'.$this->keys[$clientIdKey].implode('-', $componentIds);
$cacheExpire = 10;
if (!$result = $this->cache->get($cacheKey, $cacheExpire)) {
$clientSKey = $this->getClientSecretKey();
$state = $this->getAuthLoginState();
$url = $this->getAuthenticationUrl()
.'pages/'.$this->keys[$clientIdKey].'/incidents/'.$incidentId.'.json'
.'?api_key='.$this->keys[$clientSKey]
.'&response_type=code'
.'&state='.$state;
if ($body) {
$url .= '&incident[body]='.urlencode($body);
}
if ($incidentStatus) {
$url .= '&incident[status]='.urlencode($incidentStatus);
}
if ($name) {
$url .= '&incident[name]='.urlencode($name);
}
foreach ($componentIds as $componentId) {
$url .= '&incident[component_ids][]='.(int) $componentId;
}
$result = $this->makeRequest($url, ['ignore_event_dispatch' => true], 'PATCH');
if (is_array($result) && count($result)) {
$this->cache->set($cacheKey, $result, $cacheExpire);
}
}
}
return $result;
} | [
"private",
"function",
"updateIncident",
"(",
"$",
"incidentId",
",",
"$",
"incidentStatus",
"=",
"null",
",",
"$",
"name",
"=",
"null",
",",
"$",
"body",
"=",
"null",
",",
"$",
"componentIds",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"[",
"]",
... | Update an active statuspage incident.
@param $incidentId
@param null $incidentStatus The status, one of investigating|identified|monitoring|resolved
@param null $name The name of the incident
@param null $body The body of the new incident update that will be created
@param array $componentIds List of components affected by the incident
@return array|mixed|string | [
"Update",
"an",
"active",
"statuspage",
"incident",
"."
] | a9be743542d4a889a6cd647b5442d976af8c540d | https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Integration/HealthIntegration.php#L211-L246 | train |
contentful/contentful-core.php | src/File/ImageOptions.php | ImageOptions.setWidth | public function setWidth(int $width = \null)
{
if (\null !== $width && $width < 0) {
throw new \InvalidArgumentException('Width must not be negative.');
}
$this->width = $width;
return $this;
} | php | public function setWidth(int $width = \null)
{
if (\null !== $width && $width < 0) {
throw new \InvalidArgumentException('Width must not be negative.');
}
$this->width = $width;
return $this;
} | [
"public",
"function",
"setWidth",
"(",
"int",
"$",
"width",
"=",
"\\",
"null",
")",
"{",
"if",
"(",
"\\",
"null",
"!==",
"$",
"width",
"&&",
"$",
"width",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Width must not be nega... | Set the width of the image.
The image will by default not be stretched, skewed or enlarged.
Instead it will be fit into the bounding box given by the width
and height parameters.
Can be set to null to not set a width.
@param int|null $width the width in pixel
@throws \InvalidArgumentException If $width is negative
@return $this | [
"Set",
"the",
"width",
"of",
"the",
"image",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L129-L138 | train |
contentful/contentful-core.php | src/File/ImageOptions.php | ImageOptions.setHeight | public function setHeight(int $height = \null)
{
if (\null !== $height && $height < 0) {
throw new \InvalidArgumentException('Height must not be negative.');
}
$this->height = $height;
return $this;
} | php | public function setHeight(int $height = \null)
{
if (\null !== $height && $height < 0) {
throw new \InvalidArgumentException('Height must not be negative.');
}
$this->height = $height;
return $this;
} | [
"public",
"function",
"setHeight",
"(",
"int",
"$",
"height",
"=",
"\\",
"null",
")",
"{",
"if",
"(",
"\\",
"null",
"!==",
"$",
"height",
"&&",
"$",
"height",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Height must not be... | Set the height of the image.
The image will by default not be stretched, skewed or enlarged.
Instead it will be fit into the bounding box given by the width
and height parameters.
Can be set to null to not set a height.
@param int|null $height the height in pixel
@throws \InvalidArgumentException If $height is negative
@return $this | [
"Set",
"the",
"height",
"of",
"the",
"image",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L155-L164 | train |
contentful/contentful-core.php | src/File/ImageOptions.php | ImageOptions.setFormat | public function setFormat(string $format = \null)
{
$validValues = ['png', 'jpg', 'webp'];
if (\null !== $format && !\in_array($format, $validValues, \true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown format "%s" given. Expected "%s" or null.',
$format,
\implode(', ', $validValues)
));
}
$this->format = $format;
return $this;
} | php | public function setFormat(string $format = \null)
{
$validValues = ['png', 'jpg', 'webp'];
if (\null !== $format && !\in_array($format, $validValues, \true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown format "%s" given. Expected "%s" or null.',
$format,
\implode(', ', $validValues)
));
}
$this->format = $format;
return $this;
} | [
"public",
"function",
"setFormat",
"(",
"string",
"$",
"format",
"=",
"\\",
"null",
")",
"{",
"$",
"validValues",
"=",
"[",
"'png'",
",",
"'jpg'",
",",
"'webp'",
"]",
";",
"if",
"(",
"\\",
"null",
"!==",
"$",
"format",
"&&",
"!",
"\\",
"in_array",
... | Set the format of the image. Valid values are "png" and "jpg".
Can be set to null to not enforce a format.
@param string|null $format
@throws \InvalidArgumentException If $format is not a valid value
@return $this | [
"Set",
"the",
"format",
"of",
"the",
"image",
".",
"Valid",
"values",
"are",
"png",
"and",
"jpg",
".",
"Can",
"be",
"set",
"to",
"null",
"to",
"not",
"enforce",
"a",
"format",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L176-L191 | train |
contentful/contentful-core.php | src/File/ImageOptions.php | ImageOptions.setQuality | public function setQuality(int $quality = \null)
{
if (\null !== $quality && ($quality < 1 || $quality > 100)) {
throw new \InvalidArgumentException(\sprintf(
'Quality must be between 1 and 100, "%d" given.',
$quality
));
}
$this->quality = $quality;
return $this;
} | php | public function setQuality(int $quality = \null)
{
if (\null !== $quality && ($quality < 1 || $quality > 100)) {
throw new \InvalidArgumentException(\sprintf(
'Quality must be between 1 and 100, "%d" given.',
$quality
));
}
$this->quality = $quality;
return $this;
} | [
"public",
"function",
"setQuality",
"(",
"int",
"$",
"quality",
"=",
"\\",
"null",
")",
"{",
"if",
"(",
"\\",
"null",
"!==",
"$",
"quality",
"&&",
"(",
"$",
"quality",
"<",
"1",
"||",
"$",
"quality",
">",
"100",
")",
")",
"{",
"throw",
"new",
"\\... | Quality of the JPEG encoded image.
The image format will be forced to JPEG.
@param int|null $quality if an int, between 1 and 100
@throws \InvalidArgumentException If $quality is out of range
@return $this | [
"Quality",
"of",
"the",
"JPEG",
"encoded",
"image",
".",
"The",
"image",
"format",
"will",
"be",
"forced",
"to",
"JPEG",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L203-L215 | train |
contentful/contentful-core.php | src/File/ImageOptions.php | ImageOptions.setResizeFit | public function setResizeFit(string $resizeFit = \null)
{
$validValues = ['pad', 'crop', 'fill', 'thumb', 'scale'];
if (\null !== $resizeFit && !\in_array($resizeFit, $validValues, \true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown resize fit "%s" given. Expected "%s" or null.',
$resizeFit,
\implode(', ', $validValues)
));
}
$this->resizeFit = $resizeFit;
return $this;
} | php | public function setResizeFit(string $resizeFit = \null)
{
$validValues = ['pad', 'crop', 'fill', 'thumb', 'scale'];
if (\null !== $resizeFit && !\in_array($resizeFit, $validValues, \true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown resize fit "%s" given. Expected "%s" or null.',
$resizeFit,
\implode(', ', $validValues)
));
}
$this->resizeFit = $resizeFit;
return $this;
} | [
"public",
"function",
"setResizeFit",
"(",
"string",
"$",
"resizeFit",
"=",
"\\",
"null",
")",
"{",
"$",
"validValues",
"=",
"[",
"'pad'",
",",
"'crop'",
",",
"'fill'",
",",
"'thumb'",
",",
"'scale'",
"]",
";",
"if",
"(",
"\\",
"null",
"!==",
"$",
"r... | Change the behavior when resizing the image.
By default, images are resized to fit inside the bounding box
set trough setWidth and setHeight while retaining their aspect ratio.
Possible values are:
- null for the default value
- 'pad' Same as the default, but add padding so that the generated image has exactly the given dimensions.
- 'crop' Crop a part of the original image.
- 'fill' Fill the given dimensions by cropping the image.
- 'thumb' Create a thumbnail of detected faces from image, used with 'setFocus'.
- 'scale' Scale the image regardless of the original aspect ratio.
@param string|null $resizeFit
@throws \InvalidArgumentException For unknown values of $resizeBehavior
@return $this | [
"Change",
"the",
"behavior",
"when",
"resizing",
"the",
"image",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L267-L282 | train |
contentful/contentful-core.php | src/File/ImageOptions.php | ImageOptions.setResizeFocus | public function setResizeFocus(string $resizeFocus = \null)
{
$validValues = [
'face',
'faces',
'top',
'bottom',
'right',
'left',
'top_right',
'top_left',
'bottom_right',
'bottom_left',
];
if (\null !== $resizeFocus && !\in_array($resizeFocus, $validValues, \true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown resize focus "%s" given. Expected "%s" or null.',
$resizeFocus,
\implode(', ', $validValues)
));
}
$this->resizeFocus = $resizeFocus;
return $this;
} | php | public function setResizeFocus(string $resizeFocus = \null)
{
$validValues = [
'face',
'faces',
'top',
'bottom',
'right',
'left',
'top_right',
'top_left',
'bottom_right',
'bottom_left',
];
if (\null !== $resizeFocus && !\in_array($resizeFocus, $validValues, \true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown resize focus "%s" given. Expected "%s" or null.',
$resizeFocus,
\implode(', ', $validValues)
));
}
$this->resizeFocus = $resizeFocus;
return $this;
} | [
"public",
"function",
"setResizeFocus",
"(",
"string",
"$",
"resizeFocus",
"=",
"\\",
"null",
")",
"{",
"$",
"validValues",
"=",
"[",
"'face'",
",",
"'faces'",
",",
"'top'",
",",
"'bottom'",
",",
"'right'",
",",
"'left'",
",",
"'top_right'",
",",
"'top_lef... | Set the focus area when the resize fit is set to 'thumb'.
Possible values are:
- 'top', 'right', 'left', 'bottom'
- A combination like 'bottom_right'
- 'face' or 'faces' to focus the resizing via face detection
@param string|null $resizeFocus
@throws \InvalidArgumentException For unknown values of $resizeFocus
@return $this | [
"Set",
"the",
"focus",
"area",
"when",
"the",
"resize",
"fit",
"is",
"set",
"to",
"thumb",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L298-L324 | train |
silverstripe/silverstripe-reports | code/ReportAdmin.php | ReportAdmin.Reports | public function Reports()
{
$output = new ArrayList();
/** @var Report $report */
foreach (Report::get_reports() as $report) {
if ($report->canView()) {
$output->push($report);
}
}
return $output;
} | php | public function Reports()
{
$output = new ArrayList();
/** @var Report $report */
foreach (Report::get_reports() as $report) {
if ($report->canView()) {
$output->push($report);
}
}
return $output;
} | [
"public",
"function",
"Reports",
"(",
")",
"{",
"$",
"output",
"=",
"new",
"ArrayList",
"(",
")",
";",
"/** @var Report $report */",
"foreach",
"(",
"Report",
"::",
"get_reports",
"(",
")",
"as",
"$",
"report",
")",
"{",
"if",
"(",
"$",
"report",
"->",
... | Return a SS_List of SS_Report subclasses
that are available for use.
@return SS_List | [
"Return",
"a",
"SS_List",
"of",
"SS_Report",
"subclasses",
"that",
"are",
"available",
"for",
"use",
"."
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/ReportAdmin.php#L105-L115 | train |
silverstripe/silverstripe-reports | code/ReportAdmin.php | ReportAdmin.Breadcrumbs | public function Breadcrumbs($unlinked = false)
{
$items = parent::Breadcrumbs($unlinked);
// The root element should explicitly point to the root node.
// Uses session state for current record otherwise.
$items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link();
if ($report = $this->reportObject) {
$breadcrumbs = $report->getBreadcrumbs();
if (!empty($breadcrumbs)) {
foreach ($breadcrumbs as $crumb) {
$items->push($crumb);
}
}
//build breadcrumb trail to the current report
$items->push(new ArrayData(array(
'Title' => $report->title(),
'Link' => Controller::join_links(
$this->Link(),
'?' . http_build_query(array('q' => $this->request->requestVar('q')))
)
)));
}
return $items;
} | php | public function Breadcrumbs($unlinked = false)
{
$items = parent::Breadcrumbs($unlinked);
// The root element should explicitly point to the root node.
// Uses session state for current record otherwise.
$items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link();
if ($report = $this->reportObject) {
$breadcrumbs = $report->getBreadcrumbs();
if (!empty($breadcrumbs)) {
foreach ($breadcrumbs as $crumb) {
$items->push($crumb);
}
}
//build breadcrumb trail to the current report
$items->push(new ArrayData(array(
'Title' => $report->title(),
'Link' => Controller::join_links(
$this->Link(),
'?' . http_build_query(array('q' => $this->request->requestVar('q')))
)
)));
}
return $items;
} | [
"public",
"function",
"Breadcrumbs",
"(",
"$",
"unlinked",
"=",
"false",
")",
"{",
"$",
"items",
"=",
"parent",
"::",
"Breadcrumbs",
"(",
"$",
"unlinked",
")",
";",
"// The root element should explicitly point to the root node.",
"// Uses session state for current record ... | Returns the Breadcrumbs for the ReportAdmin
@param bool $unlinked
@return ArrayList | [
"Returns",
"the",
"Breadcrumbs",
"for",
"the",
"ReportAdmin"
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/ReportAdmin.php#L167-L194 | train |
silverstripe/silverstripe-reports | code/ReportAdmin.php | ReportAdmin.Link | public function Link($action = null)
{
if ($this->reportObject) {
return $this->reportObject->getLink($action);
}
// Basic link to this cms section
return parent::Link($action);
} | php | public function Link($action = null)
{
if ($this->reportObject) {
return $this->reportObject->getLink($action);
}
// Basic link to this cms section
return parent::Link($action);
} | [
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reportObject",
")",
"{",
"return",
"$",
"this",
"->",
"reportObject",
"->",
"getLink",
"(",
"$",
"action",
")",
";",
"}",
"// Basic link to this cms s... | Returns the link to the report admin section, or the specific report that is currently displayed
@param string $action
@return string | [
"Returns",
"the",
"link",
"to",
"the",
"report",
"admin",
"section",
"or",
"the",
"specific",
"report",
"that",
"is",
"currently",
"displayed"
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/ReportAdmin.php#L202-L210 | train |
contentful/contentful-core.php | src/Api/UserAgentGenerator.php | UserAgentGenerator.getUserAgent | public function getUserAgent(): string
{
if (null === $this->cachedUserAgent) {
$this->cachedUserAgent = $this->generate();
}
return $this->cachedUserAgent;
} | php | public function getUserAgent(): string
{
if (null === $this->cachedUserAgent) {
$this->cachedUserAgent = $this->generate();
}
return $this->cachedUserAgent;
} | [
"public",
"function",
"getUserAgent",
"(",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cachedUserAgent",
")",
"{",
"$",
"this",
"->",
"cachedUserAgent",
"=",
"$",
"this",
"->",
"generate",
"(",
")",
";",
"}",
"return",
"$",
... | Returns the value of the User-Agent header for any requests made to Contentful.
@return string | [
"Returns",
"the",
"value",
"of",
"the",
"User",
"-",
"Agent",
"header",
"for",
"any",
"requests",
"made",
"to",
"Contentful",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/UserAgentGenerator.php#L128-L135 | train |
contentful/contentful-core.php | src/Api/BaseQuery.php | BaseQuery.getQueryData | public function getQueryData(): array
{
return \array_merge($this->whereConditions, [
'limit' => $this->limit,
'skip' => $this->skip,
'content_type' => $this->contentType,
'mimetype_group' => $this->mimeTypeGroup,
'order' => $this->orderConditions ? \implode(',', $this->orderConditions) : null,
'select' => $this->select,
'links_to_entry' => $this->linksToEntry,
'links_to_asset' => $this->linksToAsset,
]);
} | php | public function getQueryData(): array
{
return \array_merge($this->whereConditions, [
'limit' => $this->limit,
'skip' => $this->skip,
'content_type' => $this->contentType,
'mimetype_group' => $this->mimeTypeGroup,
'order' => $this->orderConditions ? \implode(',', $this->orderConditions) : null,
'select' => $this->select,
'links_to_entry' => $this->linksToEntry,
'links_to_asset' => $this->linksToAsset,
]);
} | [
"public",
"function",
"getQueryData",
"(",
")",
":",
"array",
"{",
"return",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"whereConditions",
",",
"[",
"'limit'",
"=>",
"$",
"this",
"->",
"limit",
",",
"'skip'",
"=>",
"$",
"this",
"->",
"skip",
",",
"'c... | Returns the parameters to execute this query.
@return array | [
"Returns",
"the",
"parameters",
"to",
"execute",
"this",
"query",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L132-L144 | train |
contentful/contentful-core.php | src/Api/BaseQuery.php | BaseQuery.setSkip | public function setSkip(int $skip = null)
{
if (null !== $skip && $skip < 0) {
throw new \RangeException(\sprintf(
'Skip value must be 0 or bigger, "%d" given.',
$skip
));
}
$this->skip = $skip;
return $this;
} | php | public function setSkip(int $skip = null)
{
if (null !== $skip && $skip < 0) {
throw new \RangeException(\sprintf(
'Skip value must be 0 or bigger, "%d" given.',
$skip
));
}
$this->skip = $skip;
return $this;
} | [
"public",
"function",
"setSkip",
"(",
"int",
"$",
"skip",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"skip",
"&&",
"$",
"skip",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"RangeException",
"(",
"\\",
"sprintf",
"(",
"'Skip value must be 0 or ... | Sets the index of the first result to retrieve. To reset set to NULL.
@param int|null $skip The index of the first result that will be retrieved. Must be >= 0.
@throws \RangeException If $skip is not within the specified range
@return $this | [
"Sets",
"the",
"index",
"of",
"the",
"first",
"result",
"to",
"retrieve",
".",
"To",
"reset",
"set",
"to",
"NULL",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L165-L177 | train |
contentful/contentful-core.php | src/Api/BaseQuery.php | BaseQuery.setLimit | public function setLimit(int $limit = null)
{
if (null !== $limit && ($limit < 1 || $limit > 1000)) {
throw new \RangeException(\sprintf(
'Limit value must be between 0 and 1000, "%d" given.',
$limit
));
}
$this->limit = $limit;
return $this;
} | php | public function setLimit(int $limit = null)
{
if (null !== $limit && ($limit < 1 || $limit > 1000)) {
throw new \RangeException(\sprintf(
'Limit value must be between 0 and 1000, "%d" given.',
$limit
));
}
$this->limit = $limit;
return $this;
} | [
"public",
"function",
"setLimit",
"(",
"int",
"$",
"limit",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"limit",
"&&",
"(",
"$",
"limit",
"<",
"1",
"||",
"$",
"limit",
">",
"1000",
")",
")",
"{",
"throw",
"new",
"\\",
"RangeException",
... | Set the maximum number of results to retrieve. To reset set to NULL;.
@param int|null $limit The maximum number of results to retrieve, must be between 1 and 1000 or null
@throws \RangeException If $maxArguments is not withing the specified range
@return $this | [
"Set",
"the",
"maximum",
"number",
"of",
"results",
"to",
"retrieve",
".",
"To",
"reset",
"set",
"to",
"NULL",
";",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L188-L200 | train |
contentful/contentful-core.php | src/Api/BaseQuery.php | BaseQuery.orderBy | public function orderBy(string $field, bool $reverse = false)
{
if ($reverse) {
$field = '-'.$field;
}
$this->orderConditions[] = $field;
return $this;
} | php | public function orderBy(string $field, bool $reverse = false)
{
if ($reverse) {
$field = '-'.$field;
}
$this->orderConditions[] = $field;
return $this;
} | [
"public",
"function",
"orderBy",
"(",
"string",
"$",
"field",
",",
"bool",
"$",
"reverse",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reverse",
")",
"{",
"$",
"field",
"=",
"'-'",
".",
"$",
"field",
";",
"}",
"$",
"this",
"->",
"orderConditions",
"["... | Set the order of the items retrieved by this query.
Note that when ordering Entries by fields you must set the content_type URI query parameter to the ID of
the Content Type you want to filter by. Can be called multiple times to order by multiple values.
@param string $field
@param bool $reverse
@return $this | [
"Set",
"the",
"order",
"of",
"the",
"items",
"retrieved",
"by",
"this",
"query",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L213-L222 | train |
contentful/contentful-core.php | src/Api/BaseQuery.php | BaseQuery.where | public function where(string $field, $value)
{
$matches = [];
// We check whether there is a specific operator in the field name,
// and if so we validate it against a whitelist
if (\preg_match('/(.+)\[([a-zA-Z]+)\]/', $field, $matches)) {
$operator = \mb_strtolower($matches[2]);
if (!\in_array($operator, self::$validOperators, true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown operator "%s" given. Expected "%s" or no operator.',
$operator,
\implode(', ', self::$validOperators)
));
}
}
if ($value instanceof \DateTimeInterface) {
$value = $value->format(self::DATE_FORMAT);
}
if ($value instanceof Location) {
$value = $value->queryStringFormatted();
}
if (\is_array($value)) {
$value = \implode(',', $value);
}
$this->whereConditions[$field] = $value;
return $this;
} | php | public function where(string $field, $value)
{
$matches = [];
// We check whether there is a specific operator in the field name,
// and if so we validate it against a whitelist
if (\preg_match('/(.+)\[([a-zA-Z]+)\]/', $field, $matches)) {
$operator = \mb_strtolower($matches[2]);
if (!\in_array($operator, self::$validOperators, true)) {
throw new \InvalidArgumentException(\sprintf(
'Unknown operator "%s" given. Expected "%s" or no operator.',
$operator,
\implode(', ', self::$validOperators)
));
}
}
if ($value instanceof \DateTimeInterface) {
$value = $value->format(self::DATE_FORMAT);
}
if ($value instanceof Location) {
$value = $value->queryStringFormatted();
}
if (\is_array($value)) {
$value = \implode(',', $value);
}
$this->whereConditions[$field] = $value;
return $this;
} | [
"public",
"function",
"where",
"(",
"string",
"$",
"field",
",",
"$",
"value",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"// We check whether there is a specific operator in the field name,",
"// and if so we validate it against a whitelist",
"if",
"(",
"\\",
"preg_... | Add a filter condition to this query.
@param string $field
@param string|array|\DateTimeInterface|Location $value
@throws \InvalidArgumentException If $operator is not one of the valid values
@return $this | [
"Add",
"a",
"filter",
"condition",
"to",
"this",
"query",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L272-L302 | train |
contentful/contentful-core.php | src/Api/BaseQuery.php | BaseQuery.select | public function select(array $select)
{
$select = \array_filter($select, function (string $value): bool {
return 0 !== \mb_strpos($value, 'sys');
});
$select[] = 'sys';
$this->select = \implode(',', $select);
return $this;
} | php | public function select(array $select)
{
$select = \array_filter($select, function (string $value): bool {
return 0 !== \mb_strpos($value, 'sys');
});
$select[] = 'sys';
$this->select = \implode(',', $select);
return $this;
} | [
"public",
"function",
"select",
"(",
"array",
"$",
"select",
")",
"{",
"$",
"select",
"=",
"\\",
"array_filter",
"(",
"$",
"select",
",",
"function",
"(",
"string",
"$",
"value",
")",
":",
"bool",
"{",
"return",
"0",
"!==",
"\\",
"mb_strpos",
"(",
"$... | The select operator allows you to choose what to return from an entity.
You provide one or multiple JSON paths and the API will return the properties at those paths.
To only request the metadata simply query for 'sys'.
@param string[] $select
@return $this | [
"The",
"select",
"operator",
"allows",
"you",
"to",
"choose",
"what",
"to",
"return",
"from",
"an",
"entity",
".",
"You",
"provide",
"one",
"or",
"multiple",
"JSON",
"paths",
"and",
"the",
"API",
"will",
"return",
"the",
"properties",
"at",
"those",
"paths... | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L314-L324 | train |
contentful/contentful-core.php | src/ResourceBuilder/BaseResourceBuilder.php | BaseResourceBuilder.getMapper | public function getMapper($fqcn)
{
if (!isset($this->mappers[$fqcn])) {
$this->mappers[$fqcn] = $this->createMapper($fqcn);
}
return $this->mappers[$fqcn];
} | php | public function getMapper($fqcn)
{
if (!isset($this->mappers[$fqcn])) {
$this->mappers[$fqcn] = $this->createMapper($fqcn);
}
return $this->mappers[$fqcn];
} | [
"public",
"function",
"getMapper",
"(",
"$",
"fqcn",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mappers",
"[",
"$",
"fqcn",
"]",
")",
")",
"{",
"$",
"this",
"->",
"mappers",
"[",
"$",
"fqcn",
"]",
"=",
"$",
"this",
"->",
"creat... | Returns the mapper object appropriate for the given data.
@param string $fqcn
@throws \RuntimeException
@return MapperInterface | [
"Returns",
"the",
"mapper",
"object",
"appropriate",
"for",
"the",
"given",
"data",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/ResourceBuilder/BaseResourceBuilder.php#L74-L81 | train |
contentful/contentful-core.php | src/ResourceBuilder/BaseResourceBuilder.php | BaseResourceBuilder.determineMapperFqcn | private function determineMapperFqcn(array $data)
{
$type = $this->getSystemType($data);
$fqcn = $this->mapperNamespace.'\\'.$type;
if (isset($this->dataMapperMatchers[$type])) {
$matchedFqcn = $this->dataMapperMatchers[$type]($data);
if (!$matchedFqcn) {
return $fqcn;
}
if (!\class_exists($matchedFqcn, \true)) {
throw new \RuntimeException(\sprintf(
'Mapper class "%s" does not exist.',
$matchedFqcn
));
}
return $matchedFqcn;
}
return $fqcn;
} | php | private function determineMapperFqcn(array $data)
{
$type = $this->getSystemType($data);
$fqcn = $this->mapperNamespace.'\\'.$type;
if (isset($this->dataMapperMatchers[$type])) {
$matchedFqcn = $this->dataMapperMatchers[$type]($data);
if (!$matchedFqcn) {
return $fqcn;
}
if (!\class_exists($matchedFqcn, \true)) {
throw new \RuntimeException(\sprintf(
'Mapper class "%s" does not exist.',
$matchedFqcn
));
}
return $matchedFqcn;
}
return $fqcn;
} | [
"private",
"function",
"determineMapperFqcn",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getSystemType",
"(",
"$",
"data",
")",
";",
"$",
"fqcn",
"=",
"$",
"this",
"->",
"mapperNamespace",
".",
"'\\\\'",
".",
"$",
"type"... | Determines the fully-qualified class name of the mapper object
that will handle the mapping process.
This function will use user-defined data matchers, if available.
If the user-defined matcher does not return anything,
we default to the base mapper, so the user doesn't have
to manually return the default value.
@param array $data The raw API data
@return string The mapper's fully-qualified class name | [
"Determines",
"the",
"fully",
"-",
"qualified",
"class",
"name",
"of",
"the",
"mapper",
"object",
"that",
"will",
"handle",
"the",
"mapping",
"process",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/ResourceBuilder/BaseResourceBuilder.php#L97-L120 | train |
contentful/contentful-core.php | src/Api/Message.php | Message.createFromString | public static function createFromString(string $json): self
{
$data = guzzle_json_decode($json, true);
if (
!isset($data['api']) ||
!isset($data['request']) ||
!isset($data['response']) ||
!isset($data['duration']) ||
!isset($data['exception'])
) {
throw new \InvalidArgumentException(
'String passed to Message::createFromString() is valid JSON but does not contain required fields.'
);
}
return new self(
$data['api'],
$data['duration'],
guzzle_parse_request($data['request']),
$data['response'] ? guzzle_parse_response($data['response']) : null,
$data['exception'] ? \unserialize($data['exception']) : null
);
} | php | public static function createFromString(string $json): self
{
$data = guzzle_json_decode($json, true);
if (
!isset($data['api']) ||
!isset($data['request']) ||
!isset($data['response']) ||
!isset($data['duration']) ||
!isset($data['exception'])
) {
throw new \InvalidArgumentException(
'String passed to Message::createFromString() is valid JSON but does not contain required fields.'
);
}
return new self(
$data['api'],
$data['duration'],
guzzle_parse_request($data['request']),
$data['response'] ? guzzle_parse_response($data['response']) : null,
$data['exception'] ? \unserialize($data['exception']) : null
);
} | [
"public",
"static",
"function",
"createFromString",
"(",
"string",
"$",
"json",
")",
":",
"self",
"{",
"$",
"data",
"=",
"guzzle_json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'api'",
"]",
")",... | Creates a new instance of the class from a JSON string.
@param string $json
@return self | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"class",
"from",
"a",
"JSON",
"string",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Message.php#L93-L116 | train |
contentful/contentful-core.php | src/Api/DateTimeImmutable.php | DateTimeImmutable.formatForJson | public function formatForJson(): string
{
$date = $this->setTimezone(new \DateTimeZone('Etc/UTC'));
$result = $date->format('Y-m-d\TH:i:s');
$milliseconds = \floor($date->format('u') / 1000);
if ($milliseconds > 0) {
$result .= '.'.\str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT);
}
return $result.'Z';
} | php | public function formatForJson(): string
{
$date = $this->setTimezone(new \DateTimeZone('Etc/UTC'));
$result = $date->format('Y-m-d\TH:i:s');
$milliseconds = \floor($date->format('u') / 1000);
if ($milliseconds > 0) {
$result .= '.'.\str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT);
}
return $result.'Z';
} | [
"public",
"function",
"formatForJson",
"(",
")",
":",
"string",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'Etc/UTC'",
")",
")",
";",
"$",
"result",
"=",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d\\T... | Formats the string for an easier interoperability with Contentful.
@return string | [
"Formats",
"the",
"string",
"for",
"an",
"easier",
"interoperability",
"with",
"Contentful",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/DateTimeImmutable.php#L26-L37 | train |
silverstripe/silverstripe-reports | code/Report.php | Report.records | public function records($params)
{
if ($this->hasMethod('sourceRecords')) {
return $this->sourceRecords($params, null, null);
} else {
$query = $this->sourceQuery($params);
$results = ArrayList::create();
foreach ($query->execute() as $data) {
$class = $this->dataClass();
$result = Injector::inst()->create($class, $data);
$results->push($result);
}
return $results;
}
} | php | public function records($params)
{
if ($this->hasMethod('sourceRecords')) {
return $this->sourceRecords($params, null, null);
} else {
$query = $this->sourceQuery($params);
$results = ArrayList::create();
foreach ($query->execute() as $data) {
$class = $this->dataClass();
$result = Injector::inst()->create($class, $data);
$results->push($result);
}
return $results;
}
} | [
"public",
"function",
"records",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMethod",
"(",
"'sourceRecords'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sourceRecords",
"(",
"$",
"params",
",",
"null",
",",
"null",
")",
";",
"}"... | Return a SS_List records for this report.
@param array $params
@return SS_List | [
"Return",
"a",
"SS_List",
"records",
"for",
"this",
"report",
"."
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L163-L177 | train |
silverstripe/silverstripe-reports | code/Report.php | Report.getCount | public function getCount($params = array())
{
$sourceRecords = $this->sourceRecords($params, null, null);
if (!$sourceRecords instanceof SS_List) {
user_error(static::class . "::sourceRecords does not return an SS_List", E_USER_NOTICE);
return "-1";
}
return $sourceRecords->count();
} | php | public function getCount($params = array())
{
$sourceRecords = $this->sourceRecords($params, null, null);
if (!$sourceRecords instanceof SS_List) {
user_error(static::class . "::sourceRecords does not return an SS_List", E_USER_NOTICE);
return "-1";
}
return $sourceRecords->count();
} | [
"public",
"function",
"getCount",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"sourceRecords",
"=",
"$",
"this",
"->",
"sourceRecords",
"(",
"$",
"params",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"!",
"$",
"sourceRecords",
"inst... | counts the number of objects returned
@param array $params - any parameters for the sourceRecords
@return int | [
"counts",
"the",
"number",
"of",
"objects",
"returned"
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L219-L227 | train |
silverstripe/silverstripe-reports | code/Report.php | Report.get_reports | public static function get_reports()
{
$reports = ClassInfo::subclassesFor(get_called_class());
$reportsArray = [];
if ($reports && count($reports) > 0) {
$excludedReports = static::get_excluded_reports();
// Collect reports into array with an attribute for 'sort'
foreach ($reports as $report) {
// Don't use the Report superclass, or any excluded report classes
if (in_array($report, $excludedReports)) {
continue;
}
$reflectionClass = new ReflectionClass($report);
// Don't use abstract classes
if ($reflectionClass->isAbstract()) {
continue;
}
/** @var Report $reportObj */
$reportObj = $report::create();
if ($reportObj->hasMethod('sort')) {
// Use the sort method to specify the sort field
$reportObj->sort = $reportObj->sort();
}
$reportsArray[$report] = $reportObj;
}
}
uasort($reportsArray, function ($a, $b) {
if ($a->sort == $b->sort) {
return 0;
} else {
return ($a->sort < $b->sort) ? -1 : 1;
}
});
return $reportsArray;
} | php | public static function get_reports()
{
$reports = ClassInfo::subclassesFor(get_called_class());
$reportsArray = [];
if ($reports && count($reports) > 0) {
$excludedReports = static::get_excluded_reports();
// Collect reports into array with an attribute for 'sort'
foreach ($reports as $report) {
// Don't use the Report superclass, or any excluded report classes
if (in_array($report, $excludedReports)) {
continue;
}
$reflectionClass = new ReflectionClass($report);
// Don't use abstract classes
if ($reflectionClass->isAbstract()) {
continue;
}
/** @var Report $reportObj */
$reportObj = $report::create();
if ($reportObj->hasMethod('sort')) {
// Use the sort method to specify the sort field
$reportObj->sort = $reportObj->sort();
}
$reportsArray[$report] = $reportObj;
}
}
uasort($reportsArray, function ($a, $b) {
if ($a->sort == $b->sort) {
return 0;
} else {
return ($a->sort < $b->sort) ? -1 : 1;
}
});
return $reportsArray;
} | [
"public",
"static",
"function",
"get_reports",
"(",
")",
"{",
"$",
"reports",
"=",
"ClassInfo",
"::",
"subclassesFor",
"(",
"get_called_class",
"(",
")",
")",
";",
"$",
"reportsArray",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"reports",
"&&",
"count",
"(",
... | Return the SS_Report objects making up the given list.
@return Report[] Array of Report objects | [
"Return",
"the",
"SS_Report",
"objects",
"making",
"up",
"the",
"given",
"list",
"."
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L245-L283 | train |
silverstripe/silverstripe-reports | code/Report.php | Report.getSourceParams | protected function getSourceParams()
{
$params = [];
if (Injector::inst()->has(HTTPRequest::class)) {
/** @var HTTPRequest $request */
$request = Injector::inst()->get(HTTPRequest::class);
$params = $request->param('filters') ?: $request->requestVar('filters') ?: [];
}
$this->extend('updateSourceParams', $params);
return $params;
} | php | protected function getSourceParams()
{
$params = [];
if (Injector::inst()->has(HTTPRequest::class)) {
/** @var HTTPRequest $request */
$request = Injector::inst()->get(HTTPRequest::class);
$params = $request->param('filters') ?: $request->requestVar('filters') ?: [];
}
$this->extend('updateSourceParams', $params);
return $params;
} | [
"protected",
"function",
"getSourceParams",
"(",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"Injector",
"::",
"inst",
"(",
")",
"->",
"has",
"(",
"HTTPRequest",
"::",
"class",
")",
")",
"{",
"/** @var HTTPRequest $request */",
"$",
"request",
... | Get source params for the report to filter by
@return array | [
"Get",
"source",
"params",
"for",
"the",
"report",
"to",
"filter",
"by"
] | 1f1278b8203536e93ebba3df03adbca9a1ac1ead | https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L488-L500 | train |
contentful/contentful-core.php | src/Api/Requester.php | Requester.sendRequest | public function sendRequest(RequestInterface $request): Message
{
$startTime = \microtime(true);
$exception = null;
try {
$response = $this->httpClient->send($request);
} catch (ClientException $exception) {
$response = $exception->hasResponse()
? $exception->getResponse()
: null;
$exception = $this->createCustomException($exception);
}
$duration = \microtime(true) - $startTime;
return new Message(
$this->api,
$duration,
$request,
$response,
$exception
);
} | php | public function sendRequest(RequestInterface $request): Message
{
$startTime = \microtime(true);
$exception = null;
try {
$response = $this->httpClient->send($request);
} catch (ClientException $exception) {
$response = $exception->hasResponse()
? $exception->getResponse()
: null;
$exception = $this->createCustomException($exception);
}
$duration = \microtime(true) - $startTime;
return new Message(
$this->api,
$duration,
$request,
$response,
$exception
);
} | [
"public",
"function",
"sendRequest",
"(",
"RequestInterface",
"$",
"request",
")",
":",
"Message",
"{",
"$",
"startTime",
"=",
"\\",
"microtime",
"(",
"true",
")",
";",
"$",
"exception",
"=",
"null",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
... | Queries the API, and returns a message object
which contains all information needed for processing and logging.
@param RequestInterface $request
@return Message | [
"Queries",
"the",
"API",
"and",
"returns",
"a",
"message",
"object",
"which",
"contains",
"all",
"information",
"needed",
"for",
"processing",
"and",
"logging",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Requester.php#L58-L82 | train |
contentful/contentful-core.php | src/Api/Requester.php | Requester.createCustomException | private function createCustomException(ClientException $exception): Exception
{
$errorId = '';
$response = $exception->getResponse();
if ($response) {
$data = guzzle_json_decode((string) $response->getBody(), true);
$errorId = (string) $data['sys']['id'] ?? '';
}
$exceptionClass = $this->getExceptionClass($errorId);
return new $exceptionClass($exception);
} | php | private function createCustomException(ClientException $exception): Exception
{
$errorId = '';
$response = $exception->getResponse();
if ($response) {
$data = guzzle_json_decode((string) $response->getBody(), true);
$errorId = (string) $data['sys']['id'] ?? '';
}
$exceptionClass = $this->getExceptionClass($errorId);
return new $exceptionClass($exception);
} | [
"private",
"function",
"createCustomException",
"(",
"ClientException",
"$",
"exception",
")",
":",
"Exception",
"{",
"$",
"errorId",
"=",
"''",
";",
"$",
"response",
"=",
"$",
"exception",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"$",
"response",
")... | Attempts to create a custom exception.
It will return a default exception if no suitable class is found.
@param ClientException $exception
@return Exception | [
"Attempts",
"to",
"create",
"a",
"custom",
"exception",
".",
"It",
"will",
"return",
"a",
"default",
"exception",
"if",
"no",
"suitable",
"class",
"is",
"found",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Requester.php#L92-L104 | train |
contentful/contentful-core.php | src/Api/Requester.php | Requester.getExceptionClass | private function getExceptionClass(string $apiError): string
{
if ($this->exceptionNamespace) {
$class = $this->exceptionNamespace.'\\'.$apiError.'Exception';
if (\class_exists($class)) {
return $class;
}
}
$class = '\\Contentful\\Core\\Exception\\'.$apiError.'Exception';
return \class_exists($class) ? $class : Exception::class;
} | php | private function getExceptionClass(string $apiError): string
{
if ($this->exceptionNamespace) {
$class = $this->exceptionNamespace.'\\'.$apiError.'Exception';
if (\class_exists($class)) {
return $class;
}
}
$class = '\\Contentful\\Core\\Exception\\'.$apiError.'Exception';
return \class_exists($class) ? $class : Exception::class;
} | [
"private",
"function",
"getExceptionClass",
"(",
"string",
"$",
"apiError",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"exceptionNamespace",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"exceptionNamespace",
".",
"'\\\\'",
".",
"$",
"apiErro... | Returns the FQCN of an exception class to be used for the given API error.
@param string $apiError
@return string | [
"Returns",
"the",
"FQCN",
"of",
"an",
"exception",
"class",
"to",
"be",
"used",
"for",
"the",
"given",
"API",
"error",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Requester.php#L113-L126 | train |
contentful/contentful-core.php | src/Api/BaseClient.php | BaseClient.callApi | protected function callApi(string $method, string $uri, array $options = []): array
{
$request = $this->requestBuilder->build($method, $uri, $options);
$message = $this->requester->sendRequest($request);
$this->messages[] = $message;
$this->logMessage($message);
$exception = $message->getException();
if (null !== $exception) {
throw $exception;
}
return $this->parseResponse($message->getResponse());
} | php | protected function callApi(string $method, string $uri, array $options = []): array
{
$request = $this->requestBuilder->build($method, $uri, $options);
$message = $this->requester->sendRequest($request);
$this->messages[] = $message;
$this->logMessage($message);
$exception = $message->getException();
if (null !== $exception) {
throw $exception;
}
return $this->parseResponse($message->getResponse());
} | [
"protected",
"function",
"callApi",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"requestBuilder",
"->",
"build",
"(",
"$",
"meth... | Make a call to the API and returns the parsed JSON.
@param string $method The HTTP method
@param string $uri The URI path
@param array $options An array of optional parameters. The following keys are accepted:
* query An array of query parameters that will be appended to the URI
* headers An array of headers that will be added to the request
* body The request body
* host A string that can be used to override the default client base URI
@throws \Exception
@return array | [
"Make",
"a",
"call",
"to",
"the",
"API",
"and",
"returns",
"the",
"parsed",
"JSON",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseClient.php#L106-L121 | train |
contentful/contentful-core.php | src/Api/BaseClient.php | BaseClient.logMessage | private function logMessage(Message $message)
{
$logMessage = \sprintf(
'%s %s (%.3Fs)',
$message->getRequest()->getMethod(),
(string) $message->getRequest()->getUri(),
$message->getDuration()
);
// This is a "simple" log, for general purpose
$this->logger->log(
$message->getLogLevel(),
$logMessage
);
// This is a debug log, with all message details, useful for debugging
$this->logger->debug($logMessage, $message->jsonSerialize());
} | php | private function logMessage(Message $message)
{
$logMessage = \sprintf(
'%s %s (%.3Fs)',
$message->getRequest()->getMethod(),
(string) $message->getRequest()->getUri(),
$message->getDuration()
);
// This is a "simple" log, for general purpose
$this->logger->log(
$message->getLogLevel(),
$logMessage
);
// This is a debug log, with all message details, useful for debugging
$this->logger->debug($logMessage, $message->jsonSerialize());
} | [
"private",
"function",
"logMessage",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"logMessage",
"=",
"\\",
"sprintf",
"(",
"'%s %s (%.3Fs)'",
",",
"$",
"message",
"->",
"getRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
",",
"(",
"string",
")",
"$",
... | Write information about a message object into the logger.
@param Message $message | [
"Write",
"information",
"about",
"a",
"message",
"object",
"into",
"the",
"logger",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseClient.php#L128-L145 | train |
contentful/contentful-core.php | src/Api/BaseClient.php | BaseClient.parseResponse | private function parseResponse(ResponseInterface $response = null): array
{
$body = $response
? (string) $response->getBody()
: null;
return $body
? guzzle_json_decode($body, true)
: [];
} | php | private function parseResponse(ResponseInterface $response = null): array
{
$body = $response
? (string) $response->getBody()
: null;
return $body
? guzzle_json_decode($body, true)
: [];
} | [
"private",
"function",
"parseResponse",
"(",
"ResponseInterface",
"$",
"response",
"=",
"null",
")",
":",
"array",
"{",
"$",
"body",
"=",
"$",
"response",
"?",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
":",
"null",
";",
"return",
... | Parse the body of a JSON response.
@param ResponseInterface|null $response
@return array | [
"Parse",
"the",
"body",
"of",
"a",
"JSON",
"response",
"."
] | 46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536 | https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseClient.php#L154-L163 | train |
eveseat/services | src/Repositories/Character/Notifications.php | Notifications.getCharacterNotifications | public function getCharacterNotifications(int $character_id, int $chunk = 50): Collection
{
return CharacterNotification::where('character_id', $character_id)
->take($chunk)
->orderBy('timestamp', 'desc')
->get();
} | php | public function getCharacterNotifications(int $character_id, int $chunk = 50): Collection
{
return CharacterNotification::where('character_id', $character_id)
->take($chunk)
->orderBy('timestamp', 'desc')
->get();
} | [
"public",
"function",
"getCharacterNotifications",
"(",
"int",
"$",
"character_id",
",",
"int",
"$",
"chunk",
"=",
"50",
")",
":",
"Collection",
"{",
"return",
"CharacterNotification",
"::",
"where",
"(",
"'character_id'",
",",
"$",
"character_id",
")",
"->",
... | Return notifications for a character.
@param int $character_id
@param int $chunk
@return \Illuminate\Support\Collection | [
"Return",
"notifications",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Notifications.php#L42-L49 | train |
eveseat/services | src/Repositories/Character/Industry.php | Industry.getCharacterIndustry | public function getCharacterIndustry(int $character_id, bool $get = true)
{
$industry = DB::table('character_industry_jobs as a')
->select(DB::raw('
a.*,
ramActivities.*,
blueprintType.typeName as blueprintTypeName,
productType.typeName as productTypeName,
--
-- Start Facility Name Lookup
--
CASE
when a.station_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.station_id-6000000)
when a.station_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.station_id-6000001)
when a.station_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.station_id-6000000)
when a.station_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.station_id)
when a.station_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.station_id)
when a.station_id >= 61000000 then
(SELECT c.name FROM `universe_structures` AS c
WHERE c.structure_id = a.station_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.station_id) end
AS facilityName'))
->leftJoin(
'ramActivities',
'ramActivities.activityID', '=',
'a.activity_id')// character_industry_jobs aliased to a
->join(
'invTypes as blueprintType',
'blueprintType.typeID', '=',
'a.blueprint_type_id'
)
->join(
'invTypes as productType',
'productType.typeID', '=',
'a.product_type_id'
)
->where('a.character_id', $character_id);
if ($get)
return $industry->orderBy('end_date', 'desc')
->get();
return $industry;
} | php | public function getCharacterIndustry(int $character_id, bool $get = true)
{
$industry = DB::table('character_industry_jobs as a')
->select(DB::raw('
a.*,
ramActivities.*,
blueprintType.typeName as blueprintTypeName,
productType.typeName as productTypeName,
--
-- Start Facility Name Lookup
--
CASE
when a.station_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.station_id-6000000)
when a.station_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.station_id-6000001)
when a.station_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.station_id-6000000)
when a.station_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.station_id)
when a.station_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.station_id)
when a.station_id >= 61000000 then
(SELECT c.name FROM `universe_structures` AS c
WHERE c.structure_id = a.station_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.station_id) end
AS facilityName'))
->leftJoin(
'ramActivities',
'ramActivities.activityID', '=',
'a.activity_id')// character_industry_jobs aliased to a
->join(
'invTypes as blueprintType',
'blueprintType.typeID', '=',
'a.blueprint_type_id'
)
->join(
'invTypes as productType',
'productType.typeID', '=',
'a.product_type_id'
)
->where('a.character_id', $character_id);
if ($get)
return $industry->orderBy('end_date', 'desc')
->get();
return $industry;
} | [
"public",
"function",
"getCharacterIndustry",
"(",
"int",
"$",
"character_id",
",",
"bool",
"$",
"get",
"=",
"true",
")",
"{",
"$",
"industry",
"=",
"DB",
"::",
"table",
"(",
"'character_industry_jobs as a'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(... | Return the industry jobs for a character.
@param int $character_id
@param bool $get
@return \Illuminate\Support\Collection | [
"Return",
"the",
"industry",
"jobs",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Industry.php#L41-L100 | train |
eveseat/services | src/Repositories/Corporation/Contracts.php | Contracts.getCorporationContracts | public function getCorporationContracts(
int $corporation_id, bool $get = true, int $chunk = 50)
{
$contracts = DB::table(DB::raw('contract_details as a'))
->select(DB::raw(
'
--
-- All Columns
--
*,
--
-- Start Location Lookup
--
CASE
when a.start_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000000)
when a.start_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000001)
when a.start_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id-6000000)
when a.start_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
when a.start_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id)
when a.start_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.start_location_id) end
AS startlocation,
--
-- End Location Lookup
--
CASE
when a.end_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000000)
when a.end_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000001)
when a.end_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id-6000000)
when a.end_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
when a.end_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id)
when a.end_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.end_location_id) end
AS endlocation '))
->join('corporation_contracts', 'corporation_contracts.contract_id', '=', 'a.contract_id')
->where('corporation_contracts.corporation_id', $corporation_id);
if ($get)
return $contracts
->orderBy('date_issued', 'desc')
->paginate($chunk);
return $contracts;
} | php | public function getCorporationContracts(
int $corporation_id, bool $get = true, int $chunk = 50)
{
$contracts = DB::table(DB::raw('contract_details as a'))
->select(DB::raw(
'
--
-- All Columns
--
*,
--
-- Start Location Lookup
--
CASE
when a.start_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000000)
when a.start_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000001)
when a.start_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id-6000000)
when a.start_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
when a.start_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id)
when a.start_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.start_location_id) end
AS startlocation,
--
-- End Location Lookup
--
CASE
when a.end_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000000)
when a.end_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000001)
when a.end_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id-6000000)
when a.end_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
when a.end_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id)
when a.end_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.end_location_id) end
AS endlocation '))
->join('corporation_contracts', 'corporation_contracts.contract_id', '=', 'a.contract_id')
->where('corporation_contracts.corporation_id', $corporation_id);
if ($get)
return $contracts
->orderBy('date_issued', 'desc')
->paginate($chunk);
return $contracts;
} | [
"public",
"function",
"getCorporationContracts",
"(",
"int",
"$",
"corporation_id",
",",
"bool",
"$",
"get",
"=",
"true",
",",
"int",
"$",
"chunk",
"=",
"50",
")",
"{",
"$",
"contracts",
"=",
"DB",
"::",
"table",
"(",
"DB",
"::",
"raw",
"(",
"'contract... | Return the contracts for a Corporation.
@param int $corporation_id
@param bool $get
@param int $chunk
@return \Illuminate\Pagination\LengthAwarePaginator | [
"Return",
"the",
"contracts",
"for",
"a",
"Corporation",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Contracts.php#L44-L122 | train |
eveseat/services | src/Repositories/Character/Pi.php | Pi.getCharacterPlanetaryColonies | public function getCharacterPlanetaryColonies(int $character_id): Collection
{
return CharacterPlanet::where('character_id', $character_id)
->join('mapDenormalize as system', 'system.itemID', '=', 'solar_system_id')
->join('mapDenormalize as planet', 'planet.itemID', '=', 'planet_id')
->select('character_planets.*', 'system.itemName', 'planet.typeID')
->get();
} | php | public function getCharacterPlanetaryColonies(int $character_id): Collection
{
return CharacterPlanet::where('character_id', $character_id)
->join('mapDenormalize as system', 'system.itemID', '=', 'solar_system_id')
->join('mapDenormalize as planet', 'planet.itemID', '=', 'planet_id')
->select('character_planets.*', 'system.itemName', 'planet.typeID')
->get();
} | [
"public",
"function",
"getCharacterPlanetaryColonies",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"CharacterPlanet",
"::",
"where",
"(",
"'character_id'",
",",
"$",
"character_id",
")",
"->",
"join",
"(",
"'mapDenormalize as system'",
",... | Return the Planetary Colonies for a character.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Return",
"the",
"Planetary",
"Colonies",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Pi.php#L41-L49 | train |
eveseat/services | src/Repositories/Corporation/Standings.php | Standings.getCorporationStandings | public function getCorporationStandings(int $corporation_id, int $chunk = 50)
{
return CorporationStanding::where('corporation_id', $corporation_id)
->leftJoin('chrFactions', 'from_id', '=', 'factionID')
->orderBy('from_type')
->paginate($chunk);
} | php | public function getCorporationStandings(int $corporation_id, int $chunk = 50)
{
return CorporationStanding::where('corporation_id', $corporation_id)
->leftJoin('chrFactions', 'from_id', '=', 'factionID')
->orderBy('from_type')
->paginate($chunk);
} | [
"public",
"function",
"getCorporationStandings",
"(",
"int",
"$",
"corporation_id",
",",
"int",
"$",
"chunk",
"=",
"50",
")",
"{",
"return",
"CorporationStanding",
"::",
"where",
"(",
"'corporation_id'",
",",
"$",
"corporation_id",
")",
"->",
"leftJoin",
"(",
... | Return the standings for a Corporation.
@param int $corporation_id
@param int $chunk
@return mixed | [
"Return",
"the",
"standings",
"for",
"a",
"Corporation",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Standings.php#L41-L48 | train |
eveseat/services | src/Repositories/Corporation/Corporation.php | Corporation.getAllCorporationsWithAffiliationsAndFilters | public function getAllCorporationsWithAffiliationsAndFilters(bool $get = true)
{
// Get the User for permissions and affiliation
// checks
$user = auth()->user();
// Start a fresh query
$corporations = new CorporationInfo();
// Check if this user us a superuser. If not,
// limit to stuff only they can see.
if (! $user->hasSuperUser())
$corporations = $corporations->whereIn('corporation_id',
array_keys($user->getAffiliationMap()['corp']));
if ($get)
return $corporations->orderBy('name', 'desc')
->get();
return $corporations->getQuery();
} | php | public function getAllCorporationsWithAffiliationsAndFilters(bool $get = true)
{
// Get the User for permissions and affiliation
// checks
$user = auth()->user();
// Start a fresh query
$corporations = new CorporationInfo();
// Check if this user us a superuser. If not,
// limit to stuff only they can see.
if (! $user->hasSuperUser())
$corporations = $corporations->whereIn('corporation_id',
array_keys($user->getAffiliationMap()['corp']));
if ($get)
return $corporations->orderBy('name', 'desc')
->get();
return $corporations->getQuery();
} | [
"public",
"function",
"getAllCorporationsWithAffiliationsAndFilters",
"(",
"bool",
"$",
"get",
"=",
"true",
")",
"{",
"// Get the User for permissions and affiliation",
"// checks",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"// Start a fresh que... | Return the corporations for which a user has access.
@param bool $get
@return mixed | [
"Return",
"the",
"corporations",
"for",
"which",
"a",
"user",
"has",
"access",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Corporation.php#L49-L71 | train |
eveseat/services | src/Repositories/Corporation/Ledger.php | Ledger.getCorporationLedgerBountyPrizeDates | public function getCorporationLedgerBountyPrizeDates(int $corporation_id): Collection
{
return CorporationWalletJournal::select(DB::raw('DISTINCT MONTH(date) as month, YEAR(date) as year'))
->where('corporation_id', $corporation_id)
->whereIn('ref_type', ['bounty_prizes', 'bounty_prize'])
->orderBy('date', 'desc')
->get();
} | php | public function getCorporationLedgerBountyPrizeDates(int $corporation_id): Collection
{
return CorporationWalletJournal::select(DB::raw('DISTINCT MONTH(date) as month, YEAR(date) as year'))
->where('corporation_id', $corporation_id)
->whereIn('ref_type', ['bounty_prizes', 'bounty_prize'])
->orderBy('date', 'desc')
->get();
} | [
"public",
"function",
"getCorporationLedgerBountyPrizeDates",
"(",
"int",
"$",
"corporation_id",
")",
":",
"Collection",
"{",
"return",
"CorporationWalletJournal",
"::",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'DISTINCT MONTH(date) as month, YEAR(date) as year'",
")",
")"... | Return the Bounty Prize Payout dates for a Corporation.
@param int $corporation_id
@return \Illuminate\Support\Collection | [
"Return",
"the",
"Bounty",
"Prize",
"Payout",
"dates",
"for",
"a",
"Corporation",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Ledger.php#L42-L50 | train |
eveseat/services | src/Traits/NotableTrait.php | NotableTrait.addNote | public static function addNote(
int $object_id, string $title, string $note): Note
{
return Note::create([
'object_type' => __CLASS__,
'object_id' => $object_id,
'title' => $title,
'note' => $note,
]);
} | php | public static function addNote(
int $object_id, string $title, string $note): Note
{
return Note::create([
'object_type' => __CLASS__,
'object_id' => $object_id,
'title' => $title,
'note' => $note,
]);
} | [
"public",
"static",
"function",
"addNote",
"(",
"int",
"$",
"object_id",
",",
"string",
"$",
"title",
",",
"string",
"$",
"note",
")",
":",
"Note",
"{",
"return",
"Note",
"::",
"create",
"(",
"[",
"'object_type'",
"=>",
"__CLASS__",
",",
"'object_id'",
"... | Add a note.
@param int $object_id
@param string $title
@param string $note
@return \Seat\Services\Models\Note | [
"Add",
"a",
"note",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Traits/NotableTrait.php#L43-L54 | train |
eveseat/services | src/Traits/NotableTrait.php | NotableTrait.getNote | public static function getNote(int $object_id, int $note_id): Builder
{
return Note::where('object_type', __CLASS__)
->where('object_id', $object_id)
->where('id', $note_id);
} | php | public static function getNote(int $object_id, int $note_id): Builder
{
return Note::where('object_type', __CLASS__)
->where('object_id', $object_id)
->where('id', $note_id);
} | [
"public",
"static",
"function",
"getNote",
"(",
"int",
"$",
"object_id",
",",
"int",
"$",
"note_id",
")",
":",
"Builder",
"{",
"return",
"Note",
"::",
"where",
"(",
"'object_type'",
",",
"__CLASS__",
")",
"->",
"where",
"(",
"'object_id'",
",",
"$",
"obj... | Get a single note.
@param int $object_id
@param int $note_id
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"a",
"single",
"note",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Traits/NotableTrait.php#L79-L86 | train |
eveseat/services | src/Traits/NotableTrait.php | NotableTrait.deleteNote | public static function deleteNote(int $object_id, int $note_id): int
{
return Note::where('object_type', __CLASS__)
->where('object_id', $object_id)
->where('id', $note_id)
->delete();
} | php | public static function deleteNote(int $object_id, int $note_id): int
{
return Note::where('object_type', __CLASS__)
->where('object_id', $object_id)
->where('id', $note_id)
->delete();
} | [
"public",
"static",
"function",
"deleteNote",
"(",
"int",
"$",
"object_id",
",",
"int",
"$",
"note_id",
")",
":",
"int",
"{",
"return",
"Note",
"::",
"where",
"(",
"'object_type'",
",",
"__CLASS__",
")",
"->",
"where",
"(",
"'object_id'",
",",
"$",
"obje... | Delete a single note.
@param int $object_id
@param int $note_id
@return int | [
"Delete",
"a",
"single",
"note",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Traits/NotableTrait.php#L96-L104 | train |
eveseat/services | src/Traits/NotableTrait.php | NotableTrait.updateNote | public static function updateNote(
int $object_id, int $note_id, string $title = null, string $note = null)
{
$note_record = Note::where('object_type', __CLASS__)
->where('object_id', $object_id)
->where('id', $note_id)
->first();
if (! is_null($title))
$note_record->title = $title;
if (! is_null($note))
$note_record->note = $note;
$note_record->save();
} | php | public static function updateNote(
int $object_id, int $note_id, string $title = null, string $note = null)
{
$note_record = Note::where('object_type', __CLASS__)
->where('object_id', $object_id)
->where('id', $note_id)
->first();
if (! is_null($title))
$note_record->title = $title;
if (! is_null($note))
$note_record->note = $note;
$note_record->save();
} | [
"public",
"static",
"function",
"updateNote",
"(",
"int",
"$",
"object_id",
",",
"int",
"$",
"note_id",
",",
"string",
"$",
"title",
"=",
"null",
",",
"string",
"$",
"note",
"=",
"null",
")",
"{",
"$",
"note_record",
"=",
"Note",
"::",
"where",
"(",
... | Update a single note with a new title or note.
@param int $object_id
@param int $note_id
@param string|null $title
@param string|null $note | [
"Update",
"a",
"single",
"note",
"with",
"a",
"new",
"title",
"or",
"note",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Traits/NotableTrait.php#L114-L131 | train |
eveseat/services | src/Repositories/Character/Skills.php | Skills.getCharacterSkillsInformation | public function getCharacterSkillsInformation(int $character_id): Collection
{
return CharacterSkill::join('invTypes',
'character_skills.skill_id', '=',
'invTypes.typeID')
->join('invGroups', 'invTypes.groupID', '=', 'invGroups.groupID')
->where('character_skills.character_id', $character_id)
->orderBy('invTypes.typeName')
->get();
} | php | public function getCharacterSkillsInformation(int $character_id): Collection
{
return CharacterSkill::join('invTypes',
'character_skills.skill_id', '=',
'invTypes.typeID')
->join('invGroups', 'invTypes.groupID', '=', 'invGroups.groupID')
->where('character_skills.character_id', $character_id)
->orderBy('invTypes.typeName')
->get();
} | [
"public",
"function",
"getCharacterSkillsInformation",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"CharacterSkill",
"::",
"join",
"(",
"'invTypes'",
",",
"'character_skills.skill_id'",
",",
"'='",
",",
"'invTypes.typeID'",
")",
"->",
"jo... | Return the skills detail for a specific Character.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Return",
"the",
"skills",
"detail",
"for",
"a",
"specific",
"Character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Skills.php#L39-L50 | train |
eveseat/services | src/Repositories/Character/Skills.php | Skills.getCharacterSkillQueue | public function getCharacterSkillQueue(int $character_id): Collection
{
return CharacterSkillQueue::where('characterID', $character_id)
->where('queue_position', '>', 0)
->orderBy('queue_position')
->get();
} | php | public function getCharacterSkillQueue(int $character_id): Collection
{
return CharacterSkillQueue::where('characterID', $character_id)
->where('queue_position', '>', 0)
->orderBy('queue_position')
->get();
} | [
"public",
"function",
"getCharacterSkillQueue",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"CharacterSkillQueue",
"::",
"where",
"(",
"'characterID'",
",",
"$",
"character_id",
")",
"->",
"where",
"(",
"'queue_position'",
",",
"'>'",
... | Return a characters current Skill Queue.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Return",
"a",
"characters",
"current",
"Skill",
"Queue",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Skills.php#L74-L82 | train |
eveseat/services | src/Repositories/Character/Skills.php | Skills.getCharacterSkillsAmountPerLevel | public function getCharacterSkillsAmountPerLevel(int $character_id): array
{
$skills = CharacterSkill::where('character_id', $character_id)
->get();
return [
$skills->where('trained_skill_level', 0)->count(),
$skills->where('trained_skill_level', 1)->count(),
$skills->where('trained_skill_level', 2)->count(),
$skills->where('trained_skill_level', 3)->count(),
$skills->where('trained_skill_level', 4)->count(),
$skills->where('trained_skill_level', 5)->count(),
];
} | php | public function getCharacterSkillsAmountPerLevel(int $character_id): array
{
$skills = CharacterSkill::where('character_id', $character_id)
->get();
return [
$skills->where('trained_skill_level', 0)->count(),
$skills->where('trained_skill_level', 1)->count(),
$skills->where('trained_skill_level', 2)->count(),
$skills->where('trained_skill_level', 3)->count(),
$skills->where('trained_skill_level', 4)->count(),
$skills->where('trained_skill_level', 5)->count(),
];
} | [
"public",
"function",
"getCharacterSkillsAmountPerLevel",
"(",
"int",
"$",
"character_id",
")",
":",
"array",
"{",
"$",
"skills",
"=",
"CharacterSkill",
"::",
"where",
"(",
"'character_id'",
",",
"$",
"character_id",
")",
"->",
"get",
"(",
")",
";",
"return",
... | Get the numer of skills per Level for a character.
@param int $character_id
@return array | [
"Get",
"the",
"numer",
"of",
"skills",
"per",
"Level",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Skills.php#L91-L105 | train |
eveseat/services | src/Repositories/Character/Skills.php | Skills.getCharacterSkillCoverage | public function getCharacterSkillCoverage(int $character_id): Collection
{
$in_game_skills = DB::table('invTypes')
->join(
'invMarketGroups',
'invMarketGroups.marketGroupID', '=', 'invTypes.marketGroupID'
)
->where('parentGroupID', '?')// binding at [1]
->select(
'marketGroupName',
DB::raw('COUNT(invTypes.marketGroupID) * 5 as amount')
)
->groupBy('marketGroupName')
->toSql();
$character_skills = CharacterSkill::join(
'invTypes',
'invTypes.typeID', '=',
'character_skills.skill_id'
)
->join(
'invMarketGroups',
'invMarketGroups.marketGroupID', '=',
'invTypes.marketGroupID'
)
->where('character_id', '?')// binding at [2]
->select(
'marketGroupName',
DB::raw('COUNT(invTypes.marketGroupID) * character_skills.trained_skill_level as amount')
)
->groupBy(['marketGroupName', 'trained_skill_level'])
->toSql();
$skills = DB::table(
DB::raw('(' . $in_game_skills . ') a')
)
->leftJoin(
DB::raw('(' . $character_skills . ') b'),
'a.marketGroupName',
'b.marketGroupName'
)
->select(
'a.marketGroupName',
DB::raw('a.amount AS gameAmount'),
DB::raw('SUM(b.amount) AS characterAmount')
)
->groupBy(['a.marketGroupName', 'a.amount'])
->addBinding(150, 'select')// binding [1]
->addBinding($character_id, 'select')// binding [2]
->get();
return $skills;
} | php | public function getCharacterSkillCoverage(int $character_id): Collection
{
$in_game_skills = DB::table('invTypes')
->join(
'invMarketGroups',
'invMarketGroups.marketGroupID', '=', 'invTypes.marketGroupID'
)
->where('parentGroupID', '?')// binding at [1]
->select(
'marketGroupName',
DB::raw('COUNT(invTypes.marketGroupID) * 5 as amount')
)
->groupBy('marketGroupName')
->toSql();
$character_skills = CharacterSkill::join(
'invTypes',
'invTypes.typeID', '=',
'character_skills.skill_id'
)
->join(
'invMarketGroups',
'invMarketGroups.marketGroupID', '=',
'invTypes.marketGroupID'
)
->where('character_id', '?')// binding at [2]
->select(
'marketGroupName',
DB::raw('COUNT(invTypes.marketGroupID) * character_skills.trained_skill_level as amount')
)
->groupBy(['marketGroupName', 'trained_skill_level'])
->toSql();
$skills = DB::table(
DB::raw('(' . $in_game_skills . ') a')
)
->leftJoin(
DB::raw('(' . $character_skills . ') b'),
'a.marketGroupName',
'b.marketGroupName'
)
->select(
'a.marketGroupName',
DB::raw('a.amount AS gameAmount'),
DB::raw('SUM(b.amount) AS characterAmount')
)
->groupBy(['a.marketGroupName', 'a.amount'])
->addBinding(150, 'select')// binding [1]
->addBinding($character_id, 'select')// binding [2]
->get();
return $skills;
} | [
"public",
"function",
"getCharacterSkillCoverage",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"$",
"in_game_skills",
"=",
"DB",
"::",
"table",
"(",
"'invTypes'",
")",
"->",
"join",
"(",
"'invMarketGroups'",
",",
"'invMarketGroups.marketGroupID'",
... | Get a characters skill as well as category completion
ration rate.
TODO: This is definitely a candidate for a better refactor!
@param int $character_id
@return \Illuminate\Support\Collection | [
"Get",
"a",
"characters",
"skill",
"as",
"well",
"as",
"category",
"completion",
"ration",
"rate",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Skills.php#L117-L170 | train |
eveseat/services | src/Settings/Settings.php | Settings.get | public static function get($name, $for_id = null)
{
// Pickup the value from the cache if we can. Otherwise,
// read the value for the database and cache it for next
// time.
return Cache::rememberForever(self::get_key_prefix($name,
self::get_affected_id($for_id)), function () use ($name, $for_id) {
// Init a new MODEL
$value = (new static::$model);
// If we are not in the global scope, add a constraint
// to be user group specific.
if (static::$scope != 'global')
$value = $value->where('group_id', self::get_affected_id($for_id));
// Retrieve the value
$value = $value->where('name', $name)
->value('value');
if ($value)
return json_decode($value);
// If we have no value, check if we can return
// a default setting
if (array_key_exists($name, static::$defaults))
return static::$defaults[$name];
return null;
});
} | php | public static function get($name, $for_id = null)
{
// Pickup the value from the cache if we can. Otherwise,
// read the value for the database and cache it for next
// time.
return Cache::rememberForever(self::get_key_prefix($name,
self::get_affected_id($for_id)), function () use ($name, $for_id) {
// Init a new MODEL
$value = (new static::$model);
// If we are not in the global scope, add a constraint
// to be user group specific.
if (static::$scope != 'global')
$value = $value->where('group_id', self::get_affected_id($for_id));
// Retrieve the value
$value = $value->where('name', $name)
->value('value');
if ($value)
return json_decode($value);
// If we have no value, check if we can return
// a default setting
if (array_key_exists($name, static::$defaults))
return static::$defaults[$name];
return null;
});
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"for_id",
"=",
"null",
")",
"{",
"// Pickup the value from the cache if we can. Otherwise,",
"// read the value for the database and cache it for next",
"// time.",
"return",
"Cache",
"::",
"rememberForever",
... | Retrieve a setting by name.
@param $name
@param null $for_id
@return mixed
@throws \Seat\Services\Exceptions\SettingException | [
"Retrieve",
"a",
"setting",
"by",
"name",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Settings/Settings.php#L72-L103 | train |
eveseat/services | src/Settings/Settings.php | Settings.get_key_prefix | public static function get_key_prefix($name, $for_id = null)
{
// Ensure we have a prefix to work with.
if (is_null(static::$prefix))
throw new SettingException('No prefix defined. Have you extended and declared $prefix?');
// Prefix user keys with group_id
if (static::$scope != 'global')
return implode('.', [$for_id, static::$prefix, $name]);
// Global keys only with the global prefix.
return implode('.', [static::$prefix, $name]);
} | php | public static function get_key_prefix($name, $for_id = null)
{
// Ensure we have a prefix to work with.
if (is_null(static::$prefix))
throw new SettingException('No prefix defined. Have you extended and declared $prefix?');
// Prefix user keys with group_id
if (static::$scope != 'global')
return implode('.', [$for_id, static::$prefix, $name]);
// Global keys only with the global prefix.
return implode('.', [static::$prefix, $name]);
} | [
"public",
"static",
"function",
"get_key_prefix",
"(",
"$",
"name",
",",
"$",
"for_id",
"=",
"null",
")",
"{",
"// Ensure we have a prefix to work with.",
"if",
"(",
"is_null",
"(",
"static",
"::",
"$",
"prefix",
")",
")",
"throw",
"new",
"SettingException",
"... | Determine the unique prefix for the key by name.
@param $name
@param $for_id
@return string
@throws \Seat\Services\Exceptions\SettingException | [
"Determine",
"the",
"unique",
"prefix",
"for",
"the",
"key",
"by",
"name",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Settings/Settings.php#L114-L127 | train |
eveseat/services | src/Settings/Settings.php | Settings.get_affected_id | public static function get_affected_id($for_id)
{
// Without auth, return what we have.
if (! auth()->check())
return $for_id;
if (is_null($for_id))
return auth()->user()->group->id;
return $for_id;
} | php | public static function get_affected_id($for_id)
{
// Without auth, return what we have.
if (! auth()->check())
return $for_id;
if (is_null($for_id))
return auth()->user()->group->id;
return $for_id;
} | [
"public",
"static",
"function",
"get_affected_id",
"(",
"$",
"for_id",
")",
"{",
"// Without auth, return what we have.",
"if",
"(",
"!",
"auth",
"(",
")",
"->",
"check",
"(",
")",
")",
"return",
"$",
"for_id",
";",
"if",
"(",
"is_null",
"(",
"$",
"for_id"... | Determine the effected group id.
If this is for a specific id use that, otherwise
assume the currently logged in user's id. If we
dont have an already logged in session, well then
we make the $for_id null.
@param $for_id
@return int|null | [
"Determine",
"the",
"effected",
"group",
"id",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Settings/Settings.php#L141-L152 | train |
eveseat/services | src/Repositories/Character/Contacts.php | Contacts.getCharacterContacts | public function getCharacterContacts(Collection $character_ids, array $standings): Builder
{
return CharacterContact::whereIn('character_contacts.character_id', $character_ids->toArray())
->whereIn('standing', $standings);
} | php | public function getCharacterContacts(Collection $character_ids, array $standings): Builder
{
return CharacterContact::whereIn('character_contacts.character_id', $character_ids->toArray())
->whereIn('standing', $standings);
} | [
"public",
"function",
"getCharacterContacts",
"(",
"Collection",
"$",
"character_ids",
",",
"array",
"$",
"standings",
")",
":",
"Builder",
"{",
"return",
"CharacterContact",
"::",
"whereIn",
"(",
"'character_contacts.character_id'",
",",
"$",
"character_ids",
"->",
... | Get a characters contact list.
@param \Illuminate\Support\Collection $character_ids
@param array $standings
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"a",
"characters",
"contact",
"list",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Contacts.php#L41-L46 | train |
eveseat/services | src/Jobs/Analytics.php | Analytics.handle | public function handle()
{
// Do nothing if tracking is disabled
if (! $this->allowTracking())
return;
// Send the hit based on the hit type
switch ($this->hit->type) {
case 'event':
$this->sendEvent();
break;
case 'exception':
$this->sendException();
break;
default:
break;
}
} | php | public function handle()
{
// Do nothing if tracking is disabled
if (! $this->allowTracking())
return;
// Send the hit based on the hit type
switch ($this->hit->type) {
case 'event':
$this->sendEvent();
break;
case 'exception':
$this->sendException();
break;
default:
break;
}
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"// Do nothing if tracking is disabled",
"if",
"(",
"!",
"$",
"this",
"->",
"allowTracking",
"(",
")",
")",
"return",
";",
"// Send the hit based on the hit type",
"switch",
"(",
"$",
"this",
"->",
"hit",
"->",
"typ... | Execute the job, keeping in mind that if tracking
is disabled, nothing should be sent and the
job should just return.
@return void
@throws \Seat\Services\Exceptions\SettingException | [
"Execute",
"the",
"job",
"keeping",
"in",
"mind",
"that",
"if",
"tracking",
"is",
"disabled",
"nothing",
"should",
"be",
"sent",
"and",
"the",
"job",
"should",
"just",
"return",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Jobs/Analytics.php#L85-L107 | train |
eveseat/services | src/Jobs/Analytics.php | Analytics.sendEvent | public function sendEvent()
{
$this->send('event', [
'ec' => $this->hit->ec, // Event Category
'ea' => $this->hit->ea, // Event Action
'el' => $this->hit->el, // Event Label
'ev' => $this->hit->ev, // Event Value
]);
} | php | public function sendEvent()
{
$this->send('event', [
'ec' => $this->hit->ec, // Event Category
'ea' => $this->hit->ea, // Event Action
'el' => $this->hit->el, // Event Label
'ev' => $this->hit->ev, // Event Value
]);
} | [
"public",
"function",
"sendEvent",
"(",
")",
"{",
"$",
"this",
"->",
"send",
"(",
"'event'",
",",
"[",
"'ec'",
"=>",
"$",
"this",
"->",
"hit",
"->",
"ec",
",",
"// Event Category",
"'ea'",
"=>",
"$",
"this",
"->",
"hit",
"->",
"ea",
",",
"// Event Ac... | Send an 'event' type hit to GA. | [
"Send",
"an",
"event",
"type",
"hit",
"to",
"GA",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Jobs/Analytics.php#L127-L137 | train |
eveseat/services | src/Jobs/Analytics.php | Analytics.send | private function send($type, array $query)
{
$client = new Client([
'base_uri' => 'https://www.google-analytics.com/',
'timeout' => 5.0,
]);
// Check if we are in debug mode
$uri = $this->debug ? '/debug/collect' : '/collect';
// Submit the hit
$client->get($uri, [
'query' => array_merge([
// Fields referenced from:
// https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
// Required Fields
// https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#required
'v' => 1, // Protocol Version
'tid' => $this->tracking_id, // Google Tracking-ID
'cid' => $this->getClientID(), // Unique Client-ID
't' => $type, // Event
// Optional Fields
'aip' => 1, // Anonymize the IP of the calling client
'an' => 'SeAT', // App Name
// Versions of the currently installed packages.
'av' => 'api/' . config('api.config.version') . ', ' .
'console/' . config('console.config.version') . ', ' .
'eveapi/' . config('eveapi.config.version') . ', ' .
'notifications/' . config('notifications.config.version') . ', ' .
'web/' . config('web.config.version') . ', ' .
'services/' . config('services.config.version') . ', ',
// User Agent is comprised of OS Name(s), Release(r)
// and Machine Type(m). Examples:
// Darwin/15.6.0/x86_64
// Linux/2.6.32-642.el6.x86_64/x86_64
//
// See:
// http://php.net/manual/en/function.php-uname.php
'ua' => 'SeAT/' . php_uname('s') .
'/' . php_uname('r') .
'/' . php_uname('m'),
'z' => rand(1, 10000), // Cache Busting Random Value
], $query),
]);
} | php | private function send($type, array $query)
{
$client = new Client([
'base_uri' => 'https://www.google-analytics.com/',
'timeout' => 5.0,
]);
// Check if we are in debug mode
$uri = $this->debug ? '/debug/collect' : '/collect';
// Submit the hit
$client->get($uri, [
'query' => array_merge([
// Fields referenced from:
// https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
// Required Fields
// https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#required
'v' => 1, // Protocol Version
'tid' => $this->tracking_id, // Google Tracking-ID
'cid' => $this->getClientID(), // Unique Client-ID
't' => $type, // Event
// Optional Fields
'aip' => 1, // Anonymize the IP of the calling client
'an' => 'SeAT', // App Name
// Versions of the currently installed packages.
'av' => 'api/' . config('api.config.version') . ', ' .
'console/' . config('console.config.version') . ', ' .
'eveapi/' . config('eveapi.config.version') . ', ' .
'notifications/' . config('notifications.config.version') . ', ' .
'web/' . config('web.config.version') . ', ' .
'services/' . config('services.config.version') . ', ',
// User Agent is comprised of OS Name(s), Release(r)
// and Machine Type(m). Examples:
// Darwin/15.6.0/x86_64
// Linux/2.6.32-642.el6.x86_64/x86_64
//
// See:
// http://php.net/manual/en/function.php-uname.php
'ua' => 'SeAT/' . php_uname('s') .
'/' . php_uname('r') .
'/' . php_uname('m'),
'z' => rand(1, 10000), // Cache Busting Random Value
], $query),
]);
} | [
"private",
"function",
"send",
"(",
"$",
"type",
",",
"array",
"$",
"query",
")",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"'https://www.google-analytics.com/'",
",",
"'timeout'",
"=>",
"5.0",
",",
"]",
")",
";",
"// Check if... | Send the GA Hit.
@param $type
@param array $query
@throws \Seat\Services\Exceptions\SettingException | [
"Send",
"the",
"GA",
"Hit",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Jobs/Analytics.php#L147-L199 | train |
eveseat/services | src/Repositories/Corporation/Industry.php | Industry.getCorporationIndustry | public function getCorporationIndustry(int $corporation_id, bool $get = true)
{
$industry = DB::table('corporation_industry_jobs as a')
->select(DB::raw('
a.*,
ramActivities.*,
blueprintType.typeName as blueprintTypeName,
productType.typeName as productTypeName,
--
-- Start Facility Name Lookup
--
CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id)
when a.location_id >= 61000000 then
(SELECT c.name FROM `universe_structures` AS c
WHERE c.structure_id = a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.location_id) end
AS facilityName'))
->leftJoin(
'ramActivities',
'ramActivities.activityID', '=',
'a.activity_id')// corporation_industry_jobs aliased to a
->join(
'invTypes as blueprintType',
'blueprintType.typeID', '=',
'a.blueprint_type_id'
)
->join(
'invTypes as productType',
'productType.typeID', '=',
'a.product_type_id'
)
->where('a.corporation_id', $corporation_id);
if ($get)
return $industry
->orderBy('end_date', 'desc')
->get();
return $industry;
} | php | public function getCorporationIndustry(int $corporation_id, bool $get = true)
{
$industry = DB::table('corporation_industry_jobs as a')
->select(DB::raw('
a.*,
ramActivities.*,
blueprintType.typeName as blueprintTypeName,
productType.typeName as productTypeName,
--
-- Start Facility Name Lookup
--
CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id)
when a.location_id >= 61000000 then
(SELECT c.name FROM `universe_structures` AS c
WHERE c.structure_id = a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.location_id) end
AS facilityName'))
->leftJoin(
'ramActivities',
'ramActivities.activityID', '=',
'a.activity_id')// corporation_industry_jobs aliased to a
->join(
'invTypes as blueprintType',
'blueprintType.typeID', '=',
'a.blueprint_type_id'
)
->join(
'invTypes as productType',
'productType.typeID', '=',
'a.product_type_id'
)
->where('a.corporation_id', $corporation_id);
if ($get)
return $industry
->orderBy('end_date', 'desc')
->get();
return $industry;
} | [
"public",
"function",
"getCorporationIndustry",
"(",
"int",
"$",
"corporation_id",
",",
"bool",
"$",
"get",
"=",
"true",
")",
"{",
"$",
"industry",
"=",
"DB",
"::",
"table",
"(",
"'corporation_industry_jobs as a'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw"... | Return the Industry jobs for a Corporation.
@param int $corporation_id
@param bool $get
@return \Illuminate\Support\Collection | [
"Return",
"the",
"Industry",
"jobs",
"for",
"a",
"Corporation",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Industry.php#L43-L103 | train |
eveseat/services | src/Repositories/Character/Character.php | Character.getAllCharactersWithAffiliations | public function getAllCharactersWithAffiliations(bool $get = true)
{
// TODO : rewrite the method according to the new ACL mechanic
// Get the User for permissions and affiliation
// checks
$user = auth()->user();
// Which characters does the currently logged in user have?
$user_character_ids = auth()->user()->associatedCharacterIds();
// Start the character information query
$characters = new CharacterInfo;
// If the user is not a super user, return only the characters the
// user has access to.
if (! $user->hasSuperUser()) {
$characters = $characters->where(function ($query) use ($user, $user_character_ids) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.list', false))
$query->orWhereIn('character_id',
array_keys($user->getAffiliationMap()['char']));
$query->orWhereIn('character_id', $user_character_ids);
});
}
if ($get)
return $characters
->orderBy('name')
->get();
return $characters->getQuery();
} | php | public function getAllCharactersWithAffiliations(bool $get = true)
{
// TODO : rewrite the method according to the new ACL mechanic
// Get the User for permissions and affiliation
// checks
$user = auth()->user();
// Which characters does the currently logged in user have?
$user_character_ids = auth()->user()->associatedCharacterIds();
// Start the character information query
$characters = new CharacterInfo;
// If the user is not a super user, return only the characters the
// user has access to.
if (! $user->hasSuperUser()) {
$characters = $characters->where(function ($query) use ($user, $user_character_ids) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.list', false))
$query->orWhereIn('character_id',
array_keys($user->getAffiliationMap()['char']));
$query->orWhereIn('character_id', $user_character_ids);
});
}
if ($get)
return $characters
->orderBy('name')
->get();
return $characters->getQuery();
} | [
"public",
"function",
"getAllCharactersWithAffiliations",
"(",
"bool",
"$",
"get",
"=",
"true",
")",
"{",
"// TODO : rewrite the method according to the new ACL mechanic",
"// Get the User for permissions and affiliation",
"// checks",
"$",
"user",
"=",
"auth",
"(",
")",
"->"... | Query the database for characters, keeping filters,
permissions and affiliations in mind.
@param bool $get
@return mixed | [
"Query",
"the",
"database",
"for",
"characters",
"keeping",
"filters",
"permissions",
"and",
"affiliations",
"in",
"mind",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Character.php#L51-L89 | train |
eveseat/services | src/Repositories/Character/Character.php | Character.getCharacterAlliances | public function getCharacterAlliances(): Collection
{
$user = auth()->user();
$alliances = CharacterInfo::join(
'alliance_members',
'alliance_members.corporation_id',
'character_infos.corporation_id')
->join(
'alliances',
'alliances.alliance_id',
'alliance_members.alliance_id')
->distinct();
// If the user us a super user, return all
if (! $user->hasSuperUser()) {
$alliances = $alliances->orWhere(function ($query) use ($user) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.list', false))
$query = $query->whereIn('character_id',
array_keys($user->getAffiliationMap()['char']));
// Add any characters from owner API keys
$query->orWhere('character_id', $user->id);
});
}
return $alliances->orderBy('alliances.name')
->pluck('alliances.name')
->filter(function ($item) {
// Filter out the null alliance name
return ! is_null($item);
});
} | php | public function getCharacterAlliances(): Collection
{
$user = auth()->user();
$alliances = CharacterInfo::join(
'alliance_members',
'alliance_members.corporation_id',
'character_infos.corporation_id')
->join(
'alliances',
'alliances.alliance_id',
'alliance_members.alliance_id')
->distinct();
// If the user us a super user, return all
if (! $user->hasSuperUser()) {
$alliances = $alliances->orWhere(function ($query) use ($user) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.list', false))
$query = $query->whereIn('character_id',
array_keys($user->getAffiliationMap()['char']));
// Add any characters from owner API keys
$query->orWhere('character_id', $user->id);
});
}
return $alliances->orderBy('alliances.name')
->pluck('alliances.name')
->filter(function ($item) {
// Filter out the null alliance name
return ! is_null($item);
});
} | [
"public",
"function",
"getCharacterAlliances",
"(",
")",
":",
"Collection",
"{",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"alliances",
"=",
"CharacterInfo",
"::",
"join",
"(",
"'alliance_members'",
",",
"'alliance_members.corporati... | Get a list of alliances the current
authenticated user has access to.
@return \Illuminate\Support\Collection | [
"Get",
"a",
"list",
"of",
"alliances",
"the",
"current",
"authenticated",
"user",
"has",
"access",
"to",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Character.php#L97-L136 | train |
eveseat/services | src/Repositories/Character/Character.php | Character.getCharacterCorporations | public function getCharacterCorporations()
{
// TODO : rewrite the method according to the new ACL mechanic
$user = auth()->user();
$corporations = ApiKeyInfoCharacters::join(
'eve_api_keys',
'eve_api_keys.key_id', '=',
'account_api_key_info_characters.keyID')
->distinct();
// If the user us a super user, return all
if (! $user->hasSuperUser()) {
$corporations = $corporations->orWhere(function ($query) use ($user) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.list', false))
$query = $query->whereIn('characterID',
array_keys($user->getAffiliationMap()['char']));
// Add any characters from owner API keys
$query->orWhere('eve_api_keys.user_id', $user->id);
});
}
return $corporations->orderBy('corporationName')
->pluck('corporationName');
} | php | public function getCharacterCorporations()
{
// TODO : rewrite the method according to the new ACL mechanic
$user = auth()->user();
$corporations = ApiKeyInfoCharacters::join(
'eve_api_keys',
'eve_api_keys.key_id', '=',
'account_api_key_info_characters.keyID')
->distinct();
// If the user us a super user, return all
if (! $user->hasSuperUser()) {
$corporations = $corporations->orWhere(function ($query) use ($user) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.list', false))
$query = $query->whereIn('characterID',
array_keys($user->getAffiliationMap()['char']));
// Add any characters from owner API keys
$query->orWhere('eve_api_keys.user_id', $user->id);
});
}
return $corporations->orderBy('corporationName')
->pluck('corporationName');
} | [
"public",
"function",
"getCharacterCorporations",
"(",
")",
"{",
"// TODO : rewrite the method according to the new ACL mechanic",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"corporations",
"=",
"ApiKeyInfoCharacters",
"::",
"join",
"(",
"... | Get a list of corporations the current
authenticated user has access to.
@deprecated replace by new ACL system. Must be move to ACL trait
@return mixed | [
"Get",
"a",
"list",
"of",
"corporations",
"the",
"current",
"authenticated",
"user",
"has",
"access",
"to",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Character.php#L146-L177 | train |
eveseat/services | src/Repositories/Corporation/Market.php | Market.getCorporationMarketOrders | public function getCorporationMarketOrders(int $corporation_id)
{
return DB::table(DB::raw('corporation_orders as a'))
->select(DB::raw(
'
--
-- Select All
--
*,
--
-- Start stationName Lookup
--
CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id)
when a.location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.location_id) end
AS stationName,
--
-- add total
--
a.price * a.volume_total AS price_total'))
->join(
'invTypes',
'a.type_id', '=',
'invTypes.typeID')
->join(
'invGroups',
'invTypes.groupID', '=',
'invGroups.groupID')
->where('a.corporation_id', $corporation_id);
} | php | public function getCorporationMarketOrders(int $corporation_id)
{
return DB::table(DB::raw('corporation_orders as a'))
->select(DB::raw(
'
--
-- Select All
--
*,
--
-- Start stationName Lookup
--
CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id)
when a.location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.location_id) end
AS stationName,
--
-- add total
--
a.price * a.volume_total AS price_total'))
->join(
'invTypes',
'a.type_id', '=',
'invTypes.typeID')
->join(
'invGroups',
'invTypes.groupID', '=',
'invGroups.groupID')
->where('a.corporation_id', $corporation_id);
} | [
"public",
"function",
"getCorporationMarketOrders",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"return",
"DB",
"::",
"table",
"(",
"DB",
"::",
"raw",
"(",
"'corporation_orders as a'",
")",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'\n ... | Return the Market Orders for a Corporation.
@param int $corporation_id
@param bool $get
@return \Illuminate\Support\Collection | [
"Return",
"the",
"Market",
"Orders",
"for",
"a",
"Corporation",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Market.php#L41-L94 | train |
eveseat/services | src/Repositories/Corporation/Assets.php | Assets.getCorporationAssets | public function getCorporationAssets(int $corporation_id): Collection
{
return CorporationAsset::with('content', 'type')
->select(DB::raw('
--
-- Select All Fields
--
*,
--
-- Start the location lookup
--
CASE
when corporation_assets.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=corporation_assets.location_id-6000000)
when corporation_assets.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=corporation_assets.location_id-6000001)
when corporation_assets.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=corporation_assets.location_id-6000000)
when corporation_assets.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=corporation_assets.location_id)
when corporation_assets.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=corporation_assets.location_id)
when corporation_assets.location_id BETWEEN 61000000 AND 61001146 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=corporation_assets.location_id)
when corporation_assets.location_id > 61001146 then
(SELECT name FROM `universe_structures` AS c
WHERE c.structure_id = corporation_assets.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=corporation_assets.location_id) end
AS location_name'))
->whereIn('location_flag', [
// These locations look like they are top-level. Even though 'OfficeFolder' is
// top level, lets just flatten it anyways.
'AssetSafety', 'OfficeFolder', 'Impounded', 'CorpDeliveries',
])
->where('corporation_assets.corporation_id', $corporation_id)
->get();
} | php | public function getCorporationAssets(int $corporation_id): Collection
{
return CorporationAsset::with('content', 'type')
->select(DB::raw('
--
-- Select All Fields
--
*,
--
-- Start the location lookup
--
CASE
when corporation_assets.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=corporation_assets.location_id-6000000)
when corporation_assets.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=corporation_assets.location_id-6000001)
when corporation_assets.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=corporation_assets.location_id-6000000)
when corporation_assets.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=corporation_assets.location_id)
when corporation_assets.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=corporation_assets.location_id)
when corporation_assets.location_id BETWEEN 61000000 AND 61001146 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=corporation_assets.location_id)
when corporation_assets.location_id > 61001146 then
(SELECT name FROM `universe_structures` AS c
WHERE c.structure_id = corporation_assets.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=corporation_assets.location_id) end
AS location_name'))
->whereIn('location_flag', [
// These locations look like they are top-level. Even though 'OfficeFolder' is
// top level, lets just flatten it anyways.
'AssetSafety', 'OfficeFolder', 'Impounded', 'CorpDeliveries',
])
->where('corporation_assets.corporation_id', $corporation_id)
->get();
} | [
"public",
"function",
"getCorporationAssets",
"(",
"int",
"$",
"corporation_id",
")",
":",
"Collection",
"{",
"return",
"CorporationAsset",
"::",
"with",
"(",
"'content'",
",",
"'type'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'\n --\n ... | Return the assets list for a Corporation.
@param int $corporation_id
@return \Illuminate\Support\Collection | [
"Return",
"the",
"assets",
"list",
"for",
"a",
"Corporation",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Assets.php#L43-L92 | train |
eveseat/services | src/Repositories/Corporation/Assets.php | Assets.getCorporationAssetByLocation | public function getCorporationAssetByLocation(int $corporation_id): Collection
{
return Locations::leftJoin('corporation_asset_lists',
'corporation_locations.itemID', '=',
'corporation_asset_lists.itemID')
->leftJoin(
'invTypes',
'corporation_asset_lists.typeID', '=',
'invTypes.typeID')
->where('corporation_locations.corporationID', $corporation_id)
->get()
->groupBy('mapID'); // <--- :O That is so sexy <3
} | php | public function getCorporationAssetByLocation(int $corporation_id): Collection
{
return Locations::leftJoin('corporation_asset_lists',
'corporation_locations.itemID', '=',
'corporation_asset_lists.itemID')
->leftJoin(
'invTypes',
'corporation_asset_lists.typeID', '=',
'invTypes.typeID')
->where('corporation_locations.corporationID', $corporation_id)
->get()
->groupBy('mapID'); // <--- :O That is so sexy <3
} | [
"public",
"function",
"getCorporationAssetByLocation",
"(",
"int",
"$",
"corporation_id",
")",
":",
"Collection",
"{",
"return",
"Locations",
"::",
"leftJoin",
"(",
"'corporation_asset_lists'",
",",
"'corporation_locations.itemID'",
",",
"'='",
",",
"'corporation_asset_li... | Returns a corporation assets grouped by location.
Only assets in space will appear here as assets
that are in stations don't have 'locations' entries.
@param int $corporation_id
@return \Illuminate\Support\Collection | [
"Returns",
"a",
"corporation",
"assets",
"grouped",
"by",
"location",
".",
"Only",
"assets",
"in",
"space",
"will",
"appear",
"here",
"as",
"assets",
"that",
"are",
"in",
"stations",
"don",
"t",
"have",
"locations",
"entries",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Assets.php#L103-L116 | train |
eveseat/services | src/Jobs/Maintenance.php | Maintenance.cleanup_tables | public function cleanup_tables()
{
logger()->info('Performing table maintenance');
// Prune the failed jobs table
FailedJob::where('id', '<', (FailedJob::max('id') - 100))->delete();
// Prune the server statuses older than a week.
ServerStatus::where('created_at', '<', carbon('now')->subWeek(1))->delete();
// Prune ESI statuses older than a week
EsiStatus::where('created_at', '<', carbon('now')->subWeek(1))->delete();
// Remove groups with no users
Group::doesntHave('users')->delete();
} | php | public function cleanup_tables()
{
logger()->info('Performing table maintenance');
// Prune the failed jobs table
FailedJob::where('id', '<', (FailedJob::max('id') - 100))->delete();
// Prune the server statuses older than a week.
ServerStatus::where('created_at', '<', carbon('now')->subWeek(1))->delete();
// Prune ESI statuses older than a week
EsiStatus::where('created_at', '<', carbon('now')->subWeek(1))->delete();
// Remove groups with no users
Group::doesntHave('users')->delete();
} | [
"public",
"function",
"cleanup_tables",
"(",
")",
"{",
"logger",
"(",
")",
"->",
"info",
"(",
"'Performing table maintenance'",
")",
";",
"// Prune the failed jobs table",
"FailedJob",
"::",
"where",
"(",
"'id'",
",",
"'<'",
",",
"(",
"FailedJob",
"::",
"max",
... | Partially truncates tables that typically contain
a lot of data. | [
"Partially",
"truncates",
"tables",
"that",
"typically",
"contain",
"a",
"lot",
"of",
"data",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Jobs/Maintenance.php#L70-L86 | train |
eveseat/services | src/Jobs/Maintenance.php | Maintenance.cleanup_stale_data | public function cleanup_stale_data()
{
logger()->info('Performing stale data maintenance');
// First cleanup characters.
CharacterInfo::whereNotIn('character_id', function ($query) {
$query->select('id')
->from((new User)->getTable());
})->each(function ($character) {
logger()->info('Cleaning up character: ' . $character->name);
$character->delete();
});
// Next, cleanup corporations
CorporationInfo::whereNotIn('corporation_id', function ($query) {
// Filter out corporations that we have characters for.
$query->select('corporation_id')
->from((new CharacterInfo)->getTable())
->whereIn('character_id', function ($sub_query) {
// Ensure that its characters with roles. Otherwise
// the corporation info is meaningless anyways.
$sub_query->select('character_id')
->from((new CharacterRole)->getTable());
});
})->each(function ($corporation) {
dump('Cleaning up corporation: ' . $corporation->name);
logger()->info('Cleaning up corporation: ' . $corporation->name);
$corporation->delete();
});
} | php | public function cleanup_stale_data()
{
logger()->info('Performing stale data maintenance');
// First cleanup characters.
CharacterInfo::whereNotIn('character_id', function ($query) {
$query->select('id')
->from((new User)->getTable());
})->each(function ($character) {
logger()->info('Cleaning up character: ' . $character->name);
$character->delete();
});
// Next, cleanup corporations
CorporationInfo::whereNotIn('corporation_id', function ($query) {
// Filter out corporations that we have characters for.
$query->select('corporation_id')
->from((new CharacterInfo)->getTable())
->whereIn('character_id', function ($sub_query) {
// Ensure that its characters with roles. Otherwise
// the corporation info is meaningless anyways.
$sub_query->select('character_id')
->from((new CharacterRole)->getTable());
});
})->each(function ($corporation) {
dump('Cleaning up corporation: ' . $corporation->name);
logger()->info('Cleaning up corporation: ' . $corporation->name);
$corporation->delete();
});
} | [
"public",
"function",
"cleanup_stale_data",
"(",
")",
"{",
"logger",
"(",
")",
"->",
"info",
"(",
"'Performing stale data maintenance'",
")",
";",
"// First cleanup characters.",
"CharacterInfo",
"::",
"whereNotIn",
"(",
"'character_id'",
",",
"function",
"(",
"$",
... | Cleans up stale data that relate to characters and
corporations that no longer have valid users. | [
"Cleans",
"up",
"stale",
"data",
"that",
"relate",
"to",
"characters",
"and",
"corporations",
"that",
"no",
"longer",
"have",
"valid",
"users",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Jobs/Maintenance.php#L92-L132 | train |
eveseat/services | src/Repositories/Character/Calendar.php | Calendar.getCharacterUpcomingCalendarEvents | public function getCharacterUpcomingCalendarEvents(int $character_id): Collection
{
return CharacterCalendarEvent::with('detail', 'attendees')
->where('character_id', $character_id)
->whereDate('event_date', '>', carbon()->toDateTimeString())
->get();
} | php | public function getCharacterUpcomingCalendarEvents(int $character_id): Collection
{
return CharacterCalendarEvent::with('detail', 'attendees')
->where('character_id', $character_id)
->whereDate('event_date', '>', carbon()->toDateTimeString())
->get();
} | [
"public",
"function",
"getCharacterUpcomingCalendarEvents",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"CharacterCalendarEvent",
"::",
"with",
"(",
"'detail'",
",",
"'attendees'",
")",
"->",
"where",
"(",
"'character_id'",
",",
"$",
"c... | Get Calendar events for a specific character.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Get",
"Calendar",
"events",
"for",
"a",
"specific",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Calendar.php#L41-L48 | train |
eveseat/services | src/Repositories/Character/Market.php | Market.getCharacterMarketOrders | public function getCharacterMarketOrders(Collection $character_ids) : Builder
{
return DB::table(DB::raw('character_orders as a'))
->select(DB::raw(
'
--
-- Select All
--
*,
--
-- Start stationName Lookup
--
CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id)
when a.location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.location_id) end
AS stationName'))
->join(
'invTypes',
'a.type_id', '=',
'invTypes.typeID')
->whereIn('a.character_id', $character_ids);
} | php | public function getCharacterMarketOrders(Collection $character_ids) : Builder
{
return DB::table(DB::raw('character_orders as a'))
->select(DB::raw(
'
--
-- Select All
--
*,
--
-- Start stationName Lookup
--
CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.location_id)
when a.location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.location_id) end
AS stationName'))
->join(
'invTypes',
'a.type_id', '=',
'invTypes.typeID')
->whereIn('a.character_id', $character_ids);
} | [
"public",
"function",
"getCharacterMarketOrders",
"(",
"Collection",
"$",
"character_ids",
")",
":",
"Builder",
"{",
"return",
"DB",
"::",
"table",
"(",
"DB",
"::",
"raw",
"(",
"'character_orders as a'",
")",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",... | Return a characters market orders.
@param \Illuminate\Support\Collection $character_ids
@return \Illuminate\Database\Query\Builder | [
"Return",
"a",
"characters",
"market",
"orders",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Market.php#L42-L87 | train |
eveseat/services | src/Repositories/Character/Standings.php | Standings.getCharacterStandings | public function getCharacterStandings(int $character_id): Collection
{
return CharacterStanding::where('character_id', $character_id)
->leftJoin('chrFactions', 'from_id', '=', 'factionID')
->orderBy('from_type')
->get();
} | php | public function getCharacterStandings(int $character_id): Collection
{
return CharacterStanding::where('character_id', $character_id)
->leftJoin('chrFactions', 'from_id', '=', 'factionID')
->orderBy('from_type')
->get();
} | [
"public",
"function",
"getCharacterStandings",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"CharacterStanding",
"::",
"where",
"(",
"'character_id'",
",",
"$",
"character_id",
")",
"->",
"leftJoin",
"(",
"'chrFactions'",
",",
"'from_id'... | Return the standings for a character.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Return",
"the",
"standings",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Standings.php#L41-L48 | train |
eveseat/services | src/Repositories/Character/Wallet.php | Wallet.getCharacterWalletTransactions | public function getCharacterWalletTransactions(Collection $character_ids) : Builder
{
return CharacterWalletTransaction::with('client', 'type')
->select(DB::raw('
*, CASE
when character_wallet_transactions.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=character_wallet_transactions.location_id-6000000)
when character_wallet_transactions.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=character_wallet_transactions.location_id-6000001)
when character_wallet_transactions.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=character_wallet_transactions.location_id-6000000)
when character_wallet_transactions.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=character_wallet_transactions.location_id)
when character_wallet_transactions.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=character_wallet_transactions.location_id)
when character_wallet_transactions.location_id BETWEEN 61000000 AND 61001146 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=character_wallet_transactions.location_id)
when character_wallet_transactions.location_id > 61001146 then
(SELECT name FROM `universe_structures` AS c
WHERE c.structure_id = character_wallet_transactions.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=character_wallet_transactions.location_id) end
AS locationName'
))
->whereIn('character_id', $character_ids->toArray());
} | php | public function getCharacterWalletTransactions(Collection $character_ids) : Builder
{
return CharacterWalletTransaction::with('client', 'type')
->select(DB::raw('
*, CASE
when character_wallet_transactions.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=character_wallet_transactions.location_id-6000000)
when character_wallet_transactions.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=character_wallet_transactions.location_id-6000001)
when character_wallet_transactions.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=character_wallet_transactions.location_id-6000000)
when character_wallet_transactions.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=character_wallet_transactions.location_id)
when character_wallet_transactions.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=character_wallet_transactions.location_id)
when character_wallet_transactions.location_id BETWEEN 61000000 AND 61001146 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=character_wallet_transactions.location_id)
when character_wallet_transactions.location_id > 61001146 then
(SELECT name FROM `universe_structures` AS c
WHERE c.structure_id = character_wallet_transactions.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=character_wallet_transactions.location_id) end
AS locationName'
))
->whereIn('character_id', $character_ids->toArray());
} | [
"public",
"function",
"getCharacterWalletTransactions",
"(",
"Collection",
"$",
"character_ids",
")",
":",
"Builder",
"{",
"return",
"CharacterWalletTransaction",
"::",
"with",
"(",
"'client'",
",",
"'type'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'\... | Retrieve Wallet Transaction Entries for a Character.
@param \Illuminate\Support\Collection $character_ids
@return \Illuminate\Database\Eloquent\Builder | [
"Retrieve",
"Wallet",
"Transaction",
"Entries",
"for",
"a",
"Character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Wallet.php#L59-L95 | train |
eveseat/services | src/Repositories/Character/Mail.php | Mail.getAllCharacterNewestMail | public function getAllCharacterNewestMail(int $limit = 10): Collection
{
$user = auth()->user();
$messages = MailHeader::select('mail_id', 'from', 'character_id', 'subject');
// If the user is a super user, return all
if (! $user->hasSuperUser()) {
$messages = $messages->where(function ($query) use ($user) {
$characters = [];
// get all user characters affiliation, including those whose are owned by himself
foreach ($user->getAffiliationMap()['char'] as $characterID => $permissions) {
// check for both character wildcard and character mail permission in order to grant the access
if (in_array('character.*', $permissions, true) ||
in_array('character.mail', $permissions, true)
)
$characters[] = $characterID;
}
// Add the collected characterID on previous task to mail records filter
$query->whereIn('character_id', $characters)
->orWhereIn('from', $characters);
});
}
return $messages->orderBy('timestamp', 'desc')
->limit($limit)
->get();
} | php | public function getAllCharacterNewestMail(int $limit = 10): Collection
{
$user = auth()->user();
$messages = MailHeader::select('mail_id', 'from', 'character_id', 'subject');
// If the user is a super user, return all
if (! $user->hasSuperUser()) {
$messages = $messages->where(function ($query) use ($user) {
$characters = [];
// get all user characters affiliation, including those whose are owned by himself
foreach ($user->getAffiliationMap()['char'] as $characterID => $permissions) {
// check for both character wildcard and character mail permission in order to grant the access
if (in_array('character.*', $permissions, true) ||
in_array('character.mail', $permissions, true)
)
$characters[] = $characterID;
}
// Add the collected characterID on previous task to mail records filter
$query->whereIn('character_id', $characters)
->orWhereIn('from', $characters);
});
}
return $messages->orderBy('timestamp', 'desc')
->limit($limit)
->get();
} | [
"public",
"function",
"getAllCharacterNewestMail",
"(",
"int",
"$",
"limit",
"=",
"10",
")",
":",
"Collection",
"{",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"messages",
"=",
"MailHeader",
"::",
"select",
"(",
"'mail_id'",
... | Return only the last X amount of mail for affiliation
related characters.
@param int $limit
@return \Illuminate\Support\Collection | [
"Return",
"only",
"the",
"last",
"X",
"amount",
"of",
"mail",
"for",
"affiliation",
"related",
"characters",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Mail.php#L42-L76 | train |
eveseat/services | src/Repositories/Character/Mail.php | Mail.getCharacterMailMessage | public function getCharacterMailMessage(int $character_id, int $message_id): MailHeader
{
return MailHeader::where('character_id', $character_id)
->where('mail_id', $message_id)
->orderBy('timestamp', 'desc')
->first();
} | php | public function getCharacterMailMessage(int $character_id, int $message_id): MailHeader
{
return MailHeader::where('character_id', $character_id)
->where('mail_id', $message_id)
->orderBy('timestamp', 'desc')
->first();
} | [
"public",
"function",
"getCharacterMailMessage",
"(",
"int",
"$",
"character_id",
",",
"int",
"$",
"message_id",
")",
":",
"MailHeader",
"{",
"return",
"MailHeader",
"::",
"where",
"(",
"'character_id'",
",",
"$",
"character_id",
")",
"->",
"where",
"(",
"'mai... | Retrieve a specific message for a character.
@param int $character_id
@param int $message_id
@return \Seat\Eveapi\Models\Mail\MailHeader | [
"Retrieve",
"a",
"specific",
"message",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Mail.php#L102-L109 | train |
eveseat/services | src/Repositories/Character/Mail.php | Mail.getCharacterMailTimeline | public function getCharacterMailTimeline(int $message_id = null)
{
// Get the User for permissions and affiliation
// checks
$user = auth()->user();
$messages = MailHeader::with('recipients', 'body');
// If a user is not a super user, only return their own mail and those
// which they are affiliated to to receive.
if (! $user->hasSuperUser()) {
$messages = $messages->where(function ($query) use ($user) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.mail', false))
$query = $query->whereIn('character_id', array_keys($user->getAffiliationMap()['char']));
// Add mail owned by *this* character
$query->orWhere('character_id', $user->id);
});
}
// Filter by messageID if its set
if (! is_null($message_id))
return $messages->where('mail_id', $message_id)
->first();
return $messages->orderBy('timestamp', 'desc')
->groupBy('mail_id')
->paginate(25);
} | php | public function getCharacterMailTimeline(int $message_id = null)
{
// Get the User for permissions and affiliation
// checks
$user = auth()->user();
$messages = MailHeader::with('recipients', 'body');
// If a user is not a super user, only return their own mail and those
// which they are affiliated to to receive.
if (! $user->hasSuperUser()) {
$messages = $messages->where(function ($query) use ($user) {
// If the user has any affiliations and can
// list those characters, add them
if ($user->has('character.mail', false))
$query = $query->whereIn('character_id', array_keys($user->getAffiliationMap()['char']));
// Add mail owned by *this* character
$query->orWhere('character_id', $user->id);
});
}
// Filter by messageID if its set
if (! is_null($message_id))
return $messages->where('mail_id', $message_id)
->first();
return $messages->orderBy('timestamp', 'desc')
->groupBy('mail_id')
->paginate(25);
} | [
"public",
"function",
"getCharacterMailTimeline",
"(",
"int",
"$",
"message_id",
"=",
"null",
")",
"{",
"// Get the User for permissions and affiliation",
"// checks",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"messages",
"=",
"MailHe... | Get the mail timeline for all of the characters
a logged in user has access to. Either by owning the
api key with the characters, or having the correct
affiliation & role.
Supplying the $message_id will return only that
mail.
@param int $message_id
@return mixed | [
"Get",
"the",
"mail",
"timeline",
"for",
"all",
"of",
"the",
"characters",
"a",
"logged",
"in",
"user",
"has",
"access",
"to",
".",
"Either",
"by",
"owning",
"the",
"api",
"key",
"with",
"the",
"characters",
"or",
"having",
"the",
"correct",
"affiliation",... | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Mail.php#L124-L156 | train |
eveseat/services | src/Image/Eve.php | Eve.detect_type | public function detect_type($id)
{
if ($id > 90000000 && $id < 98000000)
return 'character';
elseif (($id > 98000000 && $id < 99000000) || ($id > 1000000 && $id < 2000000))
return 'corporation';
elseif (($id > 99000000 && $id < 100000000) || ($id > 0 && $id < 1000000))
return 'alliance';
return 'character';
} | php | public function detect_type($id)
{
if ($id > 90000000 && $id < 98000000)
return 'character';
elseif (($id > 98000000 && $id < 99000000) || ($id > 1000000 && $id < 2000000))
return 'corporation';
elseif (($id > 99000000 && $id < 100000000) || ($id > 0 && $id < 1000000))
return 'alliance';
return 'character';
} | [
"public",
"function",
"detect_type",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
">",
"90000000",
"&&",
"$",
"id",
"<",
"98000000",
")",
"return",
"'character'",
";",
"elseif",
"(",
"(",
"$",
"id",
">",
"98000000",
"&&",
"$",
"id",
"<",
"990000... | Attempt to detect the image type based on the
range in which an integer falls.
@param $id
@return string | [
"Attempt",
"to",
"detect",
"the",
"image",
"type",
"based",
"on",
"the",
"range",
"in",
"which",
"an",
"integer",
"falls",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Image/Eve.php#L131-L144 | train |
eveseat/services | src/Repositories/Character/JumpClone.php | JumpClone.getCharacterJumpClones | public function getCharacterJumpClones(int $character_id): Collection
{
return DB::table(DB::raw(
'character_jump_clones as a'))
->select(DB::raw('
*, CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.location_id)
when a.location_id>=61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=a.location_id) end
AS location,a.location_id AS locID'))
->where('a.character_id', $character_id)
->get();
} | php | public function getCharacterJumpClones(int $character_id): Collection
{
return DB::table(DB::raw(
'character_jump_clones as a'))
->select(DB::raw('
*, CASE
when a.location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.location_id-6000000)
when a.location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.location_id-6000001)
when a.location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=a.location_id-6000000)
when a.location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=a.location_id)
when a.location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID=a.location_id)
when a.location_id>=61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id=a.location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID=a.location_id) end
AS location,a.location_id AS locID'))
->where('a.character_id', $character_id)
->get();
} | [
"public",
"function",
"getCharacterJumpClones",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"DB",
"::",
"table",
"(",
"DB",
"::",
"raw",
"(",
"'character_jump_clones as a'",
")",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
... | Get jump clones and jump clone locations for a
character.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Get",
"jump",
"clones",
"and",
"jump",
"clone",
"locations",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/JumpClone.php#L42-L75 | train |
eveseat/services | src/Repositories/Corporation/Starbases.php | Starbases.getCorporationStarbases | public function getCorporationStarbases(int $corporation_id, int $starbase_id = null)
{
return CorporationStarbase::where('corporation_id', $corporation_id)->get();
} | php | public function getCorporationStarbases(int $corporation_id, int $starbase_id = null)
{
return CorporationStarbase::where('corporation_id', $corporation_id)->get();
} | [
"public",
"function",
"getCorporationStarbases",
"(",
"int",
"$",
"corporation_id",
",",
"int",
"$",
"starbase_id",
"=",
"null",
")",
"{",
"return",
"CorporationStarbase",
"::",
"where",
"(",
"'corporation_id'",
",",
"$",
"corporation_id",
")",
"->",
"get",
"(",... | Return a list of starbases for a Corporation. If
a starbaseID is provided, then only data for that
starbase is returned.
@param int $corporation_id
@param int $starbase_id
@return Collection | [
"Return",
"a",
"list",
"of",
"starbases",
"for",
"a",
"Corporation",
".",
"If",
"a",
"starbaseID",
"is",
"provided",
"then",
"only",
"data",
"for",
"that",
"starbase",
"is",
"returned",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Starbases.php#L45-L49 | train |
eveseat/services | src/Repositories/Character/Contracts.php | Contracts.getCharacterContracts | public function getCharacterContracts(Collection $character_ids) : Builder
{
return DB::table(DB::raw('contract_details as a'))
->select(DB::raw(
'
--
-- All Columns
--
*,
--
-- Start Location Lookup
--
CASE
when a.start_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000000)
when a.start_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000001)
when a.start_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id-6000000)
when a.start_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
when a.start_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id)
when a.start_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.start_location_id) end
AS startlocation,
--
-- End Location Lookup
--
CASE
when a.end_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000000)
when a.end_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000001)
when a.end_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id-6000000)
when a.end_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
when a.end_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id)
when a.end_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.end_location_id) end
AS endlocation '))
->join('character_contracts', 'character_contracts.contract_id', '=', 'a.contract_id')
->whereIn('character_contracts.character_id', $character_ids->toArray());
} | php | public function getCharacterContracts(Collection $character_ids) : Builder
{
return DB::table(DB::raw('contract_details as a'))
->select(DB::raw(
'
--
-- All Columns
--
*,
--
-- Start Location Lookup
--
CASE
when a.start_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000000)
when a.start_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id-6000001)
when a.start_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id-6000000)
when a.start_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
when a.start_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.start_location_id)
when a.start_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.start_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.start_location_id) end
AS startlocation,
--
-- End Location Lookup
--
CASE
when a.end_location_id BETWEEN 66015148 AND 66015151 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000000)
when a.end_location_id BETWEEN 66000000 AND 66014933 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id-6000001)
when a.end_location_id BETWEEN 66014934 AND 67999999 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id-6000000)
when a.end_location_id BETWEEN 60014861 AND 60014928 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
when a.end_location_id BETWEEN 60000000 AND 61000000 then
(SELECT s.stationName FROM staStations AS s
WHERE s.stationID = a.end_location_id)
when a.end_location_id >= 61000000 then
(SELECT d.name FROM `sovereignty_structures` AS c
JOIN universe_stations d ON c.structure_id = d.station_id
WHERE c.structure_id = a.end_location_id)
else (SELECT m.itemName FROM mapDenormalize AS m
WHERE m.itemID = a.end_location_id) end
AS endlocation '))
->join('character_contracts', 'character_contracts.contract_id', '=', 'a.contract_id')
->whereIn('character_contracts.character_id', $character_ids->toArray());
} | [
"public",
"function",
"getCharacterContracts",
"(",
"Collection",
"$",
"character_ids",
")",
":",
"Builder",
"{",
"return",
"DB",
"::",
"table",
"(",
"DB",
"::",
"raw",
"(",
"'contract_details as a'",
")",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
... | Return Contract Information for a character.
@param \Illuminate\Support\Collection $character_ids
@return \Illuminate\Database\Query\Builder | [
"Return",
"Contract",
"Information",
"for",
"a",
"character",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Contracts.php#L43-L114 | train |
eveseat/services | src/Repositories/Character/Research.php | Research.getCharacterResearchAgents | public function getCharacterResearchAgents(int $character_id): Collection
{
return CharacterAgentResearch::join(
'invNames',
'character_agent_researches.agent_id', '=',
'invNames.itemID')
->join(
'invTypes',
'character_agent_researches.skill_type_id', '=',
'invTypes.typeID')
->where('character_id', $character_id)
->get();
} | php | public function getCharacterResearchAgents(int $character_id): Collection
{
return CharacterAgentResearch::join(
'invNames',
'character_agent_researches.agent_id', '=',
'invNames.itemID')
->join(
'invTypes',
'character_agent_researches.skill_type_id', '=',
'invTypes.typeID')
->where('character_id', $character_id)
->get();
} | [
"public",
"function",
"getCharacterResearchAgents",
"(",
"int",
"$",
"character_id",
")",
":",
"Collection",
"{",
"return",
"CharacterAgentResearch",
"::",
"join",
"(",
"'invNames'",
",",
"'character_agent_researches.agent_id'",
",",
"'='",
",",
"'invNames.itemID'",
")"... | Return a characters research info.
@param int $character_id
@return \Illuminate\Support\Collection | [
"Return",
"a",
"characters",
"research",
"info",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Research.php#L41-L54 | train |
eveseat/services | src/Repositories/Configuration/UserRespository.php | UserRespository.getUserGroupCharacters | public function getUserGroupCharacters(Group $group = null): Collection
{
if (! $group)
return collect();
return Group::with('users')->find($group->id)->users;
} | php | public function getUserGroupCharacters(Group $group = null): Collection
{
if (! $group)
return collect();
return Group::with('users')->find($group->id)->users;
} | [
"public",
"function",
"getUserGroupCharacters",
"(",
"Group",
"$",
"group",
"=",
"null",
")",
":",
"Collection",
"{",
"if",
"(",
"!",
"$",
"group",
")",
"return",
"collect",
"(",
")",
";",
"return",
"Group",
"::",
"with",
"(",
"'users'",
")",
"->",
"fi... | Return the characters that are part of a group.
@param \Seat\Web\Models\Group $group
@return \Illuminate\Support\Collection | [
"Return",
"the",
"characters",
"that",
"are",
"part",
"of",
"a",
"group",
"."
] | 89562547b16d1a59f49bb0fe12426ce8d6133ee6 | https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Configuration/UserRespository.php#L110-L117 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.