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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
shopgate/cart-integration-magento2-base | src/Helper/Encoder.php | Encoder.decode | public function decode($string)
{
if ($this->isSerialized($string)) {
return $this->unserialize($string);
}
$result = json_decode($string, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException('Unable to unserialize value.');
}
return $result;
} | php | public function decode($string)
{
if ($this->isSerialized($string)) {
return $this->unserialize($string);
}
$result = json_decode($string, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException('Unable to unserialize value.');
}
return $result;
} | [
"public",
"function",
"decode",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSerialized",
"(",
"$",
"string",
")",
")",
"{",
"return",
"$",
"this",
"->",
"unserialize",
"(",
"$",
"string",
")",
";",
"}",
"$",
"result",
"=",
"json_... | Unserialize the given string
@param string $string
@return string|int|float|bool|array|null
@throws \InvalidArgumentException | [
"Unserialize",
"the",
"given",
"string"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Encoder.php#L53-L65 | train |
shopgate/cart-integration-magento2-base | src/Helper/Encoder.php | Encoder.unserialize | private function unserialize($string)
{
if (false === $string || null === $string || '' === $string) {
throw new \InvalidArgumentException('Unable to unserialize value.');
}
set_error_handler(
function () {
restore_error_handler();
throw new \InvalidArgumentException('Unable to unserialize value, string is corrupted.');
},
E_NOTICE
);
$result = unserialize($string);
restore_error_handler();
return $result;
} | php | private function unserialize($string)
{
if (false === $string || null === $string || '' === $string) {
throw new \InvalidArgumentException('Unable to unserialize value.');
}
set_error_handler(
function () {
restore_error_handler();
throw new \InvalidArgumentException('Unable to unserialize value, string is corrupted.');
},
E_NOTICE
);
$result = unserialize($string);
restore_error_handler();
return $result;
} | [
"private",
"function",
"unserialize",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"string",
"||",
"null",
"===",
"$",
"string",
"||",
"''",
"===",
"$",
"string",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unable ... | Uses the old school unserialization
@param string $string
@return array
@throws \InvalidArgumentException | [
"Uses",
"the",
"old",
"school",
"unserialization"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Encoder.php#L87-L103 | train |
camspiers/silverstripe-loggerbridge | src/Camspiers/LoggerBridge/BacktraceReporter/BasicBacktraceReporter.php | BasicBacktraceReporter.getBacktrace | public function getBacktrace($exception = null)
{
$skipLimit = false;
if ($exception instanceof \Exception || $exception instanceof \Throwable) {
$backtrace = $exception->getTrace();
foreach ($backtrace as $index => $backtraceCall) {
unset($backtrace[$index]['args']);
}
} elseif (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->backtraceLimit);
$skipLimit = true;
} else {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
if ($this->backtraceLimit > 0 && !$skipLimit) {
$backtrace = array_slice($backtrace, 0, $this->backtraceLimit);
}
return $backtrace;
} | php | public function getBacktrace($exception = null)
{
$skipLimit = false;
if ($exception instanceof \Exception || $exception instanceof \Throwable) {
$backtrace = $exception->getTrace();
foreach ($backtrace as $index => $backtraceCall) {
unset($backtrace[$index]['args']);
}
} elseif (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->backtraceLimit);
$skipLimit = true;
} else {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
if ($this->backtraceLimit > 0 && !$skipLimit) {
$backtrace = array_slice($backtrace, 0, $this->backtraceLimit);
}
return $backtrace;
} | [
"public",
"function",
"getBacktrace",
"(",
"$",
"exception",
"=",
"null",
")",
"{",
"$",
"skipLimit",
"=",
"false",
";",
"if",
"(",
"$",
"exception",
"instanceof",
"\\",
"Exception",
"||",
"$",
"exception",
"instanceof",
"\\",
"Throwable",
")",
"{",
"$",
... | Returns a basic backtrace
@param mixed $exception
@return array | [
"Returns",
"a",
"basic",
"backtrace"
] | 16891556ff2e9eb7c2f94e42106044fb28bde33d | https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/BacktraceReporter/BasicBacktraceReporter.php#L39-L60 | train |
CarbonPackages/Carbon.Eel | Classes/ArrayHelper.php | ArrayHelper.BEM | public function BEM($block = null, $element = null, $modifiers = []): array
{
if (!isset($block) || !is_string($block) || !$block) {
return [];
}
$baseClass = $element ? "{$block}__{$element}" : "{$block}";
$classes = [$baseClass];
if (isset($modifiers)) {
$modifiers = self::modifierArray($modifiers);
foreach ($modifiers as $value) {
$classes[] = "{$baseClass}--{$value}";
}
}
return $classes;
} | php | public function BEM($block = null, $element = null, $modifiers = []): array
{
if (!isset($block) || !is_string($block) || !$block) {
return [];
}
$baseClass = $element ? "{$block}__{$element}" : "{$block}";
$classes = [$baseClass];
if (isset($modifiers)) {
$modifiers = self::modifierArray($modifiers);
foreach ($modifiers as $value) {
$classes[] = "{$baseClass}--{$value}";
}
}
return $classes;
} | [
"public",
"function",
"BEM",
"(",
"$",
"block",
"=",
"null",
",",
"$",
"element",
"=",
"null",
",",
"$",
"modifiers",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"block",
")",
"||",
"!",
"is_string",
"(",
"$",
"blo... | Generates a BEM array
@param string $block defaults to null
@param string $element defaults to null
@param string|array $modifiers defaults to []
@return array | [
"Generates",
"a",
"BEM",
"array"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/ArrayHelper.php#L28-L44 | train |
CarbonPackages/Carbon.Eel | Classes/ArrayHelper.php | ArrayHelper.modifierArray | private static function modifierArray($modifiers = []): array {
if (is_string($modifiers)) {
return [$modifiers];
}
$array = [];
if (is_array($modifiers)) {
foreach ($modifiers as $key => $value) {
if (!$value) {
continue;
}
if (is_array($value)) {
$array = array_merge($array, self::modifierArray($value));
} else if (is_string($value)) {
$array[] = $value;
} else if (is_string($key)) {
$array[] = $key;
}
}
}
return array_unique($array);
} | php | private static function modifierArray($modifiers = []): array {
if (is_string($modifiers)) {
return [$modifiers];
}
$array = [];
if (is_array($modifiers)) {
foreach ($modifiers as $key => $value) {
if (!$value) {
continue;
}
if (is_array($value)) {
$array = array_merge($array, self::modifierArray($value));
} else if (is_string($value)) {
$array[] = $value;
} else if (is_string($key)) {
$array[] = $key;
}
}
}
return array_unique($array);
} | [
"private",
"static",
"function",
"modifierArray",
"(",
"$",
"modifiers",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"is_string",
"(",
"$",
"modifiers",
")",
")",
"{",
"return",
"[",
"$",
"modifiers",
"]",
";",
"}",
"$",
"array",
"=",
"[",
"]... | Generate the array for the modifiers
@param string|array $modifiers
@return array | [
"Generate",
"the",
"array",
"for",
"the",
"modifiers"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/ArrayHelper.php#L53-L73 | train |
CarbonPackages/Carbon.Eel | Classes/ArrayHelper.php | ArrayHelper.join | public function join(array $array, string $separator = ','): string
{
$result = '';
foreach ($array as $item) {
if (is_array($item)) {
$result .= $this->join($item, $separator) . $separator;
} else {
$result .= $item . $separator;
}
}
$result = substr($result, 0, 0 - strlen($separator));
return $result;
} | php | public function join(array $array, string $separator = ','): string
{
$result = '';
foreach ($array as $item) {
if (is_array($item)) {
$result .= $this->join($item, $separator) . $separator;
} else {
$result .= $item . $separator;
}
}
$result = substr($result, 0, 0 - strlen($separator));
return $result;
} | [
"public",
"function",
"join",
"(",
"array",
"$",
"array",
",",
"string",
"$",
"separator",
"=",
"','",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
... | Join the given array recursively
using the given separator string.
@param array $array The array
@param string $separator The speparator, defaults to ','
@return string The joined string | [
"Join",
"the",
"given",
"array",
"recursively",
"using",
"the",
"given",
"separator",
"string",
"."
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/ArrayHelper.php#L136-L151 | train |
CarbonPackages/Carbon.Eel | Classes/ArrayHelper.php | ArrayHelper.extractSubElements | public function extractSubElements(
array $array,
bool $preserveKeys = false
): array {
$resultArray = [];
foreach ($array as $element) {
if (is_array($element)) {
foreach ($element as $subKey => $subElement) {
if ($preserveKeys) {
$resultArray[$subKey] = $subElement;
} else {
$resultArray[] = $subElement;
}
}
} else {
$resultArray[] = $element;
}
}
return $resultArray;
} | php | public function extractSubElements(
array $array,
bool $preserveKeys = false
): array {
$resultArray = [];
foreach ($array as $element) {
if (is_array($element)) {
foreach ($element as $subKey => $subElement) {
if ($preserveKeys) {
$resultArray[$subKey] = $subElement;
} else {
$resultArray[] = $subElement;
}
}
} else {
$resultArray[] = $element;
}
}
return $resultArray;
} | [
"public",
"function",
"extractSubElements",
"(",
"array",
"$",
"array",
",",
"bool",
"$",
"preserveKeys",
"=",
"false",
")",
":",
"array",
"{",
"$",
"resultArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"element",
")",
"{",
"if",
... | This method extracts sub elements to the parent level.
An input array of type:
[
element1 => [
0 => 'value1'
],
element2 => [
0 => 'value2'
1 => 'value3'
],
will be converted to:
[
0 => 'value1'
1 => 'value2'
2 => 'value3'
]
@param array $array The array
@param bool $preserveKeys Should the key be preserved, defaults to `false`
@return array | [
"This",
"method",
"extracts",
"sub",
"elements",
"to",
"the",
"parent",
"level",
"."
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/ArrayHelper.php#L178-L199 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.outputStyles | public static function outputStyles($output = '')
{
self::lookIfProcessFiles('style', 'header');
$template = self::$templates['style'];
$styles = self::$data['style']['header'];
foreach ($styles as $value) {
$output .= sprintf(
$template,
$value['url']
);
}
self::$data['style']['header'] = [];
return ! empty($output) ? $output : false;
} | php | public static function outputStyles($output = '')
{
self::lookIfProcessFiles('style', 'header');
$template = self::$templates['style'];
$styles = self::$data['style']['header'];
foreach ($styles as $value) {
$output .= sprintf(
$template,
$value['url']
);
}
self::$data['style']['header'] = [];
return ! empty($output) ? $output : false;
} | [
"public",
"static",
"function",
"outputStyles",
"(",
"$",
"output",
"=",
"''",
")",
"{",
"self",
"::",
"lookIfProcessFiles",
"(",
"'style'",
",",
"'header'",
")",
";",
"$",
"template",
"=",
"self",
"::",
"$",
"templates",
"[",
"'style'",
"]",
";",
"$",
... | Output stylesheet.
@since 1.1.5
@param string $output → output for styles
@return string|false → output or false | [
"Output",
"stylesheet",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L115-L132 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.isAdded | public static function isAdded($type, $name)
{
if (isset(self::$data[$type]['header'][$name])) {
return true;
} elseif (isset(self::$data[$type]['footer'][$name])) {
return true;
}
return false;
} | php | public static function isAdded($type, $name)
{
if (isset(self::$data[$type]['header'][$name])) {
return true;
} elseif (isset(self::$data[$type]['footer'][$name])) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"isAdded",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"type",
"]",
"[",
"'header'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";... | Check if a particular style or script has been added.
@since 1.1.5
@param string $type → script|style
@param string $name → script or style name
@return bool | [
"Check",
"if",
"a",
"particular",
"style",
"or",
"script",
"has",
"been",
"added",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L174-L183 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.unify | public static function unify($uniqueID, $params, $minify = false)
{
self::$id = $uniqueID;
self::$unify = $params;
self::$minify = $minify;
return true;
} | php | public static function unify($uniqueID, $params, $minify = false)
{
self::$id = $uniqueID;
self::$unify = $params;
self::$minify = $minify;
return true;
} | [
"public",
"static",
"function",
"unify",
"(",
"$",
"uniqueID",
",",
"$",
"params",
",",
"$",
"minify",
"=",
"false",
")",
"{",
"self",
"::",
"$",
"id",
"=",
"$",
"uniqueID",
";",
"self",
"::",
"$",
"unify",
"=",
"$",
"params",
";",
"self",
"::",
... | Sets whether to merge the content of files into a single file.
@since 1.1.5
@param string $uniqueID → unique identifier for unified file
@param mixed $params → path urls
@param bool $minify → minimize file content
@return bool true | [
"Sets",
"whether",
"to",
"merge",
"the",
"content",
"of",
"files",
"into",
"a",
"single",
"file",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L196-L203 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.remove | public static function remove($type, $name)
{
if (isset(self::$data[$type]['header'][$name])) {
unset(self::$data[$type]['header'][$name]);
return true;
} elseif (isset(self::$data[$type]['footer'][$name])) {
unset(self::$data[$type]['footer'][$name]);
return true;
}
return false;
} | php | public static function remove($type, $name)
{
if (isset(self::$data[$type]['header'][$name])) {
unset(self::$data[$type]['header'][$name]);
return true;
} elseif (isset(self::$data[$type]['footer'][$name])) {
unset(self::$data[$type]['footer'][$name]);
return true;
}
return false;
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"type",
"]",
"[",
"'header'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"self",... | Remove before script or style have been registered.
@since 1.0.1
@param string $type → script|style
@param string $name → script or style name
@return bool true | [
"Remove",
"before",
"script",
"or",
"style",
"have",
"been",
"registered",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L215-L228 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.lookIfProcessFiles | protected static function lookIfProcessFiles($type, $place)
{
if (is_string(self::$unify) || isset(self::$unify[$type . 's'])) {
return self::unifyFiles(
self::prepareFiles($type, $place)
);
}
} | php | protected static function lookIfProcessFiles($type, $place)
{
if (is_string(self::$unify) || isset(self::$unify[$type . 's'])) {
return self::unifyFiles(
self::prepareFiles($type, $place)
);
}
} | [
"protected",
"static",
"function",
"lookIfProcessFiles",
"(",
"$",
"type",
",",
"$",
"place",
")",
"{",
"if",
"(",
"is_string",
"(",
"self",
"::",
"$",
"unify",
")",
"||",
"isset",
"(",
"self",
"::",
"$",
"unify",
"[",
"$",
"type",
".",
"'s'",
"]",
... | Look whether to process files to minify or unify files.
@since 1.1.5
@param string $type → script|style
@param string $place → header|footer
@return bool true | [
"Look",
"whether",
"to",
"process",
"files",
"to",
"minify",
"or",
"unify",
"files",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L271-L278 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.prepareFiles | protected static function prepareFiles($type, $place)
{
self::getProcessedFiles();
$params['type'] = $type;
$params['place'] = $place;
$params['routes'] = self::getRoutesToFolder($type);
foreach (self::$data[$type][$place] as $id => $file) {
$path = self::getPathFromUrl($file['url']);
$params['urls'][$id] = $file['url'];
$params['files'][$id] = basename($file['url']);
$params['paths'][$id] = $path;
if (is_file($path) && self::isModifiedFile($path)) {
unset($params['urls'][$id]);
continue;
}
$path = $params['routes']['path'] . $params['files'][$id];
if (is_file($path)) {
if (self::isModifiedHash($file['url'], $path)) {
continue;
}
$params['paths'][$id] = $path;
} elseif (self::isExternalUrl($file['url'])) {
continue;
}
unset($params['urls'][$id]);
}
return $params;
} | php | protected static function prepareFiles($type, $place)
{
self::getProcessedFiles();
$params['type'] = $type;
$params['place'] = $place;
$params['routes'] = self::getRoutesToFolder($type);
foreach (self::$data[$type][$place] as $id => $file) {
$path = self::getPathFromUrl($file['url']);
$params['urls'][$id] = $file['url'];
$params['files'][$id] = basename($file['url']);
$params['paths'][$id] = $path;
if (is_file($path) && self::isModifiedFile($path)) {
unset($params['urls'][$id]);
continue;
}
$path = $params['routes']['path'] . $params['files'][$id];
if (is_file($path)) {
if (self::isModifiedHash($file['url'], $path)) {
continue;
}
$params['paths'][$id] = $path;
} elseif (self::isExternalUrl($file['url'])) {
continue;
}
unset($params['urls'][$id]);
}
return $params;
} | [
"protected",
"static",
"function",
"prepareFiles",
"(",
"$",
"type",
",",
"$",
"place",
")",
"{",
"self",
"::",
"getProcessedFiles",
"(",
")",
";",
"$",
"params",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"params",
"[",
"'place'",
"]",
"=",
"$"... | Check files and prepare paths and urls.
@since 1.1.5
@param string $type → script|style
@param string $place → header|footer
@return array|false → paths, urls and outdated files | [
"Check",
"files",
"and",
"prepare",
"paths",
"and",
"urls",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L290-L325 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.getRoutesToFolder | protected static function getRoutesToFolder($type)
{
$type = $type . 's';
$url = isset(self::$unify[$type]) ? self::$unify[$type] : self::$unify;
return ['url' => $url, 'path' => self::getPathFromUrl($url)];
} | php | protected static function getRoutesToFolder($type)
{
$type = $type . 's';
$url = isset(self::$unify[$type]) ? self::$unify[$type] : self::$unify;
return ['url' => $url, 'path' => self::getPathFromUrl($url)];
} | [
"protected",
"static",
"function",
"getRoutesToFolder",
"(",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"type",
".",
"'s'",
";",
"$",
"url",
"=",
"isset",
"(",
"self",
"::",
"$",
"unify",
"[",
"$",
"type",
"]",
")",
"?",
"self",
"::",
"$",
"un... | Get path|url to the minimized file.
@since 1.1.5
@param string $type → scripts|styles
@return array → url|path to minimized file | [
"Get",
"path|url",
"to",
"the",
"minimized",
"file",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L336-L343 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.isModifiedHash | protected static function isModifiedHash($url, $path)
{
if (self::isExternalUrl($url)) {
if (sha1_file($url) !== sha1_file($path)) {
return self::$changes = true;
}
}
return false;
} | php | protected static function isModifiedHash($url, $path)
{
if (self::isExternalUrl($url)) {
if (sha1_file($url) !== sha1_file($path)) {
return self::$changes = true;
}
}
return false;
} | [
"protected",
"static",
"function",
"isModifiedHash",
"(",
"$",
"url",
",",
"$",
"path",
")",
"{",
"if",
"(",
"self",
"::",
"isExternalUrl",
"(",
"$",
"url",
")",
")",
"{",
"if",
"(",
"sha1_file",
"(",
"$",
"url",
")",
"!==",
"sha1_file",
"(",
"$",
... | Check if it matches the file hash.
@since 1.1.5
@param string $url → external url
@param string $path → internal file path
@return bool | [
"Check",
"if",
"it",
"matches",
"the",
"file",
"hash",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L402-L411 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.unifyFiles | protected static function unifyFiles($params, $data = '')
{
$type = $params['type'];
$place = $params['place'];
$routes = $params['routes'];
$ext = ($type == 'style') ? '.css' : '.js';
$hash = sha1(implode('', $params['files']));
$minFile = $routes['path'] . $hash . $ext;
if (! is_file($minFile) || self::$changes == true) {
foreach ($params['paths'] as $id => $path) {
if (isset($params['urls'][$id])) {
$url = $params['urls'][$id];
$path = $routes['path'] . $params['files'][$id];
$data .= self::saveExternalFile($url, $path);
}
$data .= file_get_contents($path);
}
$data = (self::$minify) ? self::compressFiles($data) : $data;
self::saveFile($minFile, $data);
}
self::setProcessedFiles();
return self::setNewParams($type, $place, $hash, $routes['url'], $ext);
} | php | protected static function unifyFiles($params, $data = '')
{
$type = $params['type'];
$place = $params['place'];
$routes = $params['routes'];
$ext = ($type == 'style') ? '.css' : '.js';
$hash = sha1(implode('', $params['files']));
$minFile = $routes['path'] . $hash . $ext;
if (! is_file($minFile) || self::$changes == true) {
foreach ($params['paths'] as $id => $path) {
if (isset($params['urls'][$id])) {
$url = $params['urls'][$id];
$path = $routes['path'] . $params['files'][$id];
$data .= self::saveExternalFile($url, $path);
}
$data .= file_get_contents($path);
}
$data = (self::$minify) ? self::compressFiles($data) : $data;
self::saveFile($minFile, $data);
}
self::setProcessedFiles();
return self::setNewParams($type, $place, $hash, $routes['url'], $ext);
} | [
"protected",
"static",
"function",
"unifyFiles",
"(",
"$",
"params",
",",
"$",
"data",
"=",
"''",
")",
"{",
"$",
"type",
"=",
"$",
"params",
"[",
"'type'",
"]",
";",
"$",
"place",
"=",
"$",
"params",
"[",
"'place'",
"]",
";",
"$",
"routes",
"=",
... | Unify files.
@since 1.1.5
@param array $params → paths and urls of files to unify
@param string $data → initial string
@return bool true | [
"Unify",
"files",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L437-L463 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.saveExternalFile | protected static function saveExternalFile($url, $path)
{
if ($data = file_get_contents($url)) {
return (self::saveFile($path, $data)) ? $data : '';
}
return '';
} | php | protected static function saveExternalFile($url, $path)
{
if ($data = file_get_contents($url)) {
return (self::saveFile($path, $data)) ? $data : '';
}
return '';
} | [
"protected",
"static",
"function",
"saveExternalFile",
"(",
"$",
"url",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"url",
")",
")",
"{",
"return",
"(",
"self",
"::",
"saveFile",
"(",
"$",
"path",
",",
"$",... | Save external file.
@since 1.1.5
@param string $url → external url
@param string $path → internal file path
@return string → file content or empty | [
"Save",
"external",
"file",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L475-L482 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.compressFiles | protected static function compressFiles($content)
{
$var = ["\r\n", "\r", "\n", "\t", ' ', ' ', ' '];
$content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content);
$content = str_replace($var, '', $content);
$content = str_replace('{ ', '{', $content);
$content = str_replace(' }', '}', $content);
$content = str_replace('; ', ';', $content);
return $content;
} | php | protected static function compressFiles($content)
{
$var = ["\r\n", "\r", "\n", "\t", ' ', ' ', ' '];
$content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content);
$content = str_replace($var, '', $content);
$content = str_replace('{ ', '{', $content);
$content = str_replace(' }', '}', $content);
$content = str_replace('; ', ';', $content);
return $content;
} | [
"protected",
"static",
"function",
"compressFiles",
"(",
"$",
"content",
")",
"{",
"$",
"var",
"=",
"[",
"\"\\r\\n\"",
",",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
",",
"' '",
",",
"' '",
",",
"' '",
"]",
";",
"$",
"content",
"=",
"preg_replace... | File minifier.
@since 1.1.5
@author powerbuoy (https://github.com/powerbuoy)
@param string $content → file content
@return array → unified parameters | [
"File",
"minifier",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L495-L507 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.setNewParams | protected static function setNewParams($type, $place, $hash, $url, $ext)
{
$data = [
'name' => self::$id,
'url' => $url . $hash . $ext,
'attr' => self::unifyParams($type, 'attr'),
'version' => self::unifyParams($type, 'version', '1.0.0'),
];
if ($type === 'script') {
$data['footer'] = self::unifyParams($type, 'footer', false);
}
self::$data[$type][$place] = [$data['name'] => $data];
return true;
} | php | protected static function setNewParams($type, $place, $hash, $url, $ext)
{
$data = [
'name' => self::$id,
'url' => $url . $hash . $ext,
'attr' => self::unifyParams($type, 'attr'),
'version' => self::unifyParams($type, 'version', '1.0.0'),
];
if ($type === 'script') {
$data['footer'] = self::unifyParams($type, 'footer', false);
}
self::$data[$type][$place] = [$data['name'] => $data];
return true;
} | [
"protected",
"static",
"function",
"setNewParams",
"(",
"$",
"type",
",",
"$",
"place",
",",
"$",
"hash",
",",
"$",
"url",
",",
"$",
"ext",
")",
"{",
"$",
"data",
"=",
"[",
"'name'",
"=>",
"self",
"::",
"$",
"id",
",",
"'url'",
"=>",
"$",
"url",
... | Set new parameters for the unified file.
@since 1.1.5
@param string $type → script|style
@param string $place → header|footer
@param string $hash → filename hash
@param string $url → path url
@param string $extension → file extension
@return bool true | [
"Set",
"new",
"parameters",
"for",
"the",
"unified",
"file",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L571-L587 | train |
Josantonius/PHP-Asset | src/Asset.php | Asset.unifyParams | protected static function unifyParams($type, $field, $default = '')
{
$data = array_column(self::$data[$type], $field);
switch ($field) {
case 'attr':
case 'footer':
case 'version':
foreach ($data as $value) {
if ($data[0] !== $value) {
return $default;
}
}
return (isset($data[0]) && $data[0]) ? $data[0] : $default;
default:
$params = [];
foreach ($data as $value) {
$params = array_merge($params, $value);
}
return array_unique($params);
}
} | php | protected static function unifyParams($type, $field, $default = '')
{
$data = array_column(self::$data[$type], $field);
switch ($field) {
case 'attr':
case 'footer':
case 'version':
foreach ($data as $value) {
if ($data[0] !== $value) {
return $default;
}
}
return (isset($data[0]) && $data[0]) ? $data[0] : $default;
default:
$params = [];
foreach ($data as $value) {
$params = array_merge($params, $value);
}
return array_unique($params);
}
} | [
"protected",
"static",
"function",
"unifyParams",
"(",
"$",
"type",
",",
"$",
"field",
",",
"$",
"default",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"array_column",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"type",
"]",
",",
"$",
"field",
")",
";",
... | Obtain all the parameters of a particular field and unify them.
@since 1.1.5
@param string $type → script|style
@param string $field → field to unify
@param string $default → default param
@return array → unified parameters | [
"Obtain",
"all",
"the",
"parameters",
"of",
"a",
"particular",
"field",
"and",
"unify",
"them",
"."
] | ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb | https://github.com/Josantonius/PHP-Asset/blob/ff553c6c4eb948fc117d86c12a2f23c08dd7c6bb/src/Asset.php#L600-L623 | train |
shopgate/cart-integration-magento2-base | src/Model/Service/Config/SgCore.php | SgCore.retrievePathScope | private function retrievePathScope($path, $shopNumber)
{
$shopConfigs = $this->getShopNumberCollection($shopNumber);
if (!$shopConfigs->getSize()) {
throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_UNKNOWN_SHOP_NUMBER, false, true);
}
$firstItem = $shopConfigs->getFirstItem();
/**
* todo-sg: should be improved to use a single query, e.g. (scope = x AND scope_id = x) OR (scope = ...)
*
* @var Value $shopConfig
*/
foreach ($shopConfigs as $shopConfig) {
/** @var Collection $collection */
$collection = $this
->getCollectionByPath($path)
->addFieldToFilter('scope', $shopConfig->getScope())
->addFieldToFilter('scope_id', $shopConfig->getScopeId());
if ($collection->getItems()) {
/** @var Value $propertyConfig */
$propertyConfig = $collection->setOrder('scope_id')->getFirstItem();
if ($propertyConfig->getData('value')) {
return $propertyConfig;
}
}
}
return $firstItem;
} | php | private function retrievePathScope($path, $shopNumber)
{
$shopConfigs = $this->getShopNumberCollection($shopNumber);
if (!$shopConfigs->getSize()) {
throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_UNKNOWN_SHOP_NUMBER, false, true);
}
$firstItem = $shopConfigs->getFirstItem();
/**
* todo-sg: should be improved to use a single query, e.g. (scope = x AND scope_id = x) OR (scope = ...)
*
* @var Value $shopConfig
*/
foreach ($shopConfigs as $shopConfig) {
/** @var Collection $collection */
$collection = $this
->getCollectionByPath($path)
->addFieldToFilter('scope', $shopConfig->getScope())
->addFieldToFilter('scope_id', $shopConfig->getScopeId());
if ($collection->getItems()) {
/** @var Value $propertyConfig */
$propertyConfig = $collection->setOrder('scope_id')->getFirstItem();
if ($propertyConfig->getData('value')) {
return $propertyConfig;
}
}
}
return $firstItem;
} | [
"private",
"function",
"retrievePathScope",
"(",
"$",
"path",
",",
"$",
"shopNumber",
")",
"{",
"$",
"shopConfigs",
"=",
"$",
"this",
"->",
"getShopNumberCollection",
"(",
"$",
"shopNumber",
")",
";",
"if",
"(",
"!",
"$",
"shopConfigs",
"->",
"getSize",
"(... | Edge case checker, handles scenarios when multiple
scope id's have the same shop number.
Traverses the given collection of shopConfigs
to check whether a value in a given path exists.
If not, returns the first item of the collection.
@param string $path
@param string $shopNumber
@return Value | \Magento\Framework\DataObject
@throws ShopgateLibraryException | [
"Edge",
"case",
"checker",
"handles",
"scenarios",
"when",
"multiple",
"scope",
"id",
"s",
"have",
"the",
"same",
"shop",
"number",
".",
"Traverses",
"the",
"given",
"collection",
"of",
"shopConfigs",
"to",
"check",
"whether",
"a",
"value",
"in",
"a",
"given... | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Service/Config/SgCore.php#L98-L130 | train |
shopsys/migrations | src/Component/Doctrine/Migrations/MigrationsLocator.php | MigrationsLocator.getMigrationsLocations | public function getMigrationsLocations()
{
$migrationsLocations = [];
foreach ($this->kernel->getBundles() as $bundle) {
$migrationsLocation = $this->createMigrationsLocation($bundle);
if ($this->filesystem->exists($migrationsLocation->getDirectory())) {
$migrationsLocations[] = $migrationsLocation;
}
}
return $migrationsLocations;
} | php | public function getMigrationsLocations()
{
$migrationsLocations = [];
foreach ($this->kernel->getBundles() as $bundle) {
$migrationsLocation = $this->createMigrationsLocation($bundle);
if ($this->filesystem->exists($migrationsLocation->getDirectory())) {
$migrationsLocations[] = $migrationsLocation;
}
}
return $migrationsLocations;
} | [
"public",
"function",
"getMigrationsLocations",
"(",
")",
"{",
"$",
"migrationsLocations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"kernel",
"->",
"getBundles",
"(",
")",
"as",
"$",
"bundle",
")",
"{",
"$",
"migrationsLocation",
"=",
"$",
... | Gets possible locations of migration classes to allow multiple sources of migrations.
@return \Shopsys\MigrationBundle\Component\Doctrine\Migrations\MigrationsLocation[] | [
"Gets",
"possible",
"locations",
"of",
"migration",
"classes",
"to",
"allow",
"multiple",
"sources",
"of",
"migrations",
"."
] | 4e28e3f13e53973b1daa600adb01e51cf30ea016 | https://github.com/shopsys/migrations/blob/4e28e3f13e53973b1daa600adb01e51cf30ea016/src/Component/Doctrine/Migrations/MigrationsLocator.php#L50-L61 | train |
shopsys/migrations | src/Component/Doctrine/Migrations/MigrationsLocator.php | MigrationsLocator.createMigrationsLocation | public function createMigrationsLocation(BundleInterface $bundle)
{
return new MigrationsLocation(
$bundle->getPath() . '/' . $this->relativeDirectory,
$bundle->getNamespace() . '\\' . $this->relativeNamespace
);
} | php | public function createMigrationsLocation(BundleInterface $bundle)
{
return new MigrationsLocation(
$bundle->getPath() . '/' . $this->relativeDirectory,
$bundle->getNamespace() . '\\' . $this->relativeNamespace
);
} | [
"public",
"function",
"createMigrationsLocation",
"(",
"BundleInterface",
"$",
"bundle",
")",
"{",
"return",
"new",
"MigrationsLocation",
"(",
"$",
"bundle",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"relativeDirectory",
",",
"$",
"bundle"... | Creates a locations of migration classes for a particular bundle.
@param \Symfony\Component\HttpKernel\Bundle\BundleInterface $bundle
@return \Shopsys\MigrationBundle\Component\Doctrine\Migrations\MigrationsLocation | [
"Creates",
"a",
"locations",
"of",
"migration",
"classes",
"for",
"a",
"particular",
"bundle",
"."
] | 4e28e3f13e53973b1daa600adb01e51cf30ea016 | https://github.com/shopsys/migrations/blob/4e28e3f13e53973b1daa600adb01e51cf30ea016/src/Component/Doctrine/Migrations/MigrationsLocator.php#L69-L75 | train |
shopgate/cart-integration-magento2-base | src/Helper/Quote/Customer.php | Customer.setEntity | public function setEntity(MageQuote $quote)
{
$id = $this->sgBase->getExternalCustomerId();
$email = $this->sgBase->getMail();
try {
$customer = $id ? $this->customerHelper->getById($id) : $this->customerHelper->getByEmail($email);
} catch (NoSuchEntityException $e) {
$customer = new DataObject();
$this->log->debug('Could not load customer by id or mail.');
}
$quote->setCustomerEmail($email)
->setRemoteIp($this->sgBase->getCustomerIp());
if ($this->sgBase->isGuest()) {
$quote->setCustomerIsGuest(true);
} elseif ($customer->getId()) {
$this->session->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId());
$quote->setCustomer($customer)
->setCustomerIsGuest(false);
} else {
throw new \ShopgateLibraryException(
\ShopgateLibraryException::UNKNOWN_ERROR_CODE,
__('Customer with external id "%1" or email "%2" does not exist', $id, $email)->render()
);
}
} | php | public function setEntity(MageQuote $quote)
{
$id = $this->sgBase->getExternalCustomerId();
$email = $this->sgBase->getMail();
try {
$customer = $id ? $this->customerHelper->getById($id) : $this->customerHelper->getByEmail($email);
} catch (NoSuchEntityException $e) {
$customer = new DataObject();
$this->log->debug('Could not load customer by id or mail.');
}
$quote->setCustomerEmail($email)
->setRemoteIp($this->sgBase->getCustomerIp());
if ($this->sgBase->isGuest()) {
$quote->setCustomerIsGuest(true);
} elseif ($customer->getId()) {
$this->session->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId());
$quote->setCustomer($customer)
->setCustomerIsGuest(false);
} else {
throw new \ShopgateLibraryException(
\ShopgateLibraryException::UNKNOWN_ERROR_CODE,
__('Customer with external id "%1" or email "%2" does not exist', $id, $email)->render()
);
}
} | [
"public",
"function",
"setEntity",
"(",
"MageQuote",
"$",
"quote",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"sgBase",
"->",
"getExternalCustomerId",
"(",
")",
";",
"$",
"email",
"=",
"$",
"this",
"->",
"sgBase",
"->",
"getMail",
"(",
")",
";",
"t... | Just sets the customer to quote
@param MageQuote $quote
@throws \ShopgateLibraryException | [
"Just",
"sets",
"the",
"customer",
"to",
"quote"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote/Customer.php#L87-L113 | train |
shopgate/cart-integration-magento2-base | src/Helper/Quote/Customer.php | Customer.setAddress | public function setAddress(MageQuote $quote)
{
$billing = $this->sgBase->getInvoiceAddress();
if (!empty($billing)) {
$data = $this->sgCustomer->createAddressData($this->sgBase, $billing, $quote->getCustomerId());
$quote->getBillingAddress()
->addData($data)
->setCustomerAddressId($billing->getId())
->setCustomerId($this->sgBase->getExternalCustomerId())
->setData('should_ignore_validation', true);
}
$shipping = $this->sgBase->getDeliveryAddress();
if (!empty($shipping)) {
$data = $this->sgCustomer->createAddressData($this->sgBase, $shipping, $quote->getCustomerId());
$quote->getShippingAddress()
->addData($data)
->setCustomerAddressId($shipping->getId())
->setCustomerId($this->sgBase->getExternalCustomerId())
->setData('should_ignore_validation', true);
}
if (!$quote->getShippingAddress()->getCountryId()) {
$defaultCountryItem = $this->sgCoreConfig->getConfigByPath(Custom::XML_PATH_GENERAL_COUNTRY_DEFAULT);
$quote->getShippingAddress()->setCountryId($defaultCountryItem->getValue());
}
} | php | public function setAddress(MageQuote $quote)
{
$billing = $this->sgBase->getInvoiceAddress();
if (!empty($billing)) {
$data = $this->sgCustomer->createAddressData($this->sgBase, $billing, $quote->getCustomerId());
$quote->getBillingAddress()
->addData($data)
->setCustomerAddressId($billing->getId())
->setCustomerId($this->sgBase->getExternalCustomerId())
->setData('should_ignore_validation', true);
}
$shipping = $this->sgBase->getDeliveryAddress();
if (!empty($shipping)) {
$data = $this->sgCustomer->createAddressData($this->sgBase, $shipping, $quote->getCustomerId());
$quote->getShippingAddress()
->addData($data)
->setCustomerAddressId($shipping->getId())
->setCustomerId($this->sgBase->getExternalCustomerId())
->setData('should_ignore_validation', true);
}
if (!$quote->getShippingAddress()->getCountryId()) {
$defaultCountryItem = $this->sgCoreConfig->getConfigByPath(Custom::XML_PATH_GENERAL_COUNTRY_DEFAULT);
$quote->getShippingAddress()->setCountryId($defaultCountryItem->getValue());
}
} | [
"public",
"function",
"setAddress",
"(",
"MageQuote",
"$",
"quote",
")",
"{",
"$",
"billing",
"=",
"$",
"this",
"->",
"sgBase",
"->",
"getInvoiceAddress",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"billing",
")",
")",
"{",
"$",
"data",
"=",
... | Sets Billing and Shipping addresses to quote
@param MageQuote $quote
@throws \Magento\Framework\Exception\LocalizedException | [
"Sets",
"Billing",
"and",
"Shipping",
"addresses",
"to",
"quote"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote/Customer.php#L122-L148 | train |
shopgate/cart-integration-magento2-base | src/Helper/Quote/Customer.php | Customer.resetGuest | public function resetGuest(MageQuote $quote)
{
if ($this->sgBase->isGuest()) {
$quote->getBillingAddress()->isObjectNew(false);
$quote->getShippingAddress()->isObjectNew(false);
}
} | php | public function resetGuest(MageQuote $quote)
{
if ($this->sgBase->isGuest()) {
$quote->getBillingAddress()->isObjectNew(false);
$quote->getShippingAddress()->isObjectNew(false);
}
} | [
"public",
"function",
"resetGuest",
"(",
"MageQuote",
"$",
"quote",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sgBase",
"->",
"isGuest",
"(",
")",
")",
"{",
"$",
"quote",
"->",
"getBillingAddress",
"(",
")",
"->",
"isObjectNew",
"(",
"false",
")",
";",
... | Helps reset the billing & shipping objects for guests
@see https://shopgate.atlassian.net/browse/MAGENTO-429
@param MageQuote $quote | [
"Helps",
"reset",
"the",
"billing",
"&",
"shipping",
"objects",
"for",
"guests"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote/Customer.php#L157-L163 | train |
hypeJunction/hypeApps | classes/hypeJunction/Di/DiContainer.php | DiContainer.setValue | public function setValue($name, $value) {
if (substr($name, -1) === '_') {
throw new InvalidArgumentException('$name cannot end with "_"');
}
$this->remove($name);
$this->{$name} = $value;
return $this;
} | php | public function setValue($name, $value) {
if (substr($name, -1) === '_') {
throw new InvalidArgumentException('$name cannot end with "_"');
}
$this->remove($name);
$this->{$name} = $value;
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"1",
")",
"===",
"'_'",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$name cannot end with \"_\"'",
")",
";"... | Set a value to be returned without modification
@param string $name The name of the value
@param mixed $value The value
@return \Elgg\Di\DiContainer
@throws InvalidArgumentException | [
"Set",
"a",
"value",
"to",
"be",
"returned",
"without",
"modification"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Di/DiContainer.php#L98-L105 | train |
hypeJunction/hypeApps | classes/hypeJunction/Di/DiContainer.php | DiContainer.setClassName | public function setClassName($name, $class_name, $shared = true) {
if (substr($name, -1) === '_') {
throw new InvalidArgumentException('$name cannot end with "_"');
}
$classname_pattern = self::CLASS_NAME_PATTERN_53;
if (!is_string($class_name) || !preg_match($classname_pattern, $class_name)) {
throw new InvalidArgumentException('Class names must be valid PHP class names');
}
$func = function () use ($class_name) {
return new $class_name();
};
return $this->setFactory($name, $func, $shared);
} | php | public function setClassName($name, $class_name, $shared = true) {
if (substr($name, -1) === '_') {
throw new InvalidArgumentException('$name cannot end with "_"');
}
$classname_pattern = self::CLASS_NAME_PATTERN_53;
if (!is_string($class_name) || !preg_match($classname_pattern, $class_name)) {
throw new InvalidArgumentException('Class names must be valid PHP class names');
}
$func = function () use ($class_name) {
return new $class_name();
};
return $this->setFactory($name, $func, $shared);
} | [
"public",
"function",
"setClassName",
"(",
"$",
"name",
",",
"$",
"class_name",
",",
"$",
"shared",
"=",
"true",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"1",
")",
"===",
"'_'",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
... | Set a factory based on instantiating a class with no arguments.
@param string $name Name of the value
@param string $class_name Class name to be instantiated
@param bool $shared Whether the same value should be returned for every request
@return \Elgg\Di\DiContainer
@throws InvalidArgumentException | [
"Set",
"a",
"factory",
"based",
"on",
"instantiating",
"a",
"class",
"with",
"no",
"arguments",
"."
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Di/DiContainer.php#L140-L152 | train |
hypeJunction/hypeApps | classes/hypeJunction/Di/DiContainer.php | DiContainer.remove | public function remove($name) {
if (substr($name, -1) === '_') {
throw new InvalidArgumentException('$name cannot end with "_"');
}
unset($this->{$name});
unset($this->factories_[$name]);
return $this;
} | php | public function remove($name) {
if (substr($name, -1) === '_') {
throw new InvalidArgumentException('$name cannot end with "_"');
}
unset($this->{$name});
unset($this->factories_[$name]);
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"1",
")",
"===",
"'_'",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$name cannot end with \"_\"'",
")",
";",
"}",
"unset",
"(",
... | Remove a value from the container
@param string $name The name of the value
@return \Elgg\Di\DiContainer | [
"Remove",
"a",
"value",
"from",
"the",
"container"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Di/DiContainer.php#L160-L167 | train |
hypeJunction/hypeApps | classes/hypeJunction/Di/DiContainer.php | DiContainer.has | public function has($name) {
if (isset($this->factories_[$name])) {
return true;
}
if (substr($name, -1) === '_') {
return false;
}
return (bool)property_exists($this, $name);
} | php | public function has($name) {
if (isset($this->factories_[$name])) {
return true;
}
if (substr($name, -1) === '_') {
return false;
}
return (bool)property_exists($this, $name);
} | [
"public",
"function",
"has",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"factories_",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"1",
")",
"=... | Does the container have this value
@param string $name The name of the value
@return bool | [
"Does",
"the",
"container",
"have",
"this",
"value"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Di/DiContainer.php#L175-L183 | train |
webeweb/core-library | src/ChartAccounts/Model/AbstractChartAccountsModel.php | AbstractChartAccountsModel.addAccount | public function addAccount(ChartAccountsAccount $account) {
foreach ($this->accounts as $current) {
if ($current->getNumber() === $account->getNumber()) {
throw new AccountAlreadyExistsException($account);
}
}
$this->accounts[] = $account;
return $this;
} | php | public function addAccount(ChartAccountsAccount $account) {
foreach ($this->accounts as $current) {
if ($current->getNumber() === $account->getNumber()) {
throw new AccountAlreadyExistsException($account);
}
}
$this->accounts[] = $account;
return $this;
} | [
"public",
"function",
"addAccount",
"(",
"ChartAccountsAccount",
"$",
"account",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"accounts",
"as",
"$",
"current",
")",
"{",
"if",
"(",
"$",
"current",
"->",
"getNumber",
"(",
")",
"===",
"$",
"account",
"->",... | Add an account.
@param ChartAccountsAccount $account The account.
@return AbstractChartAccountsModel Returns this charts of accounts model.
@throws AccountAlreadyExistsException Throws an account already exists. | [
"Add",
"an",
"account",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ChartAccounts/Model/AbstractChartAccountsModel.php#L60-L68 | train |
webeweb/core-library | src/ChartAccounts/Model/AbstractChartAccountsModel.php | AbstractChartAccountsModel.removeAccount | public function removeAccount(ChartAccountsAccount $account) {
for ($i = count($this->accounts) - 1; 0 <= $i; --$i) {
if ($account->getNumber() !== $this->accounts[$i]->getNumber()) {
continue;
}
unset($this->accounts[$i]);
}
return $this;
} | php | public function removeAccount(ChartAccountsAccount $account) {
for ($i = count($this->accounts) - 1; 0 <= $i; --$i) {
if ($account->getNumber() !== $this->accounts[$i]->getNumber()) {
continue;
}
unset($this->accounts[$i]);
}
return $this;
} | [
"public",
"function",
"removeAccount",
"(",
"ChartAccountsAccount",
"$",
"account",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"this",
"->",
"accounts",
")",
"-",
"1",
";",
"0",
"<=",
"$",
"i",
";",
"--",
"$",
"i",
")",
"{",
"if",
"(... | Remove an account.
@param ChartAccountsAccount $account The account.
@return AbstractChartAccountsModel Returns this charts of accounts model. | [
"Remove",
"an",
"account",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ChartAccounts/Model/AbstractChartAccountsModel.php#L103-L111 | train |
shopgate/cart-integration-magento2-base | src/Model/Source/CmsMap.php | CmsMap.getCmsPageRenderer | protected function getCmsPageRenderer()
{
if (!$this->cmsPageRenderer) {
$this->cmsPageRenderer = $this->getLayout()->createBlock(
'Shopgate\Base\Block\Adminhtml\Form\Field\CmsMap',
'',
['data' => ['is_render_to_js_template' => true]]
);
}
return $this->cmsPageRenderer;
} | php | protected function getCmsPageRenderer()
{
if (!$this->cmsPageRenderer) {
$this->cmsPageRenderer = $this->getLayout()->createBlock(
'Shopgate\Base\Block\Adminhtml\Form\Field\CmsMap',
'',
['data' => ['is_render_to_js_template' => true]]
);
}
return $this->cmsPageRenderer;
} | [
"protected",
"function",
"getCmsPageRenderer",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cmsPageRenderer",
")",
"{",
"$",
"this",
"->",
"cmsPageRenderer",
"=",
"$",
"this",
"->",
"getLayout",
"(",
")",
"->",
"createBlock",
"(",
"'Shopgate\\Base\\Blo... | Returns a rendered for cms page mapping
@codingStandardsIgnoreEnd
@return CmsMapField
@throws \Magento\Framework\Exception\LocalizedException | [
"Returns",
"a",
"rendered",
"for",
"cms",
"page",
"mapping"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Source/CmsMap.php#L80-L91 | train |
Team-Tea-Time/laravel-filer | src/Filer.php | Filer.routes | public static function routes(Router $router, $namespace = 'TeamTeaTime\Filer\Controllers')
{
$router->group(compact('namespace'), function ($router) {
$router->get('{id}', [
'as' => 'filer.file.view',
'uses' => 'LocalFileController@view'
]);
$router->get('{id}/download', [
'as' => 'filer.file.download',
'uses' => 'LocalFileController@download'
]);
});
} | php | public static function routes(Router $router, $namespace = 'TeamTeaTime\Filer\Controllers')
{
$router->group(compact('namespace'), function ($router) {
$router->get('{id}', [
'as' => 'filer.file.view',
'uses' => 'LocalFileController@view'
]);
$router->get('{id}/download', [
'as' => 'filer.file.download',
'uses' => 'LocalFileController@download'
]);
});
} | [
"public",
"static",
"function",
"routes",
"(",
"Router",
"$",
"router",
",",
"$",
"namespace",
"=",
"'TeamTeaTime\\Filer\\Controllers'",
")",
"{",
"$",
"router",
"->",
"group",
"(",
"compact",
"(",
"'namespace'",
")",
",",
"function",
"(",
"$",
"router",
")"... | Define the standard routes.
@param Router $router
@param string $namespace
@return void | [
"Define",
"the",
"standard",
"routes",
"."
] | e69fae1bc99a317097e997b3d029ecc9be0a0b4b | https://github.com/Team-Tea-Time/laravel-filer/blob/e69fae1bc99a317097e997b3d029ecc9be0a0b4b/src/Filer.php#L15-L27 | train |
Team-Tea-Time/laravel-filer | src/Filer.php | Filer.checkType | public static function checkType($item)
{
if (is_string($item)) {
// Item is a string; check to see if it's a URL or filepath
if (filter_var($item, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
// Item is a URL
return Type::URL;
} elseif (is_file(config('filer.path.absolute') . "/{$item}")) {
// Item is a filepath
return Type::FILEPATH;
}
} elseif (is_a($item, 'SplFileInfo')) {
// Item is a file object
return Type::FILE;
}
// Throw an exception if item doesn't match any known types
throw new Exception('Unknown item type');
} | php | public static function checkType($item)
{
if (is_string($item)) {
// Item is a string; check to see if it's a URL or filepath
if (filter_var($item, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
// Item is a URL
return Type::URL;
} elseif (is_file(config('filer.path.absolute') . "/{$item}")) {
// Item is a filepath
return Type::FILEPATH;
}
} elseif (is_a($item, 'SplFileInfo')) {
// Item is a file object
return Type::FILE;
}
// Throw an exception if item doesn't match any known types
throw new Exception('Unknown item type');
} | [
"public",
"static",
"function",
"checkType",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"// Item is a string; check to see if it's a URL or filepath",
"if",
"(",
"filter_var",
"(",
"$",
"item",
",",
"FILTER_VALIDATE_URL",
... | Attempts to determine what the given item is between a local filepath, a
local file object or a URL.
@param mixed $item
@return string
@throws Exception | [
"Attempts",
"to",
"determine",
"what",
"the",
"given",
"item",
"is",
"between",
"a",
"local",
"filepath",
"a",
"local",
"file",
"object",
"or",
"a",
"URL",
"."
] | e69fae1bc99a317097e997b3d029ecc9be0a0b4b | https://github.com/Team-Tea-Time/laravel-filer/blob/e69fae1bc99a317097e997b3d029ecc9be0a0b4b/src/Filer.php#L37-L55 | train |
Team-Tea-Time/laravel-filer | src/Filer.php | Filer.getRelativeFilepath | public static function getRelativeFilepath($file)
{
$storageDir = self::convertSlashes(config('filer.path.absolute'));
$absolutePath = self::convertSlashes($file->getRealPath());
return dirname(str_replace($storageDir, '', $absolutePath));
} | php | public static function getRelativeFilepath($file)
{
$storageDir = self::convertSlashes(config('filer.path.absolute'));
$absolutePath = self::convertSlashes($file->getRealPath());
return dirname(str_replace($storageDir, '', $absolutePath));
} | [
"public",
"static",
"function",
"getRelativeFilepath",
"(",
"$",
"file",
")",
"{",
"$",
"storageDir",
"=",
"self",
"::",
"convertSlashes",
"(",
"config",
"(",
"'filer.path.absolute'",
")",
")",
";",
"$",
"absolutePath",
"=",
"self",
"::",
"convertSlashes",
"("... | Returns a file's relative path.
@param mixed $file
@return string | [
"Returns",
"a",
"file",
"s",
"relative",
"path",
"."
] | e69fae1bc99a317097e997b3d029ecc9be0a0b4b | https://github.com/Team-Tea-Time/laravel-filer/blob/e69fae1bc99a317097e997b3d029ecc9be0a0b4b/src/Filer.php#L63-L68 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/SFTP.php | Net_SFTP._setstat | function _setstat($filename, $attr, $recursive)
{
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
return false;
}
$filename = $this->_realpath($filename);
if ($filename === false) {
return false;
}
$this->_remove_from_stat_cache($filename);
if ($recursive) {
$i = 0;
$result = $this->_setstat_recursive($filename, $attr, $i);
$this->_read_put_responses($i);
return $result;
}
// SFTPv4+ has an additional byte field - type - that would need to be sent, as well. setting it to
// SSH_FILEXFER_TYPE_UNKNOWN might work. if not, we'd have to do an SSH_FXP_STAT before doing an SSH_FXP_SETSTAT.
if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($filename), $filename, $attr))) {
return false;
}
/*
"Because some systems must use separate system calls to set various attributes, it is possible that a failure
response will be returned, but yet some of the attributes may be have been successfully modified. If possible,
servers SHOULD avoid this situation; however, clients MUST be aware that this is possible."
-- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.6
*/
$response = $this->_get_sftp_packet();
if ($this->packet_type != NET_SFTP_STATUS) {
user_error('Expected SSH_FXP_STATUS');
return false;
}
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
if ($status != NET_SFTP_STATUS_OK) {
$this->_logError($response, $status);
return false;
}
return true;
} | php | function _setstat($filename, $attr, $recursive)
{
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
return false;
}
$filename = $this->_realpath($filename);
if ($filename === false) {
return false;
}
$this->_remove_from_stat_cache($filename);
if ($recursive) {
$i = 0;
$result = $this->_setstat_recursive($filename, $attr, $i);
$this->_read_put_responses($i);
return $result;
}
// SFTPv4+ has an additional byte field - type - that would need to be sent, as well. setting it to
// SSH_FILEXFER_TYPE_UNKNOWN might work. if not, we'd have to do an SSH_FXP_STAT before doing an SSH_FXP_SETSTAT.
if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($filename), $filename, $attr))) {
return false;
}
/*
"Because some systems must use separate system calls to set various attributes, it is possible that a failure
response will be returned, but yet some of the attributes may be have been successfully modified. If possible,
servers SHOULD avoid this situation; however, clients MUST be aware that this is possible."
-- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.6
*/
$response = $this->_get_sftp_packet();
if ($this->packet_type != NET_SFTP_STATUS) {
user_error('Expected SSH_FXP_STATUS');
return false;
}
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
if ($status != NET_SFTP_STATUS_OK) {
$this->_logError($response, $status);
return false;
}
return true;
} | [
"function",
"_setstat",
"(",
"$",
"filename",
",",
"$",
"attr",
",",
"$",
"recursive",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"bitmap",
"&",
"NET_SSH2_MASK_LOGIN",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"$",
"t... | Sets information about a file
@param string $filename
@param string $attr
@param bool $recursive
@return bool
@access private | [
"Sets",
"information",
"about",
"a",
"file"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/SFTP.php#L1545-L1594 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/SFTP.php | Net_SFTP.rename | function rename($oldname, $newname)
{
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
return false;
}
$oldname = $this->_realpath($oldname);
$newname = $this->_realpath($newname);
if ($oldname === false || $newname === false) {
return false;
}
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3
$packet = pack('Na*Na*', strlen($oldname), $oldname, strlen($newname), $newname);
if (!$this->_send_sftp_packet(NET_SFTP_RENAME, $packet)) {
return false;
}
$response = $this->_get_sftp_packet();
if ($this->packet_type != NET_SFTP_STATUS) {
user_error('Expected SSH_FXP_STATUS');
return false;
}
// if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
if ($status != NET_SFTP_STATUS_OK) {
$this->_logError($response, $status);
return false;
}
// don't move the stat cache entry over since this operation could very well change the
// atime and mtime attributes
//$this->_update_stat_cache($newname, $this->_query_stat_cache($oldname));
$this->_remove_from_stat_cache($oldname);
$this->_remove_from_stat_cache($newname);
return true;
} | php | function rename($oldname, $newname)
{
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
return false;
}
$oldname = $this->_realpath($oldname);
$newname = $this->_realpath($newname);
if ($oldname === false || $newname === false) {
return false;
}
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3
$packet = pack('Na*Na*', strlen($oldname), $oldname, strlen($newname), $newname);
if (!$this->_send_sftp_packet(NET_SFTP_RENAME, $packet)) {
return false;
}
$response = $this->_get_sftp_packet();
if ($this->packet_type != NET_SFTP_STATUS) {
user_error('Expected SSH_FXP_STATUS');
return false;
}
// if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
if ($status != NET_SFTP_STATUS_OK) {
$this->_logError($response, $status);
return false;
}
// don't move the stat cache entry over since this operation could very well change the
// atime and mtime attributes
//$this->_update_stat_cache($newname, $this->_query_stat_cache($oldname));
$this->_remove_from_stat_cache($oldname);
$this->_remove_from_stat_cache($newname);
return true;
} | [
"function",
"rename",
"(",
"$",
"oldname",
",",
"$",
"newname",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"bitmap",
"&",
"NET_SSH2_MASK_LOGIN",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"oldname",
"=",
"$",
"this",
"->",
"_realpath",
... | Renames a file or a directory on the SFTP server
@param string $oldname
@param string $newname
@return bool
@access public | [
"Renames",
"a",
"file",
"or",
"a",
"directory",
"on",
"the",
"SFTP",
"server"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/SFTP.php#L2727-L2768 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/Extended/OrderItem.php | OrderItem.getStackQty | public function getStackQty()
{
$info = $this->getInternalOrderInfo();
$qty = 1;
if ($info->getStackQuantity() > 1) {
$qty = $info->getStackQuantity();
}
return $qty;
} | php | public function getStackQty()
{
$info = $this->getInternalOrderInfo();
$qty = 1;
if ($info->getStackQuantity() > 1) {
$qty = $info->getStackQuantity();
}
return $qty;
} | [
"public",
"function",
"getStackQty",
"(",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"getInternalOrderInfo",
"(",
")",
";",
"$",
"qty",
"=",
"1",
";",
"if",
"(",
"$",
"info",
"->",
"getStackQuantity",
"(",
")",
">",
"1",
")",
"{",
"$",
"qty",
... | Retrieve stack qty if it exists
@return int
@throws \Zend_Json_Exception | [
"Retrieve",
"stack",
"qty",
"if",
"it",
"exists"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/OrderItem.php#L88-L98 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/Extended/OrderItem.php | OrderItem.setInternalOrderInfo | public function setInternalOrderInfo($value)
{
if ($value instanceof ItemInfo) {
$value = $value->toJson();
} elseif (is_array($value)) {
$value = \Zend_Json_Encoder::encode($value);
}
return parent::setInternalOrderInfo($value);
} | php | public function setInternalOrderInfo($value)
{
if ($value instanceof ItemInfo) {
$value = $value->toJson();
} elseif (is_array($value)) {
$value = \Zend_Json_Encoder::encode($value);
}
return parent::setInternalOrderInfo($value);
} | [
"public",
"function",
"setInternalOrderInfo",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ItemInfo",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"toJson",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
... | Encodes to JSON if it's not empty or already JSON
@param mixed $value
@return string | null | [
"Encodes",
"to",
"JSON",
"if",
"it",
"s",
"not",
"empty",
"or",
"already",
"JSON"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/OrderItem.php#L133-L142 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/Extended/OrderItem.php | OrderItem.setMagentoError | public function setMagentoError($errorText)
{
$code = $this->translateMagentoError($errorText);
$message = \ShopgateLibraryException::getMessageFor($code);
$this->setUnhandledError($code, $message);
return $this;
} | php | public function setMagentoError($errorText)
{
$code = $this->translateMagentoError($errorText);
$message = \ShopgateLibraryException::getMessageFor($code);
$this->setUnhandledError($code, $message);
return $this;
} | [
"public",
"function",
"setMagentoError",
"(",
"$",
"errorText",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"translateMagentoError",
"(",
"$",
"errorText",
")",
";",
"$",
"message",
"=",
"\\",
"ShopgateLibraryException",
"::",
"getMessageFor",
"(",
"$",
"... | Takes a magento quote exception
and translated it into Shopgate error
@param string $errorText
@return OrderItem | [
"Takes",
"a",
"magento",
"quote",
"exception",
"and",
"translated",
"it",
"into",
"Shopgate",
"error"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/OrderItem.php#L196-L203 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/Extended/OrderItem.php | OrderItem.getExportProductId | public function getExportProductId()
{
return $this->getInternalOrderInfo()->getItemType() == Grouped::TYPE_CODE
? $this->getChildId()
: $this->getParentId();
} | php | public function getExportProductId()
{
return $this->getInternalOrderInfo()->getItemType() == Grouped::TYPE_CODE
? $this->getChildId()
: $this->getParentId();
} | [
"public",
"function",
"getExportProductId",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getInternalOrderInfo",
"(",
")",
"->",
"getItemType",
"(",
")",
"==",
"Grouped",
"::",
"TYPE_CODE",
"?",
"$",
"this",
"->",
"getChildId",
"(",
")",
":",
"$",
"this",
... | Uses an export ID based on expectations
of our backend API | [
"Uses",
"an",
"export",
"ID",
"based",
"on",
"expectations",
"of",
"our",
"backend",
"API"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Extended/OrderItem.php#L262-L267 | train |
mothership-gmbh/state_machine | src/Status.php | Status.validate | private function validate()
{
if (!array_key_exists('type', $this->properties)) {
throw new StatusException(sprintf('Key %s in %s missing', 'type', __CLASS__), 100, null);
}
$type = $this->properties['type'];
// the type specified must be valid
if (!in_array($this->properties['type'], $this->types)) {
throw new StatusException('The type specified is invalid', 100, null);
}
switch ($type) {
case StatusInterface::TYPE_INITIAL:
case StatusInterface::TYPE_EXCEPTION:
$mandatoryKeys = ['name'];
break;
default:
$mandatoryKeys = ['name', 'transitions_from', 'transitions_to'];
break;
}
foreach ($mandatoryKeys as $key) {
if (!array_key_exists($key, $this->properties)) {
throw new StatusException(sprintf('Key %s in %s missing', $key, __CLASS__), 100, null);
}
}
if (StatusInterface::TYPE_INITIAL != $type && StatusInterface::TYPE_EXCEPTION != $type) {
$keysMustBeArray = ['transitions_from', 'transitions_to'];
foreach ($keysMustBeArray as $key) {
if (!is_array($this->properties[$key])) {
throw new StatusException(sprintf('Key %s is not an array', $key), 100, null);
}
}
}
} | php | private function validate()
{
if (!array_key_exists('type', $this->properties)) {
throw new StatusException(sprintf('Key %s in %s missing', 'type', __CLASS__), 100, null);
}
$type = $this->properties['type'];
// the type specified must be valid
if (!in_array($this->properties['type'], $this->types)) {
throw new StatusException('The type specified is invalid', 100, null);
}
switch ($type) {
case StatusInterface::TYPE_INITIAL:
case StatusInterface::TYPE_EXCEPTION:
$mandatoryKeys = ['name'];
break;
default:
$mandatoryKeys = ['name', 'transitions_from', 'transitions_to'];
break;
}
foreach ($mandatoryKeys as $key) {
if (!array_key_exists($key, $this->properties)) {
throw new StatusException(sprintf('Key %s in %s missing', $key, __CLASS__), 100, null);
}
}
if (StatusInterface::TYPE_INITIAL != $type && StatusInterface::TYPE_EXCEPTION != $type) {
$keysMustBeArray = ['transitions_from', 'transitions_to'];
foreach ($keysMustBeArray as $key) {
if (!is_array($this->properties[$key])) {
throw new StatusException(sprintf('Key %s is not an array', $key), 100, null);
}
}
}
} | [
"private",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'type'",
",",
"$",
"this",
"->",
"properties",
")",
")",
"{",
"throw",
"new",
"StatusException",
"(",
"sprintf",
"(",
"'Key %s in %s missing'",
",",
"'type'",
",",
... | Validate all required properties on initialization.
@throws \Mothership\StateMachine\Exception\StatusException | [
"Validate",
"all",
"required",
"properties",
"on",
"initialization",
"."
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/Status.php#L58-L96 | train |
mothership-gmbh/state_machine | src/CollectionWorkflowAbstract.php | CollectionWorkflowAbstract.has_more | public function has_more()
{
if ($this->_pointer + 1 == count($this->_collection)) {
return false;
}
++$this->_pointer;
return true;
} | php | public function has_more()
{
if ($this->_pointer + 1 == count($this->_collection)) {
return false;
}
++$this->_pointer;
return true;
} | [
"public",
"function",
"has_more",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_pointer",
"+",
"1",
"==",
"count",
"(",
"$",
"this",
"->",
"_collection",
")",
")",
"{",
"return",
"false",
";",
"}",
"++",
"$",
"this",
"->",
"_pointer",
";",
"return... | If the collection has not been finished yet, return false.
false -> go to finish()
true -> continue with process_items()
@return bool | [
"If",
"the",
"collection",
"has",
"not",
"been",
"finished",
"yet",
"return",
"false",
"."
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/CollectionWorkflowAbstract.php#L63-L71 | train |
yii2lab/yii2-extension | src/console/helpers/Error.php | Error.line | static function line($message = '', $newLine = 'after') {
if($newLine == 'before' || $newLine == 'both') {
echo PHP_EOL;
}
echo self::formatMessage("Error. $message", ['fg-red']);
if($newLine == 'after' || $newLine == 'both') {
echo PHP_EOL;
}
} | php | static function line($message = '', $newLine = 'after') {
if($newLine == 'before' || $newLine == 'both') {
echo PHP_EOL;
}
echo self::formatMessage("Error. $message", ['fg-red']);
if($newLine == 'after' || $newLine == 'both') {
echo PHP_EOL;
}
} | [
"static",
"function",
"line",
"(",
"$",
"message",
"=",
"''",
",",
"$",
"newLine",
"=",
"'after'",
")",
"{",
"if",
"(",
"$",
"newLine",
"==",
"'before'",
"||",
"$",
"newLine",
"==",
"'both'",
")",
"{",
"echo",
"PHP_EOL",
";",
"}",
"echo",
"self",
"... | Prints error message.
@param string $message message | [
"Prints",
"error",
"message",
"."
] | a569d282004ef119579960c7549ecbc2e4441b8d | https://github.com/yii2lab/yii2-extension/blob/a569d282004ef119579960c7549ecbc2e4441b8d/src/console/helpers/Error.php#L28-L36 | train |
yii2lab/yii2-extension | src/console/helpers/Error.php | Error.formatMessage | private static function formatMessage($message, $styles)
{
if (empty($styles) || !self::ansiColorsSupported()) {
return $message;
}
return sprintf("\x1b[%sm", implode(';', array_map('Output::getStyleCode', $styles))) . $message . "\x1b[0m";
} | php | private static function formatMessage($message, $styles)
{
if (empty($styles) || !self::ansiColorsSupported()) {
return $message;
}
return sprintf("\x1b[%sm", implode(';', array_map('Output::getStyleCode', $styles))) . $message . "\x1b[0m";
} | [
"private",
"static",
"function",
"formatMessage",
"(",
"$",
"message",
",",
"$",
"styles",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"styles",
")",
"||",
"!",
"self",
"::",
"ansiColorsSupported",
"(",
")",
")",
"{",
"return",
"$",
"message",
";",
"}",
... | Formats message using styles if STDOUT supports it.
@param string $message message
@param string[] $styles styles
@return string formatted message. | [
"Formats",
"message",
"using",
"styles",
"if",
"STDOUT",
"supports",
"it",
"."
] | a569d282004ef119579960c7549ecbc2e4441b8d | https://github.com/yii2lab/yii2-extension/blob/a569d282004ef119579960c7549ecbc2e4441b8d/src/console/helpers/Error.php#L88-L95 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/IconFactory.php | IconFactory.getSizes | public function getSizes(\ElggEntity $entity, array $icon_sizes = array()) {
$defaults = ($entity && $entity->getSubtype() == 'file') ? $this->config->getFileIconSizes() : $this->config->getGlobalIconSizes();
$sizes = array_merge($defaults, $icon_sizes);
return elgg_trigger_plugin_hook('entity:icon:sizes', $entity->getType(), array(
'entity' => $entity,
'subtype' => $entity->getSubtype(),
), $sizes);
} | php | public function getSizes(\ElggEntity $entity, array $icon_sizes = array()) {
$defaults = ($entity && $entity->getSubtype() == 'file') ? $this->config->getFileIconSizes() : $this->config->getGlobalIconSizes();
$sizes = array_merge($defaults, $icon_sizes);
return elgg_trigger_plugin_hook('entity:icon:sizes', $entity->getType(), array(
'entity' => $entity,
'subtype' => $entity->getSubtype(),
), $sizes);
} | [
"public",
"function",
"getSizes",
"(",
"\\",
"ElggEntity",
"$",
"entity",
",",
"array",
"$",
"icon_sizes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"defaults",
"=",
"(",
"$",
"entity",
"&&",
"$",
"entity",
"->",
"getSubtype",
"(",
")",
"==",
"'file'",
... | Get icon size config
@param \ElggEntity $entity Entity
@param array $icon_sizes Predefined icon sizes
@return array | [
"Get",
"icon",
"size",
"config"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/IconFactory.php#L145-L154 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/IconFactory.php | IconFactory.getIconDirectory | public function getIconDirectory(\ElggEntity $entity, $size = null, $directory = null) {
$sizes = $this->getSizes($entity);
if (isset($sizes[$size]['metadata_name'])) {
$md_name = $sizes[$size]['metadata_name'];
if ($entity->$md_name) {
$directory = '';
}
}
if ($directory === null) {
$directory = $directory ? : $entity->icon_directory;
if ($entity instanceof \ElggUser) {
$directory = 'profile';
} else if ($entity instanceof \ElggGroup) {
$directory = 'groups';
} else {
$directory = $this->config->getDefaultIconDirectory();
}
}
$directory = elgg_trigger_plugin_hook('entity:icon:directory', $entity->getType(), array(
'entity' => $entity,
'size' => $size,
), $directory);
return trim($directory, '/');
} | php | public function getIconDirectory(\ElggEntity $entity, $size = null, $directory = null) {
$sizes = $this->getSizes($entity);
if (isset($sizes[$size]['metadata_name'])) {
$md_name = $sizes[$size]['metadata_name'];
if ($entity->$md_name) {
$directory = '';
}
}
if ($directory === null) {
$directory = $directory ? : $entity->icon_directory;
if ($entity instanceof \ElggUser) {
$directory = 'profile';
} else if ($entity instanceof \ElggGroup) {
$directory = 'groups';
} else {
$directory = $this->config->getDefaultIconDirectory();
}
}
$directory = elgg_trigger_plugin_hook('entity:icon:directory', $entity->getType(), array(
'entity' => $entity,
'size' => $size,
), $directory);
return trim($directory, '/');
} | [
"public",
"function",
"getIconDirectory",
"(",
"\\",
"ElggEntity",
"$",
"entity",
",",
"$",
"size",
"=",
"null",
",",
"$",
"directory",
"=",
"null",
")",
"{",
"$",
"sizes",
"=",
"$",
"this",
"->",
"getSizes",
"(",
"$",
"entity",
")",
";",
"if",
"(",
... | Determines and normalizes the directory in which the icon is stored
@param \ElggEntity $entity Entity
@param string $size Icon size
@param string $directory Default directory
@return string | [
"Determines",
"and",
"normalizes",
"the",
"directory",
"in",
"which",
"the",
"icon",
"is",
"stored"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/IconFactory.php#L164-L191 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/IconFactory.php | IconFactory.getIconFilename | public function getIconFilename(\ElggEntity $entity, $size = '') {
$mimetype = $entity->icon_mimetype ? : $entity->mimetype;
switch ($mimetype) {
default :
$ext = 'jpg';
break;
case 'image/png' :
$ext = 'png';
break;
case 'image/gif' :
$ext = 'gif';
break;
}
$sizes = $this->getSizes($entity);
if (isset($sizes[$size]['metadata_name'])) {
$md_name = $sizes[$size]['metadata_name'];
$filename = $entity->$md_name;
}
if (!$filename) {
$filename = "{$entity->guid}{$size}.{$ext}";
}
return elgg_trigger_plugin_hook('entity:icon:directory', $entity->getType(), array(
'entity' => $entity,
'size' => $size,
), $filename);
} | php | public function getIconFilename(\ElggEntity $entity, $size = '') {
$mimetype = $entity->icon_mimetype ? : $entity->mimetype;
switch ($mimetype) {
default :
$ext = 'jpg';
break;
case 'image/png' :
$ext = 'png';
break;
case 'image/gif' :
$ext = 'gif';
break;
}
$sizes = $this->getSizes($entity);
if (isset($sizes[$size]['metadata_name'])) {
$md_name = $sizes[$size]['metadata_name'];
$filename = $entity->$md_name;
}
if (!$filename) {
$filename = "{$entity->guid}{$size}.{$ext}";
}
return elgg_trigger_plugin_hook('entity:icon:directory', $entity->getType(), array(
'entity' => $entity,
'size' => $size,
), $filename);
} | [
"public",
"function",
"getIconFilename",
"(",
"\\",
"ElggEntity",
"$",
"entity",
",",
"$",
"size",
"=",
"''",
")",
"{",
"$",
"mimetype",
"=",
"$",
"entity",
"->",
"icon_mimetype",
"?",
":",
"$",
"entity",
"->",
"mimetype",
";",
"switch",
"(",
"$",
"mim... | Determines icon filename
@param \ElggEntity $entity Entity
@param string $size Size
@return string | [
"Determines",
"icon",
"filename"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/IconFactory.php#L200-L227 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/IconFactory.php | IconFactory.getIconFile | public function getIconFile(\ElggEntity $entity, $size = '') {
$dir = $this->getIconDirectory($entity, $size);
$filename = $this->getIconFilename($entity, $size);
if ($entity instanceof \ElggUser) {
$owner_guid = $entity->guid;
} else if ($entity->owner_guid) {
$owner_guid = $entity->owner_guid;
} else {
$owner_guid = elgg_get_site_entity();
}
$file = new \ElggFile();
$file->owner_guid = $owner_guid;
$file->setFilename("{$dir}/{$filename}");
$file->mimetype = $file->detectMimeType();
return $file;
} | php | public function getIconFile(\ElggEntity $entity, $size = '') {
$dir = $this->getIconDirectory($entity, $size);
$filename = $this->getIconFilename($entity, $size);
if ($entity instanceof \ElggUser) {
$owner_guid = $entity->guid;
} else if ($entity->owner_guid) {
$owner_guid = $entity->owner_guid;
} else {
$owner_guid = elgg_get_site_entity();
}
$file = new \ElggFile();
$file->owner_guid = $owner_guid;
$file->setFilename("{$dir}/{$filename}");
$file->mimetype = $file->detectMimeType();
return $file;
} | [
"public",
"function",
"getIconFile",
"(",
"\\",
"ElggEntity",
"$",
"entity",
",",
"$",
"size",
"=",
"''",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"getIconDirectory",
"(",
"$",
"entity",
",",
"$",
"size",
")",
";",
"$",
"filename",
"=",
"$",
"... | Returns an ElggFile containing the entity icon
@param \ElggEntity $entity Entity
@param string $size Size
@return \ElggFile | [
"Returns",
"an",
"ElggFile",
"containing",
"the",
"entity",
"icon"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/IconFactory.php#L236-L255 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/IconFactory.php | IconFactory.getURL | public function getURL(\ElggEntity $entity, $size = '') {
$icon = $this->getIconFile($entity, $size);
if (!$icon->exists()) {
return;
}
$key = get_site_secret();
$guid = $entity->guid;
$path = $icon->getFilename();
$hmac = hash_hmac('sha256', $guid . $path, $key);
$query = serialize(array(
'uid' => $guid,
'd' => ($entity instanceof \ElggUser) ? $entity->guid : $entity->owner_guid, // guid of the dir owner
'dts' => ($entity instanceof \ElggUser) ? $entity->time_created : $entity->getOwnerEntity()->time_created,
'path' => $path,
'ts' => $entity->icontime,
'mac' => $hmac,
));
$url = elgg_http_add_url_query_elements('mod/hypeApps/servers/icon.php', array(
'q' => base64_encode($query),
));
return elgg_normalize_url($url);
} | php | public function getURL(\ElggEntity $entity, $size = '') {
$icon = $this->getIconFile($entity, $size);
if (!$icon->exists()) {
return;
}
$key = get_site_secret();
$guid = $entity->guid;
$path = $icon->getFilename();
$hmac = hash_hmac('sha256', $guid . $path, $key);
$query = serialize(array(
'uid' => $guid,
'd' => ($entity instanceof \ElggUser) ? $entity->guid : $entity->owner_guid, // guid of the dir owner
'dts' => ($entity instanceof \ElggUser) ? $entity->time_created : $entity->getOwnerEntity()->time_created,
'path' => $path,
'ts' => $entity->icontime,
'mac' => $hmac,
));
$url = elgg_http_add_url_query_elements('mod/hypeApps/servers/icon.php', array(
'q' => base64_encode($query),
));
return elgg_normalize_url($url);
} | [
"public",
"function",
"getURL",
"(",
"\\",
"ElggEntity",
"$",
"entity",
",",
"$",
"size",
"=",
"''",
")",
"{",
"$",
"icon",
"=",
"$",
"this",
"->",
"getIconFile",
"(",
"$",
"entity",
",",
"$",
"size",
")",
";",
"if",
"(",
"!",
"$",
"icon",
"->",
... | Prepares a URL that can be used to display an icon bypassing the engine boot
@param \ElggEntity $entity Entity
@param string $size Size
@return string|null | [
"Prepares",
"a",
"URL",
"that",
"can",
"be",
"used",
"to",
"display",
"an",
"icon",
"bypassing",
"the",
"engine",
"boot"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/IconFactory.php#L264-L291 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/IconFactory.php | IconFactory.outputRawIcon | public function outputRawIcon($entity_guid, $size = null) {
if (headers_sent()) {
exit;
}
$ha = access_get_show_hidden_status();
access_show_hidden_entities(true);
$entity = get_entity($entity_guid);
if (!$entity) {
exit;
}
$size = strtolower($size ? : 'medium');
$filename = "icons/" . $entity->guid . $size . ".jpg";
$etag = md5($entity->icontime . $size);
$filehandler = new \ElggFile();
$filehandler->owner_guid = $entity->owner_guid;
$filehandler->setFilename($filename);
if ($filehandler->exists()) {
$filehandler->open('read');
$contents = $filehandler->grabFile();
$filehandler->close();
} else {
forward('', '404');
}
$mimetype = ($entity->mimetype) ? $entity->mimetype : 'image/jpeg';
access_show_hidden_entities($ha);
header("Content-type: $mimetype");
header("Etag: $etag");
header('Expires: ' . date('r', time() + 864000));
header("Pragma: public");
header("Cache-Control: public");
header("Content-Length: " . strlen($contents));
echo $contents;
exit;
} | php | public function outputRawIcon($entity_guid, $size = null) {
if (headers_sent()) {
exit;
}
$ha = access_get_show_hidden_status();
access_show_hidden_entities(true);
$entity = get_entity($entity_guid);
if (!$entity) {
exit;
}
$size = strtolower($size ? : 'medium');
$filename = "icons/" . $entity->guid . $size . ".jpg";
$etag = md5($entity->icontime . $size);
$filehandler = new \ElggFile();
$filehandler->owner_guid = $entity->owner_guid;
$filehandler->setFilename($filename);
if ($filehandler->exists()) {
$filehandler->open('read');
$contents = $filehandler->grabFile();
$filehandler->close();
} else {
forward('', '404');
}
$mimetype = ($entity->mimetype) ? $entity->mimetype : 'image/jpeg';
access_show_hidden_entities($ha);
header("Content-type: $mimetype");
header("Etag: $etag");
header('Expires: ' . date('r', time() + 864000));
header("Pragma: public");
header("Cache-Control: public");
header("Content-Length: " . strlen($contents));
echo $contents;
exit;
} | [
"public",
"function",
"outputRawIcon",
"(",
"$",
"entity_guid",
",",
"$",
"size",
"=",
"null",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"exit",
";",
"}",
"$",
"ha",
"=",
"access_get_show_hidden_status",
"(",
")",
";",
"access_show_hidden_en... | Outputs raw icon
@param int $entity_guid GUID of an entity
@param string $size Icon size
@return void | [
"Outputs",
"raw",
"icon"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/IconFactory.php#L300-L333 | train |
shopsys/migrations | src/Component/Doctrine/Migrations/Configuration.php | Configuration.getMigrationsToExecute | public function getMigrationsToExecute($direction, $to)
{
if ($direction === Version::DIRECTION_DOWN) {
$this->throwMethodIsNotAllowedException('Migration down is not allowed.');
}
$migrationVersionsToExecute = [];
$allMigrationVersions = $this->getMigrations();
$migratedVersions = $this->getMigratedVersions();
foreach ($allMigrationVersions as $version) {
if ($to < $version->getVersion()) {
$this->throwMethodIsNotAllowedException('Partial migration up in not allowed.');
}
if ($this->shouldExecuteMigration($version, $migratedVersions)) {
$migrationVersionsToExecute[$version->getVersion()] = $version;
}
}
return $migrationVersionsToExecute;
} | php | public function getMigrationsToExecute($direction, $to)
{
if ($direction === Version::DIRECTION_DOWN) {
$this->throwMethodIsNotAllowedException('Migration down is not allowed.');
}
$migrationVersionsToExecute = [];
$allMigrationVersions = $this->getMigrations();
$migratedVersions = $this->getMigratedVersions();
foreach ($allMigrationVersions as $version) {
if ($to < $version->getVersion()) {
$this->throwMethodIsNotAllowedException('Partial migration up in not allowed.');
}
if ($this->shouldExecuteMigration($version, $migratedVersions)) {
$migrationVersionsToExecute[$version->getVersion()] = $version;
}
}
return $migrationVersionsToExecute;
} | [
"public",
"function",
"getMigrationsToExecute",
"(",
"$",
"direction",
",",
"$",
"to",
")",
"{",
"if",
"(",
"$",
"direction",
"===",
"Version",
"::",
"DIRECTION_DOWN",
")",
"{",
"$",
"this",
"->",
"throwMethodIsNotAllowedException",
"(",
"'Migration down is not al... | Returns the array of migrations to executed based on the given direction and target version number.
Because of multiple migrations locations and the lock file, only complete UP migrations are allowed.
@param string $direction the direction we are migrating (DOWN is not allowed)
@param string $to the version to migrate to (partial migrations are not allowed)
@throws \Shopsys\MigrationBundle\Component\Doctrine\Migrations\Exception\MethodIsNotAllowedException
@return \Doctrine\DBAL\Migrations\Version[] $migrations the array of migrations we can execute | [
"Returns",
"the",
"array",
"of",
"migrations",
"to",
"executed",
"based",
"on",
"the",
"given",
"direction",
"and",
"target",
"version",
"number",
".",
"Because",
"of",
"multiple",
"migrations",
"locations",
"and",
"the",
"lock",
"file",
"only",
"complete",
"U... | 4e28e3f13e53973b1daa600adb01e51cf30ea016 | https://github.com/shopsys/migrations/blob/4e28e3f13e53973b1daa600adb01e51cf30ea016/src/Component/Doctrine/Migrations/Configuration.php#L107-L128 | train |
davro/fabrication | library/GCode.php | GCode.drawCircle | public function drawCircle($x, $y, $z, $radius, $motion = 'G2', $plane = 'G17')
{
if ($plane == 'G17') {
$of = $x - $radius;
$this->setCode("(circle)");
$this->setCode("G0 X{$of} Y{$y}");
$this->setCode("G1 Z{$z} (axis spindle start point)");
// TODO Tool size ...
// TODO Cutting spindle movement ...
$this->setCode("{$plane} {$motion} X{$of} Y{$y} I{$radius} J0.00 Z{$z}");
$this->setCode("G0 Z{$this->spindleAxisStartPosition} (axis spindle start position)");
$this->setCode("(/circle)\n");
}
if ($plane == 'G18') {
// G18 is disabled
return;
}
if ($plane == 'G19') {
// G19 is disabled
return;
}
return $this;
} | php | public function drawCircle($x, $y, $z, $radius, $motion = 'G2', $plane = 'G17')
{
if ($plane == 'G17') {
$of = $x - $radius;
$this->setCode("(circle)");
$this->setCode("G0 X{$of} Y{$y}");
$this->setCode("G1 Z{$z} (axis spindle start point)");
// TODO Tool size ...
// TODO Cutting spindle movement ...
$this->setCode("{$plane} {$motion} X{$of} Y{$y} I{$radius} J0.00 Z{$z}");
$this->setCode("G0 Z{$this->spindleAxisStartPosition} (axis spindle start position)");
$this->setCode("(/circle)\n");
}
if ($plane == 'G18') {
// G18 is disabled
return;
}
if ($plane == 'G19') {
// G19 is disabled
return;
}
return $this;
} | [
"public",
"function",
"drawCircle",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"z",
",",
"$",
"radius",
",",
"$",
"motion",
"=",
"'G2'",
",",
"$",
"plane",
"=",
"'G17'",
")",
"{",
"if",
"(",
"$",
"plane",
"==",
"'G17'",
")",
"{",
"$",
"of",
"=",... | Draw a circle on a XY plane
With a certain motion clockwise or anticlockwise for conventional or climb milling
TODO Plane selection
G17 XY Plane
G18 XZ Plane
G19 YZ Plane
Motion control
G2 Clockwise Arcs
G3 Counter-Clockwise Arcs
@param float $x
@param float $y
@param float $z
@param float $radius
@param string $motion
@param string $plane
@return boolean | [
"Draw",
"a",
"circle",
"on",
"a",
"XY",
"plane",
"With",
"a",
"certain",
"motion",
"clockwise",
"or",
"anticlockwise",
"for",
"conventional",
"or",
"climb",
"milling"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/GCode.php#L226-L255 | train |
davro/fabrication | library/GCode.php | GCode.drawBox | public function drawBox($x1, $y1, $z1, $x2, $y2, $z2)
{
$this->setCode("(box)");
$this->setCode("G0 X{$x1} Y{$y1} Z{$this->spindleAxisStartPosition} (move to spindle axis start position)");
$this->setCode("G1 Z{$z1}");
$this->setCode("G1 X{$x1} Y{$y1} Z{$z1}");
$this->setCode("G1 Y{$y2}");
$this->setCode("G1 X{$x2}");
$this->setCode("G1 Y{$y1}");
$this->setCode("G1 X{$x1}");
$this->setCode("G0 Z{$z2}");
$this->setCode("(/box)\n");
return $this;
} | php | public function drawBox($x1, $y1, $z1, $x2, $y2, $z2)
{
$this->setCode("(box)");
$this->setCode("G0 X{$x1} Y{$y1} Z{$this->spindleAxisStartPosition} (move to spindle axis start position)");
$this->setCode("G1 Z{$z1}");
$this->setCode("G1 X{$x1} Y{$y1} Z{$z1}");
$this->setCode("G1 Y{$y2}");
$this->setCode("G1 X{$x2}");
$this->setCode("G1 Y{$y1}");
$this->setCode("G1 X{$x1}");
$this->setCode("G0 Z{$z2}");
$this->setCode("(/box)\n");
return $this;
} | [
"public",
"function",
"drawBox",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"z1",
",",
"$",
"x2",
",",
"$",
"y2",
",",
"$",
"z2",
")",
"{",
"$",
"this",
"->",
"setCode",
"(",
"\"(box)\"",
")",
";",
"$",
"this",
"->",
"setCode",
"(",
"\"G0 X{$x1}... | Draw a box on a XY plane
@param float $x1
@param float $y1
@param float $z1
@param float $x2
@param float $y2
@param float $z2
@return \GCode | [
"Draw",
"a",
"box",
"on",
"a",
"XY",
"plane"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/GCode.php#L268-L282 | train |
davro/fabrication | library/GCode.php | GCode.drawLine | public function drawLine($xStart, $yStart, $zStart, $xEnd, $yEnd, $zEnd)
{
$this->setCode("(line)");
$this->setCode("G0 X{$xStart} Y{$yStart} Z{$this->spindleAxisStartPosition}");
$this->setCode("G1 Z{$zStart}");
// testing tool setup tool metric M8 diameter 4mm
$this->setCode("T1 M08");
$this->setCode("G41 D4");
$this->setCode("G1 X{$xStart} Y{$yStart} Z{$zStart}");
$this->setCode("G1 X{$xEnd} Y{$yEnd} Z{$zEnd}");
$this->setCode("G0 Z{$this->spindleAxisStartPosition}");
$this->setCode("G0 X{$xStart} Y{$yStart}");
$this->setCode("(/line)\n");
return $this;
} | php | public function drawLine($xStart, $yStart, $zStart, $xEnd, $yEnd, $zEnd)
{
$this->setCode("(line)");
$this->setCode("G0 X{$xStart} Y{$yStart} Z{$this->spindleAxisStartPosition}");
$this->setCode("G1 Z{$zStart}");
// testing tool setup tool metric M8 diameter 4mm
$this->setCode("T1 M08");
$this->setCode("G41 D4");
$this->setCode("G1 X{$xStart} Y{$yStart} Z{$zStart}");
$this->setCode("G1 X{$xEnd} Y{$yEnd} Z{$zEnd}");
$this->setCode("G0 Z{$this->spindleAxisStartPosition}");
$this->setCode("G0 X{$xStart} Y{$yStart}");
$this->setCode("(/line)\n");
return $this;
} | [
"public",
"function",
"drawLine",
"(",
"$",
"xStart",
",",
"$",
"yStart",
",",
"$",
"zStart",
",",
"$",
"xEnd",
",",
"$",
"yEnd",
",",
"$",
"zEnd",
")",
"{",
"$",
"this",
"->",
"setCode",
"(",
"\"(line)\"",
")",
";",
"$",
"this",
"->",
"setCode",
... | Draw a line on a XY plane
@param float $xStart
@param float $yStart
@param float $zStart
@param float $xEnd
@param float $yEnd
@param float $zEnd
@return \GCode | [
"Draw",
"a",
"line",
"on",
"a",
"XY",
"plane"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/GCode.php#L295-L313 | train |
davro/fabrication | library/GCode.php | GCode.drawCubicSpline | public function drawCubicSpline($xStart, $yStart, $xFromEnd, $yFromEnd, $xEnd, $yEnd)
{
$this->setCode("(cubic spline)");
$this->setCode("G0 X{$xStart} Y{$yStart} Z{$this->spindleAxisStartPosition}");
// $this->setCode("G1 Z{$zStart}");
// G5 Cubic spline
$this->setCode("G5 I{$xStart} J{$yStart} P{$xFromEnd} Q-{$yFromEnd} X{$xEnd} Y{$yEnd}");
$this->setCode("G0 Z{$this->spindleAxisStartPosition}");
$this->setCode("G0 X{$xStart} Y{$yStart}");
$this->setCode("(/cubic spline)");
return $this;
} | php | public function drawCubicSpline($xStart, $yStart, $xFromEnd, $yFromEnd, $xEnd, $yEnd)
{
$this->setCode("(cubic spline)");
$this->setCode("G0 X{$xStart} Y{$yStart} Z{$this->spindleAxisStartPosition}");
// $this->setCode("G1 Z{$zStart}");
// G5 Cubic spline
$this->setCode("G5 I{$xStart} J{$yStart} P{$xFromEnd} Q-{$yFromEnd} X{$xEnd} Y{$yEnd}");
$this->setCode("G0 Z{$this->spindleAxisStartPosition}");
$this->setCode("G0 X{$xStart} Y{$yStart}");
$this->setCode("(/cubic spline)");
return $this;
} | [
"public",
"function",
"drawCubicSpline",
"(",
"$",
"xStart",
",",
"$",
"yStart",
",",
"$",
"xFromEnd",
",",
"$",
"yFromEnd",
",",
"$",
"xEnd",
",",
"$",
"yEnd",
")",
"{",
"$",
"this",
"->",
"setCode",
"(",
"\"(cubic spline)\"",
")",
";",
"$",
"this",
... | G5 creates a cubic B-spline in the XY plane with the X and Y axes only.
P and Q must both be specified for every G5 command.
@param float $xStart
@param float $yStart
@param float $xFromEnd
@param float $yFromEnd
@param float $xEnd
@param float $yEnd
@return \GCode | [
"G5",
"creates",
"a",
"cubic",
"B",
"-",
"spline",
"in",
"the",
"XY",
"plane",
"with",
"the",
"X",
"and",
"Y",
"axes",
"only",
".",
"P",
"and",
"Q",
"must",
"both",
"be",
"specified",
"for",
"every",
"G5",
"command",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/GCode.php#L327-L341 | train |
orchestral/notifier | src/Handlers/Handler.php | Handler.createMessageCallback | protected function createMessageCallback(Recipient $user, $subject = null, $callback = null)
{
return function (Message $message) use ($user, $subject, $callback) {
// Set the recipient detail.
$message->to($user->getRecipientEmail(), $user->getRecipientName());
// Only append the subject if it was provided.
! empty($subject) && $message->subject($subject);
// Run any callback if provided.
\is_callable($callback) && $callback(...func_get_args());
};
} | php | protected function createMessageCallback(Recipient $user, $subject = null, $callback = null)
{
return function (Message $message) use ($user, $subject, $callback) {
// Set the recipient detail.
$message->to($user->getRecipientEmail(), $user->getRecipientName());
// Only append the subject if it was provided.
! empty($subject) && $message->subject($subject);
// Run any callback if provided.
\is_callable($callback) && $callback(...func_get_args());
};
} | [
"protected",
"function",
"createMessageCallback",
"(",
"Recipient",
"$",
"user",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"return",
"function",
"(",
"Message",
"$",
"message",
")",
"use",
"(",
"$",
"user",
",",
"$",
... | Create message callback.
@param \Orchestra\Contracts\Notification\Recipient $user
@param string|null $subject
@param callable|null $callback
@return \Closure | [
"Create",
"message",
"callback",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Handlers/Handler.php#L19-L31 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Route/Utility.php | Utility.getRoute | public function getRoute()
{
/** @var Http $req */
$req = $this->context->getRequest();
if (isset($this->map[$req->getControllerName()])) {
return $this->map[$req->getControllerName()];
}
return $this->map[Generic::CONTROLLER_KEY];
} | php | public function getRoute()
{
/** @var Http $req */
$req = $this->context->getRequest();
if (isset($this->map[$req->getControllerName()])) {
return $this->map[$req->getControllerName()];
}
return $this->map[Generic::CONTROLLER_KEY];
} | [
"public",
"function",
"getRoute",
"(",
")",
"{",
"/** @var Http $req */",
"$",
"req",
"=",
"$",
"this",
"->",
"context",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"req",
"->",
"getControllerName",
"... | Retrieves the correct route based on
the current controller
@return TypeInterface | [
"Retrieves",
"the",
"correct",
"route",
"based",
"on",
"the",
"current",
"controller"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Route/Utility.php#L54-L63 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Payment/Retriever.php | Retriever.getPaymentMethods | public function getPaymentMethods()
{
$this->quote->setStoreId($this->storeManager->getStore()->getId());
$export = [];
$paymentMethods = $this->paymentModel->getAvailableMethods($this->quote);
foreach ($paymentMethods as $method) {
$export[] = [
'id' => $method->getCode(),
'title' => $method->getTitle(),
'is_active' => 1
];
}
return $export;
} | php | public function getPaymentMethods()
{
$this->quote->setStoreId($this->storeManager->getStore()->getId());
$export = [];
$paymentMethods = $this->paymentModel->getAvailableMethods($this->quote);
foreach ($paymentMethods as $method) {
$export[] = [
'id' => $method->getCode(),
'title' => $method->getTitle(),
'is_active' => 1
];
}
return $export;
} | [
"public",
"function",
"getPaymentMethods",
"(",
")",
"{",
"$",
"this",
"->",
"quote",
"->",
"setStoreId",
"(",
"$",
"this",
"->",
"storeManager",
"->",
"getStore",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"$",
"export",
"=",
"[",
"]",
";",
"$",
... | Retrieves all available payment methods and formats
them to Shopgate Merchant API ready format
@return array() - e.g. ['id' => 'checkmo', 'title' => 'Money Order', 'is_active' => 1] | [
"Retrieves",
"all",
"available",
"payment",
"methods",
"and",
"formats",
"them",
"to",
"Shopgate",
"Merchant",
"API",
"ready",
"format"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Payment/Retriever.php#L65-L81 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Builder.php | Builder.buildHttpRedirect | public function buildHttpRedirect()
{
if (!is_null($this->http)) {
return $this->http;
}
$builder = new ShopgateBuilder($this->initConfig());
$userAgent = $this->header->getHttpUserAgent();
try {
$this->http = $builder->buildHttpRedirect($userAgent, $this->request->getParams(), $_COOKIE);
} catch (\ShopgateMerchantApiException $e) {
$this->logger->error('HTTP > oAuth access token for store not set: ' . $e->getMessage());
return null;
} catch (\Exception $e) {
$this->logger->error('HTTP > error in HTTP redirect: ' . $e->getMessage());
return null;
}
return $this->http;
} | php | public function buildHttpRedirect()
{
if (!is_null($this->http)) {
return $this->http;
}
$builder = new ShopgateBuilder($this->initConfig());
$userAgent = $this->header->getHttpUserAgent();
try {
$this->http = $builder->buildHttpRedirect($userAgent, $this->request->getParams(), $_COOKIE);
} catch (\ShopgateMerchantApiException $e) {
$this->logger->error('HTTP > oAuth access token for store not set: ' . $e->getMessage());
return null;
} catch (\Exception $e) {
$this->logger->error('HTTP > error in HTTP redirect: ' . $e->getMessage());
return null;
}
return $this->http;
} | [
"public",
"function",
"buildHttpRedirect",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"http",
")",
")",
"{",
"return",
"$",
"this",
"->",
"http",
";",
"}",
"$",
"builder",
"=",
"new",
"ShopgateBuilder",
"(",
"$",
"this",
"->",
... | Instantiates the HTTP redirect object
@return Shopgate_Helper_Redirect_Type_Http | null | [
"Instantiates",
"the",
"HTTP",
"redirect",
"object"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Builder.php#L84-L106 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Builder.php | Builder.buildJsRedirect | public function buildJsRedirect()
{
if (!is_null($this->js)) {
return $this->js;
}
$builder = new ShopgateBuilder($this->initConfig());
try {
$this->js = $builder->buildJsRedirect($this->request->getParams(), $_COOKIE);
} catch (\ShopgateMerchantApiException $e) {
$this->logger->error('JS > oAuth access token for store not set: ' . $e->getMessage());
return null;
} catch (\Exception $e) {
$this->logger->error('JS > error in HTTP redirect: ' . $e->getMessage());
return null;
}
return $this->js;
} | php | public function buildJsRedirect()
{
if (!is_null($this->js)) {
return $this->js;
}
$builder = new ShopgateBuilder($this->initConfig());
try {
$this->js = $builder->buildJsRedirect($this->request->getParams(), $_COOKIE);
} catch (\ShopgateMerchantApiException $e) {
$this->logger->error('JS > oAuth access token for store not set: ' . $e->getMessage());
return null;
} catch (\Exception $e) {
$this->logger->error('JS > error in HTTP redirect: ' . $e->getMessage());
return null;
}
return $this->js;
} | [
"public",
"function",
"buildJsRedirect",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"js",
")",
")",
"{",
"return",
"$",
"this",
"->",
"js",
";",
"}",
"$",
"builder",
"=",
"new",
"ShopgateBuilder",
"(",
"$",
"this",
"->",
"ini... | Instantiates the JS script builder object
@return Shopgate_Helper_Redirect_Type_Js | null | [
"Instantiates",
"the",
"JS",
"script",
"builder",
"object"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Builder.php#L126-L147 | train |
BerliozFramework/Berlioz | src/Entity/Pagination.php | Pagination.prepare | public function prepare(OptionList $objOptions = null): OptionList
{
if (is_null($objOptions)) {
$objOptions = new OptionList;
}
// Page
if ('post' == $this->options->get('method')) {
$requestBody = $this->serverRequest->getParsedBody();
if (is_array($requestBody) && !empty($requestBody[$this->getParam()])) {
$this->page = intval($requestBody[$this->getParam()]);
} else {
$this->page = 1;
}
} else {
$queryParams = $this->serverRequest->getQueryParams();
if (is_array($queryParams) && !empty($queryParams[$this->getParam()])) {
$this->page = intval($queryParams[$this->getParam()]);
} else {
$this->page = 1;
}
}
// Nb per page
$this->nb_per_page = $this->options->is_int('nb_per_page') ? $this->options->get('nb_per_page') : 20;
// Obj _b_options
$objOptions->set('limitStart', $this->nb_per_page * ($this->page - 1));
$objOptions->set('limitEnd', $objOptions->get('limitStart') + $this->nb_per_page);
$objOptions->set('limitNb', $this->nb_per_page);
return $objOptions;
} | php | public function prepare(OptionList $objOptions = null): OptionList
{
if (is_null($objOptions)) {
$objOptions = new OptionList;
}
// Page
if ('post' == $this->options->get('method')) {
$requestBody = $this->serverRequest->getParsedBody();
if (is_array($requestBody) && !empty($requestBody[$this->getParam()])) {
$this->page = intval($requestBody[$this->getParam()]);
} else {
$this->page = 1;
}
} else {
$queryParams = $this->serverRequest->getQueryParams();
if (is_array($queryParams) && !empty($queryParams[$this->getParam()])) {
$this->page = intval($queryParams[$this->getParam()]);
} else {
$this->page = 1;
}
}
// Nb per page
$this->nb_per_page = $this->options->is_int('nb_per_page') ? $this->options->get('nb_per_page') : 20;
// Obj _b_options
$objOptions->set('limitStart', $this->nb_per_page * ($this->page - 1));
$objOptions->set('limitEnd', $objOptions->get('limitStart') + $this->nb_per_page);
$objOptions->set('limitNb', $this->nb_per_page);
return $objOptions;
} | [
"public",
"function",
"prepare",
"(",
"OptionList",
"$",
"objOptions",
"=",
"null",
")",
":",
"OptionList",
"{",
"if",
"(",
"is_null",
"(",
"$",
"objOptions",
")",
")",
"{",
"$",
"objOptions",
"=",
"new",
"OptionList",
";",
"}",
"// Page",
"if",
"(",
"... | Prepare the OptionList for Collection.
This method complete OptionList for Collection with some
_b_options for SQL query like limitStart, limitEnd and limitNb.
This _b_options must be implemented in DB queries in Collection
get methods.
@param OptionList $objOptions OptionList object with _b_options for Collection object
@return OptionList OptionList given in param completed | [
"Prepare",
"the",
"OptionList",
"for",
"Collection",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Pagination.php#L137-L171 | train |
BerliozFramework/Berlioz | src/Entity/Pagination.php | Pagination.handle | public function handle($mixed): Pagination
{
if ($mixed instanceof Collection) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max(count($mixed), 1) / max($this->nb_per_page, 1));
} else {
if ($mixed instanceof \Countable) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max(count($mixed), 1) / max($this->nb_per_page, 1));
} else {
if (is_int($mixed)) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max($mixed, 1) / max($this->nb_per_page, 1));
} else {
trigger_error('Parameter of Pagination::handle must be an Collection object or integer', E_USER_WARNING);
}
}
}
return $this;
} | php | public function handle($mixed): Pagination
{
if ($mixed instanceof Collection) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max(count($mixed), 1) / max($this->nb_per_page, 1));
} else {
if ($mixed instanceof \Countable) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max(count($mixed), 1) / max($this->nb_per_page, 1));
} else {
if (is_int($mixed)) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max($mixed, 1) / max($this->nb_per_page, 1));
} else {
trigger_error('Parameter of Pagination::handle must be an Collection object or integer', E_USER_WARNING);
}
}
}
return $this;
} | [
"public",
"function",
"handle",
"(",
"$",
"mixed",
")",
":",
"Pagination",
"{",
"if",
"(",
"$",
"mixed",
"instanceof",
"Collection",
")",
"{",
"$",
"this",
"->",
"mixed",
"=",
"$",
"mixed",
";",
"$",
"this",
"->",
"nb_pages",
"=",
"ceil",
"(",
"max",... | Called to complete the Pagination object with the number of elements.
Need to call this method after to get elements with Collection.
If no Collection method used, need to pass an integer with value of number
of elements.
@param \Berlioz\Core\Entity\Collection|\Countable|int $mixed Collection with nbTotal property completed or
integer
@return static | [
"Called",
"to",
"complete",
"the",
"Pagination",
"object",
"with",
"the",
"number",
"of",
"elements",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Pagination.php#L185-L205 | train |
BerliozFramework/Berlioz | src/Entity/Pagination.php | Pagination.canBeShowed | public function canBeShowed(): bool
{
return ($this->mixed instanceof Collection || $this->mixed instanceof \Countable || is_int($this->mixed));
} | php | public function canBeShowed(): bool
{
return ($this->mixed instanceof Collection || $this->mixed instanceof \Countable || is_int($this->mixed));
} | [
"public",
"function",
"canBeShowed",
"(",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"this",
"->",
"mixed",
"instanceof",
"Collection",
"||",
"$",
"this",
"->",
"mixed",
"instanceof",
"\\",
"Countable",
"||",
"is_int",
"(",
"$",
"this",
"->",
"mixed",
")... | If Pagination can be showed.
@return bool | [
"If",
"Pagination",
"can",
"be",
"showed",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Pagination.php#L212-L215 | train |
BerliozFramework/Berlioz | src/Entity/Pagination.php | Pagination.getParam | public function getParam(): string
{
if ($this->options->is_null('param')) {
$this->options->set('param', 'page' . (1 == self::$iPagination ? '' : self::$iPagination));
}
return $this->options->get('param');
} | php | public function getParam(): string
{
if ($this->options->is_null('param')) {
$this->options->set('param', 'page' . (1 == self::$iPagination ? '' : self::$iPagination));
}
return $this->options->get('param');
} | [
"public",
"function",
"getParam",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"->",
"is_null",
"(",
"'param'",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"set",
"(",
"'param'",
",",
"'page'",
".",
"(",
"1",
"==",
... | Get the GET or POST parameter name.
@return string | [
"Get",
"the",
"GET",
"or",
"POST",
"parameter",
"name",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Pagination.php#L222-L229 | train |
BerliozFramework/Berlioz | src/Entity/Pagination.php | Pagination.getHttpQueryString | public function getHttpQueryString(array $moreQuery = null): string
{
$queries = [];
if (!(is_null($this->page) || 1 == $this->page)) {
$queries[$this->getParam()] = $this->page;
}
if (!empty($moreQuery)) {
$queries = array_merge($queries, $moreQuery);
}
return !empty($queries) ? '?' . http_build_query($queries) : '';
} | php | public function getHttpQueryString(array $moreQuery = null): string
{
$queries = [];
if (!(is_null($this->page) || 1 == $this->page)) {
$queries[$this->getParam()] = $this->page;
}
if (!empty($moreQuery)) {
$queries = array_merge($queries, $moreQuery);
}
return !empty($queries) ? '?' . http_build_query($queries) : '';
} | [
"public",
"function",
"getHttpQueryString",
"(",
"array",
"$",
"moreQuery",
"=",
"null",
")",
":",
"string",
"{",
"$",
"queries",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"(",
"is_null",
"(",
"$",
"this",
"->",
"page",
")",
"||",
"1",
"==",
"$",
"this",... | Get query string part of URL for navigation between pages.
@param array $moreQuery Additional query string parameters
@return string Query string part of URL | [
"Get",
"query",
"string",
"part",
"of",
"URL",
"for",
"navigation",
"between",
"pages",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Entity/Pagination.php#L238-L251 | train |
mothership-gmbh/state_machine | src/StateMachineAbstract.php | StateMachineAbstract.parseYAML | protected function parseYAML()
{
try {
$yaml = $this->configuration;
$yaml_fixed = [];
$yaml_fixed['class'] = $yaml['class'];
foreach ($yaml['states'] as $key => $value) {
if ($value['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL && $value['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
$state = [
'name' => $key,
'type' => $value['type'],
'transitions_from' => $value['transitions_from'],
'transitions_to' => $value['transitions_to'],
];
$yaml_fixed['states'][] = $state;
} else {
$state = [
'name' => $key,
'type' => $value['type'],
];
$yaml_fixed['states'][] = $state;
}
}
$yaml_fixed['yaml'] = $this->configuration;
return $yaml_fixed;
} catch (\Symfony\Component\Yaml\Exception\ParseException $ex) {
throw $ex;
}
} | php | protected function parseYAML()
{
try {
$yaml = $this->configuration;
$yaml_fixed = [];
$yaml_fixed['class'] = $yaml['class'];
foreach ($yaml['states'] as $key => $value) {
if ($value['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL && $value['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
$state = [
'name' => $key,
'type' => $value['type'],
'transitions_from' => $value['transitions_from'],
'transitions_to' => $value['transitions_to'],
];
$yaml_fixed['states'][] = $state;
} else {
$state = [
'name' => $key,
'type' => $value['type'],
];
$yaml_fixed['states'][] = $state;
}
}
$yaml_fixed['yaml'] = $this->configuration;
return $yaml_fixed;
} catch (\Symfony\Component\Yaml\Exception\ParseException $ex) {
throw $ex;
}
} | [
"protected",
"function",
"parseYAML",
"(",
")",
"{",
"try",
"{",
"$",
"yaml",
"=",
"$",
"this",
"->",
"configuration",
";",
"$",
"yaml_fixed",
"=",
"[",
"]",
";",
"$",
"yaml_fixed",
"[",
"'class'",
"]",
"=",
"$",
"yaml",
"[",
"'class'",
"]",
";",
"... | Parse the yaml configuration.
@return array
@throws \Symfony\Component\Yaml\Exception\ParseException
@throws \Exception | [
"Parse",
"the",
"yaml",
"configuration",
"."
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/StateMachineAbstract.php#L80-L110 | train |
mothership-gmbh/state_machine | src/StateMachineAbstract.php | StateMachineAbstract.initWorkflow | protected function initWorkflow()
{
$className = $this->workflowConfiguration['class']['name'];
if (!class_exists($className, true)) {
throw new StateMachineException('The class ' . $className . ' does not exist!', 100);
}
try {
$this->workflow = new $className($this->workflowConfiguration);
} catch (WorkflowException $ex) {
throw new StateMachineException('Workflow with some problems', 90, $ex);
}
} | php | protected function initWorkflow()
{
$className = $this->workflowConfiguration['class']['name'];
if (!class_exists($className, true)) {
throw new StateMachineException('The class ' . $className . ' does not exist!', 100);
}
try {
$this->workflow = new $className($this->workflowConfiguration);
} catch (WorkflowException $ex) {
throw new StateMachineException('Workflow with some problems', 90, $ex);
}
} | [
"protected",
"function",
"initWorkflow",
"(",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"workflowConfiguration",
"[",
"'class'",
"]",
"[",
"'name'",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
",",
"true",
")",
")",
"{",
... | Create the workflow.
@throws \Mothership\StateMachine\Exception\StateMachineException | [
"Create",
"the",
"workflow",
"."
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/StateMachineAbstract.php#L117-L130 | train |
mothership-gmbh/state_machine | src/StateMachineAbstract.php | StateMachineAbstract.renderGraph | public function renderGraph($outputPath = './workflow.png', $stopAfterExecution = true)
{
/*
* This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/
* Feel free to tweak the rendering output. I have decided do use the most simple
* implementation over the fancy stuff to avoid additional complexity.
*/
$template
= '
digraph finite_state_machine {
rankdir=LR;
size="%d"
node [shape = doublecircle]; start;
node [shape = circle];
%s
}
';
$pattern = ' %s -> %s [ label = "%s" ];';
$_transitions = [];
foreach ($this->workflowConfiguration['states'] as $state) {
if (array_key_exists('transitions_from', $state)) {
$transitions_from = $state['transitions_from'];
foreach ($transitions_from as $from) {
if (is_array($from)) {
$_transitions[] = sprintf(
$pattern,
$from['status'],
$state['name'],
'<< IF '
. $this->convertToStringCondition($from['result']) . ' >>' . $state['name']
);
} else {
$_transitions[] = sprintf($pattern, $from, $state['name'], $state['name']);
}
}
} else {
if ('type' == 'exception') {
$_transitions[] = 'node [shape = doublecircle]; exception;';
}
}
}
file_put_contents('/tmp/sm.gv', sprintf($template, count($_transitions) * 2, implode("\n", $_transitions)));
shell_exec('dot -Tpng /tmp/sm.gv -o ' . $outputPath);
if ($stopAfterExecution) {
//exit;
}
} | php | public function renderGraph($outputPath = './workflow.png', $stopAfterExecution = true)
{
/*
* This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/
* Feel free to tweak the rendering output. I have decided do use the most simple
* implementation over the fancy stuff to avoid additional complexity.
*/
$template
= '
digraph finite_state_machine {
rankdir=LR;
size="%d"
node [shape = doublecircle]; start;
node [shape = circle];
%s
}
';
$pattern = ' %s -> %s [ label = "%s" ];';
$_transitions = [];
foreach ($this->workflowConfiguration['states'] as $state) {
if (array_key_exists('transitions_from', $state)) {
$transitions_from = $state['transitions_from'];
foreach ($transitions_from as $from) {
if (is_array($from)) {
$_transitions[] = sprintf(
$pattern,
$from['status'],
$state['name'],
'<< IF '
. $this->convertToStringCondition($from['result']) . ' >>' . $state['name']
);
} else {
$_transitions[] = sprintf($pattern, $from, $state['name'], $state['name']);
}
}
} else {
if ('type' == 'exception') {
$_transitions[] = 'node [shape = doublecircle]; exception;';
}
}
}
file_put_contents('/tmp/sm.gv', sprintf($template, count($_transitions) * 2, implode("\n", $_transitions)));
shell_exec('dot -Tpng /tmp/sm.gv -o ' . $outputPath);
if ($stopAfterExecution) {
//exit;
}
} | [
"public",
"function",
"renderGraph",
"(",
"$",
"outputPath",
"=",
"'./workflow.png'",
",",
"$",
"stopAfterExecution",
"=",
"true",
")",
"{",
"/*\n * This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/\n * Feel free to tweak the rendering... | create a graph for the state machine.
@param string $outputPath relative path of the generated image
@param bool|false $stopAfterExecution if we want to exit after graphic generation
@return void | [
"create",
"a",
"graph",
"for",
"the",
"state",
"machine",
"."
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/StateMachineAbstract.php#L140-L191 | train |
mothership-gmbh/state_machine | src/StateMachineAbstract.php | StateMachineAbstract.run | public function run(array $args = [], $enableLog = false)
{
try {
return $this->workflow->run($args, $enableLog);
} catch (WorkflowException $ex) {
throw new StateMachineException('Error running State Machine', 100, $ex);
}
} | php | public function run(array $args = [], $enableLog = false)
{
try {
return $this->workflow->run($args, $enableLog);
} catch (WorkflowException $ex) {
throw new StateMachineException('Error running State Machine', 100, $ex);
}
} | [
"public",
"function",
"run",
"(",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"enableLog",
"=",
"false",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"workflow",
"->",
"run",
"(",
"$",
"args",
",",
"$",
"enableLog",
")",
";",
"}",
"catch... | Run the state machine with optional arguments.
@param array $args
@param bool $enableLog
@return mixed
@throws StateMachineException | [
"Run",
"the",
"state",
"machine",
"with",
"optional",
"arguments",
"."
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/StateMachineAbstract.php#L203-L210 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Route/Tags/Generic.php | Generic.generate | public function generate($pageTitle)
{
return [
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_SITENAME => $this->getSiteName(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_DESKTOP_URL => $this->getShopUrl(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_MOBILE_WEB_URL => $this->getMobileUrl(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_TITLE => $pageTitle
];
} | php | public function generate($pageTitle)
{
return [
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_SITENAME => $this->getSiteName(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_DESKTOP_URL => $this->getShopUrl(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_MOBILE_WEB_URL => $this->getMobileUrl(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_TITLE => $pageTitle
];
} | [
"public",
"function",
"generate",
"(",
"$",
"pageTitle",
")",
"{",
"return",
"[",
"Shopgate_Helper_Redirect_TagsGenerator",
"::",
"SITE_PARAMETER_SITENAME",
"=>",
"$",
"this",
"->",
"getSiteName",
"(",
")",
",",
"Shopgate_Helper_Redirect_TagsGenerator",
"::",
"SITE_PARA... | Generates a default set of tags
@param string $pageTitle
@return array
@throws \Magento\Framework\Exception\LocalizedException | [
"Generates",
"a",
"default",
"set",
"of",
"tags"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Route/Tags/Generic.php#L56-L64 | train |
webeweb/core-library | src/Network/CURL/Factory/CURLFactory.php | CURLFactory.getInstance | public static function getInstance($method, CURLConfiguration $configuration = null, $resourcePath = null) {
// Check the configuration.
if (null === $configuration) {
$configuration = new CURLConfiguration();
}
// Switch into $method.
switch ($method) {
case self::HTTP_METHOD_DELETE:
return new CURLDeleteRequest($configuration, $resourcePath);
case self::HTTP_METHOD_GET:
return new CURLGetRequest($configuration, $resourcePath);
case self::HTTP_METHOD_HEAD:
return new CURLHeadRequest($configuration, $resourcePath);
case self::HTTP_METHOD_OPTIONS:
return new CURLOptionsRequest($configuration, $resourcePath);
case self::HTTP_METHOD_PATCH:
return new CURLPatchRequest($configuration, $resourcePath);
case self::HTTP_METHOD_POST:
return new CURLPostRequest($configuration, $resourcePath);
case self::HTTP_METHOD_PUT:
return new CURLPutRequest($configuration, $resourcePath);
default:
throw new InvalidHTTPMethodException($method);
}
} | php | public static function getInstance($method, CURLConfiguration $configuration = null, $resourcePath = null) {
// Check the configuration.
if (null === $configuration) {
$configuration = new CURLConfiguration();
}
// Switch into $method.
switch ($method) {
case self::HTTP_METHOD_DELETE:
return new CURLDeleteRequest($configuration, $resourcePath);
case self::HTTP_METHOD_GET:
return new CURLGetRequest($configuration, $resourcePath);
case self::HTTP_METHOD_HEAD:
return new CURLHeadRequest($configuration, $resourcePath);
case self::HTTP_METHOD_OPTIONS:
return new CURLOptionsRequest($configuration, $resourcePath);
case self::HTTP_METHOD_PATCH:
return new CURLPatchRequest($configuration, $resourcePath);
case self::HTTP_METHOD_POST:
return new CURLPostRequest($configuration, $resourcePath);
case self::HTTP_METHOD_PUT:
return new CURLPutRequest($configuration, $resourcePath);
default:
throw new InvalidHTTPMethodException($method);
}
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"method",
",",
"CURLConfiguration",
"$",
"configuration",
"=",
"null",
",",
"$",
"resourcePath",
"=",
"null",
")",
"{",
"// Check the configuration.",
"if",
"(",
"null",
"===",
"$",
"configuration",
")",
... | Get an instance.
@param string $method The method.
@param CURLConfiguration $configuration The configuration.
@return CURLRequestInterface Returns this request.
@throws InvalidHTTPMethodException Throws an invalid HTTP method exception if the method is not implemented. | [
"Get",
"an",
"instance",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/CURL/Factory/CURLFactory.php#L42-L76 | train |
SaftIng/Saft | src/Saft/Addition/ARC2/Store/ARC2.php | ARC2.createGraph | public function createGraph(NamedNode $graph, array $options = [])
{
if (false === isset($this->getGraphs()[$graph->getUri()])) {
// table names
$g2t = $this->configuration['table-prefix'].'_g2t';
$id2val = $this->configuration['table-prefix'].'_id2val';
/*
* for id2val table
*/
$query = 'INSERT INTO '.$id2val.' (val) VALUES("'.$graph->getUri().'")';
$this->store->queryDB($query, $this->store->getDBCon());
$usedId = $this->store->getDBCon()->insert_id;
/*
* for g2t table
*/
$newIdg2t = 1 + $this->getRowCount($g2t);
$query = 'INSERT INTO '.$g2t.' (t, g) VALUES('.$newIdg2t.', '.$usedId.')';
$this->store->queryDB($query, $this->store->getDBCon());
$usedId = $this->store->getDBCon()->insert_id;
}
} | php | public function createGraph(NamedNode $graph, array $options = [])
{
if (false === isset($this->getGraphs()[$graph->getUri()])) {
// table names
$g2t = $this->configuration['table-prefix'].'_g2t';
$id2val = $this->configuration['table-prefix'].'_id2val';
/*
* for id2val table
*/
$query = 'INSERT INTO '.$id2val.' (val) VALUES("'.$graph->getUri().'")';
$this->store->queryDB($query, $this->store->getDBCon());
$usedId = $this->store->getDBCon()->insert_id;
/*
* for g2t table
*/
$newIdg2t = 1 + $this->getRowCount($g2t);
$query = 'INSERT INTO '.$g2t.' (t, g) VALUES('.$newIdg2t.', '.$usedId.')';
$this->store->queryDB($query, $this->store->getDBCon());
$usedId = $this->store->getDBCon()->insert_id;
}
} | [
"public",
"function",
"createGraph",
"(",
"NamedNode",
"$",
"graph",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"this",
"->",
"getGraphs",
"(",
")",
"[",
"$",
"graph",
"->",
"getUri",
"(",
"... | Create a new graph with the URI given as NamedNode.
@param NamedNode $graph instance of NamedNode containing the URI of the graph to create
@param array $options optional It contains key-value pairs and should provide additional
introductions for the store and/or its adapter(s)
@throws \Exception if the given graph could not be created | [
"Create",
"a",
"new",
"graph",
"with",
"the",
"URI",
"given",
"as",
"NamedNode",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/ARC2/Store/ARC2.php#L211-L233 | train |
SaftIng/Saft | src/Saft/Addition/ARC2/Store/ARC2.php | ARC2.getRowCount | public function getRowCount($tableName)
{
$result = $this->store->queryDB(
'SELECT COUNT(*) as count FROM '.$tableName,
$this->store->getDBCon()
);
$row = $result->fetch_assoc();
return $row['count'];
} | php | public function getRowCount($tableName)
{
$result = $this->store->queryDB(
'SELECT COUNT(*) as count FROM '.$tableName,
$this->store->getDBCon()
);
$row = $result->fetch_assoc();
return $row['count'];
} | [
"public",
"function",
"getRowCount",
"(",
"$",
"tableName",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"store",
"->",
"queryDB",
"(",
"'SELECT COUNT(*) as count FROM '",
".",
"$",
"tableName",
",",
"$",
"this",
"->",
"store",
"->",
"getDBCon",
"(",
"... | Helper function to get the number of rows in a table.
@param string $tableName
@return int number of rows in the target table | [
"Helper",
"function",
"to",
"get",
"the",
"number",
"of",
"rows",
"in",
"a",
"table",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/ARC2/Store/ARC2.php#L366-L375 | train |
SaftIng/Saft | src/Saft/Addition/ARC2/Store/ARC2.php | ARC2.openConnection | protected function openConnection()
{
// set standard values
$this->configuration = array_merge([
'host' => 'localhost',
'database' => '',
'username' => '',
'password' => '',
'table-prefix' => 'saft_',
], $this->configuration);
/*
* check for missing connection credentials
*/
if ('' == $this->configuration['database']) {
throw new \Exception('ARC2: Field database is not set.');
} elseif ('' == $this->configuration['username']) {
throw new \Exception('ARC2: Field username is not set.');
} elseif ('' == $this->configuration['host']) {
throw new \Exception('ARC2: Field host is not set.');
}
// init store
$this->store = \ARC2::getStore([
'db_host' => $this->configuration['host'],
'db_name' => $this->configuration['database'],
'db_user' => $this->configuration['username'],
'db_pwd' => $this->configuration['password'],
'store_name' => $this->configuration['table-prefix'],
]);
} | php | protected function openConnection()
{
// set standard values
$this->configuration = array_merge([
'host' => 'localhost',
'database' => '',
'username' => '',
'password' => '',
'table-prefix' => 'saft_',
], $this->configuration);
/*
* check for missing connection credentials
*/
if ('' == $this->configuration['database']) {
throw new \Exception('ARC2: Field database is not set.');
} elseif ('' == $this->configuration['username']) {
throw new \Exception('ARC2: Field username is not set.');
} elseif ('' == $this->configuration['host']) {
throw new \Exception('ARC2: Field host is not set.');
}
// init store
$this->store = \ARC2::getStore([
'db_host' => $this->configuration['host'],
'db_name' => $this->configuration['database'],
'db_user' => $this->configuration['username'],
'db_pwd' => $this->configuration['password'],
'store_name' => $this->configuration['table-prefix'],
]);
} | [
"protected",
"function",
"openConnection",
"(",
")",
"{",
"// set standard values",
"$",
"this",
"->",
"configuration",
"=",
"array_merge",
"(",
"[",
"'host'",
"=>",
"'localhost'",
",",
"'database'",
"=>",
"''",
",",
"'username'",
"=>",
"''",
",",
"'password'",
... | Creates and sets up an instance of ARC2_Store. | [
"Creates",
"and",
"sets",
"up",
"an",
"instance",
"of",
"ARC2_Store",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/ARC2/Store/ARC2.php#L400-L430 | train |
shopgate/cart-integration-magento2-base | src/Model/Utility/SgProfiler.php | SgProfiler.start | public function start($identifier = null)
{
$this->loadProfile($identifier);
$this->currentProfile->start();
return $this;
} | php | public function start($identifier = null)
{
$this->loadProfile($identifier);
$this->currentProfile->start();
return $this;
} | [
"public",
"function",
"start",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"loadProfile",
"(",
"$",
"identifier",
")",
";",
"$",
"this",
"->",
"currentProfile",
"->",
"start",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Loads and starts a profile.
If nothing is provided, then
it starts a generic profile.
@param string | null $identifier
@return $this | [
"Loads",
"and",
"starts",
"a",
"profile",
".",
"If",
"nothing",
"is",
"provided",
"then",
"it",
"starts",
"a",
"generic",
"profile",
"."
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Utility/SgProfiler.php#L55-L61 | train |
shopgate/cart-integration-magento2-base | src/Model/Utility/SgProfiler.php | SgProfiler.loadProfile | protected function loadProfile($identifier = null)
{
if (!$identifier) {
$identifier = 'generic';
}
if (isset($this->profiles[$identifier])) {
$this->currentProfile = $this->profiles[$identifier];
} else {
$this->currentProfile = new SgProfile();
$this->profiles[$identifier] = $this->currentProfile;
}
return $this->currentProfile;
} | php | protected function loadProfile($identifier = null)
{
if (!$identifier) {
$identifier = 'generic';
}
if (isset($this->profiles[$identifier])) {
$this->currentProfile = $this->profiles[$identifier];
} else {
$this->currentProfile = new SgProfile();
$this->profiles[$identifier] = $this->currentProfile;
}
return $this->currentProfile;
} | [
"protected",
"function",
"loadProfile",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"identifier",
")",
"{",
"$",
"identifier",
"=",
"'generic'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"profiles",
"[",
"$",
"iden... | Retrieves the current profile
@param string | null $identifier
@return SgProfile | [
"Retrieves",
"the",
"current",
"profile"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Utility/SgProfiler.php#L70-L84 | train |
shopgate/cart-integration-magento2-base | src/Model/Utility/SgProfiler.php | SgProfiler.debug | public function debug($message = "%s seconds")
{
$this->logger->debug(sprintf($message, $this->currentProfile->getDuration()));
} | php | public function debug($message = "%s seconds")
{
$this->logger->debug(sprintf($message, $this->currentProfile->getDuration()));
} | [
"public",
"function",
"debug",
"(",
"$",
"message",
"=",
"\"%s seconds\"",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"currentProfile",
"->",
"getDuration",
"(",
")",
")",
")",
";"... | Prints a message to debug log
@param string $message - message needs to contain "%s" to print timing
@return bool | [
"Prints",
"a",
"message",
"to",
"debug",
"log"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Utility/SgProfiler.php#L117-L120 | train |
smirik/php-datetime-ago | src/Smirik/PHPDateTimeAgo/TextTranslator/AbstractTextTranslator.php | AbstractTextTranslator.weeks | public function weeks($weeks)
{
return sprintf($this->formatPattern, $weeks, $this->week_words[$this->pluralization($weeks)]);
} | php | public function weeks($weeks)
{
return sprintf($this->formatPattern, $weeks, $this->week_words[$this->pluralization($weeks)]);
} | [
"public",
"function",
"weeks",
"(",
"$",
"weeks",
")",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"formatPattern",
",",
"$",
"weeks",
",",
"$",
"this",
"->",
"week_words",
"[",
"$",
"this",
"->",
"pluralization",
"(",
"$",
"weeks",
")",
"]",
"... | Returns "weeks ago" like string
@param integer $weeks
@return string | [
"Returns",
"weeks",
"ago",
"like",
"string"
] | 9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39 | https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/TextTranslator/AbstractTextTranslator.php#L44-L47 | train |
smirik/php-datetime-ago | src/Smirik/PHPDateTimeAgo/TextTranslator/AbstractTextTranslator.php | AbstractTextTranslator.months | public function months($months)
{
return sprintf($this->formatPattern, $months, $this->month_words[$this->pluralization($months)]);
} | php | public function months($months)
{
return sprintf($this->formatPattern, $months, $this->month_words[$this->pluralization($months)]);
} | [
"public",
"function",
"months",
"(",
"$",
"months",
")",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"formatPattern",
",",
"$",
"months",
",",
"$",
"this",
"->",
"month_words",
"[",
"$",
"this",
"->",
"pluralization",
"(",
"$",
"months",
")",
"]"... | Returns "months ago" like string
@param integer $months
@return string | [
"Returns",
"months",
"ago",
"like",
"string"
] | 9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39 | https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/TextTranslator/AbstractTextTranslator.php#L54-L57 | train |
smirik/php-datetime-ago | src/Smirik/PHPDateTimeAgo/TextTranslator/AbstractTextTranslator.php | AbstractTextTranslator.years | public function years($years)
{
return sprintf($this->formatPattern, $years, $this->year_words[$this->pluralization($years)]);
} | php | public function years($years)
{
return sprintf($this->formatPattern, $years, $this->year_words[$this->pluralization($years)]);
} | [
"public",
"function",
"years",
"(",
"$",
"years",
")",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"formatPattern",
",",
"$",
"years",
",",
"$",
"this",
"->",
"year_words",
"[",
"$",
"this",
"->",
"pluralization",
"(",
"$",
"years",
")",
"]",
"... | Returns "years ago" like string
@param integer $years
@return string | [
"Returns",
"years",
"ago",
"like",
"string"
] | 9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39 | https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/TextTranslator/AbstractTextTranslator.php#L64-L67 | train |
webeweb/core-library | src/Model/Organizer/TimeSlot.php | TimeSlot.leftJoinWithout | public function leftJoinWithout() {
// Sort and count the time slots.
$buffer = TimeSlotHelper::merge($this->getTimeSlots());
$number = count($buffer);
// Check the time slots count.
if (0 === $number) {
return [$this];
}
// Initialize the output.
$output = [$this];
// Handle each time slot.
for ($i = 0; $i < $number; ++$i) {
//
$j = count($output) - 1;
// Left join without.
$res = TimeSlotHelper::leftJoinWithout($output[$j], $buffer[$i]);
if (null === $res) {
continue;
}
//
$output[$j] = $res[0];
if (2 === count($res)) {
$output[] = $res[1];
}
}
// Return the output.
if (1 === count($output) && $this === $output[0]) {
return [];
}
return $output;
} | php | public function leftJoinWithout() {
// Sort and count the time slots.
$buffer = TimeSlotHelper::merge($this->getTimeSlots());
$number = count($buffer);
// Check the time slots count.
if (0 === $number) {
return [$this];
}
// Initialize the output.
$output = [$this];
// Handle each time slot.
for ($i = 0; $i < $number; ++$i) {
//
$j = count($output) - 1;
// Left join without.
$res = TimeSlotHelper::leftJoinWithout($output[$j], $buffer[$i]);
if (null === $res) {
continue;
}
//
$output[$j] = $res[0];
if (2 === count($res)) {
$output[] = $res[1];
}
}
// Return the output.
if (1 === count($output) && $this === $output[0]) {
return [];
}
return $output;
} | [
"public",
"function",
"leftJoinWithout",
"(",
")",
"{",
"// Sort and count the time slots.",
"$",
"buffer",
"=",
"TimeSlotHelper",
"::",
"merge",
"(",
"$",
"this",
"->",
"getTimeSlots",
"(",
")",
")",
";",
"$",
"number",
"=",
"count",
"(",
"$",
"buffer",
")"... | Left join without.
@return TimeSlot[] Returns the time slots. | [
"Left",
"join",
"without",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlot.php#L115-L153 | train |
webeweb/core-library | src/Model/Organizer/TimeSlot.php | TimeSlot.removeTimeSlot | public function removeTimeSlot(TimeSlot $timeSlot) {
for ($i = count($this->timeSlots) - 1; 0 <= $i; --$i) {
if (true !== TimeSlotHelper::equals($timeSlot, $this->timeSlots[$i])) {
continue;
}
unset($this->timeSlots[$i]);
}
return $this;
} | php | public function removeTimeSlot(TimeSlot $timeSlot) {
for ($i = count($this->timeSlots) - 1; 0 <= $i; --$i) {
if (true !== TimeSlotHelper::equals($timeSlot, $this->timeSlots[$i])) {
continue;
}
unset($this->timeSlots[$i]);
}
return $this;
} | [
"public",
"function",
"removeTimeSlot",
"(",
"TimeSlot",
"$",
"timeSlot",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"this",
"->",
"timeSlots",
")",
"-",
"1",
";",
"0",
"<=",
"$",
"i",
";",
"--",
"$",
"i",
")",
"{",
"if",
"(",
"tru... | Remove a time slot.
@param TimeSlot $timeSlot The time slot.
@return TimeSlot Returns this time slot. | [
"Remove",
"a",
"time",
"slot",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Organizer/TimeSlot.php#L161-L169 | train |
BerliozFramework/Berlioz | src/Config.php | Config.setConfigDirectory | private function setConfigDirectory(string $dirName): void
{
$dirName = realpath($this->getDirectory(Config::DIR_ROOT) . $dirName);
if (is_dir($dirName)) {
$this->configDirectory = $dirName;
} else {
if ($dirName !== false) {
throw new \InvalidArgumentException(sprintf('Directory "%s" does not exists', $dirName));
} else {
throw new \InvalidArgumentException(sprintf('Config directory does not exists', $dirName));
}
}
} | php | private function setConfigDirectory(string $dirName): void
{
$dirName = realpath($this->getDirectory(Config::DIR_ROOT) . $dirName);
if (is_dir($dirName)) {
$this->configDirectory = $dirName;
} else {
if ($dirName !== false) {
throw new \InvalidArgumentException(sprintf('Directory "%s" does not exists', $dirName));
} else {
throw new \InvalidArgumentException(sprintf('Config directory does not exists', $dirName));
}
}
} | [
"private",
"function",
"setConfigDirectory",
"(",
"string",
"$",
"dirName",
")",
":",
"void",
"{",
"$",
"dirName",
"=",
"realpath",
"(",
"$",
"this",
"->",
"getDirectory",
"(",
"Config",
"::",
"DIR_ROOT",
")",
".",
"$",
"dirName",
")",
";",
"if",
"(",
... | Set configuration directory.
@param string $dirName Path of directory
@return void
@throws \InvalidArgumentException If directory doesn't exists | [
"Set",
"configuration",
"directory",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Config.php#L60-L73 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Customer/Retriever.php | Retriever.getCustomerGroups | public function getCustomerGroups()
{
$groups = [];
/** @var GroupInterface $customerGroup */
foreach ($this->customerGroupCollection->getItems() as $customerGroup) {
$group = [];
$group['id'] = $customerGroup->getId();
$group['name'] = $customerGroup->getCode();
$group['is_default'] = intval($customerGroup->getId() == GroupInterface::NOT_LOGGED_IN_ID);
$matchingTaxClasses =
$this->taxCollection->getItemsByColumnValue('class_id', $customerGroup->getTaxClassId());
if (count($matchingTaxClasses)) {
$group['customer_tax_class_key'] = array_pop($matchingTaxClasses)->getClassName();
}
$groups[] = $group;
}
return $groups;
} | php | public function getCustomerGroups()
{
$groups = [];
/** @var GroupInterface $customerGroup */
foreach ($this->customerGroupCollection->getItems() as $customerGroup) {
$group = [];
$group['id'] = $customerGroup->getId();
$group['name'] = $customerGroup->getCode();
$group['is_default'] = intval($customerGroup->getId() == GroupInterface::NOT_LOGGED_IN_ID);
$matchingTaxClasses =
$this->taxCollection->getItemsByColumnValue('class_id', $customerGroup->getTaxClassId());
if (count($matchingTaxClasses)) {
$group['customer_tax_class_key'] = array_pop($matchingTaxClasses)->getClassName();
}
$groups[] = $group;
}
return $groups;
} | [
"public",
"function",
"getCustomerGroups",
"(",
")",
"{",
"$",
"groups",
"=",
"[",
"]",
";",
"/** @var GroupInterface $customerGroup */",
"foreach",
"(",
"$",
"this",
"->",
"customerGroupCollection",
"->",
"getItems",
"(",
")",
"as",
"$",
"customerGroup",
")",
"... | Retrieves Customer Group data
@return array | [
"Retrieves",
"Customer",
"Group",
"data"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Customer/Retriever.php#L53-L75 | train |
inpsyde/inpsyde-validator | src/AbstractValidator.php | AbstractValidator.create_error_message | protected function create_error_message( $message_name, $value ) {
$message = $this->get_message_template( $message_name );
if ( ! is_scalar( $value ) ) {
$value = $this->get_value_as_string( $value );
}
// replacing the placeholder for the %value%
$message = str_replace( '%value%', $value, $message );
// replacing the possible options-placeholder on the message
foreach ( $this->options as $search => $replace ) {
$replace = $this->get_value_as_string( $replace );
$message = str_replace( '%' . $search . '%', $replace, $message );
}
return $message;
} | php | protected function create_error_message( $message_name, $value ) {
$message = $this->get_message_template( $message_name );
if ( ! is_scalar( $value ) ) {
$value = $this->get_value_as_string( $value );
}
// replacing the placeholder for the %value%
$message = str_replace( '%value%', $value, $message );
// replacing the possible options-placeholder on the message
foreach ( $this->options as $search => $replace ) {
$replace = $this->get_value_as_string( $replace );
$message = str_replace( '%' . $search . '%', $replace, $message );
}
return $message;
} | [
"protected",
"function",
"create_error_message",
"(",
"$",
"message_name",
",",
"$",
"value",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"get_message_template",
"(",
"$",
"message_name",
")",
";",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",... | Creating an Error-Message for the given messageName from an messageTemplate.
@param String $message_name
@param String $value
@return Null|String
@deprecated | [
"Creating",
"an",
"Error",
"-",
"Message",
"for",
"the",
"given",
"messageName",
"from",
"an",
"messageTemplate",
"."
] | dcc57f705f142071a1764204bb469eee0bb5015d | https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/AbstractValidator.php#L140-L158 | train |
inpsyde/inpsyde-validator | src/AbstractValidator.php | AbstractValidator.get_value_as_string | protected function get_value_as_string( $value ) {
if ( is_object( $value ) && ! in_array( '__toString', get_class_methods( $value ) ) ) {
$value = get_class( $value ) . ' object';
} else if ( is_array( $value ) ) {
$value = var_export( $value, TRUE );
}
return (string) $value;
} | php | protected function get_value_as_string( $value ) {
if ( is_object( $value ) && ! in_array( '__toString', get_class_methods( $value ) ) ) {
$value = get_class( $value ) . ' object';
} else if ( is_array( $value ) ) {
$value = var_export( $value, TRUE );
}
return (string) $value;
} | [
"protected",
"function",
"get_value_as_string",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"!",
"in_array",
"(",
"'__toString'",
",",
"get_class_methods",
"(",
"$",
"value",
")",
")",
")",
"{",
"$",
"value",
"=",
... | Converts non-scalar values into a readable string.
@param mixed $value
@return string $type
@deprecated | [
"Converts",
"non",
"-",
"scalar",
"values",
"into",
"a",
"readable",
"string",
"."
] | dcc57f705f142071a1764204bb469eee0bb5015d | https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/AbstractValidator.php#L169-L178 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/ZypioSNMP.php | ZypioSNMP.addOid | public function addOid( $oid, $type = STRING, $value= NULL, $allowed = [] ){
$this->tree[$oid] = [ 'type' => $type, 'value' => $value, 'allowed' => $allowed ];
return $this;
} | php | public function addOid( $oid, $type = STRING, $value= NULL, $allowed = [] ){
$this->tree[$oid] = [ 'type' => $type, 'value' => $value, 'allowed' => $allowed ];
return $this;
} | [
"public",
"function",
"addOid",
"(",
"$",
"oid",
",",
"$",
"type",
"=",
"STRING",
",",
"$",
"value",
"=",
"NULL",
",",
"$",
"allowed",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"tree",
"[",
"$",
"oid",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"t... | Add an OID to your base OID
@param string $oid The OID you wish to store data for
@param string $type Your OID type, STRING,Integer, etc
@param multiple $value The value of your OID | [
"Add",
"an",
"OID",
"to",
"your",
"base",
"OID"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/ZypioSNMP.php#L58-L63 | train |
hypeJunction/hypeApps | classes/hypeJunction/Files/Image.php | Image.resize | public function resize($props = array(), $coords = null) {
$croppable = elgg_extract('croppable', $props, false);
$width = elgg_extract('w', $props);
$height = elgg_extract('h', $props);
if (is_array($coords) && $croppable) {
$master_width = elgg_extract('master_width', $coords, self::MASTER);
$master_height = elgg_extract('master_height', $coords, self::MASTER);
$x1 = elgg_extract('x1', $coords, 0);
$y1 = elgg_extract('y1', $coords, 0);
$x2 = elgg_extract('x2', $coords, self::MASTER);
$y2 = elgg_extract('y2', $coords, self::MASTER);
// scale to master size and then crop
$this->source = $this->source->resize($master_width, $master_height, 'inside', 'down')->crop($x1, $y1, $x2 - $x1, $y2 - $y1)->resize($width);
} else if ($croppable) {
// crop to icon width and height
$this->source = $this->source->resize($width, $height, 'outside', 'any')->crop('center', 'center', $width, $height);
} else {
$this->source = $this->source->resize($width, $height, 'inside', 'down');
}
return $this;
} | php | public function resize($props = array(), $coords = null) {
$croppable = elgg_extract('croppable', $props, false);
$width = elgg_extract('w', $props);
$height = elgg_extract('h', $props);
if (is_array($coords) && $croppable) {
$master_width = elgg_extract('master_width', $coords, self::MASTER);
$master_height = elgg_extract('master_height', $coords, self::MASTER);
$x1 = elgg_extract('x1', $coords, 0);
$y1 = elgg_extract('y1', $coords, 0);
$x2 = elgg_extract('x2', $coords, self::MASTER);
$y2 = elgg_extract('y2', $coords, self::MASTER);
// scale to master size and then crop
$this->source = $this->source->resize($master_width, $master_height, 'inside', 'down')->crop($x1, $y1, $x2 - $x1, $y2 - $y1)->resize($width);
} else if ($croppable) {
// crop to icon width and height
$this->source = $this->source->resize($width, $height, 'outside', 'any')->crop('center', 'center', $width, $height);
} else {
$this->source = $this->source->resize($width, $height, 'inside', 'down');
}
return $this;
} | [
"public",
"function",
"resize",
"(",
"$",
"props",
"=",
"array",
"(",
")",
",",
"$",
"coords",
"=",
"null",
")",
"{",
"$",
"croppable",
"=",
"elgg_extract",
"(",
"'croppable'",
",",
"$",
"props",
",",
"false",
")",
";",
"$",
"width",
"=",
"elgg_extra... | Resizes the image to dimensions found in props and crops if coords are provided
@param array $props Properties, including 'w', 'h', 'croppable'
@param array $coords Coordinates, include 'master_width', 'master_height', 'x1', 'y1' etc
@return Image | [
"Resizes",
"the",
"image",
"to",
"dimensions",
"found",
"in",
"props",
"and",
"crops",
"if",
"coords",
"are",
"provided"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Files/Image.php#L31-L57 | train |
hypeJunction/hypeApps | classes/hypeJunction/Files/Image.php | Image.save | public function save($path, $quality = array()) {
$ext = pathinfo($path, PATHINFO_EXTENSION);
$jpeg_quality = elgg_extract('jpeg_quality', $quality);
$png_quality = elgg_extract('png_quality', $quality);
$png_filter = elgg_extract('png_filter', $quality);
switch ($ext) {
default :
$this->source->saveToFile($path, $jpeg_quality);
break;
case 'gif';
$this->source->saveToFile($path);
break;
case 'png' :
$this->source->saveToFile($path, $png_quality, $png_filter);
break;
}
return $this;
} | php | public function save($path, $quality = array()) {
$ext = pathinfo($path, PATHINFO_EXTENSION);
$jpeg_quality = elgg_extract('jpeg_quality', $quality);
$png_quality = elgg_extract('png_quality', $quality);
$png_filter = elgg_extract('png_filter', $quality);
switch ($ext) {
default :
$this->source->saveToFile($path, $jpeg_quality);
break;
case 'gif';
$this->source->saveToFile($path);
break;
case 'png' :
$this->source->saveToFile($path, $png_quality, $png_filter);
break;
}
return $this;
} | [
"public",
"function",
"save",
"(",
"$",
"path",
",",
"$",
"quality",
"=",
"array",
"(",
")",
")",
"{",
"$",
"ext",
"=",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_EXTENSION",
")",
";",
"$",
"jpeg_quality",
"=",
"elgg_extract",
"(",
"'jpeg_quality'",
... | Saves resized image to a file
@param string $path File location
@param quality $quality Quality options
@return Image | [
"Saves",
"resized",
"image",
"to",
"a",
"file"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Files/Image.php#L66-L88 | train |
nabu-3/provider-mysql-driver | CMySQLConnector.php | CMySQLConnector.clearStats | private function clearStats()
{
$this->queries_executed = 0;
$this->queries_released = 0;
$this->queries_erroneous = 0;
$this->sentences_executed = 0;
$this->sentences_erroneous = 0;
$this->inserts_executed = 0;
$this->inserts_erroneous = 0;
$this->updates_executed = 0;
$this->updates_erroneous = 0;
$this->deletes_executed = 0;
$this->deletes_erroneous = 0;
} | php | private function clearStats()
{
$this->queries_executed = 0;
$this->queries_released = 0;
$this->queries_erroneous = 0;
$this->sentences_executed = 0;
$this->sentences_erroneous = 0;
$this->inserts_executed = 0;
$this->inserts_erroneous = 0;
$this->updates_executed = 0;
$this->updates_erroneous = 0;
$this->deletes_executed = 0;
$this->deletes_erroneous = 0;
} | [
"private",
"function",
"clearStats",
"(",
")",
"{",
"$",
"this",
"->",
"queries_executed",
"=",
"0",
";",
"$",
"this",
"->",
"queries_released",
"=",
"0",
";",
"$",
"this",
"->",
"queries_erroneous",
"=",
"0",
";",
"$",
"this",
"->",
"sentences_executed",
... | Reset all stats. | [
"Reset",
"all",
"stats",
"."
] | 85fc8ff326819c3970c933fc65a1e298f92fb017 | https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLConnector.php#L210-L227 | train |
nabu-3/provider-mysql-driver | CMySQLConnector.php | CMySQLConnector.enqueueStatement | public function enqueueStatement(CNabuDBAbstractStatement $statement)
{
if ($statement instanceof CMySQLStatement) {
$hash = $statement->getHash();
if (!is_array($this->statements) || count($this->statements) === 0) {
$this->statements = array($hash => $statement);
} else {
$this->statements[$hash] = $statement;
}
}
} | php | public function enqueueStatement(CNabuDBAbstractStatement $statement)
{
if ($statement instanceof CMySQLStatement) {
$hash = $statement->getHash();
if (!is_array($this->statements) || count($this->statements) === 0) {
$this->statements = array($hash => $statement);
} else {
$this->statements[$hash] = $statement;
}
}
} | [
"public",
"function",
"enqueueStatement",
"(",
"CNabuDBAbstractStatement",
"$",
"statement",
")",
"{",
"if",
"(",
"$",
"statement",
"instanceof",
"CMySQLStatement",
")",
"{",
"$",
"hash",
"=",
"$",
"statement",
"->",
"getHash",
"(",
")",
";",
"if",
"(",
"!",... | Equeues a statement in the stack to control it.
@param CNabuDBAbstractStatement $statement Statement instance to be enqueued. | [
"Equeues",
"a",
"statement",
"in",
"the",
"stack",
"to",
"control",
"it",
"."
] | 85fc8ff326819c3970c933fc65a1e298f92fb017 | https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLConnector.php#L232-L242 | train |
nabu-3/provider-mysql-driver | CMySQLConnector.php | CMySQLConnector.dequeueStatement | public function dequeueStatement(CNabuDBAbstractStatement $statement)
{
if ($statement instanceof CMySQLStatement) {
$hash = $statement->getHash();
if ($hash !== null && count($this->statements) > 0 && array_key_exists($hash, $this->statements)) {
unset($this->statements[$hash]);
}
}
} | php | public function dequeueStatement(CNabuDBAbstractStatement $statement)
{
if ($statement instanceof CMySQLStatement) {
$hash = $statement->getHash();
if ($hash !== null && count($this->statements) > 0 && array_key_exists($hash, $this->statements)) {
unset($this->statements[$hash]);
}
}
} | [
"public",
"function",
"dequeueStatement",
"(",
"CNabuDBAbstractStatement",
"$",
"statement",
")",
"{",
"if",
"(",
"$",
"statement",
"instanceof",
"CMySQLStatement",
")",
"{",
"$",
"hash",
"=",
"$",
"statement",
"->",
"getHash",
"(",
")",
";",
"if",
"(",
"$",... | Dequeues a statement.
@param CNabuDBAbstractStatement $statement Statement instance to be dequeued. | [
"Dequeues",
"a",
"statement",
"."
] | 85fc8ff326819c3970c933fc65a1e298f92fb017 | https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLConnector.php#L247-L255 | train |
nabu-3/provider-mysql-driver | CMySQLConnector.php | CMySQLConnector.clearLeadingAndTrailingSpaces | private function clearLeadingAndTrailingSpaces(string $sentence) : string
{
if ($this->trailing_optimization) {
$sentence = preg_replace('/^\\s+/', '', $sentence);
$sentence = preg_replace('/\\s+$/', '', $sentence);
$sentence = preg_replace('/\\s*\\n\\s*/', ' ', $sentence);
}
return $sentence;
} | php | private function clearLeadingAndTrailingSpaces(string $sentence) : string
{
if ($this->trailing_optimization) {
$sentence = preg_replace('/^\\s+/', '', $sentence);
$sentence = preg_replace('/\\s+$/', '', $sentence);
$sentence = preg_replace('/\\s*\\n\\s*/', ' ', $sentence);
}
return $sentence;
} | [
"private",
"function",
"clearLeadingAndTrailingSpaces",
"(",
"string",
"$",
"sentence",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"trailing_optimization",
")",
"{",
"$",
"sentence",
"=",
"preg_replace",
"(",
"'/^\\\\s+/'",
",",
"''",
",",
"$",
"... | Clean all leading and trailing spaces in a sentence. To prevent to alter literals in the sentence, this method
could to be called before apply variable values.
@param string $sentence Sentence to be cleaned.
@return string Returns the Sentence cleaned if the Leading & Trailing Optimization is enabled. | [
"Clean",
"all",
"leading",
"and",
"trailing",
"spaces",
"in",
"a",
"sentence",
".",
"To",
"prevent",
"to",
"alter",
"literals",
"in",
"the",
"sentence",
"this",
"method",
"could",
"to",
"be",
"called",
"before",
"apply",
"variable",
"values",
"."
] | 85fc8ff326819c3970c933fc65a1e298f92fb017 | https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLConnector.php#L387-L396 | train |
cymapgt/UserCredential | src/traits/UserCredentialAuthenticationLdapTrait.php | UserCredentialAuthenticationLdapTrait.initializeLdap | public function initializeLdap() {
//initialize from parent
$this->initialize();
//validate ldap settings
$ldapSettings = $this->_passwordAuthenticationPlatformSettings;
if(
!(array_key_exists('ldap_account_suffix', $ldapSettings))
||!(array_key_exists('ad_password', $ldapSettings))
|| !(array_key_exists('ad_username', $ldapSettings))
|| !(array_key_exists('base_dn', $ldapSettings))
|| !(array_key_exists('cn_identifier', $ldapSettings))
|| !(array_key_exists('domain_controllers', $ldapSettings))
|| !(array_key_exists('group_attribute', $ldapSettings))
|| !(array_key_exists('group_cn_identifier', $ldapSettings))
|| !(array_key_exists('ldap_server_type', $ldapSettings))
|| !(array_key_exists('network_timeout', $ldapSettings))
|| !(array_key_exists('port', $ldapSettings))
|| !(array_key_exists('recursive_groups', $ldapSettings))
|| !(array_key_exists('time_limit', $ldapSettings))
|| !(array_key_exists('use_ssl', $ldapSettings))
|| !(array_key_exists('cache_support', $ldapSettings))
|| !(array_key_exists('cache_folder', $ldapSettings))
|| !(array_key_exists('expired_password_valid', $ldapSettings))
) {
throw new UserCredentialException("The LDAP feature of the usercredential login service is not initialized with all parameters", 2000);
}
//inject settings to the ldap handler
$this->_passwordAuthenticationPlatformSettings = $ldapSettings;
$this->initializeLdapAuthenticationHandler();
} | php | public function initializeLdap() {
//initialize from parent
$this->initialize();
//validate ldap settings
$ldapSettings = $this->_passwordAuthenticationPlatformSettings;
if(
!(array_key_exists('ldap_account_suffix', $ldapSettings))
||!(array_key_exists('ad_password', $ldapSettings))
|| !(array_key_exists('ad_username', $ldapSettings))
|| !(array_key_exists('base_dn', $ldapSettings))
|| !(array_key_exists('cn_identifier', $ldapSettings))
|| !(array_key_exists('domain_controllers', $ldapSettings))
|| !(array_key_exists('group_attribute', $ldapSettings))
|| !(array_key_exists('group_cn_identifier', $ldapSettings))
|| !(array_key_exists('ldap_server_type', $ldapSettings))
|| !(array_key_exists('network_timeout', $ldapSettings))
|| !(array_key_exists('port', $ldapSettings))
|| !(array_key_exists('recursive_groups', $ldapSettings))
|| !(array_key_exists('time_limit', $ldapSettings))
|| !(array_key_exists('use_ssl', $ldapSettings))
|| !(array_key_exists('cache_support', $ldapSettings))
|| !(array_key_exists('cache_folder', $ldapSettings))
|| !(array_key_exists('expired_password_valid', $ldapSettings))
) {
throw new UserCredentialException("The LDAP feature of the usercredential login service is not initialized with all parameters", 2000);
}
//inject settings to the ldap handler
$this->_passwordAuthenticationPlatformSettings = $ldapSettings;
$this->initializeLdapAuthenticationHandler();
} | [
"public",
"function",
"initializeLdap",
"(",
")",
"{",
"//initialize from parent",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"//validate ldap settings",
"$",
"ldapSettings",
"=",
"$",
"this",
"->",
"_passwordAuthenticationPlatformSettings",
";",
"if",
"(",
"!"... | Check that the initialization parameters array for LDAP authentication is enriched with the
required keys
Cyril Ogana <cogana@gmail.com>
2018
@throws UserCredentialException | [
"Check",
"that",
"the",
"initialization",
"parameters",
"array",
"for",
"LDAP",
"authentication",
"is",
"enriched",
"with",
"the",
"required",
"keys"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/traits/UserCredentialAuthenticationLdapTrait.php#L52-L84 | train |
cymapgt/UserCredential | src/traits/UserCredentialAuthenticationLdapTrait.php | UserCredentialAuthenticationLdapTrait.initializeLdapAuthenticationHandler | protected function initializeLdapAuthenticationHandler() {
$ldapSettings = $this->_passwordAuthenticationPlatformSettings;
$ldapAuthenticationHandler = new MultiotpWrapper();
$ldapAuthenticationHandler->SetLdapServerPassword($this->getCurrentPassword());
$ldapAuthenticationHandler->SetLdapBindDn($this->getCurrentUsername());
$ldapAuthenticationHandler->SetLdapAccountSuffix($ldapSettings['ldap_account_suffix']);
$ldapAuthenticationHandler->SetLdapBaseDn($ldapSettings['base_dn']);
$ldapAuthenticationHandler->SetLdapCnIdentifier($ldapSettings['cn_identifier']);
$ldapAuthenticationHandler->SetLdapDomainControllers($ldapSettings['domain_controllers']);
$ldapAuthenticationHandler->SetLdapGroupAttribute($ldapSettings['group_attribute']);
$ldapAuthenticationHandler->SetLdapGroupCnIdentifier($ldapSettings['group_cn_identifier']);
$ldapAuthenticationHandler->SetLdapServerType($ldapSettings['ldap_server_type']);
$ldapAuthenticationHandler->SetLdapNetworkTimeout($ldapSettings['network_timeout']);
$ldapAuthenticationHandler->SetLdapPort($ldapSettings['port']);
$ldapAuthenticationHandler->SetLdapRecursiveGroups($ldapSettings['recursive_groups']);
$ldapAuthenticationHandler->SetLdapTimeLimit($ldapSettings['time_limit']);
$ldapAuthenticationHandler->SetLdapSsl($ldapSettings['use_ssl']);
$ldapAuthenticationHandler->SetLdapCacheOn($ldapSettings['cache_support']);
$ldapAuthenticationHandler->SetLdapCacheFolder($ldapSettings['cache_folder']);
$ldapAuthenticationHandler->SetLdapExpiredPasswordValid($ldapSettings['expired_password_valid']);
$this->ldapAuthenticationHandler = $ldapAuthenticationHandler;
} | php | protected function initializeLdapAuthenticationHandler() {
$ldapSettings = $this->_passwordAuthenticationPlatformSettings;
$ldapAuthenticationHandler = new MultiotpWrapper();
$ldapAuthenticationHandler->SetLdapServerPassword($this->getCurrentPassword());
$ldapAuthenticationHandler->SetLdapBindDn($this->getCurrentUsername());
$ldapAuthenticationHandler->SetLdapAccountSuffix($ldapSettings['ldap_account_suffix']);
$ldapAuthenticationHandler->SetLdapBaseDn($ldapSettings['base_dn']);
$ldapAuthenticationHandler->SetLdapCnIdentifier($ldapSettings['cn_identifier']);
$ldapAuthenticationHandler->SetLdapDomainControllers($ldapSettings['domain_controllers']);
$ldapAuthenticationHandler->SetLdapGroupAttribute($ldapSettings['group_attribute']);
$ldapAuthenticationHandler->SetLdapGroupCnIdentifier($ldapSettings['group_cn_identifier']);
$ldapAuthenticationHandler->SetLdapServerType($ldapSettings['ldap_server_type']);
$ldapAuthenticationHandler->SetLdapNetworkTimeout($ldapSettings['network_timeout']);
$ldapAuthenticationHandler->SetLdapPort($ldapSettings['port']);
$ldapAuthenticationHandler->SetLdapRecursiveGroups($ldapSettings['recursive_groups']);
$ldapAuthenticationHandler->SetLdapTimeLimit($ldapSettings['time_limit']);
$ldapAuthenticationHandler->SetLdapSsl($ldapSettings['use_ssl']);
$ldapAuthenticationHandler->SetLdapCacheOn($ldapSettings['cache_support']);
$ldapAuthenticationHandler->SetLdapCacheFolder($ldapSettings['cache_folder']);
$ldapAuthenticationHandler->SetLdapExpiredPasswordValid($ldapSettings['expired_password_valid']);
$this->ldapAuthenticationHandler = $ldapAuthenticationHandler;
} | [
"protected",
"function",
"initializeLdapAuthenticationHandler",
"(",
")",
"{",
"$",
"ldapSettings",
"=",
"$",
"this",
"->",
"_passwordAuthenticationPlatformSettings",
";",
"$",
"ldapAuthenticationHandler",
"=",
"new",
"MultiotpWrapper",
"(",
")",
";",
"$",
"ldapAuthenti... | Instantiate the LDAP handler and inject appropriate settings into it
Cyril Ogana <cogana@gmail.com>
2018 | [
"Instantiate",
"the",
"LDAP",
"handler",
"and",
"inject",
"appropriate",
"settings",
"into",
"it"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/traits/UserCredentialAuthenticationLdapTrait.php#L92-L115 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Observer.php | Observer.execute | public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->redirect->isAllowed()) {
$this->session->unsetScript();
return;
}
foreach ($this->getRedirects() as $redirect) {
$redirect->run();
}
} | php | public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->redirect->isAllowed()) {
$this->session->unsetScript();
return;
}
foreach ($this->getRedirects() as $redirect) {
$redirect->run();
}
} | [
"public",
"function",
"execute",
"(",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"Event",
"\\",
"Observer",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"redirect",
"->",
"isAllowed",
"(",
")",
")",
"{",
"$",
"this",
"->",
"session",
... | Runs the redirect list
@inheritdoc | [
"Runs",
"the",
"redirect",
"list"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Observer.php#L65-L76 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Observer.php | Observer.getRedirects | private function getRedirects()
{
$httpWithJsBackup = [
$this->httpRedirect,
$this->jsRedirect
];
return $this->redirect->isTypeJavaScript() ? [$this->jsRedirect] : $httpWithJsBackup;
} | php | private function getRedirects()
{
$httpWithJsBackup = [
$this->httpRedirect,
$this->jsRedirect
];
return $this->redirect->isTypeJavaScript() ? [$this->jsRedirect] : $httpWithJsBackup;
} | [
"private",
"function",
"getRedirects",
"(",
")",
"{",
"$",
"httpWithJsBackup",
"=",
"[",
"$",
"this",
"->",
"httpRedirect",
",",
"$",
"this",
"->",
"jsRedirect",
"]",
";",
"return",
"$",
"this",
"->",
"redirect",
"->",
"isTypeJavaScript",
"(",
")",
"?",
... | By default will run HTTP redirect with JS fallback if HTTP
does not work. If JS is set as the main redirect, it will
just run the JS redirect
@return Type\TypeInterface[] | [
"By",
"default",
"will",
"run",
"HTTP",
"redirect",
"with",
"JS",
"fallback",
"if",
"HTTP",
"does",
"not",
"work",
".",
"If",
"JS",
"is",
"set",
"as",
"the",
"main",
"redirect",
"it",
"will",
"just",
"run",
"the",
"JS",
"redirect"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Observer.php#L85-L93 | train |
SaftIng/Saft | src/Saft/Store/AbstractTriplePatternStore.php | AbstractTriplePatternStore.getStatement | protected function getStatement(Query $queryObject)
{
$queryParts = $queryObject->getQueryParts();
$tupleInformaton = null;
$tupleType = null;
/*
* Use triple pattern
*/
if (true === isset($queryParts['triple_pattern'])) {
$tupleInformation = $queryParts['triple_pattern'];
$tupleType = 'triple';
/*
* Use quad pattern
*/
} elseif (true === isset($queryParts['quad_pattern'])) {
$tupleInformation = $queryParts['quad_pattern'];
$tupleType = 'quad';
/*
* Neither triple nor quad information
*/
} else {
throw new \Exception(
'Neither triple nor quad information available in given query object: '.$queryObject->getQuery()
);
}
if (1 > count($tupleInformation)) {
throw new \Exception('Query contains more than one triple- respectivly quad pattern.');
}
/*
* Triple
*/
if ('triple' == $tupleType) {
$subject = $this->createNodeByValueAndType($tupleInformation[0]['s'], $tupleInformation[0]['s_type']);
$predicate = $this->createNodeByValueAndType($tupleInformation[0]['p'], $tupleInformation[0]['p_type']);
$object = $this->createNodeByValueAndType($tupleInformation[0]['o'], $tupleInformation[0]['o_type']);
$graph = null;
/*
* Quad
*/
} elseif ('quad' == $tupleType) {
$subject = $this->createNodeByValueAndType($tupleInformation[0]['s'], $tupleInformation[0]['s_type']);
$predicate = $this->createNodeByValueAndType($tupleInformation[0]['p'], $tupleInformation[0]['p_type']);
$object = $this->createNodeByValueAndType($tupleInformation[0]['o'], $tupleInformation[0]['o_type']);
$graph = $this->createNodeByValueAndType($tupleInformation[0]['g'], 'uri');
}
// no else neccessary, because otherwise the upper exception would be thrown if tupleType is neither
// quad or triple.
return $this->statementFactory->createStatement($subject, $predicate, $object, $graph);
} | php | protected function getStatement(Query $queryObject)
{
$queryParts = $queryObject->getQueryParts();
$tupleInformaton = null;
$tupleType = null;
/*
* Use triple pattern
*/
if (true === isset($queryParts['triple_pattern'])) {
$tupleInformation = $queryParts['triple_pattern'];
$tupleType = 'triple';
/*
* Use quad pattern
*/
} elseif (true === isset($queryParts['quad_pattern'])) {
$tupleInformation = $queryParts['quad_pattern'];
$tupleType = 'quad';
/*
* Neither triple nor quad information
*/
} else {
throw new \Exception(
'Neither triple nor quad information available in given query object: '.$queryObject->getQuery()
);
}
if (1 > count($tupleInformation)) {
throw new \Exception('Query contains more than one triple- respectivly quad pattern.');
}
/*
* Triple
*/
if ('triple' == $tupleType) {
$subject = $this->createNodeByValueAndType($tupleInformation[0]['s'], $tupleInformation[0]['s_type']);
$predicate = $this->createNodeByValueAndType($tupleInformation[0]['p'], $tupleInformation[0]['p_type']);
$object = $this->createNodeByValueAndType($tupleInformation[0]['o'], $tupleInformation[0]['o_type']);
$graph = null;
/*
* Quad
*/
} elseif ('quad' == $tupleType) {
$subject = $this->createNodeByValueAndType($tupleInformation[0]['s'], $tupleInformation[0]['s_type']);
$predicate = $this->createNodeByValueAndType($tupleInformation[0]['p'], $tupleInformation[0]['p_type']);
$object = $this->createNodeByValueAndType($tupleInformation[0]['o'], $tupleInformation[0]['o_type']);
$graph = $this->createNodeByValueAndType($tupleInformation[0]['g'], 'uri');
}
// no else neccessary, because otherwise the upper exception would be thrown if tupleType is neither
// quad or triple.
return $this->statementFactory->createStatement($subject, $predicate, $object, $graph);
} | [
"protected",
"function",
"getStatement",
"(",
"Query",
"$",
"queryObject",
")",
"{",
"$",
"queryParts",
"=",
"$",
"queryObject",
"->",
"getQueryParts",
"(",
")",
";",
"$",
"tupleInformaton",
"=",
"null",
";",
"$",
"tupleType",
"=",
"null",
";",
"/*\n ... | Create Statement instance based on a given Query instance.
@param Query $queryObject query object which represents a SPARQL query
@return Statement statement object itself
@throws \Exception if query contains more than one triple pattern
@throws \Exception if more than one graph was found
@api
@since 0.1 | [
"Create",
"Statement",
"instance",
"based",
"on",
"a",
"given",
"Query",
"instance",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Store/AbstractTriplePatternStore.php#L182-L239 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.