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
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.removeTransport | public function removeTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
{
return $this->transports->removeElement($transport);
} | php | public function removeTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
{
return $this->transports->removeElement($transport);
} | [
"public",
"function",
"removeTransport",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Transport",
"\\",
"Transport",
"$",
"transport",
")",
"{",
"return",
"$",
"this",
"->",
"transports",
"->",
"removeElement",
"(",
"$",
"transport",
")",
";",
"}"
] | Remove transport.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport
@return bool TRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"transport",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L759-L762 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.addInvoice | public function addInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
{
$this->invoices[] = $invoice;
return $this;
} | php | public function addInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
{
$this->invoices[] = $invoice;
return $this;
} | [
"public",
"function",
"addInvoice",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Invoice",
"\\",
"Invoice",
"$",
"invoice",
")",
"{",
"$",
"this",
"->",
"invoices",
"[",
"]",
"=",
"$",
"invoice",
";",
"return",
"$",
"this",
";",
"}"
] | Add invoice.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice
@return Shipping | [
"Add",
"invoice",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L781-L786 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.removeInvoice | public function removeInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
{
return $this->invoices->removeElement($invoice);
} | php | public function removeInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
{
return $this->invoices->removeElement($invoice);
} | [
"public",
"function",
"removeInvoice",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Invoice",
"\\",
"Invoice",
"$",
"invoice",
")",
"{",
"return",
"$",
"this",
"->",
"invoices",
"->",
"removeElement",
"(",
"$",
"invoice",
")",
";",
"}"
] | Remove invoice.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice
@return bool TRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"invoice",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L795-L798 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.addComment | public function addComment(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Comment\Comment $comment)
{
$this->comments[] = $comment;
return $this;
} | php | public function addComment(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Comment\Comment $comment)
{
$this->comments[] = $comment;
return $this;
} | [
"public",
"function",
"addComment",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Comment",
"\\",
"Comment",
"$",
"comment",
")",
"{",
"$",
"this",
"->",
"comments",
"[",
"]",
"=",
"$",
"comment",
";",
"return",
"$",
"this",
";",
"}"
] | Add comment.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Comment\Comment $comment
@return Shipping | [
"Add",
"comment",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L817-L822 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.removeComment | public function removeComment(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Comment\Comment $comment)
{
return $this->comments->removeElement($comment);
} | php | public function removeComment(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Comment\Comment $comment)
{
return $this->comments->removeElement($comment);
} | [
"public",
"function",
"removeComment",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Comment",
"\\",
"Comment",
"$",
"comment",
")",
"{",
"return",
"$",
"this",
"->",
"comments",
"->",
"removeElement",
"(",
"$",
"comment",
")",
";",
"}"
] | Remove comment.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Comment\Comment $comment
@return bool TRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"comment",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L831-L834 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.addFeedback | public function addFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Feedback\Feedback $feedback)
{
$this->feedbacks[] = $feedback;
return $this;
} | php | public function addFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Feedback\Feedback $feedback)
{
$this->feedbacks[] = $feedback;
return $this;
} | [
"public",
"function",
"addFeedback",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Feedback",
"\\",
"Feedback",
"$",
"feedback",
")",
"{",
"$",
"this",
"->",
"feedbacks",
"[",
"]",
"=",
"$",
"feedback",
";",
"return",
"$",
"this",
";",
"}"
] | Add feedback.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Feedback\Feedback $feedback
@return Shipping | [
"Add",
"feedback",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L853-L858 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.addPayment | public function addPayment(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Payment\Payment $payment)
{
$this->payments[] = $payment;
return $this;
} | php | public function addPayment(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Payment\Payment $payment)
{
$this->payments[] = $payment;
return $this;
} | [
"public",
"function",
"addPayment",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Payment",
"\\",
"Payment",
"$",
"payment",
")",
"{",
"$",
"this",
"->",
"payments",
"[",
"]",
"=",
"$",
"payment",
";",
"return",
"$",
"this",
";",
"}"
] | Add payment.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Payment\Payment $payment
@return Shipping | [
"Add",
"payment",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L889-L894 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.addConciliation | public function addConciliation(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Conciliation\Conciliation $conciliation)
{
$this->conciliations[] = $conciliation;
return $this;
} | php | public function addConciliation(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Conciliation\Conciliation $conciliation)
{
$this->conciliations[] = $conciliation;
return $this;
} | [
"public",
"function",
"addConciliation",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Conciliation",
"\\",
"Conciliation",
"$",
"conciliation",
")",
"{",
"$",
"this",
"->",
"conciliations",
"[",
"]",
"=",
"$",
"conciliation",
";",
"return",
"$",
"this",
";",
"}"
] | Add conciliation.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Conciliation\Conciliation $conciliation
@return Shipping | [
"Add",
"conciliation",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L925-L930 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Shipping/Shipping.php | Shipping.removeConciliation | public function removeConciliation(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Conciliation\Conciliation $conciliation)
{
return $this->conciliations->removeElement($conciliation);
} | php | public function removeConciliation(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Conciliation\Conciliation $conciliation)
{
return $this->conciliations->removeElement($conciliation);
} | [
"public",
"function",
"removeConciliation",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Conciliation",
"\\",
"Conciliation",
"$",
"conciliation",
")",
"{",
"return",
"$",
"this",
"->",
"conciliations",
"->",
"removeElement",
"(",
"$",
"conciliation",
")",
";",
"}"
] | Remove conciliation.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Conciliation\Conciliation $conciliation
@return bool TRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"conciliation",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L939-L942 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.configure | public function configure(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->jsonFile = null;
$this->io = $io;
$publicDirectorySet = $this->isPublicDirectorySet();
$wordPressInstallDirectorySet = $this->isWordPressInstallDirectorySet();
$reposConfigured = $this->areReposConfigured();
$sortingConfigured = $this->isSortingConfigured();
if ($publicDirectorySet && $wordPressInstallDirectorySet && $reposConfigured && $sortingConfigured) {
return;
}
if (! $publicDirectorySet) {
$this->setPublicDirectory();
}
if (! $wordPressInstallDirectorySet) {
$this->setWordPressInstallDirectory();
}
if (! $reposConfigured) {
$this->configureRepos();
}
if (! $sortingConfigured) {
$this->configureSorting();
}
$this->sortProperties();
$this->saveJson();
} | php | public function configure(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->jsonFile = null;
$this->io = $io;
$publicDirectorySet = $this->isPublicDirectorySet();
$wordPressInstallDirectorySet = $this->isWordPressInstallDirectorySet();
$reposConfigured = $this->areReposConfigured();
$sortingConfigured = $this->isSortingConfigured();
if ($publicDirectorySet && $wordPressInstallDirectorySet && $reposConfigured && $sortingConfigured) {
return;
}
if (! $publicDirectorySet) {
$this->setPublicDirectory();
}
if (! $wordPressInstallDirectorySet) {
$this->setWordPressInstallDirectory();
}
if (! $reposConfigured) {
$this->configureRepos();
}
if (! $sortingConfigured) {
$this->configureSorting();
}
$this->sortProperties();
$this->saveJson();
} | [
"public",
"function",
"configure",
"(",
"Composer",
"$",
"composer",
",",
"IOInterface",
"$",
"io",
")",
"{",
"$",
"this",
"->",
"composer",
"=",
"$",
"composer",
";",
"$",
"this",
"->",
"jsonFile",
"=",
"null",
";",
"$",
"this",
"->",
"io",
"=",
"$",
"io",
";",
"$",
"publicDirectorySet",
"=",
"$",
"this",
"->",
"isPublicDirectorySet",
"(",
")",
";",
"$",
"wordPressInstallDirectorySet",
"=",
"$",
"this",
"->",
"isWordPressInstallDirectorySet",
"(",
")",
";",
"$",
"reposConfigured",
"=",
"$",
"this",
"->",
"areReposConfigured",
"(",
")",
";",
"$",
"sortingConfigured",
"=",
"$",
"this",
"->",
"isSortingConfigured",
"(",
")",
";",
"if",
"(",
"$",
"publicDirectorySet",
"&&",
"$",
"wordPressInstallDirectorySet",
"&&",
"$",
"reposConfigured",
"&&",
"$",
"sortingConfigured",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"publicDirectorySet",
")",
"{",
"$",
"this",
"->",
"setPublicDirectory",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"wordPressInstallDirectorySet",
")",
"{",
"$",
"this",
"->",
"setWordPressInstallDirectory",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"reposConfigured",
")",
"{",
"$",
"this",
"->",
"configureRepos",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"sortingConfigured",
")",
"{",
"$",
"this",
"->",
"configureSorting",
"(",
")",
";",
"}",
"$",
"this",
"->",
"sortProperties",
"(",
")",
";",
"$",
"this",
"->",
"saveJson",
"(",
")",
";",
"}"
] | Configure the composer.json file.
@return void | [
"Configure",
"the",
"composer",
".",
"json",
"file",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L113-L146 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.setPublicDirectory | protected function setPublicDirectory()
{
if (! $this->json) {
$this->readJson();
}
$this->json['extra']['public-dir'] = $this->plugin->getPublicDirectory();
} | php | protected function setPublicDirectory()
{
if (! $this->json) {
$this->readJson();
}
$this->json['extra']['public-dir'] = $this->plugin->getPublicDirectory();
} | [
"protected",
"function",
"setPublicDirectory",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"json",
")",
"{",
"$",
"this",
"->",
"readJson",
"(",
")",
";",
"}",
"$",
"this",
"->",
"json",
"[",
"'extra'",
"]",
"[",
"'public-dir'",
"]",
"=",
"$",
"this",
"->",
"plugin",
"->",
"getPublicDirectory",
"(",
")",
";",
"}"
] | Set the public directory in the composer.json.
@return void | [
"Set",
"the",
"public",
"directory",
"in",
"the",
"composer",
".",
"json",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L167-L174 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.setWordPressInstallDirectory | protected function setWordPressInstallDirectory()
{
if (! $this->json) {
$this->readJson();
}
$this->json['extra']['wordpress-install-dir'] = $this->plugin->getPublicDirectory() . '/wp';
} | php | protected function setWordPressInstallDirectory()
{
if (! $this->json) {
$this->readJson();
}
$this->json['extra']['wordpress-install-dir'] = $this->plugin->getPublicDirectory() . '/wp';
} | [
"protected",
"function",
"setWordPressInstallDirectory",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"json",
")",
"{",
"$",
"this",
"->",
"readJson",
"(",
")",
";",
"}",
"$",
"this",
"->",
"json",
"[",
"'extra'",
"]",
"[",
"'wordpress-install-dir'",
"]",
"=",
"$",
"this",
"->",
"plugin",
"->",
"getPublicDirectory",
"(",
")",
".",
"'/wp'",
";",
"}"
] | Set the WordPress installation directory in the composer.json.
@return void | [
"Set",
"the",
"WordPress",
"installation",
"directory",
"in",
"the",
"composer",
".",
"json",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L209-L216 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.areReposConfigured | protected function areReposConfigured()
{
if (! $this->json) {
$this->readJson();
}
return ! empty($this->json['repositories']) && $this->pregGrepRecursive('/^http(s|\?)?:\/\/wpackagist\.org\/?$/', $this->json['repositories']);
} | php | protected function areReposConfigured()
{
if (! $this->json) {
$this->readJson();
}
return ! empty($this->json['repositories']) && $this->pregGrepRecursive('/^http(s|\?)?:\/\/wpackagist\.org\/?$/', $this->json['repositories']);
} | [
"protected",
"function",
"areReposConfigured",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"json",
")",
"{",
"$",
"this",
"->",
"readJson",
"(",
")",
";",
"}",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"json",
"[",
"'repositories'",
"]",
")",
"&&",
"$",
"this",
"->",
"pregGrepRecursive",
"(",
"'/^http(s|\\?)?:\\/\\/wpackagist\\.org\\/?$/'",
",",
"$",
"this",
"->",
"json",
"[",
"'repositories'",
"]",
")",
";",
"}"
] | Check if the additional repositories for using WordPress with composer are set.
@return bool | [
"Check",
"if",
"the",
"additional",
"repositories",
"for",
"using",
"WordPress",
"with",
"composer",
"are",
"set",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L223-L230 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.configureRepos | protected function configureRepos()
{
if (! $this->json) {
$this->readJson();
}
$public = $this->plugin->getPublicDirectory();
$plugins_path = $public . '/plugins/{$name}/';
$themes_path = $public . '/themes/{$name}/';
$this->json['repositories'][] = [
'type' => 'composer',
'url' => 'https://wpackagist.org',
];
$extra = $this->json['extra'];
if (isset($extra['installer-paths'])) {
foreach ($extra['installer-paths'] as $path => &$names) {
if ($path != $plugins_path && ($key = array_search('type:wordpress-plugin', $names)) !== false ||
$path != $themes_path && ($key = array_search('type:wordpress-theme', $names)) !== false
) {
unset($names[$key]);
if (! count($names)) {
unset($extra['installer-paths'][$path]);
}
}
}
}
$extra['installer-paths'][$plugins_path][] = 'type:wordpress-plugin';
$extra['installer-paths'][$themes_path][] = 'type:wordpress-theme';
$this->json['extra'] = $extra;
} | php | protected function configureRepos()
{
if (! $this->json) {
$this->readJson();
}
$public = $this->plugin->getPublicDirectory();
$plugins_path = $public . '/plugins/{$name}/';
$themes_path = $public . '/themes/{$name}/';
$this->json['repositories'][] = [
'type' => 'composer',
'url' => 'https://wpackagist.org',
];
$extra = $this->json['extra'];
if (isset($extra['installer-paths'])) {
foreach ($extra['installer-paths'] as $path => &$names) {
if ($path != $plugins_path && ($key = array_search('type:wordpress-plugin', $names)) !== false ||
$path != $themes_path && ($key = array_search('type:wordpress-theme', $names)) !== false
) {
unset($names[$key]);
if (! count($names)) {
unset($extra['installer-paths'][$path]);
}
}
}
}
$extra['installer-paths'][$plugins_path][] = 'type:wordpress-plugin';
$extra['installer-paths'][$themes_path][] = 'type:wordpress-theme';
$this->json['extra'] = $extra;
} | [
"protected",
"function",
"configureRepos",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"json",
")",
"{",
"$",
"this",
"->",
"readJson",
"(",
")",
";",
"}",
"$",
"public",
"=",
"$",
"this",
"->",
"plugin",
"->",
"getPublicDirectory",
"(",
")",
";",
"$",
"plugins_path",
"=",
"$",
"public",
".",
"'/plugins/{$name}/'",
";",
"$",
"themes_path",
"=",
"$",
"public",
".",
"'/themes/{$name}/'",
";",
"$",
"this",
"->",
"json",
"[",
"'repositories'",
"]",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"'composer'",
",",
"'url'",
"=>",
"'https://wpackagist.org'",
",",
"]",
";",
"$",
"extra",
"=",
"$",
"this",
"->",
"json",
"[",
"'extra'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"extra",
"[",
"'installer-paths'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"extra",
"[",
"'installer-paths'",
"]",
"as",
"$",
"path",
"=>",
"&",
"$",
"names",
")",
"{",
"if",
"(",
"$",
"path",
"!=",
"$",
"plugins_path",
"&&",
"(",
"$",
"key",
"=",
"array_search",
"(",
"'type:wordpress-plugin'",
",",
"$",
"names",
")",
")",
"!==",
"false",
"||",
"$",
"path",
"!=",
"$",
"themes_path",
"&&",
"(",
"$",
"key",
"=",
"array_search",
"(",
"'type:wordpress-theme'",
",",
"$",
"names",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"names",
"[",
"$",
"key",
"]",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"names",
")",
")",
"{",
"unset",
"(",
"$",
"extra",
"[",
"'installer-paths'",
"]",
"[",
"$",
"path",
"]",
")",
";",
"}",
"}",
"}",
"}",
"$",
"extra",
"[",
"'installer-paths'",
"]",
"[",
"$",
"plugins_path",
"]",
"[",
"]",
"=",
"'type:wordpress-plugin'",
";",
"$",
"extra",
"[",
"'installer-paths'",
"]",
"[",
"$",
"themes_path",
"]",
"[",
"]",
"=",
"'type:wordpress-theme'",
";",
"$",
"this",
"->",
"json",
"[",
"'extra'",
"]",
"=",
"$",
"extra",
";",
"}"
] | Configure additional repositories for using WordPress with composer,
and set the installation directories for WordPress packages.
@return void | [
"Configure",
"additional",
"repositories",
"for",
"using",
"WordPress",
"with",
"composer",
"and",
"set",
"the",
"installation",
"directories",
"for",
"WordPress",
"packages",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L238-L273 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.isSortingConfigured | protected function isSortingConfigured()
{
if (! $this->json) {
$this->readJson();
}
return ! empty($this->json['config']) && ! empty($this->json['config']['sort-packages']);
} | php | protected function isSortingConfigured()
{
if (! $this->json) {
$this->readJson();
}
return ! empty($this->json['config']) && ! empty($this->json['config']['sort-packages']);
} | [
"protected",
"function",
"isSortingConfigured",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"json",
")",
"{",
"$",
"this",
"->",
"readJson",
"(",
")",
";",
"}",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"json",
"[",
"'config'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"json",
"[",
"'config'",
"]",
"[",
"'sort-packages'",
"]",
")",
";",
"}"
] | Check if autmatic sorting of linked packages is enabled.
@return bool | [
"Check",
"if",
"autmatic",
"sorting",
"of",
"linked",
"packages",
"is",
"enabled",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L280-L287 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.sortProperties | protected function sortProperties()
{
if (! $this->json) {
$this->readJson();
}
$this->json = $this->sortByArray($this->json, $this->composerOrder);
if (isset($this->json['autoload'])) {
$this->json['autoload'] = $this->sortByArray($this->json['autoload'], $this->autoloadOrder);
}
if (isset($this->json['autoload-dev'])) {
$this->json['autoload-dev'] = $this->sortByArray($this->json['autoload-dev'], $this->autoloadOrder);
}
foreach (['support', 'require', 'require-dev', 'conflict', 'replace', 'provide', 'suggest'] as $property) {
if (isset($this->json[$property])) {
ksort($this->json[$property]);
}
}
} | php | protected function sortProperties()
{
if (! $this->json) {
$this->readJson();
}
$this->json = $this->sortByArray($this->json, $this->composerOrder);
if (isset($this->json['autoload'])) {
$this->json['autoload'] = $this->sortByArray($this->json['autoload'], $this->autoloadOrder);
}
if (isset($this->json['autoload-dev'])) {
$this->json['autoload-dev'] = $this->sortByArray($this->json['autoload-dev'], $this->autoloadOrder);
}
foreach (['support', 'require', 'require-dev', 'conflict', 'replace', 'provide', 'suggest'] as $property) {
if (isset($this->json[$property])) {
ksort($this->json[$property]);
}
}
} | [
"protected",
"function",
"sortProperties",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"json",
")",
"{",
"$",
"this",
"->",
"readJson",
"(",
")",
";",
"}",
"$",
"this",
"->",
"json",
"=",
"$",
"this",
"->",
"sortByArray",
"(",
"$",
"this",
"->",
"json",
",",
"$",
"this",
"->",
"composerOrder",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"json",
"[",
"'autoload'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"json",
"[",
"'autoload'",
"]",
"=",
"$",
"this",
"->",
"sortByArray",
"(",
"$",
"this",
"->",
"json",
"[",
"'autoload'",
"]",
",",
"$",
"this",
"->",
"autoloadOrder",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"json",
"[",
"'autoload-dev'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"json",
"[",
"'autoload-dev'",
"]",
"=",
"$",
"this",
"->",
"sortByArray",
"(",
"$",
"this",
"->",
"json",
"[",
"'autoload-dev'",
"]",
",",
"$",
"this",
"->",
"autoloadOrder",
")",
";",
"}",
"foreach",
"(",
"[",
"'support'",
",",
"'require'",
",",
"'require-dev'",
",",
"'conflict'",
",",
"'replace'",
",",
"'provide'",
",",
"'suggest'",
"]",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"json",
"[",
"$",
"property",
"]",
")",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"json",
"[",
"$",
"property",
"]",
")",
";",
"}",
"}",
"}"
] | Sort the composer.json properties.
@return void | [
"Sort",
"the",
"composer",
".",
"json",
"properties",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L308-L329 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.getJsonFile | protected function getJsonFile()
{
if (! $this->jsonFile) {
$this->jsonFile = new JsonFile('composer.json', null, $this->io);
}
return $this->jsonFile;
} | php | protected function getJsonFile()
{
if (! $this->jsonFile) {
$this->jsonFile = new JsonFile('composer.json', null, $this->io);
}
return $this->jsonFile;
} | [
"protected",
"function",
"getJsonFile",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jsonFile",
")",
"{",
"$",
"this",
"->",
"jsonFile",
"=",
"new",
"JsonFile",
"(",
"'composer.json'",
",",
"null",
",",
"$",
"this",
"->",
"io",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jsonFile",
";",
"}"
] | Get the JsonFile.
@return \Composer\Json\JsonFile | [
"Get",
"the",
"JsonFile",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L336-L343 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.pregGrepRecursive | protected function pregGrepRecursive($pattern, $haystack)
{
$matches = [];
foreach ($haystack as $key => $item) {
if (is_array($item)) {
$sub_matches = $this->pregGrepRecursive($pattern, $item);
if ($sub_matches) {
$matches[$key] = $sub_matches;
}
} elseif (preg_match($pattern, $item)) {
$matches[$key] = $item;
}
}
return $matches;
} | php | protected function pregGrepRecursive($pattern, $haystack)
{
$matches = [];
foreach ($haystack as $key => $item) {
if (is_array($item)) {
$sub_matches = $this->pregGrepRecursive($pattern, $item);
if ($sub_matches) {
$matches[$key] = $sub_matches;
}
} elseif (preg_match($pattern, $item)) {
$matches[$key] = $item;
}
}
return $matches;
} | [
"protected",
"function",
"pregGrepRecursive",
"(",
"$",
"pattern",
",",
"$",
"haystack",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"sub_matches",
"=",
"$",
"this",
"->",
"pregGrepRecursive",
"(",
"$",
"pattern",
",",
"$",
"item",
")",
";",
"if",
"(",
"$",
"sub_matches",
")",
"{",
"$",
"matches",
"[",
"$",
"key",
"]",
"=",
"$",
"sub_matches",
";",
"}",
"}",
"elseif",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"item",
")",
")",
"{",
"$",
"matches",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"matches",
";",
"}"
] | Recursive version of preg_grep.
@param string $pattern
@param array $haystack
@return array | [
"Recursive",
"version",
"of",
"preg_grep",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L372-L389 |
CupOfTea696/WordPress-Composer | src/ComposerConfigurator.php | ComposerConfigurator.sortByArray | protected function sortByArray($array, $order)
{
$keys = array_keys($array);
return array_merge(
array_flip(
array_intersect($order, $keys) +
array_diff($keys, $order)
),
$array
);
} | php | protected function sortByArray($array, $order)
{
$keys = array_keys($array);
return array_merge(
array_flip(
array_intersect($order, $keys) +
array_diff($keys, $order)
),
$array
);
} | [
"protected",
"function",
"sortByArray",
"(",
"$",
"array",
",",
"$",
"order",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"array",
")",
";",
"return",
"array_merge",
"(",
"array_flip",
"(",
"array_intersect",
"(",
"$",
"order",
",",
"$",
"keys",
")",
"+",
"array_diff",
"(",
"$",
"keys",
",",
"$",
"order",
")",
")",
",",
"$",
"array",
")",
";",
"}"
] | Sort an array by its keys, using a given array as the sort order.
@param array $array
@param array $order
@return array | [
"Sort",
"an",
"array",
"by",
"its",
"keys",
"using",
"a",
"given",
"array",
"as",
"the",
"sort",
"order",
"."
] | train | https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/ComposerConfigurator.php#L398-L409 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_report_parser.php | ezcMailMultipartReportParser.finishMultipart | public function finishMultipart()
{
if ( isset( $this->parts[0] ) )
{
$this->report->setReadablePart( $this->parts[0] );
}
if ( isset( $this->parts[1] ) )
{
$this->report->setMachinePart( $this->parts[1] );
}
if ( isset( $this->parts[2] ) )
{
$this->report->setOriginalPart( $this->parts[2] );
}
$size = 0;
foreach ( $this->report->getParts() as $part )
{
$size += $part->size;
}
$this->report->size = $size;
return $this->report;
} | php | public function finishMultipart()
{
if ( isset( $this->parts[0] ) )
{
$this->report->setReadablePart( $this->parts[0] );
}
if ( isset( $this->parts[1] ) )
{
$this->report->setMachinePart( $this->parts[1] );
}
if ( isset( $this->parts[2] ) )
{
$this->report->setOriginalPart( $this->parts[2] );
}
$size = 0;
foreach ( $this->report->getParts() as $part )
{
$size += $part->size;
}
$this->report->size = $size;
return $this->report;
} | [
"public",
"function",
"finishMultipart",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"report",
"->",
"setReadablePart",
"(",
"$",
"this",
"->",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"report",
"->",
"setMachinePart",
"(",
"$",
"this",
"->",
"parts",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"2",
"]",
")",
")",
"{",
"$",
"this",
"->",
"report",
"->",
"setOriginalPart",
"(",
"$",
"this",
"->",
"parts",
"[",
"2",
"]",
")",
";",
"}",
"$",
"size",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"report",
"->",
"getParts",
"(",
")",
"as",
"$",
"part",
")",
"{",
"$",
"size",
"+=",
"$",
"part",
"->",
"size",
";",
"}",
"$",
"this",
"->",
"report",
"->",
"size",
"=",
"$",
"size",
";",
"return",
"$",
"this",
"->",
"report",
";",
"}"
] | Returns the parts parsed for this multipart.
@return ezcMailMultipartReport | [
"Returns",
"the",
"parts",
"parsed",
"for",
"this",
"multipart",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_report_parser.php#L71-L92 |
zhouyl/mellivora | Mellivora/Database/Connectors/Connector.php | Connector.createConnection | public function createConnection($dsn, array $config, array $options)
{
list($username, $password) = [
Arr::get($config, 'username'), Arr::get($config, 'password'),
];
try {
return $this->createPdoConnection(
$dsn,
$username,
$password,
$options
);
} catch (Exception $e) {
return $this->tryAgainIfCausedByLostConnection(
$e,
$dsn,
$username,
$password,
$options
);
}
} | php | public function createConnection($dsn, array $config, array $options)
{
list($username, $password) = [
Arr::get($config, 'username'), Arr::get($config, 'password'),
];
try {
return $this->createPdoConnection(
$dsn,
$username,
$password,
$options
);
} catch (Exception $e) {
return $this->tryAgainIfCausedByLostConnection(
$e,
$dsn,
$username,
$password,
$options
);
}
} | [
"public",
"function",
"createConnection",
"(",
"$",
"dsn",
",",
"array",
"$",
"config",
",",
"array",
"$",
"options",
")",
"{",
"list",
"(",
"$",
"username",
",",
"$",
"password",
")",
"=",
"[",
"Arr",
"::",
"get",
"(",
"$",
"config",
",",
"'username'",
")",
",",
"Arr",
"::",
"get",
"(",
"$",
"config",
",",
"'password'",
")",
",",
"]",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"createPdoConnection",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"tryAgainIfCausedByLostConnection",
"(",
"$",
"e",
",",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"}",
"}"
] | Create a new PDO connection.
@param string $dsn
@param array $config
@param array $options
@return \PDO | [
"Create",
"a",
"new",
"PDO",
"connection",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Connectors/Connector.php#L37-L59 |
zhouyl/mellivora | Mellivora/Database/Connectors/Connector.php | Connector.tryAgainIfCausedByLostConnection | protected function tryAgainIfCausedByLostConnection(Exception $e, $dsn, $username, $password, $options)
{
if ($this->causedByLostConnection($e)) {
return $this->createPdoConnection($dsn, $username, $password, $options);
}
throw $e;
} | php | protected function tryAgainIfCausedByLostConnection(Exception $e, $dsn, $username, $password, $options)
{
if ($this->causedByLostConnection($e)) {
return $this->createPdoConnection($dsn, $username, $password, $options);
}
throw $e;
} | [
"protected",
"function",
"tryAgainIfCausedByLostConnection",
"(",
"Exception",
"$",
"e",
",",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"causedByLostConnection",
"(",
"$",
"e",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createPdoConnection",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"}",
"throw",
"$",
"e",
";",
"}"
] | Handle an exception that occurred during connect execution.
@param \Exception $e
@param string $dsn
@param string $username
@param string $password
@param array $options
@throws \Exception
@return \PDO | [
"Handle",
"an",
"exception",
"that",
"occurred",
"during",
"connect",
"execution",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Connectors/Connector.php#L106-L113 |
zhouyl/mellivora | Mellivora/Database/Connectors/Connector.php | Connector.getOptions | public function getOptions(array $config)
{
$options = Arr::get($config, 'options', []);
return array_diff_key($this->options, $options) + $options;
} | php | public function getOptions(array $config)
{
$options = Arr::get($config, 'options', []);
return array_diff_key($this->options, $options) + $options;
} | [
"public",
"function",
"getOptions",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"options",
"=",
"Arr",
"::",
"get",
"(",
"$",
"config",
",",
"'options'",
",",
"[",
"]",
")",
";",
"return",
"array_diff_key",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
"+",
"$",
"options",
";",
"}"
] | Get the PDO options based on the configuration.
@param array $config
@return array | [
"Get",
"the",
"PDO",
"options",
"based",
"on",
"the",
"configuration",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Connectors/Connector.php#L122-L127 |
odiaseo/pagebuilder | src/PageBuilder/Model/SiteThemeModel.php | SiteThemeModel.getActiveSiteTheme | public function getActiveSiteTheme($siteId)
{
$qb = $this->getEntityManager()->createQueryBuilder();
/** @var $query \Doctrine\ORM\Query */
$query = $qb->select('e, t')
->from($this->_entity, 'e')
->innerJoin('e.themeId', 't')
->where('e.siteId = :id')
->andWhere('e.isActive = 1')
->setMaxResults(1)
->setParameter('id', $siteId)
->getQuery();
/** @var $result \PageBuilder\Entity\Join\SiteTheme */
$result = $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);
if ($result) {
return $result->getThemeId();
} else {
return $result;
}
} | php | public function getActiveSiteTheme($siteId)
{
$qb = $this->getEntityManager()->createQueryBuilder();
/** @var $query \Doctrine\ORM\Query */
$query = $qb->select('e, t')
->from($this->_entity, 'e')
->innerJoin('e.themeId', 't')
->where('e.siteId = :id')
->andWhere('e.isActive = 1')
->setMaxResults(1)
->setParameter('id', $siteId)
->getQuery();
/** @var $result \PageBuilder\Entity\Join\SiteTheme */
$result = $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);
if ($result) {
return $result->getThemeId();
} else {
return $result;
}
} | [
"public",
"function",
"getActiveSiteTheme",
"(",
"$",
"siteId",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
";",
"/** @var $query \\Doctrine\\ORM\\Query */",
"$",
"query",
"=",
"$",
"qb",
"->",
"select",
"(",
"'e, t'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"_entity",
",",
"'e'",
")",
"->",
"innerJoin",
"(",
"'e.themeId'",
",",
"'t'",
")",
"->",
"where",
"(",
"'e.siteId = :id'",
")",
"->",
"andWhere",
"(",
"'e.isActive = 1'",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"setParameter",
"(",
"'id'",
",",
"$",
"siteId",
")",
"->",
"getQuery",
"(",
")",
";",
"/** @var $result \\PageBuilder\\Entity\\Join\\SiteTheme */",
"$",
"result",
"=",
"$",
"query",
"->",
"getOneOrNullResult",
"(",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"return",
"$",
"result",
"->",
"getThemeId",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"result",
";",
"}",
"}"
] | Get Active Site Theme
@param $siteId
@return \PageBuilder\Entity\Join\SiteTheme | [
"Get",
"Active",
"Site",
"Theme"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/SiteThemeModel.php#L16-L37 |
zhouyl/mellivora | Mellivora/Session/SimpleCacheHandler.php | SimpleCacheHandler.destroy | public function destroy($sessionId)
{
return $this->simpleCache->has($id) ? $this->cache->delete($id) : true;
} | php | public function destroy($sessionId)
{
return $this->simpleCache->has($id) ? $this->cache->delete($id) : true;
} | [
"public",
"function",
"destroy",
"(",
"$",
"sessionId",
")",
"{",
"return",
"$",
"this",
"->",
"simpleCache",
"->",
"has",
"(",
"$",
"id",
")",
"?",
"$",
"this",
"->",
"cache",
"->",
"delete",
"(",
"$",
"id",
")",
":",
"true",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Session/SimpleCacheHandler.php#L88-L91 |
heidelpay/PhpDoc | src/phpDocumentor/Configuration/ServiceProvider.php | ServiceProvider.register | public function register(Application $app)
{
$this->addMerger($app);
$app->extend(
'console',
function (ConsoleApplication $console) {
$console->getDefinition()->addOption(
new InputOption(
'config',
'c',
InputOption::VALUE_OPTIONAL,
'Location of a custom configuration file'
)
);
return $console;
}
);
$app['config.path.template'] = __DIR__ . '/Resources/phpdoc.tpl.xml';
$app['config.path.user'] = getcwd()
. ((file_exists(getcwd() . '/phpdoc.xml')) ? '/phpdoc.xml' : '/phpdoc.dist.xml');
$app['config.class'] = 'phpDocumentor\Configuration';
$app['config'] = $app->share(
function ($app) {
$loader = new Loader($app['serializer'], $app['config.merger']);
return $loader->load($app['config.path.template'], $app['config.path.user'], $app['config.class']);
}
);
} | php | public function register(Application $app)
{
$this->addMerger($app);
$app->extend(
'console',
function (ConsoleApplication $console) {
$console->getDefinition()->addOption(
new InputOption(
'config',
'c',
InputOption::VALUE_OPTIONAL,
'Location of a custom configuration file'
)
);
return $console;
}
);
$app['config.path.template'] = __DIR__ . '/Resources/phpdoc.tpl.xml';
$app['config.path.user'] = getcwd()
. ((file_exists(getcwd() . '/phpdoc.xml')) ? '/phpdoc.xml' : '/phpdoc.dist.xml');
$app['config.class'] = 'phpDocumentor\Configuration';
$app['config'] = $app->share(
function ($app) {
$loader = new Loader($app['serializer'], $app['config.merger']);
return $loader->load($app['config.path.template'], $app['config.path.user'], $app['config.class']);
}
);
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"addMerger",
"(",
"$",
"app",
")",
";",
"$",
"app",
"->",
"extend",
"(",
"'console'",
",",
"function",
"(",
"ConsoleApplication",
"$",
"console",
")",
"{",
"$",
"console",
"->",
"getDefinition",
"(",
")",
"->",
"addOption",
"(",
"new",
"InputOption",
"(",
"'config'",
",",
"'c'",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'Location of a custom configuration file'",
")",
")",
";",
"return",
"$",
"console",
";",
"}",
")",
";",
"$",
"app",
"[",
"'config.path.template'",
"]",
"=",
"__DIR__",
".",
"'/Resources/phpdoc.tpl.xml'",
";",
"$",
"app",
"[",
"'config.path.user'",
"]",
"=",
"getcwd",
"(",
")",
".",
"(",
"(",
"file_exists",
"(",
"getcwd",
"(",
")",
".",
"'/phpdoc.xml'",
")",
")",
"?",
"'/phpdoc.xml'",
":",
"'/phpdoc.dist.xml'",
")",
";",
"$",
"app",
"[",
"'config.class'",
"]",
"=",
"'phpDocumentor\\Configuration'",
";",
"$",
"app",
"[",
"'config'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"loader",
"=",
"new",
"Loader",
"(",
"$",
"app",
"[",
"'serializer'",
"]",
",",
"$",
"app",
"[",
"'config.merger'",
"]",
")",
";",
"return",
"$",
"loader",
"->",
"load",
"(",
"$",
"app",
"[",
"'config.path.template'",
"]",
",",
"$",
"app",
"[",
"'config.path.user'",
"]",
",",
"$",
"app",
"[",
"'config.class'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Adds the Configuration object to the DIC.
phpDocumentor first loads the template config file (/data/phpdoc.tpl.xml)
and then the phpdoc.dist.xml, or the phpdoc.xml if it exists but not both,
from the current working directory.
The user config file (either phpdoc.dist.xml or phpdoc.xml) is merged
with the template file.
@param Application $app An Application instance | [
"Adds",
"the",
"Configuration",
"object",
"to",
"the",
"DIC",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/ServiceProvider.php#L53-L85 |
heidelpay/PhpDoc | src/phpDocumentor/Configuration/ServiceProvider.php | ServiceProvider.addMerger | private function addMerger(Application $container)
{
$this->addMergerAnnotations($container);
$container['config.merger'] = $container->share(
function () {
return new Merger(new AnnotationReader());
}
);
} | php | private function addMerger(Application $container)
{
$this->addMergerAnnotations($container);
$container['config.merger'] = $container->share(
function () {
return new Merger(new AnnotationReader());
}
);
} | [
"private",
"function",
"addMerger",
"(",
"Application",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"addMergerAnnotations",
"(",
"$",
"container",
")",
";",
"$",
"container",
"[",
"'config.merger'",
"]",
"=",
"$",
"container",
"->",
"share",
"(",
"function",
"(",
")",
"{",
"return",
"new",
"Merger",
"(",
"new",
"AnnotationReader",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] | Initializes and adds the configuration merger object as the 'config.merger' service to the container.
@param Application $container
@return void | [
"Initializes",
"and",
"adds",
"the",
"configuration",
"merger",
"object",
"as",
"the",
"config",
".",
"merger",
"service",
"to",
"the",
"container",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/ServiceProvider.php#L94-L103 |
heidelpay/PhpDoc | src/phpDocumentor/Configuration/ServiceProvider.php | ServiceProvider.addMergerAnnotations | private function addMergerAnnotations(Application $container)
{
if (!isset($container['serializer.annotations'])) {
throw new \RuntimeException(
'The configuration service provider depends on the JmsSerializer Service Provider but the '
. '"serializer.annotations" key could not be found in the container.'
);
}
$annotations = $container['serializer.annotations'];
$annotations[] = array(
'namespace' => 'phpDocumentor\Configuration\Merger\Annotation',
'path' => __DIR__ . '/../../'
);
$container['serializer.annotations'] = $annotations;
} | php | private function addMergerAnnotations(Application $container)
{
if (!isset($container['serializer.annotations'])) {
throw new \RuntimeException(
'The configuration service provider depends on the JmsSerializer Service Provider but the '
. '"serializer.annotations" key could not be found in the container.'
);
}
$annotations = $container['serializer.annotations'];
$annotations[] = array(
'namespace' => 'phpDocumentor\Configuration\Merger\Annotation',
'path' => __DIR__ . '/../../'
);
$container['serializer.annotations'] = $annotations;
} | [
"private",
"function",
"addMergerAnnotations",
"(",
"Application",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'serializer.annotations'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The configuration service provider depends on the JmsSerializer Service Provider but the '",
".",
"'\"serializer.annotations\" key could not be found in the container.'",
")",
";",
"}",
"$",
"annotations",
"=",
"$",
"container",
"[",
"'serializer.annotations'",
"]",
";",
"$",
"annotations",
"[",
"]",
"=",
"array",
"(",
"'namespace'",
"=>",
"'phpDocumentor\\Configuration\\Merger\\Annotation'",
",",
"'path'",
"=>",
"__DIR__",
".",
"'/../../'",
")",
";",
"$",
"container",
"[",
"'serializer.annotations'",
"]",
"=",
"$",
"annotations",
";",
"}"
] | Adds the annotations for the Merger component to the Serializer.
@param Application $container
@throws \RuntimeException if the annotation handler for Jms Serializer is not added to the container as
'serializer.annotations' service.
@return void | [
"Adds",
"the",
"annotations",
"for",
"the",
"Merger",
"component",
"to",
"the",
"Serializer",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/ServiceProvider.php#L115-L130 |
NuclearCMS/Hierarchy | src/Builders/Writer.php | Writer.write | public function write($path, $contents)
{
if ( ! FileKeeper::exists($dir = $this->getBasePath()))
{
FileKeeper::directory($dir);
}
FileKeeper::write($path, $contents);
} | php | public function write($path, $contents)
{
if ( ! FileKeeper::exists($dir = $this->getBasePath()))
{
FileKeeper::directory($dir);
}
FileKeeper::write($path, $contents);
} | [
"public",
"function",
"write",
"(",
"$",
"path",
",",
"$",
"contents",
")",
"{",
"if",
"(",
"!",
"FileKeeper",
"::",
"exists",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"getBasePath",
"(",
")",
")",
")",
"{",
"FileKeeper",
"::",
"directory",
"(",
"$",
"dir",
")",
";",
"}",
"FileKeeper",
"::",
"write",
"(",
"$",
"path",
",",
"$",
"contents",
")",
";",
"}"
] | Writes a file, also creates base directory
@param $path
@param $contents | [
"Writes",
"a",
"file",
"also",
"creates",
"base",
"directory"
] | train | https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/Writer.php#L16-L24 |
interactivesolutions/honeycomb-core | src/providers/HCCoreServiceProvider.php | HCCoreServiceProvider.boot | public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'HCCore');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'HCCore');
if (!$this->app->routesAreCached()) {
\Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require __DIR__ . '/../http/routes/routes.admin.php';
require __DIR__ . '/../http/routes/routes.form-manager.php';
require __DIR__ . '/../http/routes/routes.logs.php';
require __DIR__ . '/../http/routes/routes.welcome.php';
});
}
// register oc log class facade
AliasLoader::getInstance()->alias('HCLog', \interactivesolutions\honeycombcore\errors\facades\HCLog::class);
} | php | public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'HCCore');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'HCCore');
if (!$this->app->routesAreCached()) {
\Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require __DIR__ . '/../http/routes/routes.admin.php';
require __DIR__ . '/../http/routes/routes.form-manager.php';
require __DIR__ . '/../http/routes/routes.logs.php';
require __DIR__ . '/../http/routes/routes.welcome.php';
});
}
// register oc log class facade
AliasLoader::getInstance()->alias('HCLog', \interactivesolutions\honeycombcore\errors\facades\HCLog::class);
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"__DIR__",
".",
"'/../resources/views'",
",",
"'HCCore'",
")",
";",
"$",
"this",
"->",
"loadTranslationsFrom",
"(",
"__DIR__",
".",
"'/../resources/lang'",
",",
"'HCCore'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"routesAreCached",
"(",
")",
")",
"{",
"\\",
"Route",
"::",
"group",
"(",
"[",
"'middleware'",
"=>",
"'web'",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"namespace",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"require",
"__DIR__",
".",
"'/../http/routes/routes.admin.php'",
";",
"require",
"__DIR__",
".",
"'/../http/routes/routes.form-manager.php'",
";",
"require",
"__DIR__",
".",
"'/../http/routes/routes.logs.php'",
";",
"require",
"__DIR__",
".",
"'/../http/routes/routes.welcome.php'",
";",
"}",
")",
";",
"}",
"// register oc log class facade",
"AliasLoader",
"::",
"getInstance",
"(",
")",
"->",
"alias",
"(",
"'HCLog'",
",",
"\\",
"interactivesolutions",
"\\",
"honeycombcore",
"\\",
"errors",
"\\",
"facades",
"\\",
"HCLog",
"::",
"class",
")",
";",
"}"
] | Bootstrap the application services.
@return void | [
"Bootstrap",
"the",
"application",
"services",
"."
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/providers/HCCoreServiceProvider.php#L34-L53 |
interactivesolutions/honeycomb-core | src/providers/HCCoreServiceProvider.php | HCCoreServiceProvider.register | public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/services.php', 'services');
$this->registerProviders();
$this->app->bind('hclog', function () {
return new HCLog;
});
// register artisan commands
$this->commands($this->commands);
$this->registerHelpers();
} | php | public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/services.php', 'services');
$this->registerProviders();
$this->app->bind('hclog', function () {
return new HCLog;
});
// register artisan commands
$this->commands($this->commands);
$this->registerHelpers();
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/../config/services.php'",
",",
"'services'",
")",
";",
"$",
"this",
"->",
"registerProviders",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'hclog'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"HCLog",
";",
"}",
")",
";",
"// register artisan commands",
"$",
"this",
"->",
"commands",
"(",
"$",
"this",
"->",
"commands",
")",
";",
"$",
"this",
"->",
"registerHelpers",
"(",
")",
";",
"}"
] | Register the application services.
@return void | [
"Register",
"the",
"application",
"services",
"."
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/providers/HCCoreServiceProvider.php#L60-L74 |
interactivesolutions/honeycomb-core | src/providers/HCCoreServiceProvider.php | HCCoreServiceProvider.registerProviders | protected function registerProviders()
{
// register rollbar service provider
if (class_exists(HCRollbarServiceProvider::class))
$this->app->register(HCRollbarServiceProvider::class);
// register LogViewer service provider
if (class_exists(LaravelLogViewerServiceProvider::class))
$this->app->register(LaravelLogViewerServiceProvider::class);
} | php | protected function registerProviders()
{
// register rollbar service provider
if (class_exists(HCRollbarServiceProvider::class))
$this->app->register(HCRollbarServiceProvider::class);
// register LogViewer service provider
if (class_exists(LaravelLogViewerServiceProvider::class))
$this->app->register(LaravelLogViewerServiceProvider::class);
} | [
"protected",
"function",
"registerProviders",
"(",
")",
"{",
"// register rollbar service provider",
"if",
"(",
"class_exists",
"(",
"HCRollbarServiceProvider",
"::",
"class",
")",
")",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"HCRollbarServiceProvider",
"::",
"class",
")",
";",
"// register LogViewer service provider",
"if",
"(",
"class_exists",
"(",
"LaravelLogViewerServiceProvider",
"::",
"class",
")",
")",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"LaravelLogViewerServiceProvider",
"::",
"class",
")",
";",
"}"
] | Register service providers | [
"Register",
"service",
"providers"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/providers/HCCoreServiceProvider.php#L91-L100 |
php-lug/lug | src/Component/Grid/Slicer/Slicer.php | Slicer.slice | public function slice(DataSourceBuilderInterface $builder, GridInterface $grid, array $slicing)
{
$limit = isset($slicing['limit'])
? $slicing['limit']
: ($grid->hasOption('limit') ? $grid->getOption('limit') : 10);
$page = isset($slicing['page'])
? $slicing['page']
: ($grid->hasOption('page') ? $grid->getOption('page') : 1);
$builder
->setLimit($limit)
->setPage($page);
} | php | public function slice(DataSourceBuilderInterface $builder, GridInterface $grid, array $slicing)
{
$limit = isset($slicing['limit'])
? $slicing['limit']
: ($grid->hasOption('limit') ? $grid->getOption('limit') : 10);
$page = isset($slicing['page'])
? $slicing['page']
: ($grid->hasOption('page') ? $grid->getOption('page') : 1);
$builder
->setLimit($limit)
->setPage($page);
} | [
"public",
"function",
"slice",
"(",
"DataSourceBuilderInterface",
"$",
"builder",
",",
"GridInterface",
"$",
"grid",
",",
"array",
"$",
"slicing",
")",
"{",
"$",
"limit",
"=",
"isset",
"(",
"$",
"slicing",
"[",
"'limit'",
"]",
")",
"?",
"$",
"slicing",
"[",
"'limit'",
"]",
":",
"(",
"$",
"grid",
"->",
"hasOption",
"(",
"'limit'",
")",
"?",
"$",
"grid",
"->",
"getOption",
"(",
"'limit'",
")",
":",
"10",
")",
";",
"$",
"page",
"=",
"isset",
"(",
"$",
"slicing",
"[",
"'page'",
"]",
")",
"?",
"$",
"slicing",
"[",
"'page'",
"]",
":",
"(",
"$",
"grid",
"->",
"hasOption",
"(",
"'page'",
")",
"?",
"$",
"grid",
"->",
"getOption",
"(",
"'page'",
")",
":",
"1",
")",
";",
"$",
"builder",
"->",
"setLimit",
"(",
"$",
"limit",
")",
"->",
"setPage",
"(",
"$",
"page",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Slicer/Slicer.php#L25-L38 |
mothership-ec/composer | src/Composer/Repository/Vcs/HgBitbucketDriver.php | HgBitbucketDriver.initialize | public function initialize()
{
preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#', $this->url, $match);
$this->owner = $match[1];
$this->repository = $match[2];
$this->originUrl = 'bitbucket.org';
} | php | public function initialize()
{
preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#', $this->url, $match);
$this->owner = $match[1];
$this->repository = $match[2];
$this->originUrl = 'bitbucket.org';
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"preg_match",
"(",
"'#^https?://bitbucket\\.org/([^/]+)/([^/]+)/?$#'",
",",
"$",
"this",
"->",
"url",
",",
"$",
"match",
")",
";",
"$",
"this",
"->",
"owner",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"repository",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"$",
"this",
"->",
"originUrl",
"=",
"'bitbucket.org'",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/HgBitbucketDriver.php#L34-L40 |
mothership-ec/composer | src/Composer/Repository/Vcs/HgBitbucketDriver.php | HgBitbucketDriver.getRootIdentifier | public function getRootIdentifier()
{
if (null === $this->rootIdentifier) {
$resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$repoData = JsonFile::parseJson($this->getContents($resource), $resource);
if (array() === $repoData || !isset($repoData['tip'])) {
throw new \RuntimeException($this->url.' does not appear to be a mercurial repository, use '.$this->url.'.git if this is a git bitbucket repository');
}
$this->rootIdentifier = $repoData['tip']['raw_node'];
}
return $this->rootIdentifier;
} | php | public function getRootIdentifier()
{
if (null === $this->rootIdentifier) {
$resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$repoData = JsonFile::parseJson($this->getContents($resource), $resource);
if (array() === $repoData || !isset($repoData['tip'])) {
throw new \RuntimeException($this->url.' does not appear to be a mercurial repository, use '.$this->url.'.git if this is a git bitbucket repository');
}
$this->rootIdentifier = $repoData['tip']['raw_node'];
}
return $this->rootIdentifier;
} | [
"public",
"function",
"getRootIdentifier",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"rootIdentifier",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://bitbucket.org/api/1.0/repositories/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
".",
"'/tags'",
";",
"$",
"repoData",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"this",
"->",
"getContents",
"(",
"$",
"resource",
")",
",",
"$",
"resource",
")",
";",
"if",
"(",
"array",
"(",
")",
"===",
"$",
"repoData",
"||",
"!",
"isset",
"(",
"$",
"repoData",
"[",
"'tip'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"this",
"->",
"url",
".",
"' does not appear to be a mercurial repository, use '",
".",
"$",
"this",
"->",
"url",
".",
"'.git if this is a git bitbucket repository'",
")",
";",
"}",
"$",
"this",
"->",
"rootIdentifier",
"=",
"$",
"repoData",
"[",
"'tip'",
"]",
"[",
"'raw_node'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"rootIdentifier",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/HgBitbucketDriver.php#L45-L57 |
mothership-ec/composer | src/Composer/Repository/Vcs/HgBitbucketDriver.php | HgBitbucketDriver.getDist | public function getDist($identifier)
{
$url = $this->getScheme() . '://bitbucket.org/'.$this->owner.'/'.$this->repository.'/get/'.$identifier.'.zip';
return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
} | php | public function getDist($identifier)
{
$url = $this->getScheme() . '://bitbucket.org/'.$this->owner.'/'.$this->repository.'/get/'.$identifier.'.zip';
return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
} | [
"public",
"function",
"getDist",
"(",
"$",
"identifier",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://bitbucket.org/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
".",
"'/get/'",
".",
"$",
"identifier",
".",
"'.zip'",
";",
"return",
"array",
"(",
"'type'",
"=>",
"'zip'",
",",
"'url'",
"=>",
"$",
"url",
",",
"'reference'",
"=>",
"$",
"identifier",
",",
"'shasum'",
"=>",
"''",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/HgBitbucketDriver.php#L78-L83 |
Eresus/EresusCMS | src/core/about.php | TAbout.adminRender | public function adminRender()
{
global $locale;
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->load(Eresus_CMS::getLegacyKernel()->froot . 'core/about.xml');
$data = array();
/* @var DOMElement $product */
$product = $xml->getElementsByTagName('product')->item(0);
$data['product'] = array();
$data['product']['title'] = $product->getAttribute('title');
$data['product']['version'] = $product->getAttribute('version');
$data['product']['copyrights'] = array();
$copyrights = $product->getElementsByTagName('copyright');
for ($i = 0; $i < $copyrights->length; $i++)
{
/* @var DOMElement $copyright */
$copyright = $copyrights->item($i);
$data['product']['copyrights'] []= array(
'year' => $copyright->getAttribute('year'),
'owner' => $copyright->getAttribute('owner'),
'url' => $copyright->getAttribute('url'),
);
}
$license = $xml->getElementsByTagName('license')->item(0);
$data['license'] = array();
$data['license']['text'] = $license->getElementsByTagName($locale['lang'])->item(0)->textContent;
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$tmpl = $page->getUITheme()->getTemplate('misc/about.html');
$html = $tmpl->compile($data);
return $html;
} | php | public function adminRender()
{
global $locale;
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->load(Eresus_CMS::getLegacyKernel()->froot . 'core/about.xml');
$data = array();
/* @var DOMElement $product */
$product = $xml->getElementsByTagName('product')->item(0);
$data['product'] = array();
$data['product']['title'] = $product->getAttribute('title');
$data['product']['version'] = $product->getAttribute('version');
$data['product']['copyrights'] = array();
$copyrights = $product->getElementsByTagName('copyright');
for ($i = 0; $i < $copyrights->length; $i++)
{
/* @var DOMElement $copyright */
$copyright = $copyrights->item($i);
$data['product']['copyrights'] []= array(
'year' => $copyright->getAttribute('year'),
'owner' => $copyright->getAttribute('owner'),
'url' => $copyright->getAttribute('url'),
);
}
$license = $xml->getElementsByTagName('license')->item(0);
$data['license'] = array();
$data['license']['text'] = $license->getElementsByTagName($locale['lang'])->item(0)->textContent;
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$tmpl = $page->getUITheme()->getTemplate('misc/about.html');
$html = $tmpl->compile($data);
return $html;
} | [
"public",
"function",
"adminRender",
"(",
")",
"{",
"global",
"$",
"locale",
";",
"$",
"xml",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"xml",
"->",
"load",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"froot",
".",
"'core/about.xml'",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"/* @var DOMElement $product */",
"$",
"product",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'product'",
")",
"->",
"item",
"(",
"0",
")",
";",
"$",
"data",
"[",
"'product'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'product'",
"]",
"[",
"'title'",
"]",
"=",
"$",
"product",
"->",
"getAttribute",
"(",
"'title'",
")",
";",
"$",
"data",
"[",
"'product'",
"]",
"[",
"'version'",
"]",
"=",
"$",
"product",
"->",
"getAttribute",
"(",
"'version'",
")",
";",
"$",
"data",
"[",
"'product'",
"]",
"[",
"'copyrights'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"copyrights",
"=",
"$",
"product",
"->",
"getElementsByTagName",
"(",
"'copyright'",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"copyrights",
"->",
"length",
";",
"$",
"i",
"++",
")",
"{",
"/* @var DOMElement $copyright */",
"$",
"copyright",
"=",
"$",
"copyrights",
"->",
"item",
"(",
"$",
"i",
")",
";",
"$",
"data",
"[",
"'product'",
"]",
"[",
"'copyrights'",
"]",
"[",
"]",
"=",
"array",
"(",
"'year'",
"=>",
"$",
"copyright",
"->",
"getAttribute",
"(",
"'year'",
")",
",",
"'owner'",
"=>",
"$",
"copyright",
"->",
"getAttribute",
"(",
"'owner'",
")",
",",
"'url'",
"=>",
"$",
"copyright",
"->",
"getAttribute",
"(",
"'url'",
")",
",",
")",
";",
"}",
"$",
"license",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'license'",
")",
"->",
"item",
"(",
"0",
")",
";",
"$",
"data",
"[",
"'license'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'license'",
"]",
"[",
"'text'",
"]",
"=",
"$",
"license",
"->",
"getElementsByTagName",
"(",
"$",
"locale",
"[",
"'lang'",
"]",
")",
"->",
"item",
"(",
"0",
")",
"->",
"textContent",
";",
"/** @var TAdminUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"tmpl",
"=",
"$",
"page",
"->",
"getUITheme",
"(",
")",
"->",
"getTemplate",
"(",
"'misc/about.html'",
")",
";",
"$",
"html",
"=",
"$",
"tmpl",
"->",
"compile",
"(",
"$",
"data",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Возвращает страницу "О программе"
@return string HTML | [
"Возвращает",
"страницу",
"О",
"программе"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/about.php#L42-L80 |
bradcornford/Alerter | src/Cornford/Alerter/Alert.php | Alert.create | public static function create($type, $content)
{
if (empty($type)) {
throw new AlertTypeException('Unable to create message with invalid type.');
}
if (empty($content)) {
throw new AlertContentException('Unable to create message with invalid content.');
}
return new self($type, $content);
} | php | public static function create($type, $content)
{
if (empty($type)) {
throw new AlertTypeException('Unable to create message with invalid type.');
}
if (empty($content)) {
throw new AlertContentException('Unable to create message with invalid content.');
}
return new self($type, $content);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"type",
",",
"$",
"content",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"AlertTypeException",
"(",
"'Unable to create message with invalid type.'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"{",
"throw",
"new",
"AlertContentException",
"(",
"'Unable to create message with invalid content.'",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"type",
",",
"$",
"content",
")",
";",
"}"
] | Create a new alerter instance.
@param string $type
@param string $content
@return self
@throws \Cornford\Alerter\Exceptions\AlertContentException
@throws \Cornford\Alerter\Exceptions\AlertTypeException | [
"Create",
"a",
"new",
"alerter",
"instance",
"."
] | train | https://github.com/bradcornford/Alerter/blob/6533fe7afb9d1bae553385d3e687a24bda6a1333/src/Cornford/Alerter/Alert.php#L75-L86 |
bradcornford/Alerter | src/Cornford/Alerter/Alert.php | Alert.display | public function display($viewPath = null, $view = null)
{
if (!$viewPath) {
$viewPath = $this->viewPath;
}
if (!$view) {
$view = $this->view;
}
return (new AlertDisplay($this, $viewPath, $view))->display();
} | php | public function display($viewPath = null, $view = null)
{
if (!$viewPath) {
$viewPath = $this->viewPath;
}
if (!$view) {
$view = $this->view;
}
return (new AlertDisplay($this, $viewPath, $view))->display();
} | [
"public",
"function",
"display",
"(",
"$",
"viewPath",
"=",
"null",
",",
"$",
"view",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"viewPath",
")",
"{",
"$",
"viewPath",
"=",
"$",
"this",
"->",
"viewPath",
";",
"}",
"if",
"(",
"!",
"$",
"view",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"view",
";",
"}",
"return",
"(",
"new",
"AlertDisplay",
"(",
"$",
"this",
",",
"$",
"viewPath",
",",
"$",
"view",
")",
")",
"->",
"display",
"(",
")",
";",
"}"
] | Return a string of alert display HTML for a set display view.
@param string $view
@param string $viewPath
@return string | [
"Return",
"a",
"string",
"of",
"alert",
"display",
"HTML",
"for",
"a",
"set",
"display",
"view",
"."
] | train | https://github.com/bradcornford/Alerter/blob/6533fe7afb9d1bae553385d3e687a24bda6a1333/src/Cornford/Alerter/Alert.php#L162-L173 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.add | public function add(
$id,
$parentId,
$blockType,
array $options = [],
$siblingId = null,
$prepend = null
) {
try {
$this->validateBlockType($blockType);
$this->rawLayout->add($id, $parentId, $blockType, $options, $siblingId, $prepend);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to the layout. ParentId: %s. BlockType: %s. SiblingId: %s. Reason: %s',
$id,
$parentId,
$blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType,
$siblingId,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function add(
$id,
$parentId,
$blockType,
array $options = [],
$siblingId = null,
$prepend = null
) {
try {
$this->validateBlockType($blockType);
$this->rawLayout->add($id, $parentId, $blockType, $options, $siblingId, $prepend);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to the layout. ParentId: %s. BlockType: %s. SiblingId: %s. Reason: %s',
$id,
$parentId,
$blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType,
$siblingId,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"id",
",",
"$",
"parentId",
",",
"$",
"blockType",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"siblingId",
"=",
"null",
",",
"$",
"prepend",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"validateBlockType",
"(",
"$",
"blockType",
")",
";",
"$",
"this",
"->",
"rawLayout",
"->",
"add",
"(",
"$",
"id",
",",
"$",
"parentId",
",",
"$",
"blockType",
",",
"$",
"options",
",",
"$",
"siblingId",
",",
"$",
"prepend",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot add \"%s\" item to the layout. ParentId: %s. BlockType: %s. SiblingId: %s. Reason: %s'",
",",
"$",
"id",
",",
"$",
"parentId",
",",
"$",
"blockType",
"instanceof",
"BlockTypeInterface",
"?",
"$",
"blockType",
"->",
"getName",
"(",
")",
":",
"$",
"blockType",
",",
"$",
"siblingId",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L37-L64 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.remove | public function remove($id)
{
try {
$this->rawLayout->remove($id);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot remove "%s" item from the layout. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function remove($id)
{
try {
$this->rawLayout->remove($id);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot remove "%s" item from the layout. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"rawLayout",
"->",
"remove",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot remove \"%s\" item from the layout. Reason: %s'",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L69-L86 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.move | public function move($id, $parentId = null, $siblingId = null, $prepend = null)
{
try {
$this->rawLayout->move($id, $parentId, $siblingId, $prepend);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot move "%s" item. ParentId: %s. SiblingId: %s. Reason: %s',
$id,
$parentId,
$siblingId,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function move($id, $parentId = null, $siblingId = null, $prepend = null)
{
try {
$this->rawLayout->move($id, $parentId, $siblingId, $prepend);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot move "%s" item. ParentId: %s. SiblingId: %s. Reason: %s',
$id,
$parentId,
$siblingId,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"move",
"(",
"$",
"id",
",",
"$",
"parentId",
"=",
"null",
",",
"$",
"siblingId",
"=",
"null",
",",
"$",
"prepend",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"rawLayout",
"->",
"move",
"(",
"$",
"id",
",",
"$",
"parentId",
",",
"$",
"siblingId",
",",
"$",
"prepend",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot move \"%s\" item. ParentId: %s. SiblingId: %s. Reason: %s'",
",",
"$",
"id",
",",
"$",
"parentId",
",",
"$",
"siblingId",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L91-L110 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.addAlias | public function addAlias($alias, $id)
{
try {
$this->rawLayout->addAlias($alias, $id);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" alias for "%s" item. Reason: %s',
$alias,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function addAlias($alias, $id)
{
try {
$this->rawLayout->addAlias($alias, $id);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" alias for "%s" item. Reason: %s',
$alias,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"addAlias",
"(",
"$",
"alias",
",",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"rawLayout",
"->",
"addAlias",
"(",
"$",
"alias",
",",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot add \"%s\" alias for \"%s\" item. Reason: %s'",
",",
"$",
"alias",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L115-L133 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.removeAlias | public function removeAlias($alias)
{
try {
$this->rawLayout->removeAlias($alias);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot remove "%s" alias. Reason: %s',
$alias,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function removeAlias($alias)
{
try {
$this->rawLayout->removeAlias($alias);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot remove "%s" alias. Reason: %s',
$alias,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"removeAlias",
"(",
"$",
"alias",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"rawLayout",
"->",
"removeAlias",
"(",
"$",
"alias",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot remove \"%s\" alias. Reason: %s'",
",",
"$",
"alias",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L138-L155 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.appendOption | public function appendOption($id, $optionName, $optionValue)
{
try {
if (!$optionName) {
throw new Exception\InvalidArgumentException('The option name must not be empty.');
}
if ($this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS)) {
throw new Exception\LogicException('Cannot change already resolved options.');
}
$this->optionsManipulator->appendOption($id, $optionName, $optionValue);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot append a value for "%s" option for "%s" item. Reason: %s',
$optionName,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function appendOption($id, $optionName, $optionValue)
{
try {
if (!$optionName) {
throw new Exception\InvalidArgumentException('The option name must not be empty.');
}
if ($this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS)) {
throw new Exception\LogicException('Cannot change already resolved options.');
}
$this->optionsManipulator->appendOption($id, $optionName, $optionValue);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot append a value for "%s" option for "%s" item. Reason: %s',
$optionName,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"appendOption",
"(",
"$",
"id",
",",
"$",
"optionName",
",",
"$",
"optionValue",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"optionName",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The option name must not be empty.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"rawLayout",
"->",
"hasProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"RESOLVED_OPTIONS",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"'Cannot change already resolved options.'",
")",
";",
"}",
"$",
"this",
"->",
"optionsManipulator",
"->",
"appendOption",
"(",
"$",
"id",
",",
"$",
"optionName",
",",
"$",
"optionValue",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot append a value for \"%s\" option for \"%s\" item. Reason: %s'",
",",
"$",
"optionName",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L189-L213 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.replaceOption | public function replaceOption($id, $optionName, $oldOptionValue, $newOptionValue)
{
try {
if (!$optionName) {
throw new Exception\InvalidArgumentException('The option name must not be empty.');
}
if ($this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS)) {
throw new Exception\LogicException('Cannot change already resolved options.');
}
$this->optionsManipulator->replaceOption($id, $optionName, $oldOptionValue, $newOptionValue);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot replace a value for "%s" option for "%s" item. Reason: %s',
$optionName,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function replaceOption($id, $optionName, $oldOptionValue, $newOptionValue)
{
try {
if (!$optionName) {
throw new Exception\InvalidArgumentException('The option name must not be empty.');
}
if ($this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS)) {
throw new Exception\LogicException('Cannot change already resolved options.');
}
$this->optionsManipulator->replaceOption($id, $optionName, $oldOptionValue, $newOptionValue);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot replace a value for "%s" option for "%s" item. Reason: %s',
$optionName,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"replaceOption",
"(",
"$",
"id",
",",
"$",
"optionName",
",",
"$",
"oldOptionValue",
",",
"$",
"newOptionValue",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"optionName",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The option name must not be empty.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"rawLayout",
"->",
"hasProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"RESOLVED_OPTIONS",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"'Cannot change already resolved options.'",
")",
";",
"}",
"$",
"this",
"->",
"optionsManipulator",
"->",
"replaceOption",
"(",
"$",
"id",
",",
"$",
"optionName",
",",
"$",
"oldOptionValue",
",",
"$",
"newOptionValue",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot replace a value for \"%s\" option for \"%s\" item. Reason: %s'",
",",
"$",
"optionName",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L247-L271 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.changeBlockType | public function changeBlockType($id, $blockType, $optionsCallback = null)
{
try {
if ($this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS)) {
throw new Exception\LogicException('Cannot change the block type if options are already resolved.');
}
$this->validateBlockType($blockType);
$this->rawLayout->setProperty($id, RawLayout::BLOCK_TYPE, $blockType);
if ($optionsCallback !== null) {
if (!is_callable($optionsCallback)) {
throw new Exception\UnexpectedTypeException($optionsCallback, 'callable', 'optionsCallback');
}
$options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS);
$options = call_user_func($optionsCallback, $options);
$this->rawLayout->setProperty($id, RawLayout::OPTIONS, $options);
}
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot change block type to "%s" for "%s" item. Reason: %s',
$blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function changeBlockType($id, $blockType, $optionsCallback = null)
{
try {
if ($this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS)) {
throw new Exception\LogicException('Cannot change the block type if options are already resolved.');
}
$this->validateBlockType($blockType);
$this->rawLayout->setProperty($id, RawLayout::BLOCK_TYPE, $blockType);
if ($optionsCallback !== null) {
if (!is_callable($optionsCallback)) {
throw new Exception\UnexpectedTypeException($optionsCallback, 'callable', 'optionsCallback');
}
$options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS);
$options = call_user_func($optionsCallback, $options);
$this->rawLayout->setProperty($id, RawLayout::OPTIONS, $options);
}
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot change block type to "%s" for "%s" item. Reason: %s',
$blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType,
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"changeBlockType",
"(",
"$",
"id",
",",
"$",
"blockType",
",",
"$",
"optionsCallback",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"rawLayout",
"->",
"hasProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"RESOLVED_OPTIONS",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"'Cannot change the block type if options are already resolved.'",
")",
";",
"}",
"$",
"this",
"->",
"validateBlockType",
"(",
"$",
"blockType",
")",
";",
"$",
"this",
"->",
"rawLayout",
"->",
"setProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"BLOCK_TYPE",
",",
"$",
"blockType",
")",
";",
"if",
"(",
"$",
"optionsCallback",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"optionsCallback",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"optionsCallback",
",",
"'callable'",
",",
"'optionsCallback'",
")",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"rawLayout",
"->",
"getProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"OPTIONS",
")",
";",
"$",
"options",
"=",
"call_user_func",
"(",
"$",
"optionsCallback",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"rawLayout",
"->",
"setProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"OPTIONS",
",",
"$",
"options",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot change block type to \"%s\" for \"%s\" item. Reason: %s'",
",",
"$",
"blockType",
"instanceof",
"BlockTypeInterface",
"?",
"$",
"blockType",
"->",
"getName",
"(",
")",
":",
"$",
"blockType",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L305-L335 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.setBlockTheme | public function setBlockTheme($themes, $id = null)
{
try {
if (!$id) {
$id = $this->rawLayout->getRootId();
}
$this->rawLayout->setBlockTheme($id, $themes);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot set theme(s) for "%s" item. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | php | public function setBlockTheme($themes, $id = null)
{
try {
if (!$id) {
$id = $this->rawLayout->getRootId();
}
$this->rawLayout->setBlockTheme($id, $themes);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot set theme(s) for "%s" item. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
return $this;
} | [
"public",
"function",
"setBlockTheme",
"(",
"$",
"themes",
",",
"$",
"id",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"rawLayout",
"->",
"getRootId",
"(",
")",
";",
"}",
"$",
"this",
"->",
"rawLayout",
"->",
"setBlockTheme",
"(",
"$",
"id",
",",
"$",
"themes",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot set theme(s) for \"%s\" item. Reason: %s'",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L340-L360 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.isParentFor | public function isParentFor($parentId, $id)
{
return
$this->rawLayout->has($parentId)
&& $this->rawLayout->has($id)
&& $this->rawLayout->getParentId($id) === $this->rawLayout->resolveId($parentId);
} | php | public function isParentFor($parentId, $id)
{
return
$this->rawLayout->has($parentId)
&& $this->rawLayout->has($id)
&& $this->rawLayout->getParentId($id) === $this->rawLayout->resolveId($parentId);
} | [
"public",
"function",
"isParentFor",
"(",
"$",
"parentId",
",",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"rawLayout",
"->",
"has",
"(",
"$",
"parentId",
")",
"&&",
"$",
"this",
"->",
"rawLayout",
"->",
"has",
"(",
"$",
"id",
")",
"&&",
"$",
"this",
"->",
"rawLayout",
"->",
"getParentId",
"(",
"$",
"id",
")",
"===",
"$",
"this",
"->",
"rawLayout",
"->",
"resolveId",
"(",
"$",
"parentId",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L417-L423 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.getType | public function getType($id)
{
try {
$blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE);
return $blockType instanceof BlockTypeInterface
? $blockType->getName()
: $blockType;
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot get block type for "%s" item. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
} | php | public function getType($id)
{
try {
$blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE);
return $blockType instanceof BlockTypeInterface
? $blockType->getName()
: $blockType;
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot get block type for "%s" item. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
} | [
"public",
"function",
"getType",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"blockType",
"=",
"$",
"this",
"->",
"rawLayout",
"->",
"getProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"BLOCK_TYPE",
")",
";",
"return",
"$",
"blockType",
"instanceof",
"BlockTypeInterface",
"?",
"$",
"blockType",
"->",
"getName",
"(",
")",
":",
"$",
"blockType",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot get block type for \"%s\" item. Reason: %s'",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L444-L463 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.getOptions | public function getOptions($id)
{
try {
return $this->rawLayout->getProperty($id, RawLayout::OPTIONS);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot get options for "%s" item. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
} | php | public function getOptions($id)
{
try {
return $this->rawLayout->getProperty($id, RawLayout::OPTIONS);
} catch (\Exception $e) {
throw new Exception\LogicException(
sprintf(
'Cannot get options for "%s" item. Reason: %s',
$id,
$e->getMessage()
),
0,
$e
);
}
} | [
"public",
"function",
"getOptions",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"rawLayout",
"->",
"getProperty",
"(",
"$",
"id",
",",
"RawLayout",
"::",
"OPTIONS",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot get options for \"%s\" item. Reason: %s'",
",",
"$",
"id",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L468-L483 |
oroinc/OroLayoutComponent | RawLayoutBuilder.php | RawLayoutBuilder.validateBlockType | protected function validateBlockType($blockType)
{
if (!$blockType) {
throw new Exception\InvalidArgumentException('The block type name must not be empty.');
}
if (!$blockType instanceof BlockTypeInterface) {
if (!is_string($blockType)) {
throw new Exception\UnexpectedTypeException($blockType, 'string or BlockTypeInterface', 'blockType');
}
if (!preg_match('/^[a-z][a-z0-9_]*$/iD', $blockType)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the name of the block type '
. 'because it contains illegal characters. '
. 'The valid block type name should start with a letter and only contain '
. 'letters, numbers and underscores ("_").',
$blockType
)
);
}
}
} | php | protected function validateBlockType($blockType)
{
if (!$blockType) {
throw new Exception\InvalidArgumentException('The block type name must not be empty.');
}
if (!$blockType instanceof BlockTypeInterface) {
if (!is_string($blockType)) {
throw new Exception\UnexpectedTypeException($blockType, 'string or BlockTypeInterface', 'blockType');
}
if (!preg_match('/^[a-z][a-z0-9_]*$/iD', $blockType)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the name of the block type '
. 'because it contains illegal characters. '
. 'The valid block type name should start with a letter and only contain '
. 'letters, numbers and underscores ("_").',
$blockType
)
);
}
}
} | [
"protected",
"function",
"validateBlockType",
"(",
"$",
"blockType",
")",
"{",
"if",
"(",
"!",
"$",
"blockType",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The block type name must not be empty.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"blockType",
"instanceof",
"BlockTypeInterface",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"blockType",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"blockType",
",",
"'string or BlockTypeInterface'",
",",
"'blockType'",
")",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-z][a-z0-9_]*$/iD'",
",",
"$",
"blockType",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" string cannot be used as the name of the block type '",
".",
"'because it contains illegal characters. '",
".",
"'The valid block type name should start with a letter and only contain '",
".",
"'letters, numbers and underscores (\"_\").'",
",",
"$",
"blockType",
")",
")",
";",
"}",
"}",
"}"
] | Checks if the given value can be used as the block type name
@param string|BlockTypeInterface $blockType The block type
@throws Exception\InvalidArgumentException if the block type name is not valid | [
"Checks",
"if",
"the",
"given",
"value",
"can",
"be",
"used",
"as",
"the",
"block",
"type",
"name"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayoutBuilder.php#L501-L522 |
j-d/draggy | src/Draggy/Autocode/PHPEntity.php | PHPEntity.shouldRender | public function shouldRender($templateName)
{
if (!$this->getRenderizable()) {
return false;
}
switch ($templateName) {
case 'entity':
return true;
case 'entity-base':
return $this->getProject()->getAutocodeProperty('base');
case 'repository':
return $this->getHasRepository();
case 'form':
return $this->getHasForm();
case 'form-base':
return $this->getHasForm() && $this->getProject()->getAutocodeProperty('base');
case 'controller':
return $this->getHasController();
case 'fixtures':
return $this->getHasFixtures();
case 'routes':
return $this->getHasRoutes();
case 'crud-create':
return $this->getCrudCreate();
case 'crud-read':
return $this->getCrudRead();
case 'crud-update':
return $this->getCrudUpdate();
}
return false;
} | php | public function shouldRender($templateName)
{
if (!$this->getRenderizable()) {
return false;
}
switch ($templateName) {
case 'entity':
return true;
case 'entity-base':
return $this->getProject()->getAutocodeProperty('base');
case 'repository':
return $this->getHasRepository();
case 'form':
return $this->getHasForm();
case 'form-base':
return $this->getHasForm() && $this->getProject()->getAutocodeProperty('base');
case 'controller':
return $this->getHasController();
case 'fixtures':
return $this->getHasFixtures();
case 'routes':
return $this->getHasRoutes();
case 'crud-create':
return $this->getCrudCreate();
case 'crud-read':
return $this->getCrudRead();
case 'crud-update':
return $this->getCrudUpdate();
}
return false;
} | [
"public",
"function",
"shouldRender",
"(",
"$",
"templateName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getRenderizable",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"switch",
"(",
"$",
"templateName",
")",
"{",
"case",
"'entity'",
":",
"return",
"true",
";",
"case",
"'entity-base'",
":",
"return",
"$",
"this",
"->",
"getProject",
"(",
")",
"->",
"getAutocodeProperty",
"(",
"'base'",
")",
";",
"case",
"'repository'",
":",
"return",
"$",
"this",
"->",
"getHasRepository",
"(",
")",
";",
"case",
"'form'",
":",
"return",
"$",
"this",
"->",
"getHasForm",
"(",
")",
";",
"case",
"'form-base'",
":",
"return",
"$",
"this",
"->",
"getHasForm",
"(",
")",
"&&",
"$",
"this",
"->",
"getProject",
"(",
")",
"->",
"getAutocodeProperty",
"(",
"'base'",
")",
";",
"case",
"'controller'",
":",
"return",
"$",
"this",
"->",
"getHasController",
"(",
")",
";",
"case",
"'fixtures'",
":",
"return",
"$",
"this",
"->",
"getHasFixtures",
"(",
")",
";",
"case",
"'routes'",
":",
"return",
"$",
"this",
"->",
"getHasRoutes",
"(",
")",
";",
"case",
"'crud-create'",
":",
"return",
"$",
"this",
"->",
"getCrudCreate",
"(",
")",
";",
"case",
"'crud-read'",
":",
"return",
"$",
"this",
"->",
"getCrudRead",
"(",
")",
";",
"case",
"'crud-update'",
":",
"return",
"$",
"this",
"->",
"getCrudUpdate",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/PHPEntity.php#L96-L128 |
inhere/php-librarys | src/Utils/UUID.php | UUID.makeBin | protected static function makeBin($str, $len)
{
if ($str instanceof self) {
return $str->bytes;
}
if (\strlen($str) === $len) {
return $str;
}
$str = (string)preg_replace([
// strip URN scheme and namespace
'/^urn:uuid:/is',
// strip non-hex characters
'/[^a-f0-9]/is',
], '', $str);
if (\strlen($str) !== ($len * 2)) {
return null;
}
return pack('H*', $str);
} | php | protected static function makeBin($str, $len)
{
if ($str instanceof self) {
return $str->bytes;
}
if (\strlen($str) === $len) {
return $str;
}
$str = (string)preg_replace([
// strip URN scheme and namespace
'/^urn:uuid:/is',
// strip non-hex characters
'/[^a-f0-9]/is',
], '', $str);
if (\strlen($str) !== ($len * 2)) {
return null;
}
return pack('H*', $str);
} | [
"protected",
"static",
"function",
"makeBin",
"(",
"$",
"str",
",",
"$",
"len",
")",
"{",
"if",
"(",
"$",
"str",
"instanceof",
"self",
")",
"{",
"return",
"$",
"str",
"->",
"bytes",
";",
"}",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"str",
")",
"===",
"$",
"len",
")",
"{",
"return",
"$",
"str",
";",
"}",
"$",
"str",
"=",
"(",
"string",
")",
"preg_replace",
"(",
"[",
"// strip URN scheme and namespace",
"'/^urn:uuid:/is'",
",",
"// strip non-hex characters",
"'/[^a-f0-9]/is'",
",",
"]",
",",
"''",
",",
"$",
"str",
")",
";",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"str",
")",
"!==",
"(",
"$",
"len",
"*",
"2",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"pack",
"(",
"'H*'",
",",
"$",
"str",
")",
";",
"}"
] | Insure that an input string is either binary or hexadecimal.
Returns binary representation, or false on failure.
@param string $str
@param integer $len
@return string|null | [
"Insure",
"that",
"an",
"input",
"string",
"is",
"either",
"binary",
"or",
"hexadecimal",
".",
"Returns",
"binary",
"representation",
"or",
"false",
"on",
"failure",
"."
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Utils/UUID.php#L248-L269 |
bemcasei/iugu-php | src/Iugu.php | Iugu.get | public function get($resource, array $query = [])
{
$exec = $this->execute(Method::$HTTP_GET, $resource, ['query' => $query]);
return $exec;
} | php | public function get($resource, array $query = [])
{
$exec = $this->execute(Method::$HTTP_GET, $resource, ['query' => $query]);
return $exec;
} | [
"public",
"function",
"get",
"(",
"$",
"resource",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"exec",
"=",
"$",
"this",
"->",
"execute",
"(",
"Method",
"::",
"$",
"HTTP_GET",
",",
"$",
"resource",
",",
"[",
"'query'",
"=>",
"$",
"query",
"]",
")",
";",
"return",
"$",
"exec",
";",
"}"
] | Execute GET request
@param $resource
@param array $query
@return string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Execute",
"GET",
"request"
] | train | https://github.com/bemcasei/iugu-php/blob/76c6963dab71f0f7ad70960b7431e9d603a6bcce/src/Iugu.php#L53-L58 |
bemcasei/iugu-php | src/Iugu.php | Iugu.post | public function post($resource, $data = [])
{
$exec = $this->execute(Method::$HTTP_POST, $resource, ['json' => $data]);
return $exec;
} | php | public function post($resource, $data = [])
{
$exec = $this->execute(Method::$HTTP_POST, $resource, ['json' => $data]);
return $exec;
} | [
"public",
"function",
"post",
"(",
"$",
"resource",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"exec",
"=",
"$",
"this",
"->",
"execute",
"(",
"Method",
"::",
"$",
"HTTP_POST",
",",
"$",
"resource",
",",
"[",
"'json'",
"=>",
"$",
"data",
"]",
")",
";",
"return",
"$",
"exec",
";",
"}"
] | Execute POST request
@param $resource
@param array $data
@return string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Execute",
"POST",
"request"
] | train | https://github.com/bemcasei/iugu-php/blob/76c6963dab71f0f7ad70960b7431e9d603a6bcce/src/Iugu.php#L68-L73 |
bemcasei/iugu-php | src/Iugu.php | Iugu.put | public function put($resource, $data = [])
{
$exec = $this->execute(Method::$HTTP_PUT, $resource, ['json' => $data]);
return $exec;
} | php | public function put($resource, $data = [])
{
$exec = $this->execute(Method::$HTTP_PUT, $resource, ['json' => $data]);
return $exec;
} | [
"public",
"function",
"put",
"(",
"$",
"resource",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"exec",
"=",
"$",
"this",
"->",
"execute",
"(",
"Method",
"::",
"$",
"HTTP_PUT",
",",
"$",
"resource",
",",
"[",
"'json'",
"=>",
"$",
"data",
"]",
")",
";",
"return",
"$",
"exec",
";",
"}"
] | Execute PUT request
@param $resource
@param array $data
@return string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Execute",
"PUT",
"request"
] | train | https://github.com/bemcasei/iugu-php/blob/76c6963dab71f0f7ad70960b7431e9d603a6bcce/src/Iugu.php#L83-L88 |
bemcasei/iugu-php | src/Iugu.php | Iugu.makeUrl | public function makeUrl($resource)
{
$uri = self::$IUGU_URL_API;
if (! preg_match("/^https/", $resource)) {
if (! preg_match("/^\//", $resource)) {
$resource = '/' . $resource;
}
}
$uri .= $resource;
return $uri;
} | php | public function makeUrl($resource)
{
$uri = self::$IUGU_URL_API;
if (! preg_match("/^https/", $resource)) {
if (! preg_match("/^\//", $resource)) {
$resource = '/' . $resource;
}
}
$uri .= $resource;
return $uri;
} | [
"public",
"function",
"makeUrl",
"(",
"$",
"resource",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"$",
"IUGU_URL_API",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^https/\"",
",",
"$",
"resource",
")",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^\\//\"",
",",
"$",
"resource",
")",
")",
"{",
"$",
"resource",
"=",
"'/'",
".",
"$",
"resource",
";",
"}",
"}",
"$",
"uri",
".=",
"$",
"resource",
";",
"return",
"$",
"uri",
";",
"}"
] | Check and construct an real URL to make request
@param $resource
@param array $query
@return string | [
"Check",
"and",
"construct",
"an",
"real",
"URL",
"to",
"make",
"request"
] | train | https://github.com/bemcasei/iugu-php/blob/76c6963dab71f0f7ad70960b7431e9d603a6bcce/src/Iugu.php#L112-L123 |
bemcasei/iugu-php | src/Iugu.php | Iugu.execute | public function execute($method, $resource, array $data = [])
{
$request = new Request($this->handler);
$dataResource = $request->execute($method, $this->makeUrl($resource), array_merge($data, [
'headers' => [
'Authorization' => sprintf('Basic %s', base64_encode($this->token . ':' . ''))
]
]));
return $dataResource;
} | php | public function execute($method, $resource, array $data = [])
{
$request = new Request($this->handler);
$dataResource = $request->execute($method, $this->makeUrl($resource), array_merge($data, [
'headers' => [
'Authorization' => sprintf('Basic %s', base64_encode($this->token . ':' . ''))
]
]));
return $dataResource;
} | [
"public",
"function",
"execute",
"(",
"$",
"method",
",",
"$",
"resource",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"$",
"this",
"->",
"handler",
")",
";",
"$",
"dataResource",
"=",
"$",
"request",
"->",
"execute",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"makeUrl",
"(",
"$",
"resource",
")",
",",
"array_merge",
"(",
"$",
"data",
",",
"[",
"'headers'",
"=>",
"[",
"'Authorization'",
"=>",
"sprintf",
"(",
"'Basic %s'",
",",
"base64_encode",
"(",
"$",
"this",
"->",
"token",
".",
"':'",
".",
"''",
")",
")",
"]",
"]",
")",
")",
";",
"return",
"$",
"dataResource",
";",
"}"
] | Execute the resource
@param $method
@param $resource
@param array $data
@return string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Execute",
"the",
"resource"
] | train | https://github.com/bemcasei/iugu-php/blob/76c6963dab71f0f7ad70960b7431e9d603a6bcce/src/Iugu.php#L134-L144 |
nathan-fiscaletti/extended-arrays | src/ExtendedArrays/Traits/BaseArray.php | BaseArray.offsetGet | public function offsetGet($offset)
{
return isset($this->_args[$offset])
? (
(is_array($this->_args[$offset]))
? new AssociativeArray($this->_args[$offset])
: $this->_args[$offset]
) : null;
} | php | public function offsetGet($offset)
{
return isset($this->_args[$offset])
? (
(is_array($this->_args[$offset]))
? new AssociativeArray($this->_args[$offset])
: $this->_args[$offset]
) : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
")",
"?",
"(",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
")",
")",
"?",
"new",
"AssociativeArray",
"(",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
")",
":",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
")",
":",
"null",
";",
"}"
] | Retrieve a value based on an offset in the array.
@param mixed $offset
@return mixed | [
"Retrieve",
"a",
"value",
"based",
"on",
"an",
"offset",
"in",
"the",
"array",
"."
] | train | https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/Traits/BaseArray.php#L48-L56 |
nathan-fiscaletti/extended-arrays | src/ExtendedArrays/Traits/BaseArray.php | BaseArray._asStdArray | public function _asStdArray()
{
if (
property_exists($this, 'hidden') &&
is_array($this->hidden)
) {
$results = [];
foreach ($this->_args as $key => $value) {
if (! in_array($key, $this->hidden)) {
$results[$key] = $value;
}
}
return $results;
} else {
return $this->_args;
}
} | php | public function _asStdArray()
{
if (
property_exists($this, 'hidden') &&
is_array($this->hidden)
) {
$results = [];
foreach ($this->_args as $key => $value) {
if (! in_array($key, $this->hidden)) {
$results[$key] = $value;
}
}
return $results;
} else {
return $this->_args;
}
} | [
"public",
"function",
"_asStdArray",
"(",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'hidden'",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"hidden",
")",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"hidden",
")",
")",
"{",
"$",
"results",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_args",
";",
"}",
"}"
] | Convert the array to a standard PHP array using
the $hidden property as a mask.
@return array | [
"Convert",
"the",
"array",
"to",
"a",
"standard",
"PHP",
"array",
"using",
"the",
"$hidden",
"property",
"as",
"a",
"mask",
"."
] | train | https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/Traits/BaseArray.php#L64-L82 |
raideer/twitch-api | src/Resources/Channels.php | Channels.getChannel | public function getChannel($name = null)
{
if (!$name) {
$this->wrapper->checkScope('channel_read');
return $this->wrapper->request('GET', 'channel', [], true);
}
return $this->wrapper->request('GET', "channels/$name");
} | php | public function getChannel($name = null)
{
if (!$name) {
$this->wrapper->checkScope('channel_read');
return $this->wrapper->request('GET', 'channel', [], true);
}
return $this->wrapper->request('GET', "channels/$name");
} | [
"public",
"function",
"getChannel",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"wrapper",
"->",
"checkScope",
"(",
"'channel_read'",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'channel'",
",",
"[",
"]",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"\"channels/$name\"",
")",
";",
"}"
] | Returns a channel object
If channel name not provided, wrapper will assume it's an authenticated request and return
authenticated channel (scope: channel_read).
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/channels.md#get-channelschannel
@param string $name Target channel
@return array | [
"Returns",
"a",
"channel",
"object",
"If",
"channel",
"name",
"not",
"provided",
"wrapper",
"will",
"assume",
"it",
"s",
"an",
"authenticated",
"request",
"and",
"return",
"authenticated",
"channel",
"(",
"scope",
":",
"channel_read",
")",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Channels.php#L34-L43 |
raideer/twitch-api | src/Resources/Channels.php | Channels.updateChannel | public function updateChannel($channel, $params = [])
{
$this->wrapper->checkScope('channel_editor');
return $this->wrapper->request('PUT', "channels/$channel", ['form_params' => ['channel' => $params]], true);
} | php | public function updateChannel($channel, $params = [])
{
$this->wrapper->checkScope('channel_editor');
return $this->wrapper->request('PUT', "channels/$channel", ['form_params' => ['channel' => $params]], true);
} | [
"public",
"function",
"updateChannel",
"(",
"$",
"channel",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"wrapper",
"->",
"checkScope",
"(",
"'channel_editor'",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'PUT'",
",",
"\"channels/$channel\"",
",",
"[",
"'form_params'",
"=>",
"[",
"'channel'",
"=>",
"$",
"params",
"]",
"]",
",",
"true",
")",
";",
"}"
] | AUTHENTICATED REQUEST.
Updates channel's status, game and/or delay
Required scope: channel_editor
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/channels.md#put-channelschannel
@param string $channel Target channel. If null - uses authenticated username
@param array $params Parameters
@return array | [
"AUTHENTICATED",
"REQUEST",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Channels.php#L81-L86 |
raideer/twitch-api | src/Resources/Channels.php | Channels.startCommercial | public function startCommercial($channel, $length = 30)
{
$this->wrapper->checkScope('channel_commercial');
$values = [
'length' => [30, 60, 90, 120, 150, 180],
];
$resolved = $this->resolveOptions(['length' => $length], [], ['length'], $values);
return $this->wrapper->request('POST', "channels/$channel/commercial", ['form_params' => $resolved], true);
} | php | public function startCommercial($channel, $length = 30)
{
$this->wrapper->checkScope('channel_commercial');
$values = [
'length' => [30, 60, 90, 120, 150, 180],
];
$resolved = $this->resolveOptions(['length' => $length], [], ['length'], $values);
return $this->wrapper->request('POST', "channels/$channel/commercial", ['form_params' => $resolved], true);
} | [
"public",
"function",
"startCommercial",
"(",
"$",
"channel",
",",
"$",
"length",
"=",
"30",
")",
"{",
"$",
"this",
"->",
"wrapper",
"->",
"checkScope",
"(",
"'channel_commercial'",
")",
";",
"$",
"values",
"=",
"[",
"'length'",
"=>",
"[",
"30",
",",
"60",
",",
"90",
",",
"120",
",",
"150",
",",
"180",
"]",
",",
"]",
";",
"$",
"resolved",
"=",
"$",
"this",
"->",
"resolveOptions",
"(",
"[",
"'length'",
"=>",
"$",
"length",
"]",
",",
"[",
"]",
",",
"[",
"'length'",
"]",
",",
"$",
"values",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'POST'",
",",
"\"channels/$channel/commercial\"",
",",
"[",
"'form_params'",
"=>",
"$",
"resolved",
"]",
",",
"true",
")",
";",
"}"
] | AUTHENTICATED REQUEST.
Starts a commercial
Required scope: channel_commercial
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/channels.md#post-channelschannelcommercial
@param string $channel Target channel
@param int $length Length in seconds (30,60,90,120,150,180)
@return array | [
"AUTHENTICATED",
"REQUEST",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Channels.php#L124-L135 |
raideer/twitch-api | src/Resources/Channels.php | Channels.getVideos | public function getVideos($channel, $params = [])
{
$defaults = [
'limit' => 10,
'offset' => 0,
'broadcasts' => false,
'hls' => false,
];
$values = [
'broadcasts' => [true, false],
'hls' => [true, false],
];
$resolved = $this->resolveOptions($params, $defaults, [], $values);
return $this->wrapper->request('GET', "channels/$channel/videos", ['query' => $resolved]);
} | php | public function getVideos($channel, $params = [])
{
$defaults = [
'limit' => 10,
'offset' => 0,
'broadcasts' => false,
'hls' => false,
];
$values = [
'broadcasts' => [true, false],
'hls' => [true, false],
];
$resolved = $this->resolveOptions($params, $defaults, [], $values);
return $this->wrapper->request('GET', "channels/$channel/videos", ['query' => $resolved]);
} | [
"public",
"function",
"getVideos",
"(",
"$",
"channel",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'limit'",
"=>",
"10",
",",
"'offset'",
"=>",
"0",
",",
"'broadcasts'",
"=>",
"false",
",",
"'hls'",
"=>",
"false",
",",
"]",
";",
"$",
"values",
"=",
"[",
"'broadcasts'",
"=>",
"[",
"true",
",",
"false",
"]",
",",
"'hls'",
"=>",
"[",
"true",
",",
"false",
"]",
",",
"]",
";",
"$",
"resolved",
"=",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
",",
"[",
"]",
",",
"$",
"values",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"\"channels/$channel/videos\"",
",",
"[",
"'query'",
"=>",
"$",
"resolved",
"]",
")",
";",
"}"
] | Returns a list of videos ordered by time of creation, starting with the most recent from $channel.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-channelschannelvideos
@param string $name Target channel
@return array | [
"Returns",
"a",
"list",
"of",
"videos",
"ordered",
"by",
"time",
"of",
"creation",
"starting",
"with",
"the",
"most",
"recent",
"from",
"$channel",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Channels.php#L147-L164 |
raideer/twitch-api | src/Resources/Channels.php | Channels.getFollows | public function getFollows($channel, $params = [])
{
$defaults = [
'limit' => 25,
'offset' => 0,
'cursor' => null,
'direction' => 'desc',
];
$values = [
'direction' => ['asc', 'desc'],
];
$resolved = $this->resolveOptions($params, $defaults, [], $values);
return $this->wrapper->request('GET', "channels/$channel/follows", ['query' => $resolved]);
} | php | public function getFollows($channel, $params = [])
{
$defaults = [
'limit' => 25,
'offset' => 0,
'cursor' => null,
'direction' => 'desc',
];
$values = [
'direction' => ['asc', 'desc'],
];
$resolved = $this->resolveOptions($params, $defaults, [], $values);
return $this->wrapper->request('GET', "channels/$channel/follows", ['query' => $resolved]);
} | [
"public",
"function",
"getFollows",
"(",
"$",
"channel",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'limit'",
"=>",
"25",
",",
"'offset'",
"=>",
"0",
",",
"'cursor'",
"=>",
"null",
",",
"'direction'",
"=>",
"'desc'",
",",
"]",
";",
"$",
"values",
"=",
"[",
"'direction'",
"=>",
"[",
"'asc'",
",",
"'desc'",
"]",
",",
"]",
";",
"$",
"resolved",
"=",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
",",
"[",
"]",
",",
"$",
"values",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"\"channels/$channel/follows\"",
",",
"[",
"'query'",
"=>",
"$",
"resolved",
"]",
")",
";",
"}"
] | Returns a list of follow objects for $channel.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#get-channelschannelfollows
@param string $channel Target channel name
@param array $params Optional Parameters
@return array | [
"Returns",
"a",
"list",
"of",
"follow",
"objects",
"for",
"$channel",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Channels.php#L192-L208 |
songshenzong/log | src/Twig/Extension/Dump.php | Dump.dump | public function dump(Twig_Environment $env, $context)
{
$output = '';
$count = func_num_args();
if (2 === $count) {
$data = [];
foreach ($context as $key => $value) {
if (is_object($value)) {
if (method_exists($value, 'toArray')) {
$data[$key] = $value->toArray();
} else {
$data[$key] = 'Object (' . get_class($value) . ')';
}
} else {
$data[$key] = $value;
}
}
$output .= $this->formatter->formatVar($data);
} else {
for ($i = 2; $i < $count; $i++) {
$output .= $this->formatter->formatVar(func_get_arg($i));
}
}
return '<pre>' . $output . '</pre>';
} | php | public function dump(Twig_Environment $env, $context)
{
$output = '';
$count = func_num_args();
if (2 === $count) {
$data = [];
foreach ($context as $key => $value) {
if (is_object($value)) {
if (method_exists($value, 'toArray')) {
$data[$key] = $value->toArray();
} else {
$data[$key] = 'Object (' . get_class($value) . ')';
}
} else {
$data[$key] = $value;
}
}
$output .= $this->formatter->formatVar($data);
} else {
for ($i = 2; $i < $count; $i++) {
$output .= $this->formatter->formatVar(func_get_arg($i));
}
}
return '<pre>' . $output . '</pre>';
} | [
"public",
"function",
"dump",
"(",
"Twig_Environment",
"$",
"env",
",",
"$",
"context",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"count",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"2",
"===",
"$",
"count",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"context",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"value",
",",
"'toArray'",
")",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"->",
"toArray",
"(",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"'Object ('",
".",
"get_class",
"(",
"$",
"value",
")",
".",
"')'",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"formatter",
"->",
"formatVar",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"for",
"(",
"$",
"i",
"=",
"2",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"formatter",
"->",
"formatVar",
"(",
"func_get_arg",
"(",
"$",
"i",
")",
")",
";",
"}",
"}",
"return",
"'<pre>'",
".",
"$",
"output",
".",
"'</pre>'",
";",
"}"
] | Based on Twig_Extension_Debug / twig_var_dump
(c) 2011 Fabien Potencier
@param Twig_Environment $env
@param $context
@return string | [
"Based",
"on",
"Twig_Extension_Debug",
"/",
"twig_var_dump",
"(",
"c",
")",
"2011",
"Fabien",
"Potencier"
] | train | https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/Twig/Extension/Dump.php#L59-L85 |
tequila/mongodb-odm | src/Repository/Factory/DefaultRepositoryFactory.php | DefaultRepositoryFactory.getRepository | public function getRepository(DocumentManager $documentManager, string $documentClass): Repository
{
if (!array_key_exists($documentClass, $this->repositoriesCache)) {
$metadata = $documentManager->getMetadata($documentClass);
if (null === $repositoryClass = $metadata->getRepositoryClass()) {
$repositoryClass = Repository::class;
}
$this->repositoriesCache[$documentClass] = new $repositoryClass($documentManager, $documentClass);
}
return $this->repositoriesCache[$documentClass];
} | php | public function getRepository(DocumentManager $documentManager, string $documentClass): Repository
{
if (!array_key_exists($documentClass, $this->repositoriesCache)) {
$metadata = $documentManager->getMetadata($documentClass);
if (null === $repositoryClass = $metadata->getRepositoryClass()) {
$repositoryClass = Repository::class;
}
$this->repositoriesCache[$documentClass] = new $repositoryClass($documentManager, $documentClass);
}
return $this->repositoriesCache[$documentClass];
} | [
"public",
"function",
"getRepository",
"(",
"DocumentManager",
"$",
"documentManager",
",",
"string",
"$",
"documentClass",
")",
":",
"Repository",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"documentClass",
",",
"$",
"this",
"->",
"repositoriesCache",
")",
")",
"{",
"$",
"metadata",
"=",
"$",
"documentManager",
"->",
"getMetadata",
"(",
"$",
"documentClass",
")",
";",
"if",
"(",
"null",
"===",
"$",
"repositoryClass",
"=",
"$",
"metadata",
"->",
"getRepositoryClass",
"(",
")",
")",
"{",
"$",
"repositoryClass",
"=",
"Repository",
"::",
"class",
";",
"}",
"$",
"this",
"->",
"repositoriesCache",
"[",
"$",
"documentClass",
"]",
"=",
"new",
"$",
"repositoryClass",
"(",
"$",
"documentManager",
",",
"$",
"documentClass",
")",
";",
"}",
"return",
"$",
"this",
"->",
"repositoriesCache",
"[",
"$",
"documentClass",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Repository/Factory/DefaultRepositoryFactory.php#L18-L30 |
skmetaly/laravel-twitch-restful-api | src/API/Subscriptions.php | Subscriptions.channelsSubscriptions | public function channelsSubscriptions($channel, $options = [], $token = null)
{
$availableOptions = ['limit', 'offset', 'direction'];
$query = [];
$token = $this->getToken($token);
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$query[ $option ] = $options[ $option ];
}
}
$parameters = $this->getDefaultHeaders($token);
$parameters[ 'query' ] = $query;
$response = $this->client->get('/kraken/channels/' . $channel . '/subscriptions', $parameters);
return $response->json();
} | php | public function channelsSubscriptions($channel, $options = [], $token = null)
{
$availableOptions = ['limit', 'offset', 'direction'];
$query = [];
$token = $this->getToken($token);
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$query[ $option ] = $options[ $option ];
}
}
$parameters = $this->getDefaultHeaders($token);
$parameters[ 'query' ] = $query;
$response = $this->client->get('/kraken/channels/' . $channel . '/subscriptions', $parameters);
return $response->json();
} | [
"public",
"function",
"channelsSubscriptions",
"(",
"$",
"channel",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"availableOptions",
"=",
"[",
"'limit'",
",",
"'offset'",
",",
"'direction'",
"]",
";",
"$",
"query",
"=",
"[",
"]",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"// Filter the available options",
"foreach",
"(",
"$",
"availableOptions",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"option",
"]",
")",
")",
"{",
"$",
"query",
"[",
"$",
"option",
"]",
"=",
"$",
"options",
"[",
"$",
"option",
"]",
";",
"}",
"}",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getDefaultHeaders",
"(",
"$",
"token",
")",
";",
"$",
"parameters",
"[",
"'query'",
"]",
"=",
"$",
"query",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"'/kraken/channels/'",
".",
"$",
"channel",
".",
"'/subscriptions'",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Returns a list of subscription objects sorted by subscription relationship creation date which contain users subscribed to :channel.
Authenticated, required scope: channel_subscriptions
@param $channel
@param $options
@param null $token
@return json | [
"Returns",
"a",
"list",
"of",
"subscription",
"objects",
"sorted",
"by",
"subscription",
"relationship",
"creation",
"date",
"which",
"contain",
"users",
"subscribed",
"to",
":",
"channel",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Subscriptions.php#L27-L50 |
skmetaly/laravel-twitch-restful-api | src/API/Subscriptions.php | Subscriptions.channelSubscriptionsUser | public function channelSubscriptionsUser($channel, $user, $token = null)
{
$token = $this->getToken($token);
$url = 'https://api.twitch.tv/kraken/channels/' . $channel . '/subscriptions/' . $user;
$request = $this->createRequest('GET', $url, $token);
$response = $this->client->send($request);
return $response->json();
} | php | public function channelSubscriptionsUser($channel, $user, $token = null)
{
$token = $this->getToken($token);
$url = 'https://api.twitch.tv/kraken/channels/' . $channel . '/subscriptions/' . $user;
$request = $this->createRequest('GET', $url, $token);
$response = $this->client->send($request);
return $response->json();
} | [
"public",
"function",
"channelSubscriptionsUser",
"(",
"$",
"channel",
",",
"$",
"user",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"url",
"=",
"'https://api.twitch.tv/kraken/channels/'",
".",
"$",
"channel",
".",
"'/subscriptions/'",
".",
"$",
"user",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'GET'",
",",
"$",
"url",
",",
"$",
"token",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Returns a subscription object which includes the user if that user is subscribed. Requires authentication for :channel.
Authenticated, required scope: channel_check_subscription
@param $channel
@param $user
@param null $token
@return mixed | [
"Returns",
"a",
"subscription",
"object",
"which",
"includes",
"the",
"user",
"if",
"that",
"user",
"is",
"subscribed",
".",
"Requires",
"authentication",
"for",
":",
"channel",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Subscriptions.php#L63-L73 |
zhouyl/mellivora | Mellivora/Database/Eloquent/ModelNotFoundException.php | ModelNotFoundException.setModel | public function setModel($model, $ids = [])
{
$this->model = $model;
$this->ids = array_wrap($ids);
$this->message = "No query results for model [{$model}]";
if (count($this->ids) > 0) {
$this->message .= ' ' . implode(', ', $this->ids);
} else {
$this->message .= '.';
}
return $this;
} | php | public function setModel($model, $ids = [])
{
$this->model = $model;
$this->ids = array_wrap($ids);
$this->message = "No query results for model [{$model}]";
if (count($this->ids) > 0) {
$this->message .= ' ' . implode(', ', $this->ids);
} else {
$this->message .= '.';
}
return $this;
} | [
"public",
"function",
"setModel",
"(",
"$",
"model",
",",
"$",
"ids",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"model",
";",
"$",
"this",
"->",
"ids",
"=",
"array_wrap",
"(",
"$",
"ids",
")",
";",
"$",
"this",
"->",
"message",
"=",
"\"No query results for model [{$model}]\"",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"ids",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"message",
".=",
"' '",
".",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"ids",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"message",
".=",
"'.'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the affected Eloquent model and instance ids.
@param string $model
@param array|int $ids
@return $this | [
"Set",
"the",
"affected",
"Eloquent",
"model",
"and",
"instance",
"ids",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/ModelNotFoundException.php#L31-L45 |
Erdiko/core | src/Cache.php | Cache.getCacheObject | public static function getCacheObject($cacheConfig = 'default')
{
//Check if the caller requests an new object
if (empty(static::$instance[$cacheConfig])) {
$config = Helper::getConfig('application', $cacheConfig);
//Check if the object already be created
if (isset($config["cache"][$cacheConfig])) {
static::$instance[$cacheConfig] = new $config["cache"][$cacheConfig]['class'];
} else {
throw new \Exception("There is no cache config defined ({$cacheConfig})");
}
}
return static::$instance[$cacheConfig];
} | php | public static function getCacheObject($cacheConfig = 'default')
{
//Check if the caller requests an new object
if (empty(static::$instance[$cacheConfig])) {
$config = Helper::getConfig('application', $cacheConfig);
//Check if the object already be created
if (isset($config["cache"][$cacheConfig])) {
static::$instance[$cacheConfig] = new $config["cache"][$cacheConfig]['class'];
} else {
throw new \Exception("There is no cache config defined ({$cacheConfig})");
}
}
return static::$instance[$cacheConfig];
} | [
"public",
"static",
"function",
"getCacheObject",
"(",
"$",
"cacheConfig",
"=",
"'default'",
")",
"{",
"//Check if the caller requests an new object",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"instance",
"[",
"$",
"cacheConfig",
"]",
")",
")",
"{",
"$",
"config",
"=",
"Helper",
"::",
"getConfig",
"(",
"'application'",
",",
"$",
"cacheConfig",
")",
";",
"//Check if the object already be created",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"\"cache\"",
"]",
"[",
"$",
"cacheConfig",
"]",
")",
")",
"{",
"static",
"::",
"$",
"instance",
"[",
"$",
"cacheConfig",
"]",
"=",
"new",
"$",
"config",
"[",
"\"cache\"",
"]",
"[",
"$",
"cacheConfig",
"]",
"[",
"'class'",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"There is no cache config defined ({$cacheConfig})\"",
")",
";",
"}",
"}",
"return",
"static",
"::",
"$",
"instance",
"[",
"$",
"cacheConfig",
"]",
";",
"}"
] | Get the cache instance
@param string $cacheConfig
@return object | [
"Get",
"the",
"cache",
"instance"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Cache.php#L24-L40 |
pinepain/amqpy | src/AMQPy/Serializers/SerializersPool.php | SerializersPool.register | public function register($serializer)
{
if (is_array($serializer)) {
foreach ($serializer as $s) {
$this->register($s);
}
return $this;
}
if (is_string($serializer)) {
if (!class_exists($serializer)) {
throw new SerializersPoolException("Serializer class '{$serializer}' not found");
}
$serializer = new $serializer;
}
if (!is_object($serializer)) {
$serializer_type = gettype($serializer);
throw new SerializersPoolException("Serializer should be object or class name, scalar '{$serializer_type}' given instead");
}
if (!is_subclass_of($serializer, 'AMQPy\Serializers\SerializerInterface')) {
$serializer_class = get_class($serializer);
throw new SerializersPoolException("Serializer class '{$serializer_class}' doesn't implement default serializer interface");
}
$this->registered[$serializer->getContentType()] = $serializer;
return $this;
} | php | public function register($serializer)
{
if (is_array($serializer)) {
foreach ($serializer as $s) {
$this->register($s);
}
return $this;
}
if (is_string($serializer)) {
if (!class_exists($serializer)) {
throw new SerializersPoolException("Serializer class '{$serializer}' not found");
}
$serializer = new $serializer;
}
if (!is_object($serializer)) {
$serializer_type = gettype($serializer);
throw new SerializersPoolException("Serializer should be object or class name, scalar '{$serializer_type}' given instead");
}
if (!is_subclass_of($serializer, 'AMQPy\Serializers\SerializerInterface')) {
$serializer_class = get_class($serializer);
throw new SerializersPoolException("Serializer class '{$serializer_class}' doesn't implement default serializer interface");
}
$this->registered[$serializer->getContentType()] = $serializer;
return $this;
} | [
"public",
"function",
"register",
"(",
"$",
"serializer",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"serializer",
")",
")",
"{",
"foreach",
"(",
"$",
"serializer",
"as",
"$",
"s",
")",
"{",
"$",
"this",
"->",
"register",
"(",
"$",
"s",
")",
";",
"}",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"serializer",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"serializer",
")",
")",
"{",
"throw",
"new",
"SerializersPoolException",
"(",
"\"Serializer class '{$serializer}' not found\"",
")",
";",
"}",
"$",
"serializer",
"=",
"new",
"$",
"serializer",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"serializer",
")",
")",
"{",
"$",
"serializer_type",
"=",
"gettype",
"(",
"$",
"serializer",
")",
";",
"throw",
"new",
"SerializersPoolException",
"(",
"\"Serializer should be object or class name, scalar '{$serializer_type}' given instead\"",
")",
";",
"}",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"serializer",
",",
"'AMQPy\\Serializers\\SerializerInterface'",
")",
")",
"{",
"$",
"serializer_class",
"=",
"get_class",
"(",
"$",
"serializer",
")",
";",
"throw",
"new",
"SerializersPoolException",
"(",
"\"Serializer class '{$serializer_class}' doesn't implement default serializer interface\"",
")",
";",
"}",
"$",
"this",
"->",
"registered",
"[",
"$",
"serializer",
"->",
"getContentType",
"(",
")",
"]",
"=",
"$",
"serializer",
";",
"return",
"$",
"this",
";",
"}"
] | @param array | SerializerInterface | string $serializer Serializer object or class name or their list to create serializer from
@return $this
@throws Exceptions\SerializersPoolException When try to register invalid serializer | [
"@param",
"array",
"|",
"SerializerInterface",
"|",
"string",
"$serializer",
"Serializer",
"object",
"or",
"class",
"name",
"or",
"their",
"list",
"to",
"create",
"serializer",
"from"
] | train | https://github.com/pinepain/amqpy/blob/fc61dacc37a97a100caf67232a72be32dd7cc896/src/AMQPy/Serializers/SerializersPool.php#L24-L55 |
getuisdk/getui-php-sdk | src/PBSignedInt.php | PBSignedInt.parseFromArray | public function parseFromArray()
{
parent::parseFromArray();
$saved = $this->value;
$this->value = round($this->value / 2);
if ($saved % 2 === 1) {
$this->value = -($this->value);
}
} | php | public function parseFromArray()
{
parent::parseFromArray();
$saved = $this->value;
$this->value = round($this->value / 2);
if ($saved % 2 === 1) {
$this->value = -($this->value);
}
} | [
"public",
"function",
"parseFromArray",
"(",
")",
"{",
"parent",
"::",
"parseFromArray",
"(",
")",
";",
"$",
"saved",
"=",
"$",
"this",
"->",
"value",
";",
"$",
"this",
"->",
"value",
"=",
"round",
"(",
"$",
"this",
"->",
"value",
"/",
"2",
")",
";",
"if",
"(",
"$",
"saved",
"%",
"2",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"-",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}",
"}"
] | Parses the message for this type
@param array
@throws \InvalidArgumentException | [
"Parses",
"the",
"message",
"for",
"this",
"type"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBSignedInt.php#L25-L34 |
getuisdk/getui-php-sdk | src/PBSignedInt.php | PBSignedInt.serializeToString | public function serializeToString($rec = -1)
{
// now convert signed int to int
$save = $this->value;
if ($this->value < 0) {
$this->value = abs($this->value) * 2 - 1;
} else {
$this->value *= 2;
}
$string = parent::serializeToString($rec);
// restore value
$this->value = $save;
return $string;
} | php | public function serializeToString($rec = -1)
{
// now convert signed int to int
$save = $this->value;
if ($this->value < 0) {
$this->value = abs($this->value) * 2 - 1;
} else {
$this->value *= 2;
}
$string = parent::serializeToString($rec);
// restore value
$this->value = $save;
return $string;
} | [
"public",
"function",
"serializeToString",
"(",
"$",
"rec",
"=",
"-",
"1",
")",
"{",
"// now convert signed int to int\r",
"$",
"save",
"=",
"$",
"this",
"->",
"value",
";",
"if",
"(",
"$",
"this",
"->",
"value",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"abs",
"(",
"$",
"this",
"->",
"value",
")",
"*",
"2",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"value",
"*=",
"2",
";",
"}",
"$",
"string",
"=",
"parent",
"::",
"serializeToString",
"(",
"$",
"rec",
")",
";",
"// restore value\r",
"$",
"this",
"->",
"value",
"=",
"$",
"save",
";",
"return",
"$",
"string",
";",
"}"
] | Serializes type
@param mixed $rec
@return mixed | [
"Serializes",
"type"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBSignedInt.php#L41-L55 |
madkom/regex | src/Replacer.php | Replacer.replace | public function replace(string $subject, string $replacement, int $limit = -1, int &$count = null) : string
{
$result = preg_replace($this->pattern->getPattern() . $this->modifier, $replacement, $subject, $limit, $count);
if (($errno = preg_last_error()) !== PREG_NO_ERROR) {
$message = array_flip(get_defined_constants(true)['pcre'])[$errno];
switch ($errno) {
case PREG_INTERNAL_ERROR:
throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BACKTRACK_LIMIT_ERROR:
throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_RECURSION_LIMIT_ERROR:
throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_ERROR:
throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_OFFSET_ERROR:
throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_JIT_STACKLIMIT_ERROR:
throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
}
}
return $result;
} | php | public function replace(string $subject, string $replacement, int $limit = -1, int &$count = null) : string
{
$result = preg_replace($this->pattern->getPattern() . $this->modifier, $replacement, $subject, $limit, $count);
if (($errno = preg_last_error()) !== PREG_NO_ERROR) {
$message = array_flip(get_defined_constants(true)['pcre'])[$errno];
switch ($errno) {
case PREG_INTERNAL_ERROR:
throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BACKTRACK_LIMIT_ERROR:
throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_RECURSION_LIMIT_ERROR:
throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_ERROR:
throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_OFFSET_ERROR:
throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_JIT_STACKLIMIT_ERROR:
throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
}
}
return $result;
} | [
"public",
"function",
"replace",
"(",
"string",
"$",
"subject",
",",
"string",
"$",
"replacement",
",",
"int",
"$",
"limit",
"=",
"-",
"1",
",",
"int",
"&",
"$",
"count",
"=",
"null",
")",
":",
"string",
"{",
"$",
"result",
"=",
"preg_replace",
"(",
"$",
"this",
"->",
"pattern",
"->",
"getPattern",
"(",
")",
".",
"$",
"this",
"->",
"modifier",
",",
"$",
"replacement",
",",
"$",
"subject",
",",
"$",
"limit",
",",
"$",
"count",
")",
";",
"if",
"(",
"(",
"$",
"errno",
"=",
"preg_last_error",
"(",
")",
")",
"!==",
"PREG_NO_ERROR",
")",
"{",
"$",
"message",
"=",
"array_flip",
"(",
"get_defined_constants",
"(",
"true",
")",
"[",
"'pcre'",
"]",
")",
"[",
"$",
"errno",
"]",
";",
"switch",
"(",
"$",
"errno",
")",
"{",
"case",
"PREG_INTERNAL_ERROR",
":",
"throw",
"new",
"InternalException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_BACKTRACK_LIMIT_ERROR",
":",
"throw",
"new",
"BacktrackLimitException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_RECURSION_LIMIT_ERROR",
":",
"throw",
"new",
"RecursionLimitException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_BAD_UTF8_ERROR",
":",
"throw",
"new",
"BadUtf8Exception",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_BAD_UTF8_OFFSET_ERROR",
":",
"throw",
"new",
"BadUtf8OffsetException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_JIT_STACKLIMIT_ERROR",
":",
"throw",
"new",
"JitStackLimitException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Retrieve replaced subject with replacement
@param string $subject
@param string $replacement
@param int $limit
@param int|null $count
@return string
@throws BacktrackLimitException
@throws BadUtf8Exception
@throws BadUtf8OffsetException
@throws InternalException
@throws JitStackLimitException
@throws RecursionLimitException | [
"Retrieve",
"replaced",
"subject",
"with",
"replacement"
] | train | https://github.com/madkom/regex/blob/798c1124805b130b1110ee6e8dcc9a88d8aaffa8/src/Replacer.php#L58-L81 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php | ezcBaseMetaDataPearReader.getRequiredPhpVersion | public function getRequiredPhpVersion()
{
@$packageInfo = $this->registry->packageInfo( 'ezcomponents', null, 'components.ez.no' );
if ( array_key_exists( 'required', $packageInfo['dependencies'] ) )
{
return $packageInfo['dependencies']['required']['php']['min'];
}
return $packageInfo['dependencies']['php']['min'];
} | php | public function getRequiredPhpVersion()
{
@$packageInfo = $this->registry->packageInfo( 'ezcomponents', null, 'components.ez.no' );
if ( array_key_exists( 'required', $packageInfo['dependencies'] ) )
{
return $packageInfo['dependencies']['required']['php']['min'];
}
return $packageInfo['dependencies']['php']['min'];
} | [
"public",
"function",
"getRequiredPhpVersion",
"(",
")",
"{",
"@",
"$",
"packageInfo",
"=",
"$",
"this",
"->",
"registry",
"->",
"packageInfo",
"(",
"'ezcomponents'",
",",
"null",
",",
"'components.ez.no'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'required'",
",",
"$",
"packageInfo",
"[",
"'dependencies'",
"]",
")",
")",
"{",
"return",
"$",
"packageInfo",
"[",
"'dependencies'",
"]",
"[",
"'required'",
"]",
"[",
"'php'",
"]",
"[",
"'min'",
"]",
";",
"}",
"return",
"$",
"packageInfo",
"[",
"'dependencies'",
"]",
"[",
"'php'",
"]",
"[",
"'min'",
"]",
";",
"}"
] | Returns a PHP version string that describes the required PHP version for
this installed eZ Components bundle.
@return string | [
"Returns",
"a",
"PHP",
"version",
"string",
"that",
"describes",
"the",
"required",
"PHP",
"version",
"for",
"this",
"installed",
"eZ",
"Components",
"bundle",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php#L61-L69 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php | ezcBaseMetaDataPearReader.isComponentInstalled | public function isComponentInstalled( $componentName )
{
@$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' );
return is_array( $packageInfo );
} | php | public function isComponentInstalled( $componentName )
{
@$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' );
return is_array( $packageInfo );
} | [
"public",
"function",
"isComponentInstalled",
"(",
"$",
"componentName",
")",
"{",
"@",
"$",
"packageInfo",
"=",
"$",
"this",
"->",
"registry",
"->",
"packageInfo",
"(",
"$",
"componentName",
",",
"null",
",",
"'components.ez.no'",
")",
";",
"return",
"is_array",
"(",
"$",
"packageInfo",
")",
";",
"}"
] | Returns whether $componentName is installed
Checks the PEAR registry whether the component is there.
@return bool | [
"Returns",
"whether",
"$componentName",
"is",
"installed"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php#L78-L82 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php | ezcBaseMetaDataPearReader.getComponentVersion | public function getComponentVersion( $componentName )
{
@$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' );
$release = $packageInfo['version']['release'];
return $release === null ? false : $release;
} | php | public function getComponentVersion( $componentName )
{
@$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' );
$release = $packageInfo['version']['release'];
return $release === null ? false : $release;
} | [
"public",
"function",
"getComponentVersion",
"(",
"$",
"componentName",
")",
"{",
"@",
"$",
"packageInfo",
"=",
"$",
"this",
"->",
"registry",
"->",
"packageInfo",
"(",
"$",
"componentName",
",",
"null",
",",
"'components.ez.no'",
")",
";",
"$",
"release",
"=",
"$",
"packageInfo",
"[",
"'version'",
"]",
"[",
"'release'",
"]",
";",
"return",
"$",
"release",
"===",
"null",
"?",
"false",
":",
"$",
"release",
";",
"}"
] | Returns the version string of the available $componentName or false when
the component is not installed.
@return string | [
"Returns",
"the",
"version",
"string",
"of",
"the",
"available",
"$componentName",
"or",
"false",
"when",
"the",
"component",
"is",
"not",
"installed",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php#L90-L95 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php | ezcBaseMetaDataPearReader.getComponentDependencies | public function getComponentDependencies( $componentName = 'ezcomponents' )
{
@$packageInfo = $this->registry->packageInfo( $componentName, 'dependencies', 'components.ez.no' );
if ( isset( $packageInfo['required']['package'] ) )
{
$deps = array();
if ( isset( $packageInfo['required']['package']['name'] ) )
{
$deps[$packageInfo['required']['package']['name']] = $packageInfo['required']['package']['min'];
}
else
{
foreach ( $packageInfo['required']['package'] as $package )
{
$deps[$package['name']] = $package['min'];
}
}
return $deps;
}
return array();
} | php | public function getComponentDependencies( $componentName = 'ezcomponents' )
{
@$packageInfo = $this->registry->packageInfo( $componentName, 'dependencies', 'components.ez.no' );
if ( isset( $packageInfo['required']['package'] ) )
{
$deps = array();
if ( isset( $packageInfo['required']['package']['name'] ) )
{
$deps[$packageInfo['required']['package']['name']] = $packageInfo['required']['package']['min'];
}
else
{
foreach ( $packageInfo['required']['package'] as $package )
{
$deps[$package['name']] = $package['min'];
}
}
return $deps;
}
return array();
} | [
"public",
"function",
"getComponentDependencies",
"(",
"$",
"componentName",
"=",
"'ezcomponents'",
")",
"{",
"@",
"$",
"packageInfo",
"=",
"$",
"this",
"->",
"registry",
"->",
"packageInfo",
"(",
"$",
"componentName",
",",
"'dependencies'",
",",
"'components.ez.no'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"packageInfo",
"[",
"'required'",
"]",
"[",
"'package'",
"]",
")",
")",
"{",
"$",
"deps",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"packageInfo",
"[",
"'required'",
"]",
"[",
"'package'",
"]",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"deps",
"[",
"$",
"packageInfo",
"[",
"'required'",
"]",
"[",
"'package'",
"]",
"[",
"'name'",
"]",
"]",
"=",
"$",
"packageInfo",
"[",
"'required'",
"]",
"[",
"'package'",
"]",
"[",
"'min'",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"packageInfo",
"[",
"'required'",
"]",
"[",
"'package'",
"]",
"as",
"$",
"package",
")",
"{",
"$",
"deps",
"[",
"$",
"package",
"[",
"'name'",
"]",
"]",
"=",
"$",
"package",
"[",
"'min'",
"]",
";",
"}",
"}",
"return",
"$",
"deps",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
] | Returns a list of components that $componentName depends on.
If $componentName is left empty, all installed components are returned.
The returned array has as keys the component names, and as values the
version of the components.
@return array(string=>string). | [
"Returns",
"a",
"list",
"of",
"components",
"that",
"$componentName",
"depends",
"on",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/pear.php#L107-L127 |
trunda/SmfMenu | src/Smf/Menu/Control/MenuControl.php | MenuControl.getRoot | public function getRoot()
{
if ($this->root === null) {
$this->root = $this->menuFactory->createItem($this->getName());
}
return $this->root;
} | php | public function getRoot()
{
if ($this->root === null) {
$this->root = $this->menuFactory->createItem($this->getName());
}
return $this->root;
} | [
"public",
"function",
"getRoot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"root",
"=",
"$",
"this",
"->",
"menuFactory",
"->",
"createItem",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"root",
";",
"}"
] | Returns root item
@return \Knp\Menu\ItemInterface | [
"Returns",
"root",
"item"
] | train | https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Control/MenuControl.php#L53-L59 |
alevilar/ristorantino-vendor | Risto/Model/RistoBaseSchema.php | RistoBaseSchema.__getDefaultValues | public function __getDefaultValues ( $tableName ) {
$values = $this->__defaultValues;
if ( $values && $tableName && array_key_exists( $tableName, $values )) {
return $values[$tableName];
} else {
return false;
}
} | php | public function __getDefaultValues ( $tableName ) {
$values = $this->__defaultValues;
if ( $values && $tableName && array_key_exists( $tableName, $values )) {
return $values[$tableName];
} else {
return false;
}
} | [
"public",
"function",
"__getDefaultValues",
"(",
"$",
"tableName",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"__defaultValues",
";",
"if",
"(",
"$",
"values",
"&&",
"$",
"tableName",
"&&",
"array_key_exists",
"(",
"$",
"tableName",
",",
"$",
"values",
")",
")",
"{",
"return",
"$",
"values",
"[",
"$",
"tableName",
"]",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | *
Devuelve los valores al ejecutar "SCHEMA CREATE"
@param string $tablename Nombre de la tabla
@return array listado de valores a insertar en la tabla para hacer el saveAll | [
"*"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Model/RistoBaseSchema.php#L73-L81 |
husccexo/php-handlersocket-core | src/HSCore/HandlerSocket.php | HandlerSocket.showLogs | public function showLogs()
{
$logs = $this->getLogs();
$result = array_map(function($array) {
$data = [];
$time = 0;
foreach ($array as $row) {
$data[] = $row['type'].chr(9).number_format($row['time'], 5).chr(9).':'.chr(9).rtrim($row['command']);
$time += $row['time'];
}
return [
'data' => join(PHP_EOL, $data),
'totalTime' => number_format($time, 5)
];
}, $logs);
foreach ($result as $socket => $row) {
echo PHP_EOL.PHP_EOL.$socket.' (total time: '.$row['totalTime'].')'.PHP_EOL.PHP_EOL.$row['data'].PHP_EOL;
}
} | php | public function showLogs()
{
$logs = $this->getLogs();
$result = array_map(function($array) {
$data = [];
$time = 0;
foreach ($array as $row) {
$data[] = $row['type'].chr(9).number_format($row['time'], 5).chr(9).':'.chr(9).rtrim($row['command']);
$time += $row['time'];
}
return [
'data' => join(PHP_EOL, $data),
'totalTime' => number_format($time, 5)
];
}, $logs);
foreach ($result as $socket => $row) {
echo PHP_EOL.PHP_EOL.$socket.' (total time: '.$row['totalTime'].')'.PHP_EOL.PHP_EOL.$row['data'].PHP_EOL;
}
} | [
"public",
"function",
"showLogs",
"(",
")",
"{",
"$",
"logs",
"=",
"$",
"this",
"->",
"getLogs",
"(",
")",
";",
"$",
"result",
"=",
"array_map",
"(",
"function",
"(",
"$",
"array",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"time",
"=",
"0",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"row",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"row",
"[",
"'type'",
"]",
".",
"chr",
"(",
"9",
")",
".",
"number_format",
"(",
"$",
"row",
"[",
"'time'",
"]",
",",
"5",
")",
".",
"chr",
"(",
"9",
")",
".",
"':'",
".",
"chr",
"(",
"9",
")",
".",
"rtrim",
"(",
"$",
"row",
"[",
"'command'",
"]",
")",
";",
"$",
"time",
"+=",
"$",
"row",
"[",
"'time'",
"]",
";",
"}",
"return",
"[",
"'data'",
"=>",
"join",
"(",
"PHP_EOL",
",",
"$",
"data",
")",
",",
"'totalTime'",
"=>",
"number_format",
"(",
"$",
"time",
",",
"5",
")",
"]",
";",
"}",
",",
"$",
"logs",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"socket",
"=>",
"$",
"row",
")",
"{",
"echo",
"PHP_EOL",
".",
"PHP_EOL",
".",
"$",
"socket",
".",
"' (total time: '",
".",
"$",
"row",
"[",
"'totalTime'",
"]",
".",
"')'",
".",
"PHP_EOL",
".",
"PHP_EOL",
".",
"$",
"row",
"[",
"'data'",
"]",
".",
"PHP_EOL",
";",
"}",
"}"
] | Print logs | [
"Print",
"logs"
] | train | https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/HandlerSocket.php#L126-L148 |
uniondrug/http | src/SwooleServerRequest.php | SwooleServerRequest.createServerRequestFromSwoole | public static function createServerRequestFromSwoole(swoole_http_request $request)
{
$get = isset($request->get) ? $request->get : [];
$post = isset($request->post) ? $request->post : [];
$cookie = isset($request->cookie) ? $request->cookie : [];
$files = isset($request->files) ? $request->files : [];
$host = '::1';
foreach (['host', 'server_addr'] as $name) {
if (!empty($request->header[$name])) {
$host = parse_url($request->header[$name], PHP_URL_HOST) ?: $request->header[$name];
}
}
$server = [
'REQUEST_METHOD' => $request->server['request_method'],
'REQUEST_URI' => $request->server['request_uri'],
'PATH_INFO' => $request->server['path_info'],
'REQUEST_TIME' => $request->server['request_time'],
'GATEWAY_INTERFACE' => 'swoole/' . SWOOLE_VERSION,
// Server
'SERVER_PROTOCOL' => isset($request->header['server_protocol']) ? $request->header['server_protocol'] : $request->server['server_protocol'],
'REQUEST_SCHEMA' => isset($request->header['request_scheme']) ? $request->header['request_scheme'] : explode('/', $request->server['server_protocol'])[0],
'SERVER_NAME' => isset($request->header['server_name']) ? $request->header['server_name'] : $host,
'SERVER_ADDR' => $host,
'SERVER_PORT' => isset($request->header['server_port']) ? $request->header['server_port'] : $request->server['server_port'],
'REMOTE_ADDR' => $host,
'REMOTE_PORT' => isset($request->header['remote_port']) ? $request->header['remote_port'] : $request->server['remote_port'],
'QUERY_STRING' => isset($request->server['query_string']) ? $request->server['query_string'] : '',
// Headers
'HTTP_HOST' => $host,
'HTTP_USER_AGENT' => isset($request->header['user-agent']) ? $request->header['user-agent'] : '',
'HTTP_ACCEPT' => isset($request->header['accept']) ? $request->header['accept'] : '*/*',
'HTTP_ACCEPT_LANGUAGE' => isset($request->header['accept-language']) ? $request->header['accept-language'] : '',
'HTTP_ACCEPT_ENCODING' => isset($request->header['accept-encoding']) ? $request->header['accept-encoding'] : '',
'HTTP_CONNECTION' => isset($request->header['connection']) ? $request->header['connection'] : '',
'HTTP_CACHE_CONTROL' => isset($request->header['cache-control']) ? $request->header['cache-control'] : '',
];
$headers = [];
foreach ($request->header as $name => $value) {
$headers[str_replace('-', '_', $name)] = $value;
}
$serverRequest = new ServerRequest(
$server['REQUEST_METHOD'],
static::createUriFromGlobal($server),
$headers,
null,
$server
);
unset($headers);
$serverRequest->getBody()->write($request->rawContent());
return $serverRequest
->withParsedBody($post)
->withQueryParams($get)
->withCookieParams($cookie)
->withUploadedFiles($files);
} | php | public static function createServerRequestFromSwoole(swoole_http_request $request)
{
$get = isset($request->get) ? $request->get : [];
$post = isset($request->post) ? $request->post : [];
$cookie = isset($request->cookie) ? $request->cookie : [];
$files = isset($request->files) ? $request->files : [];
$host = '::1';
foreach (['host', 'server_addr'] as $name) {
if (!empty($request->header[$name])) {
$host = parse_url($request->header[$name], PHP_URL_HOST) ?: $request->header[$name];
}
}
$server = [
'REQUEST_METHOD' => $request->server['request_method'],
'REQUEST_URI' => $request->server['request_uri'],
'PATH_INFO' => $request->server['path_info'],
'REQUEST_TIME' => $request->server['request_time'],
'GATEWAY_INTERFACE' => 'swoole/' . SWOOLE_VERSION,
// Server
'SERVER_PROTOCOL' => isset($request->header['server_protocol']) ? $request->header['server_protocol'] : $request->server['server_protocol'],
'REQUEST_SCHEMA' => isset($request->header['request_scheme']) ? $request->header['request_scheme'] : explode('/', $request->server['server_protocol'])[0],
'SERVER_NAME' => isset($request->header['server_name']) ? $request->header['server_name'] : $host,
'SERVER_ADDR' => $host,
'SERVER_PORT' => isset($request->header['server_port']) ? $request->header['server_port'] : $request->server['server_port'],
'REMOTE_ADDR' => $host,
'REMOTE_PORT' => isset($request->header['remote_port']) ? $request->header['remote_port'] : $request->server['remote_port'],
'QUERY_STRING' => isset($request->server['query_string']) ? $request->server['query_string'] : '',
// Headers
'HTTP_HOST' => $host,
'HTTP_USER_AGENT' => isset($request->header['user-agent']) ? $request->header['user-agent'] : '',
'HTTP_ACCEPT' => isset($request->header['accept']) ? $request->header['accept'] : '*/*',
'HTTP_ACCEPT_LANGUAGE' => isset($request->header['accept-language']) ? $request->header['accept-language'] : '',
'HTTP_ACCEPT_ENCODING' => isset($request->header['accept-encoding']) ? $request->header['accept-encoding'] : '',
'HTTP_CONNECTION' => isset($request->header['connection']) ? $request->header['connection'] : '',
'HTTP_CACHE_CONTROL' => isset($request->header['cache-control']) ? $request->header['cache-control'] : '',
];
$headers = [];
foreach ($request->header as $name => $value) {
$headers[str_replace('-', '_', $name)] = $value;
}
$serverRequest = new ServerRequest(
$server['REQUEST_METHOD'],
static::createUriFromGlobal($server),
$headers,
null,
$server
);
unset($headers);
$serverRequest->getBody()->write($request->rawContent());
return $serverRequest
->withParsedBody($post)
->withQueryParams($get)
->withCookieParams($cookie)
->withUploadedFiles($files);
} | [
"public",
"static",
"function",
"createServerRequestFromSwoole",
"(",
"swoole_http_request",
"$",
"request",
")",
"{",
"$",
"get",
"=",
"isset",
"(",
"$",
"request",
"->",
"get",
")",
"?",
"$",
"request",
"->",
"get",
":",
"[",
"]",
";",
"$",
"post",
"=",
"isset",
"(",
"$",
"request",
"->",
"post",
")",
"?",
"$",
"request",
"->",
"post",
":",
"[",
"]",
";",
"$",
"cookie",
"=",
"isset",
"(",
"$",
"request",
"->",
"cookie",
")",
"?",
"$",
"request",
"->",
"cookie",
":",
"[",
"]",
";",
"$",
"files",
"=",
"isset",
"(",
"$",
"request",
"->",
"files",
")",
"?",
"$",
"request",
"->",
"files",
":",
"[",
"]",
";",
"$",
"host",
"=",
"'::1'",
";",
"foreach",
"(",
"[",
"'host'",
",",
"'server_addr'",
"]",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"request",
"->",
"header",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"host",
"=",
"parse_url",
"(",
"$",
"request",
"->",
"header",
"[",
"$",
"name",
"]",
",",
"PHP_URL_HOST",
")",
"?",
":",
"$",
"request",
"->",
"header",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"$",
"server",
"=",
"[",
"'REQUEST_METHOD'",
"=>",
"$",
"request",
"->",
"server",
"[",
"'request_method'",
"]",
",",
"'REQUEST_URI'",
"=>",
"$",
"request",
"->",
"server",
"[",
"'request_uri'",
"]",
",",
"'PATH_INFO'",
"=>",
"$",
"request",
"->",
"server",
"[",
"'path_info'",
"]",
",",
"'REQUEST_TIME'",
"=>",
"$",
"request",
"->",
"server",
"[",
"'request_time'",
"]",
",",
"'GATEWAY_INTERFACE'",
"=>",
"'swoole/'",
".",
"SWOOLE_VERSION",
",",
"// Server",
"'SERVER_PROTOCOL'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'server_protocol'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'server_protocol'",
"]",
":",
"$",
"request",
"->",
"server",
"[",
"'server_protocol'",
"]",
",",
"'REQUEST_SCHEMA'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'request_scheme'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'request_scheme'",
"]",
":",
"explode",
"(",
"'/'",
",",
"$",
"request",
"->",
"server",
"[",
"'server_protocol'",
"]",
")",
"[",
"0",
"]",
",",
"'SERVER_NAME'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'server_name'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'server_name'",
"]",
":",
"$",
"host",
",",
"'SERVER_ADDR'",
"=>",
"$",
"host",
",",
"'SERVER_PORT'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'server_port'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'server_port'",
"]",
":",
"$",
"request",
"->",
"server",
"[",
"'server_port'",
"]",
",",
"'REMOTE_ADDR'",
"=>",
"$",
"host",
",",
"'REMOTE_PORT'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'remote_port'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'remote_port'",
"]",
":",
"$",
"request",
"->",
"server",
"[",
"'remote_port'",
"]",
",",
"'QUERY_STRING'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"server",
"[",
"'query_string'",
"]",
")",
"?",
"$",
"request",
"->",
"server",
"[",
"'query_string'",
"]",
":",
"''",
",",
"// Headers",
"'HTTP_HOST'",
"=>",
"$",
"host",
",",
"'HTTP_USER_AGENT'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'user-agent'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'user-agent'",
"]",
":",
"''",
",",
"'HTTP_ACCEPT'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'accept'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'accept'",
"]",
":",
"'*/*'",
",",
"'HTTP_ACCEPT_LANGUAGE'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'accept-language'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'accept-language'",
"]",
":",
"''",
",",
"'HTTP_ACCEPT_ENCODING'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'accept-encoding'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'accept-encoding'",
"]",
":",
"''",
",",
"'HTTP_CONNECTION'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'connection'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'connection'",
"]",
":",
"''",
",",
"'HTTP_CACHE_CONTROL'",
"=>",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'cache-control'",
"]",
")",
"?",
"$",
"request",
"->",
"header",
"[",
"'cache-control'",
"]",
":",
"''",
",",
"]",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"request",
"->",
"header",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"headers",
"[",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"$",
"name",
")",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"serverRequest",
"=",
"new",
"ServerRequest",
"(",
"$",
"server",
"[",
"'REQUEST_METHOD'",
"]",
",",
"static",
"::",
"createUriFromGlobal",
"(",
"$",
"server",
")",
",",
"$",
"headers",
",",
"null",
",",
"$",
"server",
")",
";",
"unset",
"(",
"$",
"headers",
")",
";",
"$",
"serverRequest",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"$",
"request",
"->",
"rawContent",
"(",
")",
")",
";",
"return",
"$",
"serverRequest",
"->",
"withParsedBody",
"(",
"$",
"post",
")",
"->",
"withQueryParams",
"(",
"$",
"get",
")",
"->",
"withCookieParams",
"(",
"$",
"cookie",
")",
"->",
"withUploadedFiles",
"(",
"$",
"files",
")",
";",
"}"
] | @param swoole_http_request $request
@return ServerRequestInterface | [
"@param",
"swoole_http_request",
"$request"
] | train | https://github.com/uniondrug/http/blob/d650af25bd4587499befa76081a8fe8275431320/src/SwooleServerRequest.php#L27-L87 |
99designs/ergo-http | src/ResponseSender.php | ResponseSender.send | public function send()
{
$response = $this->_response;
header($response->getStatus()->__toString());
foreach ($response->getHeaders() as $headerField)
header($headerField);
if ($response->hasBody()) echo $response->getBody();
} | php | public function send()
{
$response = $this->_response;
header($response->getStatus()->__toString());
foreach ($response->getHeaders() as $headerField)
header($headerField);
if ($response->hasBody()) echo $response->getBody();
} | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_response",
";",
"header",
"(",
"$",
"response",
"->",
"getStatus",
"(",
")",
"->",
"__toString",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"headerField",
")",
"header",
"(",
"$",
"headerField",
")",
";",
"if",
"(",
"$",
"response",
"->",
"hasBody",
"(",
")",
")",
"echo",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}"
] | Sends the headers and body. | [
"Sends",
"the",
"headers",
"and",
"body",
"."
] | train | https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/ResponseSender.php#L24-L33 |
shubinmi/helpers | src/hydrators/ConstructFromArrayOrJson.php | ConstructFromArrayOrJson.toArray | public function toArray($withNull = false)
{
$result = [];
foreach (get_object_vars($this) as $property => $value) {
$getter = 'get' . str_replace('_', '', $property);
if (method_exists($this, $getter)) {
$result[$property] = $this->{$getter}();
} else {
$result[$property] = $this->{$property};
}
}
if ($withNull) {
return $result;
}
return array_filter(
$result, function ($value) {
return isset($value);
}
);
} | php | public function toArray($withNull = false)
{
$result = [];
foreach (get_object_vars($this) as $property => $value) {
$getter = 'get' . str_replace('_', '', $property);
if (method_exists($this, $getter)) {
$result[$property] = $this->{$getter}();
} else {
$result[$property] = $this->{$property};
}
}
if ($withNull) {
return $result;
}
return array_filter(
$result, function ($value) {
return isset($value);
}
);
} | [
"public",
"function",
"toArray",
"(",
"$",
"withNull",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"getter",
"=",
"'get'",
".",
"str_replace",
"(",
"'_'",
",",
"''",
",",
"$",
"property",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"getter",
")",
")",
"{",
"$",
"result",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"getter",
"}",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"property",
"}",
";",
"}",
"}",
"if",
"(",
"$",
"withNull",
")",
"{",
"return",
"$",
"result",
";",
"}",
"return",
"array_filter",
"(",
"$",
"result",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"isset",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
] | @param bool $withNull
@return array | [
"@param",
"bool",
"$withNull"
] | train | https://github.com/shubinmi/helpers/blob/afb7e87746ffa7964411a452598fa45154f59082/src/hydrators/ConstructFromArrayOrJson.php#L33-L53 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.applyParts | private function applyParts(array $parts = [])
{
$this->scheme = array_key_exists('scheme', $parts) ? $this->filterScheme($parts['scheme']) : null;
$this->userInfo = array_key_exists('user', $parts) ? $parts['user'] : null;
$this->host = array_key_exists('host', $parts) ? $parts['host'] : null;
$this->port = array_key_exists('port', $parts) ? $this->filterPort($this->getScheme(), $this->getHost(), $parts['port']) : null;
$this->path = array_key_exists('path', $parts) ? $this->filterPath($parts['path']) : null;
$this->query = array_key_exists('query', $parts) ? $this->filterQueryAndFragment($parts['query']) : null;
$this->fragment = array_key_exists('fragment', $parts) ? $this->filterQueryAndFragment($parts['fragment']) : null;
$this->userInfo .= array_key_exists('pass', $parts) ? ':' . $parts['pass'] : null;
} | php | private function applyParts(array $parts = [])
{
$this->scheme = array_key_exists('scheme', $parts) ? $this->filterScheme($parts['scheme']) : null;
$this->userInfo = array_key_exists('user', $parts) ? $parts['user'] : null;
$this->host = array_key_exists('host', $parts) ? $parts['host'] : null;
$this->port = array_key_exists('port', $parts) ? $this->filterPort($this->getScheme(), $this->getHost(), $parts['port']) : null;
$this->path = array_key_exists('path', $parts) ? $this->filterPath($parts['path']) : null;
$this->query = array_key_exists('query', $parts) ? $this->filterQueryAndFragment($parts['query']) : null;
$this->fragment = array_key_exists('fragment', $parts) ? $this->filterQueryAndFragment($parts['fragment']) : null;
$this->userInfo .= array_key_exists('pass', $parts) ? ':' . $parts['pass'] : null;
} | [
"private",
"function",
"applyParts",
"(",
"array",
"$",
"parts",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"scheme",
"=",
"array_key_exists",
"(",
"'scheme'",
",",
"$",
"parts",
")",
"?",
"$",
"this",
"->",
"filterScheme",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"userInfo",
"=",
"array_key_exists",
"(",
"'user'",
",",
"$",
"parts",
")",
"?",
"$",
"parts",
"[",
"'user'",
"]",
":",
"null",
";",
"$",
"this",
"->",
"host",
"=",
"array_key_exists",
"(",
"'host'",
",",
"$",
"parts",
")",
"?",
"$",
"parts",
"[",
"'host'",
"]",
":",
"null",
";",
"$",
"this",
"->",
"port",
"=",
"array_key_exists",
"(",
"'port'",
",",
"$",
"parts",
")",
"?",
"$",
"this",
"->",
"filterPort",
"(",
"$",
"this",
"->",
"getScheme",
"(",
")",
",",
"$",
"this",
"->",
"getHost",
"(",
")",
",",
"$",
"parts",
"[",
"'port'",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"path",
"=",
"array_key_exists",
"(",
"'path'",
",",
"$",
"parts",
")",
"?",
"$",
"this",
"->",
"filterPath",
"(",
"$",
"parts",
"[",
"'path'",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"query",
"=",
"array_key_exists",
"(",
"'query'",
",",
"$",
"parts",
")",
"?",
"$",
"this",
"->",
"filterQueryAndFragment",
"(",
"$",
"parts",
"[",
"'query'",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"fragment",
"=",
"array_key_exists",
"(",
"'fragment'",
",",
"$",
"parts",
")",
"?",
"$",
"this",
"->",
"filterQueryAndFragment",
"(",
"$",
"parts",
"[",
"'fragment'",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"userInfo",
".=",
"array_key_exists",
"(",
"'pass'",
",",
"$",
"parts",
")",
"?",
"':'",
".",
"$",
"parts",
"[",
"'pass'",
"]",
":",
"null",
";",
"}"
] | Apply parse_url parts to a URI.
@param $parts array of parse_url parts to apply.
@throws \InvalidArgumentException | [
"Apply",
"parse_url",
"parts",
"to",
"a",
"URI",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L113-L123 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.filterPort | private function filterPort($scheme, $host, $port)
{
if (null !== $port) {
$port = (int) $port;
if (1 > $port || 65535 < $port) {
throw new \InvalidArgumentException(sprintf('Invalid port: %d. Must be between 1 and 65535', $port));
}
}
return self::isStandardPort($port, (string) $scheme, (string) $host) ? null : $port;
} | php | private function filterPort($scheme, $host, $port)
{
if (null !== $port) {
$port = (int) $port;
if (1 > $port || 65535 < $port) {
throw new \InvalidArgumentException(sprintf('Invalid port: %d. Must be between 1 and 65535', $port));
}
}
return self::isStandardPort($port, (string) $scheme, (string) $host) ? null : $port;
} | [
"private",
"function",
"filterPort",
"(",
"$",
"scheme",
",",
"$",
"host",
",",
"$",
"port",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"port",
")",
"{",
"$",
"port",
"=",
"(",
"int",
")",
"$",
"port",
";",
"if",
"(",
"1",
">",
"$",
"port",
"||",
"65535",
"<",
"$",
"port",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid port: %d. Must be between 1 and 65535'",
",",
"$",
"port",
")",
")",
";",
"}",
"}",
"return",
"self",
"::",
"isStandardPort",
"(",
"$",
"port",
",",
"(",
"string",
")",
"$",
"scheme",
",",
"(",
"string",
")",
"$",
"host",
")",
"?",
"null",
":",
"$",
"port",
";",
"}"
] | Filter port before setting it.
@param string $scheme
@param string $host
@param int $port
@return int|null
@throws \InvalidArgumentException if the port is invalid. | [
"Filter",
"port",
"before",
"setting",
"it",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L151-L161 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.isStandardPort | private static function isStandardPort($port, $scheme = null, $host = null)
{
if ($host === null || $scheme === null) {
return false;
}
return array_key_exists($scheme, static::$schemes) && $port === static::$schemes[$scheme];
} | php | private static function isStandardPort($port, $scheme = null, $host = null)
{
if ($host === null || $scheme === null) {
return false;
}
return array_key_exists($scheme, static::$schemes) && $port === static::$schemes[$scheme];
} | [
"private",
"static",
"function",
"isStandardPort",
"(",
"$",
"port",
",",
"$",
"scheme",
"=",
"null",
",",
"$",
"host",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"host",
"===",
"null",
"||",
"$",
"scheme",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"array_key_exists",
"(",
"$",
"scheme",
",",
"static",
"::",
"$",
"schemes",
")",
"&&",
"$",
"port",
"===",
"static",
"::",
"$",
"schemes",
"[",
"$",
"scheme",
"]",
";",
"}"
] | Is a given port standard for the current scheme?
@param int $port
@param string $scheme
@param string $host
@return bool | [
"Is",
"a",
"given",
"port",
"standard",
"for",
"the",
"current",
"scheme?"
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L172-L179 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.withQueryValue | public static function withQueryValue(UriInterface $uri, $key, $value)
{
$current = $uri->getQuery();
$key = rawurlencode($key);
$value = rawurlencode($value);
$result = [];
if ($current !== null) {
foreach (explode('&', $current) as $part) {
if (explode('=', $part)[0] !== $key) {
$result[] = $part;
}
}
}
$result[] = ($value !== '') ? $key . '=' . $value : $key;
return $uri->withQuery(implode('&', $result));
} | php | public static function withQueryValue(UriInterface $uri, $key, $value)
{
$current = $uri->getQuery();
$key = rawurlencode($key);
$value = rawurlencode($value);
$result = [];
if ($current !== null) {
foreach (explode('&', $current) as $part) {
if (explode('=', $part)[0] !== $key) {
$result[] = $part;
}
}
}
$result[] = ($value !== '') ? $key . '=' . $value : $key;
return $uri->withQuery(implode('&', $result));
} | [
"public",
"static",
"function",
"withQueryValue",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"current",
"=",
"$",
"uri",
"->",
"getQuery",
"(",
")",
";",
"$",
"key",
"=",
"rawurlencode",
"(",
"$",
"key",
")",
";",
"$",
"value",
"=",
"rawurlencode",
"(",
"$",
"value",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"current",
"!==",
"null",
")",
"{",
"foreach",
"(",
"explode",
"(",
"'&'",
",",
"$",
"current",
")",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"explode",
"(",
"'='",
",",
"$",
"part",
")",
"[",
"0",
"]",
"!==",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"}",
"}",
"$",
"result",
"[",
"]",
"=",
"(",
"$",
"value",
"!==",
"''",
")",
"?",
"$",
"key",
".",
"'='",
".",
"$",
"value",
":",
"$",
"key",
";",
"return",
"$",
"uri",
"->",
"withQuery",
"(",
"implode",
"(",
"'&'",
",",
"$",
"result",
")",
")",
";",
"}"
] | Create a new URI with a specific query string value.
Any existing query string values that exactly match the provided key are
removed and replaced with the given key value pair.
Note: this function will convert "=" to "%3D" and "&" to "%26".
@param UriInterface $uri URI to use as base.
@param string $key Key to set.
@param string $value Value to set.
@throws \InvalidArgumentException
@return Uri | [
"Create",
"a",
"new",
"URI",
"with",
"a",
"specific",
"query",
"string",
"value",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L257-L276 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.resolve | public static function resolve(UriInterface $base, $rel = null)
{
if ($rel === null || $rel === '') {
return $base;
}
if (!$rel instanceof UriInterface) {
$rel = new self($rel);
}
// Return the relative uri as-is if it has a scheme.
if ($rel->getScheme()) {
return $rel->withPath(static::removeDotSegments($rel->getPath()));
}
$relParts = [
'scheme' => $rel->getScheme(),
'authority' => $rel->getAuthority(),
'path' => $rel->getPath(),
'query' => $rel->getQuery(),
'fragment' => $rel->getFragment(),
];
$parts = [
'scheme' => $base->getScheme(),
'authority' => $base->getAuthority(),
'path' => $base->getPath(),
'query' => $base->getQuery(),
'fragment' => $base->getFragment(),
];
if (!empty($relParts['path'])) {
if (strpos($relParts['path'], '/') === 0) {
$parts['path'] = self::removeDotSegments($relParts['path']);
$parts['query'] = $relParts['query'];
$parts['fragment'] = $relParts['fragment'];
} else {
$mergedPath = substr($parts['path'], 0, strrpos($parts['path'], '/') + 1);
$parts['path'] = self::removeDotSegments($mergedPath . $relParts['path']);
$parts['query'] = $relParts['query'];
$parts['fragment'] = $relParts['fragment'];
}
} elseif (!empty($relParts['query'])) {
$parts['query'] = $relParts['query'];
} elseif ($relParts['fragment'] !== null) {
$parts['fragment'] = $relParts['fragment'];
}
return new self(static::createUriString(
$parts['scheme'],
$parts['authority'],
$parts['path'],
$parts['query'],
$parts['fragment']
));
} | php | public static function resolve(UriInterface $base, $rel = null)
{
if ($rel === null || $rel === '') {
return $base;
}
if (!$rel instanceof UriInterface) {
$rel = new self($rel);
}
// Return the relative uri as-is if it has a scheme.
if ($rel->getScheme()) {
return $rel->withPath(static::removeDotSegments($rel->getPath()));
}
$relParts = [
'scheme' => $rel->getScheme(),
'authority' => $rel->getAuthority(),
'path' => $rel->getPath(),
'query' => $rel->getQuery(),
'fragment' => $rel->getFragment(),
];
$parts = [
'scheme' => $base->getScheme(),
'authority' => $base->getAuthority(),
'path' => $base->getPath(),
'query' => $base->getQuery(),
'fragment' => $base->getFragment(),
];
if (!empty($relParts['path'])) {
if (strpos($relParts['path'], '/') === 0) {
$parts['path'] = self::removeDotSegments($relParts['path']);
$parts['query'] = $relParts['query'];
$parts['fragment'] = $relParts['fragment'];
} else {
$mergedPath = substr($parts['path'], 0, strrpos($parts['path'], '/') + 1);
$parts['path'] = self::removeDotSegments($mergedPath . $relParts['path']);
$parts['query'] = $relParts['query'];
$parts['fragment'] = $relParts['fragment'];
}
} elseif (!empty($relParts['query'])) {
$parts['query'] = $relParts['query'];
} elseif ($relParts['fragment'] !== null) {
$parts['fragment'] = $relParts['fragment'];
}
return new self(static::createUriString(
$parts['scheme'],
$parts['authority'],
$parts['path'],
$parts['query'],
$parts['fragment']
));
} | [
"public",
"static",
"function",
"resolve",
"(",
"UriInterface",
"$",
"base",
",",
"$",
"rel",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"rel",
"===",
"null",
"||",
"$",
"rel",
"===",
"''",
")",
"{",
"return",
"$",
"base",
";",
"}",
"if",
"(",
"!",
"$",
"rel",
"instanceof",
"UriInterface",
")",
"{",
"$",
"rel",
"=",
"new",
"self",
"(",
"$",
"rel",
")",
";",
"}",
"// Return the relative uri as-is if it has a scheme.",
"if",
"(",
"$",
"rel",
"->",
"getScheme",
"(",
")",
")",
"{",
"return",
"$",
"rel",
"->",
"withPath",
"(",
"static",
"::",
"removeDotSegments",
"(",
"$",
"rel",
"->",
"getPath",
"(",
")",
")",
")",
";",
"}",
"$",
"relParts",
"=",
"[",
"'scheme'",
"=>",
"$",
"rel",
"->",
"getScheme",
"(",
")",
",",
"'authority'",
"=>",
"$",
"rel",
"->",
"getAuthority",
"(",
")",
",",
"'path'",
"=>",
"$",
"rel",
"->",
"getPath",
"(",
")",
",",
"'query'",
"=>",
"$",
"rel",
"->",
"getQuery",
"(",
")",
",",
"'fragment'",
"=>",
"$",
"rel",
"->",
"getFragment",
"(",
")",
",",
"]",
";",
"$",
"parts",
"=",
"[",
"'scheme'",
"=>",
"$",
"base",
"->",
"getScheme",
"(",
")",
",",
"'authority'",
"=>",
"$",
"base",
"->",
"getAuthority",
"(",
")",
",",
"'path'",
"=>",
"$",
"base",
"->",
"getPath",
"(",
")",
",",
"'query'",
"=>",
"$",
"base",
"->",
"getQuery",
"(",
")",
",",
"'fragment'",
"=>",
"$",
"base",
"->",
"getFragment",
"(",
")",
",",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"relParts",
"[",
"'path'",
"]",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"relParts",
"[",
"'path'",
"]",
",",
"'/'",
")",
"===",
"0",
")",
"{",
"$",
"parts",
"[",
"'path'",
"]",
"=",
"self",
"::",
"removeDotSegments",
"(",
"$",
"relParts",
"[",
"'path'",
"]",
")",
";",
"$",
"parts",
"[",
"'query'",
"]",
"=",
"$",
"relParts",
"[",
"'query'",
"]",
";",
"$",
"parts",
"[",
"'fragment'",
"]",
"=",
"$",
"relParts",
"[",
"'fragment'",
"]",
";",
"}",
"else",
"{",
"$",
"mergedPath",
"=",
"substr",
"(",
"$",
"parts",
"[",
"'path'",
"]",
",",
"0",
",",
"strrpos",
"(",
"$",
"parts",
"[",
"'path'",
"]",
",",
"'/'",
")",
"+",
"1",
")",
";",
"$",
"parts",
"[",
"'path'",
"]",
"=",
"self",
"::",
"removeDotSegments",
"(",
"$",
"mergedPath",
".",
"$",
"relParts",
"[",
"'path'",
"]",
")",
";",
"$",
"parts",
"[",
"'query'",
"]",
"=",
"$",
"relParts",
"[",
"'query'",
"]",
";",
"$",
"parts",
"[",
"'fragment'",
"]",
"=",
"$",
"relParts",
"[",
"'fragment'",
"]",
";",
"}",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"relParts",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"parts",
"[",
"'query'",
"]",
"=",
"$",
"relParts",
"[",
"'query'",
"]",
";",
"}",
"elseif",
"(",
"$",
"relParts",
"[",
"'fragment'",
"]",
"!==",
"null",
")",
"{",
"$",
"parts",
"[",
"'fragment'",
"]",
"=",
"$",
"relParts",
"[",
"'fragment'",
"]",
";",
"}",
"return",
"new",
"self",
"(",
"static",
"::",
"createUriString",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
",",
"$",
"parts",
"[",
"'authority'",
"]",
",",
"$",
"parts",
"[",
"'path'",
"]",
",",
"$",
"parts",
"[",
"'query'",
"]",
",",
"$",
"parts",
"[",
"'fragment'",
"]",
")",
")",
";",
"}"
] | Resolve a base URI with a relative URI and return a new URI.
@param UriInterface $base Base URI
@param null|string|UriInterface $rel Relative URI
@throws \InvalidArgumentException
@return UriInterface | [
"Resolve",
"a",
"base",
"URI",
"with",
"a",
"relative",
"URI",
"and",
"return",
"a",
"new",
"URI",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L288-L344 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.removeDotSegments | public static function removeDotSegments($path)
{
static $noopPaths = ['' => true, '/' => true, '*' => true];
static $ignoreSegments = ['.' => true, '..' => true];
if (array_key_exists($path, $noopPaths)) {
return $path;
}
$results = [];
$segments = explode('/', $path);
foreach ($segments as $segment) {
if ($segment === '..') {
array_pop($results);
} elseif (!array_key_exists($segment, $ignoreSegments)) {
$results[] = $segment;
}
}
$newPath = implode('/', $results);
// add the leading slash if necessary
if (strpos($path, '/') === 0 && strpos($newPath, '/') !== 0) {
$newPath = '/' . $newPath;
}
// add the trailing slash if necessary
if ($newPath !== '/' && array_key_exists(end($segments), $ignoreSegments)) {
$newPath .= '/';
}
return $newPath;
} | php | public static function removeDotSegments($path)
{
static $noopPaths = ['' => true, '/' => true, '*' => true];
static $ignoreSegments = ['.' => true, '..' => true];
if (array_key_exists($path, $noopPaths)) {
return $path;
}
$results = [];
$segments = explode('/', $path);
foreach ($segments as $segment) {
if ($segment === '..') {
array_pop($results);
} elseif (!array_key_exists($segment, $ignoreSegments)) {
$results[] = $segment;
}
}
$newPath = implode('/', $results);
// add the leading slash if necessary
if (strpos($path, '/') === 0 && strpos($newPath, '/') !== 0) {
$newPath = '/' . $newPath;
}
// add the trailing slash if necessary
if ($newPath !== '/' && array_key_exists(end($segments), $ignoreSegments)) {
$newPath .= '/';
}
return $newPath;
} | [
"public",
"static",
"function",
"removeDotSegments",
"(",
"$",
"path",
")",
"{",
"static",
"$",
"noopPaths",
"=",
"[",
"''",
"=>",
"true",
",",
"'/'",
"=>",
"true",
",",
"'*'",
"=>",
"true",
"]",
";",
"static",
"$",
"ignoreSegments",
"=",
"[",
"'.'",
"=>",
"true",
",",
"'..'",
"=>",
"true",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"path",
",",
"$",
"noopPaths",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"segments",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"segment",
"===",
"'..'",
")",
"{",
"array_pop",
"(",
"$",
"results",
")",
";",
"}",
"elseif",
"(",
"!",
"array_key_exists",
"(",
"$",
"segment",
",",
"$",
"ignoreSegments",
")",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"segment",
";",
"}",
"}",
"$",
"newPath",
"=",
"implode",
"(",
"'/'",
",",
"$",
"results",
")",
";",
"// add the leading slash if necessary",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'/'",
")",
"===",
"0",
"&&",
"strpos",
"(",
"$",
"newPath",
",",
"'/'",
")",
"!==",
"0",
")",
"{",
"$",
"newPath",
"=",
"'/'",
".",
"$",
"newPath",
";",
"}",
"// add the trailing slash if necessary",
"if",
"(",
"$",
"newPath",
"!==",
"'/'",
"&&",
"array_key_exists",
"(",
"end",
"(",
"$",
"segments",
")",
",",
"$",
"ignoreSegments",
")",
")",
"{",
"$",
"newPath",
".=",
"'/'",
";",
"}",
"return",
"$",
"newPath",
";",
"}"
] | Removes dot segments from a path and returns the new path.
@param string $path
@return string
@link http://tools.ietf.org/html/rfc3986#section-5.2.4 | [
"Removes",
"dot",
"segments",
"from",
"a",
"path",
"and",
"returns",
"the",
"new",
"path",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L355-L386 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.withoutQueryValue | public static function withoutQueryValue(UriInterface $uri, $key)
{
if ($uri->getQuery() === null) {
return $uri;
}
$result = [];
foreach (explode('&', $uri->getQuery()) as $part) {
if (explode('=', $part)[0] !== $key) {
$result[] = $part;
}
}
return $uri->withQuery(implode('&', $result));
} | php | public static function withoutQueryValue(UriInterface $uri, $key)
{
if ($uri->getQuery() === null) {
return $uri;
}
$result = [];
foreach (explode('&', $uri->getQuery()) as $part) {
if (explode('=', $part)[0] !== $key) {
$result[] = $part;
}
}
return $uri->withQuery(implode('&', $result));
} | [
"public",
"static",
"function",
"withoutQueryValue",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"uri",
"->",
"getQuery",
"(",
")",
"===",
"null",
")",
"{",
"return",
"$",
"uri",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"'&'",
",",
"$",
"uri",
"->",
"getQuery",
"(",
")",
")",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"explode",
"(",
"'='",
",",
"$",
"part",
")",
"[",
"0",
"]",
"!==",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"}",
"return",
"$",
"uri",
"->",
"withQuery",
"(",
"implode",
"(",
"'&'",
",",
"$",
"result",
")",
")",
";",
"}"
] | Create a new URI with a specific query string value removed.
Any existing query string values that exactly match the provided key are removed.
Note: this function will convert "=" to "%3D" and "&" to "%26".
@param UriInterface $uri URI to use as a base.
@param string $key Query string key value pair to remove.
@throws \InvalidArgumentException
@return UriInterface | [
"Create",
"a",
"new",
"URI",
"with",
"a",
"specific",
"query",
"string",
"value",
"removed",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L402-L416 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.withFragment | public function withFragment($fragment)
{
if (strpos($fragment, '#') === 0) {
$fragment = substr($fragment, 1);
}
$fragment = $this->filterQueryAndFragment($fragment);
$new = clone $this;
$new->fragment = $fragment;
return $new;
} | php | public function withFragment($fragment)
{
if (strpos($fragment, '#') === 0) {
$fragment = substr($fragment, 1);
}
$fragment = $this->filterQueryAndFragment($fragment);
$new = clone $this;
$new->fragment = $fragment;
return $new;
} | [
"public",
"function",
"withFragment",
"(",
"$",
"fragment",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"fragment",
",",
"'#'",
")",
"===",
"0",
")",
"{",
"$",
"fragment",
"=",
"substr",
"(",
"$",
"fragment",
",",
"1",
")",
";",
"}",
"$",
"fragment",
"=",
"$",
"this",
"->",
"filterQueryAndFragment",
"(",
"$",
"fragment",
")",
";",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"fragment",
"=",
"$",
"fragment",
";",
"return",
"$",
"new",
";",
"}"
] | @param string $fragment
@return UriInterface | [
"@param",
"string",
"$fragment"
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L435-L446 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.withQuery | public function withQuery($query)
{
if (!is_string($query) && !method_exists($query, '__toString')) {
throw new \InvalidArgumentException('Query string must be a string');
}
$query = (string) $query;
if (strpos($query, '?') === 0) {
$query = substr($query, 1);
}
$query = $this->filterQueryAndFragment($query);
$new = clone $this;
$new->query = $query;
return $new;
} | php | public function withQuery($query)
{
if (!is_string($query) && !method_exists($query, '__toString')) {
throw new \InvalidArgumentException('Query string must be a string');
}
$query = (string) $query;
if (strpos($query, '?') === 0) {
$query = substr($query, 1);
}
$query = $this->filterQueryAndFragment($query);
$new = clone $this;
$new->query = $query;
return $new;
} | [
"public",
"function",
"withQuery",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"query",
")",
"&&",
"!",
"method_exists",
"(",
"$",
"query",
",",
"'__toString'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Query string must be a string'",
")",
";",
"}",
"$",
"query",
"=",
"(",
"string",
")",
"$",
"query",
";",
"if",
"(",
"strpos",
"(",
"$",
"query",
",",
"'?'",
")",
"===",
"0",
")",
"{",
"$",
"query",
"=",
"substr",
"(",
"$",
"query",
",",
"1",
")",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"filterQueryAndFragment",
"(",
"$",
"query",
")",
";",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"query",
"=",
"$",
"query",
";",
"return",
"$",
"new",
";",
"}"
] | @param string $query
@return UriInterface
@throws \InvalidArgumentException | [
"@param",
"string",
"$query"
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L455-L470 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.withPath | public function withPath($path)
{
if (!is_string($path)) {
throw new \InvalidArgumentException('Invalid path provided; must be a string');
}
$path = $this->filterPath($path);
$new = clone $this;
$new->path = $path;
return $new;
} | php | public function withPath($path)
{
if (!is_string($path)) {
throw new \InvalidArgumentException('Invalid path provided; must be a string');
}
$path = $this->filterPath($path);
$new = clone $this;
$new->path = $path;
return $new;
} | [
"public",
"function",
"withPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid path provided; must be a string'",
")",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"filterPath",
"(",
"$",
"path",
")",
";",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"path",
"=",
"$",
"path",
";",
"return",
"$",
"new",
";",
"}"
] | Returns instance with given path.
@param string $path
@throws \InvalidArgumentException
@return UriInterface | [
"Returns",
"instance",
"with",
"given",
"path",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L515-L526 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.createUriString | private static function createUriString(
$scheme = null,
$authority = null,
$path = null,
$query = null,
$fragment = null
) {
$uri = '';
$hierPart = '';
if ($scheme !== null) {
$uri .= $scheme . ':';
}
if (!$authority !== '') {
if ($scheme !== null && $scheme !== 'urn') {
$hierPart .= '//';
}
$hierPart .= $authority;
}
if ($path !== null) {
// Add a leading slash if necessary.
if ($hierPart && strpos($path, '/') !== 0) {
$hierPart .= '/';
}
$hierPart .= $path;
}
$uri .= $hierPart;
// if query is present prepend ? sign
if ($query !== null) {
$uri .= '?' . $query;
}
// if fragment is present prepend # sign
if ($fragment !== null) {
$uri .= '#' . $fragment;
}
return $uri;
} | php | private static function createUriString(
$scheme = null,
$authority = null,
$path = null,
$query = null,
$fragment = null
) {
$uri = '';
$hierPart = '';
if ($scheme !== null) {
$uri .= $scheme . ':';
}
if (!$authority !== '') {
if ($scheme !== null && $scheme !== 'urn') {
$hierPart .= '//';
}
$hierPart .= $authority;
}
if ($path !== null) {
// Add a leading slash if necessary.
if ($hierPart && strpos($path, '/') !== 0) {
$hierPart .= '/';
}
$hierPart .= $path;
}
$uri .= $hierPart;
// if query is present prepend ? sign
if ($query !== null) {
$uri .= '?' . $query;
}
// if fragment is present prepend # sign
if ($fragment !== null) {
$uri .= '#' . $fragment;
}
return $uri;
} | [
"private",
"static",
"function",
"createUriString",
"(",
"$",
"scheme",
"=",
"null",
",",
"$",
"authority",
"=",
"null",
",",
"$",
"path",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"fragment",
"=",
"null",
")",
"{",
"$",
"uri",
"=",
"''",
";",
"$",
"hierPart",
"=",
"''",
";",
"if",
"(",
"$",
"scheme",
"!==",
"null",
")",
"{",
"$",
"uri",
".=",
"$",
"scheme",
".",
"':'",
";",
"}",
"if",
"(",
"!",
"$",
"authority",
"!==",
"''",
")",
"{",
"if",
"(",
"$",
"scheme",
"!==",
"null",
"&&",
"$",
"scheme",
"!==",
"'urn'",
")",
"{",
"$",
"hierPart",
".=",
"'//'",
";",
"}",
"$",
"hierPart",
".=",
"$",
"authority",
";",
"}",
"if",
"(",
"$",
"path",
"!==",
"null",
")",
"{",
"// Add a leading slash if necessary.",
"if",
"(",
"$",
"hierPart",
"&&",
"strpos",
"(",
"$",
"path",
",",
"'/'",
")",
"!==",
"0",
")",
"{",
"$",
"hierPart",
".=",
"'/'",
";",
"}",
"$",
"hierPart",
".=",
"$",
"path",
";",
"}",
"$",
"uri",
".=",
"$",
"hierPart",
";",
"// if query is present prepend ? sign",
"if",
"(",
"$",
"query",
"!==",
"null",
")",
"{",
"$",
"uri",
".=",
"'?'",
".",
"$",
"query",
";",
"}",
"// if fragment is present prepend # sign",
"if",
"(",
"$",
"fragment",
"!==",
"null",
")",
"{",
"$",
"uri",
".=",
"'#'",
".",
"$",
"fragment",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] | Create a URI string from its various parts.
@param string $scheme
@param string $authority
@param string $path
@param string $query
@param string $fragment
@return string | [
"Create",
"a",
"URI",
"string",
"from",
"its",
"various",
"parts",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L617-L659 |
webservices-nl/common | src/Common/Endpoint/Uri.php | Uri.getAuthority | public function getAuthority()
{
$authority = $this->getHost();
if ($authority === null) {
return '';
}
if ($this->getUserInfo() !== '') {
$authority = $this->getUserInfo() . '@' . $authority;
}
if ($this->port !== null && self::isStandardPort($this->port, $this->scheme, $this->host) === false) {
$authority .= ':' . $this->port;
}
return $authority;
} | php | public function getAuthority()
{
$authority = $this->getHost();
if ($authority === null) {
return '';
}
if ($this->getUserInfo() !== '') {
$authority = $this->getUserInfo() . '@' . $authority;
}
if ($this->port !== null && self::isStandardPort($this->port, $this->scheme, $this->host) === false) {
$authority .= ':' . $this->port;
}
return $authority;
} | [
"public",
"function",
"getAuthority",
"(",
")",
"{",
"$",
"authority",
"=",
"$",
"this",
"->",
"getHost",
"(",
")",
";",
"if",
"(",
"$",
"authority",
"===",
"null",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
"!==",
"''",
")",
"{",
"$",
"authority",
"=",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
".",
"'@'",
".",
"$",
"authority",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"port",
"!==",
"null",
"&&",
"self",
"::",
"isStandardPort",
"(",
"$",
"this",
"->",
"port",
",",
"$",
"this",
"->",
"scheme",
",",
"$",
"this",
"->",
"host",
")",
"===",
"false",
")",
"{",
"$",
"authority",
".=",
"':'",
".",
"$",
"this",
"->",
"port",
";",
"}",
"return",
"$",
"authority",
";",
"}"
] | Retrieve the authority component of the URI.
{@inheritdoc}
@see https://tools.ietf.org/html/rfc3986#section-3.2
@return string The URI authority, in "[user-info@]host[:port]" format. | [
"Retrieve",
"the",
"authority",
"component",
"of",
"the",
"URI",
"."
] | train | https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Uri.php#L670-L686 |
mothership-ec/composer | src/Composer/Plugin/PluginManager.php | PluginManager.addPlugin | public function addPlugin(PluginInterface $plugin)
{
if ($this->io->isDebug()) {
$this->io->writeError('Loading plugin '.get_class($plugin));
}
$this->plugins[] = $plugin;
$plugin->activate($this->composer, $this->io);
if ($plugin instanceof EventSubscriberInterface) {
$this->composer->getEventDispatcher()->addSubscriber($plugin);
}
} | php | public function addPlugin(PluginInterface $plugin)
{
if ($this->io->isDebug()) {
$this->io->writeError('Loading plugin '.get_class($plugin));
}
$this->plugins[] = $plugin;
$plugin->activate($this->composer, $this->io);
if ($plugin instanceof EventSubscriberInterface) {
$this->composer->getEventDispatcher()->addSubscriber($plugin);
}
} | [
"public",
"function",
"addPlugin",
"(",
"PluginInterface",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isDebug",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"'Loading plugin '",
".",
"get_class",
"(",
"$",
"plugin",
")",
")",
";",
"}",
"$",
"this",
"->",
"plugins",
"[",
"]",
"=",
"$",
"plugin",
";",
"$",
"plugin",
"->",
"activate",
"(",
"$",
"this",
"->",
"composer",
",",
"$",
"this",
"->",
"io",
")",
";",
"if",
"(",
"$",
"plugin",
"instanceof",
"EventSubscriberInterface",
")",
"{",
"$",
"this",
"->",
"composer",
"->",
"getEventDispatcher",
"(",
")",
"->",
"addSubscriber",
"(",
"$",
"plugin",
")",
";",
"}",
"}"
] | Adds a plugin, activates it and registers it with the event dispatcher
@param PluginInterface $plugin plugin instance | [
"Adds",
"a",
"plugin",
"activates",
"it",
"and",
"registers",
"it",
"with",
"the",
"event",
"dispatcher"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Plugin/PluginManager.php#L80-L91 |
mothership-ec/composer | src/Composer/Plugin/PluginManager.php | PluginManager.loadRepository | public function loadRepository(RepositoryInterface $repo)
{
foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */
if ($package instanceof AliasPackage) {
continue;
}
if ('composer-plugin' === $package->getType()) {
$requiresComposer = null;
foreach ($package->getRequires() as $link) { /** @var Link $link */
if ('composer-plugin-api' === $link->getTarget()) {
$requiresComposer = $link->getConstraint();
break;
}
}
if (!$requiresComposer) {
throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
}
$currentPluginApiVersion = $this->getPluginApiVersion();
$currentPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currentPluginApiVersion));
if (!$requiresComposer->matches($currentPluginApiConstraint)) {
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
continue;
}
$this->registerPackage($package);
// Backward compatibility
} elseif ('composer-installer' === $package->getType()) {
$this->registerPackage($package);
}
}
} | php | public function loadRepository(RepositoryInterface $repo)
{
foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */
if ($package instanceof AliasPackage) {
continue;
}
if ('composer-plugin' === $package->getType()) {
$requiresComposer = null;
foreach ($package->getRequires() as $link) { /** @var Link $link */
if ('composer-plugin-api' === $link->getTarget()) {
$requiresComposer = $link->getConstraint();
break;
}
}
if (!$requiresComposer) {
throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
}
$currentPluginApiVersion = $this->getPluginApiVersion();
$currentPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currentPluginApiVersion));
if (!$requiresComposer->matches($currentPluginApiConstraint)) {
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
continue;
}
$this->registerPackage($package);
// Backward compatibility
} elseif ('composer-installer' === $package->getType()) {
$this->registerPackage($package);
}
}
} | [
"public",
"function",
"loadRepository",
"(",
"RepositoryInterface",
"$",
"repo",
")",
"{",
"foreach",
"(",
"$",
"repo",
"->",
"getPackages",
"(",
")",
"as",
"$",
"package",
")",
"{",
"/** @var PackageInterface $package */",
"if",
"(",
"$",
"package",
"instanceof",
"AliasPackage",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"'composer-plugin'",
"===",
"$",
"package",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"requiresComposer",
"=",
"null",
";",
"foreach",
"(",
"$",
"package",
"->",
"getRequires",
"(",
")",
"as",
"$",
"link",
")",
"{",
"/** @var Link $link */",
"if",
"(",
"'composer-plugin-api'",
"===",
"$",
"link",
"->",
"getTarget",
"(",
")",
")",
"{",
"$",
"requiresComposer",
"=",
"$",
"link",
"->",
"getConstraint",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"requiresComposer",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Plugin \"",
".",
"$",
"package",
"->",
"getName",
"(",
")",
".",
"\" is missing a require statement for a version of the composer-plugin-api package.\"",
")",
";",
"}",
"$",
"currentPluginApiVersion",
"=",
"$",
"this",
"->",
"getPluginApiVersion",
"(",
")",
";",
"$",
"currentPluginApiConstraint",
"=",
"new",
"VersionConstraint",
"(",
"'=='",
",",
"$",
"this",
"->",
"versionParser",
"->",
"normalize",
"(",
"$",
"currentPluginApiVersion",
")",
")",
";",
"if",
"(",
"!",
"$",
"requiresComposer",
"->",
"matches",
"(",
"$",
"currentPluginApiConstraint",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"'<warning>The \"'",
".",
"$",
"package",
"->",
"getName",
"(",
")",
".",
"'\" plugin was skipped because it requires a Plugin API version (\"'",
".",
"$",
"requiresComposer",
"->",
"getPrettyString",
"(",
")",
".",
"'\") that does not match your Composer installation (\"'",
".",
"$",
"currentPluginApiVersion",
".",
"'\"). You may need to run composer update with the \"--no-plugins\" option.</warning>'",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"registerPackage",
"(",
"$",
"package",
")",
";",
"// Backward compatibility",
"}",
"elseif",
"(",
"'composer-installer'",
"===",
"$",
"package",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"this",
"->",
"registerPackage",
"(",
"$",
"package",
")",
";",
"}",
"}",
"}"
] | Load all plugins and installers from a repository
Note that plugins in the specified repository that rely on events that
have fired prior to loading will be missed. This means you likely want to
call this method as early as possible.
@param RepositoryInterface $repo Repository to scan for plugins to install
@throws \RuntimeException | [
"Load",
"all",
"plugins",
"and",
"installers",
"from",
"a",
"repository"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Plugin/PluginManager.php#L114-L148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.