repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
kgilden/php-digidoc | src/File.php | File.getContent | public function getContent()
{
if (!($pathname = $this->getPathname())) {
throw new \LogicException('No pathname was specified - maybe it came from DigiDoc web service?');
}
$level = error_reporting(0);
$content = file_get_contents($pathname);
error_reporting($level);
if (false === $content) {
$error = error_get_last();
throw new RuntimeException($error['message']);
}
return $content;
} | php | public function getContent()
{
if (!($pathname = $this->getPathname())) {
throw new \LogicException('No pathname was specified - maybe it came from DigiDoc web service?');
}
$level = error_reporting(0);
$content = file_get_contents($pathname);
error_reporting($level);
if (false === $content) {
$error = error_get_last();
throw new RuntimeException($error['message']);
}
return $content;
} | [
"public",
"function",
"getContent",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"pathname",
"=",
"$",
"this",
"->",
"getPathname",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'No pathname was specified - maybe it came from DigiDoc web ser... | @todo A duplicate of Encoder::getFileContent()
@return string
@throws \LogicException If the file is not real | [
"@todo",
"A",
"duplicate",
"of",
"Encoder",
"::",
"getFileContent",
"()"
] | train | https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/File.php#L116-L132 |
KnightSwarm/laravel-saml | src/KnightSwarm/LaravelSaml/Account.php | Account.IdExists | public function IdExists($id)
{
$property = $this->getUserIdProperty();
$user = User::where($property, "=", $id)->count();
return $user === 0 ? false : true;
} | php | public function IdExists($id)
{
$property = $this->getUserIdProperty();
$user = User::where($property, "=", $id)->count();
return $user === 0 ? false : true;
} | [
"public",
"function",
"IdExists",
"(",
"$",
"id",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"getUserIdProperty",
"(",
")",
";",
"$",
"user",
"=",
"User",
"::",
"where",
"(",
"$",
"property",
",",
"\"=\"",
",",
"$",
"id",
")",
"->",
"count"... | Check if the id exists in the specified user property.
If no property is defined default to 'email'. | [
"Check",
"if",
"the",
"id",
"exists",
"in",
"the",
"specified",
"user",
"property",
".",
"If",
"no",
"property",
"is",
"defined",
"default",
"to",
"email",
"."
] | train | https://github.com/KnightSwarm/laravel-saml/blob/712d02f6edae914db7b48438361444b2daf66930/src/KnightSwarm/LaravelSaml/Account.php#L23-L28 |
KnightSwarm/laravel-saml | src/KnightSwarm/LaravelSaml/Account.php | Account.fillUserDetails | protected function fillUserDetails($user)
{
$mappings = Config::get('laravel-saml::saml.object_mappings',[]);
foreach($mappings as $key => $mapping)
{
$user->{$key} = $this->getSamlAttribute($mapping);
}
} | php | protected function fillUserDetails($user)
{
$mappings = Config::get('laravel-saml::saml.object_mappings',[]);
foreach($mappings as $key => $mapping)
{
$user->{$key} = $this->getSamlAttribute($mapping);
}
} | [
"protected",
"function",
"fillUserDetails",
"(",
"$",
"user",
")",
"{",
"$",
"mappings",
"=",
"Config",
"::",
"get",
"(",
"'laravel-saml::saml.object_mappings'",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"mappings",
"as",
"$",
"key",
"=>",
"$",
"mappin... | If mapping between saml attributes and object attributes are defined
then fill user object with mapped values. | [
"If",
"mapping",
"between",
"saml",
"attributes",
"and",
"object",
"attributes",
"are",
"defined",
"then",
"fill",
"user",
"object",
"with",
"mapped",
"values",
"."
] | train | https://github.com/KnightSwarm/laravel-saml/blob/712d02f6edae914db7b48438361444b2daf66930/src/KnightSwarm/LaravelSaml/Account.php#L74-L81 |
wisp-x/hopephp | hopephp/library/traits/Jump.php | Jump.success | protected function success($msg = '', $url = null, $data = '', $wait = 3)
{
if (is_null($url)) {
$url = Request::instance()->isAjax() ? '' : 'javascript:history.back(-1);';
}
$result = [
'code' => 1,
'msg' => $msg,
'data' => $data,
'url' => $url,
'wait' => $wait,
];
if (Request::instance()->isPost()) {
header('Content-type: application/json; charset=utf-8');
die(json_encode($result));
} else {
die(include HOPE_PATH . 'temp/jump.php');
}
} | php | protected function success($msg = '', $url = null, $data = '', $wait = 3)
{
if (is_null($url)) {
$url = Request::instance()->isAjax() ? '' : 'javascript:history.back(-1);';
}
$result = [
'code' => 1,
'msg' => $msg,
'data' => $data,
'url' => $url,
'wait' => $wait,
];
if (Request::instance()->isPost()) {
header('Content-type: application/json; charset=utf-8');
die(json_encode($result));
} else {
die(include HOPE_PATH . 'temp/jump.php');
}
} | [
"protected",
"function",
"success",
"(",
"$",
"msg",
"=",
"''",
",",
"$",
"url",
"=",
"null",
",",
"$",
"data",
"=",
"''",
",",
"$",
"wait",
"=",
"3",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"Request",... | 成功提示
@param string $msg
@param null $url
@param string $data
@param int $wait | [
"成功提示"
] | train | https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/traits/Jump.php#L26-L46 |
wisp-x/hopephp | hopephp/library/traits/Jump.php | Jump.result | protected function result($data, $code = 0, $msg = '')
{
$result = [
'code' => $code,
'msg' => $msg,
'time' => Request::instance()->server('REQUEST_TIME'),
'data' => $data,
];
header('Content-type: application/json; charset=utf-8');
die(json_encode($result));
} | php | protected function result($data, $code = 0, $msg = '')
{
$result = [
'code' => $code,
'msg' => $msg,
'time' => Request::instance()->server('REQUEST_TIME'),
'data' => $data,
];
header('Content-type: application/json; charset=utf-8');
die(json_encode($result));
} | [
"protected",
"function",
"result",
"(",
"$",
"data",
",",
"$",
"code",
"=",
"0",
",",
"$",
"msg",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'time'",
"=>",
"Request",
"::",
"... | 返回封装数据
@param $data
@param int $code
@param string $msg | [
"返回封装数据"
] | train | https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/traits/Jump.php#L83-L93 |
yeriomin/getopt | src/Yeriomin/Getopt/Getopt.php | Getopt.setParser | public function setParser(ParserInterface $parser)
{
$this->parsed = false;
$this->parser = $parser;
return $this;
} | php | public function setParser(ParserInterface $parser)
{
$this->parsed = false;
$this->parser = $parser;
return $this;
} | [
"public",
"function",
"setParser",
"(",
"ParserInterface",
"$",
"parser",
")",
"{",
"$",
"this",
"->",
"parsed",
"=",
"false",
";",
"$",
"this",
"->",
"parser",
"=",
"$",
"parser",
";",
"return",
"$",
"this",
";",
"}"
] | Set parser
@param \Yeriomin\Getopt\ParserInterface $parser
@return \Yeriomin\Getopt\Getopt | [
"Set",
"parser"
] | train | https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L148-L153 |
yeriomin/getopt | src/Yeriomin/Getopt/Getopt.php | Getopt.getUsageMessage | public function getUsageMessage()
{
foreach ($this->optionDefinitions as $def) {
$this->usageProvider->addOptionDefinition($def);
}
if (empty($this->scriptName)) {
$this->scriptName = $_SERVER['PHP_SELF'];
}
$this->usageProvider->setScriptName($this->scriptName);
return $this->usageProvider->getUsageMessage();
} | php | public function getUsageMessage()
{
foreach ($this->optionDefinitions as $def) {
$this->usageProvider->addOptionDefinition($def);
}
if (empty($this->scriptName)) {
$this->scriptName = $_SERVER['PHP_SELF'];
}
$this->usageProvider->setScriptName($this->scriptName);
return $this->usageProvider->getUsageMessage();
} | [
"public",
"function",
"getUsageMessage",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"optionDefinitions",
"as",
"$",
"def",
")",
"{",
"$",
"this",
"->",
"usageProvider",
"->",
"addOptionDefinition",
"(",
"$",
"def",
")",
";",
"}",
"if",
"(",
"empty... | Build and return the usage message based on defined options
@return string | [
"Build",
"and",
"return",
"the",
"usage",
"message",
"based",
"on",
"defined",
"options"
] | train | https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L172-L182 |
yeriomin/getopt | src/Yeriomin/Getopt/Getopt.php | Getopt.parse | public function parse()
{
$this->parser->parse($this->rawArguments);
$this->parsed = true;
$this->arguments = $this->parser->getArguments();
$optionsShort = $this->parser->getOptionsShort();
$optionsLong = $this->parser->getOptionsLong();
$missongRequired = array();
foreach ($this->optionDefinitions as $definition) {
$value = $this->getOptionValue($definition);
$short = $definition->getShort();
$long = $definition->getLong();
$optionsShort[$short] = $value;
$optionsLong[$long] = $value;
if ($definition->getRequired() && $value === null) {
$parts = array();
$parts[] = $short !== null ? '-' . $short : null;
$parts[] = $long !== null ? '--' . $long : null;
$missongRequired[] = implode('|', $parts);
}
}
if (!empty($missongRequired)) {
throw new GetoptException(
'Missing required options: '
. implode(', ', $missongRequired)
);
}
$this->optionsShort = $optionsShort;
$this->optionsLong = $optionsLong;
} | php | public function parse()
{
$this->parser->parse($this->rawArguments);
$this->parsed = true;
$this->arguments = $this->parser->getArguments();
$optionsShort = $this->parser->getOptionsShort();
$optionsLong = $this->parser->getOptionsLong();
$missongRequired = array();
foreach ($this->optionDefinitions as $definition) {
$value = $this->getOptionValue($definition);
$short = $definition->getShort();
$long = $definition->getLong();
$optionsShort[$short] = $value;
$optionsLong[$long] = $value;
if ($definition->getRequired() && $value === null) {
$parts = array();
$parts[] = $short !== null ? '-' . $short : null;
$parts[] = $long !== null ? '--' . $long : null;
$missongRequired[] = implode('|', $parts);
}
}
if (!empty($missongRequired)) {
throw new GetoptException(
'Missing required options: '
. implode(', ', $missongRequired)
);
}
$this->optionsShort = $optionsShort;
$this->optionsLong = $optionsLong;
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"this",
"->",
"rawArguments",
")",
";",
"$",
"this",
"->",
"parsed",
"=",
"true",
";",
"$",
"this",
"->",
"arguments",
"=",
"$",
"this",
"->",
"pars... | Parse the console arguments using the provided parser
and check them for validity
@throws GetoptException | [
"Parse",
"the",
"console",
"arguments",
"using",
"the",
"provided",
"parser",
"and",
"check",
"them",
"for",
"validity"
] | train | https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L200-L229 |
yeriomin/getopt | src/Yeriomin/Getopt/Getopt.php | Getopt.getOptionValue | private function getOptionValue(OptionDefinition $definition)
{
$nameShort = $definition->getShort();
$nameLong = $definition->getLong();
$valueShort = $this->parser->getOptionShort($nameShort);
$valueLong = $this->parser->getOptionLong($nameLong);
if ($nameShort !== null && $nameLong !== null
&& $valueShort !== null && $valueLong !== null
&& $valueShort !== $valueLong
) {
throw new GetoptException(
'Both -' . $nameShort . ' and --' . $nameLong
. ' given, with non-matching values. Make up your mind.'
);
}
return $valueShort !== null ? $valueShort : $valueLong;
} | php | private function getOptionValue(OptionDefinition $definition)
{
$nameShort = $definition->getShort();
$nameLong = $definition->getLong();
$valueShort = $this->parser->getOptionShort($nameShort);
$valueLong = $this->parser->getOptionLong($nameLong);
if ($nameShort !== null && $nameLong !== null
&& $valueShort !== null && $valueLong !== null
&& $valueShort !== $valueLong
) {
throw new GetoptException(
'Both -' . $nameShort . ' and --' . $nameLong
. ' given, with non-matching values. Make up your mind.'
);
}
return $valueShort !== null ? $valueShort : $valueLong;
} | [
"private",
"function",
"getOptionValue",
"(",
"OptionDefinition",
"$",
"definition",
")",
"{",
"$",
"nameShort",
"=",
"$",
"definition",
"->",
"getShort",
"(",
")",
";",
"$",
"nameLong",
"=",
"$",
"definition",
"->",
"getLong",
"(",
")",
";",
"$",
"valueSh... | Get option value based on its definition
@param \Yeriomin\Getopt\OptionDefinition $definition
@return mixed
@throws GetoptException | [
"Get",
"option",
"value",
"based",
"on",
"its",
"definition"
] | train | https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L275-L291 |
JustBlackBird/handlebars.php-helpers | src/Helpers.php | Helpers.addDefaultHelpers | protected function addDefaultHelpers()
{
parent::addDefaultHelpers();
// Date helpers
$this->add('formatDate', new Date\FormatDateHelper());
// Collection helpers
$this->add('count', new Collection\CountHelper());
$this->add('first', new Collection\FirstHelper());
$this->add('last', new Collection\LastHelper());
// Comparison helpers
$this->add('ifAny', new Comparison\IfAnyHelper());
$this->add('ifEqual', new Comparison\IfEqualHelper());
$this->add('ifEven', new Comparison\IfEvenHelper());
$this->add('ifOdd', new Comparison\IfOddHelper());
$this->add('unlessEqual', new Comparison\UnlessEqualHelper());
// Text helpers
$this->add('lowercase', new Text\LowercaseHelper());
$this->add('uppercase', new Text\UppercaseHelper());
$this->add('repeat', new Text\RepeatHelper());
$this->add('replace', new Text\ReplaceHelper());
$this->add('truncate', new Text\TruncateHelper());
$this->add('ellipsis', new Text\EllipsisHelper());
// Layout helpers
$storage = new Layout\BlockStorage();
$this->add('block', new Layout\BlockHelper($storage));
$this->add('extends', new Layout\ExtendsHelper($storage));
$this->add('override', new Layout\OverrideHelper($storage));
$this->add('ifOverridden', new Layout\IfOverriddenHelper($storage));
$this->add('unlessOverridden', new Layout\UnlessOverriddenHelper($storage));
} | php | protected function addDefaultHelpers()
{
parent::addDefaultHelpers();
// Date helpers
$this->add('formatDate', new Date\FormatDateHelper());
// Collection helpers
$this->add('count', new Collection\CountHelper());
$this->add('first', new Collection\FirstHelper());
$this->add('last', new Collection\LastHelper());
// Comparison helpers
$this->add('ifAny', new Comparison\IfAnyHelper());
$this->add('ifEqual', new Comparison\IfEqualHelper());
$this->add('ifEven', new Comparison\IfEvenHelper());
$this->add('ifOdd', new Comparison\IfOddHelper());
$this->add('unlessEqual', new Comparison\UnlessEqualHelper());
// Text helpers
$this->add('lowercase', new Text\LowercaseHelper());
$this->add('uppercase', new Text\UppercaseHelper());
$this->add('repeat', new Text\RepeatHelper());
$this->add('replace', new Text\ReplaceHelper());
$this->add('truncate', new Text\TruncateHelper());
$this->add('ellipsis', new Text\EllipsisHelper());
// Layout helpers
$storage = new Layout\BlockStorage();
$this->add('block', new Layout\BlockHelper($storage));
$this->add('extends', new Layout\ExtendsHelper($storage));
$this->add('override', new Layout\OverrideHelper($storage));
$this->add('ifOverridden', new Layout\IfOverriddenHelper($storage));
$this->add('unlessOverridden', new Layout\UnlessOverriddenHelper($storage));
} | [
"protected",
"function",
"addDefaultHelpers",
"(",
")",
"{",
"parent",
"::",
"addDefaultHelpers",
"(",
")",
";",
"// Date helpers",
"$",
"this",
"->",
"add",
"(",
"'formatDate'",
",",
"new",
"Date",
"\\",
"FormatDateHelper",
"(",
")",
")",
";",
"// Collection ... | {@inheritdoc} | [
"{"
] | train | https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Helpers.php#L25-L59 |
malenkiki/aleavatar | src/Malenki/Aleavatar/Primitive/Arc.php | Arc.radius | public function radius($int_rx, $int_ry = 0)
{
if (!is_integer($int_rx) || !is_integer($int_ry)) {
throw new \InvalidArgumentException('Radius must be integer value!');
}
if ($int_ry == 0) {
$this->radius->r = $int_rx;
$this->radius->w = 2 * $int_rx;
$this->radius->h = 2 * $int_rx;
$this->radius->is_circle = true;
} else {
$this->radius->rx = $int_rx;
$this->radius->ry = $int_ry;
$this->radius->w = 2 * $int_rx;
$this->radius->h = 2 * $int_ry;
$this->radius->is_circle = false;
}
return $this;
} | php | public function radius($int_rx, $int_ry = 0)
{
if (!is_integer($int_rx) || !is_integer($int_ry)) {
throw new \InvalidArgumentException('Radius must be integer value!');
}
if ($int_ry == 0) {
$this->radius->r = $int_rx;
$this->radius->w = 2 * $int_rx;
$this->radius->h = 2 * $int_rx;
$this->radius->is_circle = true;
} else {
$this->radius->rx = $int_rx;
$this->radius->ry = $int_ry;
$this->radius->w = 2 * $int_rx;
$this->radius->h = 2 * $int_ry;
$this->radius->is_circle = false;
}
return $this;
} | [
"public",
"function",
"radius",
"(",
"$",
"int_rx",
",",
"$",
"int_ry",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"int_rx",
")",
"||",
"!",
"is_integer",
"(",
"$",
"int_ry",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentExcep... | Sets radius.
If two values are provided, then n ellipse is defined.
If only one value is given, then you get a circle.
@param integer $int_rx
@param integer $int_ry
@throws InvalidArgumentException If radius is not an integer.
@access public
@return void | [
"Sets",
"radius",
"."
] | train | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Arc.php#L70-L90 |
JustBlackBird/handlebars.php-helpers | src/Date/FormatDateHelper.php | FormatDateHelper.execute | public function execute(Template $template, Context $context, $args, $source)
{
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 2) {
throw new \InvalidArgumentException(
'"formatDate" helper expects exactly two arguments.'
);
}
$raw_time = $context->get($parsed_args[0]);
if ($raw_time instanceof \DateTime) {
$timestamp = $raw_time->getTimestamp();
} else {
$timestamp = intval($raw_time);
}
$format = $context->get($parsed_args[1]);
return strftime($format, $timestamp);
} | php | public function execute(Template $template, Context $context, $args, $source)
{
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 2) {
throw new \InvalidArgumentException(
'"formatDate" helper expects exactly two arguments.'
);
}
$raw_time = $context->get($parsed_args[0]);
if ($raw_time instanceof \DateTime) {
$timestamp = $raw_time->getTimestamp();
} else {
$timestamp = intval($raw_time);
}
$format = $context->get($parsed_args[1]);
return strftime($format, $timestamp);
} | [
"public",
"function",
"execute",
"(",
"Template",
"$",
"template",
",",
"Context",
"$",
"context",
",",
"$",
"args",
",",
"$",
"source",
")",
"{",
"$",
"parsed_args",
"=",
"$",
"template",
"->",
"parseArguments",
"(",
"$",
"args",
")",
";",
"if",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Date/FormatDateHelper.php#L39-L57 |
CampaignChain/core | Controller/ExceptionController.php | ExceptionController.findTemplate | protected function findTemplate(Request $request, $format, $code, $showException)
{
$name = $showException ? 'exception' : 'error';
if ($showException && 'html' == $format) {
$name = 'exception_full';
}
// For error pages, try to find a template for the specific HTTP status code and format
if (!$showException) {
// CampaignChain template?
$template = sprintf('@CampaignChainCore/Exception/%s%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) {
return $template;
}
// Fallback to default
$template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) {
return $template;
}
}
// try to find a template for the given format
// CampaignChain template?
$template = sprintf('@CampaignChainCore/Exception/%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) {
return $template;
}
// Fallback to default
$template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format);
if ($this->templateExists($template)) {
return $template;
}
// default to a generic HTML exception
$request->setRequestFormat('html');
return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
} | php | protected function findTemplate(Request $request, $format, $code, $showException)
{
$name = $showException ? 'exception' : 'error';
if ($showException && 'html' == $format) {
$name = 'exception_full';
}
// For error pages, try to find a template for the specific HTTP status code and format
if (!$showException) {
// CampaignChain template?
$template = sprintf('@CampaignChainCore/Exception/%s%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) {
return $template;
}
// Fallback to default
$template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) {
return $template;
}
}
// try to find a template for the given format
// CampaignChain template?
$template = sprintf('@CampaignChainCore/Exception/%s.%s.twig', $name, $code, $format);
if ($this->templateExists($template)) {
return $template;
}
// Fallback to default
$template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format);
if ($this->templateExists($template)) {
return $template;
}
// default to a generic HTML exception
$request->setRequestFormat('html');
return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
} | [
"protected",
"function",
"findTemplate",
"(",
"Request",
"$",
"request",
",",
"$",
"format",
",",
"$",
"code",
",",
"$",
"showException",
")",
"{",
"$",
"name",
"=",
"$",
"showException",
"?",
"'exception'",
":",
"'error'",
";",
"if",
"(",
"$",
"showExce... | Just a modified Symfony\Bundle\TwigBundle\Controller\ExceptionController::findTemplate().
It will try to find an appropriate error template in the CoreBundle and will fallback to
the Twig default template if it can't find anything.
@param Request $request
@param string $format
@param int $code An HTTP response status code
@param bool $showException
@return string | [
"Just",
"a",
"modified",
"Symfony",
"\\",
"Bundle",
"\\",
"TwigBundle",
"\\",
"Controller",
"\\",
"ExceptionController",
"::",
"findTemplate",
"()",
".",
"It",
"will",
"try",
"to",
"find",
"an",
"appropriate",
"error",
"template",
"in",
"the",
"CoreBundle",
"a... | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/ExceptionController.php#L34-L74 |
joomla-framework/twitter-api | src/Media.php | Media.upload | public function upload($rawMedia = null, $base64Media = null, $owners = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('media', 'upload');
// Determine which type of data was passed for $media
if ($rawMedia !== null)
{
$data['media'] = $rawMedia;
}
elseif ($base64Media !== null)
{
$data['media_data'] = $base64Media;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('You must specify at least one valid media type.');
}
if ($rawMedia !== null && $base64Media !== null)
{
throw new \RuntimeException('You may only specify one type of media.');
}
if ($owners !== null)
{
$data['additional_owners'] = $owners;
}
// Set the API path
$path = '/media/upload.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
} | php | public function upload($rawMedia = null, $base64Media = null, $owners = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('media', 'upload');
// Determine which type of data was passed for $media
if ($rawMedia !== null)
{
$data['media'] = $rawMedia;
}
elseif ($base64Media !== null)
{
$data['media_data'] = $base64Media;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('You must specify at least one valid media type.');
}
if ($rawMedia !== null && $base64Media !== null)
{
throw new \RuntimeException('You may only specify one type of media.');
}
if ($owners !== null)
{
$data['additional_owners'] = $owners;
}
// Set the API path
$path = '/media/upload.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
} | [
"public",
"function",
"upload",
"(",
"$",
"rawMedia",
"=",
"null",
",",
"$",
"base64Media",
"=",
"null",
",",
"$",
"owners",
"=",
"null",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this",
"->",
"checkRateLimit",
"(",
"'media'",
",",
"'upload... | Method to upload media.
@param string $rawMedia Raw binary data to be uploaded.
@param string $base64Media A base64 encoded string containing the data to be uploaded.
This cannot be used in conjunction with $rawMedia
@param string $owners A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id
in Tweets or Cards. A maximum of 100 additional owners may be specified.
@return array The decoded JSON response
@since 1.2.0
@throws \RuntimeException | [
"Method",
"to",
"upload",
"media",
"."
] | train | https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Media.php#L33-L68 |
CampaignChain/core | EntityService/LocationService.php | LocationService.findLocationByUrl | public function findLocationByUrl($url, Operation $operation, $alias = null, array $options = array())
{
/*
* Set default options.
*/
$resolver = new OptionsResolver();
$resolver->setDefaults(array(
'graceful_url_exists' => true,
));
$options = $resolver->resolve($options);
$url = ParserUtil::sanitizeUrl($url);
/*
* If not a Location, then see if the URL is inside a connected
* Channel's top-level Locations. To do so, check if one of these
* criteria apply:
* - The Location URL matches the beginning of the CTA URL
* - The Location identifier is included in the CTA URL as well
* as the domain
*/
if(ParserUtil::urlExists($url, $options['graceful_url_exists'])) {
$urlParts = parse_url($url);
if($urlParts['scheme'] == 'http'){
$urlAltScheme = str_replace('http://', 'https://', $url);
} elseif($urlParts['scheme'] == 'https'){
$urlAltScheme = str_replace('https://', 'http://', $url);
}
$repository = $this->em
->getRepository('CampaignChainCoreBundle:Location');
$query = $repository->createQueryBuilder('location')
->where(
"(:url LIKE CONCAT('%', location.url, '%')) OR ".
"(:url_alt_scheme LIKE CONCAT('%', location.url, '%')) OR ".
"(".
"location.identifier IS NOT NULL AND ".
":url LIKE CONCAT('%', location.identifier, '%') AND ".
"location.url LIKE :host".
")"
)
->andWhere('location.parent IS NULL')
->setParameter('url', $url)
->setParameter('url_alt_scheme', $urlAltScheme)
->setParameter('host', $urlParts['host'].'%')
->getQuery();
try {
/** @var Location $matchingLocation */
$matchingLocation = $query->getOneOrNullResult();
} catch (NonUniqueResultException $e){
throw new \Exception('Internal Error: Found two matching Locations, but there should be only one in file '.__FILE__.' on line '.__LINE__);
}
if($matchingLocation){
/*
* Create a new Location based on the tracking alias
* within the matching Location's Channel.
*
* If no tracking alias was provided, we take the
* default LocationModule to create a new Location.
*/
if(!$alias){
// Done if the URL is exactly the same in the matching Location.
if($matchingLocation->getUrl() == $url || $matchingLocation->getUrl() == $urlAltScheme){
return $matchingLocation;
}
// Let's move on to create a new Location with the default module.
$locationService = $this->container->get('campaignchain.core.location');
/** @var LocationModule $locationModule */
$locationModule = $locationService->getLocationModule(
self::DEFAULT_LOCATION_BUNDLE_NAME,
self::DEFAULT_LOCATION_MODULE_IDENTIFIER
);
if(!$locationModule){
throw new \Exception(
'No Location module found for bundle "'.
$matchingLocation->getChannel()->getBundle()->getName().' and module '.
$matchingLocation->getChannel()->getChannelModule()->getIdentifier().'"'
);
}
} else {
/*
* Get the Location module within the matching Location's
* Channel and with the given tracking alias.
*/
/** @var LocationModule $locationModule */
$locationModule = $this->getLocationModuleByTrackingAlias(
$matchingLocation->getChannel()->getChannelModule(),
$alias
);
// Done if the matching Location also matches the alias and URL.
if(
$matchingLocation->getLocationModule() == $locationModule &&
($matchingLocation->getUrl() == $url || $matchingLocation->getUrl() == $urlAltScheme)
){
return $matchingLocation;
}
/*
* See if there is already another Location that matches the
* aliase's Location module and the URL.
*/
$repository = $this->em
->getRepository('CampaignChainCoreBundle:Location');
$query = $repository->createQueryBuilder('location')
->where('location.locationModule = :locationModule')
->andWhere('(location.url = :url OR location.url = :url_alt_scheme')
->setParameter('locationModule', $locationModule)
->setParameter('url', $url)
->setParameter('url_alt_scheme', $urlAltScheme)
->getQuery();
/** @var Location $location */
$location = $query->getOneOrNullResult();
// We found an existing Location, we're done.
if($location){
return $location;
}
if(!$locationModule){
throw new \Exception(
'Cannot map tracking alias "'.$alias.'" to a "'.
'Location module that belongs to Channel module "'.
$matchingLocation->getChannel()->getBundle()->getName().'/'.
$matchingLocation->getChannel()->getChannelModule()->getIdentifier().'"'
);
}
}
/*
* If the matching Location provides auto-generation of Locations,
* then let's create a new child Location.
*/
$ctaServiceName = $locationModule->getServices()['job_cta'];
if($ctaServiceName){
// Create the new Location
$location = new Location();
$location->setUrl($url);
$location->setOperation($operation);
$location->setChannel($matchingLocation->getChannel());
$location->setParent($matchingLocation);
// Update the Location module to be the current
// one.
$location->setLocationModule(
$locationModule
);
// Let the module's service process the new
// Location.
$ctaService = $this->container->get($ctaServiceName);
return $ctaService->execute($location);
} else {
throw new \Exception(
'No CTA Job service defined for Location module '.
'of bundle "'.$locationModule->getBundle()->getName().'" '.
'and module "'.$locationModule->getIdentifier().'"'
);
}
} else {
return false;
}
}
throw new \Exception(
'The URL '.$url.' does not exist.'
);
} | php | public function findLocationByUrl($url, Operation $operation, $alias = null, array $options = array())
{
/*
* Set default options.
*/
$resolver = new OptionsResolver();
$resolver->setDefaults(array(
'graceful_url_exists' => true,
));
$options = $resolver->resolve($options);
$url = ParserUtil::sanitizeUrl($url);
/*
* If not a Location, then see if the URL is inside a connected
* Channel's top-level Locations. To do so, check if one of these
* criteria apply:
* - The Location URL matches the beginning of the CTA URL
* - The Location identifier is included in the CTA URL as well
* as the domain
*/
if(ParserUtil::urlExists($url, $options['graceful_url_exists'])) {
$urlParts = parse_url($url);
if($urlParts['scheme'] == 'http'){
$urlAltScheme = str_replace('http://', 'https://', $url);
} elseif($urlParts['scheme'] == 'https'){
$urlAltScheme = str_replace('https://', 'http://', $url);
}
$repository = $this->em
->getRepository('CampaignChainCoreBundle:Location');
$query = $repository->createQueryBuilder('location')
->where(
"(:url LIKE CONCAT('%', location.url, '%')) OR ".
"(:url_alt_scheme LIKE CONCAT('%', location.url, '%')) OR ".
"(".
"location.identifier IS NOT NULL AND ".
":url LIKE CONCAT('%', location.identifier, '%') AND ".
"location.url LIKE :host".
")"
)
->andWhere('location.parent IS NULL')
->setParameter('url', $url)
->setParameter('url_alt_scheme', $urlAltScheme)
->setParameter('host', $urlParts['host'].'%')
->getQuery();
try {
/** @var Location $matchingLocation */
$matchingLocation = $query->getOneOrNullResult();
} catch (NonUniqueResultException $e){
throw new \Exception('Internal Error: Found two matching Locations, but there should be only one in file '.__FILE__.' on line '.__LINE__);
}
if($matchingLocation){
/*
* Create a new Location based on the tracking alias
* within the matching Location's Channel.
*
* If no tracking alias was provided, we take the
* default LocationModule to create a new Location.
*/
if(!$alias){
// Done if the URL is exactly the same in the matching Location.
if($matchingLocation->getUrl() == $url || $matchingLocation->getUrl() == $urlAltScheme){
return $matchingLocation;
}
// Let's move on to create a new Location with the default module.
$locationService = $this->container->get('campaignchain.core.location');
/** @var LocationModule $locationModule */
$locationModule = $locationService->getLocationModule(
self::DEFAULT_LOCATION_BUNDLE_NAME,
self::DEFAULT_LOCATION_MODULE_IDENTIFIER
);
if(!$locationModule){
throw new \Exception(
'No Location module found for bundle "'.
$matchingLocation->getChannel()->getBundle()->getName().' and module '.
$matchingLocation->getChannel()->getChannelModule()->getIdentifier().'"'
);
}
} else {
/*
* Get the Location module within the matching Location's
* Channel and with the given tracking alias.
*/
/** @var LocationModule $locationModule */
$locationModule = $this->getLocationModuleByTrackingAlias(
$matchingLocation->getChannel()->getChannelModule(),
$alias
);
// Done if the matching Location also matches the alias and URL.
if(
$matchingLocation->getLocationModule() == $locationModule &&
($matchingLocation->getUrl() == $url || $matchingLocation->getUrl() == $urlAltScheme)
){
return $matchingLocation;
}
/*
* See if there is already another Location that matches the
* aliase's Location module and the URL.
*/
$repository = $this->em
->getRepository('CampaignChainCoreBundle:Location');
$query = $repository->createQueryBuilder('location')
->where('location.locationModule = :locationModule')
->andWhere('(location.url = :url OR location.url = :url_alt_scheme')
->setParameter('locationModule', $locationModule)
->setParameter('url', $url)
->setParameter('url_alt_scheme', $urlAltScheme)
->getQuery();
/** @var Location $location */
$location = $query->getOneOrNullResult();
// We found an existing Location, we're done.
if($location){
return $location;
}
if(!$locationModule){
throw new \Exception(
'Cannot map tracking alias "'.$alias.'" to a "'.
'Location module that belongs to Channel module "'.
$matchingLocation->getChannel()->getBundle()->getName().'/'.
$matchingLocation->getChannel()->getChannelModule()->getIdentifier().'"'
);
}
}
/*
* If the matching Location provides auto-generation of Locations,
* then let's create a new child Location.
*/
$ctaServiceName = $locationModule->getServices()['job_cta'];
if($ctaServiceName){
// Create the new Location
$location = new Location();
$location->setUrl($url);
$location->setOperation($operation);
$location->setChannel($matchingLocation->getChannel());
$location->setParent($matchingLocation);
// Update the Location module to be the current
// one.
$location->setLocationModule(
$locationModule
);
// Let the module's service process the new
// Location.
$ctaService = $this->container->get($ctaServiceName);
return $ctaService->execute($location);
} else {
throw new \Exception(
'No CTA Job service defined for Location module '.
'of bundle "'.$locationModule->getBundle()->getName().'" '.
'and module "'.$locationModule->getIdentifier().'"'
);
}
} else {
return false;
}
}
throw new \Exception(
'The URL '.$url.' does not exist.'
);
} | [
"public",
"function",
"findLocationByUrl",
"(",
"$",
"url",
",",
"Operation",
"$",
"operation",
",",
"$",
"alias",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"/*\n * Set default options.\n */",
"$",
"resolver",
... | Finds a Location by the URL and automatically creates the Location if it
does not exist and if the respective Location module supports auto
generation of Locations.
*
@param URL $url
@param Operation $operation
@param string $alias Tracking alias
@param array $options 'graceful_url_exists':
Gracefully handles URL check if there's a
timeout.
@return bool|Location|null|object | [
"Finds",
"a",
"Location",
"by",
"the",
"URL",
"and",
"automatically",
"creates",
"the",
"Location",
"if",
"it",
"does",
"not",
"exist",
"and",
"if",
"the",
"respective",
"Location",
"module",
"supports",
"auto",
"generation",
"of",
"Locations",
".",
"*"
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/LocationService.php#L128-L304 |
CampaignChain/core | EntityService/LocationService.php | LocationService.removeLocation | public function removeLocation($id)
{
/** @var Location $location */
$location = $this->getLocation($id);
$removableActivities = new ArrayCollection();
$notRemovableActivities = new ArrayCollection();
$accessToken = $this->em
->getRepository('CampaignChainSecurityAuthenticationClientOAuthBundle:Token')
->findOneBy(['location' => $location]);
try {
$this->em->getConnection()->beginTransaction();
if ($accessToken) {
$this->em->remove($accessToken);
$this->em->flush();
}
foreach ($location->getActivities() as $activity) {
if ($this->isRemovable($location)) {
$removableActivities->add($activity);
} else {
$notRemovableActivities->add($activity);
}
}
foreach ($removableActivities as $activity) {
$this->activityService->removeActivity($activity);
}
//Hack to find the belonging entities which has to be deleted first
$bundleName = explode('/', $location->getLocationModule()->getBundle()->getName());
$classPrefix = 'CampaignChain\\' . implode('\\', array_map(function ($e) {
return ucfirst($e);
}, explode('-', $bundleName[1]))) . 'Bundle';
$entitiesToDelete = [];
foreach ($this->em->getMetadataFactory()->getAllMetadata() as $metadataClass) {
if (strpos(strtolower($metadataClass->getName()), strtolower($classPrefix)) === 0) {
$entitiesToDelete[] = $metadataClass;
}
};
foreach ($entitiesToDelete as $repo) {
$entities = $this->em->getRepository($repo->getName())->findBy(['location' => $location->getId()]);
foreach ($entities as $entityToDelete) {
$this->em->remove($entityToDelete);
}
}
$this->em->flush();
$this->em->remove($location);
$this->em->flush();
$channel = $location->getChannel();
if ($channel->getLocations()->isEmpty()) {
$this->em->remove($channel);
$this->em->flush();
}
$this->em->getConnection()->commit();
} catch(\Exception $e) {
$this->em->getConnection()->rollback();
throw $e;
}
} | php | public function removeLocation($id)
{
/** @var Location $location */
$location = $this->getLocation($id);
$removableActivities = new ArrayCollection();
$notRemovableActivities = new ArrayCollection();
$accessToken = $this->em
->getRepository('CampaignChainSecurityAuthenticationClientOAuthBundle:Token')
->findOneBy(['location' => $location]);
try {
$this->em->getConnection()->beginTransaction();
if ($accessToken) {
$this->em->remove($accessToken);
$this->em->flush();
}
foreach ($location->getActivities() as $activity) {
if ($this->isRemovable($location)) {
$removableActivities->add($activity);
} else {
$notRemovableActivities->add($activity);
}
}
foreach ($removableActivities as $activity) {
$this->activityService->removeActivity($activity);
}
//Hack to find the belonging entities which has to be deleted first
$bundleName = explode('/', $location->getLocationModule()->getBundle()->getName());
$classPrefix = 'CampaignChain\\' . implode('\\', array_map(function ($e) {
return ucfirst($e);
}, explode('-', $bundleName[1]))) . 'Bundle';
$entitiesToDelete = [];
foreach ($this->em->getMetadataFactory()->getAllMetadata() as $metadataClass) {
if (strpos(strtolower($metadataClass->getName()), strtolower($classPrefix)) === 0) {
$entitiesToDelete[] = $metadataClass;
}
};
foreach ($entitiesToDelete as $repo) {
$entities = $this->em->getRepository($repo->getName())->findBy(['location' => $location->getId()]);
foreach ($entities as $entityToDelete) {
$this->em->remove($entityToDelete);
}
}
$this->em->flush();
$this->em->remove($location);
$this->em->flush();
$channel = $location->getChannel();
if ($channel->getLocations()->isEmpty()) {
$this->em->remove($channel);
$this->em->flush();
}
$this->em->getConnection()->commit();
} catch(\Exception $e) {
$this->em->getConnection()->rollback();
throw $e;
}
} | [
"public",
"function",
"removeLocation",
"(",
"$",
"id",
")",
"{",
"/** @var Location $location */",
"$",
"location",
"=",
"$",
"this",
"->",
"getLocation",
"(",
"$",
"id",
")",
";",
"$",
"removableActivities",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"$... | This method deletes a location if there are no closed activities.
If there are open activities the location is deactivated
@param $id
@throws \Exception | [
"This",
"method",
"deletes",
"a",
"location",
"if",
"there",
"are",
"no",
"closed",
"activities",
".",
"If",
"there",
"are",
"open",
"activities",
"the",
"location",
"is",
"deactivated"
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/LocationService.php#L369-L437 |
vipsoft/code-coverage-extension | src/VIPSoft/CodeCoverageExtension/Service/ReportService.php | ReportService.generateReport | public function generateReport(\PHP_CodeCoverage $coverage)
{
$format = $this->config['report']['format'];
$options = $this->config['report']['options'];
$report = $this->factory->create($format, $options);
$report->process($coverage);
} | php | public function generateReport(\PHP_CodeCoverage $coverage)
{
$format = $this->config['report']['format'];
$options = $this->config['report']['options'];
$report = $this->factory->create($format, $options);
$report->process($coverage);
} | [
"public",
"function",
"generateReport",
"(",
"\\",
"PHP_CodeCoverage",
"$",
"coverage",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"config",
"[",
"'report'",
"]",
"[",
"'format'",
"]",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"config",
"[",
"... | Generate report
@param \PHP_CodeCoverage $coverage | [
"Generate",
"report"
] | train | https://github.com/vipsoft/code-coverage-extension/blob/b49c1fe33528aa74024fd23a43428e615c104cdf/src/VIPSoft/CodeCoverageExtension/Service/ReportService.php#L47-L54 |
airan587/laravel-admin-aliossUpload | src/Http/Controllers/AliOssUploadController.php | AliOssUploadController.index | public function index() {
$config = config('admin.extensions.alioss-upload');
$id= $config['OSS_ACCESS_ID'];
$key= $config['OSS_ACCESS_KEY'];
$host = $config['OSS_HOST'];
$now = time();
$expire = 180; //设置该policy超时时间,秒
$end = $now + $expire;
$expiration = $this->gmt_iso8601( $end );
//前缀目录
$dir = $uploadDir = "files/". date( "Ym" )."/".date( "d" )."/" ; //'user-dir/';
//最大文件大小 20M
$condition = array( 0=>'content-length-range', 1=>0, 2=>20480000 );
$conditions[] = $condition;
//表示用户上传的数据,必须是以$dir开始,不然上传会失败,这一步不是必须项,只是为了安全起见,防止用户通过policy上传到别人的目录
$start = array( 0=>'starts-with', 1=>'$key', 2=>$dir );
$conditions[] = $start;
//根据自己的逻辑,设定expire 时间,让前端定时取signature
$arr = array( 'expiration'=>$expiration, 'conditions'=>$conditions );
$policy = json_encode( $arr );
$base64_policy = base64_encode( $policy );
$string_to_sign = $base64_policy;
$signature = base64_encode( hash_hmac( 'sha1', $string_to_sign, $key, true ) );
$response = array();
$response['accessid'] = $id;
$response['host'] = $host;
$response['policy'] = $base64_policy;
$response['signature'] = $signature;
$response['expire'] = $end;
//这个参数是设置用户上传指定的前缀
$response['dir'] = $dir;
$response['oss_url'] = $config['OSS_URL'];//仅用于方便前端组合图片路径
return $response;
} | php | public function index() {
$config = config('admin.extensions.alioss-upload');
$id= $config['OSS_ACCESS_ID'];
$key= $config['OSS_ACCESS_KEY'];
$host = $config['OSS_HOST'];
$now = time();
$expire = 180; //设置该policy超时时间,秒
$end = $now + $expire;
$expiration = $this->gmt_iso8601( $end );
//前缀目录
$dir = $uploadDir = "files/". date( "Ym" )."/".date( "d" )."/" ; //'user-dir/';
//最大文件大小 20M
$condition = array( 0=>'content-length-range', 1=>0, 2=>20480000 );
$conditions[] = $condition;
//表示用户上传的数据,必须是以$dir开始,不然上传会失败,这一步不是必须项,只是为了安全起见,防止用户通过policy上传到别人的目录
$start = array( 0=>'starts-with', 1=>'$key', 2=>$dir );
$conditions[] = $start;
//根据自己的逻辑,设定expire 时间,让前端定时取signature
$arr = array( 'expiration'=>$expiration, 'conditions'=>$conditions );
$policy = json_encode( $arr );
$base64_policy = base64_encode( $policy );
$string_to_sign = $base64_policy;
$signature = base64_encode( hash_hmac( 'sha1', $string_to_sign, $key, true ) );
$response = array();
$response['accessid'] = $id;
$response['host'] = $host;
$response['policy'] = $base64_policy;
$response['signature'] = $signature;
$response['expire'] = $end;
//这个参数是设置用户上传指定的前缀
$response['dir'] = $dir;
$response['oss_url'] = $config['OSS_URL'];//仅用于方便前端组合图片路径
return $response;
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"config",
"=",
"config",
"(",
"'admin.extensions.alioss-upload'",
")",
";",
"$",
"id",
"=",
"$",
"config",
"[",
"'OSS_ACCESS_ID'",
"]",
";",
"$",
"key",
"=",
"$",
"config",
"[",
"'OSS_ACCESS_KEY'",
"]",
... | 获取alioss参数 | [
"获取alioss参数"
] | train | https://github.com/airan587/laravel-admin-aliossUpload/blob/a884bb05919806d223e2f2aa792df6dedc8e1ad6/src/Http/Controllers/AliOssUploadController.php#L12-L50 |
airan587/laravel-admin-aliossUpload | src/Http/Controllers/AliOssUploadController.php | AliOssUploadController.delete | public function delete(){
$path = request('path');
//oss
$config = config('admin.extensions.alioss-upload');
$accessKeyId = $config['OSS_ACCESS_ID'];
$accessKeySecret = $config['OSS_ACCESS_KEY'];
$endpoint = $config['OSS_ENDPOINT'];
$bucket = $config['OSS_BUCKET'];
//连接oss
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
$ossClient->deleteObject($bucket, $path);//删除单个文件
} catch (OssException $e) {
return json_encode(["data"=>"OssException: ".$e->getMessage()]);
}
return json_encode(["data"=>'ok']);
} | php | public function delete(){
$path = request('path');
//oss
$config = config('admin.extensions.alioss-upload');
$accessKeyId = $config['OSS_ACCESS_ID'];
$accessKeySecret = $config['OSS_ACCESS_KEY'];
$endpoint = $config['OSS_ENDPOINT'];
$bucket = $config['OSS_BUCKET'];
//连接oss
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
$ossClient->deleteObject($bucket, $path);//删除单个文件
} catch (OssException $e) {
return json_encode(["data"=>"OssException: ".$e->getMessage()]);
}
return json_encode(["data"=>'ok']);
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"path",
"=",
"request",
"(",
"'path'",
")",
";",
"//oss",
"$",
"config",
"=",
"config",
"(",
"'admin.extensions.alioss-upload'",
")",
";",
"$",
"accessKeyId",
"=",
"$",
"config",
"[",
"'OSS_ACCESS_ID'",
"... | 删除文件 | [
"删除文件"
] | train | https://github.com/airan587/laravel-admin-aliossUpload/blob/a884bb05919806d223e2f2aa792df6dedc8e1ad6/src/Http/Controllers/AliOssUploadController.php#L53-L70 |
airan587/laravel-admin-aliossUpload | src/Http/Controllers/AliOssUploadController.php | AliOssUploadController.gmt_iso8601 | public function gmt_iso8601( $time ) {
$dtStr = date( "c", $time );
$mydatetime = new \DateTime( $dtStr );
$expiration = $mydatetime->format( \DateTime::ISO8601 );
$pos = strpos( $expiration, '+' );
$expiration = substr( $expiration, 0, $pos );
return $expiration."Z";
} | php | public function gmt_iso8601( $time ) {
$dtStr = date( "c", $time );
$mydatetime = new \DateTime( $dtStr );
$expiration = $mydatetime->format( \DateTime::ISO8601 );
$pos = strpos( $expiration, '+' );
$expiration = substr( $expiration, 0, $pos );
return $expiration."Z";
} | [
"public",
"function",
"gmt_iso8601",
"(",
"$",
"time",
")",
"{",
"$",
"dtStr",
"=",
"date",
"(",
"\"c\"",
",",
"$",
"time",
")",
";",
"$",
"mydatetime",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"dtStr",
")",
";",
"$",
"expiration",
"=",
"$",
"mydate... | gmt时间格式转换 | [
"gmt时间格式转换"
] | train | https://github.com/airan587/laravel-admin-aliossUpload/blob/a884bb05919806d223e2f2aa792df6dedc8e1ad6/src/Http/Controllers/AliOssUploadController.php#L82-L89 |
CampaignChain/core | Entity/ReportAnalyticsActivityFact.php | ReportAnalyticsActivityFact.getJavascriptTimestamp | public function getJavascriptTimestamp()
{
$date = new \DateTime($this->time->format('Y-m-d H:i:s'));
$javascriptTimestamp = $date->getTimestamp() * 1000;
return $javascriptTimestamp;
} | php | public function getJavascriptTimestamp()
{
$date = new \DateTime($this->time->format('Y-m-d H:i:s'));
$javascriptTimestamp = $date->getTimestamp() * 1000;
return $javascriptTimestamp;
} | [
"public",
"function",
"getJavascriptTimestamp",
"(",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"this",
"->",
"time",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
")",
";",
"$",
"javascriptTimestamp",
"=",
"$",
"date",
"->",
"getTimestamp... | Get time in JavaScript timestamp format.
@return \DateTime | [
"Get",
"time",
"in",
"JavaScript",
"timestamp",
"format",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportAnalyticsActivityFact.php#L105-L111 |
Deathnerd/php-wtforms | src/DefaultMeta.php | DefaultMeta.renderField | public function renderField(Field $field, $render_kw = [])
{
$other_kw = property_exists($field, 'render_kw') ? $field->render_kw : null;
if (!is_null($other_kw)) {
$render_kw = array_merge($other_kw, $render_kw);
}
$widget = $field->widget;
return $widget($field, $render_kw);
} | php | public function renderField(Field $field, $render_kw = [])
{
$other_kw = property_exists($field, 'render_kw') ? $field->render_kw : null;
if (!is_null($other_kw)) {
$render_kw = array_merge($other_kw, $render_kw);
}
$widget = $field->widget;
return $widget($field, $render_kw);
} | [
"public",
"function",
"renderField",
"(",
"Field",
"$",
"field",
",",
"$",
"render_kw",
"=",
"[",
"]",
")",
"{",
"$",
"other_kw",
"=",
"property_exists",
"(",
"$",
"field",
",",
"'render_kw'",
")",
"?",
"$",
"field",
"->",
"render_kw",
":",
"null",
";"... | @param Field $field
@param array $render_kw
@return mixed | [
"@param",
"Field",
"$field",
"@param",
"array",
"$render_kw"
] | train | https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/DefaultMeta.php#L53-L62 |
Deathnerd/php-wtforms | src/DefaultMeta.php | DefaultMeta.buildCSRF | public function buildCSRF(Form $form)
{
if (!is_null($this->csrf_class)) {
return (new \ReflectionClass($this->csrf_class))->newInstance();
}
return new SessionCSRF();
} | php | public function buildCSRF(Form $form)
{
if (!is_null($this->csrf_class)) {
return (new \ReflectionClass($this->csrf_class))->newInstance();
}
return new SessionCSRF();
} | [
"public",
"function",
"buildCSRF",
"(",
"Form",
"$",
"form",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"csrf_class",
")",
")",
"{",
"return",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"csrf_class",
")",
")",
"->"... | Build a CSRF implementation. This is called once per form instance
The default implementation builds the class referenced to by
{@link csrf_class} with zero arguments. If {@link csrf_class} is ``null``,
will instead use the default implementation {@link \WTForms\CSRF\Session\SessionCSRF}.
@param Form $form The form
@return object|SessionCSRF A CSRF representation | [
"Build",
"a",
"CSRF",
"implementation",
".",
"This",
"is",
"called",
"once",
"per",
"form",
"instance",
"The",
"default",
"implementation",
"builds",
"the",
"class",
"referenced",
"to",
"by",
"{",
"@link",
"csrf_class",
"}",
"with",
"zero",
"arguments",
".",
... | train | https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/DefaultMeta.php#L74-L81 |
ionux/phactor | src/Math.php | Math.Multiply | public function Multiply($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->mul($a, $b);
} | php | public function Multiply($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->mul($a, $b);
} | [
"public",
"function",
"Multiply",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"mul",
"(",
"$",
"a",
"... | Multiplies two arbitrary precision numbers.
@param string $a The first number to multiply.
@param string $b The second number to multiply.
@return string The result of the operation. | [
"Multiplies",
"two",
"arbitrary",
"precision",
"numbers",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L51-L56 |
ionux/phactor | src/Math.php | Math.Add | public function Add($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->add($a, $b);
} | php | public function Add($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->add($a, $b);
} | [
"public",
"function",
"Add",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"add",
"(",
"$",
"a",
",",
... | Adds two arbitrary precision numbers.
@param string $a The first number to add.
@param string $b The second number to add.
@return string The result of the operation. | [
"Adds",
"two",
"arbitrary",
"precision",
"numbers",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L65-L70 |
ionux/phactor | src/Math.php | Math.Subtract | public function Subtract($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->sub($a, $b);
} | php | public function Subtract($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->sub($a, $b);
} | [
"public",
"function",
"Subtract",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"sub",
"(",
"$",
"a",
"... | Subtracts two arbitrary precision numbers.
@param string $a The first number to Subtract.
@param string $b The second number to Subtract.
@return string The result of the operation. | [
"Subtracts",
"two",
"arbitrary",
"precision",
"numbers",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L79-L84 |
ionux/phactor | src/Math.php | Math.Divide | public function Divide($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->div($a, $b);
} | php | public function Divide($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->div($a, $b);
} | [
"public",
"function",
"Divide",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"div",
"(",
"$",
"a",
","... | Divides two arbitrary precision numbers.
@param string $a The first number to Divide.
@param string $b The second number to Divide.
@return string The result of the operation. | [
"Divides",
"two",
"arbitrary",
"precision",
"numbers",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L93-L98 |
ionux/phactor | src/Math.php | Math.Modulo | public function Modulo($a, $b, $correct = false)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->mod($a, $b, $correct);
} | php | public function Modulo($a, $b, $correct = false)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->mod($a, $b, $correct);
} | [
"public",
"function",
"Modulo",
"(",
"$",
"a",
",",
"$",
"b",
",",
"$",
"correct",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math"... | Performs the modulo 'b' of an arbitrary precision
number 'a'. There's a slight quirk in GMP's
implementation so this returns a mathematically
correct answer if you specify the $correct parameter
and you're using GMP, of course.
@param string $a The first number.
@param string $b The second number.
@param boolean $correct Flag to calculate mathematically correct modulo.
@return string The result of the operation. | [
"Performs",
"the",
"modulo",
"b",
"of",
"an",
"arbitrary",
"precision",
"number",
"a",
".",
"There",
"s",
"a",
"slight",
"quirk",
"in",
"GMP",
"s",
"implementation",
"so",
"this",
"returns",
"a",
"mathematically",
"correct",
"answer",
"if",
"you",
"specify",... | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L112-L117 |
ionux/phactor | src/Math.php | Math.PowMod | public function PowMod($a, $b, $c)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->powmod($a, $b, $c);
} | php | public function PowMod($a, $b, $c)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->powmod($a, $b, $c);
} | [
"public",
"function",
"PowMod",
"(",
"$",
"a",
",",
"$",
"b",
",",
"$",
"c",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"powmod",
... | Raises an arbitrary precision number to another,
reduced by a specified modulus.
@param string $a The first number.
@param string $b The exponent.
@param string $c The modulus.
@return string The result of the operation. | [
"Raises",
"an",
"arbitrary",
"precision",
"number",
"to",
"another",
"reduced",
"by",
"a",
"specified",
"modulus",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L128-L133 |
ionux/phactor | src/Math.php | Math.Invert | public function Invert($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->inv($a, $b);
} | php | public function Invert($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->inv($a, $b);
} | [
"public",
"function",
"Invert",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"inv",
"(",
"$",
"a",
","... | Performs the inverse modulo of two arbitrary precision numbers.
@param string $a The first number to Divide.
@param string $b The second number to Divide.
@return string The result of the operation. | [
"Performs",
"the",
"inverse",
"modulo",
"of",
"two",
"arbitrary",
"precision",
"numbers",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L142-L147 |
ionux/phactor | src/Math.php | Math.Compare | public function Compare($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->comp($a, $b);
} | php | public function Compare($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->comp($a, $b);
} | [
"public",
"function",
"Compare",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"comp",
"(",
"$",
"a",
"... | Compares two arbitrary precision numbers.
@param string $a The first number to compare.
@param string $b The second number to compare.
@return string The result of the comparison. | [
"Compares",
"two",
"arbitrary",
"precision",
"numbers",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L156-L161 |
ionux/phactor | src/Math.php | Math.Power | public function Power($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->power($a, $b);
} | php | public function Power($a, $b)
{
$this->preOpMethodParamsCheck(array($a, $b));
return $this->math->power($a, $b);
} | [
"public",
"function",
"Power",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"return",
"$",
"this",
"->",
"math",
"->",
"power",
"(",
"$",
"a",
",... | Raises an arbitrary precision number to an integer power.
@param string $a The number to raise to the power.
@param string $b The integer power
@return string The result of the operation. | [
"Raises",
"an",
"arbitrary",
"precision",
"number",
"to",
"an",
"integer",
"power",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L170-L175 |
ionux/phactor | src/Math.php | Math.encodeHex | public function encodeHex($dec, $prefix = true)
{
$this->preOpMethodParamsCheck(array($dec));
$dec = ($this->Test($dec) != 'hex') ? strrev($this->encodeValue($this->absValue($dec), '16')) : $dec;
return ($prefix === true) ? $this->addHexPrefix($dec) : $dec;
} | php | public function encodeHex($dec, $prefix = true)
{
$this->preOpMethodParamsCheck(array($dec));
$dec = ($this->Test($dec) != 'hex') ? strrev($this->encodeValue($this->absValue($dec), '16')) : $dec;
return ($prefix === true) ? $this->addHexPrefix($dec) : $dec;
} | [
"public",
"function",
"encodeHex",
"(",
"$",
"dec",
",",
"$",
"prefix",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"dec",
")",
")",
";",
"$",
"dec",
"=",
"(",
"$",
"this",
"->",
"Test",
"(",
"$",
"... | Encodes a decimal value into hexadecimal.
@param string $dec The decimal value to convert.
@param boolean $prefix Whether or not to append the '0x'.
@return string $hex The result of the conversion. | [
"Encodes",
"a",
"decimal",
"value",
"into",
"hexadecimal",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L197-L204 |
ionux/phactor | src/Math.php | Math.decodeHex | public function decodeHex($hex)
{
$this->preOpMethodParamsCheck(array($hex));
$dec = false;
if ($this->Test($hex) == 'hex') {
$hex = $this->stripHexPrefix($this->prepAndClean($hex));
$hex_len = strlen($hex);
if ($hex_len < 5) {
$dec = hexdec($hex);
} else {
for ($i = 0; $i < $hex_len; $i++) {
$current = stripos($this->hex_chars, $hex[$i]);
$dec = $this->math->add($this->math->mul($dec, '16'), $current);
}
}
}
return ($dec === false) ? $hex : $dec;
} | php | public function decodeHex($hex)
{
$this->preOpMethodParamsCheck(array($hex));
$dec = false;
if ($this->Test($hex) == 'hex') {
$hex = $this->stripHexPrefix($this->prepAndClean($hex));
$hex_len = strlen($hex);
if ($hex_len < 5) {
$dec = hexdec($hex);
} else {
for ($i = 0; $i < $hex_len; $i++) {
$current = stripos($this->hex_chars, $hex[$i]);
$dec = $this->math->add($this->math->mul($dec, '16'), $current);
}
}
}
return ($dec === false) ? $hex : $dec;
} | [
"public",
"function",
"decodeHex",
"(",
"$",
"hex",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"hex",
")",
")",
";",
"$",
"dec",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"Test",
"(",
"$",
"hex",
")",
"=... | Decodes a hexadecimal value into decimal.
@param string $hex
@return string $dec | [
"Decodes",
"a",
"hexadecimal",
"value",
"into",
"decimal",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L212-L234 |
ionux/phactor | src/Math.php | Math.D2B | public function D2B($num)
{
$this->preOpMethodParamsCheck(array($num));
/* Make sure that we're dealing with a decimal number. */
$num = $this->decodeHex($num);
try {
$bin = '';
while ($this->math->comp($num, '0') > 0) {
switch ($this->math->mod($num, '2')) {
case '1':
$bin .= '1';
break;
default:
$bin .= '0';
break;
}
$num = $this->math->div($num, '2');
}
return $bin;
} catch (\Exception $e) {
throw $e;
}
} | php | public function D2B($num)
{
$this->preOpMethodParamsCheck(array($num));
/* Make sure that we're dealing with a decimal number. */
$num = $this->decodeHex($num);
try {
$bin = '';
while ($this->math->comp($num, '0') > 0) {
switch ($this->math->mod($num, '2')) {
case '1':
$bin .= '1';
break;
default:
$bin .= '0';
break;
}
$num = $this->math->div($num, '2');
}
return $bin;
} catch (\Exception $e) {
throw $e;
}
} | [
"public",
"function",
"D2B",
"(",
"$",
"num",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"num",
")",
")",
";",
"/* Make sure that we're dealing with a decimal number. */",
"$",
"num",
"=",
"$",
"this",
"->",
"decodeHex",
"("... | This method returns a binary string representation of
the decimal number. Used for the doubleAndAdd() method.
@param string $num The number to convert.
@return string $bin The converted number.
@throws \Exception | [
"This",
"method",
"returns",
"a",
"binary",
"string",
"representation",
"of",
"the",
"decimal",
"number",
".",
"Used",
"for",
"the",
"doubleAndAdd",
"()",
"method",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L244-L273 |
ionux/phactor | src/Math.php | Math.binConv | public function binConv($hex)
{
$this->preOpMethodParamsCheck(array($hex));
switch ($this->Test($hex)) {
case 'dec':
$hex = $this->encodeHex($hex);
break;
case 'hex':
$hex = $this->addHexPrefix($this->prepAndClean($hex));
break;
default:
throw new \Exception('Unknown data type passed to the binConv() function. Value received was "' . var_export($hex, true) . '".');
}
return strrev($this->encodeValue($hex, '256'));
} | php | public function binConv($hex)
{
$this->preOpMethodParamsCheck(array($hex));
switch ($this->Test($hex)) {
case 'dec':
$hex = $this->encodeHex($hex);
break;
case 'hex':
$hex = $this->addHexPrefix($this->prepAndClean($hex));
break;
default:
throw new \Exception('Unknown data type passed to the binConv() function. Value received was "' . var_export($hex, true) . '".');
}
return strrev($this->encodeValue($hex, '256'));
} | [
"public",
"function",
"binConv",
"(",
"$",
"hex",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"hex",
")",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"Test",
"(",
"$",
"hex",
")",
")",
"{",
"case",
"'dec'",
":",
... | Converts hex value into octet (byte) string.
@param string $hex
@return string
@throws \Exception | [
"Converts",
"hex",
"value",
"into",
"octet",
"(",
"byte",
")",
"string",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L282-L298 |
ionux/phactor | src/Math.php | Math.encodeBase58 | public function encodeBase58($hex)
{
$this->preOpMethodParamsCheck(array($hex));
try {
if (strlen($hex) % 2 != 0 || $this->Test($hex) != 'hex') {
throw new \Exception('Uneven number of hex characters or invalid parameter passed to encodeBase58 function. Value received was "' . var_export($hex, true) . '".');
} else {
$orighex = $hex;
$hex = $this->addHexPrefix($this->prepAndClean($hex));
$return = strrev($this->encodeValue($hex, '58'));
for ($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == '00'; $i += 2) {
$return = '1' . $return;
}
}
return $return;
} catch (\Exception $e) {
throw $e;
}
} | php | public function encodeBase58($hex)
{
$this->preOpMethodParamsCheck(array($hex));
try {
if (strlen($hex) % 2 != 0 || $this->Test($hex) != 'hex') {
throw new \Exception('Uneven number of hex characters or invalid parameter passed to encodeBase58 function. Value received was "' . var_export($hex, true) . '".');
} else {
$orighex = $hex;
$hex = $this->addHexPrefix($this->prepAndClean($hex));
$return = strrev($this->encodeValue($hex, '58'));
for ($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == '00'; $i += 2) {
$return = '1' . $return;
}
}
return $return;
} catch (\Exception $e) {
throw $e;
}
} | [
"public",
"function",
"encodeBase58",
"(",
"$",
"hex",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"hex",
")",
")",
";",
"try",
"{",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"%",
"2",
"!=",
"0",
"||",
"$",
"th... | Converts a hex number to BASE-58 used for Bitcoin-related tasks.
@param string $hex
@return string $return
@throws \Exception | [
"Converts",
"a",
"hex",
"number",
"to",
"BASE",
"-",
"58",
"used",
"for",
"Bitcoin",
"-",
"related",
"tasks",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L307-L330 |
ionux/phactor | src/Math.php | Math.decodeBase58 | public function decodeBase58($base58)
{
$this->preOpMethodParamsCheck(array($base58));
try {
$origbase58 = $base58;
$return = '0';
$b58_len = strlen($base58);
for ($i = 0; $i < $b58_len; $i++) {
$current = strpos($this->b58_chars, $base58[$i]);
$return = $this->math->mul($return, '58');
$return = $this->math->add($return, $current);
}
$return = $this->encodeHex($return);
for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == '1'; $i++) {
$return = '00' . $return;
}
return (strlen($return) % 2 != 0) ? '0' . $return : $return;
} catch (\Exception $e) {
throw $e;
}
} | php | public function decodeBase58($base58)
{
$this->preOpMethodParamsCheck(array($base58));
try {
$origbase58 = $base58;
$return = '0';
$b58_len = strlen($base58);
for ($i = 0; $i < $b58_len; $i++) {
$current = strpos($this->b58_chars, $base58[$i]);
$return = $this->math->mul($return, '58');
$return = $this->math->add($return, $current);
}
$return = $this->encodeHex($return);
for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == '1'; $i++) {
$return = '00' . $return;
}
return (strlen($return) % 2 != 0) ? '0' . $return : $return;
} catch (\Exception $e) {
throw $e;
}
} | [
"public",
"function",
"decodeBase58",
"(",
"$",
"base58",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"base58",
")",
")",
";",
"try",
"{",
"$",
"origbase58",
"=",
"$",
"base58",
";",
"$",
"return",
"=",
"'0'",
";",
... | Converts a BASE-58 number used for Bitcoin-related tasks to hex.
@param string $base58
@return string $return
@throws \Exception | [
"Converts",
"a",
"BASE",
"-",
"58",
"number",
"used",
"for",
"Bitcoin",
"-",
"related",
"tasks",
"to",
"hex",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L339-L365 |
ionux/phactor | src/Math.php | Math.MathCheck | private function MathCheck()
{
if ($this->math == null || is_object($this->math) === false) {
if (function_exists('gmp_add')) {
$this->math = new GMP();
} else if (function_exists('bcadd')) {
$this->math = new BC();
} else {
throw new \Exception('Both GMP and BC Math extensions are missing on this system! Please install one to use the Phactor math library.');
}
}
$this->bytes = (empty($this->bytes)) ? $this->GenBytes() : $this->bytes;
} | php | private function MathCheck()
{
if ($this->math == null || is_object($this->math) === false) {
if (function_exists('gmp_add')) {
$this->math = new GMP();
} else if (function_exists('bcadd')) {
$this->math = new BC();
} else {
throw new \Exception('Both GMP and BC Math extensions are missing on this system! Please install one to use the Phactor math library.');
}
}
$this->bytes = (empty($this->bytes)) ? $this->GenBytes() : $this->bytes;
} | [
"private",
"function",
"MathCheck",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"math",
"==",
"null",
"||",
"is_object",
"(",
"$",
"this",
"->",
"math",
")",
"===",
"false",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gmp_add'",
")",
")",
"{",
... | Internal function to make sure we can find an acceptable math extension to use here.
@throws \Exception | [
"Internal",
"function",
"to",
"make",
"sure",
"we",
"can",
"find",
"an",
"acceptable",
"math",
"extension",
"to",
"use",
"here",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L372-L385 |
ionux/phactor | src/Math.php | Math.preOpMethodParamsCheck | private function preOpMethodParamsCheck($params)
{
$this->MathCheck();
foreach ($params as $key => $value) {
if ($this->numberCheck($value) === false) {
$caller = debug_backtrace();
throw new \Exception('Empty or invalid parameters passed to ' . $caller[count($caller) - 1]['function'] . ' function. Argument list received: ' . var_export($caller[count($caller) - 1]['args'], true));
}
}
} | php | private function preOpMethodParamsCheck($params)
{
$this->MathCheck();
foreach ($params as $key => $value) {
if ($this->numberCheck($value) === false) {
$caller = debug_backtrace();
throw new \Exception('Empty or invalid parameters passed to ' . $caller[count($caller) - 1]['function'] . ' function. Argument list received: ' . var_export($caller[count($caller) - 1]['args'], true));
}
}
} | [
"private",
"function",
"preOpMethodParamsCheck",
"(",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"MathCheck",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"numberCheck",
... | Handles the pre-work validation checking for method parameters.
@param array $params The array of parameters to check.
@return boolean Will only be true, otherwise throws \Exception
@throws \Exception | [
"Handles",
"the",
"pre",
"-",
"work",
"validation",
"checking",
"for",
"method",
"parameters",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L394-L404 |
ionux/phactor | src/Math.php | Math.encodeValue | private function encodeValue($val, $base)
{
$this->preOpMethodParamsCheck(array($val, $base));
$digits = $this->baseCheck($base);
try {
$new = '';
while ($this->math->comp($val, '0') > 0) {
$qq = $this->math->div($val, $base);
$rem = $this->math->mod($val, $base);
$val = $qq;
$new = $new . $digits[$rem];
}
return $new;
} catch (\Exception $e) {
throw $e;
}
} | php | private function encodeValue($val, $base)
{
$this->preOpMethodParamsCheck(array($val, $base));
$digits = $this->baseCheck($base);
try {
$new = '';
while ($this->math->comp($val, '0') > 0) {
$qq = $this->math->div($val, $base);
$rem = $this->math->mod($val, $base);
$val = $qq;
$new = $new . $digits[$rem];
}
return $new;
} catch (\Exception $e) {
throw $e;
}
} | [
"private",
"function",
"encodeValue",
"(",
"$",
"val",
",",
"$",
"base",
")",
"{",
"$",
"this",
"->",
"preOpMethodParamsCheck",
"(",
"array",
"(",
"$",
"val",
",",
"$",
"base",
")",
")",
";",
"$",
"digits",
"=",
"$",
"this",
"->",
"baseCheck",
"(",
... | The generic value encoding method.
@param string $val A number to convert.
@param string $base The base to convert it into.
@return string The same number but in a different base.
@throws \Exception | [
"The",
"generic",
"value",
"encoding",
"method",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L414-L436 |
ionux/phactor | src/Math.php | Math.zeroCompare | private function zeroCompare($a, $b)
{
return ($this->math->comp($a, '0') <= 0 || $this->math->comp($b, '0') <= 0);
} | php | private function zeroCompare($a, $b)
{
return ($this->math->comp($a, '0') <= 0 || $this->math->comp($b, '0') <= 0);
} | [
"private",
"function",
"zeroCompare",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"math",
"->",
"comp",
"(",
"$",
"a",
",",
"'0'",
")",
"<=",
"0",
"||",
"$",
"this",
"->",
"math",
"->",
"comp",
"(",
"$",
"b",
","... | Checks if two parameters are less than or equal to zero.
@param string $a The first parameter to check.
@param string $b The second parameter to check.
@return boolean Result of the check. | [
"Checks",
"if",
"two",
"parameters",
"are",
"less",
"than",
"or",
"equal",
"to",
"zero",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L472-L475 |
notthatbad/silverstripe-rest-api | code/controllers/NestedResourceRestController.php | NestedResourceRestController.beforeCallActionHandler | public final function beforeCallActionHandler(\SS_HTTPRequest $request, $action) {
$id = $request->param(\Config::inst()->get('NestedResourceRestController', 'root_resource_id_field'));
if(!$id) {
throw new RestUserException(static::$no_id_message, static::$no_id_message);
}
$resource = $this->getRootResource($id);
if(!$resource) {
\SS_Log::log("NoResourceError was not handled inside the controller", \SS_Log::WARN);
throw new RestSystemException("NoResourceError was not handled inside the controller", 501);
}
// call the action and inject the root resource
return $this->$action($request, $resource);
} | php | public final function beforeCallActionHandler(\SS_HTTPRequest $request, $action) {
$id = $request->param(\Config::inst()->get('NestedResourceRestController', 'root_resource_id_field'));
if(!$id) {
throw new RestUserException(static::$no_id_message, static::$no_id_message);
}
$resource = $this->getRootResource($id);
if(!$resource) {
\SS_Log::log("NoResourceError was not handled inside the controller", \SS_Log::WARN);
throw new RestSystemException("NoResourceError was not handled inside the controller", 501);
}
// call the action and inject the root resource
return $this->$action($request, $resource);
} | [
"public",
"final",
"function",
"beforeCallActionHandler",
"(",
"\\",
"SS_HTTPRequest",
"$",
"request",
",",
"$",
"action",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"param",
"(",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'NestedRes... | Get called by the action handler of BaseRestController. Tries to fetch the root resource.
@param \SS_HTTPRequest $request a http request
@param string $action the name of the action (eg. post, put, get, delete)
@return array the result of the action call
@throws RestSystemException
@throws RestUserException | [
"Get",
"called",
"by",
"the",
"action",
"handler",
"of",
"BaseRestController",
".",
"Tries",
"to",
"fetch",
"the",
"root",
"resource",
"."
] | train | https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/NestedResourceRestController.php#L36-L48 |
diemuzi/mp3 | src/Mp3/Service/ServiceProvider.php | ServiceProvider.getSearchPath | protected function getSearchPath()
{
if (!isset($this->config['mp3']['searchPath'])) {
throw new \Exception(
$this->translate->translate(
'searchPath is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['searchPath'];
} | php | protected function getSearchPath()
{
if (!isset($this->config['mp3']['searchPath'])) {
throw new \Exception(
$this->translate->translate(
'searchPath is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['searchPath'];
} | [
"protected",
"function",
"getSearchPath",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'mp3'",
"]",
"[",
"'searchPath'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"translate",
"-... | Get Search Path
@return string
@throws \Exception | [
"Get",
"Search",
"Path"
] | train | https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L65-L77 |
diemuzi/mp3 | src/Mp3/Service/ServiceProvider.php | ServiceProvider.getBaseDir | protected function getBaseDir()
{
if (!isset($this->config['mp3']['baseDir'])) {
throw new \Exception(
$this->translate->translate(
'baseDir is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['baseDir'];
} | php | protected function getBaseDir()
{
if (!isset($this->config['mp3']['baseDir'])) {
throw new \Exception(
$this->translate->translate(
'baseDir is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['baseDir'];
} | [
"protected",
"function",
"getBaseDir",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'mp3'",
"]",
"[",
"'baseDir'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"translate",
"->",
... | Get Base Directory
@return string
@throws \Exception | [
"Get",
"Base",
"Directory"
] | train | https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L85-L97 |
diemuzi/mp3 | src/Mp3/Service/ServiceProvider.php | ServiceProvider.getFormat | protected function getFormat()
{
if (!isset($this->config['mp3']['format'])) {
throw new \Exception(
$this->translate->translate(
'format is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['format'];
} | php | protected function getFormat()
{
if (!isset($this->config['mp3']['format'])) {
throw new \Exception(
$this->translate->translate(
'format is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['format'];
} | [
"protected",
"function",
"getFormat",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'mp3'",
"]",
"[",
"'format'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"translate",
"->",
"t... | Get Format
@return string
@throws \Exception | [
"Get",
"Format"
] | train | https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L105-L117 |
diemuzi/mp3 | src/Mp3/Service/ServiceProvider.php | ServiceProvider.getSearchFile | protected function getSearchFile()
{
if (!isset($this->config['mp3']['searchFile'])) {
throw new \Exception(
$this->translate->translate(
'searchFile is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['searchFile'];
} | php | protected function getSearchFile()
{
if (!isset($this->config['mp3']['searchFile'])) {
throw new \Exception(
$this->translate->translate(
'searchFile is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['searchFile'];
} | [
"protected",
"function",
"getSearchFile",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'mp3'",
"]",
"[",
"'searchFile'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"translate",
"-... | Get Search File
@return string
@throws \Exception | [
"Get",
"Search",
"File"
] | train | https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L125-L137 |
diemuzi/mp3 | src/Mp3/Service/ServiceProvider.php | ServiceProvider.getMemoryLimit | protected function getMemoryLimit()
{
if (!isset($this->config['mp3']['memoryLimit'])) {
throw new \Exception(
$this->translate->translate(
'memoryLimit is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['memoryLimit'];
} | php | protected function getMemoryLimit()
{
if (!isset($this->config['mp3']['memoryLimit'])) {
throw new \Exception(
$this->translate->translate(
'memoryLimit is not currently set',
'mp3'
)
);
}
return $this->config['mp3']['memoryLimit'];
} | [
"protected",
"function",
"getMemoryLimit",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'mp3'",
"]",
"[",
"'memoryLimit'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"translate",
... | Get Memory Limit
@return string
@throws \Exception | [
"Get",
"Memory",
"Limit"
] | train | https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L145-L157 |
moharrum/laravel-geoip-world-cities | src/seeds/CitiesTableSeeder.php | CitiesTableSeeder.run | public function run()
{
foreach($this->dumpFiles() as $dumpPart) {
$query = "LOAD DATA LOCAL INFILE '"
. str_replace('\\', '/', $dumpPart) . "'
INTO TABLE `" . Config::citiesTableName() . "`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n' IGNORE 1 LINES
(country,
city_ascii,
city,
region,
population,
latitude,
longitude
)";
DB::connection()->getpdo()->exec($query);
}
} | php | public function run()
{
foreach($this->dumpFiles() as $dumpPart) {
$query = "LOAD DATA LOCAL INFILE '"
. str_replace('\\', '/', $dumpPart) . "'
INTO TABLE `" . Config::citiesTableName() . "`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n' IGNORE 1 LINES
(country,
city_ascii,
city,
region,
population,
latitude,
longitude
)";
DB::connection()->getpdo()->exec($query);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dumpFiles",
"(",
")",
"as",
"$",
"dumpPart",
")",
"{",
"$",
"query",
"=",
"\"LOAD DATA LOCAL INFILE '\"",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"dumpPart",... | Run the database seeds.
@return void | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/moharrum/laravel-geoip-world-cities/blob/2a3e928d644da3348c3f203b4f41208209c5e97c/src/seeds/CitiesTableSeeder.php#L28-L49 |
moharrum/laravel-geoip-world-cities | src/seeds/CitiesTableSeeder.php | CitiesTableSeeder.dumpFiles | private function dumpFiles()
{
$files = [];
foreach(File::allFiles(Config::dumpPath()) as $dumpFile) {
$files[] = $dumpFile->getRealpath();
}
sort($files);
return $files;
} | php | private function dumpFiles()
{
$files = [];
foreach(File::allFiles(Config::dumpPath()) as $dumpFile) {
$files[] = $dumpFile->getRealpath();
}
sort($files);
return $files;
} | [
"private",
"function",
"dumpFiles",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"File",
"::",
"allFiles",
"(",
"Config",
"::",
"dumpPath",
"(",
")",
")",
"as",
"$",
"dumpFile",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"dum... | Returns an array containing the full path to each dump file.
@return array | [
"Returns",
"an",
"array",
"containing",
"the",
"full",
"path",
"to",
"each",
"dump",
"file",
"."
] | train | https://github.com/moharrum/laravel-geoip-world-cities/blob/2a3e928d644da3348c3f203b4f41208209c5e97c/src/seeds/CitiesTableSeeder.php#L56-L67 |
vakata/image | src/Image.php | Image.resize | public function resize(int $width = 0, int $height = 0) : ImageInterface
{
$this->operations[] = [ __FUNCTION__, func_get_args() ];
return $this;
} | php | public function resize(int $width = 0, int $height = 0) : ImageInterface
{
$this->operations[] = [ __FUNCTION__, func_get_args() ];
return $this;
} | [
"public",
"function",
"resize",
"(",
"int",
"$",
"width",
"=",
"0",
",",
"int",
"$",
"height",
"=",
"0",
")",
":",
"ImageInterface",
"{",
"$",
"this",
"->",
"operations",
"[",
"]",
"=",
"[",
"__FUNCTION__",
",",
"func_get_args",
"(",
")",
"]",
";",
... | Resize the image, if one dimension is skipped it will be automatically calculated.
@param int|integer $width the width of the resized image
@param int|integer $height the height of the resized image
@return $this | [
"Resize",
"the",
"image",
"if",
"one",
"dimension",
"is",
"skipped",
"it",
"will",
"be",
"automatically",
"calculated",
"."
] | train | https://github.com/vakata/image/blob/1d074cc6e274b1b8fe97cf138efcd2c665699686/src/Image.php#L47-L51 |
vakata/image | src/Image.php | Image.crop | public function crop(int $width = 0, int $height = 0, array $keep = [], bool $keepEnlarge = false) : ImageInterface
{
$this->operations[] = [ __FUNCTION__, func_get_args() ];
return $this;
} | php | public function crop(int $width = 0, int $height = 0, array $keep = [], bool $keepEnlarge = false) : ImageInterface
{
$this->operations[] = [ __FUNCTION__, func_get_args() ];
return $this;
} | [
"public",
"function",
"crop",
"(",
"int",
"$",
"width",
"=",
"0",
",",
"int",
"$",
"height",
"=",
"0",
",",
"array",
"$",
"keep",
"=",
"[",
"]",
",",
"bool",
"$",
"keepEnlarge",
"=",
"false",
")",
":",
"ImageInterface",
"{",
"$",
"this",
"->",
"o... | Crop a thumbnail with hardcoded dimensions, if one dimension is skipped it will be automatically calculated.
@param int|integer $width the width of the thumbnail
@param int|integer $height the height of the thumbnail
@param array $keep optional array of x, y, w, h of the import part of the image
@param array $keepEnlarge should the keep zone be enlarged to fit the thumbnail - defaults to false
@return $this | [
"Crop",
"a",
"thumbnail",
"with",
"hardcoded",
"dimensions",
"if",
"one",
"dimension",
"is",
"skipped",
"it",
"will",
"be",
"automatically",
"calculated",
"."
] | train | https://github.com/vakata/image/blob/1d074cc6e274b1b8fe97cf138efcd2c665699686/src/Image.php#L60-L64 |
vakata/image | src/Image.php | Image.toString | public function toString(string $format = null) : string
{
$operations = $this->operations;
$operations[] = [ 'getImage', [ $format ] ];
$driver = $this->getDriver();
return array_reduce($operations, function ($carry, $item) use ($driver) {
return $driver->{$item[0]}(...$item[1]);
});
} | php | public function toString(string $format = null) : string
{
$operations = $this->operations;
$operations[] = [ 'getImage', [ $format ] ];
$driver = $this->getDriver();
return array_reduce($operations, function ($carry, $item) use ($driver) {
return $driver->{$item[0]}(...$item[1]);
});
} | [
"public",
"function",
"toString",
"(",
"string",
"$",
"format",
"=",
"null",
")",
":",
"string",
"{",
"$",
"operations",
"=",
"$",
"this",
"->",
"operations",
";",
"$",
"operations",
"[",
"]",
"=",
"[",
"'getImage'",
",",
"[",
"$",
"format",
"]",
"]"... | Get the converted image
@param string|null $format the format to use (optional, if null the current format will be used)
@return string binary string of the converted image | [
"Get",
"the",
"converted",
"image"
] | train | https://github.com/vakata/image/blob/1d074cc6e274b1b8fe97cf138efcd2c665699686/src/Image.php#L100-L109 |
JustBlackBird/handlebars.php-helpers | src/Comparison/IfAnyHelper.php | IfAnyHelper.evaluateCondition | protected function evaluateCondition($args)
{
if (count($args) == 0) {
throw new \InvalidArgumentException(
'"ifAny" helper expects at least one argument.'
);
}
foreach ($args as $value) {
if ($value instanceof StringWrapper) {
// Casting any object of \Handlebars\StringWrapper will have
// false positive result even for those with empty internal
// strings. Thus we need to check internal string of such
// objects.
$value = $value->getString();
}
if ($value) {
return true;
}
}
return false;
} | php | protected function evaluateCondition($args)
{
if (count($args) == 0) {
throw new \InvalidArgumentException(
'"ifAny" helper expects at least one argument.'
);
}
foreach ($args as $value) {
if ($value instanceof StringWrapper) {
// Casting any object of \Handlebars\StringWrapper will have
// false positive result even for those with empty internal
// strings. Thus we need to check internal string of such
// objects.
$value = $value->getString();
}
if ($value) {
return true;
}
}
return false;
} | [
"protected",
"function",
"evaluateCondition",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'\"ifAny\" helper expects at least one argument.'",
")",
";",
"}",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Comparison/IfAnyHelper.php#L36-L59 |
Spomky-Labs/RoleHierarchyBundle | Security/RoleHierarchy.php | RoleHierarchy.buildRolesTree | protected function buildRolesTree(RoleManagerInterface $role_manager)
{
$hierarchy = [];
$roles = $role_manager->getRoles();
foreach ($roles as $role) {
if ($role instanceof RoleInterface) {
if ($role->getParent()) {
if (!isset($hierarchy[$role->getParent()->getName()])) {
$hierarchy[$role->getParent()->getName()] = [];
}
$hierarchy[$role->getParent()->getName()][] = $role->getName();
} else {
if (!isset($hierarchy[$role->getName()])) {
$hierarchy[$role->getName()] = [];
}
}
}
}
return $hierarchy;
} | php | protected function buildRolesTree(RoleManagerInterface $role_manager)
{
$hierarchy = [];
$roles = $role_manager->getRoles();
foreach ($roles as $role) {
if ($role instanceof RoleInterface) {
if ($role->getParent()) {
if (!isset($hierarchy[$role->getParent()->getName()])) {
$hierarchy[$role->getParent()->getName()] = [];
}
$hierarchy[$role->getParent()->getName()][] = $role->getName();
} else {
if (!isset($hierarchy[$role->getName()])) {
$hierarchy[$role->getName()] = [];
}
}
}
}
return $hierarchy;
} | [
"protected",
"function",
"buildRolesTree",
"(",
"RoleManagerInterface",
"$",
"role_manager",
")",
"{",
"$",
"hierarchy",
"=",
"[",
"]",
";",
"$",
"roles",
"=",
"$",
"role_manager",
"->",
"getRoles",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
... | @param \SpomkyLabs\RoleHierarchyBundle\Model\RoleManagerInterface $role_manager
@return array | [
"@param",
"\\",
"SpomkyLabs",
"\\",
"RoleHierarchyBundle",
"\\",
"Model",
"\\",
"RoleManagerInterface",
"$role_manager"
] | train | https://github.com/Spomky-Labs/RoleHierarchyBundle/blob/f6df7a8777c1e3094889f7e94af4942b35924f7b/Security/RoleHierarchy.php#L36-L56 |
Deathnerd/php-wtforms | src/csrf/core/CSRFTokenField.php | CSRFTokenField.process | public function process($formdata, $data = null)
{
parent::process($formdata, $data);
$this->current_token = $this->csrf_impl->generateCSRFToken($this);
} | php | public function process($formdata, $data = null)
{
parent::process($formdata, $data);
$this->current_token = $this->csrf_impl->generateCSRFToken($this);
} | [
"public",
"function",
"process",
"(",
"$",
"formdata",
",",
"$",
"data",
"=",
"null",
")",
"{",
"parent",
"::",
"process",
"(",
"$",
"formdata",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"current_token",
"=",
"$",
"this",
"->",
"csrf_impl",
"->"... | @param $formdata
@param null $data
@throws WTForms\Exceptions\NotImplemented | [
"@param",
"$formdata",
"@param",
"null",
"$data"
] | train | https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/csrf/core/CSRFTokenField.php#L75-L79 |
caffeinated/widgets | src/WidgetFactory.php | WidgetFactory.flattenParameters | protected function flattenParameters(array $parameters)
{
$flattened = array();
foreach($parameters as $parameter) {
array_walk($parameter, function($value, $key) use (&$flattened) {
$flattened[$key] = $value;
});
}
return $flattened;
} | php | protected function flattenParameters(array $parameters)
{
$flattened = array();
foreach($parameters as $parameter) {
array_walk($parameter, function($value, $key) use (&$flattened) {
$flattened[$key] = $value;
});
}
return $flattened;
} | [
"protected",
"function",
"flattenParameters",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"flattened",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
")",
"{",
"array_walk",
"(",
"$",
"parameter",
",",
"function... | Flattens the given array.
@param array $parameters
@return array | [
"Flattens",
"the",
"given",
"array",
"."
] | train | https://github.com/caffeinated/widgets/blob/3cd508518c4d62cf6173304638e7a06324a69d61/src/WidgetFactory.php#L67-L78 |
jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php | AbstractElementProcessor.getThing | protected function getThing($typeof, $resourceId, ContextInterface $context)
{
/** @var TypeInterface[] $types */
$types = [];
if (strlen($typeof)) {
foreach (preg_split('/\s+/', $typeof) as $prefixedType) {
$types[] = $this->getType($prefixedType, $context);
}
}
return new Thing($types, $resourceId);
} | php | protected function getThing($typeof, $resourceId, ContextInterface $context)
{
/** @var TypeInterface[] $types */
$types = [];
if (strlen($typeof)) {
foreach (preg_split('/\s+/', $typeof) as $prefixedType) {
$types[] = $this->getType($prefixedType, $context);
}
}
return new Thing($types, $resourceId);
} | [
"protected",
"function",
"getThing",
"(",
"$",
"typeof",
",",
"$",
"resourceId",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"/** @var TypeInterface[] $types */",
"$",
"types",
"=",
"[",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"typeof",
")",
")",
"... | Return a thing by typeof value
@param string|null $typeof Thing type
@param string|null $resourceId Resource ID
@param ContextInterface $context Context
@return Thing Thing
@throws RuntimeException If the default vocabulary is empty | [
"Return",
"a",
"thing",
"by",
"typeof",
"value"
] | train | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php#L138-L149 |
jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php | AbstractElementProcessor.getType | protected function getType($prefixedType, ContextInterface $context)
{
list($prefix, $typeName) = $this->getPrefixName($prefixedType);
$vocabulary = $this->getVocabulary($prefix, $context);
if ($vocabulary instanceof VocabularyInterface) {
return new Type($typeName, $vocabulary);
}
// If the default vocabulary is empty
throw new RuntimeException(
RuntimeException::EMPTY_DEFAULT_VOCABULARY_STR,
RuntimeException::EMPTY_DEFAULT_VOCABULARY
);
} | php | protected function getType($prefixedType, ContextInterface $context)
{
list($prefix, $typeName) = $this->getPrefixName($prefixedType);
$vocabulary = $this->getVocabulary($prefix, $context);
if ($vocabulary instanceof VocabularyInterface) {
return new Type($typeName, $vocabulary);
}
// If the default vocabulary is empty
throw new RuntimeException(
RuntimeException::EMPTY_DEFAULT_VOCABULARY_STR,
RuntimeException::EMPTY_DEFAULT_VOCABULARY
);
} | [
"protected",
"function",
"getType",
"(",
"$",
"prefixedType",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"list",
"(",
"$",
"prefix",
",",
"$",
"typeName",
")",
"=",
"$",
"this",
"->",
"getPrefixName",
"(",
"$",
"prefixedType",
")",
";",
"$",
"voc... | Instantiate a type
@param string $prefixedType Prefixed type
@param ContextInterface $context Context
@return TypeInterface Type | [
"Instantiate",
"a",
"type"
] | train | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php#L158-L171 |
CampaignChain/core | Entity/Activity.php | Activity.setStatus | public function setStatus($status, $calledFromOperation = false)
{
parent::setStatus($status);
// Change the Operation as well only if this method has not been called by an Operation instance to avoid recursion.
if (!$calledFromOperation && $this->getEqualsOperation() && count($this->getOperations())) {
$this->getOperations()[0]->setStatus($this->status, true);
}
return $this;
} | php | public function setStatus($status, $calledFromOperation = false)
{
parent::setStatus($status);
// Change the Operation as well only if this method has not been called by an Operation instance to avoid recursion.
if (!$calledFromOperation && $this->getEqualsOperation() && count($this->getOperations())) {
$this->getOperations()[0]->setStatus($this->status, true);
}
return $this;
} | [
"public",
"function",
"setStatus",
"(",
"$",
"status",
",",
"$",
"calledFromOperation",
"=",
"false",
")",
"{",
"parent",
"::",
"setStatus",
"(",
"$",
"status",
")",
";",
"// Change the Operation as well only if this method has not been called by an Operation instance to av... | If the Activity equals the Operation, then set the status of the Activity to the same value.
@param string $status
@param bool $calledFromOperation
@return Activity | [
"If",
"the",
"Activity",
"equals",
"the",
"Operation",
"then",
"set",
"the",
"status",
"of",
"the",
"Activity",
"to",
"the",
"same",
"value",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/Activity.php#L296-L306 |
CampaignChain/core | Util/SystemUtil.php | SystemUtil.redirectInstallMode | static function redirectInstallMode($redirectUrl = '/campaignchain/install.php')
{
// Only apply if in request context.
if(isset($_SERVER['REQUEST_URI'])) {
if (
self::isInstallMode() &&
false === strpos($_SERVER['REQUEST_URI'], '/install/')
) {
// System is not installed yet and user wants to access
// a secured page. Hence, redirect to Installation Wizard.
header('Location: '.$redirectUrl);
exit;
} elseif (
// System is installed and user wants to access the Installation
// Wizard. Hence, redirect to login page.
!self::isInstallMode() &&
0 === strpos($_SERVER['REQUEST_URI'], '/install/')
) {
header('Location: /');
exit;
}
}
} | php | static function redirectInstallMode($redirectUrl = '/campaignchain/install.php')
{
// Only apply if in request context.
if(isset($_SERVER['REQUEST_URI'])) {
if (
self::isInstallMode() &&
false === strpos($_SERVER['REQUEST_URI'], '/install/')
) {
// System is not installed yet and user wants to access
// a secured page. Hence, redirect to Installation Wizard.
header('Location: '.$redirectUrl);
exit;
} elseif (
// System is installed and user wants to access the Installation
// Wizard. Hence, redirect to login page.
!self::isInstallMode() &&
0 === strpos($_SERVER['REQUEST_URI'], '/install/')
) {
header('Location: /');
exit;
}
}
} | [
"static",
"function",
"redirectInstallMode",
"(",
"$",
"redirectUrl",
"=",
"'/campaignchain/install.php'",
")",
"{",
"// Only apply if in request context.",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
")",
"{",
"if",
"(",
"self",
"::",... | Checks whether system is in install mode.
@param string $redirectUrl | [
"Checks",
"whether",
"system",
"is",
"in",
"install",
"mode",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L44-L66 |
CampaignChain/core | Util/SystemUtil.php | SystemUtil.getConfigFiles | public static function getConfigFiles()
{
$configFiles = array();
$symfonyConfigDir =
self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'config';
$campaignchainConfigDir =
self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'campaignchain'.DIRECTORY_SEPARATOR.
'config';
$configFiles['kernel_symfony'] =
self::getRootDir().'app'.DIRECTORY_SEPARATOR.'AppKernel.php';
$configFiles['bundles_dist'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'AppKernel_campaignchain.php';
$configFiles['bundles'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'campaignchain'.DIRECTORY_SEPARATOR.
'AppKernel.php';
$configFiles['config_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR.
'config_campaignchain_imports.yml.dist';
$configFiles['config'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR.
'imports.yml';
$configFiles['routing_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR.
'routing_campaignchain.yml.dist';
$configFiles['routing'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR.
'routing.yml';
$configFiles['security_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR.
'security_campaignchain.yml.dist';
$configFiles['security'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR.
'security.yml';
return $configFiles;
} | php | public static function getConfigFiles()
{
$configFiles = array();
$symfonyConfigDir =
self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'config';
$campaignchainConfigDir =
self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'campaignchain'.DIRECTORY_SEPARATOR.
'config';
$configFiles['kernel_symfony'] =
self::getRootDir().'app'.DIRECTORY_SEPARATOR.'AppKernel.php';
$configFiles['bundles_dist'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'AppKernel_campaignchain.php';
$configFiles['bundles'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR.
'campaignchain'.DIRECTORY_SEPARATOR.
'AppKernel.php';
$configFiles['config_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR.
'config_campaignchain_imports.yml.dist';
$configFiles['config'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR.
'imports.yml';
$configFiles['routing_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR.
'routing_campaignchain.yml.dist';
$configFiles['routing'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR.
'routing.yml';
$configFiles['security_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR.
'security_campaignchain.yml.dist';
$configFiles['security'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR.
'security.yml';
return $configFiles;
} | [
"public",
"static",
"function",
"getConfigFiles",
"(",
")",
"{",
"$",
"configFiles",
"=",
"array",
"(",
")",
";",
"$",
"symfonyConfigDir",
"=",
"self",
"::",
"getRootDir",
"(",
")",
".",
"'app'",
".",
"DIRECTORY_SEPARATOR",
".",
"'config'",
";",
"$",
"camp... | Returns an array with the absolute path of all configuration files
of the CampaignChain app.
@return array | [
"Returns",
"an",
"array",
"with",
"the",
"absolute",
"path",
"of",
"all",
"configuration",
"files",
"of",
"the",
"CampaignChain",
"app",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L98-L134 |
CampaignChain/core | Util/SystemUtil.php | SystemUtil.initKernel | public static function initKernel()
{
$configFiles = self::getConfigFiles();
$fs = new Filesystem();
if(!$fs->exists($configFiles['bundles'])){
$fs->copy($configFiles['bundles_dist'], $configFiles['bundles'], true);
}
if(!$fs->exists($configFiles['config'])){
$fs->copy($configFiles['config_dist'], $configFiles['config'], true);
}
if(!$fs->exists($configFiles['routing'])){
$fs->copy($configFiles['routing_dist'], $configFiles['routing'], true);
}
if(!$fs->exists($configFiles['security'])){
$fs->copy($configFiles['security_dist'], $configFiles['security'], true);
}
} | php | public static function initKernel()
{
$configFiles = self::getConfigFiles();
$fs = new Filesystem();
if(!$fs->exists($configFiles['bundles'])){
$fs->copy($configFiles['bundles_dist'], $configFiles['bundles'], true);
}
if(!$fs->exists($configFiles['config'])){
$fs->copy($configFiles['config_dist'], $configFiles['config'], true);
}
if(!$fs->exists($configFiles['routing'])){
$fs->copy($configFiles['routing_dist'], $configFiles['routing'], true);
}
if(!$fs->exists($configFiles['security'])){
$fs->copy($configFiles['security_dist'], $configFiles['security'], true);
}
} | [
"public",
"static",
"function",
"initKernel",
"(",
")",
"{",
"$",
"configFiles",
"=",
"self",
"::",
"getConfigFiles",
"(",
")",
";",
"$",
"fs",
"=",
"new",
"Filesystem",
"(",
")",
";",
"if",
"(",
"!",
"$",
"fs",
"->",
"exists",
"(",
"$",
"configFiles... | Creates the CampaignChain app configuration files based on the default
files or overwrites existing ones with the default. | [
"Creates",
"the",
"CampaignChain",
"app",
"configuration",
"files",
"based",
"on",
"the",
"default",
"files",
"or",
"overwrites",
"existing",
"ones",
"with",
"the",
"default",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L140-L158 |
CampaignChain/core | Util/SystemUtil.php | SystemUtil.resetApp | public static function resetApp()
{
// Set install mode.
SystemUtil::enableInstallMode();
$currentDir = getcwd();
chdir(self::getRootDir());
ob_start();
// Drop all tables
$command = 'php bin/console doctrine:schema:drop --force --full-database';
system($command, $output);
// Run composer post install command.
$command = 'composer run-script post-install-cmd';
system($command, $output);
ob_get_clean();
chdir($currentDir);
} | php | public static function resetApp()
{
// Set install mode.
SystemUtil::enableInstallMode();
$currentDir = getcwd();
chdir(self::getRootDir());
ob_start();
// Drop all tables
$command = 'php bin/console doctrine:schema:drop --force --full-database';
system($command, $output);
// Run composer post install command.
$command = 'composer run-script post-install-cmd';
system($command, $output);
ob_get_clean();
chdir($currentDir);
} | [
"public",
"static",
"function",
"resetApp",
"(",
")",
"{",
"// Set install mode.",
"SystemUtil",
"::",
"enableInstallMode",
"(",
")",
";",
"$",
"currentDir",
"=",
"getcwd",
"(",
")",
";",
"chdir",
"(",
"self",
"::",
"getRootDir",
"(",
")",
")",
";",
"ob_st... | Puts the CampaignChain app into same status as after a fresh
<code>
composer create-project
</code>
installation. | [
"Puts",
"the",
"CampaignChain",
"app",
"into",
"same",
"status",
"as",
"after",
"a",
"fresh",
"<code",
">",
"composer",
"create",
"-",
"project",
"<",
"/",
"code",
">",
"installation",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L167-L183 |
JustBlackBird/handlebars.php-helpers | src/Layout/UnlessOverriddenHelper.php | UnlessOverriddenHelper.execute | public function execute(Template $template, Context $context, $args, $source)
{
// Get block name
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 1) {
throw new \InvalidArgumentException(
'"unlessOverridden" helper expects exactly one argument.'
);
}
$block_name = $context->get(array_shift($parsed_args));
// Check condition and render blocks
if (!$this->blocksStorage->has($block_name)) {
$template->setStopToken('else');
$buffer = $template->render($context);
$template->setStopToken(false);
} else {
$template->setStopToken('else');
$template->discard();
$template->setStopToken(false);
$buffer = $template->render($context);
}
return $buffer;
} | php | public function execute(Template $template, Context $context, $args, $source)
{
// Get block name
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 1) {
throw new \InvalidArgumentException(
'"unlessOverridden" helper expects exactly one argument.'
);
}
$block_name = $context->get(array_shift($parsed_args));
// Check condition and render blocks
if (!$this->blocksStorage->has($block_name)) {
$template->setStopToken('else');
$buffer = $template->render($context);
$template->setStopToken(false);
} else {
$template->setStopToken('else');
$template->discard();
$template->setStopToken(false);
$buffer = $template->render($context);
}
return $buffer;
} | [
"public",
"function",
"execute",
"(",
"Template",
"$",
"template",
",",
"Context",
"$",
"context",
",",
"$",
"args",
",",
"$",
"source",
")",
"{",
"// Get block name",
"$",
"parsed_args",
"=",
"$",
"template",
"->",
"parseArguments",
"(",
"$",
"args",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Layout/UnlessOverriddenHelper.php#L39-L63 |
canis-io/lumen-jwt-auth | src/Adapters/Lcobucci/Generator.php | Generator.getDefaultClaims | protected function getDefaultClaims()
{
$default = [];
$default['nbf'] = time() + $this->config['nbfOffset'];
$default['exp'] = time() + $this->config['expOffset'];
if (!empty($this->config['issuer'])) {
$default['iss'] = $this->config['issuer'];
}
if (!empty($this->config['audience'])) {
$default['aud'] = $this->config['audience'];
}
return $default;
} | php | protected function getDefaultClaims()
{
$default = [];
$default['nbf'] = time() + $this->config['nbfOffset'];
$default['exp'] = time() + $this->config['expOffset'];
if (!empty($this->config['issuer'])) {
$default['iss'] = $this->config['issuer'];
}
if (!empty($this->config['audience'])) {
$default['aud'] = $this->config['audience'];
}
return $default;
} | [
"protected",
"function",
"getDefaultClaims",
"(",
")",
"{",
"$",
"default",
"=",
"[",
"]",
";",
"$",
"default",
"[",
"'nbf'",
"]",
"=",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"config",
"[",
"'nbfOffset'",
"]",
";",
"$",
"default",
"[",
"'exp'",
... | Default claims (can be overriden)
@return array | [
"Default",
"claims",
"(",
"can",
"be",
"overriden",
")"
] | train | https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/Adapters/Lcobucci/Generator.php#L54-L66 |
moharrum/laravel-geoip-world-cities | src/Console/CreateCitiesSeederCommand.php | CreateCitiesSeederCommand.handle | public function handle()
{
$exists = false;
if (File::exists($this->publishedSeederRealpath())) {
$exists = true;
if (!$this->confirm('The seeder file already exists, overwrite it? [Yes|no]')) {
return $this->info('Okay, no changes made to the file.');
}
}
try {
if(! $exists) {
$this->callSilent('make:seed', ['name' => substr($this->seeder_file, 0, strpos($this->seeder_file, '.'))]);
}
} catch (\Exception $ex) {
}
$inputFile = file_get_contents($this->localSeederPath());
$outputFile = fopen($this->publishedSeederRealpath(), 'w');
if ($inputFile && $outputFile) {
fwrite($outputFile, $inputFile);
fclose($outputFile);
} else {
File::delete($this->publishedSeederRealpath());
return $this->error(
'There was an error creating the seeder file, '
.'check write permissions for ' . base_path('database') . DIRECTORY_SEPARATOR . 'seeds'
.PHP_EOL
.PHP_EOL
.'If you think this is a bug, please submit a bug report '
.'at https://github.com/moharrum/laravel-geoip-world-cities/issues'
);
}
if(! $exists) {
$this->info('Okay, seeder file created successfully.');
return;
}
$this->info('Okay, seeder file overwritten successfully.');
} | php | public function handle()
{
$exists = false;
if (File::exists($this->publishedSeederRealpath())) {
$exists = true;
if (!$this->confirm('The seeder file already exists, overwrite it? [Yes|no]')) {
return $this->info('Okay, no changes made to the file.');
}
}
try {
if(! $exists) {
$this->callSilent('make:seed', ['name' => substr($this->seeder_file, 0, strpos($this->seeder_file, '.'))]);
}
} catch (\Exception $ex) {
}
$inputFile = file_get_contents($this->localSeederPath());
$outputFile = fopen($this->publishedSeederRealpath(), 'w');
if ($inputFile && $outputFile) {
fwrite($outputFile, $inputFile);
fclose($outputFile);
} else {
File::delete($this->publishedSeederRealpath());
return $this->error(
'There was an error creating the seeder file, '
.'check write permissions for ' . base_path('database') . DIRECTORY_SEPARATOR . 'seeds'
.PHP_EOL
.PHP_EOL
.'If you think this is a bug, please submit a bug report '
.'at https://github.com/moharrum/laravel-geoip-world-cities/issues'
);
}
if(! $exists) {
$this->info('Okay, seeder file created successfully.');
return;
}
$this->info('Okay, seeder file overwritten successfully.');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"exists",
"=",
"false",
";",
"if",
"(",
"File",
"::",
"exists",
"(",
"$",
"this",
"->",
"publishedSeederRealpath",
"(",
")",
")",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"if",
"(",
"!",
"$",
... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/moharrum/laravel-geoip-world-cities/blob/2a3e928d644da3348c3f203b4f41208209c5e97c/src/Console/CreateCitiesSeederCommand.php#L64-L112 |
sulu/SuluAutomationBundle | Admin/AutomationAdmin.php | AutomationAdmin.getSecurityContexts | public function getSecurityContexts()
{
return [
'Sulu' => [
'Automation' => [
self::TASK_SECURITY_CONTEXT => [
PermissionTypes::VIEW,
PermissionTypes::ADD,
PermissionTypes::EDIT,
PermissionTypes::DELETE,
],
],
],
];
} | php | public function getSecurityContexts()
{
return [
'Sulu' => [
'Automation' => [
self::TASK_SECURITY_CONTEXT => [
PermissionTypes::VIEW,
PermissionTypes::ADD,
PermissionTypes::EDIT,
PermissionTypes::DELETE,
],
],
],
];
} | [
"public",
"function",
"getSecurityContexts",
"(",
")",
"{",
"return",
"[",
"'Sulu'",
"=>",
"[",
"'Automation'",
"=>",
"[",
"self",
"::",
"TASK_SECURITY_CONTEXT",
"=>",
"[",
"PermissionTypes",
"::",
"VIEW",
",",
"PermissionTypes",
"::",
"ADD",
",",
"PermissionTyp... | {@inheritdoc} | [
"{"
] | train | https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Admin/AutomationAdmin.php#L45-L59 |
TUNER88/laravel-redmine-api | src/RedmineClientServiceProvider.php | RedmineClientServiceProvider.register | public function register()
{
$app = $this->app;
// create image
$app['redmine'] = $app->share(function ($app) {
$configs = $app['config']->get('redmine');
if(!empty($configs['key'])) {
return new \Redmine\Client($configs['url'], $configs['key']);
} else {
return new \Redmine\Client($configs['url'], $configs['username'], $configs['password']);
}
});
} | php | public function register()
{
$app = $this->app;
// create image
$app['redmine'] = $app->share(function ($app) {
$configs = $app['config']->get('redmine');
if(!empty($configs['key'])) {
return new \Redmine\Client($configs['url'], $configs['key']);
} else {
return new \Redmine\Client($configs['url'], $configs['username'], $configs['password']);
}
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"// create image",
"$",
"app",
"[",
"'redmine'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"configs",
"=",
... | Register the application services.
@return void | [
"Register",
"the",
"application",
"services",
"."
] | train | https://github.com/TUNER88/laravel-redmine-api/blob/a80eb05d37aefb96ceb4b64d4517894ea3646375/src/RedmineClientServiceProvider.php#L45-L61 |
civicrm/civicrm-setup | src/Setup.php | Setup.init | public static function init($modelValues = array(), $pluginCallback = NULL, $log = NULL) {
if (!defined('CIVI_SETUP')) {
define('CIVI_SETUP', 1);
}
self::$instance = new Setup();
self::$instance->model = new \Civi\Setup\Model();
self::$instance->model->setValues($modelValues);
self::$instance->dispatcher = new EventDispatcher();
self::$instance->log = $log ? $log : new NullLogger();
$pluginDir = dirname(__DIR__) . '/plugins';
$pluginFiles = array();
foreach (['*.civi-setup.php', '*/*.civi-setup.php'] as $pattern) {
foreach ((array) glob("$pluginDir/$pattern") as $file) {
$key = substr($file, strlen($pluginDir) + 1);
$key = preg_replace('/\.civi-setup\.php$/', '', $key);
$pluginFiles[$key] = $file;
}
}
ksort($pluginFiles);
if ($pluginCallback) {
$pluginFiles = $pluginCallback($pluginFiles);
}
foreach ($pluginFiles as $pluginFile) {
self::$instance->log->debug('[Setup.php] Load plugin {file}', array(
'file' => $pluginFile,
));
require $pluginFile;
}
$event = new InitEvent(self::$instance->getModel());
self::$instance->getDispatcher()->dispatch('civi.setup.init', $event);
// return $event; ...or... return self::$instance;
} | php | public static function init($modelValues = array(), $pluginCallback = NULL, $log = NULL) {
if (!defined('CIVI_SETUP')) {
define('CIVI_SETUP', 1);
}
self::$instance = new Setup();
self::$instance->model = new \Civi\Setup\Model();
self::$instance->model->setValues($modelValues);
self::$instance->dispatcher = new EventDispatcher();
self::$instance->log = $log ? $log : new NullLogger();
$pluginDir = dirname(__DIR__) . '/plugins';
$pluginFiles = array();
foreach (['*.civi-setup.php', '*/*.civi-setup.php'] as $pattern) {
foreach ((array) glob("$pluginDir/$pattern") as $file) {
$key = substr($file, strlen($pluginDir) + 1);
$key = preg_replace('/\.civi-setup\.php$/', '', $key);
$pluginFiles[$key] = $file;
}
}
ksort($pluginFiles);
if ($pluginCallback) {
$pluginFiles = $pluginCallback($pluginFiles);
}
foreach ($pluginFiles as $pluginFile) {
self::$instance->log->debug('[Setup.php] Load plugin {file}', array(
'file' => $pluginFile,
));
require $pluginFile;
}
$event = new InitEvent(self::$instance->getModel());
self::$instance->getDispatcher()->dispatch('civi.setup.init', $event);
// return $event; ...or... return self::$instance;
} | [
"public",
"static",
"function",
"init",
"(",
"$",
"modelValues",
"=",
"array",
"(",
")",
",",
"$",
"pluginCallback",
"=",
"NULL",
",",
"$",
"log",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'CIVI_SETUP'",
")",
")",
"{",
"define",
"(",
... | The initialization process loads any `*.civi-setup.php` files and
fires the `civi.setup.init` event.
@param array $modelValues
List of default configuration options.
Recommended fields: 'srcPath', 'cms'
@param callable $pluginCallback
Function which manipulates the list of plugin files.
Use this to add, remove, or re-order callbacks.
function(array $files) => array
Ex: ['hello' => '/var/www/plugins/hello.civi-setup.php']
@param LoggerInterface $log | [
"The",
"initialization",
"process",
"loads",
"any",
"*",
".",
"civi",
"-",
"setup",
".",
"php",
"files",
"and",
"fires",
"the",
"civi",
".",
"setup",
".",
"init",
"event",
"."
] | train | https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup.php#L61-L97 |
civicrm/civicrm-setup | src/Setup.php | Setup.assertProtocolCompatibility | public static function assertProtocolCompatibility($expectedVersion) {
if (version_compare(self::PROTOCOL, $expectedVersion, '<')) {
throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion));
}
list ($actualFirst) = explode('.', self::PROTOCOL);
list ($expectedFirst) = explode('.', $expectedVersion);
if ($actualFirst > $expectedFirst) {
throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion));
}
} | php | public static function assertProtocolCompatibility($expectedVersion) {
if (version_compare(self::PROTOCOL, $expectedVersion, '<')) {
throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion));
}
list ($actualFirst) = explode('.', self::PROTOCOL);
list ($expectedFirst) = explode('.', $expectedVersion);
if ($actualFirst > $expectedFirst) {
throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion));
}
} | [
"public",
"static",
"function",
"assertProtocolCompatibility",
"(",
"$",
"expectedVersion",
")",
"{",
"if",
"(",
"version_compare",
"(",
"self",
"::",
"PROTOCOL",
",",
"$",
"expectedVersion",
",",
"'<'",
")",
")",
"{",
"throw",
"new",
"InitException",
"(",
"sp... | Assert that this copy of civicrm-setup is compatible with the client.
@param string $expectedVersion
@throws \Exception | [
"Assert",
"that",
"this",
"copy",
"of",
"civicrm",
"-",
"setup",
"is",
"compatible",
"with",
"the",
"client",
"."
] | train | https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup.php#L105-L114 |
JustBlackBird/handlebars.php-helpers | src/Collection/CountHelper.php | CountHelper.execute | public function execute(Template $template, Context $context, $args, $source)
{
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 1) {
throw new \InvalidArgumentException(
'"last" helper expects exactly one argument.'
);
}
$collection = $context->get($parsed_args[0]);
if (!is_array($collection) && !($collection instanceof \Countable)) {
throw new \InvalidArgumentException('Wrong type of the argument in the "count" helper.');
}
return count($collection);
} | php | public function execute(Template $template, Context $context, $args, $source)
{
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 1) {
throw new \InvalidArgumentException(
'"last" helper expects exactly one argument.'
);
}
$collection = $context->get($parsed_args[0]);
if (!is_array($collection) && !($collection instanceof \Countable)) {
throw new \InvalidArgumentException('Wrong type of the argument in the "count" helper.');
}
return count($collection);
} | [
"public",
"function",
"execute",
"(",
"Template",
"$",
"template",
",",
"Context",
"$",
"context",
",",
"$",
"args",
",",
"$",
"source",
")",
"{",
"$",
"parsed_args",
"=",
"$",
"template",
"->",
"parseArguments",
"(",
"$",
"args",
")",
";",
"if",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Collection/CountHelper.php#L36-L51 |
malenkiki/aleavatar | src/Malenki/Aleavatar/Primitive/Polygon.php | Polygon.point | public function point($int_x, $int_y)
{
if (is_double($int_x)) {
$int_x = (integer) $int_x;
}
if (is_double($int_y)) {
$int_y = (integer) $int_y;
}
if ((!is_integer($int_x) || !is_integer($int_y)) || $int_x < 0 || $int_y < 0) {
throw new \InvalidArgumentException('Coordinates must be composed of two positive integers!');
}
$this->arr_points[] = array($int_x, $int_y);
return $this;
} | php | public function point($int_x, $int_y)
{
if (is_double($int_x)) {
$int_x = (integer) $int_x;
}
if (is_double($int_y)) {
$int_y = (integer) $int_y;
}
if ((!is_integer($int_x) || !is_integer($int_y)) || $int_x < 0 || $int_y < 0) {
throw new \InvalidArgumentException('Coordinates must be composed of two positive integers!');
}
$this->arr_points[] = array($int_x, $int_y);
return $this;
} | [
"public",
"function",
"point",
"(",
"$",
"int_x",
",",
"$",
"int_y",
")",
"{",
"if",
"(",
"is_double",
"(",
"$",
"int_x",
")",
")",
"{",
"$",
"int_x",
"=",
"(",
"integer",
")",
"$",
"int_x",
";",
"}",
"if",
"(",
"is_double",
"(",
"$",
"int_y",
... | Adds one point by giving it x and y coordinates.
@param integer $int_x
@param integer $int_y
@throws \InvalidArgumentException If coordinates are not positive integers.
@access public
@return Polygon | [
"Adds",
"one",
"point",
"by",
"giving",
"it",
"x",
"and",
"y",
"coordinates",
"."
] | train | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Polygon.php#L66-L83 |
malenkiki/aleavatar | src/Malenki/Aleavatar/Primitive/Polygon.php | Polygon.svg | public function svg()
{
if (count($this->arr_points) < 3) {
throw new \RuntimeException('Before exporting to SVG, you must give at least 3 points!');
}
$arr = array();
foreach ($this->arr_points as $point) {
$arr[] = implode(',', $point);
}
$str_attr_points = implode(' ', $arr);
return sprintf('<polygon points="%s" style="fill:%s" />', $str_attr_points, $this->color);
} | php | public function svg()
{
if (count($this->arr_points) < 3) {
throw new \RuntimeException('Before exporting to SVG, you must give at least 3 points!');
}
$arr = array();
foreach ($this->arr_points as $point) {
$arr[] = implode(',', $point);
}
$str_attr_points = implode(' ', $arr);
return sprintf('<polygon points="%s" style="fill:%s" />', $str_attr_points, $this->color);
} | [
"public",
"function",
"svg",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"arr_points",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Before exporting to SVG, you must give at least 3 points!'",
")",
";",
"}",
"$",
"... | Returns the SVG code part rendering the current polygon.
@throws \RuntimeException If amount of point is less than 3.
@access public
@return void | [
"Returns",
"the",
"SVG",
"code",
"part",
"rendering",
"the",
"current",
"polygon",
"."
] | train | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Polygon.php#L110-L125 |
JustBlackBird/handlebars.php-helpers | src/Layout/ExtendsHelper.php | ExtendsHelper.execute | public function execute(Template $template, Context $context, $args, $source)
{
// Get name of the parent template
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 1) {
throw new \InvalidArgumentException(
'"extends" helper expects exactly one argument.'
);
}
$parent_template = $context->get(array_shift($parsed_args));
// Render content inside "extends" block to override blocks
$template->render($context);
// We need another instance of \Handlebars\Template to render parent
// template. It can be got from Handlebars engine, so get the engine.
$handlebars = $template->getEngine();
// Render the parent template
$this->level++;
$buffer = $handlebars->render($parent_template, $context);
$this->level--;
if ($this->level == 0) {
// The template and all its parents are rendered. Clean up the
// storage.
$this->blocksStorage->clear();
}
return $buffer;
} | php | public function execute(Template $template, Context $context, $args, $source)
{
// Get name of the parent template
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 1) {
throw new \InvalidArgumentException(
'"extends" helper expects exactly one argument.'
);
}
$parent_template = $context->get(array_shift($parsed_args));
// Render content inside "extends" block to override blocks
$template->render($context);
// We need another instance of \Handlebars\Template to render parent
// template. It can be got from Handlebars engine, so get the engine.
$handlebars = $template->getEngine();
// Render the parent template
$this->level++;
$buffer = $handlebars->render($parent_template, $context);
$this->level--;
if ($this->level == 0) {
// The template and all its parents are rendered. Clean up the
// storage.
$this->blocksStorage->clear();
}
return $buffer;
} | [
"public",
"function",
"execute",
"(",
"Template",
"$",
"template",
",",
"Context",
"$",
"context",
",",
"$",
"args",
",",
"$",
"source",
")",
"{",
"// Get name of the parent template",
"$",
"parsed_args",
"=",
"$",
"template",
"->",
"parseArguments",
"(",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Layout/ExtendsHelper.php#L48-L78 |
ionux/phactor | src/Key.php | Key.GenerateKeypair | public function GenerateKeypair()
{
$point = $this->GenerateNewPoint();
$point['Rx_hex'] = $this->stripHexPrefix($point['Rx_hex']);
$point['Ry_hex'] = $this->stripHexPrefix($point['Ry_hex']);
$point['random_number'] = $this->stripHexPrefix($point['random_number']);
$comp_prefix = ($this->Modulo($point['R']['y'], '2') == '1') ? '03' : '02';
$this->keyInfo = array(
'private_key_hex' => $this->encodeHex($point['random_number']),
'private_key_dec' => $point['random_number'],
'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'],
'public_key_compressed' => $comp_prefix . $point['Rx_hex'],
'public_key_x' => $point['Rx_hex'],
'public_key_y' => $point['Ry_hex'],
);
return $this->keyInfo;
} | php | public function GenerateKeypair()
{
$point = $this->GenerateNewPoint();
$point['Rx_hex'] = $this->stripHexPrefix($point['Rx_hex']);
$point['Ry_hex'] = $this->stripHexPrefix($point['Ry_hex']);
$point['random_number'] = $this->stripHexPrefix($point['random_number']);
$comp_prefix = ($this->Modulo($point['R']['y'], '2') == '1') ? '03' : '02';
$this->keyInfo = array(
'private_key_hex' => $this->encodeHex($point['random_number']),
'private_key_dec' => $point['random_number'],
'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'],
'public_key_compressed' => $comp_prefix . $point['Rx_hex'],
'public_key_x' => $point['Rx_hex'],
'public_key_y' => $point['Ry_hex'],
);
return $this->keyInfo;
} | [
"public",
"function",
"GenerateKeypair",
"(",
")",
"{",
"$",
"point",
"=",
"$",
"this",
"->",
"GenerateNewPoint",
"(",
")",
";",
"$",
"point",
"[",
"'Rx_hex'",
"]",
"=",
"$",
"this",
"->",
"stripHexPrefix",
"(",
"$",
"point",
"[",
"'Rx_hex'",
"]",
")",... | This is the main function for generating a new keypair.
@return array $keyInfo The complete keypair array. | [
"This",
"is",
"the",
"main",
"function",
"for",
"generating",
"a",
"new",
"keypair",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L109-L129 |
ionux/phactor | src/Key.php | Key.parseUncompressedPublicKey | public function parseUncompressedPublicKey($pubkey)
{
return (substr($pubkey, 0, 2) == '04') ? $this->prepAndClean(substr($pubkey, 2)) : $this->prepAndClean($pubkey);
} | php | public function parseUncompressedPublicKey($pubkey)
{
return (substr($pubkey, 0, 2) == '04') ? $this->prepAndClean(substr($pubkey, 2)) : $this->prepAndClean($pubkey);
} | [
"public",
"function",
"parseUncompressedPublicKey",
"(",
"$",
"pubkey",
")",
"{",
"return",
"(",
"substr",
"(",
"$",
"pubkey",
",",
"0",
",",
"2",
")",
"==",
"'04'",
")",
"?",
"$",
"this",
"->",
"prepAndClean",
"(",
"substr",
"(",
"$",
"pubkey",
",",
... | Checks if the uncompressed public key has the 0x04 prefix.
@param string $pubkey The key to check.
@return string The public key without the prefix. | [
"Checks",
"if",
"the",
"uncompressed",
"public",
"key",
"has",
"the",
"0x04",
"prefix",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L137-L140 |
ionux/phactor | src/Key.php | Key.parseCompressedPublicKey | public function parseCompressedPublicKey($pubkey, $returnHex = false)
{
$prefix = substr($pubkey, 0, 2);
if ($prefix !== '02' && $prefix !== '03') {
return $this->prepAndClean($pubkey);
}
$pointX = substr($pubkey, 2);
$pointY = substr($this->calcYfromX($pointX, $prefix), 2);
$parsedValue = $this->prepAndClean($pointX . $pointY);
return ($returnHex === false) ? $parsedValue : $this->encodeHex($parsedValue);
} | php | public function parseCompressedPublicKey($pubkey, $returnHex = false)
{
$prefix = substr($pubkey, 0, 2);
if ($prefix !== '02' && $prefix !== '03') {
return $this->prepAndClean($pubkey);
}
$pointX = substr($pubkey, 2);
$pointY = substr($this->calcYfromX($pointX, $prefix), 2);
$parsedValue = $this->prepAndClean($pointX . $pointY);
return ($returnHex === false) ? $parsedValue : $this->encodeHex($parsedValue);
} | [
"public",
"function",
"parseCompressedPublicKey",
"(",
"$",
"pubkey",
",",
"$",
"returnHex",
"=",
"false",
")",
"{",
"$",
"prefix",
"=",
"substr",
"(",
"$",
"pubkey",
",",
"0",
",",
"2",
")",
";",
"if",
"(",
"$",
"prefix",
"!==",
"'02'",
"&&",
"$",
... | Parses a compressed public key with the 0x02 or 0x03 prefix.
@param string $pubkey The key to check.
@param bool $returnHex Whether or not to return the value in decimal or hex.
@return string The (x,y) coordinate pair. | [
"Parses",
"a",
"compressed",
"public",
"key",
"with",
"the",
"0x02",
"or",
"0x03",
"prefix",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L149-L163 |
ionux/phactor | src/Key.php | Key.parseCoordinatePairFromPublicKey | public function parseCoordinatePairFromPublicKey($pubkey)
{
return array(
'x' => $this->addHexPrefix(substr($pubkey, 0, 64)),
'y' => $this->addHexPrefix(substr($pubkey, 64))
);
} | php | public function parseCoordinatePairFromPublicKey($pubkey)
{
return array(
'x' => $this->addHexPrefix(substr($pubkey, 0, 64)),
'y' => $this->addHexPrefix(substr($pubkey, 64))
);
} | [
"public",
"function",
"parseCoordinatePairFromPublicKey",
"(",
"$",
"pubkey",
")",
"{",
"return",
"array",
"(",
"'x'",
"=>",
"$",
"this",
"->",
"addHexPrefix",
"(",
"substr",
"(",
"$",
"pubkey",
",",
"0",
",",
"64",
")",
")",
",",
"'y'",
"=>",
"$",
"th... | Parses the x & y coordinates from an uncompressed public key.
@param string $pubkey The key to parse.
@return array The public key (x,y) coordinates. | [
"Parses",
"the",
"x",
"&",
"y",
"coordinates",
"from",
"an",
"uncompressed",
"public",
"key",
"."
] | train | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L171-L177 |
CampaignChain/core | Controller/REST/LocationController.php | LocationController.getLocationsAction | public function getLocationsAction($id)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->where('l.id = :id');
$qb->setParameter('id', $id);
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | php | public function getLocationsAction($id)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->where('l.id = :id');
$qb->setParameter('id', $id);
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | [
"public",
"function",
"getLocationsAction",
"(",
"$",
"id",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"self",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'Cam... | Get a specific Location by its ID.
Example Request
===============
GET /api/v1/locations/42
Example Response
================
[
{
"id": 129,
"identifier": "100008922632416",
"name": "Amariki Test One",
"url": "https://www.facebook.com/profile.php?id=100008922632416",
"image": "https://graph.facebook.com/100008922632416/picture?width=150&height=150",
"status": "active",
"createdDate": "2016-10-25T12:26:57+0000",
"modifiedDate": "2016-10-27T13:36:44+0000"
}
]
@ApiDoc(
section="Core",
requirements={
{
"name"="id",
"requirement"="\d+",
"description" = "Location ID"
}
}
)
@param string $id Location ID
@return \Symfony\Component\HttpFoundation\Response | [
"Get",
"a",
"specific",
"Location",
"by",
"its",
"ID",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/LocationController.php#L77-L89 |
CampaignChain/core | Controller/REST/LocationController.php | LocationController.postToggleStatusAction | public function postToggleStatusAction(Request $request)
{
$id = $request->request->get('id');
$service = $this->get('campaignchain.core.location');
try {
$status = $service->toggleStatus($id);
$response = $this->forward(
'CampaignChainCoreBundle:REST/Location:getLocations',
array(
'id' => $request->request->get('id')
)
);
return $response->setStatusCode(Response::HTTP_CREATED);
} catch (\Exception $e) {
return $this->errorResponse($e->getMessage());
}
} | php | public function postToggleStatusAction(Request $request)
{
$id = $request->request->get('id');
$service = $this->get('campaignchain.core.location');
try {
$status = $service->toggleStatus($id);
$response = $this->forward(
'CampaignChainCoreBundle:REST/Location:getLocations',
array(
'id' => $request->request->get('id')
)
);
return $response->setStatusCode(Response::HTTP_CREATED);
} catch (\Exception $e) {
return $this->errorResponse($e->getMessage());
}
} | [
"public",
"function",
"postToggleStatusAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.location... | Toggle the status of a Location to active or inactive.
Example Request
===============
POST /api/v1/location/toggle-status
Example Input
=============
{
"id": "42"
}
Example Response
================
See:
GET /api/v1/locations/{id}
@ApiDoc(
section="Core",
requirements={
{
"name"="id",
"requirement"="\d+",
"description" = "Location ID"
}
}
)
@REST\Post("/toggle-status")
@return \Symfony\Component\HttpFoundation\Response | [
"Toggle",
"the",
"status",
"of",
"a",
"Location",
"to",
"active",
"or",
"inactive",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/LocationController.php#L128-L146 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.getIdFromUsername | public function getIdFromUsername($username)
{
$id = $this->load('uname2uid', $username);
return ($id === 0) ? null : (int) $id;
} | php | public function getIdFromUsername($username)
{
$id = $this->load('uname2uid', $username);
return ($id === 0) ? null : (int) $id;
} | [
"public",
"function",
"getIdFromUsername",
"(",
"$",
"username",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"load",
"(",
"'uname2uid'",
",",
"$",
"username",
")",
";",
"return",
"(",
"$",
"id",
"===",
"0",
")",
"?",
"null",
":",
"(",
"int",
")",
... | Service will return the user ID of given username.
@param string $username
@return int | [
"Service",
"will",
"return",
"the",
"user",
"ID",
"of",
"given",
"username",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L44-L49 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.problems | public function problems()
{
$rawProblems = $this->load('p');
$problems = array();
foreach ($rawProblems as $problem) {
$problems[] = Helper\formatProblem($problem, false);
}
return $problems;
} | php | public function problems()
{
$rawProblems = $this->load('p');
$problems = array();
foreach ($rawProblems as $problem) {
$problems[] = Helper\formatProblem($problem, false);
}
return $problems;
} | [
"public",
"function",
"problems",
"(",
")",
"{",
"$",
"rawProblems",
"=",
"$",
"this",
"->",
"load",
"(",
"'p'",
")",
";",
"$",
"problems",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rawProblems",
"as",
"$",
"problem",
")",
"{",
"$",
"probl... | Returns the list of problems at UVa.
@return array | [
"Returns",
"the",
"list",
"of",
"problems",
"at",
"UVa",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L56-L66 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.problem | public function problem($id, $type = 'id')
{
$problem = $this->load('p', array($type, $id));
return Helper\formatProblem($problem);
} | php | public function problem($id, $type = 'id')
{
$problem = $this->load('p', array($type, $id));
return Helper\formatProblem($problem);
} | [
"public",
"function",
"problem",
"(",
"$",
"id",
",",
"$",
"type",
"=",
"'id'",
")",
"{",
"$",
"problem",
"=",
"$",
"this",
"->",
"load",
"(",
"'p'",
",",
"array",
"(",
"$",
"type",
",",
"$",
"id",
")",
")",
";",
"return",
"Helper",
"\\",
"form... | View a specific problem.
@param int $id
@param string $type accepted values are 'id' and 'num'.
@return array | [
"View",
"a",
"specific",
"problem",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L76-L81 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.problemSubmissions | public function problemSubmissions($problems, $start = 0, $end = 2147483648)
{
if (is_array($problems) === false) {
$problems = array($problems);
}
$rawSubmissions = $this->load('p/subs', array($problems, $start, $end));
$submissions = array();
foreach ($rawSubmissions as $submission) {
$submissions[] = Helper\formatSubmission($submission);
}
return $submissions;
} | php | public function problemSubmissions($problems, $start = 0, $end = 2147483648)
{
if (is_array($problems) === false) {
$problems = array($problems);
}
$rawSubmissions = $this->load('p/subs', array($problems, $start, $end));
$submissions = array();
foreach ($rawSubmissions as $submission) {
$submissions[] = Helper\formatSubmission($submission);
}
return $submissions;
} | [
"public",
"function",
"problemSubmissions",
"(",
"$",
"problems",
",",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"2147483648",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"problems",
")",
"===",
"false",
")",
"{",
"$",
"problems",
"=",
"array",
"(... | View submissions to specific problems on a given submission date range.
@param array|int $problems
@param int $start Unix timestamp.
@param int $end Unix timestamp.
@return array | [
"View",
"submissions",
"to",
"specific",
"problems",
"on",
"a",
"given",
"submission",
"date",
"range",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L92-L106 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.problemRanklist | public function problemRanklist($problem, $rank = 1, $count = 100)
{
$rawSubmissions = $this->load('p/rank', array($problem, $rank, $count));
return Helper\formatSubmissions($rawSubmissions);
} | php | public function problemRanklist($problem, $rank = 1, $count = 100)
{
$rawSubmissions = $this->load('p/rank', array($problem, $rank, $count));
return Helper\formatSubmissions($rawSubmissions);
} | [
"public",
"function",
"problemRanklist",
"(",
"$",
"problem",
",",
"$",
"rank",
"=",
"1",
",",
"$",
"count",
"=",
"100",
")",
"{",
"$",
"rawSubmissions",
"=",
"$",
"this",
"->",
"load",
"(",
"'p/rank'",
",",
"array",
"(",
"$",
"problem",
",",
"$",
... | Returns submissions to a problem ranked from $rank to $rank + $count - 1.
@param int $problem
@param int $rank
@param int $count
@return array | [
"Returns",
"submissions",
"to",
"a",
"problem",
"ranked",
"from",
"$rank",
"to",
"$rank",
"+",
"$count",
"-",
"1",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L117-L122 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.userProblemRanklist | public function userProblemRanklist($problem, $user, $above = 10, $below = 10)
{
$rawSubmissions = $this->load('p/ranklist', array($problem, $user, $above, $below));
$submissions = array();
foreach ($rawSubmissions as $submission) {
$submissions[] = Helper\formatSubmission($submission);
}
return $submissions;
} | php | public function userProblemRanklist($problem, $user, $above = 10, $below = 10)
{
$rawSubmissions = $this->load('p/ranklist', array($problem, $user, $above, $below));
$submissions = array();
foreach ($rawSubmissions as $submission) {
$submissions[] = Helper\formatSubmission($submission);
}
return $submissions;
} | [
"public",
"function",
"userProblemRanklist",
"(",
"$",
"problem",
",",
"$",
"user",
",",
"$",
"above",
"=",
"10",
",",
"$",
"below",
"=",
"10",
")",
"{",
"$",
"rawSubmissions",
"=",
"$",
"this",
"->",
"load",
"(",
"'p/ranklist'",
",",
"array",
"(",
"... | Returns nearby submissions (by runtime) for a particular user submission to a problem.
@param int $problem
@param int $user
@param int $above
@param int $below
@return array | [
"Returns",
"nearby",
"submissions",
"(",
"by",
"runtime",
")",
"for",
"a",
"particular",
"user",
"submission",
"to",
"a",
"problem",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L134-L144 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.userSubmissions | public function userSubmissions($user, $min = null)
{
if (is_null($min)) {
$rawSubmissions = $this->load('subs-user', $user);
} else {
$rawSubmissions = $this->load('subs-user', array($user, $min));
}
$submissions = array();
foreach ($rawSubmissions['subs'] as $submission) {
$submissions[] = Helper\formatUserSubmission(
$submission,
$user,
$rawSubmissions['name'],
$rawSubmissions['name']
);
}
return $submissions;
} | php | public function userSubmissions($user, $min = null)
{
if (is_null($min)) {
$rawSubmissions = $this->load('subs-user', $user);
} else {
$rawSubmissions = $this->load('subs-user', array($user, $min));
}
$submissions = array();
foreach ($rawSubmissions['subs'] as $submission) {
$submissions[] = Helper\formatUserSubmission(
$submission,
$user,
$rawSubmissions['name'],
$rawSubmissions['name']
);
}
return $submissions;
} | [
"public",
"function",
"userSubmissions",
"(",
"$",
"user",
",",
"$",
"min",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"min",
")",
")",
"{",
"$",
"rawSubmissions",
"=",
"$",
"this",
"->",
"load",
"(",
"'subs-user'",
",",
"$",
"user",
")... | Returns all of the submissions of a particular user.
@param int $user
@param int $min
@return array | [
"Returns",
"all",
"of",
"the",
"submissions",
"of",
"a",
"particular",
"user",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L154-L174 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.userProblemSubmissions | public function userProblemSubmissions($users, $problems, $min = 0, $type = 'id')
{
if (!is_array($users)) {
$users = array($users);
}
if (!is_array($problems)) {
$problems = array($problems);
}
if ($type === 'id') {
$rawSubmissions = $this->load('subs-pids', array($users, $problems, $min));
} else {
$rawSubmissions = $this->load('subs-nums', array($users, $problems, $min));
}
$users = array();
foreach ($rawSubmissions as $id => $user) {
foreach ($user['subs'] as $submission) {
$users[$id][] = Helper\formatUserSubmission(
$submission,
$id,
$user['name'],
$user['uname']
);
}
}
return $users;
} | php | public function userProblemSubmissions($users, $problems, $min = 0, $type = 'id')
{
if (!is_array($users)) {
$users = array($users);
}
if (!is_array($problems)) {
$problems = array($problems);
}
if ($type === 'id') {
$rawSubmissions = $this->load('subs-pids', array($users, $problems, $min));
} else {
$rawSubmissions = $this->load('subs-nums', array($users, $problems, $min));
}
$users = array();
foreach ($rawSubmissions as $id => $user) {
foreach ($user['subs'] as $submission) {
$users[$id][] = Helper\formatUserSubmission(
$submission,
$id,
$user['name'],
$user['uname']
);
}
}
return $users;
} | [
"public",
"function",
"userProblemSubmissions",
"(",
"$",
"users",
",",
"$",
"problems",
",",
"$",
"min",
"=",
"0",
",",
"$",
"type",
"=",
"'id'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"users",
")",
")",
"{",
"$",
"users",
"=",
"array",
... | Returns all the submissions of the users on specific problems.
@param array|int $users
@param array|int $problems
@param int $min
@param string $type
@return array | [
"Returns",
"all",
"the",
"submissions",
"of",
"the",
"users",
"on",
"specific",
"problems",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L212-L241 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.userSolvedProblems | public function userSolvedProblems($users)
{
if (is_array($users) === false) {
$users = array($users);
}
$rawSolved = $this->load('solved-bits', array($users));
$users = array();
foreach ($rawSolved as $user) {
$users[$user['uid']] = $user['solved'];
}
return $users;
} | php | public function userSolvedProblems($users)
{
if (is_array($users) === false) {
$users = array($users);
}
$rawSolved = $this->load('solved-bits', array($users));
$users = array();
foreach ($rawSolved as $user) {
$users[$user['uid']] = $user['solved'];
}
return $users;
} | [
"public",
"function",
"userSolvedProblems",
"(",
"$",
"users",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"users",
")",
"===",
"false",
")",
"{",
"$",
"users",
"=",
"array",
"(",
"$",
"users",
")",
";",
"}",
"$",
"rawSolved",
"=",
"$",
"this",
"->"... | Get The Bit-Encoded-Problem IDs that Has Been Solved by Some Authors.
@param array|int $users
@return array | [
"Get",
"The",
"Bit",
"-",
"Encoded",
"-",
"Problem",
"IDs",
"that",
"Has",
"Been",
"Solved",
"by",
"Some",
"Authors",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L250-L263 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.userRanklist | public function userRanklist($user, $above = 10, $below = 10)
{
$rawUsers = $this->load('ranklist', array($user, $above, $below));
$users = array();
foreach ($rawUsers as $user) {
$users[] = Helper\formatRanklist($user);
}
return $users;
} | php | public function userRanklist($user, $above = 10, $below = 10)
{
$rawUsers = $this->load('ranklist', array($user, $above, $below));
$users = array();
foreach ($rawUsers as $user) {
$users[] = Helper\formatRanklist($user);
}
return $users;
} | [
"public",
"function",
"userRanklist",
"(",
"$",
"user",
",",
"$",
"above",
"=",
"10",
",",
"$",
"below",
"=",
"10",
")",
"{",
"$",
"rawUsers",
"=",
"$",
"this",
"->",
"load",
"(",
"'ranklist'",
",",
"array",
"(",
"$",
"user",
",",
"$",
"above",
"... | Returns the user's ranklist and their neighbors.
@param int $user
@param int $above
@param int $below
@return array | [
"Returns",
"the",
"user",
"s",
"ranklist",
"and",
"their",
"neighbors",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L274-L284 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.ranklist | public function ranklist($pos = 1, $count = 10)
{
$rawUsers = $this->load('rank', array($pos, $count));
$users = array();
foreach ($rawUsers as $user) {
$users[] = Helper\formatRanklist($user);
}
return $users;
} | php | public function ranklist($pos = 1, $count = 10)
{
$rawUsers = $this->load('rank', array($pos, $count));
$users = array();
foreach ($rawUsers as $user) {
$users[] = Helper\formatRanklist($user);
}
return $users;
} | [
"public",
"function",
"ranklist",
"(",
"$",
"pos",
"=",
"1",
",",
"$",
"count",
"=",
"10",
")",
"{",
"$",
"rawUsers",
"=",
"$",
"this",
"->",
"load",
"(",
"'rank'",
",",
"array",
"(",
"$",
"pos",
",",
"$",
"count",
")",
")",
";",
"$",
"users",
... | Global ranklist.
@param int $pos
@param int $count
@return array | [
"Global",
"ranklist",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L294-L304 |
kasparsklavins/Hunter | src/Hunter.php | Hunter.load | protected function load($node, $arguments = array())
{
if (is_array($arguments) === false) {
$arguments = array($arguments);
}
if (empty($arguments)) {
$response = file_get_contents($this->source . $node);
} else {
foreach ($arguments as &$argument) {
if (is_array($argument)) {
$argument = implode(',', $argument);
}
}
$response = file_get_contents($this->source . $node . '/' . implode('/', $arguments));
}
return json_decode($response, true);
} | php | protected function load($node, $arguments = array())
{
if (is_array($arguments) === false) {
$arguments = array($arguments);
}
if (empty($arguments)) {
$response = file_get_contents($this->source . $node);
} else {
foreach ($arguments as &$argument) {
if (is_array($argument)) {
$argument = implode(',', $argument);
}
}
$response = file_get_contents($this->source . $node . '/' . implode('/', $arguments));
}
return json_decode($response, true);
} | [
"protected",
"function",
"load",
"(",
"$",
"node",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"arguments",
")",
"===",
"false",
")",
"{",
"$",
"arguments",
"=",
"array",
"(",
"$",
"arguments",
")",
";"... | Reads & decodes data from the specified node.
@param string $node
@param array|int $arguments
@return mixed | [
"Reads",
"&",
"decodes",
"data",
"from",
"the",
"specified",
"node",
"."
] | train | https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L314-L331 |
gorriecoe/silverstripe-menu | src/models/MenuSet.php | MenuSet.getCMSFields | public function getCMSFields()
{
$fields = FieldList::create(
TabSet::create(
'Root',
Tab::create('Main')
)
->setTitle(_t(__CLASS__ . '.TABMAIN', 'Main'))
);
$fields->addFieldToTab(
'Root.Main',
GridField::create(
'Links',
_t(__CLASS__ . '.FIELDLINKS', 'Links'),
$this->Links,
GridFieldConfig_RecordEditor::create()
->addComponent(new GridFieldOrderableRows('Sort'))
)
);
$this->extend('updateCMSFields', $fields);
return $fields;
} | php | public function getCMSFields()
{
$fields = FieldList::create(
TabSet::create(
'Root',
Tab::create('Main')
)
->setTitle(_t(__CLASS__ . '.TABMAIN', 'Main'))
);
$fields->addFieldToTab(
'Root.Main',
GridField::create(
'Links',
_t(__CLASS__ . '.FIELDLINKS', 'Links'),
$this->Links,
GridFieldConfig_RecordEditor::create()
->addComponent(new GridFieldOrderableRows('Sort'))
)
);
$this->extend('updateCMSFields', $fields);
return $fields;
} | [
"public",
"function",
"getCMSFields",
"(",
")",
"{",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
"TabSet",
"::",
"create",
"(",
"'Root'",
",",
"Tab",
"::",
"create",
"(",
"'Main'",
")",
")",
"->",
"setTitle",
"(",
"_t",
"(",
"__CLASS__",
".",... | CMS Fields
@return FieldList | [
"CMS",
"Fields"
] | train | https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuSet.php#L93-L117 |
gorriecoe/silverstripe-menu | src/models/MenuSet.php | MenuSet.providePermissions | public function providePermissions()
{
$permissions = [];
foreach (MenuSet::get() as $menuset) {
$key = $menuset->PermissionKey();
$permissions[$key] = [
'name' => _t(
__CLASS__ . '.EDITMENUSET',
"Manage links with in '{name}'",
[
'name' => $menuset->obj('Title')
]
),
'category' => _t(__CLASS__ . '.MENUSETS', 'Menu sets')
];
}
return $permissions;
} | php | public function providePermissions()
{
$permissions = [];
foreach (MenuSet::get() as $menuset) {
$key = $menuset->PermissionKey();
$permissions[$key] = [
'name' => _t(
__CLASS__ . '.EDITMENUSET',
"Manage links with in '{name}'",
[
'name' => $menuset->obj('Title')
]
),
'category' => _t(__CLASS__ . '.MENUSETS', 'Menu sets')
];
}
return $permissions;
} | [
"public",
"function",
"providePermissions",
"(",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"MenuSet",
"::",
"get",
"(",
")",
"as",
"$",
"menuset",
")",
"{",
"$",
"key",
"=",
"$",
"menuset",
"->",
"PermissionKey",
"(",
")",
";"... | Return a map of permission codes to add to the dropdown shown in the Security section of the CMS
@return array | [
"Return",
"a",
"map",
"of",
"permission",
"codes",
"to",
"add",
"to",
"the",
"dropdown",
"shown",
"in",
"the",
"Security",
"section",
"of",
"the",
"CMS"
] | train | https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuSet.php#L123-L140 |
gorriecoe/silverstripe-menu | src/models/MenuSet.php | MenuSet.requireDefaultRecords | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$default_menu_sets = $this->config()->get('sets') ?: array();
foreach ($default_menu_sets as $slug => $options) {
if (is_array($options)) {
$title = $options['title'];
$allowChildren = isset($options['allow_children']) ? $options['allow_children'] : false;
} else {
$title = $options;
$allowChildren = false;
}
$slug = Convert::raw2htmlid($slug);
$record = MenuSet::get()->find('Slug', $slug);
if (!$record) {
$record = MenuSet::create();
DB::alteration_message("Menu '$title' created", 'created');
} else {
DB::alteration_message("Menu '$title' updated", 'updated');
}
$record->Slug = $slug;
$record->Title = $title;
$record->AllowChildren = $allowChildren;
$record->write();
}
} | php | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$default_menu_sets = $this->config()->get('sets') ?: array();
foreach ($default_menu_sets as $slug => $options) {
if (is_array($options)) {
$title = $options['title'];
$allowChildren = isset($options['allow_children']) ? $options['allow_children'] : false;
} else {
$title = $options;
$allowChildren = false;
}
$slug = Convert::raw2htmlid($slug);
$record = MenuSet::get()->find('Slug', $slug);
if (!$record) {
$record = MenuSet::create();
DB::alteration_message("Menu '$title' created", 'created');
} else {
DB::alteration_message("Menu '$title' updated", 'updated');
}
$record->Slug = $slug;
$record->Title = $title;
$record->AllowChildren = $allowChildren;
$record->write();
}
} | [
"public",
"function",
"requireDefaultRecords",
"(",
")",
"{",
"parent",
"::",
"requireDefaultRecords",
"(",
")",
";",
"$",
"default_menu_sets",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'sets'",
")",
"?",
":",
"array",
"(",
")",
";",... | Set up default records based on the yaml config | [
"Set",
"up",
"default",
"records",
"based",
"on",
"the",
"yaml",
"config"
] | train | https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuSet.php#L194-L219 |
gorriecoe/silverstripe-menu | src/models/MenuSet.php | MenuSet.CMSEditLink | public function CMSEditLink() {
return Controller::join_links(
Controller::curr()->Link(),
'EditForm',
'field',
$this->ClassName,
'item',
$this->ID
);
} | php | public function CMSEditLink() {
return Controller::join_links(
Controller::curr()->Link(),
'EditForm',
'field',
$this->ClassName,
'item',
$this->ID
);
} | [
"public",
"function",
"CMSEditLink",
"(",
")",
"{",
"return",
"Controller",
"::",
"join_links",
"(",
"Controller",
"::",
"curr",
"(",
")",
"->",
"Link",
"(",
")",
",",
"'EditForm'",
",",
"'field'",
",",
"$",
"this",
"->",
"ClassName",
",",
"'item'",
",",... | Generates a link to edit this page in the CMS.
@return string | [
"Generates",
"a",
"link",
"to",
"edit",
"this",
"page",
"in",
"the",
"CMS",
"."
] | train | https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuSet.php#L226-L235 |
kgilden/php-digidoc | src/X509/Cert.php | Cert.hasSigned | public function hasSigned(Signature $signature)
{
$key = openssl_pkey_get_public($this->x509Cert);
try {
$hasSigned = $signature->isSignedByKey($key);
} catch (\Excetpion $e) {
openssl_pkey_free($key);
throw $e;
}
openssl_pkey_free($key);
return $hasSigned;
} | php | public function hasSigned(Signature $signature)
{
$key = openssl_pkey_get_public($this->x509Cert);
try {
$hasSigned = $signature->isSignedByKey($key);
} catch (\Excetpion $e) {
openssl_pkey_free($key);
throw $e;
}
openssl_pkey_free($key);
return $hasSigned;
} | [
"public",
"function",
"hasSigned",
"(",
"Signature",
"$",
"signature",
")",
"{",
"$",
"key",
"=",
"openssl_pkey_get_public",
"(",
"$",
"this",
"->",
"x509Cert",
")",
";",
"try",
"{",
"$",
"hasSigned",
"=",
"$",
"signature",
"->",
"isSignedByKey",
"(",
"$",... | @param Signature $signature
@return boolean Whether the signature has been signed by this certificate | [
"@param",
"Signature",
"$signature"
] | train | https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/X509/Cert.php#L52-L66 |
kgilden/php-digidoc | src/X509/Cert.php | Cert.pem2der | private function pem2der($pem_data) {
$begin = "CERTIFICATE-----";
$end = "-----END";
$pem_data = substr($pem_data, strpos($pem_data, $begin) + strlen($begin));
$pem_data = substr($pem_data, 0, strpos($pem_data, $end));
return base64_decode($pem_data);
} | php | private function pem2der($pem_data) {
$begin = "CERTIFICATE-----";
$end = "-----END";
$pem_data = substr($pem_data, strpos($pem_data, $begin) + strlen($begin));
$pem_data = substr($pem_data, 0, strpos($pem_data, $end));
return base64_decode($pem_data);
} | [
"private",
"function",
"pem2der",
"(",
"$",
"pem_data",
")",
"{",
"$",
"begin",
"=",
"\"CERTIFICATE-----\"",
";",
"$",
"end",
"=",
"\"-----END\"",
";",
"$",
"pem_data",
"=",
"substr",
"(",
"$",
"pem_data",
",",
"strpos",
"(",
"$",
"pem_data",
",",
"$",
... | Source: http://php.net/manual/en/ref.openssl.php | [
"Source",
":",
"http",
":",
"//",
"php",
".",
"net",
"/",
"manual",
"/",
"en",
"/",
"ref",
".",
"openssl",
".",
"php"
] | train | https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/X509/Cert.php#L104-L111 |
CampaignChain/core | Validator/AbstractOperationValidator.php | AbstractOperationValidator.isExecutableByCampaignByInterval | public function isExecutableByCampaignByInterval($content, \DateTime $startDate, $interval, $errMsg)
{
/** @var Campaign $campaign */
$campaign = $content->getOperation()->getActivity()->getCampaign();
if($campaign->getInterval()){
$campaignIntervalDate = new \DateTime();
$campaignIntervalDate->modify($campaign->getInterval());
$maxDuplicateIntervalDate = new \DateTime();
$maxDuplicateIntervalDate->modify($interval);
if($maxDuplicateIntervalDate > $campaignIntervalDate){
return array(
'status' => false,
'message' => $errMsg,
);
}
}
return $this->isExecutableByCampaign(
$content, $content->getOperation()->getActivity()->getStartDate()
);
} | php | public function isExecutableByCampaignByInterval($content, \DateTime $startDate, $interval, $errMsg)
{
/** @var Campaign $campaign */
$campaign = $content->getOperation()->getActivity()->getCampaign();
if($campaign->getInterval()){
$campaignIntervalDate = new \DateTime();
$campaignIntervalDate->modify($campaign->getInterval());
$maxDuplicateIntervalDate = new \DateTime();
$maxDuplicateIntervalDate->modify($interval);
if($maxDuplicateIntervalDate > $campaignIntervalDate){
return array(
'status' => false,
'message' => $errMsg,
);
}
}
return $this->isExecutableByCampaign(
$content, $content->getOperation()->getActivity()->getStartDate()
);
} | [
"public",
"function",
"isExecutableByCampaignByInterval",
"(",
"$",
"content",
",",
"\\",
"DateTime",
"$",
"startDate",
",",
"$",
"interval",
",",
"$",
"errMsg",
")",
"{",
"/** @var Campaign $campaign */",
"$",
"campaign",
"=",
"$",
"content",
"->",
"getOperation"... | This is a helper method to quickly implement Activity-specific
checks as per an interval.
For example, the same Tweet cannot be published within 24 hours.
@param $content
@param \DateTime $startDate
@param $interval
@param $errMsg
@return array | [
"This",
"is",
"a",
"helper",
"method",
"to",
"quickly",
"implement",
"Activity",
"-",
"specific",
"checks",
"as",
"per",
"an",
"interval",
"."
] | train | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Validator/AbstractOperationValidator.php#L104-L126 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.