id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
43,500 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/NavbarHelper.php | NavbarHelper.text | public function text($text, $options = []) {
$options += [
'templateVars' => []
];
$text = preg_replace_callback('/<a([^>]*)?>([^<]*)?<\/a>/i', function($matches) {
$attrs = preg_replace_callback ('/class="(.*)?"/', function ($m) {
$cl = $this->addClass (['class' => $m[1]], 'navbar-link');
return 'class="'.$cl['class'].'"';
}, $matches[1], -1, $count);
if ($count == 0) {
$attrs .= ' class="navbar-link"';
}
return '<a'.$attrs.'>'.$matches[2].'</a>';
}, $text);
return $this->formatTemplate('navbarText', [
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | php | public function text($text, $options = []) {
$options += [
'templateVars' => []
];
$text = preg_replace_callback('/<a([^>]*)?>([^<]*)?<\/a>/i', function($matches) {
$attrs = preg_replace_callback ('/class="(.*)?"/', function ($m) {
$cl = $this->addClass (['class' => $m[1]], 'navbar-link');
return 'class="'.$cl['class'].'"';
}, $matches[1], -1, $count);
if ($count == 0) {
$attrs .= ' class="navbar-link"';
}
return '<a'.$attrs.'>'.$matches[2].'</a>';
}, $text);
return $this->formatTemplate('navbarText', [
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"text",
"(",
"$",
"text",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'templateVars'",
"=>",
"[",
"]",
"]",
";",
"$",
"text",
"=",
"preg_replace_callback",
"(",
"'/<a([^>]*)?>([^<]*)?<\\/a>/i'",
",",
"f... | Add a text to the navbar.
### Options
- `templateVars` Provide template variables for the text template.
- Other attributes will be assigned to the text element.
@param string $text The text message.
@param array $options Array attributes for the wrapper element.
@return string A HTML element wrapping the text for the navbar. | [
"Add",
"a",
"text",
"to",
"the",
"navbar",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L336-L355 |
43,501 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/NavbarHelper.php | NavbarHelper.beginMenu | public function beginMenu($name = null, $url = null, $options = [],
$linkOptions = [], $listOptions = []) {
$template = 'outerMenuStart';
$templateOptions = [];
if (is_array($name)) {
$options = $name;
}
$options += [
'templateVars' => []
];
if ($this->_level == 1) {
$linkOptions += [
'caret' => '<span class="caret"></span>'
];
$template = 'innerMenuStart';
$templateOptions['dropdownLink'] = $this->formatTemplate('dropdownLink', [
'content' => $name,
'caret' => $linkOptions['caret'],
'url' => $url ? $this->Url->build($url) : '#',
'attrs' => $this->templater()->formatAttributes($linkOptions, ['caret'])
]);
$templateOptions['dropdownMenuStart'] = $this->formatTemplate('dropdownMenuStart', [
'attrs' => $this->templater()->formatAttributes($listOptions)
]);
}
$this->_level += 1;
return $this->formatTemplate($template, $templateOptions + [
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | php | public function beginMenu($name = null, $url = null, $options = [],
$linkOptions = [], $listOptions = []) {
$template = 'outerMenuStart';
$templateOptions = [];
if (is_array($name)) {
$options = $name;
}
$options += [
'templateVars' => []
];
if ($this->_level == 1) {
$linkOptions += [
'caret' => '<span class="caret"></span>'
];
$template = 'innerMenuStart';
$templateOptions['dropdownLink'] = $this->formatTemplate('dropdownLink', [
'content' => $name,
'caret' => $linkOptions['caret'],
'url' => $url ? $this->Url->build($url) : '#',
'attrs' => $this->templater()->formatAttributes($linkOptions, ['caret'])
]);
$templateOptions['dropdownMenuStart'] = $this->formatTemplate('dropdownMenuStart', [
'attrs' => $this->templater()->formatAttributes($listOptions)
]);
}
$this->_level += 1;
return $this->formatTemplate($template, $templateOptions + [
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"beginMenu",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"url",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"linkOptions",
"=",
"[",
"]",
",",
"$",
"listOptions",
"=",
"[",
"]",
")",
"{",
"$",
"template",
"=",
... | Start a new menu.
Two types of menus exist:
- Horizontal hover menu in the navbar (level 0).
- Vertical dropdown menu (level 1).
The menu level is determined automatically: A dropdown menu needs to be part of
a hover menu. In the hover menu case, pass the options array as the first argument.
You can populate the menu with `link()`, `divider()`, and sub menus.
Use `'class' => 'navbar-right'` option for flush right.
**Note:** The `$linkOptions` and `$listOptions` parameters are not used for menu
at level 0 (horizontal menu).
### Options
- `templateVars` Provide template variables for the menu template.
- Other attributes will be assigned to the menu element.
### Link Options
- `caret` HTML caret element. Default is `'<span class="caret"></span>'`.
- Other attributes will be assigned to the link element.
### List Options
- Other attributes will be assigned to the list element.
@param string $name Name of the menu.
@param string|array $url URL for the menu.
@param array $options Array of options for the wrapping element.
@param array $linkOptions Array of options for the link. See above.
@param array $listOptions Array of options for the openning `ul` elements.
@return string HTML elements to start a menu. | [
"Start",
"a",
"new",
"menu",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L394-L424 |
43,502 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/NavbarHelper.php | NavbarHelper.endMenu | public function endMenu() {
$template = 'outerMenuEnd';
$options = [];
if ($this->_level == 2) {
$template = 'innerMenuEnd';
$options['dropdownMenuEnd'] = $this->formatTemplate('dropdownMenuEnd', []);
}
$this->_level -= 1;
return $this->formatTemplate($template, $options);
} | php | public function endMenu() {
$template = 'outerMenuEnd';
$options = [];
if ($this->_level == 2) {
$template = 'innerMenuEnd';
$options['dropdownMenuEnd'] = $this->formatTemplate('dropdownMenuEnd', []);
}
$this->_level -= 1;
return $this->formatTemplate($template, $options);
} | [
"public",
"function",
"endMenu",
"(",
")",
"{",
"$",
"template",
"=",
"'outerMenuEnd'",
";",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"_level",
"==",
"2",
")",
"{",
"$",
"template",
"=",
"'innerMenuEnd'",
";",
"$",
"options",... | End a menu.
@return string HTML elements to close a menu. | [
"End",
"a",
"menu",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L431-L440 |
43,503 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/NavbarHelper.php | NavbarHelper.end | public function end() {
$containerEnd = $this->formatTemplate('containerEnd', []);
$responsiveEnd = '';
if ($this->_responsive) {
$responsiveEnd = $this->formatTemplate('responsiveEnd', []);
}
return $this->formatTemplate('navbarEnd', [
'containerEnd' => $containerEnd,
'responsiveEnd' => $responsiveEnd
]);
} | php | public function end() {
$containerEnd = $this->formatTemplate('containerEnd', []);
$responsiveEnd = '';
if ($this->_responsive) {
$responsiveEnd = $this->formatTemplate('responsiveEnd', []);
}
return $this->formatTemplate('navbarEnd', [
'containerEnd' => $containerEnd,
'responsiveEnd' => $responsiveEnd
]);
} | [
"public",
"function",
"end",
"(",
")",
"{",
"$",
"containerEnd",
"=",
"$",
"this",
"->",
"formatTemplate",
"(",
"'containerEnd'",
",",
"[",
"]",
")",
";",
"$",
"responsiveEnd",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"_responsive",
")",
"{",
"$... | Close a navbar.
@return string HTML elements to close the navbar. | [
"Close",
"a",
"navbar",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L447-L457 |
43,504 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.icon | public function icon($icon, array $options = []) {
$options += [
'templateVars' => []
];
return $this->formatTemplate('icon', [
'type' => $icon,
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | php | public function icon($icon, array $options = []) {
$options += [
'templateVars' => []
];
return $this->formatTemplate('icon', [
'type' => $icon,
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"icon",
"(",
"$",
"icon",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'templateVars'",
"=>",
"[",
"]",
"]",
";",
"return",
"$",
"this",
"->",
"formatTemplate",
"(",
"'icon'",
",",
"[",
"'... | Create an icon using the template `icon`.
### Options
- `templateVars` Provide template variables for the `icon` template.
- Other attributes will be assigned to the wrapper element.
@param string $icon Name of the icon.
@param array $options Array of options. See above.
@return string The HTML icon. | [
"Create",
"an",
"icon",
"using",
"the",
"template",
"icon",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L127-L136 |
43,505 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.label | public function label($text, $type = null, $options = []) {
if (is_string($type)) {
$options['type'] = $type;
}
else if (is_array($type)) {
$options = $type;
}
$options += $this->getConfig('label') + [
'templateVars' => []
];
$type = $options['type'];
return $this->formatTemplate('label', [
'type' => $options['type'],
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options, ['type']),
'templateVars' => $options['templateVars']
]);
} | php | public function label($text, $type = null, $options = []) {
if (is_string($type)) {
$options['type'] = $type;
}
else if (is_array($type)) {
$options = $type;
}
$options += $this->getConfig('label') + [
'templateVars' => []
];
$type = $options['type'];
return $this->formatTemplate('label', [
'type' => $options['type'],
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options, ['type']),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"label",
"(",
"$",
"text",
",",
"$",
"type",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"$",
"options",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
... | Create a Twitter Bootstrap span label.
The second parameter may either be `$type` or `$options` (in which case
the third parameter is not used, and the label type can be specified in the
`$options` array).
### Options
- `tag` The HTML tag to use.
- `type` The type of the label.
- `templateVars` Provide template variables for the `label` template.
- Other attributes will be assigned to the wrapper element.
@param string $text The label text
@param string|array $type The label type (default, primary, success, warning,
info, danger) or the array of options (see `$options`).
@param array $options Array of options. See above. Default values are retrieved
from the configuration.
@return string The HTML label element. | [
"Create",
"a",
"Twitter",
"Bootstrap",
"span",
"label",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L168-L185 |
43,506 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.badge | public function badge($text, $options = []) {
$options += [
'templateVars' => []
];
return $this->formatTemplate('badge', [
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | php | public function badge($text, $options = []) {
$options += [
'templateVars' => []
];
return $this->formatTemplate('badge', [
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"badge",
"(",
"$",
"text",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'templateVars'",
"=>",
"[",
"]",
"]",
";",
"return",
"$",
"this",
"->",
"formatTemplate",
"(",
"'badge'",
",",
"[",
"'content'"... | Create a Twitter Bootstrap badge.
### Options
- `templateVars` Provide template variables for the `badge` template.
- Other attributes will be assigned to the wrapper element.
@param string $text The badge text.
@param array $options Array of attributes for the span element. | [
"Create",
"a",
"Twitter",
"Bootstrap",
"badge",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L199-L208 |
43,507 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.alert | public function alert($text, $type = null, $options = []) {
if (is_string($type)) {
$options['type'] = $type;
}
else if (is_array($type)) {
$options = $type;
}
$options += $this->getConfig('alert') + [
'templateVars' => []
];
$close = null;
if ($options['close']) {
$closeContent = $this->formatTemplate('alertCloseContent', [
'templateVars' => $options['templateVars']
]);
$close = $this->formatTemplate('alertCloseButton', [
'label' => __('Close'),
'content' => $closeContent,
'attrs' => $this->templater()->formatAttributes([]),
'templateVars' => $options['templateVars']
]);
$options = $this->addClass($options, 'alert-dismissible');
}
return $this->formatTemplate('alert', [
'type' => $options['type'],
'close' => $close,
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options, ['close', 'type']),
'templateVars' => $options['templateVars']
]);
} | php | public function alert($text, $type = null, $options = []) {
if (is_string($type)) {
$options['type'] = $type;
}
else if (is_array($type)) {
$options = $type;
}
$options += $this->getConfig('alert') + [
'templateVars' => []
];
$close = null;
if ($options['close']) {
$closeContent = $this->formatTemplate('alertCloseContent', [
'templateVars' => $options['templateVars']
]);
$close = $this->formatTemplate('alertCloseButton', [
'label' => __('Close'),
'content' => $closeContent,
'attrs' => $this->templater()->formatAttributes([]),
'templateVars' => $options['templateVars']
]);
$options = $this->addClass($options, 'alert-dismissible');
}
return $this->formatTemplate('alert', [
'type' => $options['type'],
'close' => $close,
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options, ['close', 'type']),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"alert",
"(",
"$",
"text",
",",
"$",
"type",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"$",
"options",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
... | Create a Twitter Bootstrap style alert block, containing text.
The second parameter may either be `$type` or `$options` (in this case,
the third parameter is not used, and the alert type can be specified in the
`$options` array).
### Options
- `close` Dismissible alert. See configuration for default.
- `type` The type of the alert. See configuration for default.
- `templateVars` Provide template variables for the `alert` template.
- Other attributes will be assigned to the wrapper element.
@param string $text The alert text.
@param string|array $type The type of the alert.
@param array $options Array of options. See above.
@return string A HTML bootstrap alert element. | [
"Create",
"a",
"Twitter",
"Bootstrap",
"style",
"alert",
"block",
"containing",
"text",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L240-L270 |
43,508 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.tooltip | public function tooltip($text, $tooltip, $options = []) {
$options += $this->getConfig('tooltip') + [
'tooltip' => $tooltip,
'templateVars' => []
];
return $this->formatTemplate('tooltip', [
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options, ['tag', 'toggle', 'placement', 'tooltip']),
'templateVars' => array_merge($options, $options['templateVars'])
]);
} | php | public function tooltip($text, $tooltip, $options = []) {
$options += $this->getConfig('tooltip') + [
'tooltip' => $tooltip,
'templateVars' => []
];
return $this->formatTemplate('tooltip', [
'content' => $text,
'attrs' => $this->templater()->formatAttributes($options, ['tag', 'toggle', 'placement', 'tooltip']),
'templateVars' => array_merge($options, $options['templateVars'])
]);
} | [
"public",
"function",
"tooltip",
"(",
"$",
"text",
",",
"$",
"tooltip",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"$",
"this",
"->",
"getConfig",
"(",
"'tooltip'",
")",
"+",
"[",
"'tooltip'",
"=>",
"$",
"tooltip",
",",
"'t... | Create a Twitter Bootstrap style tooltip.
### Options
- `toggle` The 'data-toggle' HTML attribute.
- `placement` The `data-placement` HTML attribute.
- `tag` The tag to use.
- `templateVars` Provide template variables for the `tooltip` template.
- Other attributes will be assigned to the wrapper element.
@param string $text The HTML tag inner text.
@param string $tooltip The tooltip text.
@param array $options An array of options. See above. Default values are retrieved
from the configuration.
@return string The text wrapped in the specified HTML tag with a tooltip. | [
"Create",
"a",
"Twitter",
"Bootstrap",
"style",
"tooltip",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L290-L300 |
43,509 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.progress | public function progress($widths, array $options = []) {
$options += $this->getConfig('progress') + [
'striped' => false,
'active' => false,
'min' => 0,
'max' => 100,
'templateVars' => []
];
if (!is_array($widths)) {
$widths = [
['width' => $widths]
];
}
$bars = '';
foreach ($widths as $width) {
$width += $options;
if ($width['striped']) {
$width = $this->addClass($width, 'progress-bar-striped');
}
if ($width['active']) {
$width = $this->addClass($width, 'active');
}
$inner = $this->formatTemplate('progressBarInner', [
'width' => $width['width']
]);
$bars .= $this->formatTemplate('progressBar', [
'inner' => $inner,
'type' => $width['type'],
'min' => $width['min'],
'max' => $width['max'],
'width' => $width['width'],
'attrs' => $this->templater()->formatAttributes($width, ['striped', 'active', 'min', 'max', 'type', 'width']),
'templateVars' => $width['templateVars']
]);
}
return $this->formatTemplate('progressBarContainer', [
'content' => $bars,
'attrs' => $this->templater()->formatAttributes([]),
'templateVars' => $options['templateVars']
]);
} | php | public function progress($widths, array $options = []) {
$options += $this->getConfig('progress') + [
'striped' => false,
'active' => false,
'min' => 0,
'max' => 100,
'templateVars' => []
];
if (!is_array($widths)) {
$widths = [
['width' => $widths]
];
}
$bars = '';
foreach ($widths as $width) {
$width += $options;
if ($width['striped']) {
$width = $this->addClass($width, 'progress-bar-striped');
}
if ($width['active']) {
$width = $this->addClass($width, 'active');
}
$inner = $this->formatTemplate('progressBarInner', [
'width' => $width['width']
]);
$bars .= $this->formatTemplate('progressBar', [
'inner' => $inner,
'type' => $width['type'],
'min' => $width['min'],
'max' => $width['max'],
'width' => $width['width'],
'attrs' => $this->templater()->formatAttributes($width, ['striped', 'active', 'min', 'max', 'type', 'width']),
'templateVars' => $width['templateVars']
]);
}
return $this->formatTemplate('progressBarContainer', [
'content' => $bars,
'attrs' => $this->templater()->formatAttributes([]),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"progress",
"(",
"$",
"widths",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"$",
"this",
"->",
"getConfig",
"(",
"'progress'",
")",
"+",
"[",
"'striped'",
"=>",
"false",
",",
"'active'",
"=>",
"f... | Create a Twitter Bootstrap style progress bar.
### Bar options:
- `active` If `true` the progress bar will be active. Default is `false`.
- `max` Maximum value for the progress bar. Default is `100`.
- `min` Minimum value for the progress bar. Default is `0`.
- `striped` If `true` the progress bar will be striped. Default is `false`.
- `type` A string containing the `type` of the progress bar (primary, info, danger,
success, warning). Default to `'primary'`.
- `templateVars` Provide template variables for the `progressBar` template.
- Other attributes will be assigned to the progress bar element.
@param int|array $widths
- `int` The width (in %) of the bar.
- `array` An array of bars, with, for each bar, the following fields:
- `width` **required** The width of the bar.
- Other options possible (see above).
@param array $options Array of options. See above.
@return string The HTML bootstrap progress bar. | [
"Create",
"a",
"Twitter",
"Bootstrap",
"style",
"progress",
"bar",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L325-L366 |
43,510 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/HtmlHelper.php | HtmlHelper.splicedRows | public function splicedRows($breakIndex, array $data, callable $determineContent) {
$rowsHtml = '<div class="row">';
$count = 1;
foreach ($data as $index => $colData) {
$rowsHtml .= $determineContent($colData);
if ($count % $breakIndex === 0) {
$rowsHtml .= '<div class="clearfix hidden-xs hidden-sm"></div>';
}
$count++;
}
$rowsHtml .= '</div>';
return $rowsHtml;
} | php | public function splicedRows($breakIndex, array $data, callable $determineContent) {
$rowsHtml = '<div class="row">';
$count = 1;
foreach ($data as $index => $colData) {
$rowsHtml .= $determineContent($colData);
if ($count % $breakIndex === 0) {
$rowsHtml .= '<div class="clearfix hidden-xs hidden-sm"></div>';
}
$count++;
}
$rowsHtml .= '</div>';
return $rowsHtml;
} | [
"public",
"function",
"splicedRows",
"(",
"$",
"breakIndex",
",",
"array",
"$",
"data",
",",
"callable",
"$",
"determineContent",
")",
"{",
"$",
"rowsHtml",
"=",
"'<div class=\"row\">'",
";",
"$",
"count",
"=",
"1",
";",
"foreach",
"(",
"$",
"data",
"as",
... | Create a formatted collection of elements while
maintaining proper bootstrappy markup. Useful when
displaying, for example, a list of products that would require
more than the maximum number of columns per row.
@deprecated 3.1.0
@param int|string $breakIndex Divisible index that will trigger a new row
@param array $data Collection of data used to render each column
@param callable $determineContent A callback that will be called with the
data required to render an individual column
@return string | [
"Create",
"a",
"formatted",
"collection",
"of",
"elements",
"while",
"maintaining",
"proper",
"bootstrappy",
"markup",
".",
"Useful",
"when",
"displaying",
"for",
"example",
"a",
"list",
"of",
"products",
"that",
"would",
"require",
"more",
"than",
"the",
"maxim... | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L496-L513 |
43,511 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/FormHelper.php | FormHelper._wrapInputGroup | protected function _wrapInputGroup($addonOrButtons) {
if ($addonOrButtons) {
$template = 'inputGroupButtons';
if (is_string($addonOrButtons)) {
$addonOrButtons = $this->_makeIcon($addonOrButtons);
if (!Matching::findTagOrAttribute(
'button', ['type' => 'submit'], $addonOrButtons)) {
$template = 'inputGroupAddons';
}
}
else {
$addonOrButtons = implode('', $addonOrButtons);
}
$addonOrButtons = $this->formatTemplate($template, [
'content' => $addonOrButtons
]);
}
return $addonOrButtons;
} | php | protected function _wrapInputGroup($addonOrButtons) {
if ($addonOrButtons) {
$template = 'inputGroupButtons';
if (is_string($addonOrButtons)) {
$addonOrButtons = $this->_makeIcon($addonOrButtons);
if (!Matching::findTagOrAttribute(
'button', ['type' => 'submit'], $addonOrButtons)) {
$template = 'inputGroupAddons';
}
}
else {
$addonOrButtons = implode('', $addonOrButtons);
}
$addonOrButtons = $this->formatTemplate($template, [
'content' => $addonOrButtons
]);
}
return $addonOrButtons;
} | [
"protected",
"function",
"_wrapInputGroup",
"(",
"$",
"addonOrButtons",
")",
"{",
"if",
"(",
"$",
"addonOrButtons",
")",
"{",
"$",
"template",
"=",
"'inputGroupButtons'",
";",
"if",
"(",
"is_string",
"(",
"$",
"addonOrButtons",
")",
")",
"{",
"$",
"addonOrBu... | Wraps the given string corresponding to add-ons or buttons inside a HTML wrapper
element.
If `$addonOrButtons` is an array, it should contains buttons and will be wrapped
accordingly. If `$addonOrButtons` is a string, the wrapper will be chosen depending
on the content (see `_matchButton()`).
@param string|array $addonOrButtons Content to be wrapped or array of buttons to be
wrapped.
@return string The elements wrapped in a suitable HTML element. | [
"Wraps",
"the",
"given",
"string",
"corresponding",
"to",
"add",
"-",
"ons",
"or",
"buttons",
"inside",
"a",
"HTML",
"wrapper",
"element",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L317-L335 |
43,512 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/FormHelper.php | FormHelper.prepend | public function prepend($input, $prepend) {
$prepend = $this->_wrapInputGroup($prepend);
if ($input === null) {
return $this->formatTemplate('inputGroupStart', ['prepend' => $prepend]);
}
return $this->_wrap($input, $prepend, null);
} | php | public function prepend($input, $prepend) {
$prepend = $this->_wrapInputGroup($prepend);
if ($input === null) {
return $this->formatTemplate('inputGroupStart', ['prepend' => $prepend]);
}
return $this->_wrap($input, $prepend, null);
} | [
"public",
"function",
"prepend",
"(",
"$",
"input",
",",
"$",
"prepend",
")",
"{",
"$",
"prepend",
"=",
"$",
"this",
"->",
"_wrapInputGroup",
"(",
"$",
"prepend",
")",
";",
"if",
"(",
"$",
"input",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"-... | Prepend the given content to the given input or create an opening input group.
@param string|null $input Input to which `$prepend` will be prepend, or
null to create an opening input group.
@param string|array $prepend The content to prepend.,
@return string The input with the content of `$prepend` prepended or an
opening `<div>` for an input group. | [
"Prepend",
"the",
"given",
"content",
"to",
"the",
"given",
"input",
"or",
"create",
"an",
"opening",
"input",
"group",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L369-L375 |
43,513 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/FormHelper.php | FormHelper.append | public function append($input, $append) {
$append = $this->_wrapInputGroup($append);
if ($input === null) {
return $this->formatTemplate('inputGroupEnd', ['append' => $append]);
}
return $this->_wrap($input, null, $append);
} | php | public function append($input, $append) {
$append = $this->_wrapInputGroup($append);
if ($input === null) {
return $this->formatTemplate('inputGroupEnd', ['append' => $append]);
}
return $this->_wrap($input, null, $append);
} | [
"public",
"function",
"append",
"(",
"$",
"input",
",",
"$",
"append",
")",
"{",
"$",
"append",
"=",
"$",
"this",
"->",
"_wrapInputGroup",
"(",
"$",
"append",
")",
";",
"if",
"(",
"$",
"input",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
... | Append the given content to the given input or close an input group.
@param string|null $input Input to which `$append` will be append, or
null to create a closing element for an input group.
@param string|array $append The content to append.,
@return string The input with the content of `$append` appended or a
closing `</div>` for an input group. | [
"Append",
"the",
"given",
"content",
"to",
"the",
"given",
"input",
"or",
"close",
"an",
"input",
"group",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L387-L393 |
43,514 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/FormHelper.php | FormHelper.buttonGroup | public function buttonGroup($buttons, array $options = []) {
$options += [
'vertical' => false,
'templateVars' => []
];
if ($options['vertical']) {
$options = $this->addClass($options, 'btn-group-vertical');
}
return $this->formatTemplate('buttonGroup', [
'content' => implode('', $buttons),
'attrs' => $this->templater()->formatAttributes($options, ['vertical']),
'templateVars' => $options['templateVars']
]);
} | php | public function buttonGroup($buttons, array $options = []) {
$options += [
'vertical' => false,
'templateVars' => []
];
if ($options['vertical']) {
$options = $this->addClass($options, 'btn-group-vertical');
}
return $this->formatTemplate('buttonGroup', [
'content' => implode('', $buttons),
'attrs' => $this->templater()->formatAttributes($options, ['vertical']),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"buttonGroup",
"(",
"$",
"buttons",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'vertical'",
"=>",
"false",
",",
"'templateVars'",
"=>",
"[",
"]",
"]",
";",
"if",
"(",
"$",
"options",
"[",
... | Creates a button group using the given buttons.
### Options
- `vertical` Specifies if the group should be vertical. Default to `false`.
Other options are passed to the `Html::tag` method.
@param array $buttons Array of buttons for the group.
@param array $options Array of options. See above.
@return string A HTML string containing the button group. | [
"Creates",
"a",
"button",
"group",
"using",
"the",
"given",
"buttons",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L605-L618 |
43,515 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/FormHelper.php | FormHelper.buttonToolbar | public function buttonToolbar(array $buttonGroups, array $options = array()) {
$options += [
'templateVars' => []
];
return $this->formatTemplate('buttonToolbar', [
'content' => implode('', $buttonGroups),
'attrs' => $this->templater()->formatAttributes($options, ['vertical']),
'templateVars' => $options['templateVars']
]);
} | php | public function buttonToolbar(array $buttonGroups, array $options = array()) {
$options += [
'templateVars' => []
];
return $this->formatTemplate('buttonToolbar', [
'content' => implode('', $buttonGroups),
'attrs' => $this->templater()->formatAttributes($options, ['vertical']),
'templateVars' => $options['templateVars']
]);
} | [
"public",
"function",
"buttonToolbar",
"(",
"array",
"$",
"buttonGroups",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"+=",
"[",
"'templateVars'",
"=>",
"[",
"]",
"]",
";",
"return",
"$",
"this",
"->",
"formatTemplate"... | Creates a button toolbar using the given button groups.
@param array $buttonGroups Array of groups for the toolbar
@param array $options Array of options for the `Html::div` method.
@return string A HTML string containing the button toolbar. | [
"Creates",
"a",
"button",
"toolbar",
"using",
"the",
"given",
"button",
"groups",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L628-L637 |
43,516 | Holt59/cakephp3-bootstrap-helpers | src/View/Helper/FormHelper.php | FormHelper.dropdownButton | public function dropdownButton($title, array $menu = [], array $options = []) {
// List of options to send to the dropdown() method
$optsForHtml = ['align'];
$ulOptions = [];
foreach ($optsForHtml as $opt) {
if (isset($options[$opt])) {
$ulOptions[$opt] = $options[$opt];
unset($options[$opt]);
}
}
$options += [
'type' => false,
'dropup' => false,
'data-toggle' => 'dropdown'
];
$dropup = $options['dropup'];
unset($options['dropup']);
$bGroupOptions = [];
if ($dropup) {
$bGroupOptions = $this->addClass($bGroupOptions, 'dropup');
}
$options = $this->addClass($options, 'dropdown-toggle');
return $this->buttonGroup([
$this->button($title.' <span class="caret"></span>', $options),
$this->Html->dropdown($menu, $ulOptions)
], $bGroupOptions);
} | php | public function dropdownButton($title, array $menu = [], array $options = []) {
// List of options to send to the dropdown() method
$optsForHtml = ['align'];
$ulOptions = [];
foreach ($optsForHtml as $opt) {
if (isset($options[$opt])) {
$ulOptions[$opt] = $options[$opt];
unset($options[$opt]);
}
}
$options += [
'type' => false,
'dropup' => false,
'data-toggle' => 'dropdown'
];
$dropup = $options['dropup'];
unset($options['dropup']);
$bGroupOptions = [];
if ($dropup) {
$bGroupOptions = $this->addClass($bGroupOptions, 'dropup');
}
$options = $this->addClass($options, 'dropdown-toggle');
return $this->buttonGroup([
$this->button($title.' <span class="caret"></span>', $options),
$this->Html->dropdown($menu, $ulOptions)
], $bGroupOptions);
} | [
"public",
"function",
"dropdownButton",
"(",
"$",
"title",
",",
"array",
"$",
"menu",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// List of options to send to the dropdown() method",
"$",
"optsForHtml",
"=",
"[",
"'align'",
"]",
"... | Creates a dropdown button.
This function is a shortcut for:
```php
$this->Form->$buttonGroup([
$this->Form->button($title, $options),
$this->Html->dropdown($menu, [])
]);
```
@param string $title The text for the button.
@param array $menu HTML elements corresponding to menu options (which will be wrapped
into `<li>` tag). To add separator, pass 'divider'. See `BootstrapHtml::dropdown()`.
@param array $options Array of options for the button. See `button()`.
@return string A HTML string containing the button dropdown. | [
"Creates",
"a",
"dropdown",
"button",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L658-L687 |
43,517 | Holt59/cakephp3-bootstrap-helpers | src/View/Widget/ColumnSelectBoxWidget.php | ColumnSelectBoxWidget.render | public function render(array $data, \Cake\View\Form\ContextInterface $context)
{
$data += [
'name' => '',
'empty' => false,
'escape' => true,
'options' => [],
'disabled' => null,
'val' => null,
'templateVars' => []
];
$options = $this->_renderContent($data);
$name = $data['name'];
unset($data['name'], $data['options'], $data['empty'], $data['val'], $data['escape']);
if (isset($data['disabled']) && is_array($data['disabled'])) {
unset($data['disabled']);
}
return $this->_templates->format('selectColumn', [
'name' => $name,
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes($data),
'content' => implode('', $options),
]);
} | php | public function render(array $data, \Cake\View\Form\ContextInterface $context)
{
$data += [
'name' => '',
'empty' => false,
'escape' => true,
'options' => [],
'disabled' => null,
'val' => null,
'templateVars' => []
];
$options = $this->_renderContent($data);
$name = $data['name'];
unset($data['name'], $data['options'], $data['empty'], $data['val'], $data['escape']);
if (isset($data['disabled']) && is_array($data['disabled'])) {
unset($data['disabled']);
}
return $this->_templates->format('selectColumn', [
'name' => $name,
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes($data),
'content' => implode('', $options),
]);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"\\",
"Cake",
"\\",
"View",
"\\",
"Form",
"\\",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"+=",
"[",
"'name'",
"=>",
"''",
",",
"'empty'",
"=>",
"false",
",",
"'escape'",
... | Render a select box form input inside a column.
Render a select box input given a set of data. Supported keys
are:
- `name` - Set the input name.
- `options` - An array of options.
- `disabled` - Either true or an array of options to disable.
When true, the select element will be disabled.
- `val` - Either a string or an array of options to mark as selected.
- `empty` - Set to true to add an empty option at the top of the
option elements. Set to a string to define the display text of the
empty option. If an array is used the key will set the value of the empty
option while, the value will set the display text.
- `escape` - Set to false to disable HTML escaping.
### Options format
See `Cake\View\Widget\SelectBoxWidget::render()` methods.
@param array $data Data to render with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string A generated select box.
@throws \RuntimeException when the name attribute is empty. | [
"Render",
"a",
"select",
"box",
"form",
"input",
"inside",
"a",
"column",
"."
] | 30dda77c540a8da7d336a1201acb86bced220cb8 | https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Widget/ColumnSelectBoxWidget.php#L53-L76 |
43,518 | Ingenico-ePayments/connect-sdk-php | lib/Ingenico/Connect/Sdk/Webhooks/InMemorySecretKeyStore.php | InMemorySecretKeyStore.storeSecretKey | public function storeSecretKey($keyId, $secretKey)
{
if (is_null($keyId) || strlen(trim($keyId)) == 0) {
throw new UnexpectedValueException("keyId is required");
}
if (is_null($secretKey) || strlen(trim($secretKey)) == 0) {
throw new UnexpectedValueException("secretKey is required");
}
$this->secretKeys[$keyId] = $secretKey;
} | php | public function storeSecretKey($keyId, $secretKey)
{
if (is_null($keyId) || strlen(trim($keyId)) == 0) {
throw new UnexpectedValueException("keyId is required");
}
if (is_null($secretKey) || strlen(trim($secretKey)) == 0) {
throw new UnexpectedValueException("secretKey is required");
}
$this->secretKeys[$keyId] = $secretKey;
} | [
"public",
"function",
"storeSecretKey",
"(",
"$",
"keyId",
",",
"$",
"secretKey",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"keyId",
")",
"||",
"strlen",
"(",
"trim",
"(",
"$",
"keyId",
")",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"UnexpectedValueE... | Stores the given secret key for the given key id.
@param string $keyId
@param string $secretKey | [
"Stores",
"the",
"given",
"secret",
"key",
"for",
"the",
"given",
"key",
"id",
"."
] | 97154626b4b6116a176c356e4676f1794e396586 | https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/InMemorySecretKeyStore.php#L42-L51 |
43,519 | Ingenico-ePayments/connect-sdk-php | lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php | WebhooksHelper.unmarshal | public function unmarshal($body, $requestHeaders)
{
$this->validate($body, $requestHeaders);
$response = new DefaultConnectionResponse(200, array('Content-Type' => 'application/json'), $body);
$responseClassMap = new ResponseClassMap();
$responseClassMap->addResponseClassName(200, '\Ingenico\Connect\Sdk\Domain\Webhooks\WebhooksEvent');
$event = $this->getResponseFactory()->createResponse($response, $responseClassMap);
$this->validateApiVersion($event);
return $event;
} | php | public function unmarshal($body, $requestHeaders)
{
$this->validate($body, $requestHeaders);
$response = new DefaultConnectionResponse(200, array('Content-Type' => 'application/json'), $body);
$responseClassMap = new ResponseClassMap();
$responseClassMap->addResponseClassName(200, '\Ingenico\Connect\Sdk\Domain\Webhooks\WebhooksEvent');
$event = $this->getResponseFactory()->createResponse($response, $responseClassMap);
$this->validateApiVersion($event);
return $event;
} | [
"public",
"function",
"unmarshal",
"(",
"$",
"body",
",",
"$",
"requestHeaders",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"body",
",",
"$",
"requestHeaders",
")",
";",
"$",
"response",
"=",
"new",
"DefaultConnectionResponse",
"(",
"200",
",",
"... | Unmarshals the given input stream that contains the body,
while also validating its contents using the given request headers.
@param string $body
@param array $requestHeaders
@return WebhooksEvent
@throws SignatureValidationException
@throws ApiVersionMismatchException | [
"Unmarshals",
"the",
"given",
"input",
"stream",
"that",
"contains",
"the",
"body",
"while",
"also",
"validating",
"its",
"contents",
"using",
"the",
"given",
"request",
"headers",
"."
] | 97154626b4b6116a176c356e4676f1794e396586 | https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php#L49-L60 |
43,520 | Ingenico-ePayments/connect-sdk-php | lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php | WebhooksHelper.validateBody | private function validateBody($body, $requestHeaders)
{
$signature = $this->getHeaderValue($requestHeaders, 'X-GCS-Signature');
$keyId = $this->getHeaderValue($requestHeaders, 'X-GCS-KeyId');
$secretKey = $this->secretKeyStore->getSecretKey($keyId);
$expectedSignature = base64_encode(hash_hmac("sha256", $body, $secretKey, true));
$isValid = $this->areEqualSignatures($signature, $expectedSignature);
if (!$isValid) {
throw new SignatureValidationException("failed to validate signature '$signature'");
}
} | php | private function validateBody($body, $requestHeaders)
{
$signature = $this->getHeaderValue($requestHeaders, 'X-GCS-Signature');
$keyId = $this->getHeaderValue($requestHeaders, 'X-GCS-KeyId');
$secretKey = $this->secretKeyStore->getSecretKey($keyId);
$expectedSignature = base64_encode(hash_hmac("sha256", $body, $secretKey, true));
$isValid = $this->areEqualSignatures($signature, $expectedSignature);
if (!$isValid) {
throw new SignatureValidationException("failed to validate signature '$signature'");
}
} | [
"private",
"function",
"validateBody",
"(",
"$",
"body",
",",
"$",
"requestHeaders",
")",
"{",
"$",
"signature",
"=",
"$",
"this",
"->",
"getHeaderValue",
"(",
"$",
"requestHeaders",
",",
"'X-GCS-Signature'",
")",
";",
"$",
"keyId",
"=",
"$",
"this",
"->",... | validation utility methods | [
"validation",
"utility",
"methods"
] | 97154626b4b6116a176c356e4676f1794e396586 | https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php#L75-L87 |
43,521 | Ingenico-ePayments/connect-sdk-php | lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php | WebhooksHelper.validateApiVersion | private function validateApiVersion($event)
{
if (Client::API_VERSION !== $event->apiVersion) {
throw new ApiVersionMismatchException($event->apiVersion, Client::API_VERSION);
}
} | php | private function validateApiVersion($event)
{
if (Client::API_VERSION !== $event->apiVersion) {
throw new ApiVersionMismatchException($event->apiVersion, Client::API_VERSION);
}
} | [
"private",
"function",
"validateApiVersion",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"Client",
"::",
"API_VERSION",
"!==",
"$",
"event",
"->",
"apiVersion",
")",
"{",
"throw",
"new",
"ApiVersionMismatchException",
"(",
"$",
"event",
"->",
"apiVersion",
",",
... | general utility methods | [
"general",
"utility",
"methods"
] | 97154626b4b6116a176c356e4676f1794e396586 | https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php#L107-L112 |
43,522 | activecollab/activecollab-feather-sdk | src/Client.php | Client.prepareUrl | private function prepareUrl($path)
{
$bits = parse_url($path);
$path = isset($bits['path']) && $bits['path'] ? $bits['path'] : '/';
if (substr($path, 0, 1) !== '/') {
$path = '/' . $path;
}
$query = isset($bits['query']) && $bits['query'] ? '?' . $bits['query'] : '';
return $this->getUrl() . '/api/v' . $this->getApiVersion() . $path . $query;
} | php | private function prepareUrl($path)
{
$bits = parse_url($path);
$path = isset($bits['path']) && $bits['path'] ? $bits['path'] : '/';
if (substr($path, 0, 1) !== '/') {
$path = '/' . $path;
}
$query = isset($bits['query']) && $bits['query'] ? '?' . $bits['query'] : '';
return $this->getUrl() . '/api/v' . $this->getApiVersion() . $path . $query;
} | [
"private",
"function",
"prepareUrl",
"(",
"$",
"path",
")",
"{",
"$",
"bits",
"=",
"parse_url",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"isset",
"(",
"$",
"bits",
"[",
"'path'",
"]",
")",
"&&",
"$",
"bits",
"[",
"'path'",
"]",
"?",
"$",
"... | Prepare URL from the given path.
@param string $path
@return string | [
"Prepare",
"URL",
"from",
"the",
"given",
"path",
"."
] | 061e952f30e20df33a160b13adb4dd70d324ba70 | https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Client.php#L173-L186 |
43,523 | activecollab/activecollab-feather-sdk | src/Client.php | Client.prepareAttachments | private function prepareAttachments($attachments = null)
{
$file_params = [];
if ($attachments) {
$counter = 1;
foreach ($attachments as $attachment) {
$path = is_array($attachment) ? $attachment[0] : $attachment;
if (is_readable($path)) {
$file_params['attachment_'.$counter++] = $attachment;
} else {
throw new FileNotReadable($attachment);
}
}
}
return $file_params;
} | php | private function prepareAttachments($attachments = null)
{
$file_params = [];
if ($attachments) {
$counter = 1;
foreach ($attachments as $attachment) {
$path = is_array($attachment) ? $attachment[0] : $attachment;
if (is_readable($path)) {
$file_params['attachment_'.$counter++] = $attachment;
} else {
throw new FileNotReadable($attachment);
}
}
}
return $file_params;
} | [
"private",
"function",
"prepareAttachments",
"(",
"$",
"attachments",
"=",
"null",
")",
"{",
"$",
"file_params",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"attachments",
")",
"{",
"$",
"counter",
"=",
"1",
";",
"foreach",
"(",
"$",
"attachments",
"as",
"$",
... | Prepare attachments for request.
@param array|null $attachments
@return array|null
@throws Exceptions\FileNotReadable | [
"Prepare",
"attachments",
"for",
"request",
"."
] | 061e952f30e20df33a160b13adb4dd70d324ba70 | https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Client.php#L209-L228 |
43,524 | activecollab/activecollab-feather-sdk | src/Response.php | Response.isJson | public function isJson()
{
if ($this->is_json === null) {
$this->is_json = strpos($this->getContentType(), 'application/json') !== false;
}
return $this->is_json;
} | php | public function isJson()
{
if ($this->is_json === null) {
$this->is_json = strpos($this->getContentType(), 'application/json') !== false;
}
return $this->is_json;
} | [
"public",
"function",
"isJson",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_json",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"is_json",
"=",
"strpos",
"(",
"$",
"this",
"->",
"getContentType",
"(",
")",
",",
"'application/json'",
")",
"!==",
"... | Return true if response is JSON.
@return bool | [
"Return",
"true",
"if",
"response",
"is",
"JSON",
"."
] | 061e952f30e20df33a160b13adb4dd70d324ba70 | https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Response.php#L122-L129 |
43,525 | activecollab/activecollab-feather-sdk | src/Connector.php | Connector.& | private function &getHandle($url, $headers)
{
$http = curl_init();
curl_setopt($http, CURLOPT_USERAGENT, $this->getUserAgent());
curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
curl_setopt($http, CURLINFO_HEADER_OUT, true);
curl_setopt($http, CURLOPT_URL, $url);
if (!$this->getSslVerifyPeer()) {
curl_setopt($http, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($http, CURLOPT_SSL_VERIFYHOST, false);
}
if (is_array($headers) && count($headers)) {
curl_setopt($http, CURLOPT_HTTPHEADER, $headers);
}
$this->response_headers = [];
curl_setopt(
$http,
CURLOPT_HEADERFUNCTION,
function($curl, $header) {
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) {
return $len;
}
$name = strtolower(trim($header[0]));
if (!array_key_exists($name, $this->response_headers)) {
$this->response_headers[$name] = [trim($header[1])];
} else {
$this->response_headers[$name][] = trim($header[1]);
}
return $len;
}
);
return $http;
} | php | private function &getHandle($url, $headers)
{
$http = curl_init();
curl_setopt($http, CURLOPT_USERAGENT, $this->getUserAgent());
curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
curl_setopt($http, CURLINFO_HEADER_OUT, true);
curl_setopt($http, CURLOPT_URL, $url);
if (!$this->getSslVerifyPeer()) {
curl_setopt($http, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($http, CURLOPT_SSL_VERIFYHOST, false);
}
if (is_array($headers) && count($headers)) {
curl_setopt($http, CURLOPT_HTTPHEADER, $headers);
}
$this->response_headers = [];
curl_setopt(
$http,
CURLOPT_HEADERFUNCTION,
function($curl, $header) {
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) {
return $len;
}
$name = strtolower(trim($header[0]));
if (!array_key_exists($name, $this->response_headers)) {
$this->response_headers[$name] = [trim($header[1])];
} else {
$this->response_headers[$name][] = trim($header[1]);
}
return $len;
}
);
return $http;
} | [
"private",
"function",
"&",
"getHandle",
"(",
"$",
"url",
",",
"$",
"headers",
")",
"{",
"$",
"http",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"http",
",",
"CURLOPT_USERAGENT",
",",
"$",
"this",
"->",
"getUserAgent",
"(",
")",
")",
"... | Return curl resource.
@param string $url
@param array|null $headers
@return resource | [
"Return",
"curl",
"resource",
"."
] | 061e952f30e20df33a160b13adb4dd70d324ba70 | https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Connector.php#L182-L226 |
43,526 | activecollab/activecollab-feather-sdk | src/Connector.php | Connector.execute | private function execute(&$http)
{
$raw_response = curl_exec($http);
if ($raw_response === false) {
$error_code = curl_errno($http);
$error_message = curl_error($http);
curl_close($http);
throw new CallFailed($error_code, $raw_response, null, $error_message);
} else {
$response = new Response($http, $raw_response, $this->response_headers);
curl_close($http);
return $response;
}
} | php | private function execute(&$http)
{
$raw_response = curl_exec($http);
if ($raw_response === false) {
$error_code = curl_errno($http);
$error_message = curl_error($http);
curl_close($http);
throw new CallFailed($error_code, $raw_response, null, $error_message);
} else {
$response = new Response($http, $raw_response, $this->response_headers);
curl_close($http);
return $response;
}
} | [
"private",
"function",
"execute",
"(",
"&",
"$",
"http",
")",
"{",
"$",
"raw_response",
"=",
"curl_exec",
"(",
"$",
"http",
")",
";",
"if",
"(",
"$",
"raw_response",
"===",
"false",
")",
"{",
"$",
"error_code",
"=",
"curl_errno",
"(",
"$",
"http",
")... | Do the call.
@param resource $http
@return string
@throws CallFailed | [
"Do",
"the",
"call",
"."
] | 061e952f30e20df33a160b13adb4dd70d324ba70 | https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Connector.php#L235-L252 |
43,527 | activecollab/activecollab-feather-sdk | src/Authenticator/Cloud.php | Cloud.loadAccountsAndUser | private function loadAccountsAndUser()
{
if (!$this->accounts_and_user_loaded) {
$email_address = $this->getEmailAddress();
$password = $this->getPassword();
if (empty($email_address) || empty($password)) {
throw new Authentication('Email address and password are required');
}
$response = $this->getConnector()->post('https://my.activecollab.com/api/v1/external/login', null, [
'email' => $this->getEmailAddress(),
'password' => $this->getPassword(),
]);
if ($response instanceof ResponseInterface) {
if ($response->isJson()) {
$result = $response->getJson();
if (empty($result['is_ok'])) {
if (empty($result['message'])) {
throw new ListAccounts();
} else {
throw new ListAccounts($result['message']);
}
} elseif (empty($result['user']) || empty($result['user']['intent'])) {
throw new ListAccounts('Invalid response');
} else {
$this->accounts = $this->all_accounts = [];
if (!empty($result['accounts']) && is_array($result['accounts'])) {
foreach ($result['accounts'] as $account) {
$this->all_accounts[] = $account;
if ($account['class'] == 'FeatherApplicationInstance' || $account['class'] == 'ActiveCollab\Shepherd\Model\Account\ActiveCollab\FeatherAccount') {
$account_id = (integer) $account['name'];
$this->accounts[$account_id] = [
'id' => (integer) $account['name'],
'name' => $account['display_name'],
'url' => $account['url'],
];
}
}
}
$this->intent = $result['user']['intent'];
unset($result['user']['intent']);
$this->user = $result['user'];
}
} else {
throw new Authentication(
sprintf(
'Invalid response. JSON expected, got "%s", status code "%s"',
$response->getContentType(),
$response->getHttpCode()
)
);
}
} else {
throw new Authentication('Invalid response');
}
}
} | php | private function loadAccountsAndUser()
{
if (!$this->accounts_and_user_loaded) {
$email_address = $this->getEmailAddress();
$password = $this->getPassword();
if (empty($email_address) || empty($password)) {
throw new Authentication('Email address and password are required');
}
$response = $this->getConnector()->post('https://my.activecollab.com/api/v1/external/login', null, [
'email' => $this->getEmailAddress(),
'password' => $this->getPassword(),
]);
if ($response instanceof ResponseInterface) {
if ($response->isJson()) {
$result = $response->getJson();
if (empty($result['is_ok'])) {
if (empty($result['message'])) {
throw new ListAccounts();
} else {
throw new ListAccounts($result['message']);
}
} elseif (empty($result['user']) || empty($result['user']['intent'])) {
throw new ListAccounts('Invalid response');
} else {
$this->accounts = $this->all_accounts = [];
if (!empty($result['accounts']) && is_array($result['accounts'])) {
foreach ($result['accounts'] as $account) {
$this->all_accounts[] = $account;
if ($account['class'] == 'FeatherApplicationInstance' || $account['class'] == 'ActiveCollab\Shepherd\Model\Account\ActiveCollab\FeatherAccount') {
$account_id = (integer) $account['name'];
$this->accounts[$account_id] = [
'id' => (integer) $account['name'],
'name' => $account['display_name'],
'url' => $account['url'],
];
}
}
}
$this->intent = $result['user']['intent'];
unset($result['user']['intent']);
$this->user = $result['user'];
}
} else {
throw new Authentication(
sprintf(
'Invalid response. JSON expected, got "%s", status code "%s"',
$response->getContentType(),
$response->getHttpCode()
)
);
}
} else {
throw new Authentication('Invalid response');
}
}
} | [
"private",
"function",
"loadAccountsAndUser",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"accounts_and_user_loaded",
")",
"{",
"$",
"email_address",
"=",
"$",
"this",
"->",
"getEmailAddress",
"(",
")",
";",
"$",
"password",
"=",
"$",
"this",
"->",
... | Load account and user details from Active Collab ID. | [
"Load",
"account",
"and",
"user",
"details",
"from",
"Active",
"Collab",
"ID",
"."
] | 061e952f30e20df33a160b13adb4dd70d324ba70 | https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Authenticator/Cloud.php#L134-L197 |
43,528 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.toArray | public function toArray()
{
return array(
'scheme' => $this->scheme->get(),
'user' => $this->user->get(),
'pass' => $this->pass->get(),
'host' => $this->host->get(),
'port' => $this->port->get(),
'path' => $this->path->get(),
'query' => $this->query->get(),
'fragment' => $this->fragment->get(),
);
} | php | public function toArray()
{
return array(
'scheme' => $this->scheme->get(),
'user' => $this->user->get(),
'pass' => $this->pass->get(),
'host' => $this->host->get(),
'port' => $this->port->get(),
'path' => $this->path->get(),
'query' => $this->query->get(),
'fragment' => $this->fragment->get(),
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'scheme'",
"=>",
"$",
"this",
"->",
"scheme",
"->",
"get",
"(",
")",
",",
"'user'",
"=>",
"$",
"this",
"->",
"user",
"->",
"get",
"(",
")",
",",
"'pass'",
"=>",
"$",
"this",
... | Retuns a array representation like parse_url
But includes all components
@return array | [
"Retuns",
"a",
"array",
"representation",
"like",
"parse_url",
"But",
"includes",
"all",
"components"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L174-L186 |
43,529 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.createFromUrl | public static function createFromUrl($url)
{
$url = (string) $url;
$url = trim($url);
$original_url = $url;
$url = self::sanitizeUrl($url);
//if no valid scheme is found we add one
if (is_null($url)) {
throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $original_url));
}
$components = array_merge(array(
'scheme' => null,
'user' => null,
'pass' => null,
'host' => null,
'port' => null,
'path' => null,
'query' => null,
'fragment' => null,
), self::parseUrl($url));
$components = self::formatAuthComponent($components);
$components = self::formatPathComponent($components, $original_url);
return new static(
new Components\Scheme($components['scheme']),
new Components\User($components['user']),
new Components\Pass($components['pass']),
new Components\Host($components['host']),
new Components\Port($components['port']),
new Components\Path($components['path']),
new Components\Query($components['query']),
new Components\Fragment($components['fragment'])
);
} | php | public static function createFromUrl($url)
{
$url = (string) $url;
$url = trim($url);
$original_url = $url;
$url = self::sanitizeUrl($url);
//if no valid scheme is found we add one
if (is_null($url)) {
throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $original_url));
}
$components = array_merge(array(
'scheme' => null,
'user' => null,
'pass' => null,
'host' => null,
'port' => null,
'path' => null,
'query' => null,
'fragment' => null,
), self::parseUrl($url));
$components = self::formatAuthComponent($components);
$components = self::formatPathComponent($components, $original_url);
return new static(
new Components\Scheme($components['scheme']),
new Components\User($components['user']),
new Components\Pass($components['pass']),
new Components\Host($components['host']),
new Components\Port($components['port']),
new Components\Path($components['path']),
new Components\Query($components['query']),
new Components\Fragment($components['fragment'])
);
} | [
"public",
"static",
"function",
"createFromUrl",
"(",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"url",
";",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"$",
"original_url",
"=",
"$",
"url",
";",
"$",
"url",
"=",
"s... | Return a instance of Url from a string
@param string $url a string or an object that implement the __toString method
@return static
@throws RuntimeException If the URL can not be parse | [
"Return",
"a",
"instance",
"of",
"Url",
"from",
"a",
"string"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L197-L232 |
43,530 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.parseUrl | protected static function parseUrl($url)
{
$components = @parse_url($url);
if (! empty($components)) {
return $components;
}
if (is_null(static::$is_parse_url_bugged)) {
static::$is_parse_url_bugged = ! is_array(@parse_url("//example.org:80"));
}
//bugfix for https://bugs.php.net/bug.php?id=68917
if (static::$is_parse_url_bugged &&
strpos($url, '/') === 0 &&
is_array($components = @parse_url('http:'.$url))
) {
unset($components['scheme']);
return $components;
}
throw new RuntimeException(sprintf("The given URL: `%s` could not be parse", $url));
} | php | protected static function parseUrl($url)
{
$components = @parse_url($url);
if (! empty($components)) {
return $components;
}
if (is_null(static::$is_parse_url_bugged)) {
static::$is_parse_url_bugged = ! is_array(@parse_url("//example.org:80"));
}
//bugfix for https://bugs.php.net/bug.php?id=68917
if (static::$is_parse_url_bugged &&
strpos($url, '/') === 0 &&
is_array($components = @parse_url('http:'.$url))
) {
unset($components['scheme']);
return $components;
}
throw new RuntimeException(sprintf("The given URL: `%s` could not be parse", $url));
} | [
"protected",
"static",
"function",
"parseUrl",
"(",
"$",
"url",
")",
"{",
"$",
"components",
"=",
"@",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"components",
")",
")",
"{",
"return",
"$",
"components",
";",
"}",
"i... | Parse a string as an URL
@param string $url The URL to parse
@throws InvalidArgumentException if the URL can not be parsed
@return array | [
"Parse",
"a",
"string",
"as",
"an",
"URL"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L243-L263 |
43,531 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.createFromServer | public static function createFromServer(array $server)
{
$scheme = self::fetchServerScheme($server);
$host = self::fetchServerHost($server);
$port = self::fetchServerPort($server);
$request = self::fetchServerRequestUri($server);
return self::createFromUrl($scheme.$host.$port.$request);
} | php | public static function createFromServer(array $server)
{
$scheme = self::fetchServerScheme($server);
$host = self::fetchServerHost($server);
$port = self::fetchServerPort($server);
$request = self::fetchServerRequestUri($server);
return self::createFromUrl($scheme.$host.$port.$request);
} | [
"public",
"static",
"function",
"createFromServer",
"(",
"array",
"$",
"server",
")",
"{",
"$",
"scheme",
"=",
"self",
"::",
"fetchServerScheme",
"(",
"$",
"server",
")",
";",
"$",
"host",
"=",
"self",
"::",
"fetchServerHost",
"(",
"$",
"server",
")",
";... | Return a instance of Url from a server array
@param array $server the server array
@return static
@throws RuntimeException If the URL can not be parse | [
"Return",
"a",
"instance",
"of",
"Url",
"from",
"a",
"server",
"array"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L292-L300 |
43,532 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.fetchServerScheme | protected static function fetchServerScheme(array $server)
{
$scheme = '';
if (isset($server['SERVER_PROTOCOL'])) {
$scheme = explode('/', $server['SERVER_PROTOCOL']);
$scheme = strtolower($scheme[0]);
if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) {
$scheme .= 's';
}
$scheme .= ':';
}
return $scheme.'//';
} | php | protected static function fetchServerScheme(array $server)
{
$scheme = '';
if (isset($server['SERVER_PROTOCOL'])) {
$scheme = explode('/', $server['SERVER_PROTOCOL']);
$scheme = strtolower($scheme[0]);
if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) {
$scheme .= 's';
}
$scheme .= ':';
}
return $scheme.'//';
} | [
"protected",
"static",
"function",
"fetchServerScheme",
"(",
"array",
"$",
"server",
")",
"{",
"$",
"scheme",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
")",
"{",
"$",
"scheme",
"=",
"explode",
"(",
"'/'... | Return the Server URL scheme component
@param array $server the server array
@return string | [
"Return",
"the",
"Server",
"URL",
"scheme",
"component"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L309-L322 |
43,533 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.fetchServerHost | protected static function fetchServerHost(array $server)
{
if (isset($server['HTTP_HOST'])) {
$header = $server['HTTP_HOST'];
if (! preg_match('/(:\d+)$/', $header, $matches)) {
return $header;
}
return substr($header, 0, -strlen($matches[1]));
}
if (isset($server['SERVER_ADDR'])) {
return $server['SERVER_ADDR'];
}
throw new RuntimeException('Host could not be detected');
} | php | protected static function fetchServerHost(array $server)
{
if (isset($server['HTTP_HOST'])) {
$header = $server['HTTP_HOST'];
if (! preg_match('/(:\d+)$/', $header, $matches)) {
return $header;
}
return substr($header, 0, -strlen($matches[1]));
}
if (isset($server['SERVER_ADDR'])) {
return $server['SERVER_ADDR'];
}
throw new RuntimeException('Host could not be detected');
} | [
"protected",
"static",
"function",
"fetchServerHost",
"(",
"array",
"$",
"server",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
")",
")",
"{",
"$",
"header",
"=",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
";",
"if",
"(",
"... | Return the Server URL host component
@param array $server the server array
@return string
@throws \RuntimeException If no host is detected | [
"Return",
"the",
"Server",
"URL",
"host",
"component"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L333-L349 |
43,534 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.fetchServerPort | protected static function fetchServerPort(array $server)
{
$port = '';
if (isset($server['SERVER_PORT']) && '80' != $server['SERVER_PORT']) {
$port = ':'. (int) $server['SERVER_PORT'];
}
return $port;
} | php | protected static function fetchServerPort(array $server)
{
$port = '';
if (isset($server['SERVER_PORT']) && '80' != $server['SERVER_PORT']) {
$port = ':'. (int) $server['SERVER_PORT'];
}
return $port;
} | [
"protected",
"static",
"function",
"fetchServerPort",
"(",
"array",
"$",
"server",
")",
"{",
"$",
"port",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'SERVER_PORT'",
"]",
")",
"&&",
"'80'",
"!=",
"$",
"server",
"[",
"'SERVER_PORT'",
"... | Return the Server URL port component
@param array $server the server array
@return string | [
"Return",
"the",
"Server",
"URL",
"port",
"component"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L358-L366 |
43,535 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.formatAuthComponent | protected static function formatAuthComponent(array $components)
{
if (!is_null($components['scheme'])
&& is_null($components['host'])
&& !empty($components['path'])
&& strpos($components['path'], '@') !== false
) {
$tmp = explode('@', $components['path'], 2);
$components['user'] = $components['scheme'];
$components['pass'] = $tmp[0];
$components['path'] = $tmp[1];
$components['scheme'] = null;
}
return $components;
} | php | protected static function formatAuthComponent(array $components)
{
if (!is_null($components['scheme'])
&& is_null($components['host'])
&& !empty($components['path'])
&& strpos($components['path'], '@') !== false
) {
$tmp = explode('@', $components['path'], 2);
$components['user'] = $components['scheme'];
$components['pass'] = $tmp[0];
$components['path'] = $tmp[1];
$components['scheme'] = null;
}
return $components;
} | [
"protected",
"static",
"function",
"formatAuthComponent",
"(",
"array",
"$",
"components",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"components",
"[",
"'scheme'",
"]",
")",
"&&",
"is_null",
"(",
"$",
"components",
"[",
"'host'",
"]",
")",
"&&",
"!"... | Reformat the component according to the auth content
@param array $components the result from parse_url
@return array | [
"Reformat",
"the",
"component",
"according",
"to",
"the",
"auth",
"content"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L395-L410 |
43,536 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.formatHostComponent | protected static function formatHostComponent(array $components)
{
if (strpos($components['host'], '@')) {
list($auth, $components['host']) = explode('@', $components['host']);
$components['user'] = $auth;
$components['pass'] = null;
if (false !== strpos($auth, ':')) {
list($components['user'], $components['pass']) = explode(':', $auth);
}
}
return $components;
} | php | protected static function formatHostComponent(array $components)
{
if (strpos($components['host'], '@')) {
list($auth, $components['host']) = explode('@', $components['host']);
$components['user'] = $auth;
$components['pass'] = null;
if (false !== strpos($auth, ':')) {
list($components['user'], $components['pass']) = explode(':', $auth);
}
}
return $components;
} | [
"protected",
"static",
"function",
"formatHostComponent",
"(",
"array",
"$",
"components",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"components",
"[",
"'host'",
"]",
",",
"'@'",
")",
")",
"{",
"list",
"(",
"$",
"auth",
",",
"$",
"components",
"[",
"'ho... | Reformat the component according to the host content
@param array $components the result from parse_url
@return array | [
"Reformat",
"the",
"component",
"according",
"to",
"the",
"host",
"content"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L419-L431 |
43,537 | thephpleague/url | src/AbstractUrl.php | AbstractUrl.formatPathComponent | protected static function formatPathComponent(array $components, $url)
{
if (is_null($components['scheme'])
&& is_null($components['host'])
&& !empty($components['path'])
) {
if (0 === strpos($components['path'], '///')) {
//even with the added scheme the URL is still broken
throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $url));
}
if (0 === strpos($components['path'], '//')) {
$tmp = substr($components['path'], 2);
$components['path'] = null;
$res = explode('/', $tmp, 2);
$components['host'] = $res[0];
if (isset($res[1])) {
$components['path'] = $res[1];
}
$components = self::formatHostComponent($components);
}
}
return $components;
} | php | protected static function formatPathComponent(array $components, $url)
{
if (is_null($components['scheme'])
&& is_null($components['host'])
&& !empty($components['path'])
) {
if (0 === strpos($components['path'], '///')) {
//even with the added scheme the URL is still broken
throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $url));
}
if (0 === strpos($components['path'], '//')) {
$tmp = substr($components['path'], 2);
$components['path'] = null;
$res = explode('/', $tmp, 2);
$components['host'] = $res[0];
if (isset($res[1])) {
$components['path'] = $res[1];
}
$components = self::formatHostComponent($components);
}
}
return $components;
} | [
"protected",
"static",
"function",
"formatPathComponent",
"(",
"array",
"$",
"components",
",",
"$",
"url",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"components",
"[",
"'scheme'",
"]",
")",
"&&",
"is_null",
"(",
"$",
"components",
"[",
"'host'",
"]",
")... | Reformat the component according to the path content
@param array $components the result from parse_url
@param string $url the original URL to be parse
@return array | [
"Reformat",
"the",
"component",
"according",
"to",
"the",
"path",
"content"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L441-L465 |
43,538 | thephpleague/url | src/Components/AbstractArray.php | AbstractArray.convertToArray | protected function convertToArray($data, Closure $callback)
{
if (is_null($data)) {
return array();
}
if ($data instanceof Traversable) {
return iterator_to_array($data);
}
if (self::isStringable($data)) {
$data = (string) $data;
$data = trim($data);
$data = $callback($data);
}
if (! is_array($data)) {
throw new RuntimeException('Your submitted data could not be converted into a proper array');
}
return $data;
} | php | protected function convertToArray($data, Closure $callback)
{
if (is_null($data)) {
return array();
}
if ($data instanceof Traversable) {
return iterator_to_array($data);
}
if (self::isStringable($data)) {
$data = (string) $data;
$data = trim($data);
$data = $callback($data);
}
if (! is_array($data)) {
throw new RuntimeException('Your submitted data could not be converted into a proper array');
}
return $data;
} | [
"protected",
"function",
"convertToArray",
"(",
"$",
"data",
",",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"data",
"instanceof",
"Traversable",
... | convert a given data into an array
@param mixed $data the data to insert
@param \Closure $callback a callable function to be called to parse
a given string into the corresponding component
@return array
@throws \RuntimeException if the data is not valid | [
"convert",
"a",
"given",
"data",
"into",
"an",
"array"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractArray.php#L134-L155 |
43,539 | thephpleague/url | src/Components/Host.php | Host.validate | protected function validate($data)
{
$data = $this->validateSegment($data);
if (! $data) {
return $data;
}
$this->saveInternalEncoding();
if (! $this->isValidHostLength($data)) {
$this->restoreInternalEncoding();
throw new RuntimeException('Invalid hostname, check its length');
}
if (! $this->isValidHostPattern($data)) {
$this->restoreInternalEncoding();
throw new RuntimeException('Invalid host label, check its content');
}
if (! $this->isValidHostLabels($data)) {
$this->restoreInternalEncoding();
throw new RuntimeException('Invalid host label counts, check its count');
}
$data = $this->sanitizeValue($data);
$data = explode(
$this->delimiter,
$this->punycode->decode(implode($this->delimiter, $data))
);
$this->restoreInternalEncoding();
return $data;
} | php | protected function validate($data)
{
$data = $this->validateSegment($data);
if (! $data) {
return $data;
}
$this->saveInternalEncoding();
if (! $this->isValidHostLength($data)) {
$this->restoreInternalEncoding();
throw new RuntimeException('Invalid hostname, check its length');
}
if (! $this->isValidHostPattern($data)) {
$this->restoreInternalEncoding();
throw new RuntimeException('Invalid host label, check its content');
}
if (! $this->isValidHostLabels($data)) {
$this->restoreInternalEncoding();
throw new RuntimeException('Invalid host label counts, check its count');
}
$data = $this->sanitizeValue($data);
$data = explode(
$this->delimiter,
$this->punycode->decode(implode($this->delimiter, $data))
);
$this->restoreInternalEncoding();
return $data;
} | [
"protected",
"function",
"validate",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"validateSegment",
"(",
"$",
"data",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
"$",
"data",
";",
"}",
"$",
"this",
"->",
"saveI... | Validate Host data before insertion into a URL host component
@param mixed $data the data to insert
@return array
@throws RuntimeException If the added is invalid | [
"Validate",
"Host",
"data",
"before",
"insertion",
"into",
"a",
"URL",
"host",
"component"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/Host.php#L149-L180 |
43,540 | thephpleague/url | src/Components/AbstractComponent.php | AbstractComponent.sanitizeComponent | protected function sanitizeComponent($str)
{
if (is_null($str)) {
return $str;
}
$str = filter_var((string) $str, FILTER_UNSAFE_RAW, array('flags' => FILTER_FLAG_STRIP_LOW));
$str = trim($str);
return $str;
} | php | protected function sanitizeComponent($str)
{
if (is_null($str)) {
return $str;
}
$str = filter_var((string) $str, FILTER_UNSAFE_RAW, array('flags' => FILTER_FLAG_STRIP_LOW));
$str = trim($str);
return $str;
} | [
"protected",
"function",
"sanitizeComponent",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"$",
"str",
"=",
"filter_var",
"(",
"(",
"string",
")",
"$",
"str",
",",
"FILTER_UNSAFE_RAW... | Sanitize a string component
@param mixed $str
@return string|null | [
"Sanitize",
"a",
"string",
"component"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractComponent.php#L99-L108 |
43,541 | thephpleague/url | src/Components/AbstractSegment.php | AbstractSegment.sanitizeValue | protected function sanitizeValue($str)
{
if (is_array($str)) {
foreach ($str as &$value) {
$value = $this->sanitizeValue($value);
}
unset($value);
return $str;
}
$str = filter_var((string) $str, FILTER_UNSAFE_RAW, array('flags' => FILTER_FLAG_STRIP_LOW));
$str = trim($str);
return $str;
} | php | protected function sanitizeValue($str)
{
if (is_array($str)) {
foreach ($str as &$value) {
$value = $this->sanitizeValue($value);
}
unset($value);
return $str;
}
$str = filter_var((string) $str, FILTER_UNSAFE_RAW, array('flags' => FILTER_FLAG_STRIP_LOW));
$str = trim($str);
return $str;
} | [
"protected",
"function",
"sanitizeValue",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"str",
")",
")",
"{",
"foreach",
"(",
"$",
"str",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"sanitizeValue",
"(",
... | Sanitize a string component recursively
@param mixed $str
@return mixed | [
"Sanitize",
"a",
"string",
"component",
"recursively"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractSegment.php#L95-L110 |
43,542 | thephpleague/url | src/Components/AbstractSegment.php | AbstractSegment.offsetSet | public function offsetSet($offset, $value)
{
$data = $this->data;
if (is_null($offset)) {
$data[] = $value;
$this->set($data);
return;
}
$offset = filter_var($offset, FILTER_VALIDATE_INT, array('min_range' => 0));
if (false === $offset) {
throw new InvalidArgumentException('Offset must be an integer');
}
$data[$offset] = $value;
$this->set($data);
} | php | public function offsetSet($offset, $value)
{
$data = $this->data;
if (is_null($offset)) {
$data[] = $value;
$this->set($data);
return;
}
$offset = filter_var($offset, FILTER_VALIDATE_INT, array('min_range' => 0));
if (false === $offset) {
throw new InvalidArgumentException('Offset must be an integer');
}
$data[$offset] = $value;
$this->set($data);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"value",
";",
"$",
... | ArrayAccess Interface method
@param int|string $offset
@param mixed $value | [
"ArrayAccess",
"Interface",
"method"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractSegment.php#L118-L133 |
43,543 | thephpleague/url | src/Components/AbstractSegment.php | AbstractSegment.validateSegment | protected function validateSegment($data)
{
$delimiter = $this->delimiter;
return $this->convertToArray($data, function ($str) use ($delimiter) {
if ('' == $str) {
return array();
}
if ($delimiter == $str[0]) {
$str = substr($str, 1);
}
return explode($delimiter, $str);
});
} | php | protected function validateSegment($data)
{
$delimiter = $this->delimiter;
return $this->convertToArray($data, function ($str) use ($delimiter) {
if ('' == $str) {
return array();
}
if ($delimiter == $str[0]) {
$str = substr($str, 1);
}
return explode($delimiter, $str);
});
} | [
"protected",
"function",
"validateSegment",
"(",
"$",
"data",
")",
"{",
"$",
"delimiter",
"=",
"$",
"this",
"->",
"delimiter",
";",
"return",
"$",
"this",
"->",
"convertToArray",
"(",
"$",
"data",
",",
"function",
"(",
"$",
"str",
")",
"use",
"(",
"$",... | Validate data before insertion into a URL segment based component
@param mixed $data the data to insert
@return array
@throws \RuntimeException if the data is not valid | [
"Validate",
"data",
"before",
"insertion",
"into",
"a",
"URL",
"segment",
"based",
"component"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractSegment.php#L199-L213 |
43,544 | thephpleague/url | src/Components/AbstractSegment.php | AbstractSegment.appendSegment | protected function appendSegment(array $left, array $value, $whence = null, $whence_index = null)
{
$right = array();
if (null !== $whence && count($found = array_keys($left, $whence))) {
array_reverse($found);
$index = $found[0];
if (array_key_exists($whence_index, $found)) {
$index = $found[$whence_index];
}
$right = array_slice($left, $index+1);
$left = array_slice($left, 0, $index+1);
}
return array_merge($left, $value, $right);
} | php | protected function appendSegment(array $left, array $value, $whence = null, $whence_index = null)
{
$right = array();
if (null !== $whence && count($found = array_keys($left, $whence))) {
array_reverse($found);
$index = $found[0];
if (array_key_exists($whence_index, $found)) {
$index = $found[$whence_index];
}
$right = array_slice($left, $index+1);
$left = array_slice($left, 0, $index+1);
}
return array_merge($left, $value, $right);
} | [
"protected",
"function",
"appendSegment",
"(",
"array",
"$",
"left",
",",
"array",
"$",
"value",
",",
"$",
"whence",
"=",
"null",
",",
"$",
"whence_index",
"=",
"null",
")",
"{",
"$",
"right",
"=",
"array",
"(",
")",
";",
"if",
"(",
"null",
"!==",
... | Append some data to a given array
@param array $left the original array
@param array $value the data to prepend
@param string $whence the value of the data to prepend before
@param integer $whence_index the occurrence index for $whence
@return array | [
"Append",
"some",
"data",
"to",
"a",
"given",
"array"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractSegment.php#L225-L239 |
43,545 | thephpleague/url | src/Components/AbstractSegment.php | AbstractSegment.fetchRemainingSegment | protected function fetchRemainingSegment(array $data, $value)
{
$segment = implode($this->delimiter, $data);
if ('' == $value) {
if ($index = array_search('', $data, true)) {
$left = array_slice($data, 0, $index);
$right = array_slice($data, $index+1);
return implode($this->delimiter, array_merge($left, $right));
}
return $segment;
}
$part = implode($this->delimiter, $this->formatRemoveSegment($value));
$regexStart = '@(:?^|\\'.$this->delimiter.')';
if (! preg_match($regexStart.preg_quote($part, '@').'@', $segment, $matches, PREG_OFFSET_CAPTURE)) {
return null;
}
$pos = $matches[0][1];
return substr($segment, 0, $pos).substr($segment, $pos + strlen($part) + 1);
} | php | protected function fetchRemainingSegment(array $data, $value)
{
$segment = implode($this->delimiter, $data);
if ('' == $value) {
if ($index = array_search('', $data, true)) {
$left = array_slice($data, 0, $index);
$right = array_slice($data, $index+1);
return implode($this->delimiter, array_merge($left, $right));
}
return $segment;
}
$part = implode($this->delimiter, $this->formatRemoveSegment($value));
$regexStart = '@(:?^|\\'.$this->delimiter.')';
if (! preg_match($regexStart.preg_quote($part, '@').'@', $segment, $matches, PREG_OFFSET_CAPTURE)) {
return null;
}
$pos = $matches[0][1];
return substr($segment, 0, $pos).substr($segment, $pos + strlen($part) + 1);
} | [
"protected",
"function",
"fetchRemainingSegment",
"(",
"array",
"$",
"data",
",",
"$",
"value",
")",
"{",
"$",
"segment",
"=",
"implode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"data",
")",
";",
"if",
"(",
"''",
"==",
"$",
"value",
")",
"{",
... | Remove some data from a given array
@param array $data the original array
@param mixed $value the data to be removed (can be an array or a single segment)
@return string|null
@throws \RuntimeException If $value is invalid | [
"Remove",
"some",
"data",
"from",
"a",
"given",
"array"
] | 45f5529ea879ffc166cc4e4ffa478a212c183628 | https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractSegment.php#L276-L301 |
43,546 | pear/Log | Log/composite.php | Log_composite.open | function open()
{
/* Attempt to open each of our children. */
$this->_opened = true;
foreach ($this->_children as $child) {
$this->_opened &= $child->open();
}
/* If all children were opened, return success. */
return $this->_opened;
} | php | function open()
{
/* Attempt to open each of our children. */
$this->_opened = true;
foreach ($this->_children as $child) {
$this->_opened &= $child->open();
}
/* If all children were opened, return success. */
return $this->_opened;
} | [
"function",
"open",
"(",
")",
"{",
"/* Attempt to open each of our children. */",
"$",
"this",
"->",
"_opened",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_children",
"as",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"_opened",
"&=",
"$",
"child"... | Opens all of the child instances.
@return True if all of the child instances were successfully opened.
@access public | [
"Opens",
"all",
"of",
"the",
"child",
"instances",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/composite.php#L58-L68 |
43,547 | pear/Log | Log/composite.php | Log_composite.close | function close()
{
/* If we haven't been opened, there's nothing more to do. */
if (!$this->_opened) {
return true;
}
/* Attempt to close each of our children. */
$closed = true;
foreach ($this->_children as $child) {
if ($child->_opened) {
$closed &= $child->close();
}
}
/* Clear the opened state for consistency. */
$this->_opened = false;
/* If all children were closed, return success. */
return $closed;
} | php | function close()
{
/* If we haven't been opened, there's nothing more to do. */
if (!$this->_opened) {
return true;
}
/* Attempt to close each of our children. */
$closed = true;
foreach ($this->_children as $child) {
if ($child->_opened) {
$closed &= $child->close();
}
}
/* Clear the opened state for consistency. */
$this->_opened = false;
/* If all children were closed, return success. */
return $closed;
} | [
"function",
"close",
"(",
")",
"{",
"/* If we haven't been opened, there's nothing more to do. */",
"if",
"(",
"!",
"$",
"this",
"->",
"_opened",
")",
"{",
"return",
"true",
";",
"}",
"/* Attempt to close each of our children. */",
"$",
"closed",
"=",
"true",
";",
"... | Closes all open child instances.
@return True if all of the opened child instances were successfully
closed.
@access public | [
"Closes",
"all",
"open",
"child",
"instances",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/composite.php#L78-L98 |
43,548 | pear/Log | Log/composite.php | Log_composite.flush | function flush()
{
/* Attempt to flush each of our children. */
$flushed = true;
foreach ($this->_children as $child) {
$flushed &= $child->flush();
}
/* If all children were flushed, return success. */
return $flushed;
} | php | function flush()
{
/* Attempt to flush each of our children. */
$flushed = true;
foreach ($this->_children as $child) {
$flushed &= $child->flush();
}
/* If all children were flushed, return success. */
return $flushed;
} | [
"function",
"flush",
"(",
")",
"{",
"/* Attempt to flush each of our children. */",
"$",
"flushed",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_children",
"as",
"$",
"child",
")",
"{",
"$",
"flushed",
"&=",
"$",
"child",
"->",
"flush",
"(",
")",... | Flushes all child instances. It is assumed that all of the children
have been successfully opened.
@return True if all of the child instances were successfully flushed.
@access public
@since Log 1.8.2 | [
"Flushes",
"all",
"child",
"instances",
".",
"It",
"is",
"assumed",
"that",
"all",
"of",
"the",
"children",
"have",
"been",
"successfully",
"opened",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/composite.php#L109-L119 |
43,549 | pear/Log | Log/composite.php | Log_composite.setIdent | function setIdent($ident)
{
/* Call our base class's setIdent() method. */
parent::setIdent($ident);
/* ... and then call setIdent() on all of our children. */
foreach ($this->_children as $child) {
$child->setIdent($ident);
}
} | php | function setIdent($ident)
{
/* Call our base class's setIdent() method. */
parent::setIdent($ident);
/* ... and then call setIdent() on all of our children. */
foreach ($this->_children as $child) {
$child->setIdent($ident);
}
} | [
"function",
"setIdent",
"(",
"$",
"ident",
")",
"{",
"/* Call our base class's setIdent() method. */",
"parent",
"::",
"setIdent",
"(",
"$",
"ident",
")",
";",
"/* ... and then call setIdent() on all of our children. */",
"foreach",
"(",
"$",
"this",
"->",
"_children",
... | Sets this identification string for all of this composite's children.
@param string $ident The new identification string.
@access public
@since Log 1.6.7 | [
"Sets",
"this",
"identification",
"string",
"for",
"all",
"of",
"this",
"composite",
"s",
"children",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/composite.php#L222-L231 |
43,550 | pear/Log | Log/composite.php | Log_composite.addChild | function addChild(&$child)
{
/* Make sure this is a Log instance. */
if (!is_a($child, 'Log')) {
return false;
}
$this->_children[$child->_id] = $child;
return true;
} | php | function addChild(&$child)
{
/* Make sure this is a Log instance. */
if (!is_a($child, 'Log')) {
return false;
}
$this->_children[$child->_id] = $child;
return true;
} | [
"function",
"addChild",
"(",
"&",
"$",
"child",
")",
"{",
"/* Make sure this is a Log instance. */",
"if",
"(",
"!",
"is_a",
"(",
"$",
"child",
",",
"'Log'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_children",
"[",
"$",
"child",
... | Adds a Log instance to the list of children.
@param object $child The Log instance to add.
@return boolean True if the Log instance was successfully added.
@access public | [
"Adds",
"a",
"Log",
"instance",
"to",
"the",
"list",
"of",
"children",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/composite.php#L242-L252 |
43,551 | pear/Log | Log/composite.php | Log_composite.removeChild | function removeChild($child)
{
if (!is_a($child, 'Log') || !isset($this->_children[$child->_id])) {
return false;
}
unset($this->_children[$child->_id]);
return true;
} | php | function removeChild($child)
{
if (!is_a($child, 'Log') || !isset($this->_children[$child->_id])) {
return false;
}
unset($this->_children[$child->_id]);
return true;
} | [
"function",
"removeChild",
"(",
"$",
"child",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"child",
",",
"'Log'",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"_children",
"[",
"$",
"child",
"->",
"_id",
"]",
")",
")",
"{",
"return",
"false",
... | Removes a Log instance from the list of children.
@param object $child The Log instance to remove.
@return boolean True if the Log instance was successfully removed.
@access public | [
"Removes",
"a",
"Log",
"instance",
"from",
"the",
"list",
"of",
"children",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/composite.php#L263-L272 |
43,552 | pear/Log | Log/observer.php | Log_observer.& | function &factory($type, $priority = PEAR_LOG_INFO, $conf = array())
{
$type = strtolower($type);
$class = 'Log_observer_' . $type;
/*
* If the desired class already exists (because the caller has supplied
* it from some custom location), simply instantiate and return a new
* instance.
*/
if (class_exists($class)) {
$object = new $class($priority, $conf);
return $object;
}
/* Support both the new-style and old-style file naming conventions. */
$newstyle = true;
$classfile = dirname(__FILE__) . '/observer_' . $type . '.php';
if (!file_exists($classfile)) {
$classfile = 'Log/' . $type . '.php';
$newstyle = false;
}
/*
* Attempt to include our version of the named class, but don't treat
* a failure as fatal. The caller may have already included their own
* version of the named class.
*/
@include_once $classfile;
/* If the class exists, return a new instance of it. */
if (class_exists($class)) {
/* Support both new-style and old-style construction. */
if ($newstyle) {
$object = new $class($priority, $conf);
} else {
$object = new $class($priority);
}
return $object;
}
$null = null;
return $null;
} | php | function &factory($type, $priority = PEAR_LOG_INFO, $conf = array())
{
$type = strtolower($type);
$class = 'Log_observer_' . $type;
/*
* If the desired class already exists (because the caller has supplied
* it from some custom location), simply instantiate and return a new
* instance.
*/
if (class_exists($class)) {
$object = new $class($priority, $conf);
return $object;
}
/* Support both the new-style and old-style file naming conventions. */
$newstyle = true;
$classfile = dirname(__FILE__) . '/observer_' . $type . '.php';
if (!file_exists($classfile)) {
$classfile = 'Log/' . $type . '.php';
$newstyle = false;
}
/*
* Attempt to include our version of the named class, but don't treat
* a failure as fatal. The caller may have already included their own
* version of the named class.
*/
@include_once $classfile;
/* If the class exists, return a new instance of it. */
if (class_exists($class)) {
/* Support both new-style and old-style construction. */
if ($newstyle) {
$object = new $class($priority, $conf);
} else {
$object = new $class($priority);
}
return $object;
}
$null = null;
return $null;
} | [
"function",
"&",
"factory",
"(",
"$",
"type",
",",
"$",
"priority",
"=",
"PEAR_LOG_INFO",
",",
"$",
"conf",
"=",
"array",
"(",
")",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"$",
"class",
"=",
"'Log_observer_'",
".",
"$"... | Attempts to return a new concrete Log_observer instance of the requested
type.
@param string $type The type of concreate Log_observer subclass
to return.
@param integer $priority The highest priority at which to receive
log event notifications.
@param array $conf Optional associative array of additional
configuration values.
@return object The newly created concrete Log_observer
instance, or null on an error. | [
"Attempts",
"to",
"return",
"a",
"new",
"concrete",
"Log_observer",
"instance",
"of",
"the",
"requested",
"type",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/observer.php#L70-L114 |
43,553 | pear/Log | Log/win.php | Log_win.close | function close()
{
/*
* If there are still lines waiting to be written, open the output
* window so that we can drain the buffer.
*/
if (!$this->_opened && (count($this->_buffer) > 0)) {
$this->open();
}
if ($this->_opened) {
$this->_writeln('</table>');
$this->_writeln('</body></html>');
$this->_drainBuffer();
$this->_opened = false;
}
return ($this->_opened === false);
} | php | function close()
{
/*
* If there are still lines waiting to be written, open the output
* window so that we can drain the buffer.
*/
if (!$this->_opened && (count($this->_buffer) > 0)) {
$this->open();
}
if ($this->_opened) {
$this->_writeln('</table>');
$this->_writeln('</body></html>');
$this->_drainBuffer();
$this->_opened = false;
}
return ($this->_opened === false);
} | [
"function",
"close",
"(",
")",
"{",
"/*\n * If there are still lines waiting to be written, open the output\n * window so that we can drain the buffer.\n */",
"if",
"(",
"!",
"$",
"this",
"->",
"_opened",
"&&",
"(",
"count",
"(",
"$",
"this",
"->",
"_b... | Closes the output stream if it is open. If there are still pending
lines in the output buffer, the output window will be opened so that
the buffer can be drained.
@access public | [
"Closes",
"the",
"output",
"stream",
"if",
"it",
"is",
"open",
".",
"If",
"there",
"are",
"still",
"pending",
"lines",
"in",
"the",
"output",
"buffer",
"the",
"output",
"window",
"will",
"be",
"opened",
"so",
"that",
"the",
"buffer",
"can",
"be",
"draine... | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/win.php#L173-L191 |
43,554 | pear/Log | Log/win.php | Log_win._drainBuffer | function _drainBuffer()
{
$win = $this->_name;
foreach ($this->_buffer as $line) {
echo "<script language='JavaScript'>\n";
echo "$win.document.writeln('" . addslashes($line) . "');\n";
echo "self.focus();\n";
echo "</script>\n";
}
/* Now that the buffer has been drained, clear it. */
$this->_buffer = array();
} | php | function _drainBuffer()
{
$win = $this->_name;
foreach ($this->_buffer as $line) {
echo "<script language='JavaScript'>\n";
echo "$win.document.writeln('" . addslashes($line) . "');\n";
echo "self.focus();\n";
echo "</script>\n";
}
/* Now that the buffer has been drained, clear it. */
$this->_buffer = array();
} | [
"function",
"_drainBuffer",
"(",
")",
"{",
"$",
"win",
"=",
"$",
"this",
"->",
"_name",
";",
"foreach",
"(",
"$",
"this",
"->",
"_buffer",
"as",
"$",
"line",
")",
"{",
"echo",
"\"<script language='JavaScript'>\\n\"",
";",
"echo",
"\"$win.document.writeln('\"",... | Writes the contents of the output buffer to the output window.
@access private | [
"Writes",
"the",
"contents",
"of",
"the",
"output",
"buffer",
"to",
"the",
"output",
"window",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/win.php#L198-L210 |
43,555 | pear/Log | Log/win.php | Log_win._writeln | function _writeln($line)
{
/* Add this line to our output buffer. */
$this->_buffer[] = $line;
/* Buffer the output until this page's headers have been sent. */
if (!headers_sent()) {
return;
}
/* If we haven't already opened the output window, do so now. */
if (!$this->_opened && !$this->open()) {
return;
}
/* Drain the buffer to the output window. */
$this->_drainBuffer();
} | php | function _writeln($line)
{
/* Add this line to our output buffer. */
$this->_buffer[] = $line;
/* Buffer the output until this page's headers have been sent. */
if (!headers_sent()) {
return;
}
/* If we haven't already opened the output window, do so now. */
if (!$this->_opened && !$this->open()) {
return;
}
/* Drain the buffer to the output window. */
$this->_drainBuffer();
} | [
"function",
"_writeln",
"(",
"$",
"line",
")",
"{",
"/* Add this line to our output buffer. */",
"$",
"this",
"->",
"_buffer",
"[",
"]",
"=",
"$",
"line",
";",
"/* Buffer the output until this page's headers have been sent. */",
"if",
"(",
"!",
"headers_sent",
"(",
")... | Writes a single line of text to the output buffer.
@param string $line The line of text to write.
@access private | [
"Writes",
"a",
"single",
"line",
"of",
"text",
"to",
"the",
"output",
"buffer",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/win.php#L219-L236 |
43,556 | pear/Log | Log.php | Log._extractMessage | function _extractMessage($message)
{
/*
* If we've been given an object, attempt to extract the message using
* a known method. If we can't find such a method, default to the
* "human-readable" version of the object.
*
* We also use the human-readable format for arrays.
*/
if (is_object($message)) {
if (method_exists($message, 'getmessage')) {
$message = $message->getMessage();
} else if (method_exists($message, 'tostring')) {
$message = $message->toString();
} else if (method_exists($message, '__tostring')) {
$message = (string)$message;
} else {
$message = var_export($message, true);
}
} else if (is_array($message)) {
if (isset($message['message'])) {
if (is_scalar($message['message'])) {
$message = $message['message'];
} else {
$message = var_export($message['message'], true);
}
} else {
$message = var_export($message, true);
}
} else if (is_bool($message) || $message === NULL) {
$message = var_export($message, true);
}
/* Otherwise, we assume the message is a string. */
return $message;
} | php | function _extractMessage($message)
{
/*
* If we've been given an object, attempt to extract the message using
* a known method. If we can't find such a method, default to the
* "human-readable" version of the object.
*
* We also use the human-readable format for arrays.
*/
if (is_object($message)) {
if (method_exists($message, 'getmessage')) {
$message = $message->getMessage();
} else if (method_exists($message, 'tostring')) {
$message = $message->toString();
} else if (method_exists($message, '__tostring')) {
$message = (string)$message;
} else {
$message = var_export($message, true);
}
} else if (is_array($message)) {
if (isset($message['message'])) {
if (is_scalar($message['message'])) {
$message = $message['message'];
} else {
$message = var_export($message['message'], true);
}
} else {
$message = var_export($message, true);
}
} else if (is_bool($message) || $message === NULL) {
$message = var_export($message, true);
}
/* Otherwise, we assume the message is a string. */
return $message;
} | [
"function",
"_extractMessage",
"(",
"$",
"message",
")",
"{",
"/*\n * If we've been given an object, attempt to extract the message using\n * a known method. If we can't find such a method, default to the\n * \"human-readable\" version of the object.\n *\n * We... | Returns the string representation of the message data.
If $message is an object, _extractMessage() will attempt to extract
the message text using a known method (such as a PEAR_Error object's
getMessage() method). If a known method, cannot be found, the
serialized representation of the object will be returned.
If the message data is already a string, it will be returned unchanged.
@param mixed $message The original message data. This may be a
string or any object.
@return string The string representation of the message.
@access protected | [
"Returns",
"the",
"string",
"representation",
"of",
"the",
"message",
"data",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log.php#L409-L444 |
43,557 | pear/Log | Log.php | Log._format | function _format($format, $timestamp, $priority, $message)
{
/*
* If the format string references any of the backtrace-driven
* variables (%5 %6,%7,%8), generate the backtrace and fetch them.
*/
if (preg_match('/%[5678]/', $format)) {
/* Plus 2 to account for our internal function calls. */
$d = $this->_backtrace_depth + 2;
list($file, $line, $func, $class) = $this->_getBacktraceVars($d);
}
/*
* Build the formatted string. We use the sprintf() function's
* "argument swapping" capability to dynamically select and position
* the variables which will ultimately appear in the log string.
*/
return sprintf($format,
$timestamp,
$this->_ident,
$this->priorityToString($priority),
$message,
isset($file) ? $file : '',
isset($line) ? $line : '',
isset($func) ? $func : '',
isset($class) ? $class : '');
} | php | function _format($format, $timestamp, $priority, $message)
{
/*
* If the format string references any of the backtrace-driven
* variables (%5 %6,%7,%8), generate the backtrace and fetch them.
*/
if (preg_match('/%[5678]/', $format)) {
/* Plus 2 to account for our internal function calls. */
$d = $this->_backtrace_depth + 2;
list($file, $line, $func, $class) = $this->_getBacktraceVars($d);
}
/*
* Build the formatted string. We use the sprintf() function's
* "argument swapping" capability to dynamically select and position
* the variables which will ultimately appear in the log string.
*/
return sprintf($format,
$timestamp,
$this->_ident,
$this->priorityToString($priority),
$message,
isset($file) ? $file : '',
isset($line) ? $line : '',
isset($func) ? $func : '',
isset($class) ? $class : '');
} | [
"function",
"_format",
"(",
"$",
"format",
",",
"$",
"timestamp",
",",
"$",
"priority",
",",
"$",
"message",
")",
"{",
"/*\n * If the format string references any of the backtrace-driven\n * variables (%5 %6,%7,%8), generate the backtrace and fetch them.\n */"... | Produces a formatted log line based on a format string and a set of
variables representing the current log record and state.
@return string Formatted log string.
@access protected
@since Log 1.9.4 | [
"Produces",
"a",
"formatted",
"log",
"line",
"based",
"on",
"a",
"format",
"string",
"and",
"a",
"set",
"of",
"variables",
"representing",
"the",
"current",
"log",
"record",
"and",
"state",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log.php#L542-L568 |
43,558 | pear/Log | Log.php | Log.attach | function attach(&$observer)
{
if (!is_a($observer, 'Log_observer')) {
return false;
}
$this->_listeners[$observer->_id] = &$observer;
return true;
} | php | function attach(&$observer)
{
if (!is_a($observer, 'Log_observer')) {
return false;
}
$this->_listeners[$observer->_id] = &$observer;
return true;
} | [
"function",
"attach",
"(",
"&",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"observer",
",",
"'Log_observer'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_listeners",
"[",
"$",
"observer",
"->",
"_id",
"]",
"="... | Adds a Log_observer instance to the list of observers that are listening
for messages emitted by this Log instance.
@param object $observer The Log_observer instance to attach as a
listener.
@return boolean True if the observer is successfully attached.
@access public
@since Log 1.0 | [
"Adds",
"a",
"Log_observer",
"instance",
"to",
"the",
"list",
"of",
"observers",
"that",
"are",
"listening",
"for",
"messages",
"emitted",
"by",
"this",
"Log",
"instance",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log.php#L783-L792 |
43,559 | pear/Log | Log.php | Log.detach | function detach($observer)
{
if (!is_a($observer, 'Log_observer') ||
!isset($this->_listeners[$observer->_id])) {
return false;
}
unset($this->_listeners[$observer->_id]);
return true;
} | php | function detach($observer)
{
if (!is_a($observer, 'Log_observer') ||
!isset($this->_listeners[$observer->_id])) {
return false;
}
unset($this->_listeners[$observer->_id]);
return true;
} | [
"function",
"detach",
"(",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"observer",
",",
"'Log_observer'",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"_listeners",
"[",
"$",
"observer",
"->",
"_id",
"]",
")",
")",
"{",
"return... | Removes a Log_observer instance from the list of observers.
@param object $observer The Log_observer instance to detach from
the list of listeners.
@return boolean True if the observer is successfully detached.
@access public
@since Log 1.0 | [
"Removes",
"a",
"Log_observer",
"instance",
"from",
"the",
"list",
"of",
"observers",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log.php#L805-L815 |
43,560 | pear/Log | Log.php | Log._announce | function _announce($event)
{
foreach ($this->_listeners as $id => $listener) {
if ($event['priority'] <= $this->_listeners[$id]->_priority) {
$this->_listeners[$id]->notify($event);
}
}
} | php | function _announce($event)
{
foreach ($this->_listeners as $id => $listener) {
if ($event['priority'] <= $this->_listeners[$id]->_priority) {
$this->_listeners[$id]->notify($event);
}
}
} | [
"function",
"_announce",
"(",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_listeners",
"as",
"$",
"id",
"=>",
"$",
"listener",
")",
"{",
"if",
"(",
"$",
"event",
"[",
"'priority'",
"]",
"<=",
"$",
"this",
"->",
"_listeners",
"[",
"$... | Informs each registered observer instance that a new message has been
logged.
@param array $event A hash describing the log event.
@access protected | [
"Informs",
"each",
"registered",
"observer",
"instance",
"that",
"a",
"new",
"message",
"has",
"been",
"logged",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log.php#L825-L832 |
43,561 | pear/Log | Log/sqlite.php | Log_sqlite._createTable | function _createTable()
{
$q = "SELECT name FROM sqlite_master WHERE name='" . $this->_table .
"' AND type='table'";
$res = sqlite_query($this->_db, $q);
if (sqlite_num_rows($res) == 0) {
$q = 'CREATE TABLE [' . $this->_table . '] (' .
'id INTEGER PRIMARY KEY NOT NULL, ' .
'logtime NOT NULL, ' .
'ident CHAR(16) NOT NULL, ' .
'priority INT NOT NULL, ' .
'message)';
if (!($res = sqlite_unbuffered_query($this->_db, $q))) {
return false;
}
}
return true;
} | php | function _createTable()
{
$q = "SELECT name FROM sqlite_master WHERE name='" . $this->_table .
"' AND type='table'";
$res = sqlite_query($this->_db, $q);
if (sqlite_num_rows($res) == 0) {
$q = 'CREATE TABLE [' . $this->_table . '] (' .
'id INTEGER PRIMARY KEY NOT NULL, ' .
'logtime NOT NULL, ' .
'ident CHAR(16) NOT NULL, ' .
'priority INT NOT NULL, ' .
'message)';
if (!($res = sqlite_unbuffered_query($this->_db, $q))) {
return false;
}
}
return true;
} | [
"function",
"_createTable",
"(",
")",
"{",
"$",
"q",
"=",
"\"SELECT name FROM sqlite_master WHERE name='\"",
".",
"$",
"this",
"->",
"_table",
".",
"\"' AND type='table'\"",
";",
"$",
"res",
"=",
"sqlite_query",
"(",
"$",
"this",
"->",
"_db",
",",
"$",
"q",
... | Checks whether the log table exists and creates it if necessary.
@return boolean True on success or false on failure.
@access private | [
"Checks",
"whether",
"the",
"log",
"table",
"exists",
"and",
"creates",
"it",
"if",
"necessary",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/sqlite.php#L201-L222 |
43,562 | pear/Log | Log/null.php | Log_null.log | function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
} | php | function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
} | [
"function",
"log",
"(",
"$",
"message",
",",
"$",
"priority",
"=",
"null",
")",
"{",
"/* If a priority hasn't been specified, use the default value. */",
"if",
"(",
"$",
"priority",
"===",
"null",
")",
"{",
"$",
"priority",
"=",
"$",
"this",
"->",
"_priority",
... | Simply consumes the log event. The message will still be passed
along to any Log_observer instances that are observing this Log.
@param mixed $message String or object containing the message to log.
@param string $priority The priority of the message. Valid
values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
@return boolean True on success or false on failure.
@access public | [
"Simply",
"consumes",
"the",
"log",
"event",
".",
"The",
"message",
"will",
"still",
"be",
"passed",
"along",
"to",
"any",
"Log_observer",
"instances",
"that",
"are",
"observing",
"this",
"Log",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/null.php#L74-L89 |
43,563 | pear/Log | Log/console.php | Log_console.close | function close()
{
$this->flush();
$this->_opened = false;
if ($this->_closeResource === true && is_resource($this->_stream)) {
fclose($this->_stream);
}
return true;
} | php | function close()
{
$this->flush();
$this->_opened = false;
if ($this->_closeResource === true && is_resource($this->_stream)) {
fclose($this->_stream);
}
return true;
} | [
"function",
"close",
"(",
")",
"{",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"_opened",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"_closeResource",
"===",
"true",
"&&",
"is_resource",
"(",
"$",
"this",
"->",
"_stream",
"... | Closes the output stream.
This results in a call to flush().
@access public
@since Log 1.9.0 | [
"Closes",
"the",
"output",
"stream",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/console.php#L141-L149 |
43,564 | pear/Log | Log/mcal.php | Log_mcal.close | function close()
{
if ($this->_opened) {
mcal_close($this->_stream);
$this->_opened = false;
}
return ($this->_opened === false);
} | php | function close()
{
if ($this->_opened) {
mcal_close($this->_stream);
$this->_opened = false;
}
return ($this->_opened === false);
} | [
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_opened",
")",
"{",
"mcal_close",
"(",
"$",
"this",
"->",
"_stream",
")",
";",
"$",
"this",
"->",
"_opened",
"=",
"false",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"_opened",
"... | Closes the calendar stream, if it is open.
@access public | [
"Closes",
"the",
"calendar",
"stream",
"if",
"it",
"is",
"open",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/mcal.php#L106-L114 |
43,565 | pear/Log | Log/mdb2.php | Log_mdb2._createTable | function _createTable()
{
$this->_db->loadModule('Manager', null, true);
$result = $this->_db->manager->createTable(
$this->_table,
array(
'id' => array('type' => $this->_types['id']),
'logtime' => array('type' => $this->_types['logtime']),
'ident' => array('type' => $this->_types['ident']),
'priority' => array('type' => $this->_types['priority']),
'message' => array('type' => $this->_types['message'])
)
);
if (PEAR::isError($result)) {
return false;
}
$result = $this->_db->manager->createIndex(
$this->_table,
'unique_id',
array('fields' => array('id' => true), 'unique' => true)
);
if (PEAR::isError($result)) {
return false;
}
return true;
} | php | function _createTable()
{
$this->_db->loadModule('Manager', null, true);
$result = $this->_db->manager->createTable(
$this->_table,
array(
'id' => array('type' => $this->_types['id']),
'logtime' => array('type' => $this->_types['logtime']),
'ident' => array('type' => $this->_types['ident']),
'priority' => array('type' => $this->_types['priority']),
'message' => array('type' => $this->_types['message'])
)
);
if (PEAR::isError($result)) {
return false;
}
$result = $this->_db->manager->createIndex(
$this->_table,
'unique_id',
array('fields' => array('id' => true), 'unique' => true)
);
if (PEAR::isError($result)) {
return false;
}
return true;
} | [
"function",
"_createTable",
"(",
")",
"{",
"$",
"this",
"->",
"_db",
"->",
"loadModule",
"(",
"'Manager'",
",",
"null",
",",
"true",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"_db",
"->",
"manager",
"->",
"createTable",
"(",
"$",
"this",
"->",... | Create the log table in the database.
@return boolean True on success or false on failure.
@access private | [
"Create",
"the",
"log",
"table",
"in",
"the",
"database",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/mdb2.php#L310-L337 |
43,566 | pear/Log | Log/file.php | Log_file._mkpath | function _mkpath($path, $mode = 0700)
{
/* Separate the last pathname component from the rest of the path. */
$head = dirname($path);
$tail = basename($path);
/* Make sure we've split the path into two complete components. */
if (empty($tail)) {
$head = dirname($path);
$tail = basename($path);
}
/* Recurse up the path if our current segment does not exist. */
if (!empty($head) && !empty($tail) && !is_dir($head)) {
$this->_mkpath($head, $mode);
}
/* Create this segment of the path. */
return @mkdir($head, $mode);
} | php | function _mkpath($path, $mode = 0700)
{
/* Separate the last pathname component from the rest of the path. */
$head = dirname($path);
$tail = basename($path);
/* Make sure we've split the path into two complete components. */
if (empty($tail)) {
$head = dirname($path);
$tail = basename($path);
}
/* Recurse up the path if our current segment does not exist. */
if (!empty($head) && !empty($tail) && !is_dir($head)) {
$this->_mkpath($head, $mode);
}
/* Create this segment of the path. */
return @mkdir($head, $mode);
} | [
"function",
"_mkpath",
"(",
"$",
"path",
",",
"$",
"mode",
"=",
"0700",
")",
"{",
"/* Separate the last pathname component from the rest of the path. */",
"$",
"head",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"$",
"tail",
"=",
"basename",
"(",
"$",
"path",
... | Creates the given directory path. If the parent directories don't
already exist, they will be created, too.
This implementation is inspired by Python's os.makedirs function.
@param string $path The full directory path to create.
@param integer $mode The permissions mode with which the
directories will be created.
@return True if the full path is successfully created or already
exists.
@access private | [
"Creates",
"the",
"given",
"directory",
"path",
".",
"If",
"the",
"parent",
"directories",
"don",
"t",
"already",
"exist",
"they",
"will",
"be",
"created",
"too",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/file.php#L174-L193 |
43,567 | pear/Log | Log/file.php | Log_file.open | function open()
{
if (!$this->_opened) {
/* If the log file's directory doesn't exist, create it. */
if (!is_dir(dirname($this->_filename))) {
$this->_mkpath($this->_filename, $this->_dirmode);
}
/* Determine whether the log file needs to be created. */
$creating = !file_exists($this->_filename);
/* Obtain a handle to the log file. */
$this->_fp = fopen($this->_filename, ($this->_append) ? 'a' : 'w');
/* We consider the file "opened" if we have a valid file pointer. */
$this->_opened = ($this->_fp !== false);
/* Attempt to set the file's permissions if we just created it. */
if ($creating && $this->_opened) {
chmod($this->_filename, $this->_mode);
}
}
return $this->_opened;
} | php | function open()
{
if (!$this->_opened) {
/* If the log file's directory doesn't exist, create it. */
if (!is_dir(dirname($this->_filename))) {
$this->_mkpath($this->_filename, $this->_dirmode);
}
/* Determine whether the log file needs to be created. */
$creating = !file_exists($this->_filename);
/* Obtain a handle to the log file. */
$this->_fp = fopen($this->_filename, ($this->_append) ? 'a' : 'w');
/* We consider the file "opened" if we have a valid file pointer. */
$this->_opened = ($this->_fp !== false);
/* Attempt to set the file's permissions if we just created it. */
if ($creating && $this->_opened) {
chmod($this->_filename, $this->_mode);
}
}
return $this->_opened;
} | [
"function",
"open",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_opened",
")",
"{",
"/* If the log file's directory doesn't exist, create it. */",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"_filename",
")",
")",
")",
"{",
"$"... | Opens the log file for output. If the specified log file does not
already exist, it will be created. By default, new log entries are
appended to the end of the log file.
This is implicitly called by log(), if necessary.
@access public | [
"Opens",
"the",
"log",
"file",
"for",
"output",
".",
"If",
"the",
"specified",
"log",
"file",
"does",
"not",
"already",
"exist",
"it",
"will",
"be",
"created",
".",
"By",
"default",
"new",
"log",
"entries",
"are",
"appended",
"to",
"the",
"end",
"of",
... | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/file.php#L204-L228 |
43,568 | pear/Log | Log/file.php | Log_file.close | function close()
{
/* If the log file is open, close it. */
if ($this->_opened && fclose($this->_fp)) {
$this->_opened = false;
}
return ($this->_opened === false);
} | php | function close()
{
/* If the log file is open, close it. */
if ($this->_opened && fclose($this->_fp)) {
$this->_opened = false;
}
return ($this->_opened === false);
} | [
"function",
"close",
"(",
")",
"{",
"/* If the log file is open, close it. */",
"if",
"(",
"$",
"this",
"->",
"_opened",
"&&",
"fclose",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"$",
"this",
"->",
"_opened",
"=",
"false",
";",
"}",
"return",
"(",
... | Closes the log file if it is open.
@access public | [
"Closes",
"the",
"log",
"file",
"if",
"it",
"is",
"open",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/file.php#L235-L243 |
43,569 | pear/Log | Log/mail.php | Log_mail.close | function close()
{
if ($this->_opened) {
if ($this->_shouldSend && !empty($this->_message)) {
if ($this->_mailBackend === '') { // use mail()
$headers = "From: $this->_from\r\n";
$headers .= 'User-Agent: PEAR Log Package';
if (mail($this->_recipients, $this->_subject,
$this->_message, $headers) == false) {
return false;
}
} else { // use PEAR::Mail
include_once 'Mail.php';
$headers = array('From' => $this->_from,
'To' => $this->_recipients,
'User-Agent' => 'PEAR Log Package',
'Subject' => $this->_subject);
$mailer = &Mail::factory($this->_mailBackend,
$this->_mailParams);
$res = $mailer->send($this->_recipients, $headers,
$this->_message);
if (PEAR::isError($res)) {
return false;
}
}
/* Clear the message string now that the email has been sent. */
$this->_message = '';
$this->_shouldSend = false;
}
$this->_opened = false;
}
return ($this->_opened === false);
} | php | function close()
{
if ($this->_opened) {
if ($this->_shouldSend && !empty($this->_message)) {
if ($this->_mailBackend === '') { // use mail()
$headers = "From: $this->_from\r\n";
$headers .= 'User-Agent: PEAR Log Package';
if (mail($this->_recipients, $this->_subject,
$this->_message, $headers) == false) {
return false;
}
} else { // use PEAR::Mail
include_once 'Mail.php';
$headers = array('From' => $this->_from,
'To' => $this->_recipients,
'User-Agent' => 'PEAR Log Package',
'Subject' => $this->_subject);
$mailer = &Mail::factory($this->_mailBackend,
$this->_mailParams);
$res = $mailer->send($this->_recipients, $headers,
$this->_message);
if (PEAR::isError($res)) {
return false;
}
}
/* Clear the message string now that the email has been sent. */
$this->_message = '';
$this->_shouldSend = false;
}
$this->_opened = false;
}
return ($this->_opened === false);
} | [
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_opened",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_shouldSend",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"_message",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_mailBackend... | Closes the message, if it is open, and sends the mail.
This is implicitly called by the destructor, if necessary.
@access public | [
"Closes",
"the",
"message",
"if",
"it",
"is",
"open",
"and",
"sends",
"the",
"mail",
".",
"This",
"is",
"implicitly",
"called",
"by",
"the",
"destructor",
"if",
"necessary",
"."
] | bde9c8e735c4941839eafaa86e69edb590be1d60 | https://github.com/pear/Log/blob/bde9c8e735c4941839eafaa86e69edb590be1d60/Log/mail.php#L198-L232 |
43,570 | GinoPane/PHPolyglot | src/API/Supplemental/Yandex/YandexApiTrait.php | YandexApiTrait.filterYandexSpecificErrors | public function filterYandexSpecificErrors(array $responseArray): void
{
if (isset($responseArray['code'])) {
if (($responseArray['code'] !== YandexApiStatusesInterface::STATUS_SUCCESS) &&
isset(self::$customStatusMessages[$responseArray['code']])
) {
$errorMessage = $responseArray['message']
?? self::$customStatusMessages[$responseArray['code']];
throw new BadResponseContextException($errorMessage, $responseArray['code']);
}
}
} | php | public function filterYandexSpecificErrors(array $responseArray): void
{
if (isset($responseArray['code'])) {
if (($responseArray['code'] !== YandexApiStatusesInterface::STATUS_SUCCESS) &&
isset(self::$customStatusMessages[$responseArray['code']])
) {
$errorMessage = $responseArray['message']
?? self::$customStatusMessages[$responseArray['code']];
throw new BadResponseContextException($errorMessage, $responseArray['code']);
}
}
} | [
"public",
"function",
"filterYandexSpecificErrors",
"(",
"array",
"$",
"responseArray",
")",
":",
"void",
"{",
"if",
"(",
"isset",
"(",
"$",
"responseArray",
"[",
"'code'",
"]",
")",
")",
"{",
"if",
"(",
"(",
"$",
"responseArray",
"[",
"'code'",
"]",
"!=... | Checks for Yandex-specific errors and throws exception if error detected
@param array $responseArray
@throws BadResponseContextException | [
"Checks",
"for",
"Yandex",
"-",
"specific",
"errors",
"and",
"throws",
"exception",
"if",
"error",
"detected"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Supplemental/Yandex/YandexApiTrait.php#L52-L64 |
43,571 | GinoPane/PHPolyglot | src/API/Implementation/SpellCheck/SpellCheckApiAbstract.php | SpellCheckApiAbstract.checkTexts | public function checkTexts(array $texts, Language $languageFrom): SpellCheckResponse
{
/** @var SpellCheckResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | php | public function checkTexts(array $texts, Language $languageFrom): SpellCheckResponse
{
/** @var SpellCheckResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | [
"public",
"function",
"checkTexts",
"(",
"array",
"$",
"texts",
",",
"Language",
"$",
"languageFrom",
")",
":",
"SpellCheckResponse",
"{",
"/** @var SpellCheckResponse $response */",
"$",
"response",
"=",
"$",
"this",
"->",
"callApi",
"(",
"__FUNCTION__",
",",
"fu... | Check spelling for multiple text strings
@param array $texts
@param Language $languageFrom
@throws TransportException
@throws ResponseContextException
@throws BadResponseContextException
@throws MethodDoesNotExistException
@return SpellCheckResponse | [
"Check",
"spelling",
"for",
"multiple",
"text",
"strings"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/SpellCheck/SpellCheckApiAbstract.php#L35-L41 |
43,572 | GinoPane/PHPolyglot | src/API/Implementation/TTS/IbmWatson/AudioFormat/IbmWatsonAudioFormatsTrait.php | IbmWatsonAudioFormatsTrait.getAcceptParameter | public function getAcceptParameter(TtsAudioFormat $format, array $additionalData = []): string
{
$audioFormat = self::$formatMapping[$format->getFormat()] ?? '';
if (empty($audioFormat)) {
throw new InvalidAudioFormatCodeException($format->getFormat());
}
$accept = array_merge([$audioFormat], $this->processAdditionalParameters($format, $additionalData));
return implode(";", $accept);
} | php | public function getAcceptParameter(TtsAudioFormat $format, array $additionalData = []): string
{
$audioFormat = self::$formatMapping[$format->getFormat()] ?? '';
if (empty($audioFormat)) {
throw new InvalidAudioFormatCodeException($format->getFormat());
}
$accept = array_merge([$audioFormat], $this->processAdditionalParameters($format, $additionalData));
return implode(";", $accept);
} | [
"public",
"function",
"getAcceptParameter",
"(",
"TtsAudioFormat",
"$",
"format",
",",
"array",
"$",
"additionalData",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"audioFormat",
"=",
"self",
"::",
"$",
"formatMapping",
"[",
"$",
"format",
"->",
"getFormat",... | Returns the string containing the accept parameter required for TTS.
It specifies audio format, sample rate and additional params if any
@param TtsAudioFormat $format
@param array $additionalData
@throws InvalidAudioFormatCodeException
@throws InvalidAudioFormatParameterException
@return string | [
"Returns",
"the",
"string",
"containing",
"the",
"accept",
"parameter",
"required",
"for",
"TTS",
".",
"It",
"specifies",
"audio",
"format",
"sample",
"rate",
"and",
"additional",
"params",
"if",
"any"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/TTS/IbmWatson/AudioFormat/IbmWatsonAudioFormatsTrait.php#L49-L60 |
43,573 | GinoPane/PHPolyglot | src/API/Implementation/Dictionary/DictionaryApiAbstract.php | DictionaryApiAbstract.getTextAlternatives | public function getTextAlternatives(
string $text,
Language $language
): DictionaryResponse {
/** @var DictionaryResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | php | public function getTextAlternatives(
string $text,
Language $language
): DictionaryResponse {
/** @var DictionaryResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | [
"public",
"function",
"getTextAlternatives",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"language",
")",
":",
"DictionaryResponse",
"{",
"/** @var DictionaryResponse $response */",
"$",
"response",
"=",
"$",
"this",
"->",
"callApi",
"(",
"__FUNCTION__",
",",
... | Gets text alternatives
@param string $text
@param Language $language
@throws TransportException
@throws ResponseContextException
@throws BadResponseContextException
@throws MethodDoesNotExistException
@return DictionaryResponse | [
"Gets",
"text",
"alternatives"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/Dictionary/DictionaryApiAbstract.php#L35-L43 |
43,574 | GinoPane/PHPolyglot | src/API/Implementation/Dictionary/DictionaryApiAbstract.php | DictionaryApiAbstract.getTranslateAlternatives | public function getTranslateAlternatives(
string $text,
Language $languageTo,
Language $languageFrom
): DictionaryResponse {
/** @var DictionaryResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | php | public function getTranslateAlternatives(
string $text,
Language $languageTo,
Language $languageFrom
): DictionaryResponse {
/** @var DictionaryResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | [
"public",
"function",
"getTranslateAlternatives",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"languageTo",
",",
"Language",
"$",
"languageFrom",
")",
":",
"DictionaryResponse",
"{",
"/** @var DictionaryResponse $response */",
"$",
"response",
"=",
"$",
"this",
... | Gets text translate alternatives
@param string $text
@param Language $languageTo
@param Language $languageFrom
@throws TransportException
@throws ResponseContextException
@throws BadResponseContextException
@throws MethodDoesNotExistException
@return DictionaryResponse | [
"Gets",
"text",
"translate",
"alternatives"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/Dictionary/DictionaryApiAbstract.php#L59-L68 |
43,575 | GinoPane/PHPolyglot | src/API/Implementation/TTS/IbmWatson/IbmWatsonTtsApi.php | IbmWatsonTtsApi.createTextToSpeechContext | protected function createTextToSpeechContext(
string $text,
Language $language,
TtsAudioFormat $format,
array $additionalData = []
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TEXT_TO_SPEECH_API_PATH)))
->setRequestParameters(
array_filter(
[
'accept' => $this->getAcceptParameter($format, $additionalData),
'voice' => $this->getVoiceParameter($language, $additionalData)
]
)
)
->setData(json_encode(['text' => $text]))
->setMethod(RequestContext::METHOD_POST)
->setContentType(RequestContext::CONTENT_TYPE_JSON)
->setResponseContextClass(DummyResponseContext::class);
return $this->authorizeRequest($requestContext);
} | php | protected function createTextToSpeechContext(
string $text,
Language $language,
TtsAudioFormat $format,
array $additionalData = []
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TEXT_TO_SPEECH_API_PATH)))
->setRequestParameters(
array_filter(
[
'accept' => $this->getAcceptParameter($format, $additionalData),
'voice' => $this->getVoiceParameter($language, $additionalData)
]
)
)
->setData(json_encode(['text' => $text]))
->setMethod(RequestContext::METHOD_POST)
->setContentType(RequestContext::CONTENT_TYPE_JSON)
->setResponseContextClass(DummyResponseContext::class);
return $this->authorizeRequest($requestContext);
} | [
"protected",
"function",
"createTextToSpeechContext",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"language",
",",
"TtsAudioFormat",
"$",
"format",
",",
"array",
"$",
"additionalData",
"=",
"[",
"]",
")",
":",
"RequestContext",
"{",
"$",
"requestContext",
... | Create request context for text-to-speech request
@param string $text
@param Language $language
@param TtsAudioFormat $format
@param array $additionalData
@return RequestContext
@throws RequestContextException
@throws InvalidVoiceCodeException
@throws InvalidAudioFormatCodeException
@throws InvalidVoiceParametersException
@throws InvalidAudioFormatParameterException | [
"Create",
"request",
"context",
"for",
"text",
"-",
"to",
"-",
"speech",
"request"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/TTS/IbmWatson/IbmWatsonTtsApi.php#L87-L108 |
43,576 | GinoPane/PHPolyglot | src/API/Implementation/TTS/IbmWatson/IbmWatsonTtsApi.php | IbmWatsonTtsApi.prepareTextToSpeechResponse | protected function prepareTextToSpeechResponse(ResponseContextAbstract $context): TtsResponse
{
$response = new TtsResponse(
$context->getRaw(),
$this->getAudioFormatByContentTypeHeader($context->headers()),
json_decode($context->getRequestContext()->getData(), true)['text']
);
return $response;
} | php | protected function prepareTextToSpeechResponse(ResponseContextAbstract $context): TtsResponse
{
$response = new TtsResponse(
$context->getRaw(),
$this->getAudioFormatByContentTypeHeader($context->headers()),
json_decode($context->getRequestContext()->getData(), true)['text']
);
return $response;
} | [
"protected",
"function",
"prepareTextToSpeechResponse",
"(",
"ResponseContextAbstract",
"$",
"context",
")",
":",
"TtsResponse",
"{",
"$",
"response",
"=",
"new",
"TtsResponse",
"(",
"$",
"context",
"->",
"getRaw",
"(",
")",
",",
"$",
"this",
"->",
"getAudioForm... | Process response of text-to-speech request and prepare valid response
@param ResponseContextAbstract $context
@throws InvalidContentTypeException
@return TtsResponse | [
"Process",
"response",
"of",
"text",
"-",
"to",
"-",
"speech",
"request",
"and",
"prepare",
"valid",
"response"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/TTS/IbmWatson/IbmWatsonTtsApi.php#L119-L128 |
43,577 | krzysztof-gzocha/searcher | src/KGzocha/Searcher/Chain/ChainSearch.php | ChainSearch.search | public function search(
CriteriaCollectionInterface $criteriaCollection
): ResultCollection {
$previousCriteria = $criteriaCollection;
$previousResults = null;
$result = new ResultCollection();
/** @var CellInterface $cell */
foreach ($this->cellCollection as $name => $cell) {
if ($cell->getTransformer()->skip($previousResults)) {
continue;
}
$previousResults = $cell->getSearcher()->search($previousCriteria);
$previousCriteria = $this->getNewCriteria(
$cell,
$previousCriteria,
$previousResults
);
$result->addNamedItem((string) $name, $previousResults);
}
return $result;
} | php | public function search(
CriteriaCollectionInterface $criteriaCollection
): ResultCollection {
$previousCriteria = $criteriaCollection;
$previousResults = null;
$result = new ResultCollection();
/** @var CellInterface $cell */
foreach ($this->cellCollection as $name => $cell) {
if ($cell->getTransformer()->skip($previousResults)) {
continue;
}
$previousResults = $cell->getSearcher()->search($previousCriteria);
$previousCriteria = $this->getNewCriteria(
$cell,
$previousCriteria,
$previousResults
);
$result->addNamedItem((string) $name, $previousResults);
}
return $result;
} | [
"public",
"function",
"search",
"(",
"CriteriaCollectionInterface",
"$",
"criteriaCollection",
")",
":",
"ResultCollection",
"{",
"$",
"previousCriteria",
"=",
"$",
"criteriaCollection",
";",
"$",
"previousResults",
"=",
"null",
";",
"$",
"result",
"=",
"new",
"Re... | Will perform multiple sub-searches.
Results from first search will be transformed and passed as CriteriaCollection
to another sub-search.
Whole process will return collection of results from each sub-search.
@param CriteriaCollectionInterface $criteriaCollection
@return ResultCollection | [
"Will",
"perform",
"multiple",
"sub",
"-",
"searches",
".",
"Results",
"from",
"first",
"search",
"will",
"be",
"transformed",
"and",
"passed",
"as",
"CriteriaCollection",
"to",
"another",
"sub",
"-",
"search",
".",
"Whole",
"process",
"will",
"return",
"colle... | f44eb27fdaa7b45fa2f90221899970e2fd061829 | https://github.com/krzysztof-gzocha/searcher/blob/f44eb27fdaa7b45fa2f90221899970e2fd061829/src/KGzocha/Searcher/Chain/ChainSearch.php#L44-L68 |
43,578 | krzysztof-gzocha/searcher | src/KGzocha/Searcher/Criteria/Adapter/ImmutablePaginationAdapter.php | ImmutablePaginationAdapter.setItemsPerPage | public function setItemsPerPage(int $itemsPerPage = null)
{
return $this
->pagination
->setItemsPerPage(
$this->pagination->getItemsPerPage()
);
} | php | public function setItemsPerPage(int $itemsPerPage = null)
{
return $this
->pagination
->setItemsPerPage(
$this->pagination->getItemsPerPage()
);
} | [
"public",
"function",
"setItemsPerPage",
"(",
"int",
"$",
"itemsPerPage",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"pagination",
"->",
"setItemsPerPage",
"(",
"$",
"this",
"->",
"pagination",
"->",
"getItemsPerPage",
"(",
")",
")",
";",
"}"
] | This method will not allow to change items per page.
On each call it will set the same value.
{@inheritdoc} | [
"This",
"method",
"will",
"not",
"allow",
"to",
"change",
"items",
"per",
"page",
".",
"On",
"each",
"call",
"it",
"will",
"set",
"the",
"same",
"value",
"."
] | f44eb27fdaa7b45fa2f90221899970e2fd061829 | https://github.com/krzysztof-gzocha/searcher/blob/f44eb27fdaa7b45fa2f90221899970e2fd061829/src/KGzocha/Searcher/Criteria/Adapter/ImmutablePaginationAdapter.php#L59-L66 |
43,579 | GinoPane/PHPolyglot | src/Supplemental/Language/Language.php | Language.assertLanguageIsValid | private function assertLanguageIsValid(string $language): void
{
if (!$this->codeIsValid($language)) {
throw new InvalidLanguageCodeException(
sprintf("Language code \"%s\" is invalid", $language)
);
}
} | php | private function assertLanguageIsValid(string $language): void
{
if (!$this->codeIsValid($language)) {
throw new InvalidLanguageCodeException(
sprintf("Language code \"%s\" is invalid", $language)
);
}
} | [
"private",
"function",
"assertLanguageIsValid",
"(",
"string",
"$",
"language",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"codeIsValid",
"(",
"$",
"language",
")",
")",
"{",
"throw",
"new",
"InvalidLanguageCodeException",
"(",
"sprintf",
"(",... | Checks that specified language code is valid
@param string $language
@throws InvalidLanguageCodeException | [
"Checks",
"that",
"specified",
"language",
"code",
"is",
"valid"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/Supplemental/Language/Language.php#L88-L95 |
43,580 | GinoPane/PHPolyglot | src/Supplemental/GetConstantsTrait.php | GetConstantsTrait.getConstants | private function getConstants(): array
{
if (empty(self::$constants)) {
self::$constants = (new ReflectionClass($this))->getConstants();
}
return self::$constants;
} | php | private function getConstants(): array
{
if (empty(self::$constants)) {
self::$constants = (new ReflectionClass($this))->getConstants();
}
return self::$constants;
} | [
"private",
"function",
"getConstants",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"constants",
")",
")",
"{",
"self",
"::",
"$",
"constants",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getCons... | Fills constants array if it is empty and returns it
@return array | [
"Fills",
"constants",
"array",
"if",
"it",
"is",
"empty",
"and",
"returns",
"it"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/Supplemental/GetConstantsTrait.php#L28-L35 |
43,581 | GinoPane/PHPolyglot | src/API/Implementation/SpellCheck/Yandex/YandexSpellCheckApi.php | YandexSpellCheckApi.createCheckTextsContext | protected function createCheckTextsContext(
array $texts,
Language $languageFrom
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::CHECK_TEXTS_API_PATH)))
->setRequestParameters(
[
'lang' => $languageFrom->getCode()
]
)
->setData(['text' => $texts])
->setMethod(RequestContext::METHOD_POST)
->setEncodeArraysUsingDuplication(true)
->setContentType(RequestContext::CONTENT_TYPE_FORM_URLENCODED)
->setResponseContextClass(JsonResponseContext::class);
return $requestContext;
} | php | protected function createCheckTextsContext(
array $texts,
Language $languageFrom
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::CHECK_TEXTS_API_PATH)))
->setRequestParameters(
[
'lang' => $languageFrom->getCode()
]
)
->setData(['text' => $texts])
->setMethod(RequestContext::METHOD_POST)
->setEncodeArraysUsingDuplication(true)
->setContentType(RequestContext::CONTENT_TYPE_FORM_URLENCODED)
->setResponseContextClass(JsonResponseContext::class);
return $requestContext;
} | [
"protected",
"function",
"createCheckTextsContext",
"(",
"array",
"$",
"texts",
",",
"Language",
"$",
"languageFrom",
")",
":",
"RequestContext",
"{",
"$",
"requestContext",
"=",
"(",
"new",
"RequestContext",
"(",
"sprintf",
"(",
"\"%s/%s\"",
",",
"$",
"this",
... | Create request context for spell-check request
@param array $texts
@param Language $languageFrom
@throws RequestContextException
@return RequestContext | [
"Create",
"request",
"context",
"for",
"spell",
"-",
"check",
"request"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/SpellCheck/Yandex/YandexSpellCheckApi.php#L44-L61 |
43,582 | GinoPane/PHPolyglot | src/API/Implementation/SpellCheck/Yandex/YandexSpellCheckApi.php | YandexSpellCheckApi.prepareCheckTextsResponse | protected function prepareCheckTextsResponse(ResponseContextAbstract $context): SpellCheckResponse
{
$response = new SpellCheckResponse();
$corrections = [];
foreach ($context->getArray() as $wordCorrections) {
$corrected = [];
foreach ($wordCorrections as $wordCorrection) {
if (!empty($wordCorrection['s']) && !empty($wordCorrection['word'])) {
$corrected[$wordCorrection['word']] = (array)$wordCorrection['s'];
}
}
$corrections[] = $corrected;
}
$response->setCorrections($corrections);
return $response;
} | php | protected function prepareCheckTextsResponse(ResponseContextAbstract $context): SpellCheckResponse
{
$response = new SpellCheckResponse();
$corrections = [];
foreach ($context->getArray() as $wordCorrections) {
$corrected = [];
foreach ($wordCorrections as $wordCorrection) {
if (!empty($wordCorrection['s']) && !empty($wordCorrection['word'])) {
$corrected[$wordCorrection['word']] = (array)$wordCorrection['s'];
}
}
$corrections[] = $corrected;
}
$response->setCorrections($corrections);
return $response;
} | [
"protected",
"function",
"prepareCheckTextsResponse",
"(",
"ResponseContextAbstract",
"$",
"context",
")",
":",
"SpellCheckResponse",
"{",
"$",
"response",
"=",
"new",
"SpellCheckResponse",
"(",
")",
";",
"$",
"corrections",
"=",
"[",
"]",
";",
"foreach",
"(",
"... | Process response of spell-check request and prepare valid response
@param ResponseContextAbstract $context
@return SpellCheckResponse | [
"Process",
"response",
"of",
"spell",
"-",
"check",
"request",
"and",
"prepare",
"valid",
"response"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/SpellCheck/Yandex/YandexSpellCheckApi.php#L70-L91 |
43,583 | GinoPane/PHPolyglot | src/API/Implementation/Dictionary/Yandex/YandexDictionaryApi.php | YandexDictionaryApi.createGetTextAlternativesContext | protected function createGetTextAlternativesContext(
string $text,
Language $language
): RequestContext {
$requestContext = $this->getLookupRequest($text, $language, $language);
return $this->fillGeneralRequestSettings($requestContext);
} | php | protected function createGetTextAlternativesContext(
string $text,
Language $language
): RequestContext {
$requestContext = $this->getLookupRequest($text, $language, $language);
return $this->fillGeneralRequestSettings($requestContext);
} | [
"protected",
"function",
"createGetTextAlternativesContext",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"language",
")",
":",
"RequestContext",
"{",
"$",
"requestContext",
"=",
"$",
"this",
"->",
"getLookupRequest",
"(",
"$",
"text",
",",
"$",
"language",... | Create request context for get-text-alternatives request
@param string $text
@param Language $language
@throws RequestContextException
@return RequestContext | [
"Create",
"request",
"context",
"for",
"get",
"-",
"text",
"-",
"alternatives",
"request"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/Dictionary/Yandex/YandexDictionaryApi.php#L79-L86 |
43,584 | GinoPane/PHPolyglot | src/API/Implementation/Dictionary/Yandex/YandexDictionaryApi.php | YandexDictionaryApi.createGetTranslateAlternativesContext | protected function createGetTranslateAlternativesContext(
string $text,
Language $languageTo,
Language $languageFrom
): RequestContext {
$requestContext = $this->getLookupRequest($text, $languageTo, $languageFrom);
return $this->fillGeneralRequestSettings($requestContext);
} | php | protected function createGetTranslateAlternativesContext(
string $text,
Language $languageTo,
Language $languageFrom
): RequestContext {
$requestContext = $this->getLookupRequest($text, $languageTo, $languageFrom);
return $this->fillGeneralRequestSettings($requestContext);
} | [
"protected",
"function",
"createGetTranslateAlternativesContext",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"languageTo",
",",
"Language",
"$",
"languageFrom",
")",
":",
"RequestContext",
"{",
"$",
"requestContext",
"=",
"$",
"this",
"->",
"getLookupRequest"... | Create request context for get-translate-alternatives request
@param string $text
@param Language $languageTo
@param Language $languageFrom
@throws RequestContextException
@return RequestContext | [
"Create",
"request",
"context",
"for",
"get",
"-",
"translate",
"-",
"alternatives",
"request"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/Dictionary/Yandex/YandexDictionaryApi.php#L111-L119 |
43,585 | GinoPane/PHPolyglot | src/API/Implementation/Translate/Yandex/YandexTranslateApi.php | YandexTranslateApi.createTranslateContext | protected function createTranslateContext(
string $text,
Language $languageTo,
Language $languageFrom
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TRANSLATE_API_PATH)))
->setRequestParameters(
[
'lang' => $this->getLanguageString($languageTo, $languageFrom)
] + $this->getAuthData()
)
->setData(['text' => $text])
->setMethod(RequestContext::METHOD_POST);
return $this->fillGeneralRequestSettings($requestContext);
} | php | protected function createTranslateContext(
string $text,
Language $languageTo,
Language $languageFrom
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TRANSLATE_API_PATH)))
->setRequestParameters(
[
'lang' => $this->getLanguageString($languageTo, $languageFrom)
] + $this->getAuthData()
)
->setData(['text' => $text])
->setMethod(RequestContext::METHOD_POST);
return $this->fillGeneralRequestSettings($requestContext);
} | [
"protected",
"function",
"createTranslateContext",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"languageTo",
",",
"Language",
"$",
"languageFrom",
")",
":",
"RequestContext",
"{",
"$",
"requestContext",
"=",
"(",
"new",
"RequestContext",
"(",
"sprintf",
"(... | Create request context for translate request
@param string $text
@param Language $languageTo
@param Language $languageFrom
@throws RequestContextException
@return RequestContext | [
"Create",
"request",
"context",
"for",
"translate",
"request"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/Translate/Yandex/YandexTranslateApi.php#L68-L83 |
43,586 | GinoPane/PHPolyglot | src/API/Implementation/Translate/Yandex/YandexTranslateApi.php | YandexTranslateApi.createTranslateBulkContext | protected function createTranslateBulkContext(
array $texts,
Language $languageTo,
Language $languageFrom
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TRANSLATE_API_PATH)))
->setRequestParameters(
[
'lang' => $this->getLanguageString($languageTo, $languageFrom)
] + $this->getAuthData()
)
->setData(['text' => $texts])
->setMethod(RequestContext::METHOD_POST)
->setEncodeArraysUsingDuplication(true);
return $this->fillGeneralRequestSettings($requestContext);
} | php | protected function createTranslateBulkContext(
array $texts,
Language $languageTo,
Language $languageFrom
): RequestContext {
$requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TRANSLATE_API_PATH)))
->setRequestParameters(
[
'lang' => $this->getLanguageString($languageTo, $languageFrom)
] + $this->getAuthData()
)
->setData(['text' => $texts])
->setMethod(RequestContext::METHOD_POST)
->setEncodeArraysUsingDuplication(true);
return $this->fillGeneralRequestSettings($requestContext);
} | [
"protected",
"function",
"createTranslateBulkContext",
"(",
"array",
"$",
"texts",
",",
"Language",
"$",
"languageTo",
",",
"Language",
"$",
"languageFrom",
")",
":",
"RequestContext",
"{",
"$",
"requestContext",
"=",
"(",
"new",
"RequestContext",
"(",
"sprintf",
... | Create request context for bulk translate request
@param array $texts
@param Language $languageTo
@param Language $languageFrom
@throws RequestContextException
@return RequestContext | [
"Create",
"request",
"context",
"for",
"bulk",
"translate",
"request"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/Translate/Yandex/YandexTranslateApi.php#L108-L124 |
43,587 | GinoPane/PHPolyglot | src/API/Implementation/ApiAbstract.php | ApiAbstract.callApi | protected function callApi(string $apiClassMethod, array $arguments = []): ApiResponseInterface
{
$requestContext = $this->getApiRequestContext($apiClassMethod, $arguments);
$responseContext = $this->getApiResponseContext($requestContext);
$apiResponse = $this->prepareApiResponse($responseContext, $apiClassMethod);
return $apiResponse;
} | php | protected function callApi(string $apiClassMethod, array $arguments = []): ApiResponseInterface
{
$requestContext = $this->getApiRequestContext($apiClassMethod, $arguments);
$responseContext = $this->getApiResponseContext($requestContext);
$apiResponse = $this->prepareApiResponse($responseContext, $apiClassMethod);
return $apiResponse;
} | [
"protected",
"function",
"callApi",
"(",
"string",
"$",
"apiClassMethod",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
":",
"ApiResponseInterface",
"{",
"$",
"requestContext",
"=",
"$",
"this",
"->",
"getApiRequestContext",
"(",
"$",
"apiClassMethod",
"... | Call API method by creating RequestContext, sending it, filtering the result and preparing the response
@param string $apiClassMethod
@param array $arguments Arguments that need to be passed to API-related methods
@throws TransportException
@throws ResponseContextException
@throws BadResponseContextException
@throws MethodDoesNotExistException
@return ApiResponseInterface | [
"Call",
"API",
"method",
"by",
"creating",
"RequestContext",
"sending",
"it",
"filtering",
"the",
"result",
"and",
"preparing",
"the",
"response"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/ApiAbstract.php#L78-L87 |
43,588 | GinoPane/PHPolyglot | src/API/Implementation/ApiAbstract.php | ApiAbstract.initPropertiesFromEnvironment | protected function initPropertiesFromEnvironment(): void
{
foreach ($this->envProperties as $property => $env) {
if (!property_exists($this, $property)) {
throw new InvalidPropertyException(
sprintf("Property \"%s\" does not exist within the class \"%s\"", $property, get_class($this))
);
}
if (false === ($envSetting = getenv($env))) {
throw new InvalidEnvironmentException(
sprintf("Required environment variable \"%s\" is not set", $env)
);
}
$this->{$property} = $envSetting;
}
} | php | protected function initPropertiesFromEnvironment(): void
{
foreach ($this->envProperties as $property => $env) {
if (!property_exists($this, $property)) {
throw new InvalidPropertyException(
sprintf("Property \"%s\" does not exist within the class \"%s\"", $property, get_class($this))
);
}
if (false === ($envSetting = getenv($env))) {
throw new InvalidEnvironmentException(
sprintf("Required environment variable \"%s\" is not set", $env)
);
}
$this->{$property} = $envSetting;
}
} | [
"protected",
"function",
"initPropertiesFromEnvironment",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"envProperties",
"as",
"$",
"property",
"=>",
"$",
"env",
")",
"{",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"this",
",",
"$",
"p... | Fills specified properties using environment variables
@throws InvalidPropertyException
@throws InvalidEnvironmentException | [
"Fills",
"specified",
"properties",
"using",
"environment",
"variables"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/ApiAbstract.php#L114-L131 |
43,589 | GinoPane/PHPolyglot | src/API/Implementation/ApiAbstract.php | ApiAbstract.getApiResponseContext | private function getApiResponseContext(RequestContext $requestContext): ResponseContextAbstract
{
$responseContext = $this->httpClient->sendRequest(
$requestContext
);
$this->processApiResponseContextErrors($responseContext);
return $responseContext;
} | php | private function getApiResponseContext(RequestContext $requestContext): ResponseContextAbstract
{
$responseContext = $this->httpClient->sendRequest(
$requestContext
);
$this->processApiResponseContextErrors($responseContext);
return $responseContext;
} | [
"private",
"function",
"getApiResponseContext",
"(",
"RequestContext",
"$",
"requestContext",
")",
":",
"ResponseContextAbstract",
"{",
"$",
"responseContext",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"sendRequest",
"(",
"$",
"requestContext",
")",
";",
"$",
"t... | Accepts RequestContext and sends it to API to get ResponseContext
@param RequestContext $requestContext
@throws TransportException
@throws ResponseContextException
@throws BadResponseContextException
@return ResponseContextAbstract | [
"Accepts",
"RequestContext",
"and",
"sends",
"it",
"to",
"API",
"to",
"get",
"ResponseContext"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/ApiAbstract.php#L144-L153 |
43,590 | GinoPane/PHPolyglot | src/API/Implementation/ApiAbstract.php | ApiAbstract.getApiRequestContext | private function getApiRequestContext(string $apiClassMethod, array $arguments = []): RequestContext
{
$getRequestContext = sprintf("create%sContext", ucfirst($apiClassMethod));
$this->assertMethodExists($getRequestContext);
$requestContext = $this->{$getRequestContext}(...$arguments);
return $requestContext;
} | php | private function getApiRequestContext(string $apiClassMethod, array $arguments = []): RequestContext
{
$getRequestContext = sprintf("create%sContext", ucfirst($apiClassMethod));
$this->assertMethodExists($getRequestContext);
$requestContext = $this->{$getRequestContext}(...$arguments);
return $requestContext;
} | [
"private",
"function",
"getApiRequestContext",
"(",
"string",
"$",
"apiClassMethod",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
":",
"RequestContext",
"{",
"$",
"getRequestContext",
"=",
"sprintf",
"(",
"\"create%sContext\"",
",",
"ucfirst",
"(",
"$",
... | Gets RequestContext for sending
@param string $apiClassMethod
@param array $arguments Arguments that need to be passed to API-related methods
@return RequestContext
@throws MethodDoesNotExistException | [
"Gets",
"RequestContext",
"for",
"sending"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/ApiAbstract.php#L165-L174 |
43,591 | GinoPane/PHPolyglot | src/API/Implementation/ApiAbstract.php | ApiAbstract.prepareApiResponse | private function prepareApiResponse(
ResponseContextAbstract $responseContext,
string $apiClassMethod
): ApiResponseInterface {
$prepareApiResponse = sprintf("prepare%sResponse", ucfirst($apiClassMethod));
$this->assertMethodExists($prepareApiResponse);
$apiResponse = $this->{$prepareApiResponse}($responseContext);
return $apiResponse;
} | php | private function prepareApiResponse(
ResponseContextAbstract $responseContext,
string $apiClassMethod
): ApiResponseInterface {
$prepareApiResponse = sprintf("prepare%sResponse", ucfirst($apiClassMethod));
$this->assertMethodExists($prepareApiResponse);
$apiResponse = $this->{$prepareApiResponse}($responseContext);
return $apiResponse;
} | [
"private",
"function",
"prepareApiResponse",
"(",
"ResponseContextAbstract",
"$",
"responseContext",
",",
"string",
"$",
"apiClassMethod",
")",
":",
"ApiResponseInterface",
"{",
"$",
"prepareApiResponse",
"=",
"sprintf",
"(",
"\"prepare%sResponse\"",
",",
"ucfirst",
"("... | Prepares API response by processing ResponseContext
@param ResponseContextAbstract $responseContext
@param string $apiClassMethod
@throws MethodDoesNotExistException
@return ApiResponseInterface | [
"Prepares",
"API",
"response",
"by",
"processing",
"ResponseContext"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/ApiAbstract.php#L186-L197 |
43,592 | GinoPane/PHPolyglot | src/API/Implementation/ApiAbstract.php | ApiAbstract.assertMethodExists | private function assertMethodExists(string $method): void
{
if (!method_exists($this, $method)) {
throw new MethodDoesNotExistException(
sprintf("Specified method \"%s\" does not exist", $method)
);
}
} | php | private function assertMethodExists(string $method): void
{
if (!method_exists($this, $method)) {
throw new MethodDoesNotExistException(
sprintf("Specified method \"%s\" does not exist", $method)
);
}
} | [
"private",
"function",
"assertMethodExists",
"(",
"string",
"$",
"method",
")",
":",
"void",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"MethodDoesNotExistException",
"(",
"sprintf",
"(",
"\"S... | Throws exception if method does not exist
@param string $method
@throws MethodDoesNotExistException
@return void | [
"Throws",
"exception",
"if",
"method",
"does",
"not",
"exist"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/ApiAbstract.php#L208-L215 |
43,593 | GinoPane/PHPolyglot | src/API/Factory/ApiFactoryAbstract.php | ApiFactoryAbstract.assertConfigIsValid | protected function assertConfigIsValid(): void
{
foreach ($this->configProperties as $property) {
if (empty(self::$config[$this->configSectionName][$property])) {
throw new InvalidConfigException(
sprintf(
"Config section does not exist or is not filled properly: %s (\"%s\" is missing)",
$this->configSectionName,
$property
)
);
}
}
$this->assertApiClassImplementsInterface($this->apiInterface);
} | php | protected function assertConfigIsValid(): void
{
foreach ($this->configProperties as $property) {
if (empty(self::$config[$this->configSectionName][$property])) {
throw new InvalidConfigException(
sprintf(
"Config section does not exist or is not filled properly: %s (\"%s\" is missing)",
$this->configSectionName,
$property
)
);
}
}
$this->assertApiClassImplementsInterface($this->apiInterface);
} | [
"protected",
"function",
"assertConfigIsValid",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"configProperties",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"config",
"[",
"$",
"this",
"->",
"configSecti... | Performs basic validation of config structure. This method is to be overridden by custom implementations if
required
@throws InvalidConfigException
@throws InvalidApiClassException | [
"Performs",
"basic",
"validation",
"of",
"config",
"structure",
".",
"This",
"method",
"is",
"to",
"be",
"overridden",
"by",
"custom",
"implementations",
"if",
"required"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Factory/ApiFactoryAbstract.php#L174-L189 |
43,594 | GinoPane/PHPolyglot | src/API/Factory/ApiFactoryAbstract.php | ApiFactoryAbstract.initEnvironment | protected function initEnvironment(): void
{
$envFile = $this->getRootRelatedPath($this->getEnvFileName());
$this->assertFileIsReadable($envFile);
self::$envIsSet = (bool)(new Dotenv($this->getRootDirectory(), $this->getEnvFileName()))->load();
} | php | protected function initEnvironment(): void
{
$envFile = $this->getRootRelatedPath($this->getEnvFileName());
$this->assertFileIsReadable($envFile);
self::$envIsSet = (bool)(new Dotenv($this->getRootDirectory(), $this->getEnvFileName()))->load();
} | [
"protected",
"function",
"initEnvironment",
"(",
")",
":",
"void",
"{",
"$",
"envFile",
"=",
"$",
"this",
"->",
"getRootRelatedPath",
"(",
"$",
"this",
"->",
"getEnvFileName",
"(",
")",
")",
";",
"$",
"this",
"->",
"assertFileIsReadable",
"(",
"$",
"envFil... | Initialize environment variables
@throws InvalidPathException | [
"Initialize",
"environment",
"variables"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Factory/ApiFactoryAbstract.php#L218-L225 |
43,595 | GinoPane/PHPolyglot | src/API/Factory/ApiFactoryAbstract.php | ApiFactoryAbstract.initConfig | protected function initConfig(): void
{
$configFile = $this->getRootRelatedPath($this->getConfigFileName());
$this->assertFileIsReadable($configFile);
self::$config = (array)(include $configFile);
} | php | protected function initConfig(): void
{
$configFile = $this->getRootRelatedPath($this->getConfigFileName());
$this->assertFileIsReadable($configFile);
self::$config = (array)(include $configFile);
} | [
"protected",
"function",
"initConfig",
"(",
")",
":",
"void",
"{",
"$",
"configFile",
"=",
"$",
"this",
"->",
"getRootRelatedPath",
"(",
"$",
"this",
"->",
"getConfigFileName",
"(",
")",
")",
";",
"$",
"this",
"->",
"assertFileIsReadable",
"(",
"$",
"confi... | Initialize config variables
@throws InvalidPathException | [
"Initialize",
"config",
"variables"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Factory/ApiFactoryAbstract.php#L232-L239 |
43,596 | GinoPane/PHPolyglot | src/PHPolyglot.php | PHPolyglot.lookup | public function lookup(string $text, string $languageFrom, string $languageTo = ''): DictionaryResponse
{
if ($languageTo) {
$response = $this->getDictionaryApi()->getTranslateAlternatives(
$text, //@codeCoverageIgnore
new Language($languageTo),
new Language($languageFrom)
);
} else {
$response = $this->getDictionaryApi()->getTextAlternatives($text, new Language($languageFrom));
}
return $response;
} | php | public function lookup(string $text, string $languageFrom, string $languageTo = ''): DictionaryResponse
{
if ($languageTo) {
$response = $this->getDictionaryApi()->getTranslateAlternatives(
$text, //@codeCoverageIgnore
new Language($languageTo),
new Language($languageFrom)
);
} else {
$response = $this->getDictionaryApi()->getTextAlternatives($text, new Language($languageFrom));
}
return $response;
} | [
"public",
"function",
"lookup",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"languageFrom",
",",
"string",
"$",
"languageTo",
"=",
"''",
")",
":",
"DictionaryResponse",
"{",
"if",
"(",
"$",
"languageTo",
")",
"{",
"$",
"response",
"=",
"$",
"this",
... | The most common use of `lookup` is look up of the word in the same language, that's
why the first language parameter of `lookup` method is language-from, language-to is optional,
which differs from the language parameters order for translation
@param string $text
@param string $languageFrom
@param string $languageTo
@return DictionaryResponse | [
"The",
"most",
"common",
"use",
"of",
"lookup",
"is",
"look",
"up",
"of",
"the",
"word",
"in",
"the",
"same",
"language",
"that",
"s",
"why",
"the",
"first",
"language",
"parameter",
"of",
"lookup",
"method",
"is",
"language",
"-",
"from",
"language",
"-... | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/PHPolyglot.php#L80-L93 |
43,597 | GinoPane/PHPolyglot | src/API/Implementation/TTS/TtsApiAbstract.php | TtsApiAbstract.textToSpeech | public function textToSpeech(
string $text,
Language $language,
TtsAudioFormat $format,
array $additionalData = []
): TtsResponse {
/** @var TtsResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | php | public function textToSpeech(
string $text,
Language $language,
TtsAudioFormat $format,
array $additionalData = []
): TtsResponse {
/** @var TtsResponse $response */
$response = $this->callApi(__FUNCTION__, func_get_args());
return $response;
} | [
"public",
"function",
"textToSpeech",
"(",
"string",
"$",
"text",
",",
"Language",
"$",
"language",
",",
"TtsAudioFormat",
"$",
"format",
",",
"array",
"$",
"additionalData",
"=",
"[",
"]",
")",
":",
"TtsResponse",
"{",
"/** @var TtsResponse $response */",
"$",
... | Gets TTS raw data, that can be saved afterwards
@param string $text
@param Language $language
@param TtsAudioFormat $format
@param array $additionalData
@throws TransportException
@throws ResponseContextException
@throws BadResponseContextException
@throws MethodDoesNotExistException
@return TtsResponse | [
"Gets",
"TTS",
"raw",
"data",
"that",
"can",
"be",
"saved",
"afterwards"
] | 0fca65e3390532482e0a00ab7c51e281ad323556 | https://github.com/GinoPane/PHPolyglot/blob/0fca65e3390532482e0a00ab7c51e281ad323556/src/API/Implementation/TTS/TtsApiAbstract.php#L38-L48 |
43,598 | phpforce/soap-client | src/Phpforce/SoapClient/Client.php | Client.getLoginResult | public function getLoginResult()
{
if (null === $this->loginResult) {
$this->login($this->username, $this->password, $this->token);
}
return $this->loginResult;
} | php | public function getLoginResult()
{
if (null === $this->loginResult) {
$this->login($this->username, $this->password, $this->token);
}
return $this->loginResult;
} | [
"public",
"function",
"getLoginResult",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"loginResult",
")",
"{",
"$",
"this",
"->",
"login",
"(",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"this",
"->",
... | Get login result
@return Result\LoginResult | [
"Get",
"login",
"result"
] | df1d06533d28b34bf7e1a8eb4c6b43316ea25b56 | https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Client.php#L234-L241 |
43,599 | phpforce/soap-client | src/Phpforce/SoapClient/Client.php | Client.createSoapVars | protected function createSoapVars(array $objects, $type)
{
$soapVars = array();
foreach ($objects as $object) {
$sObject = $this->createSObject($object, $type);
$xml = '';
if (isset($sObject->fieldsToNull)) {
foreach ($sObject->fieldsToNull as $fieldToNull) {
$xml .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>';
}
$fieldsToNullVar = new \SoapVar(new \SoapVar($xml, XSD_ANYXML), SOAP_ENC_ARRAY);
$sObject->fieldsToNull = $fieldsToNullVar;
}
$soapVar = new \SoapVar($sObject, SOAP_ENC_OBJECT, $type, self::SOAP_NAMESPACE);
$soapVars[] = $soapVar;
}
return $soapVars;
} | php | protected function createSoapVars(array $objects, $type)
{
$soapVars = array();
foreach ($objects as $object) {
$sObject = $this->createSObject($object, $type);
$xml = '';
if (isset($sObject->fieldsToNull)) {
foreach ($sObject->fieldsToNull as $fieldToNull) {
$xml .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>';
}
$fieldsToNullVar = new \SoapVar(new \SoapVar($xml, XSD_ANYXML), SOAP_ENC_ARRAY);
$sObject->fieldsToNull = $fieldsToNullVar;
}
$soapVar = new \SoapVar($sObject, SOAP_ENC_OBJECT, $type, self::SOAP_NAMESPACE);
$soapVars[] = $soapVar;
}
return $soapVars;
} | [
"protected",
"function",
"createSoapVars",
"(",
"array",
"$",
"objects",
",",
"$",
"type",
")",
"{",
"$",
"soapVars",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"sObject",
"=",
"$",
"this",
"->",
... | Turn Sobjects into \SoapVars
@param array $objects Array of objects
@param string $type Object type
@return \SoapVar[] | [
"Turn",
"Sobjects",
"into",
"\\",
"SoapVars"
] | df1d06533d28b34bf7e1a8eb4c6b43316ea25b56 | https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Client.php#L459-L481 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.