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 |
|---|---|---|---|---|---|---|---|---|---|---|
robbertkl/simplepdf | classes/SimplePdf/Page.php | Page.drawLine | public function drawLine($x1, $y1, $x2, $y2)
{
$this->convertCoordinatesFromUserSpace($x1, $y1);
$this->convertCoordinatesFromUserSpace($x2, $y2);
list($y1, $y2) = array($y2, $y1);
return parent::drawLine($x1, $y1, $x2, $y2);
} | php | public function drawLine($x1, $y1, $x2, $y2)
{
$this->convertCoordinatesFromUserSpace($x1, $y1);
$this->convertCoordinatesFromUserSpace($x2, $y2);
list($y1, $y2) = array($y2, $y1);
return parent::drawLine($x1, $y1, $x2, $y2);
} | [
"public",
"function",
"drawLine",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"x2",
",",
"$",
"y2",
")",
"{",
"$",
"this",
"->",
"convertCoordinatesFromUserSpace",
"(",
"$",
"x1",
",",
"$",
"y1",
")",
";",
"$",
"this",
"->",
"convertCoordinatesFromUserSp... | Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawLine() for documentation | [
"Wrapper",
"taking",
"custom",
"units",
"and",
"margins",
"into",
"account"
] | train | https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L522-L528 |
robbertkl/simplepdf | classes/SimplePdf/Page.php | Page.drawPolygon | public function drawPolygon($x, $y, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE, $fillMethod = \ZendPdf\Page::FILL_METHOD_NON_ZERO_WINDING)
{
foreach ($x as $index => &$value) {
$this->convertCoordinatesFromUserSpace($value, $y[$index]);
}
$x = array_reverse($x, true);
$y = array_reverse($y, true);
return parent::drawPolygon($x, $y, $fillType, $fillMethod);
} | php | public function drawPolygon($x, $y, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE, $fillMethod = \ZendPdf\Page::FILL_METHOD_NON_ZERO_WINDING)
{
foreach ($x as $index => &$value) {
$this->convertCoordinatesFromUserSpace($value, $y[$index]);
}
$x = array_reverse($x, true);
$y = array_reverse($y, true);
return parent::drawPolygon($x, $y, $fillType, $fillMethod);
} | [
"public",
"function",
"drawPolygon",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"fillType",
"=",
"\\",
"ZendPdf",
"\\",
"Page",
"::",
"SHAPE_DRAW_FILL_AND_STROKE",
",",
"$",
"fillMethod",
"=",
"\\",
"ZendPdf",
"\\",
"Page",
"::",
"FILL_METHOD_NON_ZERO_WINDING",
... | Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawPolygon() for documentation | [
"Wrapper",
"taking",
"custom",
"units",
"and",
"margins",
"into",
"account"
] | train | https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L534-L542 |
robbertkl/simplepdf | classes/SimplePdf/Page.php | Page.drawRectangle | public function drawRectangle($x1, $y1, $x2, $y2, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE)
{
$this->convertCoordinatesFromUserSpace($x1, $y1);
$this->convertCoordinatesFromUserSpace($x2, $y2);
list($y1, $y2) = array($y2, $y1);
return parent::drawRectangle($x1, $y1, $x2, $y2, $fillType);
} | php | public function drawRectangle($x1, $y1, $x2, $y2, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE)
{
$this->convertCoordinatesFromUserSpace($x1, $y1);
$this->convertCoordinatesFromUserSpace($x2, $y2);
list($y1, $y2) = array($y2, $y1);
return parent::drawRectangle($x1, $y1, $x2, $y2, $fillType);
} | [
"public",
"function",
"drawRectangle",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"x2",
",",
"$",
"y2",
",",
"$",
"fillType",
"=",
"\\",
"ZendPdf",
"\\",
"Page",
"::",
"SHAPE_DRAW_FILL_AND_STROKE",
")",
"{",
"$",
"this",
"->",
"convertCoordinatesFromUserSpa... | Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawRectangle() for documentation | [
"Wrapper",
"taking",
"custom",
"units",
"and",
"margins",
"into",
"account"
] | train | https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L548-L554 |
robbertkl/simplepdf | classes/SimplePdf/Page.php | Page.drawRoundedRectangle | public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE)
{
$this->convertCoordinatesFromUserSpace($x1, $y1);
$this->convertCoordinatesFromUserSpace($x2, $y2);
list($y1, $y2) = array($y2, $y1);
$this->convertToPoints($radius);
return parent::drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType);
} | php | public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE)
{
$this->convertCoordinatesFromUserSpace($x1, $y1);
$this->convertCoordinatesFromUserSpace($x2, $y2);
list($y1, $y2) = array($y2, $y1);
$this->convertToPoints($radius);
return parent::drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType);
} | [
"public",
"function",
"drawRoundedRectangle",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"x2",
",",
"$",
"y2",
",",
"$",
"radius",
",",
"$",
"fillType",
"=",
"\\",
"ZendPdf",
"\\",
"Page",
"::",
"SHAPE_DRAW_FILL_AND_STROKE",
")",
"{",
"$",
"this",
"->",... | Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawRoundedRectangle() for documentation | [
"Wrapper",
"taking",
"custom",
"units",
"and",
"margins",
"into",
"account"
] | train | https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L560-L567 |
robbertkl/simplepdf | classes/SimplePdf/Page.php | Page.drawText | public function drawText($text, $x, $y, $charEncoding = 'WINDOWS-1252')
{
$this->convertCoordinatesFromUserSpace($x, $y);
$y -= $this->getFontSize();
return parent::drawText($text, $x, $y, $charEncoding);
} | php | public function drawText($text, $x, $y, $charEncoding = 'WINDOWS-1252')
{
$this->convertCoordinatesFromUserSpace($x, $y);
$y -= $this->getFontSize();
return parent::drawText($text, $x, $y, $charEncoding);
} | [
"public",
"function",
"drawText",
"(",
"$",
"text",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"charEncoding",
"=",
"'WINDOWS-1252'",
")",
"{",
"$",
"this",
"->",
"convertCoordinatesFromUserSpace",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"y",
"-=",... | Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawText() for documentation | [
"Wrapper",
"taking",
"custom",
"units",
"and",
"margins",
"into",
"account"
] | train | https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L573-L578 |
Opifer/EavBundle | Form/Type/SchemaType.php | SchemaType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('attributes', BootstrapCollectionType::class, [
'allow_add' => true,
'allow_delete' => true,
'type' => AttributeType::class
]);
if ($options['object_class'] !== null && class_exists($options['object_class'])) {
$builder->add('object_class', HiddenType::class, [
'data' => $options['object_class']
]);
} else {
$builder->add('object_class', SchemaObjectClassType::class, [
'label' => 'schema.object_class',
'attr' => ['help_text' => 'form.object_class.help_text']
]);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('attributes', BootstrapCollectionType::class, [
'allow_add' => true,
'allow_delete' => true,
'type' => AttributeType::class
]);
if ($options['object_class'] !== null && class_exists($options['object_class'])) {
$builder->add('object_class', HiddenType::class, [
'data' => $options['object_class']
]);
} else {
$builder->add('object_class', SchemaObjectClassType::class, [
'label' => 'schema.object_class',
'attr' => ['help_text' => 'form.object_class.help_text']
]);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'attributes'",
",",
"BootstrapCollectionType",
"::",
"class",
",",
"[",
"'allow_add'",
"=>",
"true",
",",... | {@inheritDoc} | [
"{"
] | train | https://github.com/Opifer/EavBundle/blob/4236fdc28b7574dac43f420704d0fc3c04905a4c/Form/Type/SchemaType.php#L29-L47 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Compiler/ReplaceBase64FileExtensionPass.php | ReplaceBase64FileExtensionPass.process | public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition($service = 'ivory.base64_file.form.extension')) {
return;
}
$container
->getDefinition($service)
->setClass(Base64FileExtension::class)
->replaceArgument(0, new Reference('lug.resource.routing.parameter_resolver'));
} | php | public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition($service = 'ivory.base64_file.form.extension')) {
return;
}
$container
->getDefinition($service)
->setClass(Base64FileExtension::class)
->replaceArgument(0, new Reference('lug.resource.routing.parameter_resolver'));
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"service",
"=",
"'ivory.base64_file.form.extension'",
")",
")",
"{",
"return",
";",
"}",
"$",
"container",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Compiler/ReplaceBase64FileExtensionPass.php#L27-L37 |
boomcms/boom-installer | src/BoomCMS/ServiceProviders/InstallerServiceProvider.php | InstallerServiceProvider.boot | public function boot(Request $request, Router $router)
{
$installer = new Installer\Installer();
if (php_sapi_name() !== 'cli' && !$installer->isInstalled()) {
if (!$this->app['migration.repository']->repositoryExists()) {
$this->app['migration.repository']->createRepository();
}
$this->app['migrator']->run(base_path('/vendor/boomcms/boom-core/src/database/migrations'));
$site = $installer->saveSiteDetails($request->input('site_name'), $request->input('site_email'));
$router->setActiveSite($site);
$name = $request->input('user_name');
$email = $request->input('user_email');
$person = $this->dispatch(new Jobs\CreatePerson($email, $name));
$person->addSite($site);
$person->setSuperuser(true);
Person::save($person);
auth()->login($person);
$page = $this->dispatch(new Jobs\CreatePage());
// Make the page visible so that it can be seen by the user after logging in
$page->setVisibleAtAnyTime(true);
PageFacade::save($page);
$this->dispatch(new Jobs\CreatePagePrimaryUri($page, '', ''));
$installer->markInstalled();
header('Location: /boomcms/login');
exit;
}
} | php | public function boot(Request $request, Router $router)
{
$installer = new Installer\Installer();
if (php_sapi_name() !== 'cli' && !$installer->isInstalled()) {
if (!$this->app['migration.repository']->repositoryExists()) {
$this->app['migration.repository']->createRepository();
}
$this->app['migrator']->run(base_path('/vendor/boomcms/boom-core/src/database/migrations'));
$site = $installer->saveSiteDetails($request->input('site_name'), $request->input('site_email'));
$router->setActiveSite($site);
$name = $request->input('user_name');
$email = $request->input('user_email');
$person = $this->dispatch(new Jobs\CreatePerson($email, $name));
$person->addSite($site);
$person->setSuperuser(true);
Person::save($person);
auth()->login($person);
$page = $this->dispatch(new Jobs\CreatePage());
// Make the page visible so that it can be seen by the user after logging in
$page->setVisibleAtAnyTime(true);
PageFacade::save($page);
$this->dispatch(new Jobs\CreatePagePrimaryUri($page, '', ''));
$installer->markInstalled();
header('Location: /boomcms/login');
exit;
}
} | [
"public",
"function",
"boot",
"(",
"Request",
"$",
"request",
",",
"Router",
"$",
"router",
")",
"{",
"$",
"installer",
"=",
"new",
"Installer",
"\\",
"Installer",
"(",
")",
";",
"if",
"(",
"php_sapi_name",
"(",
")",
"!==",
"'cli'",
"&&",
"!",
"$",
"... | Bootstrap any application services.
@return void | [
"Bootstrap",
"any",
"application",
"services",
"."
] | train | https://github.com/boomcms/boom-installer/blob/2c822721be27ce642f8049b0311dae40d383f9d7/src/BoomCMS/ServiceProviders/InstallerServiceProvider.php#L23-L61 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Core/Transformer/Writer/Sourcecode.php | Sourcecode.transform | public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$artifact = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR
. ($transformation->getArtifact()
? $transformation->getArtifact()
: 'source');
/** @var FileDescriptor $file */
foreach ($project->getFiles() as $file) {
$filename = $file->getPath();
$source = $file->getSource();
$root = str_repeat('../', count(explode(DIRECTORY_SEPARATOR, $filename)));
$path = $artifact . DIRECTORY_SEPARATOR . $filename;
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
$source = htmlentities($source);
file_put_contents(
$path.'.html',
<<<HTML
<html>
<head>
<script
type="text/javascript"
src="{$root}js/jquery-1.4.2.min.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shCore.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushJScript.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushPhp.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushXml.js">
</script>
<link
href="{$root}syntax_highlighter/styles/shCore.css" rel="stylesheet"
type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shCoreEclipse.css"
rel="stylesheet" type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shThemeWordpress.css"
rel="stylesheet" type="text/css"
/>
</head>
<body>
<pre class="brush: php">$source</pre>
<script type="text/javascript">
SyntaxHighlighter.all();
jQuery('.gutter div').each(function(key, data){
jQuery(data).prepend('<a name="L'+jQuery(data).text()+'"/>');
});
</script>
</body>
</html>
HTML
);
}
} | php | public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$artifact = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR
. ($transformation->getArtifact()
? $transformation->getArtifact()
: 'source');
/** @var FileDescriptor $file */
foreach ($project->getFiles() as $file) {
$filename = $file->getPath();
$source = $file->getSource();
$root = str_repeat('../', count(explode(DIRECTORY_SEPARATOR, $filename)));
$path = $artifact . DIRECTORY_SEPARATOR . $filename;
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
$source = htmlentities($source);
file_put_contents(
$path.'.html',
<<<HTML
<html>
<head>
<script
type="text/javascript"
src="{$root}js/jquery-1.4.2.min.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shCore.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushJScript.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushPhp.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushXml.js">
</script>
<link
href="{$root}syntax_highlighter/styles/shCore.css" rel="stylesheet"
type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shCoreEclipse.css"
rel="stylesheet" type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shThemeWordpress.css"
rel="stylesheet" type="text/css"
/>
</head>
<body>
<pre class="brush: php">$source</pre>
<script type="text/javascript">
SyntaxHighlighter.all();
jQuery('.gutter div').each(function(key, data){
jQuery(data).prepend('<a name="L'+jQuery(data).text()+'"/>');
});
</script>
</body>
</html>
HTML
);
}
} | [
"public",
"function",
"transform",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"artifact",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
".",
"DIRECTORY_SEPAR... | This method writes every source code entry in the structure file to a highlighted file.
@param ProjectDescriptor $project Document containing the structure.
@param Transformation $transformation Transformation to execute.
@return void | [
"This",
"method",
"writes",
"every",
"source",
"code",
"entry",
"in",
"the",
"structure",
"file",
"to",
"a",
"highlighted",
"file",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Sourcecode.php#L32-L103 |
david-mk/mail-map | src/MailMap/Mail.php | Mail.setHeaderAttributes | private function setHeaderAttributes(array $mailHeader)
{
$mailHeader = array_filter($mailHeader, function ($property) {
return property_exists($this, $property);
}, ARRAY_FILTER_USE_KEY);
foreach ($mailHeader as $property => $header) {
$this->{$property} = $header;
}
} | php | private function setHeaderAttributes(array $mailHeader)
{
$mailHeader = array_filter($mailHeader, function ($property) {
return property_exists($this, $property);
}, ARRAY_FILTER_USE_KEY);
foreach ($mailHeader as $property => $header) {
$this->{$property} = $header;
}
} | [
"private",
"function",
"setHeaderAttributes",
"(",
"array",
"$",
"mailHeader",
")",
"{",
"$",
"mailHeader",
"=",
"array_filter",
"(",
"$",
"mailHeader",
",",
"function",
"(",
"$",
"property",
")",
"{",
"return",
"property_exists",
"(",
"$",
"this",
",",
"$",... | Set attributes on email from header
@param array $mailHeader
@return void | [
"Set",
"attributes",
"on",
"email",
"from",
"header"
] | train | https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Mail.php#L173-L182 |
david-mk/mail-map | src/MailMap/Mail.php | Mail.header | public function header($key, $default = null)
{
if (array_key_exists($key, $this->headers)) {
return $this->headers[$key];
}
return $default;
} | php | public function header($key, $default = null)
{
if (array_key_exists($key, $this->headers)) {
return $this->headers[$key];
}
return $default;
} | [
"public",
"function",
"header",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
... | Get a header value. Return given default if none found
@param string $key
@param mixed $default
@return mixed | [
"Get",
"a",
"header",
"value",
".",
"Return",
"given",
"default",
"if",
"none",
"found"
] | train | https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Mail.php#L201-L208 |
david-mk/mail-map | src/MailMap/Mail.php | Mail.body | public function body($mimeType = 'html')
{
$body = [];
foreach ($this->body as $part) {
if ($part->mime_type === $mimeType) {
$body[] = $part->body;
}
}
return implode(static::partSeparator($mimeType), $body);
} | php | public function body($mimeType = 'html')
{
$body = [];
foreach ($this->body as $part) {
if ($part->mime_type === $mimeType) {
$body[] = $part->body;
}
}
return implode(static::partSeparator($mimeType), $body);
} | [
"public",
"function",
"body",
"(",
"$",
"mimeType",
"=",
"'html'",
")",
"{",
"$",
"body",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"body",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"part",
"->",
"mime_type",
"===",
"$",
"mimeType... | Render the email body as the given mime-type
@param string $mimeType
@return string | [
"Render",
"the",
"email",
"body",
"as",
"the",
"given",
"mime",
"-",
"type"
] | train | https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Mail.php#L216-L227 |
ekuiter/feature-php | FeaturePhp/Artifact/TracingLinkRenderer.php | TracingLinkRenderer._render | public function _render($textOnly) {
$tracingLinkNum = count($this->tracingLinks);
$str = "";
if ($textOnly) {
$str .= "\nFeature Traceability\n====================\n" .
"The following $tracingLinkNum tracing links were found:\n\n";
$maxLen = fphp\Helper\_String::getMaxLength($this->tracingLinks, "getFeatureName")
+ fphp\Helper\_String::getMaxLength($this->tracingLinks, "getType");
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink, true, $maxLen);
} else {
$str .= "<h2>Feature Traceability</h2>";
$str .= "<p>The following $tracingLinkNum tracing links were found:</p>";
$str .= "<table cellpadding='2'>";
$str .= "<tr align='left'><th>Feature</th><th>Type</th><th>Source</th><th>Target</th></tr>";
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink);
$str .= "</table>";
}
return $str;
} | php | public function _render($textOnly) {
$tracingLinkNum = count($this->tracingLinks);
$str = "";
if ($textOnly) {
$str .= "\nFeature Traceability\n====================\n" .
"The following $tracingLinkNum tracing links were found:\n\n";
$maxLen = fphp\Helper\_String::getMaxLength($this->tracingLinks, "getFeatureName")
+ fphp\Helper\_String::getMaxLength($this->tracingLinks, "getType");
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink, true, $maxLen);
} else {
$str .= "<h2>Feature Traceability</h2>";
$str .= "<p>The following $tracingLinkNum tracing links were found:</p>";
$str .= "<table cellpadding='2'>";
$str .= "<tr align='left'><th>Feature</th><th>Type</th><th>Source</th><th>Target</th></tr>";
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink);
$str .= "</table>";
}
return $str;
} | [
"public",
"function",
"_render",
"(",
"$",
"textOnly",
")",
"{",
"$",
"tracingLinkNum",
"=",
"count",
"(",
"$",
"this",
"->",
"tracingLinks",
")",
";",
"$",
"str",
"=",
"\"\"",
";",
"if",
"(",
"$",
"textOnly",
")",
"{",
"$",
"str",
".=",
"\"\\nFeatur... | Returns the tracing link analysis.
@param bool $textOnly whether to render text or HTML
@return string | [
"Returns",
"the",
"tracing",
"link",
"analysis",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Artifact/TracingLinkRenderer.php#L33-L55 |
ekuiter/feature-php | FeaturePhp/Artifact/TracingLinkRenderer.php | TracingLinkRenderer.analyzeTracingLink | private function analyzeTracingLink($tracingLink, $textOnly = false, $maxLen = 0) {
$maxLen += strlen($this->defaultColor);
if ($textOnly)
return sprintf("$this->accentColor%-{$maxLen}s %s\n%{$maxLen}s %s\n",
$tracingLink->getFeatureName() . "$this->defaultColor " . $tracingLink->getType(),
$tracingLink->getSourcePlace()->getSummary(),
$this->defaultColor, $tracingLink->getTargetPlace()->getSummary());
else
return "<tr><td><span class='feature'>"
. $tracingLink->getFeatureName()
. "</span></td><td>" . $tracingLink->getType()
. "</td><td>" . $tracingLink->getSourcePlace()->getSummary()
. "</td><td>" . $tracingLink->getTargetPlace()->getSummary() . "</td></tr>";
} | php | private function analyzeTracingLink($tracingLink, $textOnly = false, $maxLen = 0) {
$maxLen += strlen($this->defaultColor);
if ($textOnly)
return sprintf("$this->accentColor%-{$maxLen}s %s\n%{$maxLen}s %s\n",
$tracingLink->getFeatureName() . "$this->defaultColor " . $tracingLink->getType(),
$tracingLink->getSourcePlace()->getSummary(),
$this->defaultColor, $tracingLink->getTargetPlace()->getSummary());
else
return "<tr><td><span class='feature'>"
. $tracingLink->getFeatureName()
. "</span></td><td>" . $tracingLink->getType()
. "</td><td>" . $tracingLink->getSourcePlace()->getSummary()
. "</td><td>" . $tracingLink->getTargetPlace()->getSummary() . "</td></tr>";
} | [
"private",
"function",
"analyzeTracingLink",
"(",
"$",
"tracingLink",
",",
"$",
"textOnly",
"=",
"false",
",",
"$",
"maxLen",
"=",
"0",
")",
"{",
"$",
"maxLen",
"+=",
"strlen",
"(",
"$",
"this",
"->",
"defaultColor",
")",
";",
"if",
"(",
"$",
"textOnly... | Analyzes a single tracing link.
@param TracingLink $tracingLink
@param bool $textOnly whether to render text or HTML
@param int $maxLen
@return string | [
"Analyzes",
"a",
"single",
"tracing",
"link",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Artifact/TracingLinkRenderer.php#L64-L78 |
shabbyrobe/amiss | bin/commands/migrate-notes.php | LegacyParser.parse | public function parse($string)
{
global $matchedNotes;
$keyPrefixLen = $this->keyPrefix ? strlen($this->keyPrefix) : 0;
$data = array();
$toDelete = [];
$lines = preg_split('@\n@', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
foreach ($lines as list($l, $offset)) {
$len = strlen($l);
$l = trim($l);
$offset += $len - strlen($l);
if ($l && $l[0] == '@') {
$curDelete = trim($l);
$l = substr($l, 1);
$d = preg_split('/\s+/', $l, 2, PREG_SPLIT_OFFSET_CAPTURE);
$key = $d[0][0];
if ($this->keyPrefix) {
if (strpos($key, $this->keyPrefix)!==0)
continue;
$key = substr($key, $keyPrefixLen);
}
$key = preg_split(
"/(
\]\[
| \[
| \]\. # when php style abuts dot notation (foo[a].b)
| \]
| \.)
/x",
rtrim($key, ']')
);
if (isset($d[1])) {
$value = $d[1][0];
}
else {
$value = $this->defaultValue;
}
$current = &$data;
$found = array();
foreach ($key as $part) {
if ($current && !is_array($current)) {
throw new RewriteException("Key at path ".implode('.', $found)." already had non-array value, tried to set key $part");
}
if (!$found) {
if (in_array($part, $matchedNotes)) {
$toDelete[] = $curDelete;
}
}
$found[] = $part;
// if the last segment is empty, it means "@key[] value" or "@key. value" was used,
// so we should just assign the next key
if ($part !== "")
$current = &$current[$part];
else
$current = &$current[];
}
if ($current === null)
$current = $value;
elseif (!is_array($current))
$current = array($current, $value);
else
$current[] = $value;
unset($current);
}
}
return [$data, $toDelete];
} | php | public function parse($string)
{
global $matchedNotes;
$keyPrefixLen = $this->keyPrefix ? strlen($this->keyPrefix) : 0;
$data = array();
$toDelete = [];
$lines = preg_split('@\n@', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
foreach ($lines as list($l, $offset)) {
$len = strlen($l);
$l = trim($l);
$offset += $len - strlen($l);
if ($l && $l[0] == '@') {
$curDelete = trim($l);
$l = substr($l, 1);
$d = preg_split('/\s+/', $l, 2, PREG_SPLIT_OFFSET_CAPTURE);
$key = $d[0][0];
if ($this->keyPrefix) {
if (strpos($key, $this->keyPrefix)!==0)
continue;
$key = substr($key, $keyPrefixLen);
}
$key = preg_split(
"/(
\]\[
| \[
| \]\. # when php style abuts dot notation (foo[a].b)
| \]
| \.)
/x",
rtrim($key, ']')
);
if (isset($d[1])) {
$value = $d[1][0];
}
else {
$value = $this->defaultValue;
}
$current = &$data;
$found = array();
foreach ($key as $part) {
if ($current && !is_array($current)) {
throw new RewriteException("Key at path ".implode('.', $found)." already had non-array value, tried to set key $part");
}
if (!$found) {
if (in_array($part, $matchedNotes)) {
$toDelete[] = $curDelete;
}
}
$found[] = $part;
// if the last segment is empty, it means "@key[] value" or "@key. value" was used,
// so we should just assign the next key
if ($part !== "")
$current = &$current[$part];
else
$current = &$current[];
}
if ($current === null)
$current = $value;
elseif (!is_array($current))
$current = array($current, $value);
else
$current[] = $value;
unset($current);
}
}
return [$data, $toDelete];
} | [
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"global",
"$",
"matchedNotes",
";",
"$",
"keyPrefixLen",
"=",
"$",
"this",
"->",
"keyPrefix",
"?",
"strlen",
"(",
"$",
"this",
"->",
"keyPrefix",
")",
":",
"0",
";",
"$",
"data",
"=",
"arra... | will do for now, but it's definitely one to revisit. | [
"will",
"do",
"for",
"now",
"but",
"it",
"s",
"definitely",
"one",
"to",
"revisit",
"."
] | train | https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/bin/commands/migrate-notes.php#L504-L583 |
NuclearCMS/Hierarchy | src/NodeType.php | NodeType.addField | public function addField(array $attributes)
{
$field = $this->fields()->create($attributes);
$this->save();
return $field;
} | php | public function addField(array $attributes)
{
$field = $this->fields()->create($attributes);
$this->save();
return $field;
} | [
"public",
"function",
"addField",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"fields",
"(",
")",
"->",
"create",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"return",
"$",
"field... | Add a field to the node type
@param array $attributes
@return Eloquent | [
"Add",
"a",
"field",
"to",
"the",
"node",
"type"
] | train | https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeType.php#L120-L127 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.join | public function join($trueTableName, $alias, $on) {
$join = new Join($trueTableName, $alias, $on);
$this->statementContext->getJoinClause()->addJoin($join);
return $this;
} | php | public function join($trueTableName, $alias, $on) {
$join = new Join($trueTableName, $alias, $on);
$this->statementContext->getJoinClause()->addJoin($join);
return $this;
} | [
"public",
"function",
"join",
"(",
"$",
"trueTableName",
",",
"$",
"alias",
",",
"$",
"on",
")",
"{",
"$",
"join",
"=",
"new",
"Join",
"(",
"$",
"trueTableName",
",",
"$",
"alias",
",",
"$",
"on",
")",
";",
"$",
"this",
"->",
"statementContext",
"-... | 内连接一个表
@param string $trueTableName 要连接的表的真实表名,如"bbs_user"
@param string $alias 要连接的表的别名,如"u"
@param string $on 连接条件,注意不要带上"ON"关键字
@return Model | [
"内连接一个表"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L106-L111 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.leftJoin | public function leftJoin($trueTableName, $alias, $on) {
$join = new Join($trueTableName, $alias, $on);
$join->setType(Join::LEFT_JOIN);
$this->statementContext->getJoinClause()->addJoin($join);
return $this;
} | php | public function leftJoin($trueTableName, $alias, $on) {
$join = new Join($trueTableName, $alias, $on);
$join->setType(Join::LEFT_JOIN);
$this->statementContext->getJoinClause()->addJoin($join);
return $this;
} | [
"public",
"function",
"leftJoin",
"(",
"$",
"trueTableName",
",",
"$",
"alias",
",",
"$",
"on",
")",
"{",
"$",
"join",
"=",
"new",
"Join",
"(",
"$",
"trueTableName",
",",
"$",
"alias",
",",
"$",
"on",
")",
";",
"$",
"join",
"->",
"setType",
"(",
... | 左外连接一个表
@param string $trueTableName 要连接的表的真实表名,如"bbs_user"
@param string $alias 要连接的表的别名,如"u"
@param string $on 连接条件,注意不要带上"ON"关键字
@return Model | [
"左外连接一个表"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L121-L127 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.rightJoin | public function rightJoin($trueTableName, $alias, $on) {
$join = new Join($trueTableName, $alias, $on);
$join->setType(Join::RIGHT_JOIN);
$this->statementContext->getJoinClause()->addJoin($join);
return $this;
} | php | public function rightJoin($trueTableName, $alias, $on) {
$join = new Join($trueTableName, $alias, $on);
$join->setType(Join::RIGHT_JOIN);
$this->statementContext->getJoinClause()->addJoin($join);
return $this;
} | [
"public",
"function",
"rightJoin",
"(",
"$",
"trueTableName",
",",
"$",
"alias",
",",
"$",
"on",
")",
"{",
"$",
"join",
"=",
"new",
"Join",
"(",
"$",
"trueTableName",
",",
"$",
"alias",
",",
"$",
"on",
")",
";",
"$",
"join",
"->",
"setType",
"(",
... | 右外连接一个表
@param string $trueTableName 要连接的表的真实表名,如"bbs_user"
@param string $alias 要连接的表的别名,如"u"
@param string $on 连接条件,注意不要带上"ON"关键字
@return Model | [
"右外连接一个表"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L137-L143 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.where | public function where($condition) {
if (is_array($condition)) {
$this->condition = new ArrayCondition($condition);
} elseif ($condition instanceof ConditionInterface) {
$this->condition = $condition;
} else {
throw new InvalidSQLConditionException('无效的SQL条件');
}
$this->condition->setStatementContext($this->statementContext);
return $this;
} | php | public function where($condition) {
if (is_array($condition)) {
$this->condition = new ArrayCondition($condition);
} elseif ($condition instanceof ConditionInterface) {
$this->condition = $condition;
} else {
throw new InvalidSQLConditionException('无效的SQL条件');
}
$this->condition->setStatementContext($this->statementContext);
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"condition",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"condition",
")",
")",
"{",
"$",
"this",
"->",
"condition",
"=",
"new",
"ArrayCondition",
"(",
"$",
"condition",
")",
";",
"}",
"elseif",
"(",
"$",
"cond... | 设置查询条件
@param array|ConditionInterface $condition
@return Model | [
"设置查询条件"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L150-L162 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.paging | public function paging($pageNum, $pageSize) {
$offset = ($pageNum - 1) * $pageSize;
$this->statementContext->setLimit("{$offset}, {$pageSize}");
return $this;
} | php | public function paging($pageNum, $pageSize) {
$offset = ($pageNum - 1) * $pageSize;
$this->statementContext->setLimit("{$offset}, {$pageSize}");
return $this;
} | [
"public",
"function",
"paging",
"(",
"$",
"pageNum",
",",
"$",
"pageSize",
")",
"{",
"$",
"offset",
"=",
"(",
"$",
"pageNum",
"-",
"1",
")",
"*",
"$",
"pageSize",
";",
"$",
"this",
"->",
"statementContext",
"->",
"setLimit",
"(",
"\"{$offset}, {$pageSize... | 设置分页<br />
注意:设置分页和设置limit子句会导致互相覆盖
@param int $pageNum 页号(从1开始)
@param int $pageSize 页大小
@return Model | [
"设置分页<br",
"/",
">",
"注意:设置分页和设置limit子句会导致互相覆盖"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L201-L205 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.findOne | public function findOne() {
$this->statementContext->setLimit(1);
$statement = new SelectStatement();
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$row = $this->connection->query($sql, $this->statementContext->getParameters());
$this->clear();
return $row;
} | php | public function findOne() {
$this->statementContext->setLimit(1);
$statement = new SelectStatement();
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$row = $this->connection->query($sql, $this->statementContext->getParameters());
$this->clear();
return $row;
} | [
"public",
"function",
"findOne",
"(",
")",
"{",
"$",
"this",
"->",
"statementContext",
"->",
"setLimit",
"(",
"1",
")",
";",
"$",
"statement",
"=",
"new",
"SelectStatement",
"(",
")",
";",
"$",
"statement",
"->",
"setStatementContext",
"(",
"$",
"this",
... | 查询一条记录
@return array|null|false 成功则返回一个关联数组;未找到数据返回null,SQL执行发生错误则返回false | [
"查询一条记录"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L229-L242 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.findAll | public function findAll() {
$statement = new SelectStatement();
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$rows = $this->connection->queryAll($sql, $this->statementContext->getParameters());
$this->clear();
return $rows;
} | php | public function findAll() {
$statement = new SelectStatement();
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$rows = $this->connection->queryAll($sql, $this->statementContext->getParameters());
$this->clear();
return $rows;
} | [
"public",
"function",
"findAll",
"(",
")",
"{",
"$",
"statement",
"=",
"new",
"SelectStatement",
"(",
")",
";",
"$",
"statement",
"->",
"setStatementContext",
"(",
"$",
"this",
"->",
"statementContext",
")",
";",
"$",
"statement",
"->",
"setCondition",
"(",
... | 查询多条记录
@return array|null|false 成功则返回一个结果数组;未找到数据返回null,SQL执行发生错误则返回false | [
"查询多条记录"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L248-L259 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.findValue | public function findValue($field) {
$row = $this->select($field)->findOne();
//false or null
if (!$row) {
return $row;
}
return $row[$field];
} | php | public function findValue($field) {
$row = $this->select($field)->findOne();
//false or null
if (!$row) {
return $row;
}
return $row[$field];
} | [
"public",
"function",
"findValue",
"(",
"$",
"field",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"select",
"(",
"$",
"field",
")",
"->",
"findOne",
"(",
")",
";",
"//false or null",
"if",
"(",
"!",
"$",
"row",
")",
"{",
"return",
"$",
"row",
"... | 查找单个值(某条记录的某个字段的值)
@param string $field 单个字段名称,注意不要使用字段别名
@return mixed|null|false 成功则返回相应的值;未找到数据返回null,SQL执行发生错误则返回false | [
"查找单个值",
"(",
"某条记录的某个字段的值",
")"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L266-L275 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.findColumn | public function findColumn($field) {
$rows = $this->select($field)->findAll();
//false or null
if (!$rows) {
return $rows;
}
$columnValues = [];
foreach ($rows as $row) {
$columnValues[] = $row[$field];
}
return $columnValues;
} | php | public function findColumn($field) {
$rows = $this->select($field)->findAll();
//false or null
if (!$rows) {
return $rows;
}
$columnValues = [];
foreach ($rows as $row) {
$columnValues[] = $row[$field];
}
return $columnValues;
} | [
"public",
"function",
"findColumn",
"(",
"$",
"field",
")",
"{",
"$",
"rows",
"=",
"$",
"this",
"->",
"select",
"(",
"$",
"field",
")",
"->",
"findAll",
"(",
")",
";",
"//false or null",
"if",
"(",
"!",
"$",
"rows",
")",
"{",
"return",
"$",
"rows",... | 查找一个列的值
@param string $field 单个字段名称,注意不要使用字段别名
@return array|null|false 成功则返回此列的值的数组;未找到数据返回null,SQL执行发生错误则返回false | [
"查找一个列的值"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L282-L295 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.count | public function count($field = '*') {
$this->statementContext->setFields("COUNT({$field}) AS __COUNT__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__COUNT__'];
} | php | public function count($field = '*') {
$this->statementContext->setFields("COUNT({$field}) AS __COUNT__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__COUNT__'];
} | [
"public",
"function",
"count",
"(",
"$",
"field",
"=",
"'*'",
")",
"{",
"$",
"this",
"->",
"statementContext",
"->",
"setFields",
"(",
"\"COUNT({$field}) AS __COUNT__\"",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"findOne",
"(",
")",
";",
"//SQL执行发生错误"... | 执行count聚簇函数
@param string $field
@return int|false 如果成功则返回相应的值;SQL执行发生错误则返回false | [
"执行count聚簇函数"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L302-L312 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.max | public function max($field) {
$this->statementContext->setFields("MAX({$field}) AS __MAX__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__MAX__'];
} | php | public function max($field) {
$this->statementContext->setFields("MAX({$field}) AS __MAX__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__MAX__'];
} | [
"public",
"function",
"max",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"statementContext",
"->",
"setFields",
"(",
"\"MAX({$field}) AS __MAX__\"",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"findOne",
"(",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$"... | 执行max聚簇函数
@param string $field
@return mixed|null|false 如果成功则返回相应的值;不存在相应的记录返回null;
SQL执行发生错误则返回false | [
"执行max聚簇函数"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L320-L330 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.min | public function min($field) {
$this->statementContext->setFields("MIN({$field}) AS __MIN__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__MIN__'];
} | php | public function min($field) {
$this->statementContext->setFields("MIN({$field}) AS __MIN__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__MIN__'];
} | [
"public",
"function",
"min",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"statementContext",
"->",
"setFields",
"(",
"\"MIN({$field}) AS __MIN__\"",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"findOne",
"(",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$"... | 执行min聚簇函数
@param string $field
@return mixed|null|false 如果成功则返回相应的值;不存在相应的记录返回null;
SQL执行发生错误则返回false | [
"执行min聚簇函数"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L338-L348 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.avg | public function avg($field) {
$this->statementContext->setFields("AVG({$field}) AS __AVG__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__AVG__'];
} | php | public function avg($field) {
$this->statementContext->setFields("AVG({$field}) AS __AVG__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__AVG__'];
} | [
"public",
"function",
"avg",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"statementContext",
"->",
"setFields",
"(",
"\"AVG({$field}) AS __AVG__\"",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"findOne",
"(",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$"... | 执行avg聚簇函数
@param string $field
@return mixed|null|false 如果成功则返回相应的值;不存在相应的记录返回null;
SQL执行发生错误则返回false | [
"执行avg聚簇函数"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L356-L366 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.sum | public function sum($field) {
$this->statementContext->setFields("SUM({$field}) AS __SUM__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__SUM__'];
} | php | public function sum($field) {
$this->statementContext->setFields("SUM({$field}) AS __SUM__");
$row = $this->findOne();
//SQL执行发生错误
if ($row === false) {
return false;
}
return $row['__SUM__'];
} | [
"public",
"function",
"sum",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"statementContext",
"->",
"setFields",
"(",
"\"SUM({$field}) AS __SUM__\"",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"findOne",
"(",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$"... | 执行sum聚簇函数
@param string $field
@return mixed|null|false 如果成功则返回相应的值;不存在相应的记录返回null;
SQL执行发生错误则返回false | [
"执行sum聚簇函数"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L374-L384 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.insert | public function insert(array $data) {
$statement = new InsertStatement($data);
$statement->setStatementContext($this->statementContext);
$sql = $statement->parse();
$result = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
if ($result === false) {
return false;
}
return $this->connection->lastInsertId();
} | php | public function insert(array $data) {
$statement = new InsertStatement($data);
$statement->setStatementContext($this->statementContext);
$sql = $statement->parse();
$result = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
if ($result === false) {
return false;
}
return $this->connection->lastInsertId();
} | [
"public",
"function",
"insert",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"statement",
"=",
"new",
"InsertStatement",
"(",
"$",
"data",
")",
";",
"$",
"statement",
"->",
"setStatementContext",
"(",
"$",
"this",
"->",
"statementContext",
")",
";",
"$",
"s... | 插入一条数据
@param array $data 要插入的数据,关联数组
@return string|false 插入成功则返回新插入记录的id,SQL执行发生错误返回false | [
"插入一条数据"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L391-L405 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.insertAll | public function insertAll(array $dataArr) {
$statement = new InsertAllStatement($dataArr);
$statement->setStatementContext($this->statementContext);
$sql = $statement->parse();
$rowCount = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
return $rowCount;
} | php | public function insertAll(array $dataArr) {
$statement = new InsertAllStatement($dataArr);
$statement->setStatementContext($this->statementContext);
$sql = $statement->parse();
$rowCount = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
return $rowCount;
} | [
"public",
"function",
"insertAll",
"(",
"array",
"$",
"dataArr",
")",
"{",
"$",
"statement",
"=",
"new",
"InsertAllStatement",
"(",
"$",
"dataArr",
")",
";",
"$",
"statement",
"->",
"setStatementContext",
"(",
"$",
"this",
"->",
"statementContext",
")",
";",... | 批量插入数据
@param array $dataArr 要批量插入的数据,下标数组
@return string|false 插入成功则返回新插入的记录数,SQL执行发生错误返回false | [
"批量插入数据"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L412-L422 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.update | public function update(array $data) {
$statement = new UpdateStatement($data);
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$rowCount = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
return $rowCount;
} | php | public function update(array $data) {
$statement = new UpdateStatement($data);
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$rowCount = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
return $rowCount;
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"statement",
"=",
"new",
"UpdateStatement",
"(",
"$",
"data",
")",
";",
"$",
"statement",
"->",
"setStatementContext",
"(",
"$",
"this",
"->",
"statementContext",
")",
";",
"$",
"s... | 更新数据
@param array $data 要更新的数据,关联数组
@return int|false 成功则返回受影响的行数;如果SQL执行发生错误,返回false。
注意返回<b>0</b>和返回<b>false</b>的区别。 | [
"更新数据"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L430-L441 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.inc | public function inc($field, $amount = 1) {
$this->checkIncOrDecAmount($amount);
$data = [$field => ['exp', "{$field} + {$amount}"]];
return $this->update($data);
} | php | public function inc($field, $amount = 1) {
$this->checkIncOrDecAmount($amount);
$data = [$field => ['exp', "{$field} + {$amount}"]];
return $this->update($data);
} | [
"public",
"function",
"inc",
"(",
"$",
"field",
",",
"$",
"amount",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"checkIncOrDecAmount",
"(",
"$",
"amount",
")",
";",
"$",
"data",
"=",
"[",
"$",
"field",
"=>",
"[",
"'exp'",
",",
"\"{$field} + {$amount}\"",
... | 给一个字段增加指定的值
@param string $field 字段名称
@param int|float $amount 指定的值
@return int|false 成功则返回受影响的行数;如果SQL执行发生错误,返回false。
注意返回<b>0</b>和返回<b>false</b>的区别。 | [
"给一个字段增加指定的值"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L450-L455 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.dec | public function dec($field, $amount = 1) {
$this->checkIncOrDecAmount($amount);
$data = [$field => ['exp', "{$field} - {$amount}"]];
return $this->update($data);
} | php | public function dec($field, $amount = 1) {
$this->checkIncOrDecAmount($amount);
$data = [$field => ['exp', "{$field} - {$amount}"]];
return $this->update($data);
} | [
"public",
"function",
"dec",
"(",
"$",
"field",
",",
"$",
"amount",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"checkIncOrDecAmount",
"(",
"$",
"amount",
")",
";",
"$",
"data",
"=",
"[",
"$",
"field",
"=>",
"[",
"'exp'",
",",
"\"{$field} - {$amount}\"",
... | 把一个字段减去指定的值
@param string $field 字段名称
@param int|float $amount 指定的值
@return int|false 成功则返回受影响的行数;如果SQL执行发生错误,返回false。
注意返回<b>0</b>和返回<b>false</b>的区别。 | [
"把一个字段减去指定的值"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L464-L469 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Model.php | Model.delete | public function delete() {
$statement = new DeleteStatement();
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$rowCount = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
return $rowCount;
} | php | public function delete() {
$statement = new DeleteStatement();
$statement->setStatementContext($this->statementContext);
$statement->setCondition($this->condition);
$sql = $statement->parse();
$rowCount = $this->connection->execute($sql, $this->statementContext->getParameters());
$this->clear();
return $rowCount;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"statement",
"=",
"new",
"DeleteStatement",
"(",
")",
";",
"$",
"statement",
"->",
"setStatementContext",
"(",
"$",
"this",
"->",
"statementContext",
")",
";",
"$",
"statement",
"->",
"setCondition",
"(",
... | 删除数据
@return int|false 如果成功,则返回受影响的行数;如果SQL执行发生错误,返回false。
注意返回<b>0</b>和返回<b>false</b>的区别。 | [
"删除数据"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Model.php#L487-L498 |
wplibs/rules | src/Builder.php | Builder.offsetGet | public function offsetGet( $name ) {
if ( ! array_key_exists( $name, $this->variables ) ) {
$this->variables[ $name ] = new Variable( $name );
}
return $this->variables[ $name ];
} | php | public function offsetGet( $name ) {
if ( ! array_key_exists( $name, $this->variables ) ) {
$this->variables[ $name ] = new Variable( $name );
}
return $this->variables[ $name ];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"variables",
")",
")",
"{",
"$",
"this",
"->",
"variables",
"[",
"$",
"name",
"]",
"=",
"new",
"Variable",
... | Retrieve a variable by name.
@param string $name
@return Variable | [
"Retrieve",
"a",
"variable",
"by",
"name",
"."
] | train | https://github.com/wplibs/rules/blob/29b4495e2ae87349fd64fcd844f3ba96cc268e3d/src/Builder.php#L72-L78 |
InactiveProjects/limoncello-illuminate | app/Http/Requests/BoardsRequest.php | BoardsRequest.validateOnPost | protected function validateOnPost(ErrorCollection $errors)
{
$this->validateAttributes([
Schema::ATTR_TITLE => 'required|max:' . Model::LENGTH_TITLE,
], $errors);
} | php | protected function validateOnPost(ErrorCollection $errors)
{
$this->validateAttributes([
Schema::ATTR_TITLE => 'required|max:' . Model::LENGTH_TITLE,
], $errors);
} | [
"protected",
"function",
"validateOnPost",
"(",
"ErrorCollection",
"$",
"errors",
")",
"{",
"$",
"this",
"->",
"validateAttributes",
"(",
"[",
"Schema",
"::",
"ATTR_TITLE",
"=>",
"'required|max:'",
".",
"Model",
"::",
"LENGTH_TITLE",
",",
"]",
",",
"$",
"error... | Validate input for 'store' action.
@param ErrorCollection $errors
@return void | [
"Validate",
"input",
"for",
"store",
"action",
"."
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Http/Requests/BoardsRequest.php#L39-L44 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php | ProjectDescriptorMapper.populate | public function populate(ProjectDescriptor $projectDescriptor)
{
/** @var IteratorInterface $iteratorInterface */
$iteratorInterface = $this->getCache()->getIterator();
// load the settings object
try {
$settings = $this->getCache()->getItem(self::KEY_SETTINGS);
} catch (\Exception $e) {
$settings = $this->igBinaryCompatibleCacheClear(self::KEY_SETTINGS, $e);
}
if ($settings) {
$projectDescriptor->setSettings($settings);
}
// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
if ($iteratorInterface->valid()) {
foreach ($this->getCache() as $key) {
try {
$item = $this->getCache()->getItem($key);
} catch (\Exception $e) {
$this->igBinaryCompatibleCacheClear($key, $e);
}
if ($item instanceof FileDescriptor) {
$projectDescriptor->getFiles()->set($item->getPath(), $item);
}
}
}
} | php | public function populate(ProjectDescriptor $projectDescriptor)
{
/** @var IteratorInterface $iteratorInterface */
$iteratorInterface = $this->getCache()->getIterator();
// load the settings object
try {
$settings = $this->getCache()->getItem(self::KEY_SETTINGS);
} catch (\Exception $e) {
$settings = $this->igBinaryCompatibleCacheClear(self::KEY_SETTINGS, $e);
}
if ($settings) {
$projectDescriptor->setSettings($settings);
}
// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
if ($iteratorInterface->valid()) {
foreach ($this->getCache() as $key) {
try {
$item = $this->getCache()->getItem($key);
} catch (\Exception $e) {
$this->igBinaryCompatibleCacheClear($key, $e);
}
if ($item instanceof FileDescriptor) {
$projectDescriptor->getFiles()->set($item->getPath(), $item);
}
}
}
} | [
"public",
"function",
"populate",
"(",
"ProjectDescriptor",
"$",
"projectDescriptor",
")",
"{",
"/** @var IteratorInterface $iteratorInterface */",
"$",
"iteratorInterface",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"getIterator",
"(",
")",
";",
"// load the... | Returns the Project Descriptor from the cache.
@param ProjectDescriptor $projectDescriptor
@return void | [
"Returns",
"the",
"Project",
"Descriptor",
"from",
"the",
"cache",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php#L61-L91 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php | ProjectDescriptorMapper.garbageCollect | public function garbageCollect(Collection $collection)
{
$projectRoot = $collection->getProjectRoot();
$filenames = $collection->getFilenames();
foreach ($filenames as &$name) {
// the cache key contains a path relative to the project root; here we expect absolute paths.
$name = self::FILE_PREFIX . md5(substr($name, strlen($projectRoot)));
}
/** @var IteratorInterface $iteratorInterface */
$iteratorInterface = $this->getCache()->getIterator();
// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
if ($iteratorInterface->valid()) {
foreach ($this->getCache() as $item) {
if (substr($item, 0, strlen(self::FILE_PREFIX)) === self::FILE_PREFIX && !in_array($item, $filenames)) {
$this->getCache()->removeItem($item);
}
}
}
} | php | public function garbageCollect(Collection $collection)
{
$projectRoot = $collection->getProjectRoot();
$filenames = $collection->getFilenames();
foreach ($filenames as &$name) {
// the cache key contains a path relative to the project root; here we expect absolute paths.
$name = self::FILE_PREFIX . md5(substr($name, strlen($projectRoot)));
}
/** @var IteratorInterface $iteratorInterface */
$iteratorInterface = $this->getCache()->getIterator();
// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
if ($iteratorInterface->valid()) {
foreach ($this->getCache() as $item) {
if (substr($item, 0, strlen(self::FILE_PREFIX)) === self::FILE_PREFIX && !in_array($item, $filenames)) {
$this->getCache()->removeItem($item);
}
}
}
} | [
"public",
"function",
"garbageCollect",
"(",
"Collection",
"$",
"collection",
")",
"{",
"$",
"projectRoot",
"=",
"$",
"collection",
"->",
"getProjectRoot",
"(",
")",
";",
"$",
"filenames",
"=",
"$",
"collection",
"->",
"getFilenames",
"(",
")",
";",
"foreach... | Removes all files in cache that do not occur in the given FileSet Collection.
@param Collection $collection
@return void | [
"Removes",
"all",
"files",
"in",
"cache",
"that",
"do",
"not",
"occur",
"in",
"the",
"given",
"FileSet",
"Collection",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php#L163-L184 |
qlake/framework | src/Qlake/Routing/Router.php | Router.addRoute | protected function addRoute($methods, $uri, $action)
{
$route = $this->createRoute($methods, $uri, $action);
$route->setPrefixUri($this->processGroupsUri());
$this->routes->addRoute($route);
return $route;
} | php | protected function addRoute($methods, $uri, $action)
{
$route = $this->createRoute($methods, $uri, $action);
$route->setPrefixUri($this->processGroupsUri());
$this->routes->addRoute($route);
return $route;
} | [
"protected",
"function",
"addRoute",
"(",
"$",
"methods",
",",
"$",
"uri",
",",
"$",
"action",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"$",
"methods",
",",
"$",
"uri",
",",
"$",
"action",
")",
";",
"$",
"route",
"->",
... | Create and register a route
@param array $methods
@param string $uri
@param Closure|string $action
@return Qlake\Routing\Route | [
"Create",
"and",
"register",
"a",
"route"
] | train | https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Router.php#L231-L240 |
qlake/framework | src/Qlake/Routing/Router.php | Router.match | public function match(Request $request)
{
foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
{
if ($route->isMatch($request->getPathInfo()))
{
return $route;
}
}
return null;
} | php | public function match(Request $request)
{
foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
{
if ($route->isMatch($request->getPathInfo()))
{
return $route;
}
}
return null;
} | [
"public",
"function",
"match",
"(",
"Request",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"->",
"filterByMethod",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
")",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route"... | Chack matching requested uri by registered routes.
@param Qlake\Http\Request $request
@return Qlake\Routing\Route|null | [
"Chack",
"matching",
"requested",
"uri",
"by",
"registered",
"routes",
"."
] | train | https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Router.php#L287-L298 |
thelia-modules/CustomerGroup | Model/Map/CustomerGroupI18nTableMap.php | CustomerGroupI18nTableMap.buildTableMap | public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerGroupI18nTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CustomerGroupI18nTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CustomerGroupI18nTableMap());
}
} | php | public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerGroupI18nTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CustomerGroupI18nTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CustomerGroupI18nTableMap());
}
} | [
"public",
"static",
"function",
"buildTableMap",
"(",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getDatabaseMap",
"(",
"CustomerGroupI18nTableMap",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"!",
"$",
"dbMap",
"->",
... | Add a TableMap instance to the database for this tableMap class. | [
"Add",
"a",
"TableMap",
"instance",
"to",
"the",
"database",
"for",
"this",
"tableMap",
"class",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Map/CustomerGroupI18nTableMap.php#L372-L378 |
thelia-modules/CustomerGroup | Model/Map/CustomerGroupI18nTableMap.php | CustomerGroupI18nTableMap.doDelete | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CustomerGroup\Model\CustomerGroupI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CustomerGroupI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CustomerGroupI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CustomerGroupI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CustomerGroupI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CustomerGroupI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CustomerGroupI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | php | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CustomerGroup\Model\CustomerGroupI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CustomerGroupI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CustomerGroupI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CustomerGroupI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CustomerGroupI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CustomerGroupI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CustomerGroupI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getW... | Performs a DELETE on the database, given a CustomerGroupI18n or Criteria object OR a primary key value.
@param mixed $values Criteria or CustomerGroupI18n object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"CustomerGroupI18n",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Map/CustomerGroupI18nTableMap.php#L391-L427 |
mridang/magazine | src/Magazine/Command.php | Params.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getArgument('path');
$version = $input->getArgument('version');
$package_name = $input->getArgument('name');
if (!file_exists($path) && !is_file($input->getArgument('path'))) {
self::error($output, "The specified path is missing or a directory");
} else {
if (json_decode(file_get_contents($path)) == null) {
self::error($output, "The specified file is not a valid JSON file");
} else {
$packager = new Magazine($path, $version, $output, $package_name);
$packager->package();
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getArgument('path');
$version = $input->getArgument('version');
$package_name = $input->getArgument('name');
if (!file_exists($path) && !is_file($input->getArgument('path'))) {
self::error($output, "The specified path is missing or a directory");
} else {
if (json_decode(file_get_contents($path)) == null) {
self::error($output, "The specified file is not a valid JSON file");
} else {
$packager = new Magazine($path, $version, $output, $package_name);
$packager->package();
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"path",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'path'",
")",
";",
"$",
"version",
"=",
"$",
"input",
"->",
"getArgument",
... | Main CLI method that validates that the specified path exist, is a file
and a well-formed JSON file else exits with status code 0.
@inheritdoc | [
"Main",
"CLI",
"method",
"that",
"validates",
"that",
"the",
"specified",
"path",
"exist",
"is",
"a",
"file",
"and",
"a",
"well",
"-",
"formed",
"JSON",
"file",
"else",
"exits",
"with",
"status",
"code",
"0",
"."
] | train | https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/src/Magazine/Command.php#L52-L67 |
mustardandrew/muan-laravel-acl | src/Models/UserObserver.php | UserObserver.created | public function created($user)
{
if (! $baseName = $user->baseRole) {
return;
}
// Attach base role
if (method_exists($user, 'attachRole')) {
$user->attachRole($baseName);
}
} | php | public function created($user)
{
if (! $baseName = $user->baseRole) {
return;
}
// Attach base role
if (method_exists($user, 'attachRole')) {
$user->attachRole($baseName);
}
} | [
"public",
"function",
"created",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"$",
"baseName",
"=",
"$",
"user",
"->",
"baseRole",
")",
"{",
"return",
";",
"}",
"// Attach base role",
"if",
"(",
"method_exists",
"(",
"$",
"user",
",",
"'attachRole'",
")... | Listen to the User created event.
@param object $user
@return void | [
"Listen",
"to",
"the",
"User",
"created",
"event",
"."
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Models/UserObserver.php#L19-L29 |
Rxnet/rabbitmq | Queue.php | Queue.get | public function get($queue, $noAck = false): Observable
{
$promise = $this->channel->get($queue, $noAck);
return Observable::fromPromise($promise)
->map(function (BaseMessage $message) {
return new Message($this->channel, $message);
});
} | php | public function get($queue, $noAck = false): Observable
{
$promise = $this->channel->get($queue, $noAck);
return Observable::fromPromise($promise)
->map(function (BaseMessage $message) {
return new Message($this->channel, $message);
});
} | [
"public",
"function",
"get",
"(",
"$",
"queue",
",",
"$",
"noAck",
"=",
"false",
")",
":",
"Observable",
"{",
"$",
"promise",
"=",
"$",
"this",
"->",
"channel",
"->",
"get",
"(",
"$",
"queue",
",",
"$",
"noAck",
")",
";",
"return",
"Observable",
":... | Pop one element from the queue. | [
"Pop",
"one",
"element",
"from",
"the",
"queue",
"."
] | train | https://github.com/Rxnet/rabbitmq/blob/16e2fa39daddb6cca70716b8895470c4691a6f9e/Queue.php#L118-L126 |
oroinc/OroLayoutComponent | Loader/Driver/AbstractDriver.php | AbstractDriver.load | public function load($file)
{
$className = $this->generateClassName($file);
if (!class_exists($className, false)) {
$cacheFilename = $this->getCacheFilename($file);
// write cache to file, refresh cache if source file fresher then cached one in debug mode
if (!is_file($cacheFilename) || ($this->isDebug() && filemtime($file) > filemtime($cacheFilename))) {
$this->writeCacheFile($cacheFilename, $this->doGenerate($className, $file));
}
require_once $cacheFilename;
}
return new $className($this);
} | php | public function load($file)
{
$className = $this->generateClassName($file);
if (!class_exists($className, false)) {
$cacheFilename = $this->getCacheFilename($file);
// write cache to file, refresh cache if source file fresher then cached one in debug mode
if (!is_file($cacheFilename) || ($this->isDebug() && filemtime($file) > filemtime($cacheFilename))) {
$this->writeCacheFile($cacheFilename, $this->doGenerate($className, $file));
}
require_once $cacheFilename;
}
return new $className($this);
} | [
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"generateClassName",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
")",
"{",
"$",
"cacheFilena... | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Driver/AbstractDriver.php#L45-L60 |
oroinc/OroLayoutComponent | Loader/Driver/AbstractDriver.php | AbstractDriver.doGenerate | protected function doGenerate($className, $file)
{
$resourceDataForGenerator = $this->loadResourceGeneratorData($file);
try {
$visitors = $this->prepareVisitors($file);
return $this->getGenerator()->generate($className, $resourceDataForGenerator, $visitors);
} catch (SyntaxException $e) {
$message = $e->getMessage() . "\n" . $this->dumpSource($e->getSource());
$message .= str_repeat("\n", 2) . 'Filename: ' . $file;
throw new \RuntimeException($message, 0, $e);
}
} | php | protected function doGenerate($className, $file)
{
$resourceDataForGenerator = $this->loadResourceGeneratorData($file);
try {
$visitors = $this->prepareVisitors($file);
return $this->getGenerator()->generate($className, $resourceDataForGenerator, $visitors);
} catch (SyntaxException $e) {
$message = $e->getMessage() . "\n" . $this->dumpSource($e->getSource());
$message .= str_repeat("\n", 2) . 'Filename: ' . $file;
throw new \RuntimeException($message, 0, $e);
}
} | [
"protected",
"function",
"doGenerate",
"(",
"$",
"className",
",",
"$",
"file",
")",
"{",
"$",
"resourceDataForGenerator",
"=",
"$",
"this",
"->",
"loadResourceGeneratorData",
"(",
"$",
"file",
")",
";",
"try",
"{",
"$",
"visitors",
"=",
"$",
"this",
"->",... | @param string $className
@param string $file
@return string | [
"@param",
"string",
"$className",
"@param",
"string",
"$file"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Driver/AbstractDriver.php#L76-L90 |
oroinc/OroLayoutComponent | Loader/Driver/AbstractDriver.php | AbstractDriver.prepareVisitors | protected function prepareVisitors($file)
{
$name = pathinfo($file, PATHINFO_FILENAME);
if (strpos($name, self::ELEMENT_PREFIX) === 0) {
return new VisitorCollection([new ElementDependentVisitor(substr($name, 1))]);
}
return null;
} | php | protected function prepareVisitors($file)
{
$name = pathinfo($file, PATHINFO_FILENAME);
if (strpos($name, self::ELEMENT_PREFIX) === 0) {
return new VisitorCollection([new ElementDependentVisitor(substr($name, 1))]);
}
return null;
} | [
"protected",
"function",
"prepareVisitors",
"(",
"$",
"file",
")",
"{",
"$",
"name",
"=",
"pathinfo",
"(",
"$",
"file",
",",
"PATHINFO_FILENAME",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"self",
"::",
"ELEMENT_PREFIX",
")",
"===",
"0",
")"... | @param string $file
@return null|VisitorCollection | [
"@param",
"string",
"$file"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Driver/AbstractDriver.php#L106-L115 |
oroinc/OroLayoutComponent | Loader/Driver/AbstractDriver.php | AbstractDriver.getCacheFilename | protected function getCacheFilename($name)
{
$class = substr($this->generateClassName($name), strlen(static::CLASS_PREFIX));
return str_replace(
'/',
DIRECTORY_SEPARATOR,
sprintf(
'%s/%s/%s/%s.php',
$this->getCacheDir(),
substr($class, 0, 2),
substr($class, 2, 2),
substr($class, 4)
)
);
} | php | protected function getCacheFilename($name)
{
$class = substr($this->generateClassName($name), strlen(static::CLASS_PREFIX));
return str_replace(
'/',
DIRECTORY_SEPARATOR,
sprintf(
'%s/%s/%s/%s.php',
$this->getCacheDir(),
substr($class, 0, 2),
substr($class, 2, 2),
substr($class, 4)
)
);
} | [
"protected",
"function",
"getCacheFilename",
"(",
"$",
"name",
")",
"{",
"$",
"class",
"=",
"substr",
"(",
"$",
"this",
"->",
"generateClassName",
"(",
"$",
"name",
")",
",",
"strlen",
"(",
"static",
"::",
"CLASS_PREFIX",
")",
")",
";",
"return",
"str_re... | Generates PHP filename based on given resource name
@param string $name Resource filename
@return bool|string Returns FALSE if cache dir isn't configured or generated PHP absolute filename otherwise | [
"Generates",
"PHP",
"filename",
"based",
"on",
"given",
"resource",
"name"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Driver/AbstractDriver.php#L174-L189 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/UserController.php | UserController.index | public function index()
{
$this->authorize('readList', User::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$results = $this->userRepo->getUsers(
$params['filter'],
$params['orderBy'],
$params['page'],
$params['perPage']
);
return $this->respondWithSuccess($results, new UserTransformer);
} | php | public function index()
{
$this->authorize('readList', User::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$results = $this->userRepo->getUsers(
$params['filter'],
$params['orderBy'],
$params['page'],
$params['perPage']
);
return $this->respondWithSuccess($results, new UserTransformer);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'readList'",
",",
"User",
"::",
"class",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'list'",
")",
";",
"$",
"params",
"=",
... | Display list of users
@return \Illuminate\Http\JsonResponse | [
"Display",
"list",
"of",
"users"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/UserController.php#L54-L66 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/UserController.php | UserController.show | public function show($id)
{
$user = $this->userRepo->getById($id);
if (!empty($user)) {
$this->authorize('read', $user);
return $this->respondWithSuccess($user, new UserTransformer);
}
return $this->respondNotFound();
} | php | public function show($id)
{
$user = $this->userRepo->getById($id);
if (!empty($user)) {
$this->authorize('read', $user);
return $this->respondWithSuccess($user, new UserTransformer);
}
return $this->respondNotFound();
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
... | Display the specified resource.
@param int $id user id
@return Response | [
"Display",
"the",
"specified",
"resource",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/UserController.php#L75-L83 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/UserController.php | UserController.destroy | public function destroy($id)
{
$user = $this->userRepo->getById($id);
if (!empty($user)) {
$this->authorize('delete', $user);
$user->delete();
return $this->respondWithSimpleSuccess(['success' => true]);
}
return $this->respondNotFound();
} | php | public function destroy($id)
{
$user = $this->userRepo->getById($id);
if (!empty($user)) {
$this->authorize('delete', $user);
$user->delete();
return $this->respondWithSimpleSuccess(['success' => true]);
}
return $this->respondNotFound();
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"("... | Remove the specified user from database.
@param int $id Id of the user
@return \Illuminate\Http\JsonResponse | [
"Remove",
"the",
"specified",
"user",
"from",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/UserController.php#L92-L102 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/UserController.php | UserController.update | public function update($id)
{
$user = $this->userRepo->getById($id);
if (!empty($user)) {
$this->authorize('update', $user);
$input = $this->validator->bind('nick', ['user_id' => $user->id])->bind('email', ['user_id' => $user->id])
->validate('update');
$user = $this->userRepo->update($user, $input);
return $this->respondWithSuccess($user, new UserTransformer());
}
return $this->respondNotFound();
} | php | public function update($id)
{
$user = $this->userRepo->getById($id);
if (!empty($user)) {
$this->authorize('update', $user);
$input = $this->validator->bind('nick', ['user_id' => $user->id])->bind('email', ['user_id' => $user->id])
->validate('update');
$user = $this->userRepo->update($user, $input);
return $this->respondWithSuccess($user, new UserTransformer());
}
return $this->respondNotFound();
} | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",... | Updates the specified resource in the database.
@param int $id User id
@return \Illuminate\Http\JsonResponse | [
"Updates",
"the",
"specified",
"resource",
"in",
"the",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/UserController.php#L111-L122 |
alevilar/ristorantino-vendor | Product/Controller/ProductosController.php | ProductosController.actualizarPreciosFuturos | public function actualizarPreciosFuturos(){
$failed = false;
$preciosFuturos = $this->Producto->ProductosPreciosFuturo->find('all');
$productos = array();
$pfs['ProductosPreciosFuturo.id'] = array();
foreach ($preciosFuturos as $pf){
$pfs['ProductosPreciosFuturo.id'][] = $pf['ProductosPreciosFuturo']['id'];
$productos[] = array( 'Producto' => array(
'precio' => $pf['ProductosPreciosFuturo']['precio'],
'id' => $pf['ProductosPreciosFuturo']['producto_id']
));
}
if ( $this->Producto->saveAll($productos)) {
if ( $this->Producto->ProductosPreciosFuturo->deleteAll($pfs) ) {
$this->Session->setFlash('Falló al querer eliminar los precios futuros', 'Risto.flash_error');
}
$this->Session->setFlash('Se han modificado TODOS los precios futuros de los productos');
} else {
$this->Session->setFlash('Fallo al aplicar los cambios', 'Risto.flash_error');
}
$this->redirect($this->referer());
} | php | public function actualizarPreciosFuturos(){
$failed = false;
$preciosFuturos = $this->Producto->ProductosPreciosFuturo->find('all');
$productos = array();
$pfs['ProductosPreciosFuturo.id'] = array();
foreach ($preciosFuturos as $pf){
$pfs['ProductosPreciosFuturo.id'][] = $pf['ProductosPreciosFuturo']['id'];
$productos[] = array( 'Producto' => array(
'precio' => $pf['ProductosPreciosFuturo']['precio'],
'id' => $pf['ProductosPreciosFuturo']['producto_id']
));
}
if ( $this->Producto->saveAll($productos)) {
if ( $this->Producto->ProductosPreciosFuturo->deleteAll($pfs) ) {
$this->Session->setFlash('Falló al querer eliminar los precios futuros', 'Risto.flash_error');
}
$this->Session->setFlash('Se han modificado TODOS los precios futuros de los productos');
} else {
$this->Session->setFlash('Fallo al aplicar los cambios', 'Risto.flash_error');
}
$this->redirect($this->referer());
} | [
"public",
"function",
"actualizarPreciosFuturos",
"(",
")",
"{",
"$",
"failed",
"=",
"false",
";",
"$",
"preciosFuturos",
"=",
"$",
"this",
"->",
"Producto",
"->",
"ProductosPreciosFuturo",
"->",
"find",
"(",
"'all'",
")",
";",
"$",
"productos",
"=",
"array"... | } | [
"}"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Product/Controller/ProductosController.php#L140-L165 |
DesignPond/newsletter | src/Http/Controllers/Backend/NewsletterController.php | NewsletterController.index | public function index()
{
$newsletters = $this->newsletter->getAll();
$listes = $this->list->getAll();
return view('newsletter::Backend.template.index')->with(['newsletters' => $newsletters, 'listes' => $listes]);
} | php | public function index()
{
$newsletters = $this->newsletter->getAll();
$listes = $this->list->getAll();
return view('newsletter::Backend.template.index')->with(['newsletters' => $newsletters, 'listes' => $listes]);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"newsletters",
"=",
"$",
"this",
"->",
"newsletter",
"->",
"getAll",
"(",
")",
";",
"$",
"listes",
"=",
"$",
"this",
"->",
"list",
"->",
"getAll",
"(",
")",
";",
"return",
"view",
"(",
"'newsletter::... | Display a listing of the resource.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"resource",
"."
] | train | https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/NewsletterController.php#L41-L47 |
DesignPond/newsletter | src/Http/Controllers/Backend/NewsletterController.php | NewsletterController.store | public function store(Request $request)
{
$data = $request->except('logos','header','soutien');
if(!empty($request->file('logos'))){
$logos = $this->upload->upload($request->file('logos'), 'newsletter');
$data['logos'] = isset($logos['name']) ? $logos['name'] : null;
}
if(!empty($request->file('header'))){
$header = $this->upload->upload($request->file('header'), 'newsletter');
$data['header'] = isset($header['name']) ? $header['name'] : null;
}
if(!empty($request->file('soutien'))){
$soutien = $this->upload->upload($request->file('soutien'), 'newsletter');
$data['soutien'] = isset($soutien['name']) ? $soutien['name'] : null;
}
$newsletter = $this->newsletter->create($data);
alert()->success('Newsletter crée');
return redirect('build/newsletter/'.$newsletter->id);
} | php | public function store(Request $request)
{
$data = $request->except('logos','header','soutien');
if(!empty($request->file('logos'))){
$logos = $this->upload->upload($request->file('logos'), 'newsletter');
$data['logos'] = isset($logos['name']) ? $logos['name'] : null;
}
if(!empty($request->file('header'))){
$header = $this->upload->upload($request->file('header'), 'newsletter');
$data['header'] = isset($header['name']) ? $header['name'] : null;
}
if(!empty($request->file('soutien'))){
$soutien = $this->upload->upload($request->file('soutien'), 'newsletter');
$data['soutien'] = isset($soutien['name']) ? $soutien['name'] : null;
}
$newsletter = $this->newsletter->create($data);
alert()->success('Newsletter crée');
return redirect('build/newsletter/'.$newsletter->id);
} | [
"public",
"function",
"store",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"except",
"(",
"'logos'",
",",
"'header'",
",",
"'soutien'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"request",
"->",
"file",
"(",
... | Store a newly created resource in storage.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Store",
"a",
"newly",
"created",
"resource",
"in",
"storage",
"."
] | train | https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/NewsletterController.php#L76-L100 |
DesignPond/newsletter | src/Http/Controllers/Backend/NewsletterController.php | NewsletterController.show | public function show($id)
{
$lists = $this->mailjet->getAllLists();
$newsletter = $this->newsletter->find($id);
return view('newsletter::Backend.template.show')->with(['newsletter' => $newsletter, 'lists' => $lists]);
} | php | public function show($id)
{
$lists = $this->mailjet->getAllLists();
$newsletter = $this->newsletter->find($id);
return view('newsletter::Backend.template.show')->with(['newsletter' => $newsletter, 'lists' => $lists]);
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"$",
"lists",
"=",
"$",
"this",
"->",
"mailjet",
"->",
"getAllLists",
"(",
")",
";",
"$",
"newsletter",
"=",
"$",
"this",
"->",
"newsletter",
"->",
"find",
"(",
"$",
"id",
")",
";",
"return",
... | Display the specified resource.
@param int $id
@return \Illuminate\Http\Response | [
"Display",
"the",
"specified",
"resource",
"."
] | train | https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/NewsletterController.php#L108-L114 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.find | public function find($id)
{
$response = $this->client->request('GET', sprintf('/%s/%s', $this->name, $id));
$json = (string) $response->getBody();
if (404 === $response->getStatusCode()) {
throw new Exception('Document does not exist');
}
return JSONEncoder::decode($json);
} | php | public function find($id)
{
$response = $this->client->request('GET', sprintf('/%s/%s', $this->name, $id));
$json = (string) $response->getBody();
if (404 === $response->getStatusCode()) {
throw new Exception('Document does not exist');
}
return JSONEncoder::decode($json);
} | [
"public",
"function",
"find",
"(",
"$",
"id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"sprintf",
"(",
"'/%s/%s'",
",",
"$",
"this",
"->",
"name",
",",
"$",
"id",
")",
")",
";",
"$",
"json",... | Find a document by a id.
@param string $id
@throws Exception If the document doesn't exists.
@return mixed | [
"Find",
"a",
"document",
"by",
"a",
"id",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L60-L70 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.findAll | public function findAll($limit = null, $startKey = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $startKey) {
$path .= '&startkey='.(string) $startKey;
}
$json = (string) $this->client->request('GET', $path)->getBody();
$docs = JSONEncoder::decode($json);
return $docs;
} | php | public function findAll($limit = null, $startKey = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $startKey) {
$path .= '&startkey='.(string) $startKey;
}
$json = (string) $this->client->request('GET', $path)->getBody();
$docs = JSONEncoder::decode($json);
return $docs;
} | [
"public",
"function",
"findAll",
"(",
"$",
"limit",
"=",
"null",
",",
"$",
"startKey",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"\"/{$this->name}/_all_docs?include_docs=true\"",
";",
"if",
"(",
"null",
"!==",
"$",
"limit",
")",
"{",
"$",
"path",
".=",
"'... | Find all documents from the database.
@param int|null $limit
@param string|null $startKey
@return mixed | [
"Find",
"all",
"documents",
"from",
"the",
"database",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L80-L95 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.findDocuments | public function findDocuments(array $ids, $limit = null, $offset = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $offset) {
$path .= '&skip='.(integer) $offset;
}
$response = $this->client->request('POST', $path, [
'body' => JSONEncoder::encode(['keys' => $ids]),
'headers' => ['Content-Type' => 'application/json'],
]);
return JSONEncoder::decode((string) $response->getBody());
} | php | public function findDocuments(array $ids, $limit = null, $offset = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $offset) {
$path .= '&skip='.(integer) $offset;
}
$response = $this->client->request('POST', $path, [
'body' => JSONEncoder::encode(['keys' => $ids]),
'headers' => ['Content-Type' => 'application/json'],
]);
return JSONEncoder::decode((string) $response->getBody());
} | [
"public",
"function",
"findDocuments",
"(",
"array",
"$",
"ids",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"\"/{$this->name}/_all_docs?include_docs=true\"",
";",
"if",
"(",
"null",
"!==",
"$",
"limit",
")"... | Find a documents by a id.
@param array $ids
@param null|int $limit
@param null|int $offset
@return array|null | [
"Find",
"a",
"documents",
"by",
"a",
"id",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L106-L123 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.insert | public function insert(array &$doc)
{
if (isset($doc['_id'])) {
$clone = $doc;
unset($clone['_id']);
$response = $this->client->request('PUT', "/{$this->name}/{$doc['_id']}", [
'body' => JSONEncoder::encode($clone),
'headers' => ['Content-Type' => 'application/json'],
]);
} else {
$response = $this->client->request('POST', "/{$this->name}/", [
'body' => JSONEncoder::encode($doc),
'headers' => ['Content-Type' => 'application/json'],
]);
}
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
} | php | public function insert(array &$doc)
{
if (isset($doc['_id'])) {
$clone = $doc;
unset($clone['_id']);
$response = $this->client->request('PUT', "/{$this->name}/{$doc['_id']}", [
'body' => JSONEncoder::encode($clone),
'headers' => ['Content-Type' => 'application/json'],
]);
} else {
$response = $this->client->request('POST', "/{$this->name}/", [
'body' => JSONEncoder::encode($doc),
'headers' => ['Content-Type' => 'application/json'],
]);
}
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
} | [
"public",
"function",
"insert",
"(",
"array",
"&",
"$",
"doc",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"doc",
"[",
"'_id'",
"]",
")",
")",
"{",
"$",
"clone",
"=",
"$",
"doc",
";",
"unset",
"(",
"$",
"clone",
"[",
"'_id'",
"]",
")",
";",
"$",
... | Insert a new document.
@param array $doc
@deprecated To update a document use Database::update, it will be removed in version 2
@throws Exception | [
"Insert",
"a",
"new",
"document",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L134-L159 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.update | public function update($id, array &$doc)
{
$json = JSONEncoder::encode($doc);
$response = $this->client->request('PUT', "/{$this->name}/{$id}", [
'body' => $json,
'headers' => ['Content-Type' => 'application/json'],
]);
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
} | php | public function update($id, array &$doc)
{
$json = JSONEncoder::encode($doc);
$response = $this->client->request('PUT', "/{$this->name}/{$id}", [
'body' => $json,
'headers' => ['Content-Type' => 'application/json'],
]);
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"array",
"&",
"$",
"doc",
")",
"{",
"$",
"json",
"=",
"JSONEncoder",
"::",
"encode",
"(",
"$",
"doc",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'PUT'",
... | Updates a document.
@param string $id The id from the document
@param array $doc A reference from the document
@throws Exception | [
"Updates",
"a",
"document",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L169-L186 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.delete | public function delete($id, $rev)
{
$response = $this->client->request('DELETE', "/{$this->name}/{$id}?rev={$rev}");
if (200 !== $response->getStatusCode()) {
throw new Exception(sprintf('Unable to delete %s', $id));
}
return true;
} | php | public function delete($id, $rev)
{
$response = $this->client->request('DELETE', "/{$this->name}/{$id}?rev={$rev}");
if (200 !== $response->getStatusCode()) {
throw new Exception(sprintf('Unable to delete %s', $id));
}
return true;
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
",",
"$",
"rev",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'DELETE'",
",",
"\"/{$this->name}/{$id}?rev={$rev}\"",
")",
";",
"if",
"(",
"200",
"!==",
"$",
"response"... | Deletes a document.
@param string $id
@param string $rev
@throws \RuntimeException
@return bool | [
"Deletes",
"a",
"document",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L198-L207 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.getInfo | public function getInfo()
{
$json = (string) $this->client->request('GET', "/{$this->name}/")->getBody();
return JSONEncoder::decode($json);
} | php | public function getInfo()
{
$json = (string) $this->client->request('GET', "/{$this->name}/")->getBody();
return JSONEncoder::decode($json);
} | [
"public",
"function",
"getInfo",
"(",
")",
"{",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"\"/{$this->name}/\"",
")",
"->",
"getBody",
"(",
")",
";",
"return",
"JSONEncoder",
"::",
"decode",
... | Return the database informations.
@return array | [
"Return",
"the",
"database",
"informations",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L224-L229 |
Baachi/CouchDB | src/CouchDB/Database.php | Database.getChanges | public function getChanges()
{
$response = $this->client->request('GET', "/{$this->name}/_changes");
if (200 !== $response->getStatusCode()) {
throw new Exception('Request wasn\'t successfull');
}
return JSONEncoder::decode((string) $response->getBody());
} | php | public function getChanges()
{
$response = $this->client->request('GET', "/{$this->name}/_changes");
if (200 !== $response->getStatusCode()) {
throw new Exception('Request wasn\'t successfull');
}
return JSONEncoder::decode((string) $response->getBody());
} | [
"public",
"function",
"getChanges",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"\"/{$this->name}/_changes\"",
")",
";",
"if",
"(",
"200",
"!==",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
... | Return informations about the last changes from the database.
@throws \RuntimeException If the request was not successfull
@return array | [
"Return",
"informations",
"about",
"the",
"last",
"changes",
"from",
"the",
"database",
"."
] | train | https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L238-L247 |
canax/database-query-builder | src/DatabaseQueryBuilder/DatabaseQueryBuilder.php | DatabaseQueryBuilder.setDefaultsFromConfiguration | public function setDefaultsFromConfiguration()
{
if ($this->options['dsn']) {
$dsn = explode(':', $this->options['dsn']);
$this->setSQLDialect($dsn[0]);
}
$this->setTablePrefix($this->options['table_prefix']);
} | php | public function setDefaultsFromConfiguration()
{
if ($this->options['dsn']) {
$dsn = explode(':', $this->options['dsn']);
$this->setSQLDialect($dsn[0]);
}
$this->setTablePrefix($this->options['table_prefix']);
} | [
"public",
"function",
"setDefaultsFromConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'dsn'",
"]",
")",
"{",
"$",
"dsn",
"=",
"explode",
"(",
"':'",
",",
"$",
"this",
"->",
"options",
"[",
"'dsn'",
"]",
")",
";",
"$",
... | Update builder settings from active configuration.
@return void | [
"Update",
"builder",
"settings",
"from",
"active",
"configuration",
"."
] | train | https://github.com/canax/database-query-builder/blob/c26a8a1537a8d8c2dcee305167980a57384b4e77/src/DatabaseQueryBuilder/DatabaseQueryBuilder.php#L22-L30 |
canax/database-query-builder | src/DatabaseQueryBuilder/DatabaseQueryBuilder.php | DatabaseQueryBuilder.execute | public function execute($query = null, array $params = []) : object
{
// When using one argument and its array, assume its $params
if (is_array($query)) {
$params = $query;
$query = null;
}
if (!$query) {
$query = $this->getSQL();
}
return parent::execute($query, $params);
} | php | public function execute($query = null, array $params = []) : object
{
// When using one argument and its array, assume its $params
if (is_array($query)) {
$params = $query;
$query = null;
}
if (!$query) {
$query = $this->getSQL();
}
return parent::execute($query, $params);
} | [
"public",
"function",
"execute",
"(",
"$",
"query",
"=",
"null",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"object",
"{",
"// When using one argument and its array, assume its $params",
"if",
"(",
"is_array",
"(",
"$",
"query",
")",
")",
"{",
"$"... | Execute a SQL-query.
@param string|null|array $query the SQL statement (or $params)
@param array $params the params array
@return self | [
"Execute",
"a",
"SQL",
"-",
"query",
"."
] | train | https://github.com/canax/database-query-builder/blob/c26a8a1537a8d8c2dcee305167980a57384b4e77/src/DatabaseQueryBuilder/DatabaseQueryBuilder.php#L42-L55 |
wplibs/rules | src/Operator/Is_Empty.php | Is_Empty.evaluate | public function evaluate( Context $context ) {
/* @var \Ruler\Variable $left */
list( $left ) = $this->getOperands();
$value = $left->prepareValue( $context )->getValue();
if ( is_null( $value ) ) {
return true;
}
if ( is_string( $value ) ) {
return trim( $value ) === '';
}
if ( $value instanceof \Countable ) {
return count( $value ) === 0;
}
return empty( $value );
} | php | public function evaluate( Context $context ) {
/* @var \Ruler\Variable $left */
list( $left ) = $this->getOperands();
$value = $left->prepareValue( $context )->getValue();
if ( is_null( $value ) ) {
return true;
}
if ( is_string( $value ) ) {
return trim( $value ) === '';
}
if ( $value instanceof \Countable ) {
return count( $value ) === 0;
}
return empty( $value );
} | [
"public",
"function",
"evaluate",
"(",
"Context",
"$",
"context",
")",
"{",
"/* @var \\Ruler\\Variable $left */",
"list",
"(",
"$",
"left",
")",
"=",
"$",
"this",
"->",
"getOperands",
"(",
")",
";",
"$",
"value",
"=",
"$",
"left",
"->",
"prepareValue",
"("... | Evaluate the operands.
@param Context $context Context with which to evaluate this Proposition.
@return boolean | [
"Evaluate",
"the",
"operands",
"."
] | train | https://github.com/wplibs/rules/blob/29b4495e2ae87349fd64fcd844f3ba96cc268e3d/src/Operator/Is_Empty.php#L16-L35 |
tigron/skeleton-file | migration/20160503_215547_restruct_datastore.php | Migration_20160503_215547_Restruct_datastore.up | public function up() {
$table = File::trait_get_database_table();
$db = Database::get();
$ids = $db->get_column('SELECT id FROM ' . $table, []);
foreach ($ids as $id) {
$file = File::get_by_id($id);
$old_path = $this->get_old_path($file);
if (!file_exists($old_path)) {
continue;
}
$new_path = $file->get_path();
// create directory if not exist
$pathinfo = pathinfo($new_path);
if (!is_dir($pathinfo['dirname'])) {
mkdir($pathinfo['dirname'], 0755, true);
}
rename($old_path, $new_path);
}
/**
* Run this to cleanup empty directories
*/
// echo 'find ' . $path . ' -type d -empty -delete';
} | php | public function up() {
$table = File::trait_get_database_table();
$db = Database::get();
$ids = $db->get_column('SELECT id FROM ' . $table, []);
foreach ($ids as $id) {
$file = File::get_by_id($id);
$old_path = $this->get_old_path($file);
if (!file_exists($old_path)) {
continue;
}
$new_path = $file->get_path();
// create directory if not exist
$pathinfo = pathinfo($new_path);
if (!is_dir($pathinfo['dirname'])) {
mkdir($pathinfo['dirname'], 0755, true);
}
rename($old_path, $new_path);
}
/**
* Run this to cleanup empty directories
*/
// echo 'find ' . $path . ' -type d -empty -delete';
} | [
"public",
"function",
"up",
"(",
")",
"{",
"$",
"table",
"=",
"File",
"::",
"trait_get_database_table",
"(",
")",
";",
"$",
"db",
"=",
"Database",
"::",
"get",
"(",
")",
";",
"$",
"ids",
"=",
"$",
"db",
"->",
"get_column",
"(",
"'SELECT id FROM '",
"... | Migrate up
@access public | [
"Migrate",
"up"
] | train | https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/migration/20160503_215547_restruct_datastore.php#L20-L46 |
tigron/skeleton-file | migration/20160503_215547_restruct_datastore.php | Migration_20160503_215547_Restruct_datastore.get_old_path | private function get_old_path(File $file) {
if (Config::$store_dir === null AND Config::$file_dir === null) {
throw new \Exception('Set a path first in "Config::$file_dir"');
}
$subpath = substr(base_convert($file->md5sum, 16, 10), 0, 3);
$subpath = implode('/', str_split($subpath)) . '/';
if (\Skeleton\File\Config::$file_dir !== null) {
$path = \Skeleton\File\Config::$file_dir . '/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
} else {
$path = \Skeleton\File\Config::$store_dir . '/file/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
}
return $path;
} | php | private function get_old_path(File $file) {
if (Config::$store_dir === null AND Config::$file_dir === null) {
throw new \Exception('Set a path first in "Config::$file_dir"');
}
$subpath = substr(base_convert($file->md5sum, 16, 10), 0, 3);
$subpath = implode('/', str_split($subpath)) . '/';
if (\Skeleton\File\Config::$file_dir !== null) {
$path = \Skeleton\File\Config::$file_dir . '/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
} else {
$path = \Skeleton\File\Config::$store_dir . '/file/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
}
return $path;
} | [
"private",
"function",
"get_old_path",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"Config",
"::",
"$",
"store_dir",
"===",
"null",
"AND",
"Config",
"::",
"$",
"file_dir",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Set a path f... | Get the old path
@access private
@param string $md5sum
@return string $path | [
"Get",
"the",
"old",
"path"
] | train | https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/migration/20160503_215547_restruct_datastore.php#L55-L69 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parser.php | ezcMailParser.parseMail | public function parseMail( ezcMailParserSet $set, $class = null )
{
$mail = array();
if ( !$set->hasData() )
{
return $mail;
}
if ( $class === null )
{
$class = $this->options->mailClass;
}
do
{
$this->partParser = new ezcMailRfc822Parser();
$data = "";
$size = 0;
while ( ( $data = $set->getNextLine() ) !== null )
{
$this->partParser->parseBody( $data );
$size += strlen( $data );
}
$part = $this->partParser->finish( $class );
$part->size = $size;
$mail[] = $part;
} while ( $set->nextMail() );
return $mail;
} | php | public function parseMail( ezcMailParserSet $set, $class = null )
{
$mail = array();
if ( !$set->hasData() )
{
return $mail;
}
if ( $class === null )
{
$class = $this->options->mailClass;
}
do
{
$this->partParser = new ezcMailRfc822Parser();
$data = "";
$size = 0;
while ( ( $data = $set->getNextLine() ) !== null )
{
$this->partParser->parseBody( $data );
$size += strlen( $data );
}
$part = $this->partParser->finish( $class );
$part->size = $size;
$mail[] = $part;
} while ( $set->nextMail() );
return $mail;
} | [
"public",
"function",
"parseMail",
"(",
"ezcMailParserSet",
"$",
"set",
",",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"mail",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"set",
"->",
"hasData",
"(",
")",
")",
"{",
"return",
"$",
"mail",
";... | Returns an array of ezcMail objects parsed from the mail set $set.
You can optionally use ezcMailParserOptions to provide an alternate class
name which will be instantiated instead of ezcMail, if you need to extend
ezcMail.
Example:
<code>
$options = new ezcMailParserOptions();
$options->mailClass = 'MyMailClass';
$parser = new ezcMailParser( $options );
// if you want to use MyMailClass which extends ezcMail
</code>
@apichange Remove second parameter
@throws ezcBaseFileNotFoundException
if a neccessary temporary file could not be openened.
@param ezcMailParserSet $set
@param string $class Deprecated. Use $mailClass in ezcMailParserOptions class instead.
@return array(ezcMail) | [
"Returns",
"an",
"array",
"of",
"ezcMail",
"objects",
"parsed",
"from",
"the",
"mail",
"set",
"$set",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parser.php#L218-L244 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parser.php | ezcMailParser.getTmpDir | public static function getTmpDir()
{
if ( self::$tmpDir === null )
{
self::$tmpDir = sys_get_temp_dir();
if ( substr( self::$tmpDir, strlen( self::$tmpDir ) - 1 ) !== DIRECTORY_SEPARATOR )
{
self::$tmpDir = self::$tmpDir . DIRECTORY_SEPARATOR;
}
}
return self::$tmpDir;
} | php | public static function getTmpDir()
{
if ( self::$tmpDir === null )
{
self::$tmpDir = sys_get_temp_dir();
if ( substr( self::$tmpDir, strlen( self::$tmpDir ) - 1 ) !== DIRECTORY_SEPARATOR )
{
self::$tmpDir = self::$tmpDir . DIRECTORY_SEPARATOR;
}
}
return self::$tmpDir;
} | [
"public",
"static",
"function",
"getTmpDir",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"tmpDir",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"tmpDir",
"=",
"sys_get_temp_dir",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"self",
"::",
"$",
"tmpDir",
... | Returns the temporary directory.
Uses the PHP 5.2.1 function sys_get_temp_dir().
Note that the directory name returned will have a "slash" at the end
("/" for Linux and "\" for Windows).
@return string | [
"Returns",
"the",
"temporary",
"directory",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parser.php#L270-L281 |
surebert/surebert-framework | src/sb/Password/Random.php | Random.generate | protected function generate()
{
$this->password = '';
$chars = range('a', 'z');
$symbols = Array('*', '&', '^', '%', '$', '#', '@', '!');
$chars = array_merge($chars, $symbols);
//get rid of l and o as they can be confused with 1 and 0
unset($chars[11]);
unset($chars[14]);
$chars = array_values($chars);
$chars_length = count($chars);
foreach (range(1, $this->length) as $char) {
$char = '';
$integer = rand(2, 9).'';
$new_char = $chars[rand(0, $chars_length - 1)];
if (strstr($this->password, $new_char)) {
$char = $new_char;
} elseif (strstr($this->password, $integer)) {
$char = $integer;
} else {
$char = rand(0, 1) ? $new_char : $integer;
}
$this->password .= $char;
}
$this->password = substr_replace($this->password, array_rand($symbols), rand(0, strlen($this->password)), 1);
} | php | protected function generate()
{
$this->password = '';
$chars = range('a', 'z');
$symbols = Array('*', '&', '^', '%', '$', '#', '@', '!');
$chars = array_merge($chars, $symbols);
//get rid of l and o as they can be confused with 1 and 0
unset($chars[11]);
unset($chars[14]);
$chars = array_values($chars);
$chars_length = count($chars);
foreach (range(1, $this->length) as $char) {
$char = '';
$integer = rand(2, 9).'';
$new_char = $chars[rand(0, $chars_length - 1)];
if (strstr($this->password, $new_char)) {
$char = $new_char;
} elseif (strstr($this->password, $integer)) {
$char = $integer;
} else {
$char = rand(0, 1) ? $new_char : $integer;
}
$this->password .= $char;
}
$this->password = substr_replace($this->password, array_rand($symbols), rand(0, strlen($this->password)), 1);
} | [
"protected",
"function",
"generate",
"(",
")",
"{",
"$",
"this",
"->",
"password",
"=",
"''",
";",
"$",
"chars",
"=",
"range",
"(",
"'a'",
",",
"'z'",
")",
";",
"$",
"symbols",
"=",
"Array",
"(",
"'*'",
",",
"'&'",
",",
"'^'",
",",
"'%'",
",",
... | Generates the password randomly | [
"Generates",
"the",
"password",
"randomly"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Random.php#L58-L95 |
surebert/surebert-framework | src/sb/Password/Random.php | Random.randomlyCapitalize | protected function randomlyCapitalize()
{
$chars = str_split($this->password);
$letter_positions = Array();
foreach ($chars as $key => $char) {
if (!is_numeric($char)) {
$letter_positions[] = $key;
}
}
$random_letter = $letter_positions[array_rand($letter_positions)];
$chars[$random_letter] = ucwords($chars[$random_letter]);
$this->password = implode('', $chars);
} | php | protected function randomlyCapitalize()
{
$chars = str_split($this->password);
$letter_positions = Array();
foreach ($chars as $key => $char) {
if (!is_numeric($char)) {
$letter_positions[] = $key;
}
}
$random_letter = $letter_positions[array_rand($letter_positions)];
$chars[$random_letter] = ucwords($chars[$random_letter]);
$this->password = implode('', $chars);
} | [
"protected",
"function",
"randomlyCapitalize",
"(",
")",
"{",
"$",
"chars",
"=",
"str_split",
"(",
"$",
"this",
"->",
"password",
")",
";",
"$",
"letter_positions",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"chars",
"as",
"$",
"key",
"=>",
"$",... | Randomly capitalize one of the letters in the password | [
"Randomly",
"capitalize",
"one",
"of",
"the",
"letters",
"in",
"the",
"password"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Random.php#L100-L116 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/ConstantConverter.php | ConstantConverter.convert | public function convert(\DOMElement $parent, ConstantDescriptor $constant)
{
$fullyQualifiedNamespaceName = $constant->getNamespace() instanceof NamespaceDescriptor
? $constant->getNamespace()->getFullyQualifiedStructuralElementName()
: $parent->getAttribute('namespace');
$child = new \DOMElement('constant');
$parent->appendChild($child);
$child->setAttribute('namespace', ltrim($fullyQualifiedNamespaceName, '\\'));
$child->setAttribute('line', $constant->getLine());
$child->appendChild(new \DOMElement('name', $constant->getName()));
$child->appendChild(new \DOMElement('full_name', $constant->getFullyQualifiedStructuralElementName()));
$child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue()));
$this->docBlockConverter->convert($child, $constant);
return $child;
} | php | public function convert(\DOMElement $parent, ConstantDescriptor $constant)
{
$fullyQualifiedNamespaceName = $constant->getNamespace() instanceof NamespaceDescriptor
? $constant->getNamespace()->getFullyQualifiedStructuralElementName()
: $parent->getAttribute('namespace');
$child = new \DOMElement('constant');
$parent->appendChild($child);
$child->setAttribute('namespace', ltrim($fullyQualifiedNamespaceName, '\\'));
$child->setAttribute('line', $constant->getLine());
$child->appendChild(new \DOMElement('name', $constant->getName()));
$child->appendChild(new \DOMElement('full_name', $constant->getFullyQualifiedStructuralElementName()));
$child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue()));
$this->docBlockConverter->convert($child, $constant);
return $child;
} | [
"public",
"function",
"convert",
"(",
"\\",
"DOMElement",
"$",
"parent",
",",
"ConstantDescriptor",
"$",
"constant",
")",
"{",
"$",
"fullyQualifiedNamespaceName",
"=",
"$",
"constant",
"->",
"getNamespace",
"(",
")",
"instanceof",
"NamespaceDescriptor",
"?",
"$",
... | Export the given reflected constant definition to the provided parent element.
@param \DOMElement $parent Element to augment.
@param ConstantDescriptor $constant Element to export.
@return \DOMElement | [
"Export",
"the",
"given",
"reflected",
"constant",
"definition",
"to",
"the",
"provided",
"parent",
"element",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/ConstantConverter.php#L45-L64 |
Eresus/EresusCMS | src/core/Site.php | Eresus_Site.setTitle | public function setTitle($title)
{
if (!is_string($title))
{
throw Eresus_Exception_InvalidArgumentType::factory(__METHOD__, 1, 'string', $title);
}
$this->title = $title;
} | php | public function setTitle($title)
{
if (!is_string($title))
{
throw Eresus_Exception_InvalidArgumentType::factory(__METHOD__, 1, 'string', $title);
}
$this->title = $title;
} | [
"public",
"function",
"setTitle",
"(",
"$",
"title",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"title",
")",
")",
"{",
"throw",
"Eresus_Exception_InvalidArgumentType",
"::",
"factory",
"(",
"__METHOD__",
",",
"1",
",",
"'string'",
",",
"$",
"title",... | Задаёт заголовок сайта
@param string $title новый заголовок
@throws Eresus_Exception_InvalidArgumentType
@since 3.01 | [
"Задаёт",
"заголовок",
"сайта"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Site.php#L134-L141 |
Eresus/EresusCMS | src/core/Site.php | Eresus_Site.setDescription | public function setDescription($description)
{
if (!is_string($description))
{
throw Eresus_Exception_InvalidArgumentType::factory(__METHOD__, 1, 'string', $description);
}
$this->description = $description;
} | php | public function setDescription($description)
{
if (!is_string($description))
{
throw Eresus_Exception_InvalidArgumentType::factory(__METHOD__, 1, 'string', $description);
}
$this->description = $description;
} | [
"public",
"function",
"setDescription",
"(",
"$",
"description",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"description",
")",
")",
"{",
"throw",
"Eresus_Exception_InvalidArgumentType",
"::",
"factory",
"(",
"__METHOD__",
",",
"1",
",",
"'string'",
",",... | Задаёт описание сайта
@param string $description новое описание
@throws Eresus_Exception_InvalidArgumentType
@since 3.01 | [
"Задаёт",
"описание",
"сайта"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Site.php#L152-L159 |
Eresus/EresusCMS | src/core/Site.php | Eresus_Site.setKeywords | public function setKeywords($keywords)
{
if (!is_string($keywords))
{
throw Eresus_Exception_InvalidArgumentType::factory(__METHOD__, 1, 'string', $keywords);
}
$this->keywords = $keywords;
} | php | public function setKeywords($keywords)
{
if (!is_string($keywords))
{
throw Eresus_Exception_InvalidArgumentType::factory(__METHOD__, 1, 'string', $keywords);
}
$this->keywords = $keywords;
} | [
"public",
"function",
"setKeywords",
"(",
"$",
"keywords",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"keywords",
")",
")",
"{",
"throw",
"Eresus_Exception_InvalidArgumentType",
"::",
"factory",
"(",
"__METHOD__",
",",
"1",
",",
"'string'",
",",
"$",
... | Задаёт список ключевых слов
@param string $keywords новый список ключевых слов
@throws Eresus_Exception_InvalidArgumentType
@since 3.01 | [
"Задаёт",
"список",
"ключевых",
"слов"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Site.php#L171-L178 |
highday/glitter | src/Audit/Listeners/Member/LogSuccessfulLogin.php | LogSuccessfulLogin.handle | public function handle(Login $event)
{
$model = snake_case(class_basename($event->user));
$data = [
'ip' => request()->ip(),
'ua' => request()->header('User-Agent'),
'remember' => $event->remember,
];
$event->user->log("{$model}.login", $data);
} | php | public function handle(Login $event)
{
$model = snake_case(class_basename($event->user));
$data = [
'ip' => request()->ip(),
'ua' => request()->header('User-Agent'),
'remember' => $event->remember,
];
$event->user->log("{$model}.login", $data);
} | [
"public",
"function",
"handle",
"(",
"Login",
"$",
"event",
")",
"{",
"$",
"model",
"=",
"snake_case",
"(",
"class_basename",
"(",
"$",
"event",
"->",
"user",
")",
")",
";",
"$",
"data",
"=",
"[",
"'ip'",
"=>",
"request",
"(",
")",
"->",
"ip",
"(",... | Handle the event.
@param Login $event
@return void | [
"Handle",
"the",
"event",
"."
] | train | https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Audit/Listeners/Member/LogSuccessfulLogin.php#L26-L35 |
raideer/twitch-api | src/Resources/Users.php | Users.getUser | public function getUser($name = null)
{
if (!$name) {
$this->wrapper->checkScope('user_read');
return $this->wrapper->request('GET', 'user', [], true);
}
return $this->wrapper->request('GET', "users/$name");
} | php | public function getUser($name = null)
{
if (!$name) {
$this->wrapper->checkScope('user_read');
return $this->wrapper->request('GET', 'user', [], true);
}
return $this->wrapper->request('GET', "users/$name");
} | [
"public",
"function",
"getUser",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"wrapper",
"->",
"checkScope",
"(",
"'user_read'",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
... | Returns a user object
If $name not set, will return authenticated user_read.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-usersuser
@param string $name Target user
@return array | [
"Returns",
"a",
"user",
"object",
"If",
"$name",
"not",
"set",
"will",
"return",
"authenticated",
"user_read",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Users.php#L33-L42 |
raideer/twitch-api | src/Resources/Users.php | Users.getFollowedVideos | public function getFollowedVideos($params = [])
{
$this->wrapper->checkScope('user_read');
$defaults = [
'limit' => 10,
'offset' => 0,
];
return $this->wrapper->request('GET', 'videos/followed', ['query' => $this->resolveOptions($params, $defaults)], true);
} | php | public function getFollowedVideos($params = [])
{
$this->wrapper->checkScope('user_read');
$defaults = [
'limit' => 10,
'offset' => 0,
];
return $this->wrapper->request('GET', 'videos/followed', ['query' => $this->resolveOptions($params, $defaults)], true);
} | [
"public",
"function",
"getFollowedVideos",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"wrapper",
"->",
"checkScope",
"(",
"'user_read'",
")",
";",
"$",
"defaults",
"=",
"[",
"'limit'",
"=>",
"10",
",",
"'offset'",
"=>",
"0",
",",
... | Returns a list of video objects from channels that the authenticated user is following.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-videosfollowed
@param array $params Optional params
@return array | [
"Returns",
"a",
"list",
"of",
"video",
"objects",
"from",
"channels",
"that",
"the",
"authenticated",
"user",
"is",
"following",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Users.php#L69-L79 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/Tags/SeeAssembler.php | SeeAssembler.create | public function create($data)
{
$descriptor = new SeeDescriptor($data->getName());
$descriptor->setDescription($data->getDescription());
$reference = $data->getReference();
if (substr($reference, 0, 7) !== 'http://'
&& substr($reference, 0, 8) !== 'https://'
&& $reference !== 'self'
&& $reference !== '$this'
) {
// TODO: move this to the ReflectionDocBlock component
// Expand FQCN part of the FQSEN
$referenceParts = explode('::', $reference);
if (count($referenceParts) > 1 && $reference[0] != '\\') {
$type = current($referenceParts);
$type = new Collection(
array($type),
$data->getDocBlock() ? $data->getDocBlock()->getContext() : null
);
$referenceParts[0] = $type;
} elseif (isset($reference[0]) && $reference[0] != '\\') {
array_unshift($referenceParts, Linker::CONTEXT_MARKER);
}
$reference = implode('::', $referenceParts);
}
$descriptor->setReference($reference);
return $descriptor;
} | php | public function create($data)
{
$descriptor = new SeeDescriptor($data->getName());
$descriptor->setDescription($data->getDescription());
$reference = $data->getReference();
if (substr($reference, 0, 7) !== 'http://'
&& substr($reference, 0, 8) !== 'https://'
&& $reference !== 'self'
&& $reference !== '$this'
) {
// TODO: move this to the ReflectionDocBlock component
// Expand FQCN part of the FQSEN
$referenceParts = explode('::', $reference);
if (count($referenceParts) > 1 && $reference[0] != '\\') {
$type = current($referenceParts);
$type = new Collection(
array($type),
$data->getDocBlock() ? $data->getDocBlock()->getContext() : null
);
$referenceParts[0] = $type;
} elseif (isset($reference[0]) && $reference[0] != '\\') {
array_unshift($referenceParts, Linker::CONTEXT_MARKER);
}
$reference = implode('::', $referenceParts);
}
$descriptor->setReference($reference);
return $descriptor;
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"descriptor",
"=",
"new",
"SeeDescriptor",
"(",
"$",
"data",
"->",
"getName",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setDescription",
"(",
"$",
"data",
"->",
"getDescription",
"(",
... | Creates a new Descriptor from the given Reflector.
@param SeeTag $data
@return SeeDescriptor | [
"Creates",
"a",
"new",
"Descriptor",
"from",
"the",
"given",
"Reflector",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/SeeAssembler.php#L35-L67 |
raideer/twitch-api | src/OAuth.php | OAuth.setScope | public function setScope($scope)
{
if (!is_array($scope)) {
$this->scopes = explode(' ', $scope);
} else {
$this->scopes = $scope;
}
return $this;
} | php | public function setScope($scope)
{
if (!is_array($scope)) {
$this->scopes = explode(' ', $scope);
} else {
$this->scopes = $scope;
}
return $this;
} | [
"public",
"function",
"setScope",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"this",
"->",
"scopes",
"=",
"explode",
"(",
"' '",
",",
"$",
"scope",
")",
";",
"}",
"else",
"{",
"$",
"this",
"-... | Sets the scope.
@param string or array $scope Space seperated string or array | [
"Sets",
"the",
"scope",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L91-L100 |
raideer/twitch-api | src/OAuth.php | OAuth.addScope | public function addScope($scope)
{
if (!is_array($scope)) {
$scope = explode(' ', $scope);
}
$this->scopes = array_unique(array_merge($this->scopes, $scope));
return $this;
} | php | public function addScope($scope)
{
if (!is_array($scope)) {
$scope = explode(' ', $scope);
}
$this->scopes = array_unique(array_merge($this->scopes, $scope));
return $this;
} | [
"public",
"function",
"addScope",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"explode",
"(",
"' '",
",",
"$",
"scope",
")",
";",
"}",
"$",
"this",
"->",
"scopes",
"=",
"array_uniq... | Adds a scope.
@param string $scope https://github.com/justintv/Twitch-API/blob/master/authentication.md#scopes | [
"Adds",
"a",
"scope",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L117-L126 |
raideer/twitch-api | src/OAuth.php | OAuth.getResponse | public function getResponse($code, $forceNew = false)
{
if (!$this->oauthResponse || $forceNew) {
$form_params = [
'client_id' => $this->getClientId(),
'client_secret' => $this->clientSecret,
'grant_type' => 'authorization_code',
'redirect_uri' => $this->getRedirectUri(),
'code' => $code,
'state' => $this->getState(),
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->authURL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $form_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
$data = json_decode($result, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new \UnexpectedValueException('Received data is not json');
return;
}
$status = $data['status'];
if (strrpos($status, 20, -strlen($status)) === false) {
throw new Exceptions\BadResponseException('Received bad response ('.$data['status'].'): '.$data['message']);
return;
}
$this->OAuthResponse = new OAuthResponse($data);
}
return $this->OAuthResponse;
} | php | public function getResponse($code, $forceNew = false)
{
if (!$this->oauthResponse || $forceNew) {
$form_params = [
'client_id' => $this->getClientId(),
'client_secret' => $this->clientSecret,
'grant_type' => 'authorization_code',
'redirect_uri' => $this->getRedirectUri(),
'code' => $code,
'state' => $this->getState(),
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->authURL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $form_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
$data = json_decode($result, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new \UnexpectedValueException('Received data is not json');
return;
}
$status = $data['status'];
if (strrpos($status, 20, -strlen($status)) === false) {
throw new Exceptions\BadResponseException('Received bad response ('.$data['status'].'): '.$data['message']);
return;
}
$this->OAuthResponse = new OAuthResponse($data);
}
return $this->OAuthResponse;
} | [
"public",
"function",
"getResponse",
"(",
"$",
"code",
",",
"$",
"forceNew",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"oauthResponse",
"||",
"$",
"forceNew",
")",
"{",
"$",
"form_params",
"=",
"[",
"'client_id'",
"=>",
"$",
"this",
... | Returns the OAuthResponse object that contains the access_token, registered scopes
and the refresh_token.
@param string $code Code returned by OAuth
@param bool $forceNew Force new token
@return Raideer\TwitchApi\OAuthResponse | [
"Returns",
"the",
"OAuthResponse",
"object",
"that",
"contains",
"the",
"access_token",
"registered",
"scopes",
"and",
"the",
"refresh_token",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L159-L199 |
raideer/twitch-api | src/OAuth.php | OAuth.checkScope | public function checkScope($scope)
{
if ($this->OAuthResponse) {
return $this->OAuthResponse->hasScope($scope);
}
return in_array($scope, $this->getScope());
} | php | public function checkScope($scope)
{
if ($this->OAuthResponse) {
return $this->OAuthResponse->hasScope($scope);
}
return in_array($scope, $this->getScope());
} | [
"public",
"function",
"checkScope",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"OAuthResponse",
")",
"{",
"return",
"$",
"this",
"->",
"OAuthResponse",
"->",
"hasScope",
"(",
"$",
"scope",
")",
";",
"}",
"return",
"in_array",
"(",
"$",
... | Checks if the scope is registered.
@param string $scope Scope name
@return bool | [
"Checks",
"if",
"the",
"scope",
"is",
"registered",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L208-L215 |
raideer/twitch-api | src/OAuth.php | OAuth.getUrl | public function getUrl()
{
$url = $this->baseAuthUrl;
$url .= '?response_type=code';
$url .= '&client_id='.$this->clientId;
$url .= '&redirect_uri='.$this->redirectUri;
$url .= '&scope='.implode(' ', $this->scopes);
$url .= '&state='.$this->state;
return $url;
} | php | public function getUrl()
{
$url = $this->baseAuthUrl;
$url .= '?response_type=code';
$url .= '&client_id='.$this->clientId;
$url .= '&redirect_uri='.$this->redirectUri;
$url .= '&scope='.implode(' ', $this->scopes);
$url .= '&state='.$this->state;
return $url;
} | [
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"baseAuthUrl",
";",
"$",
"url",
".=",
"'?response_type=code'",
";",
"$",
"url",
".=",
"'&client_id='",
".",
"$",
"this",
"->",
"clientId",
";",
"$",
"url",
".=",
"'&redi... | Builds the OAuth URL.
@return string URL | [
"Builds",
"the",
"OAuth",
"URL",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L222-L232 |
kenphp/ken | src/Helpers/Route.php | Route.route | public static function route($route, $handler, $method = 'GET', $options = [])
{
app()->router->route($method, $route, $handler, $options);
} | php | public static function route($route, $handler, $method = 'GET', $options = [])
{
app()->router->route($method, $route, $handler, $options);
} | [
"public",
"static",
"function",
"route",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->",
"route",
"(",
"$",
"method",
",",
"$",
"route"... | Adds route to $routeCollection.
@param string $route
@param callable $handler Target callable that will be called when the route is requested
@param string $method HTTP Method
@param array $options | [
"Adds",
"route",
"to",
"$routeCollection",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L18-L21 |
kenphp/ken | src/Helpers/Route.php | Route.get | public static function get($route, $handler, $options = [])
{
app()->router->get($route, $handler, $options);
} | php | public static function get($route, $handler, $options = [])
{
app()->router->get($route, $handler, $options);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->",
"get",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
")",
";",
"}... | Adds GET route to $routeCollection.
@param string $route
@param callable $handler Target callable that will be called when the route is requested
@param array $options | [
"Adds",
"GET",
"route",
"to",
"$routeCollection",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L30-L33 |
kenphp/ken | src/Helpers/Route.php | Route.post | public static function post($route, $handler, $options = [])
{
app()->router->post($route, $handler, $options);
} | php | public static function post($route, $handler, $options = [])
{
app()->router->post($route, $handler, $options);
} | [
"public",
"static",
"function",
"post",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->",
"post",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
")",
";",
... | Adds POST route to $routeCollection.
@param string $route
@param callable $handler Target callable that will be called when the route is requested
@param array $options | [
"Adds",
"POST",
"route",
"to",
"$routeCollection",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L42-L45 |
kenphp/ken | src/Helpers/Route.php | Route.put | public static function put($route, $handler, $options = [])
{
app()->router->put($route, $handler, $options);
} | php | public static function put($route, $handler, $options = [])
{
app()->router->put($route, $handler, $options);
} | [
"public",
"static",
"function",
"put",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->",
"put",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
")",
";",
"}... | Adds PUT route to $routeCollection.
@param string $route
@param callable $handler Target callable that will be called when the route is requested
@param array $options | [
"Adds",
"PUT",
"route",
"to",
"$routeCollection",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L54-L57 |
kenphp/ken | src/Helpers/Route.php | Route.delete | public static function delete($route, $handler, $options = [])
{
app()->router->delete($route, $handler, $options);
} | php | public static function delete($route, $handler, $options = [])
{
app()->router->delete($route, $handler, $options);
} | [
"public",
"static",
"function",
"delete",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->",
"delete",
"(",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
")",
";"... | Adds DELETE route to $routeCollection.
@param string $route
@param callable $handler Target callable that will be called when the route is requested
@param array $options | [
"Adds",
"DELETE",
"route",
"to",
"$routeCollection",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L66-L69 |
kenphp/ken | src/Helpers/Route.php | Route.map | public static function map($methods, $route, $handler, $options = [])
{
foreach ($methods as $method) {
app()->router->route($method, $route, $handler, $options);
}
} | php | public static function map($methods, $route, $handler, $options = [])
{
foreach ($methods as $method) {
app()->router->route($method, $route, $handler, $options);
}
} | [
"public",
"static",
"function",
"map",
"(",
"$",
"methods",
",",
"$",
"route",
",",
"$",
"handler",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->"... | Adds route with several HTTP methods bind to $routeCollection.
@param array $methods HTTP Methods that apply to the routes
@param string $route
@param callable $handler Target callable that will be called when the route is requested
@param array $options | [
"Adds",
"route",
"with",
"several",
"HTTP",
"methods",
"bind",
"to",
"$routeCollection",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L79-L84 |
kenphp/ken | src/Helpers/Route.php | Route.group | public static function group($route, $callback, $options = [])
{
app()->router->group($route, $callback, $options);
} | php | public static function group($route, $callback, $options = [])
{
app()->router->group($route, $callback, $options);
} | [
"public",
"static",
"function",
"group",
"(",
"$",
"route",
",",
"$",
"callback",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"app",
"(",
")",
"->",
"router",
"->",
"group",
"(",
"$",
"route",
",",
"$",
"callback",
",",
"$",
"options",
")",
";"... | Adds group route.
@param string $route Group base route
@param callable $callback
@param array $options | [
"Adds",
"group",
"route",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L93-L96 |
blast-project/BaseEntitiesBundle | src/Form/Type/SearchIndexAutocompleteType.php | SearchIndexAutocompleteType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$admin = $options['sonata_field_description']->getAssociationAdmin();
$builder->setAttribute('callback', $options['callback']);
$builder->setAttribute('minimum_input_length', $options['minimum_input_length']);
$builder->setAttribute('items_per_page', $options['items_per_page']);
$builder->setAttribute('req_param_name_page_number', $options['req_param_name_page_number']);
$builder->setAttribute('disabled', $options['disabled']);
$builder->setAttribute('to_string_callback', $options['to_string_callback']);
$builder->setAttribute('target_admin_access_action', $options['target_admin_access_action']);
$builder->addViewTransformer(
new ModelToIdTransformer(
$admin->getModelManager(),
$admin->getClass(),
$options['multiple']
),
true
);
if ($options['multiple']) {
$resizeListener = new ResizeFormListener(
'hidden', array(), true, true, true
);
$builder->addEventSubscriber($resizeListener);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$admin = $options['sonata_field_description']->getAssociationAdmin();
$builder->setAttribute('callback', $options['callback']);
$builder->setAttribute('minimum_input_length', $options['minimum_input_length']);
$builder->setAttribute('items_per_page', $options['items_per_page']);
$builder->setAttribute('req_param_name_page_number', $options['req_param_name_page_number']);
$builder->setAttribute('disabled', $options['disabled']);
$builder->setAttribute('to_string_callback', $options['to_string_callback']);
$builder->setAttribute('target_admin_access_action', $options['target_admin_access_action']);
$builder->addViewTransformer(
new ModelToIdTransformer(
$admin->getModelManager(),
$admin->getClass(),
$options['multiple']
),
true
);
if ($options['multiple']) {
$resizeListener = new ResizeFormListener(
'hidden', array(), true, true, true
);
$builder->addEventSubscriber($resizeListener);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"admin",
"=",
"$",
"options",
"[",
"'sonata_field_description'",
"]",
"->",
"getAssociationAdmin",
"(",
")",
";",
"$",
"builder",
"->",... | {@inheritdoc} | [
"{"
] | train | https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Form/Type/SearchIndexAutocompleteType.php#L32-L60 |
blast-project/BaseEntitiesBundle | src/Form/Type/SearchIndexAutocompleteType.php | SearchIndexAutocompleteType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$compound = function (Options $options) {
return $options['multiple'];
};
$callback = function ($admin, $property, $value) {
$searchIndex = $admin->getClass() . 'SearchIndex';
$datagrid = $admin->getDatagrid();
$queryBuilder = $datagrid->getQuery();
$alias = $queryBuilder->getRootalias();
$queryBuilder
->leftJoin($searchIndex, 's', 'WITH', $alias . '.id = s.object')
->where('s.keyword LIKE :value')
->setParameter('value', "%$value%")
;
// $datagrid->setValue($property, null, $value);
};
$resolver->setDefaults(array(
'attr' => array(),
'compound' => $compound,
'model_manager' => null,
'class' => null,
'admin_code' => null,
'callback' => $callback,
'multiple' => false,
'width' => '',
'context' => '',
'property' => '',
'placeholder' => '',
'minimum_input_length' => 3,
'items_per_page' => 10,
'quiet_millis' => 100,
'cache' => false,
'target_admin_access_action' => 'list',
'to_string_callback' => null,
// ajax parameters
'url' => '',
'route' => array('name' => 'sonata_admin_retrieve_autocomplete_items', 'parameters' => array()),
'req_params' => array(),
'req_param_name_search' => 'q',
'req_param_name_page_number' => '_page',
'req_param_name_items_per_page' => '_per_page',
// CSS classes
'container_css_class' => '',
'dropdown_css_class' => '',
'dropdown_item_css_class' => '',
'dropdown_auto_width' => false,
'template' => 'SonataAdminBundle:Form/Type:sonata_type_model_autocomplete.html.twig',
));
} | php | public function configureOptions(OptionsResolver $resolver)
{
$compound = function (Options $options) {
return $options['multiple'];
};
$callback = function ($admin, $property, $value) {
$searchIndex = $admin->getClass() . 'SearchIndex';
$datagrid = $admin->getDatagrid();
$queryBuilder = $datagrid->getQuery();
$alias = $queryBuilder->getRootalias();
$queryBuilder
->leftJoin($searchIndex, 's', 'WITH', $alias . '.id = s.object')
->where('s.keyword LIKE :value')
->setParameter('value', "%$value%")
;
// $datagrid->setValue($property, null, $value);
};
$resolver->setDefaults(array(
'attr' => array(),
'compound' => $compound,
'model_manager' => null,
'class' => null,
'admin_code' => null,
'callback' => $callback,
'multiple' => false,
'width' => '',
'context' => '',
'property' => '',
'placeholder' => '',
'minimum_input_length' => 3,
'items_per_page' => 10,
'quiet_millis' => 100,
'cache' => false,
'target_admin_access_action' => 'list',
'to_string_callback' => null,
// ajax parameters
'url' => '',
'route' => array('name' => 'sonata_admin_retrieve_autocomplete_items', 'parameters' => array()),
'req_params' => array(),
'req_param_name_search' => 'q',
'req_param_name_page_number' => '_page',
'req_param_name_items_per_page' => '_per_page',
// CSS classes
'container_css_class' => '',
'dropdown_css_class' => '',
'dropdown_item_css_class' => '',
'dropdown_auto_width' => false,
'template' => 'SonataAdminBundle:Form/Type:sonata_type_model_autocomplete.html.twig',
));
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"compound",
"=",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"return",
"$",
"options",
"[",
"'multiple'",
"]",
";",
"}",
";",
"$",
"callback",
"=",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Form/Type/SearchIndexAutocompleteType.php#L65-L122 |
cirrusidentity/simplesamlphp-test-utils | src/InMemoryStore.php | InMemoryStore.get | public function get($type, $key)
{
if (array_key_exists($key, self::$store)) {
//TODO: implement expiration check
// implement data type check?
return self::$store[$key]['value'];
}
return null;
} | php | public function get($type, $key)
{
if (array_key_exists($key, self::$store)) {
//TODO: implement expiration check
// implement data type check?
return self::$store[$key]['value'];
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"type",
",",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"store",
")",
")",
"{",
"//TODO: implement expiration check",
"// implement data type check?",
"return",
"self",
... | Retrieve a value from the data store.
@param string $type The data type.
@param string $key The key.
@return mixed|null The value. | [
"Retrieve",
"a",
"value",
"from",
"the",
"data",
"store",
"."
] | train | https://github.com/cirrusidentity/simplesamlphp-test-utils/blob/79150efb8bca89c180b604dc1d6194f819ebe2b2/src/InMemoryStore.php#L32-L40 |
cirrusidentity/simplesamlphp-test-utils | src/InMemoryStore.php | InMemoryStore.set | public function set($type, $key, $value, $expire = null)
{
self::$store[$key] = [
'type' => $type,
'value' => $value,
'expire' => $expire
];
} | php | public function set($type, $key, $value, $expire = null)
{
self::$store[$key] = [
'type' => $type,
'value' => $value,
'expire' => $expire
];
} | [
"public",
"function",
"set",
"(",
"$",
"type",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expire",
"=",
"null",
")",
"{",
"self",
"::",
"$",
"store",
"[",
"$",
"key",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"type",
",",
"'value'",
"=>",
"$",
... | Save a value to the data store.
@param string $type The data type.
@param string $key The key.
@param mixed $value The value.
@param int|null $expire The expiration time (unix timestamp), or null if it never expires. | [
"Save",
"a",
"value",
"to",
"the",
"data",
"store",
"."
] | train | https://github.com/cirrusidentity/simplesamlphp-test-utils/blob/79150efb8bca89c180b604dc1d6194f819ebe2b2/src/InMemoryStore.php#L50-L57 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.