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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,900 | derokorian/gen-synth | src/GenSynth.php | GenSynth.replace_keywords | private function replace_keywords($instr)
{
$keywords = $replacements = [];
$keywords[] = '<TIME>';
$keywords[] = '{TIME}';
$replacements[] = $replacements[] = number_format($time = $this->get_time(), 3);
$keywords[] = '<LANGUAGE>';
$keywords[] = '{LANGUAGE}';
$replacements[] = $replacements[] = $this->language_data['LANG_NAME'];
$keywords[] = '<VERSION>';
$keywords[] = '{VERSION}';
$replacements[] = $replacements[] = self::VERSION;
$keywords[] = '<SPEED>';
$keywords[] = '{SPEED}';
if ($time <= 0) {
$speed = 'N/A';
}
else {
$speed = strlen($this->source) / $time;
if ($speed >= 1024) {
$speed = sprintf("%.2f KB/s", $speed / 1024.0);
}
else {
$speed = sprintf("%.0f B/s", $speed);
}
}
$replacements[] = $replacements[] = $speed;
return str_replace($keywords, $replacements, $instr);
} | php | private function replace_keywords($instr)
{
$keywords = $replacements = [];
$keywords[] = '<TIME>';
$keywords[] = '{TIME}';
$replacements[] = $replacements[] = number_format($time = $this->get_time(), 3);
$keywords[] = '<LANGUAGE>';
$keywords[] = '{LANGUAGE}';
$replacements[] = $replacements[] = $this->language_data['LANG_NAME'];
$keywords[] = '<VERSION>';
$keywords[] = '{VERSION}';
$replacements[] = $replacements[] = self::VERSION;
$keywords[] = '<SPEED>';
$keywords[] = '{SPEED}';
if ($time <= 0) {
$speed = 'N/A';
}
else {
$speed = strlen($this->source) / $time;
if ($speed >= 1024) {
$speed = sprintf("%.2f KB/s", $speed / 1024.0);
}
else {
$speed = sprintf("%.0f B/s", $speed);
}
}
$replacements[] = $replacements[] = $speed;
return str_replace($keywords, $replacements, $instr);
} | [
"private",
"function",
"replace_keywords",
"(",
"$",
"instr",
")",
"{",
"$",
"keywords",
"=",
"$",
"replacements",
"=",
"[",
"]",
";",
"$",
"keywords",
"[",
"]",
"=",
"'<TIME>'",
";",
"$",
"keywords",
"[",
"]",
"=",
"'{TIME}'",
";",
"$",
"replacements"... | Replaces certain keywords in the header and footer with
certain configuration values
@param string $instr The header or footer content to do replacement on
@return string The header or footer with replaced keywords
@since 1.0.2 | [
"Replaces",
"certain",
"keywords",
"in",
"the",
"header",
"and",
"footer",
"with",
"certain",
"configuration",
"values"
] | 7114d25246da3f34adfb0ffd68464f2fca12df47 | https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L3400-L3433 |
5,901 | derokorian/gen-synth | src/GenSynth.php | GenSynth.get_line_style | private function get_line_style($line)
{
//$style = null;
$style = null;
if (isset($this->highlight_extra_lines_styles[$line])) {
$style = $this->highlight_extra_lines_styles[$line];
}
else { // if no "extra" style assigned
$style = $this->highlight_extra_lines_style;
}
return $style;
} | php | private function get_line_style($line)
{
//$style = null;
$style = null;
if (isset($this->highlight_extra_lines_styles[$line])) {
$style = $this->highlight_extra_lines_styles[$line];
}
else { // if no "extra" style assigned
$style = $this->highlight_extra_lines_style;
}
return $style;
} | [
"private",
"function",
"get_line_style",
"(",
"$",
"line",
")",
"{",
"//$style = null;\r",
"$",
"style",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"highlight_extra_lines_styles",
"[",
"$",
"line",
"]",
")",
")",
"{",
"$",
"style",
"="... | Get's the style that is used for the specified line
@param int $line The line number information is requested for
@return string | [
"Get",
"s",
"the",
"style",
"that",
"is",
"used",
"for",
"the",
"specified",
"line"
] | 7114d25246da3f34adfb0ffd68464f2fca12df47 | https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L3452-L3464 |
5,902 | derokorian/gen-synth | src/GenSynth.php | GenSynth.handle_keyword_replace | private function handle_keyword_replace($match)
{
$k = $this->_kw_replace_group;
$keyword = $match[0];
$keyword_match = $match[1];
$before = '';
$after = '';
if ($this->keyword_links) {
// Keyword links have been ebabled
if (isset($this->language_data['URLS'][$k]) &&
$this->language_data['URLS'][$k] != ''
) {
// There is a base group for this keyword
// Old system: strtolower
//$keyword = ( $this->language_data['CASE_SENSITIVE'][$group] ) ? $keyword : strtolower($keyword);
// New system: get keyword from language file to get correct case
if (!$this->language_data['CASE_SENSITIVE'][$k] &&
strpos($this->language_data['URLS'][$k], '{FNAME}') !== false
) {
foreach ($this->language_data['KEYWORDS'][$k] as $word) {
if (strcasecmp($word, $keyword_match) == 0) {
break;
}
}
}
else {
$word = $keyword_match;
}
$before = '<|UR1|"' .
str_replace(
[
'{FNAME}',
'{FNAMEL}',
'{FNAMEU}',
'.'],
[
str_replace('+', '%20', urlencode($this->hsc($word))),
str_replace('+', '%20', urlencode($this->hsc(strtolower($word)))),
str_replace('+', '%20', urlencode($this->hsc(strtoupper($word)))),
'<DOT>'],
$this->language_data['URLS'][$k]
) . '">';
$after = '</a>';
}
}
return $before . '<|/' . $k . '/>' . $this->change_case($keyword) . '|>' . $after;
} | php | private function handle_keyword_replace($match)
{
$k = $this->_kw_replace_group;
$keyword = $match[0];
$keyword_match = $match[1];
$before = '';
$after = '';
if ($this->keyword_links) {
// Keyword links have been ebabled
if (isset($this->language_data['URLS'][$k]) &&
$this->language_data['URLS'][$k] != ''
) {
// There is a base group for this keyword
// Old system: strtolower
//$keyword = ( $this->language_data['CASE_SENSITIVE'][$group] ) ? $keyword : strtolower($keyword);
// New system: get keyword from language file to get correct case
if (!$this->language_data['CASE_SENSITIVE'][$k] &&
strpos($this->language_data['URLS'][$k], '{FNAME}') !== false
) {
foreach ($this->language_data['KEYWORDS'][$k] as $word) {
if (strcasecmp($word, $keyword_match) == 0) {
break;
}
}
}
else {
$word = $keyword_match;
}
$before = '<|UR1|"' .
str_replace(
[
'{FNAME}',
'{FNAMEL}',
'{FNAMEU}',
'.'],
[
str_replace('+', '%20', urlencode($this->hsc($word))),
str_replace('+', '%20', urlencode($this->hsc(strtolower($word)))),
str_replace('+', '%20', urlencode($this->hsc(strtoupper($word)))),
'<DOT>'],
$this->language_data['URLS'][$k]
) . '">';
$after = '</a>';
}
}
return $before . '<|/' . $k . '/>' . $this->change_case($keyword) . '|>' . $after;
} | [
"private",
"function",
"handle_keyword_replace",
"(",
"$",
"match",
")",
"{",
"$",
"k",
"=",
"$",
"this",
"->",
"_kw_replace_group",
";",
"$",
"keyword",
"=",
"$",
"match",
"[",
"0",
"]",
";",
"$",
"keyword_match",
"=",
"$",
"match",
"[",
"1",
"]",
"... | Handles replacements of keywords to include markup and links if requested
@param string The keyword to add the Markup to
@return The HTML for the match found
@todo Get rid of ender in keyword links | [
"Handles",
"replacements",
"of",
"keywords",
"to",
"include",
"markup",
"and",
"links",
"if",
"requested"
] | 7114d25246da3f34adfb0ffd68464f2fca12df47 | https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L4380-L4432 |
5,903 | SlabPHP/sequencer | src/Entry.php | Entry.execute | public function execute($objectContext)
{
if (method_exists($objectContext, $this->method))
{
if (!empty($this->parameters))
{
$objectContext->{$this->method}($this->parameters);
}
else
{
$objectContext->{$this->method}($this->parameters);
}
}
} | php | public function execute($objectContext)
{
if (method_exists($objectContext, $this->method))
{
if (!empty($this->parameters))
{
$objectContext->{$this->method}($this->parameters);
}
else
{
$objectContext->{$this->method}($this->parameters);
}
}
} | [
"public",
"function",
"execute",
"(",
"$",
"objectContext",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"objectContext",
",",
"$",
"this",
"->",
"method",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"parameters",
")",
")",
"{"... | Execute a sequence
@param $objectContext | [
"Execute",
"a",
"sequence"
] | 77fd738a4df741c8e789b9ccf4974efc47328346 | https://github.com/SlabPHP/sequencer/blob/77fd738a4df741c8e789b9ccf4974efc47328346/src/Entry.php#L47-L60 |
5,904 | jakejosol/warp-framework | src/Warp/Core/Console.php | Console.Start | public static function Start()
{
// Retrieve the global variables
if(!$argv) $argv = $_SERVER["argv"];
// Get the console variables
$functionName = $argv[1];
$rows = explode(",", $argv[2]);
$vars = array();
foreach($rows as $row)
{
$parts = explode("=", $row);
$vars[$parts[0]] = $parts[1];
}
// Prepare the console
$console = new Console;
// Run the console
try
{
return $console->Run($functionName, $vars);
}
catch(\Exception $ex)
{
return "\nError: " . $ex->getMessage() . "\n";
}
} | php | public static function Start()
{
// Retrieve the global variables
if(!$argv) $argv = $_SERVER["argv"];
// Get the console variables
$functionName = $argv[1];
$rows = explode(",", $argv[2]);
$vars = array();
foreach($rows as $row)
{
$parts = explode("=", $row);
$vars[$parts[0]] = $parts[1];
}
// Prepare the console
$console = new Console;
// Run the console
try
{
return $console->Run($functionName, $vars);
}
catch(\Exception $ex)
{
return "\nError: " . $ex->getMessage() . "\n";
}
} | [
"public",
"static",
"function",
"Start",
"(",
")",
"{",
"// Retrieve the global variables",
"if",
"(",
"!",
"$",
"argv",
")",
"$",
"argv",
"=",
"$",
"_SERVER",
"[",
"\"argv\"",
"]",
";",
"// Get the console variables",
"$",
"functionName",
"=",
"$",
"argv",
... | Start the Console | [
"Start",
"the",
"Console"
] | 94b8a7859669766bf2904c68f5cde0809c288943 | https://github.com/jakejosol/warp-framework/blob/94b8a7859669766bf2904c68f5cde0809c288943/src/Warp/Core/Console.php#L75-L102 |
5,905 | jakejosol/warp-framework | src/Warp/Core/Console.php | Console.Run | public function Run($functionName, $parameters)
{
if(!array_key_exists($functionName, $this->functions))
return "\nError: The command '{$functionName}' does not exist\n";
$response = $this->functions[$functionName]($parameters);
return "\n{$response}\n";
} | php | public function Run($functionName, $parameters)
{
if(!array_key_exists($functionName, $this->functions))
return "\nError: The command '{$functionName}' does not exist\n";
$response = $this->functions[$functionName]($parameters);
return "\n{$response}\n";
} | [
"public",
"function",
"Run",
"(",
"$",
"functionName",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"functionName",
",",
"$",
"this",
"->",
"functions",
")",
")",
"return",
"\"\\nError: The command '{$functionName}' does not exis... | Generic function caller | [
"Generic",
"function",
"caller"
] | 94b8a7859669766bf2904c68f5cde0809c288943 | https://github.com/jakejosol/warp-framework/blob/94b8a7859669766bf2904c68f5cde0809c288943/src/Warp/Core/Console.php#L105-L113 |
5,906 | vutran/wpmvc-core | src/Models/Comment.php | Comment.create | public static function create($comment)
{
// If numeric, create the comment
if (is_numeric($comment)) {
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Comment(%d)', $comment);
$storedData = get_transient($transientKey);
// If the transient doesn't yet exist, query for it!
if ($storedData === false) {
// Retrieve the comment object
$comment = get_comment(intval($comment));
// Store the transient
set_transient($transientKey, $comment, $this->transientTimeout);
} else {
$comment = $storedData;
}
} elseif (is_array($comment)) {
// Convert array into object
$comment = (object) $comment;
}
return new static($comment);
} | php | public static function create($comment)
{
// If numeric, create the comment
if (is_numeric($comment)) {
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Comment(%d)', $comment);
$storedData = get_transient($transientKey);
// If the transient doesn't yet exist, query for it!
if ($storedData === false) {
// Retrieve the comment object
$comment = get_comment(intval($comment));
// Store the transient
set_transient($transientKey, $comment, $this->transientTimeout);
} else {
$comment = $storedData;
}
} elseif (is_array($comment)) {
// Convert array into object
$comment = (object) $comment;
}
return new static($comment);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"comment",
")",
"{",
"// If numeric, create the comment",
"if",
"(",
"is_numeric",
"(",
"$",
"comment",
")",
")",
"{",
"// Retrieve the transient",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Comment... | Creates a new instance by the comment ID
@access public
@param array|int $comment
@return static | [
"Creates",
"a",
"new",
"instance",
"by",
"the",
"comment",
"ID"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Comment.php#L33-L54 |
5,907 | vutran/wpmvc-core | src/Models/Comment.php | Comment.editComment | public function editComment($link = null, $before = '', $after = '')
{
// If the user cannot comment on this comment
if (!current_user_can('edit_comment', $this->id())) {
return;
}
// If the link is empty
if (null === $link) {
$link = __('Edit This');
}
// Retrieve the comment link
$link = '<a class="comment-edit-link" href="' . get_edit_comment_link($this->id()) . '">' . $link . '</a>';
return $before . apply_filters('edit_comment_link', $link, $this->id()) . $after;
} | php | public function editComment($link = null, $before = '', $after = '')
{
// If the user cannot comment on this comment
if (!current_user_can('edit_comment', $this->id())) {
return;
}
// If the link is empty
if (null === $link) {
$link = __('Edit This');
}
// Retrieve the comment link
$link = '<a class="comment-edit-link" href="' . get_edit_comment_link($this->id()) . '">' . $link . '</a>';
return $before . apply_filters('edit_comment_link', $link, $this->id()) . $after;
} | [
"public",
"function",
"editComment",
"(",
"$",
"link",
"=",
"null",
",",
"$",
"before",
"=",
"''",
",",
"$",
"after",
"=",
"''",
")",
"{",
"// If the user cannot comment on this comment",
"if",
"(",
"!",
"current_user_can",
"(",
"'edit_comment'",
",",
"$",
"... | Retrieve the comment editing link
@access public
@link https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/link-template.php#L1296
@param string $link Optional. Anchor text.
@param string $before Optional. Display before edit link.
@param string $after Optional. Display after edit link.
@return string | [
"Retrieve",
"the",
"comment",
"editing",
"link"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Comment.php#L242-L255 |
5,908 | vutran/wpmvc-core | src/Models/Comment.php | Comment.replyComment | public function replyComment($depth = 0)
{
$args = array(
'depth' => $depth,
'max_depth' => 3
);
return get_comment_reply_link($args, $this->id(), $this->postId());
} | php | public function replyComment($depth = 0)
{
$args = array(
'depth' => $depth,
'max_depth' => 3
);
return get_comment_reply_link($args, $this->id(), $this->postId());
} | [
"public",
"function",
"replyComment",
"(",
"$",
"depth",
"=",
"0",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'depth'",
"=>",
"$",
"depth",
",",
"'max_depth'",
"=>",
"3",
")",
";",
"return",
"get_comment_reply_link",
"(",
"$",
"args",
",",
"$",
"this",... | Retrive the comment reply link
@access public
@link http://codex.wordpress.org/Function_Reference/comment_reply_link
@param string $depth (default: 0)
@return string | [
"Retrive",
"the",
"comment",
"reply",
"link"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Comment.php#L265-L272 |
5,909 | wasabi-cms/core | src/Wasabi.php | Wasabi.user | public static function user($user = null)
{
if ($user !== null) {
self::$_user = $user;
}
if (!self::$_user) {
return null;
}
return self::$_user;
} | php | public static function user($user = null)
{
if ($user !== null) {
self::$_user = $user;
}
if (!self::$_user) {
return null;
}
return self::$_user;
} | [
"public",
"static",
"function",
"user",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"user",
"!==",
"null",
")",
"{",
"self",
"::",
"$",
"_user",
"=",
"$",
"user",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"_user",
")",
"{",
"r... | Get or set the currently logged in user.
@param User $user The user to set (optional).
@return User | [
"Get",
"or",
"set",
"the",
"currently",
"logged",
"in",
"user",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Wasabi.php#L50-L59 |
5,910 | wasabi-cms/core | src/Wasabi.php | Wasabi.setting | public static function setting($path, $default = null)
{
$setting = Configure::read('Settings.' . $path);
if ($setting === null) {
$setting = Configure::read('Wasabi.' . $path);
}
if ($setting === null) {
return $default;
}
return $setting;
} | php | public static function setting($path, $default = null)
{
$setting = Configure::read('Settings.' . $path);
if ($setting === null) {
$setting = Configure::read('Wasabi.' . $path);
}
if ($setting === null) {
return $default;
}
return $setting;
} | [
"public",
"static",
"function",
"setting",
"(",
"$",
"path",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"setting",
"=",
"Configure",
"::",
"read",
"(",
"'Settings.'",
".",
"$",
"path",
")",
";",
"if",
"(",
"$",
"setting",
"===",
"null",
")",
... | Get a setting stored in Wasabi Settings.
@param string $path the array path to access the setting, using Hash::get() syntax
@param null|mixed $default a default value to return when the setting is not found
@return mixed|null | [
"Get",
"a",
"setting",
"stored",
"in",
"Wasabi",
"Settings",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Wasabi.php#L68-L81 |
5,911 | wasabi-cms/core | src/Wasabi.php | Wasabi.loadLanguages | public static function loadLanguages($langId = null, $backend = false)
{
// Configure all available frontend and backend languages.
$languages = Cache::remember('languages', function () {
/** @var LanguagesTable $Languages */
$Languages = TableRegistry::get('Wasabi/Core.Languages');
$langs = $Languages->find('allFrontendBackend')->all();
return [
'frontend' => array_values($Languages->filterFrontend($langs)->toArray()),
'backend' => array_values($Languages->filterBackend($langs)->toArray())
];
}, 'wasabi/core/longterm');
Configure::write('languages', $languages);
if ($backend === true) {
// Backend
$request = Router::getRequest();
// Setup the users backend language.
$backendLanguage = $languages['backend'][0];
if ($request->session()->check('Auth.User.language_id')) {
$backendLanguageId = $request->session()->read('Auth.User.language_id');
if ($backendLanguageId !== null) {
foreach ($languages['backend'] as $lang) {
if ($lang->id === $backendLanguageId) {
$backendLanguage = $lang;
break;
}
}
}
}
// Setup the users content language.
$contentLanguage = $languages['frontend'][0];
if ($request->session()->check('contentLanguageId')) {
$contentLanguageId = $request->session()->read('contentLanguageId');
foreach ($languages['frontend'] as $lang) {
if ($lang->id === $contentLanguageId) {
$contentLanguage = $lang;
break;
}
}
}
Configure::write('contentLanguage', $contentLanguage);
Configure::write('backendLanguage', $backendLanguage);
I18n::locale($backendLanguage->iso2);
} else {
// Frontend
if ($langId !== null) {
foreach ($languages['frontend'] as $frontendLanguage) {
if ($frontendLanguage->id === $langId) {
Configure::write('contentLanguage', $frontendLanguage);
I18n::locale($frontendLanguage->iso2);
break;
}
}
} else {
Configure::write('contentLanguage', $languages['frontend'][0]);
I18n::locale($languages['frontend'][0]->iso2);
}
}
} | php | public static function loadLanguages($langId = null, $backend = false)
{
// Configure all available frontend and backend languages.
$languages = Cache::remember('languages', function () {
/** @var LanguagesTable $Languages */
$Languages = TableRegistry::get('Wasabi/Core.Languages');
$langs = $Languages->find('allFrontendBackend')->all();
return [
'frontend' => array_values($Languages->filterFrontend($langs)->toArray()),
'backend' => array_values($Languages->filterBackend($langs)->toArray())
];
}, 'wasabi/core/longterm');
Configure::write('languages', $languages);
if ($backend === true) {
// Backend
$request = Router::getRequest();
// Setup the users backend language.
$backendLanguage = $languages['backend'][0];
if ($request->session()->check('Auth.User.language_id')) {
$backendLanguageId = $request->session()->read('Auth.User.language_id');
if ($backendLanguageId !== null) {
foreach ($languages['backend'] as $lang) {
if ($lang->id === $backendLanguageId) {
$backendLanguage = $lang;
break;
}
}
}
}
// Setup the users content language.
$contentLanguage = $languages['frontend'][0];
if ($request->session()->check('contentLanguageId')) {
$contentLanguageId = $request->session()->read('contentLanguageId');
foreach ($languages['frontend'] as $lang) {
if ($lang->id === $contentLanguageId) {
$contentLanguage = $lang;
break;
}
}
}
Configure::write('contentLanguage', $contentLanguage);
Configure::write('backendLanguage', $backendLanguage);
I18n::locale($backendLanguage->iso2);
} else {
// Frontend
if ($langId !== null) {
foreach ($languages['frontend'] as $frontendLanguage) {
if ($frontendLanguage->id === $langId) {
Configure::write('contentLanguage', $frontendLanguage);
I18n::locale($frontendLanguage->iso2);
break;
}
}
} else {
Configure::write('contentLanguage', $languages['frontend'][0]);
I18n::locale($languages['frontend'][0]->iso2);
}
}
} | [
"public",
"static",
"function",
"loadLanguages",
"(",
"$",
"langId",
"=",
"null",
",",
"$",
"backend",
"=",
"false",
")",
"{",
"// Configure all available frontend and backend languages.",
"$",
"languages",
"=",
"Cache",
"::",
"remember",
"(",
"'languages'",
",",
... | Load and setup all languages.
@param null $langId If set, then the language with id = $langId will be set as the content language.
@param bool|false $backend If true also initializes all backend languages
@return void | [
"Load",
"and",
"setup",
"all",
"languages",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Wasabi.php#L90-L153 |
5,912 | wasabi-cms/core | src/Wasabi.php | Wasabi.getCurrentUrlArray | public static function getCurrentUrlArray()
{
$request = Router::getRequest();
return [
'plugin' => $request->params['plugin'],
'controller' => $request->params['controller'],
'action' => $request->params['action']
];
} | php | public static function getCurrentUrlArray()
{
$request = Router::getRequest();
return [
'plugin' => $request->params['plugin'],
'controller' => $request->params['controller'],
'action' => $request->params['action']
];
} | [
"public",
"static",
"function",
"getCurrentUrlArray",
"(",
")",
"{",
"$",
"request",
"=",
"Router",
"::",
"getRequest",
"(",
")",
";",
"return",
"[",
"'plugin'",
"=>",
"$",
"request",
"->",
"params",
"[",
"'plugin'",
"]",
",",
"'controller'",
"=>",
"$",
... | Get the plugin controller action url array from the request.
@return array | [
"Get",
"the",
"plugin",
"controller",
"action",
"url",
"array",
"from",
"the",
"request",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Wasabi.php#L190-L199 |
5,913 | PSESD/chms-common | lib/Http/Controllers/Base/IndexActions/GetIndexTrait.php | GetIndexTrait.get | public function get(Request $request, Fractal $fractal, FractalCollection $collection)
{
$this->beforeRequest($request, func_get_args());
$transformer = $this->getTransformer();
$includes = $request->input('include', '');
$filter = $request->input('filter', false);
$items = $this->getRepository();
if ($filter && is_string($filter)) {
$filter = json_decode($filter, true);
}
$queryFilter = [];
if (!empty($filter)) {
$queryFilter = new QueryFilter($filter, $items->model(), $this->getTransformer());
}
$fractal->parseIncludes($includes);
$resource = $collection->setTransformer($transformer)->setResourceKey($this->getResourceKey());
$paginator = $items->paginate($queryFilter, $transformer->getSafeEagerLoad($fractal->getRequestedIncludes()), app('context'));
$itemCollection = $paginator->getCollection();
$resource->setData($itemCollection);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return $this->respondWithCollection($fractal->createData($resource));
} | php | public function get(Request $request, Fractal $fractal, FractalCollection $collection)
{
$this->beforeRequest($request, func_get_args());
$transformer = $this->getTransformer();
$includes = $request->input('include', '');
$filter = $request->input('filter', false);
$items = $this->getRepository();
if ($filter && is_string($filter)) {
$filter = json_decode($filter, true);
}
$queryFilter = [];
if (!empty($filter)) {
$queryFilter = new QueryFilter($filter, $items->model(), $this->getTransformer());
}
$fractal->parseIncludes($includes);
$resource = $collection->setTransformer($transformer)->setResourceKey($this->getResourceKey());
$paginator = $items->paginate($queryFilter, $transformer->getSafeEagerLoad($fractal->getRequestedIncludes()), app('context'));
$itemCollection = $paginator->getCollection();
$resource->setData($itemCollection);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return $this->respondWithCollection($fractal->createData($resource));
} | [
"public",
"function",
"get",
"(",
"Request",
"$",
"request",
",",
"Fractal",
"$",
"fractal",
",",
"FractalCollection",
"$",
"collection",
")",
"{",
"$",
"this",
"->",
"beforeRequest",
"(",
"$",
"request",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"t... | Get a list of objects
@param Request $request Request object
@return ResponseInterface Response for request | [
"Get",
"a",
"list",
"of",
"objects"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Http/Controllers/Base/IndexActions/GetIndexTrait.php#L24-L45 |
5,914 | othercodes/fcontroller | src/Components/Messages.php | Messages.addMessage | public function addMessage($text, $type = null)
{
$this->set(null, new \OtherCode\FController\Components\Messages\Message($text, $type));
} | php | public function addMessage($text, $type = null)
{
$this->set(null, new \OtherCode\FController\Components\Messages\Message($text, $type));
} | [
"public",
"function",
"addMessage",
"(",
"$",
"text",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"null",
",",
"new",
"\\",
"OtherCode",
"\\",
"FController",
"\\",
"Components",
"\\",
"Messages",
"\\",
"Message",
"(",
"$",
... | Add a new message to the queue
@param string $text
@param null|string $type | [
"Add",
"a",
"new",
"message",
"to",
"the",
"queue"
] | 866e5906d6150a344a57caf0560fd273fbc448a8 | https://github.com/othercodes/fcontroller/blob/866e5906d6150a344a57caf0560fd273fbc448a8/src/Components/Messages.php#L17-L20 |
5,915 | JamesRezo/webhelper-parser | src/Factory.php | Factory.createParser | public function createParser($name)
{
$parser = new Parser();
$parser->setServer($this->createServer($name));
$compiler = new Compiler(
$parser->getServer()->getStartMultiLine(),
$parser->getServer()->getEndMultiLine(),
$parser->getServer()->getSimpleDirective()
);
$parser->setCompiler($compiler);
return $parser;
} | php | public function createParser($name)
{
$parser = new Parser();
$parser->setServer($this->createServer($name));
$compiler = new Compiler(
$parser->getServer()->getStartMultiLine(),
$parser->getServer()->getEndMultiLine(),
$parser->getServer()->getSimpleDirective()
);
$parser->setCompiler($compiler);
return $parser;
} | [
"public",
"function",
"createParser",
"(",
"$",
"name",
")",
"{",
"$",
"parser",
"=",
"new",
"Parser",
"(",
")",
";",
"$",
"parser",
"->",
"setServer",
"(",
"$",
"this",
"->",
"createServer",
"(",
"$",
"name",
")",
")",
";",
"$",
"compiler",
"=",
"... | Builds a parser instance.
@param string $name a server specification name
@return ParserInterface a parser instance | [
"Builds",
"a",
"parser",
"instance",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Factory.php#L44-L59 |
5,916 | JamesRezo/webhelper-parser | src/Factory.php | Factory.createServer | public function createServer($name)
{
$server = new Server();
if (in_array($name, $this->getKnownServers())) {
$server
->setChecker(new Checker())
->setStartMultiLine($this->servers[$name]['directives']['start_multiline'])
->setEndMultiLine($this->servers[$name]['directives']['end_multiline'])
->setSimpleDirective($this->servers[$name]['directives']['simple'])
->setBinaries($this->servers[$name]['controlers'])
->setDetectionParameter($this->servers[$name]['switch']['detect'])
->setBeforeMethods($this->servers[$name]['parser']['before'])
->setAfterMethods($this->servers[$name]['parser']['after'])
->setDumperSimpleDirective($this->servers[$name]['dumper']['simple'])
->setDumperStartDirective($this->servers[$name]['dumper']['start_multiline'])
->setDumperEndDirective($this->servers[$name]['dumper']['end_multiline'])
->setKnownDirectives($this->servers[$name]['known_directives'])
;
}
return $server;
} | php | public function createServer($name)
{
$server = new Server();
if (in_array($name, $this->getKnownServers())) {
$server
->setChecker(new Checker())
->setStartMultiLine($this->servers[$name]['directives']['start_multiline'])
->setEndMultiLine($this->servers[$name]['directives']['end_multiline'])
->setSimpleDirective($this->servers[$name]['directives']['simple'])
->setBinaries($this->servers[$name]['controlers'])
->setDetectionParameter($this->servers[$name]['switch']['detect'])
->setBeforeMethods($this->servers[$name]['parser']['before'])
->setAfterMethods($this->servers[$name]['parser']['after'])
->setDumperSimpleDirective($this->servers[$name]['dumper']['simple'])
->setDumperStartDirective($this->servers[$name]['dumper']['start_multiline'])
->setDumperEndDirective($this->servers[$name]['dumper']['end_multiline'])
->setKnownDirectives($this->servers[$name]['known_directives'])
;
}
return $server;
} | [
"public",
"function",
"createServer",
"(",
"$",
"name",
")",
"{",
"$",
"server",
"=",
"new",
"Server",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getKnownServers",
"(",
")",
")",
")",
"{",
"$",
"server",
"->",
... | Builds a server instance.
@param string $name a server specification name
@return Server\ServerInterface a server instance | [
"Builds",
"a",
"server",
"instance",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Factory.php#L68-L89 |
5,917 | samurai-fw/samurai | src/Samurai/Component/Console/Client/Client.php | Client.levelToString | public function levelToString($level)
{
$mapping = [
self::LOG_LEVEL_DEBUG => 'debug',
self::LOG_LEVEL_INFO => 'info',
self::LOG_LEVEL_WARN => 'warn',
self::LOG_LEVEL_ERROR => 'error',
self::LOG_LEVEL_FATAL => 'fatal',
];
return isset($mapping[$level]) ? $mapping[$level] : 'unknown';
} | php | public function levelToString($level)
{
$mapping = [
self::LOG_LEVEL_DEBUG => 'debug',
self::LOG_LEVEL_INFO => 'info',
self::LOG_LEVEL_WARN => 'warn',
self::LOG_LEVEL_ERROR => 'error',
self::LOG_LEVEL_FATAL => 'fatal',
];
return isset($mapping[$level]) ? $mapping[$level] : 'unknown';
} | [
"public",
"function",
"levelToString",
"(",
"$",
"level",
")",
"{",
"$",
"mapping",
"=",
"[",
"self",
"::",
"LOG_LEVEL_DEBUG",
"=>",
"'debug'",
",",
"self",
"::",
"LOG_LEVEL_INFO",
"=>",
"'info'",
",",
"self",
"::",
"LOG_LEVEL_WARN",
"=>",
"'warn'",
",",
"... | level convert to string
@param int $level
@return string | [
"level",
"convert",
"to",
"string"
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Console/Client/Client.php#L147-L157 |
5,918 | samurai-fw/samurai | src/Samurai/Component/Console/Client/Client.php | Client.class_uses_deep | public function class_uses_deep($class)
{
$traits = [];
do {
$traits = array_merge($traits, class_uses($class, false));
} while ($class = get_parent_class($class));
foreach ($traits as $trait) {
$traits = array_merge($traits, class_uses($trait, false));
}
return array_unique($traits);
} | php | public function class_uses_deep($class)
{
$traits = [];
do {
$traits = array_merge($traits, class_uses($class, false));
} while ($class = get_parent_class($class));
foreach ($traits as $trait) {
$traits = array_merge($traits, class_uses($trait, false));
}
return array_unique($traits);
} | [
"public",
"function",
"class_uses_deep",
"(",
"$",
"class",
")",
"{",
"$",
"traits",
"=",
"[",
"]",
";",
"do",
"{",
"$",
"traits",
"=",
"array_merge",
"(",
"$",
"traits",
",",
"class_uses",
"(",
"$",
"class",
",",
"false",
")",
")",
";",
"}",
"whil... | get use traits deep
@param string $class
@return array | [
"get",
"use",
"traits",
"deep"
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Console/Client/Client.php#L230-L240 |
5,919 | thecmsthread/core-admin | src/Controller/Navigation.php | Navigation.redirect | public function redirect()
{
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('navigations-page'));
} else {
return 'Redirect: ' . $this->router->generate('navigations-page');
}
} | php | public function redirect()
{
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('navigations-page'));
} else {
return 'Redirect: ' . $this->router->generate('navigations-page');
}
} | [
"public",
"function",
"redirect",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'template'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'navigations-page'",
")",
")",... | Redirect to the dashboard | [
"Redirect",
"to",
"the",
"dashboard"
] | 020595646e2dd521683e5352e6d9dbad420c06fb | https://github.com/thecmsthread/core-admin/blob/020595646e2dd521683e5352e6d9dbad420c06fb/src/Controller/Navigation.php#L87-L94 |
5,920 | thecmsthread/core-admin | src/Controller/Navigation.php | Navigation.showNavigations | public function showNavigations(array $request = [])
{
$navigations_list = $this->core->api('Navigation/all/flatten', 'GET')->run(0, null, []);
if (($navigations_list["headers"][0][2] - 200) * ($navigations_list["headers"][0][2] - 299) > 0) {
if (headers_sent() === false) {
foreach ($navigations_list["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
return $this->templates->render("500", [
"error" => $navigations_list['response'],
"result" => ''
]);
}
$navigations_list = $navigations_list['response'];
$pages = $this->core->api('Page/all', 'GET')->run();
$pages_list = [];
foreach ($pages['response'] as $key => $page) {
if ($page->status === true && $page->navigation === null) {
$pages_list[] = $page;
}
}
$messages = [
'error' => '',
'info' => '',
'success' => '',
'warning' => ''
];
if (empty($request['m']) === false) {
if ($request['m'] == 1) {
$messages['success'] = 'Navigation element added successfully.';
} elseif ($request['m'] == 2) {
$messages['success'] = 'Navigations list edited successfully.';
} elseif ($request['m'] == 3) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 202', true, 202);
}
$messages['success'] = 'Navigation element deleted successfully.';
} elseif ($request['m'] == 4) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
$messages['error'] = 'Error - Navigation element not found.';
}
}
return $this->templates->render("Main::Navigation", [
"messages" => $messages,
"navigations" => $navigations_list,
"pages" => $pages_list
]);
} | php | public function showNavigations(array $request = [])
{
$navigations_list = $this->core->api('Navigation/all/flatten', 'GET')->run(0, null, []);
if (($navigations_list["headers"][0][2] - 200) * ($navigations_list["headers"][0][2] - 299) > 0) {
if (headers_sent() === false) {
foreach ($navigations_list["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
return $this->templates->render("500", [
"error" => $navigations_list['response'],
"result" => ''
]);
}
$navigations_list = $navigations_list['response'];
$pages = $this->core->api('Page/all', 'GET')->run();
$pages_list = [];
foreach ($pages['response'] as $key => $page) {
if ($page->status === true && $page->navigation === null) {
$pages_list[] = $page;
}
}
$messages = [
'error' => '',
'info' => '',
'success' => '',
'warning' => ''
];
if (empty($request['m']) === false) {
if ($request['m'] == 1) {
$messages['success'] = 'Navigation element added successfully.';
} elseif ($request['m'] == 2) {
$messages['success'] = 'Navigations list edited successfully.';
} elseif ($request['m'] == 3) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 202', true, 202);
}
$messages['success'] = 'Navigation element deleted successfully.';
} elseif ($request['m'] == 4) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
$messages['error'] = 'Error - Navigation element not found.';
}
}
return $this->templates->render("Main::Navigation", [
"messages" => $messages,
"navigations" => $navigations_list,
"pages" => $pages_list
]);
} | [
"public",
"function",
"showNavigations",
"(",
"array",
"$",
"request",
"=",
"[",
"]",
")",
"{",
"$",
"navigations_list",
"=",
"$",
"this",
"->",
"core",
"->",
"api",
"(",
"'Navigation/all/flatten'",
",",
"'GET'",
")",
"->",
"run",
"(",
"0",
",",
"null",
... | Show the navigations list page | [
"Show",
"the",
"navigations",
"list",
"page"
] | 020595646e2dd521683e5352e6d9dbad420c06fb | https://github.com/thecmsthread/core-admin/blob/020595646e2dd521683e5352e6d9dbad420c06fb/src/Controller/Navigation.php#L99-L152 |
5,921 | amercier/rectangular-mozaic | src/Distributor.php | Distributor.distribute | public static function distribute(int $tiles, int $columns, float $tallRateTarget, float $wideRateTarget)
{
// 1. Approximate the number of rows where all tiles would fit
$tallTilesTarget = (int)round($tallRateTarget * $tiles);
$wideTilesTarget = (int)round($wideRateTarget * $tiles);
$smallTilesTarget = $tiles - $tallTilesTarget - $wideTilesTarget;
$cellsTarget = 2 * $tallTilesTarget + 2 * $wideTilesTarget + $smallTilesTarget;
$rows = (int)round($cellsTarget / $columns);
// Check $columns is reasonable
if ($columns >= $cellsTarget || $tallTilesTarget > 0 && $rows < 2) {
throw new InvalidArgumentException("Cannot fill {$tiles} items in {$columns} columns");
}
// 2. Adjust number of tiles to fit exactly the number of available cells
$distribution = Distribution::fromLargeTiles($tiles, $tallTilesTarget, $wideTilesTarget);
while (($cells = $distribution->getCells()) !== $rows * $columns) {
// A. Not enough cells => decrement the number of tall/wide tiles
if ($cells > $rows * $columns) {
$distribution->decrementLargeTiles();
// B. Too many cells => increment the number of tall/wide tiles
} else {
$distribution->incrementLargeTiles();
}
}
return [$distribution, new Grid($rows, $columns)];
} | php | public static function distribute(int $tiles, int $columns, float $tallRateTarget, float $wideRateTarget)
{
// 1. Approximate the number of rows where all tiles would fit
$tallTilesTarget = (int)round($tallRateTarget * $tiles);
$wideTilesTarget = (int)round($wideRateTarget * $tiles);
$smallTilesTarget = $tiles - $tallTilesTarget - $wideTilesTarget;
$cellsTarget = 2 * $tallTilesTarget + 2 * $wideTilesTarget + $smallTilesTarget;
$rows = (int)round($cellsTarget / $columns);
// Check $columns is reasonable
if ($columns >= $cellsTarget || $tallTilesTarget > 0 && $rows < 2) {
throw new InvalidArgumentException("Cannot fill {$tiles} items in {$columns} columns");
}
// 2. Adjust number of tiles to fit exactly the number of available cells
$distribution = Distribution::fromLargeTiles($tiles, $tallTilesTarget, $wideTilesTarget);
while (($cells = $distribution->getCells()) !== $rows * $columns) {
// A. Not enough cells => decrement the number of tall/wide tiles
if ($cells > $rows * $columns) {
$distribution->decrementLargeTiles();
// B. Too many cells => increment the number of tall/wide tiles
} else {
$distribution->incrementLargeTiles();
}
}
return [$distribution, new Grid($rows, $columns)];
} | [
"public",
"static",
"function",
"distribute",
"(",
"int",
"$",
"tiles",
",",
"int",
"$",
"columns",
",",
"float",
"$",
"tallRateTarget",
",",
"float",
"$",
"wideRateTarget",
")",
"{",
"// 1. Approximate the number of rows where all tiles would fit",
"$",
"tallTilesTar... | Create a Distribution that fits a given number of tiles within a grid.
@param int $tiles Total number of tiles of the distribution.
@param int $columns Number of columns of the grid.
@param float $tallRateTarget Targetted number of tall tiles per number of total tiles.
@param float $wideRateTarget Targetted number of wide tiles per number of total tiles.
@return mixed[] An array containing an empty grid, and the created Distribution.
@throws InvalidArgumentException If the number of columns is too low to fit the number of tiles. | [
"Create",
"a",
"Distribution",
"that",
"fits",
"a",
"given",
"number",
"of",
"tiles",
"within",
"a",
"grid",
"."
] | d026a82c1bc73979308235a7a440665e92ee8525 | https://github.com/amercier/rectangular-mozaic/blob/d026a82c1bc73979308235a7a440665e92ee8525/src/Distributor.php#L23-L51 |
5,922 | phproberto/joomla-common | src/Traits/HasParams.php | HasParams.setParam | public function setParam($name, $value)
{
if (null === $this->params)
{
$this->params = $this->loadParams();
}
$this->params->set($name, $value);
return $this;
} | php | public function setParam($name, $value)
{
if (null === $this->params)
{
$this->params = $this->loadParams();
}
$this->params->set($name, $value);
return $this;
} | [
"public",
"function",
"setParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"params",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"this",
"->",
"loadParams",
"(",
")",
";",
"}",
"$",
"this",
... | Set the value of a parameter.
@param string $name Parameter name
@param mixed $value Value to assign to selected parameter
@return self | [
"Set",
"the",
"value",
"of",
"a",
"parameter",
"."
] | bbb37df453bfcb545c3a2c6f14340f0a27e448b2 | https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Traits/HasParams.php#L81-L91 |
5,923 | webfactorybulgaria/Attributes | src/Observers/AttributeGroupObserver.php | AttributeGroupObserver.saved | public function saved(Model $model)
{
$attributes = $this->processAttributes(Request::input('attributes'));
$this->syncAttributes($model, $attributes);
} | php | public function saved(Model $model)
{
$attributes = $this->processAttributes(Request::input('attributes'));
$this->syncAttributes($model, $attributes);
} | [
"public",
"function",
"saved",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"processAttributes",
"(",
"Request",
"::",
"input",
"(",
"'attributes'",
")",
")",
";",
"$",
"this",
"->",
"syncAttributes",
"(",
"$",
"model"... | On save, process attributes.
@param Model $model eloquent
@return mixed false or void | [
"On",
"save",
"process",
"attributes",
"."
] | 217739dfe7b974a1806d6baf4ea1e1861df24f5f | https://github.com/webfactorybulgaria/Attributes/blob/217739dfe7b974a1806d6baf4ea1e1861df24f5f/src/Observers/AttributeGroupObserver.php#L20-L24 |
5,924 | webfactorybulgaria/Attributes | src/Observers/AttributeGroupObserver.php | AttributeGroupObserver.processAttributes | protected function processAttributes($attributes)
{
if (!$attributes) {
return [];
}
$attributes = explode(',', $attributes);
foreach ($attributes as $key => $attribute) {
$attributes[$key] = trim($attribute);
}
return $attributes;
} | php | protected function processAttributes($attributes)
{
if (!$attributes) {
return [];
}
$attributes = explode(',', $attributes);
foreach ($attributes as $key => $attribute) {
$attributes[$key] = trim($attribute);
}
return $attributes;
} | [
"protected",
"function",
"processAttributes",
"(",
"$",
"attributes",
")",
"{",
"if",
"(",
"!",
"$",
"attributes",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"attributes",
"=",
"explode",
"(",
"','",
",",
"$",
"attributes",
")",
";",
"foreach",
"(",
... | Convert string of attributes to array.
@param string
@return array | [
"Convert",
"string",
"of",
"attributes",
"to",
"array",
"."
] | 217739dfe7b974a1806d6baf4ea1e1861df24f5f | https://github.com/webfactorybulgaria/Attributes/blob/217739dfe7b974a1806d6baf4ea1e1861df24f5f/src/Observers/AttributeGroupObserver.php#L33-L46 |
5,925 | easy-system/es-view | src/ViewModel.php | ViewModel.addVariables | public function addVariables($variables)
{
if ($variables instanceof stdClass) {
$variables = (array) $variables;
} elseif ($variables instanceof Traversable) {
$variables = iterator_to_array($variables);
} elseif (! is_array($variables)) {
throw new InvalidArgumentException(sprintf(
'Invalid variables provided; must be an array or Traversable '
. 'or instance of stdClass, "%s" received.',
is_object($variables) ? get_class($variables) : gettype($variables)
));
}
$this->container = array_merge($this->container, $variables);
return $this;
} | php | public function addVariables($variables)
{
if ($variables instanceof stdClass) {
$variables = (array) $variables;
} elseif ($variables instanceof Traversable) {
$variables = iterator_to_array($variables);
} elseif (! is_array($variables)) {
throw new InvalidArgumentException(sprintf(
'Invalid variables provided; must be an array or Traversable '
. 'or instance of stdClass, "%s" received.',
is_object($variables) ? get_class($variables) : gettype($variables)
));
}
$this->container = array_merge($this->container, $variables);
return $this;
} | [
"public",
"function",
"addVariables",
"(",
"$",
"variables",
")",
"{",
"if",
"(",
"$",
"variables",
"instanceof",
"stdClass",
")",
"{",
"$",
"variables",
"=",
"(",
"array",
")",
"$",
"variables",
";",
"}",
"elseif",
"(",
"$",
"variables",
"instanceof",
"... | Adds the variables.
@param array|\stdClass|\Traversable $variables The variables
@throws \InvalidArgumentException If invalid variables type provided
@return self | [
"Adds",
"the",
"variables",
"."
] | 8a29efcef8cd59640c98f5440379a93d0f504212 | https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/ViewModel.php#L134-L150 |
5,926 | easy-system/es-view | src/ViewModel.php | ViewModel.addChild | public function addChild(ViewModelInterface $child, $groupId = null)
{
$this->children[] = $child;
if (! is_null($groupId)) {
$child->setGroupId($groupId);
}
return $this;
} | php | public function addChild(ViewModelInterface $child, $groupId = null)
{
$this->children[] = $child;
if (! is_null($groupId)) {
$child->setGroupId($groupId);
}
return $this;
} | [
"public",
"function",
"addChild",
"(",
"ViewModelInterface",
"$",
"child",
",",
"$",
"groupId",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"children",
"[",
"]",
"=",
"$",
"child",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"groupId",
")",
")",
"{",
"... | Adds the child model.
@param \Es\Mvc\ViewModelInterface $child The child model
@param string $groupId Optional; the group identifier
@return self | [
"Adds",
"the",
"child",
"model",
"."
] | 8a29efcef8cd59640c98f5440379a93d0f504212 | https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/ViewModel.php#L274-L282 |
5,927 | nails/driver-shop-shipping-flatrate | src/FlatRate.php | FlatRate.calculate | public function calculate($aShippableItems, $oBasket)
{
$iCostPerItem = (int) $this->getSetting('iCostPerItem') ?: 0;
$iItemCount = 0;
foreach ($aShippableItems as $oItem) {
$iItemCount += $oItem->quantity;
}
return $iItemCount * $iCostPerItem;
} | php | public function calculate($aShippableItems, $oBasket)
{
$iCostPerItem = (int) $this->getSetting('iCostPerItem') ?: 0;
$iItemCount = 0;
foreach ($aShippableItems as $oItem) {
$iItemCount += $oItem->quantity;
}
return $iItemCount * $iCostPerItem;
} | [
"public",
"function",
"calculate",
"(",
"$",
"aShippableItems",
",",
"$",
"oBasket",
")",
"{",
"$",
"iCostPerItem",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"getSetting",
"(",
"'iCostPerItem'",
")",
"?",
":",
"0",
";",
"$",
"iItemCount",
"=",
"0",
";",... | Calculates the cost of shipping all shippable items in a basket
@param array $aShippableItems An array of all items which are shippable (i.e., product type `is_physical` and is not `collect_only`)
@param stdClass $oBasket The complete basket object, used to grab the basket's total value.
@return integer | [
"Calculates",
"the",
"cost",
"of",
"shipping",
"all",
"shippable",
"items",
"in",
"a",
"basket"
] | 2e74946ae1c5d53a3e0167f19dd7eb252243ec75 | https://github.com/nails/driver-shop-shipping-flatrate/blob/2e74946ae1c5d53a3e0167f19dd7eb252243ec75/src/FlatRate.php#L32-L40 |
5,928 | davewwww/Flagging | src/Dwo/Flagging/Context/Context.php | Context.removeParam | public function removeParam($key)
{
if (null !== $this->params) {
unset($this->params[$key]);
if (empty($this->params)) {
$this->params = null;
}
}
} | php | public function removeParam($key)
{
if (null !== $this->params) {
unset($this->params[$key]);
if (empty($this->params)) {
$this->params = null;
}
}
} | [
"public",
"function",
"removeParam",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"params",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"key",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"-... | Removes the parameters.
@param string $key | [
"Removes",
"the",
"parameters",
"."
] | 7511cb8bbaa07b808a42a60e68495347a0bbbbb8 | https://github.com/davewwww/Flagging/blob/7511cb8bbaa07b808a42a60e68495347a0bbbbb8/src/Dwo/Flagging/Context/Context.php#L122-L130 |
5,929 | davewwww/Flagging | src/Dwo/Flagging/Context/Context.php | Context.setParams | public function setParams(array $params = null)
{
$this->params = $params;
if (null !== $params && empty($params)) {
$this->params = null;
}
} | php | public function setParams(array $params = null)
{
$this->params = $params;
if (null !== $params && empty($params)) {
$this->params = null;
}
} | [
"public",
"function",
"setParams",
"(",
"array",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"if",
"(",
"null",
"!==",
"$",
"params",
"&&",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"this",
"... | Sets the parameters.
@param array $params | [
"Sets",
"the",
"parameters",
"."
] | 7511cb8bbaa07b808a42a60e68495347a0bbbbb8 | https://github.com/davewwww/Flagging/blob/7511cb8bbaa07b808a42a60e68495347a0bbbbb8/src/Dwo/Flagging/Context/Context.php#L137-L143 |
5,930 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.fromString | public static function fromString(string $propertyString): self
{
$propertyData = @parse_ini_string($propertyString, true);
if (false === $propertyData) {
throw new \InvalidArgumentException(
'Property string contains errors and can not be parsed: '
. lastErrorMessage()->value()
);
}
return new static($propertyData);
} | php | public static function fromString(string $propertyString): self
{
$propertyData = @parse_ini_string($propertyString, true);
if (false === $propertyData) {
throw new \InvalidArgumentException(
'Property string contains errors and can not be parsed: '
. lastErrorMessage()->value()
);
}
return new static($propertyData);
} | [
"public",
"static",
"function",
"fromString",
"(",
"string",
"$",
"propertyString",
")",
":",
"self",
"{",
"$",
"propertyData",
"=",
"@",
"parse_ini_string",
"(",
"$",
"propertyString",
",",
"true",
")",
";",
"if",
"(",
"false",
"===",
"$",
"propertyData",
... | construct class from string
@api
@param string $propertyString
@return \stubbles\values\Properties
@throws \InvalidArgumentException
@since 2.0.0 | [
"construct",
"class",
"from",
"string"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L59-L70 |
5,931 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.fromFile | public static function fromFile(string $propertiesFile): self
{
if (!file_exists($propertiesFile) || !is_readable($propertiesFile)) {
throw new \InvalidArgumentException(
'Property file ' . $propertiesFile . ' not found'
);
}
$propertyData = @parse_ini_file($propertiesFile, true);
if (false === $propertyData) {
throw new \UnexpectedValueException(
'Property file at ' . $propertiesFile
. ' contains errors and can not be parsed: '
. lastErrorMessage()->value()
);
}
return new static($propertyData);
} | php | public static function fromFile(string $propertiesFile): self
{
if (!file_exists($propertiesFile) || !is_readable($propertiesFile)) {
throw new \InvalidArgumentException(
'Property file ' . $propertiesFile . ' not found'
);
}
$propertyData = @parse_ini_file($propertiesFile, true);
if (false === $propertyData) {
throw new \UnexpectedValueException(
'Property file at ' . $propertiesFile
. ' contains errors and can not be parsed: '
. lastErrorMessage()->value()
);
}
return new static($propertyData);
} | [
"public",
"static",
"function",
"fromFile",
"(",
"string",
"$",
"propertiesFile",
")",
":",
"self",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"propertiesFile",
")",
"||",
"!",
"is_readable",
"(",
"$",
"propertiesFile",
")",
")",
"{",
"throw",
"new",
... | construct class from a file
@api
@param string $propertiesFile full path to file containing properties
@return \stubbles\values\Properties
@throws \InvalidArgumentException if file can not be found or is not readable
@throws \UnexpectedValueException if file contains errors and can not be parsed | [
"construct",
"class",
"from",
"a",
"file"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L81-L99 |
5,932 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.section | public function section(string $section, array $default = []): array
{
if (isset($this->propertyData[$section])) {
return $this->propertyData[$section];
}
return $default;
} | php | public function section(string $section, array $default = []): array
{
if (isset($this->propertyData[$section])) {
return $this->propertyData[$section];
}
return $default;
} | [
"public",
"function",
"section",
"(",
"string",
"$",
"section",
",",
"array",
"$",
"default",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
")",
")",
"{",
"return",
"$",... | returns a whole section if it exists or the default if the section does not exist
@api
@param string $section name of the section
@param array $default value to return if section does not exist
@return scalar[]
@since 4.0.0 | [
"returns",
"a",
"whole",
"section",
"if",
"it",
"exists",
"or",
"the",
"default",
"if",
"the",
"section",
"does",
"not",
"exist"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L140-L147 |
5,933 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.keysForSection | public function keysForSection(string $section, array $default = []): array
{
if (isset($this->propertyData[$section])) {
return array_keys($this->propertyData[$section]);
}
return $default;
} | php | public function keysForSection(string $section, array $default = []): array
{
if (isset($this->propertyData[$section])) {
return array_keys($this->propertyData[$section]);
}
return $default;
} | [
"public",
"function",
"keysForSection",
"(",
"string",
"$",
"section",
",",
"array",
"$",
"default",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
")",
")",
"{",
"return",... | returns a list of all keys of a specific section
@api
@param string $section name of the section
@param string[] $default value to return if section does not exist
@return string[]
@since 4.0.0 | [
"returns",
"a",
"list",
"of",
"all",
"keys",
"of",
"a",
"specific",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L158-L165 |
5,934 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.containValue | public function containValue(string $section, string $key): bool
{
if (isset($this->propertyData[$section]) && isset($this->propertyData[$section][$key])) {
return true;
}
return false;
} | php | public function containValue(string $section, string $key): bool
{
if (isset($this->propertyData[$section]) && isset($this->propertyData[$section][$key])) {
return true;
}
return false;
} | [
"public",
"function",
"containValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
... | checks if a certain section contains a certain key
@api
@param string $section name of the section
@param string $key name of the key
@return bool
@since 4.0.0 | [
"checks",
"if",
"a",
"certain",
"section",
"contains",
"a",
"certain",
"key"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L176-L183 |
5,935 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.value | public function value(string $section, string $key, $default = null)
{
if (isset($this->propertyData[$section]) && isset($this->propertyData[$section][$key])) {
return $this->propertyData[$section][$key];
}
return $default;
} | php | public function value(string $section, string $key, $default = null)
{
if (isset($this->propertyData[$section]) && isset($this->propertyData[$section][$key])) {
return $this->propertyData[$section][$key];
}
return $default;
} | [
"public",
"function",
"value",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
")",
"&&",
"isset",
"(",
"$",... | returns a value from a section or a default value if the section or key does not exist
@api
@param string $section name of the section
@param string $key name of the key
@param mixed $default value to return if section or key does not exist
@return scalar
@since 4.0.0 | [
"returns",
"a",
"value",
"from",
"a",
"section",
"or",
"a",
"default",
"value",
"if",
"the",
"section",
"or",
"key",
"does",
"not",
"exist"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L195-L202 |
5,936 | stubbles/stubbles-values | src/main/php/Properties.php | Properties.parseValue | public function parseValue(string $section, string $key, $default = null)
{
if (isset($this->propertyData[$section]) && isset($this->propertyData[$section][$key])) {
if ($this->propertyData[$section][$key] instanceof Secret) {
return $this->propertyData[$section][$key];
}
return Parse::toType($this->propertyData[$section][$key]);
}
return $default;
} | php | public function parseValue(string $section, string $key, $default = null)
{
if (isset($this->propertyData[$section]) && isset($this->propertyData[$section][$key])) {
if ($this->propertyData[$section][$key] instanceof Secret) {
return $this->propertyData[$section][$key];
}
return Parse::toType($this->propertyData[$section][$key]);
}
return $default;
} | [
"public",
"function",
"parseValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
")",
"&&",
"isset",
"(",
... | parses value and returns the parsing result
@param string $section
@param string $key
@param mixed $default
@return mixed
@see \stubbles\values\Parse::toType()
@since 4.1.0 | [
"parses",
"value",
"and",
"returns",
"the",
"parsing",
"result"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Properties.php#L214-L225 |
5,937 | infinity-se/infinity-base | src/InfinityBase/Mapper/AbstractMapper.php | AbstractMapper.getRepository | protected function getRepository()
{
if (null === $this->repository) {
$this->repository = $this->getEntityManager()
->getRepository($this->getModuleNamespace() . '\Entity\\' . $this->getEntityName());
}
return $this->repository;
} | php | protected function getRepository()
{
if (null === $this->repository) {
$this->repository = $this->getEntityManager()
->getRepository($this->getModuleNamespace() . '\Entity\\' . $this->getEntityName());
}
return $this->repository;
} | [
"protected",
"function",
"getRepository",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"repository",
")",
"{",
"$",
"this",
"->",
"repository",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
... | Get the accounts repository
@return EntityRepository | [
"Get",
"the",
"accounts",
"repository"
] | 4f869ae4b549e779560a83528d2ed2664f6deb5b | https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/Mapper/AbstractMapper.php#L26-L33 |
5,938 | themichaelhall/datatypes | src/Hostname.php | Hostname.equals | public function equals(HostnameInterface $hostname): bool
{
return $this->getDomainParts() === $hostname->getDomainParts() && $this->getTld() === $hostname->getTld();
} | php | public function equals(HostnameInterface $hostname): bool
{
return $this->getDomainParts() === $hostname->getDomainParts() && $this->getTld() === $hostname->getTld();
} | [
"public",
"function",
"equals",
"(",
"HostnameInterface",
"$",
"hostname",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getDomainParts",
"(",
")",
"===",
"$",
"hostname",
"->",
"getDomainParts",
"(",
")",
"&&",
"$",
"this",
"->",
"getTld",
"(",
"... | Returns true if the hostname equals other hostname, false otherwise.
@since 1.2.0
@param HostnameInterface $hostname The other hostname.
@return bool True if the hostname equals other hostname, false otherwise. | [
"Returns",
"true",
"if",
"the",
"hostname",
"equals",
"other",
"hostname",
"false",
"otherwise",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L30-L33 |
5,939 | themichaelhall/datatypes | src/Hostname.php | Hostname.getDomainName | public function getDomainName(): string
{
return $this->myDomainParts[count($this->myDomainParts) - 1] . ($this->myTld !== null ? '.' . $this->myTld : '');
} | php | public function getDomainName(): string
{
return $this->myDomainParts[count($this->myDomainParts) - 1] . ($this->myTld !== null ? '.' . $this->myTld : '');
} | [
"public",
"function",
"getDomainName",
"(",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"myDomainParts",
"[",
"count",
"(",
"$",
"this",
"->",
"myDomainParts",
")",
"-",
"1",
"]",
".",
"(",
"$",
"this",
"->",
"myTld",
"!==",
"null",
"?",
"'... | Returns the domain name including top-level domain.
@since 1.0.0
@return string The domain name including top-level domain. | [
"Returns",
"the",
"domain",
"name",
"including",
"top",
"-",
"level",
"domain",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L42-L45 |
5,940 | themichaelhall/datatypes | src/Hostname.php | Hostname.withTld | public function withTld(string $tld): HostnameInterface
{
if (!self::myValidateTld($tld, $error)) {
throw new HostnameInvalidArgumentException($error);
}
// Normalize top-level domain.
self::myNormalizeTld($tld);
return new self($this->myDomainParts, $tld);
} | php | public function withTld(string $tld): HostnameInterface
{
if (!self::myValidateTld($tld, $error)) {
throw new HostnameInvalidArgumentException($error);
}
// Normalize top-level domain.
self::myNormalizeTld($tld);
return new self($this->myDomainParts, $tld);
} | [
"public",
"function",
"withTld",
"(",
"string",
"$",
"tld",
")",
":",
"HostnameInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"myValidateTld",
"(",
"$",
"tld",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"HostnameInvalidArgumentException",
"(",
"$",
... | Returns a copy of the Hostname instance with the specified top-level domain.
@since 1.0.0
@param string $tld The top-level domain.
@throws HostnameInvalidArgumentException If the top-level domain parameter is not a valid top-level domain.
@return HostnameInterface The Hostname instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Hostname",
"instance",
"with",
"the",
"specified",
"top",
"-",
"level",
"domain",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L82-L92 |
5,941 | themichaelhall/datatypes | src/Hostname.php | Hostname.fromParts | public static function fromParts(array $domainParts, ?string $tld = null): HostnameInterface
{
if (count($domainParts) === 0) {
throw new HostnameInvalidArgumentException('Domain parts [] is empty.');
}
if (!self::myValidateDomainParts($domainParts, $error)) {
throw new HostnameInvalidArgumentException('Domain parts ["' . implode('", "', $domainParts) . '"] is invalid: ' . $error);
}
if (!self::myValidateTld($tld, $error)) {
throw new HostnameInvalidArgumentException($error);
}
self::myNormalizeDomainParts($domainParts);
self::myNormalizeTld($tld);
return new self($domainParts, $tld);
} | php | public static function fromParts(array $domainParts, ?string $tld = null): HostnameInterface
{
if (count($domainParts) === 0) {
throw new HostnameInvalidArgumentException('Domain parts [] is empty.');
}
if (!self::myValidateDomainParts($domainParts, $error)) {
throw new HostnameInvalidArgumentException('Domain parts ["' . implode('", "', $domainParts) . '"] is invalid: ' . $error);
}
if (!self::myValidateTld($tld, $error)) {
throw new HostnameInvalidArgumentException($error);
}
self::myNormalizeDomainParts($domainParts);
self::myNormalizeTld($tld);
return new self($domainParts, $tld);
} | [
"public",
"static",
"function",
"fromParts",
"(",
"array",
"$",
"domainParts",
",",
"?",
"string",
"$",
"tld",
"=",
"null",
")",
":",
"HostnameInterface",
"{",
"if",
"(",
"count",
"(",
"$",
"domainParts",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"Hos... | Creates a hostname from hostname parts.
@since 1.0.0
@param string[] $domainParts The domain parts.
@param string|null $tld The top level domain or null if no top-level domain should be included.
@throws HostnameInvalidArgumentException If any of the parameters are invalid.
@throws \InvalidArgumentException If the $domainParts parameter is not an array of strings.
@return HostnameInterface The hostname instance. | [
"Creates",
"a",
"hostname",
"from",
"hostname",
"parts",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L119-L137 |
5,942 | themichaelhall/datatypes | src/Hostname.php | Hostname.myParse | private static function myParse(string $hostname, ?array &$domainParts = null, ?string &$tld = null, ?string &$error = null): bool
{
if ($hostname === '') {
$error = 'Hostname "' . $hostname . '" is empty.';
return false;
}
if (strlen($hostname) > 255) {
$error = 'Hostname "' . $hostname . '" is too long: Maximum allowed length is 255 characters."';
return false;
}
$domainParts = explode(
'.',
substr($hostname, -1) === '.' ? substr($hostname, 0, -1) : $hostname // Remove trailing "." from hostname.
);
// Is there a top-level domain?
$tld = count($domainParts) > 1 ? array_pop($domainParts) : null;
if ($tld !== null) {
if (!self::myValidateTld($tld, $error)) {
$error = 'Hostname "' . $hostname . '" is invalid: ' . $error;
return false;
}
}
// Validate the domain parts.
if (!self::myValidateDomainParts($domainParts, $error)) {
$error = 'Hostname "' . $hostname . '" is invalid: ' . $error;
return false;
}
// Normalize result.
self::myNormalizeDomainParts($domainParts);
self::myNormalizeTld($tld);
return true;
} | php | private static function myParse(string $hostname, ?array &$domainParts = null, ?string &$tld = null, ?string &$error = null): bool
{
if ($hostname === '') {
$error = 'Hostname "' . $hostname . '" is empty.';
return false;
}
if (strlen($hostname) > 255) {
$error = 'Hostname "' . $hostname . '" is too long: Maximum allowed length is 255 characters."';
return false;
}
$domainParts = explode(
'.',
substr($hostname, -1) === '.' ? substr($hostname, 0, -1) : $hostname // Remove trailing "." from hostname.
);
// Is there a top-level domain?
$tld = count($domainParts) > 1 ? array_pop($domainParts) : null;
if ($tld !== null) {
if (!self::myValidateTld($tld, $error)) {
$error = 'Hostname "' . $hostname . '" is invalid: ' . $error;
return false;
}
}
// Validate the domain parts.
if (!self::myValidateDomainParts($domainParts, $error)) {
$error = 'Hostname "' . $hostname . '" is invalid: ' . $error;
return false;
}
// Normalize result.
self::myNormalizeDomainParts($domainParts);
self::myNormalizeTld($tld);
return true;
} | [
"private",
"static",
"function",
"myParse",
"(",
"string",
"$",
"hostname",
",",
"?",
"array",
"&",
"$",
"domainParts",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"tld",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bo... | Tries to parse a hostname and returns the result or error text.
@param string $hostname The hostname.
@param string[]|null $domainParts The domain parts if parsing was successful, undefined otherwise.
@param string|null $tld The top-level domain if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Tries",
"to",
"parse",
"a",
"hostname",
"and",
"returns",
"the",
"result",
"or",
"error",
"text",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L213-L255 |
5,943 | themichaelhall/datatypes | src/Hostname.php | Hostname.myValidateTld | private static function myValidateTld(?string $tld, ?string &$error): bool
{
if ($tld === null) {
return true;
}
if ($tld === '') {
$error = 'Top-level domain "' . $tld . '" is empty.';
return false;
}
if (strlen($tld) > 63) {
$error = 'Top-level domain "' . $tld . '" is too long: Maximum allowed length is 63 characters.';
return false;
}
if (preg_match('/[^a-zA-Z]/', $tld, $matches)) {
$error = 'Top-level domain "' . $tld . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
} | php | private static function myValidateTld(?string $tld, ?string &$error): bool
{
if ($tld === null) {
return true;
}
if ($tld === '') {
$error = 'Top-level domain "' . $tld . '" is empty.';
return false;
}
if (strlen($tld) > 63) {
$error = 'Top-level domain "' . $tld . '" is too long: Maximum allowed length is 63 characters.';
return false;
}
if (preg_match('/[^a-zA-Z]/', $tld, $matches)) {
$error = 'Top-level domain "' . $tld . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
} | [
"private",
"static",
"function",
"myValidateTld",
"(",
"?",
"string",
"$",
"tld",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"tld",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"tld",
"==... | Validates a top-level domain.
@param string|null $tld The top-level domain.
@param string|null $error The The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"a",
"top",
"-",
"level",
"domain",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L265-L290 |
5,944 | themichaelhall/datatypes | src/Hostname.php | Hostname.myValidateDomainParts | private static function myValidateDomainParts(array $domainParts, ?string &$error): bool
{
foreach ($domainParts as $part) {
if (!is_string($part)) {
throw new \InvalidArgumentException('$domainParts parameter is not an array of strings.');
}
if (!self::myValidateDomainPart($part, $error)) {
return false;
}
}
return true;
} | php | private static function myValidateDomainParts(array $domainParts, ?string &$error): bool
{
foreach ($domainParts as $part) {
if (!is_string($part)) {
throw new \InvalidArgumentException('$domainParts parameter is not an array of strings.');
}
if (!self::myValidateDomainPart($part, $error)) {
return false;
}
}
return true;
} | [
"private",
"static",
"function",
"myValidateDomainParts",
"(",
"array",
"$",
"domainParts",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"domainParts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
... | Validates domain parts.
@param string[] $domainParts The domain parts.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@throws \InvalidArgumentException If the $domainParts parameter is not an array of strings.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"domain",
"parts",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L302-L315 |
5,945 | themichaelhall/datatypes | src/Hostname.php | Hostname.myValidateDomainPart | private static function myValidateDomainPart(string $domainPart, ?string &$error): bool
{
if ($domainPart === '') {
$error = 'Part of domain "' . $domainPart . '" is empty.';
return false;
}
if (strlen($domainPart) > 63) {
$error = 'Part of domain "' . $domainPart . '" is too long: Maximum allowed length is 63 characters.';
return false;
}
if (preg_match('/[^a-zA-Z0-9-]/', $domainPart, $matches)) {
$error = 'Part of domain "' . $domainPart . '" contains invalid character "' . $matches[0] . '".';
return false;
}
if (substr($domainPart, 0, 1) === '-') {
$error = 'Part of domain "' . $domainPart . '" begins with "-".';
return false;
}
if (substr($domainPart, -1) === '-') {
$error = 'Part of domain "' . $domainPart . '" ends with "-".';
return false;
}
return true;
} | php | private static function myValidateDomainPart(string $domainPart, ?string &$error): bool
{
if ($domainPart === '') {
$error = 'Part of domain "' . $domainPart . '" is empty.';
return false;
}
if (strlen($domainPart) > 63) {
$error = 'Part of domain "' . $domainPart . '" is too long: Maximum allowed length is 63 characters.';
return false;
}
if (preg_match('/[^a-zA-Z0-9-]/', $domainPart, $matches)) {
$error = 'Part of domain "' . $domainPart . '" contains invalid character "' . $matches[0] . '".';
return false;
}
if (substr($domainPart, 0, 1) === '-') {
$error = 'Part of domain "' . $domainPart . '" begins with "-".';
return false;
}
if (substr($domainPart, -1) === '-') {
$error = 'Part of domain "' . $domainPart . '" ends with "-".';
return false;
}
return true;
} | [
"private",
"static",
"function",
"myValidateDomainPart",
"(",
"string",
"$",
"domainPart",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"domainPart",
"===",
"''",
")",
"{",
"$",
"error",
"=",
"'Part of domain \"'",
".",
"... | Validates a domain part.
@param string $domainPart The domain part.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"a",
"domain",
"part",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L325-L358 |
5,946 | themichaelhall/datatypes | src/Hostname.php | Hostname.myNormalizeTld | private static function myNormalizeTld(?string &$tld = null): void
{
if ($tld !== null) {
$tld = strtolower($tld);
}
} | php | private static function myNormalizeTld(?string &$tld = null): void
{
if ($tld !== null) {
$tld = strtolower($tld);
}
} | [
"private",
"static",
"function",
"myNormalizeTld",
"(",
"?",
"string",
"&",
"$",
"tld",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"$",
"tld",
"!==",
"null",
")",
"{",
"$",
"tld",
"=",
"strtolower",
"(",
"$",
"tld",
")",
";",
"}",
"}"
] | Normalizes a top-level domain.
@param string|null $tld The top-level domain. | [
"Normalizes",
"a",
"top",
"-",
"level",
"domain",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Hostname.php#L365-L370 |
5,947 | austinkregel/laravel-data-store | src/DataStore.php | DataStore.first | public function first(string $key)
{
$key = $this->getKey($key);
if (!$this->exists($key)) {
throw new ModelNotFoundException(sprintf('No query results for the redis key [%s]', $key));
}
$value = cache($key);
if (is_array($value)) {
return Arr::first($value);
}
return $value;
} | php | public function first(string $key)
{
$key = $this->getKey($key);
if (!$this->exists($key)) {
throw new ModelNotFoundException(sprintf('No query results for the redis key [%s]', $key));
}
$value = cache($key);
if (is_array($value)) {
return Arr::first($value);
}
return $value;
} | [
"public",
"function",
"first",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"ModelNotF... | Grab the first bit of data of whatever is saved to the key.
@param string $key
@return mixed|null | [
"Grab",
"the",
"first",
"bit",
"of",
"data",
"of",
"whatever",
"is",
"saved",
"to",
"the",
"key",
"."
] | 6ecad3a77445717f2543b64879bff3192f2af96e | https://github.com/austinkregel/laravel-data-store/blob/6ecad3a77445717f2543b64879bff3192f2af96e/src/DataStore.php#L117-L132 |
5,948 | austinkregel/laravel-data-store | src/DataStore.php | DataStore.save | public function save(string $key, callable $callback)
{
$key = $this->getKey($key);
return cache()->rememberForever($key, $callback);
} | php | public function save(string $key, callable $callback)
{
$key = $this->getKey($key);
return cache()->rememberForever($key, $callback);
} | [
"public",
"function",
"save",
"(",
"string",
"$",
"key",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
";",
"return",
"cache",
"(",
")",
"->",
"rememberForever",
"(",
"$",
"key",
","... | Save the results of the callback to the cache.
@param string $key
@param callable $callback
@return mixed
@throws ModelNotFoundException | [
"Save",
"the",
"results",
"of",
"the",
"callback",
"to",
"the",
"cache",
"."
] | 6ecad3a77445717f2543b64879bff3192f2af96e | https://github.com/austinkregel/laravel-data-store/blob/6ecad3a77445717f2543b64879bff3192f2af96e/src/DataStore.php#L141-L146 |
5,949 | austinkregel/laravel-data-store | src/DataStore.php | DataStore.exists | public function exists(string $key): bool
{
$key = $this->getKey($key);
return cache()->has($key);
} | php | public function exists(string $key): bool
{
$key = $this->getKey($key);
return cache()->has($key);
} | [
"public",
"function",
"exists",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
";",
"return",
"cache",
"(",
")",
"->",
"has",
"(",
"$",
"key",
")",
";",
"}"
] | Checks if the thing exists in the store
@param string $key
@return bool | [
"Checks",
"if",
"the",
"thing",
"exists",
"in",
"the",
"store"
] | 6ecad3a77445717f2543b64879bff3192f2af96e | https://github.com/austinkregel/laravel-data-store/blob/6ecad3a77445717f2543b64879bff3192f2af96e/src/DataStore.php#L153-L158 |
5,950 | austinkregel/laravel-data-store | src/DataStore.php | DataStore.destroy | public function destroy(string $key): void
{
$key = $this->getKey($key);
cache()->forget($key);
} | php | public function destroy(string $key): void
{
$key = $this->getKey($key);
cache()->forget($key);
} | [
"public",
"function",
"destroy",
"(",
"string",
"$",
"key",
")",
":",
"void",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
";",
"cache",
"(",
")",
"->",
"forget",
"(",
"$",
"key",
")",
";",
"}"
] | Remove an item from the store
@param string $key
@return void | [
"Remove",
"an",
"item",
"from",
"the",
"store"
] | 6ecad3a77445717f2543b64879bff3192f2af96e | https://github.com/austinkregel/laravel-data-store/blob/6ecad3a77445717f2543b64879bff3192f2af96e/src/DataStore.php#L165-L170 |
5,951 | kaecyra/app-common | src/Event/EventAwareTrait.php | EventAwareTrait.fireReflected | public function fireReflected(string $event, array $arguments = null) {
return $this->getEventManager()->fireReflected($event, $arguments);
} | php | public function fireReflected(string $event, array $arguments = null) {
return $this->getEventManager()->fireReflected($event, $arguments);
} | [
"public",
"function",
"fireReflected",
"(",
"string",
"$",
"event",
",",
"array",
"$",
"arguments",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"fireReflected",
"(",
"$",
"event",
",",
"$",
"arguments",
")",
";"... | Fire events and reflect on the handler to pass named arguments
@param type $event
@param type $arguments | [
"Fire",
"events",
"and",
"reflect",
"on",
"the",
"handler",
"to",
"pass",
"named",
"arguments"
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Event/EventAwareTrait.php#L106-L108 |
5,952 | mszewcz/php-light-framework | src/Html/Tags.php | Tags.setDefaultAttributes | private static function setDefaultAttributes(array $attributes, array $default): array
{
foreach ($default as $name => $value) {
if (!\array_key_exists($name, $attributes)) {
$attributes[$name] = $value;
}
}
return $attributes;
} | php | private static function setDefaultAttributes(array $attributes, array $default): array
{
foreach ($default as $name => $value) {
if (!\array_key_exists($name, $attributes)) {
$attributes[$name] = $value;
}
}
return $attributes;
} | [
"private",
"static",
"function",
"setDefaultAttributes",
"(",
"array",
"$",
"attributes",
",",
"array",
"$",
"default",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"default",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"\\",
"arra... | Sets default attributes
@param array $attributes
@param array $default
@return array | [
"Sets",
"default",
"attributes"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Tags.php#L216-L224 |
5,953 | mszewcz/php-light-framework | src/Html/Tags.php | Tags.extractAttributes | private static function extractAttributes(array $attributes = []): string
{
$extracted = [];
if (\count($attributes) > 0) {
foreach ($attributes as $name => $value) {
if ($name != 'id' || ($name == 'id' && $value != '')) {
$extracted[] = sprintf(
'%s="%s"',
\strtolower($name),
\htmlspecialchars((string)$value, ENT_COMPAT | ENT_HTML5)
);
}
}
return \sprintf(' %s', \implode(' ', $extracted));
}
return '';
} | php | private static function extractAttributes(array $attributes = []): string
{
$extracted = [];
if (\count($attributes) > 0) {
foreach ($attributes as $name => $value) {
if ($name != 'id' || ($name == 'id' && $value != '')) {
$extracted[] = sprintf(
'%s="%s"',
\strtolower($name),
\htmlspecialchars((string)$value, ENT_COMPAT | ENT_HTML5)
);
}
}
return \sprintf(' %s', \implode(' ', $extracted));
}
return '';
} | [
"private",
"static",
"function",
"extractAttributes",
"(",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"extracted",
"=",
"[",
"]",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"attributes",
")",
">",
"0",
")",
"{",
"foreach",... | This method transforms attributes array to string
@param array $attributes
@return string | [
"This",
"method",
"transforms",
"attributes",
"array",
"to",
"string"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Tags.php#L232-L248 |
5,954 | mszewcz/php-light-framework | src/Html/Tags.php | Tags.buildTag | private static function buildTag(string $name, $arguments): string
{
$tagConf = static::$tagsData[$name];
$hasValue = (boolean)$tagConf['hasValue'];
$clear = \iterator_to_array($tagConf['clearAttributes'], true);
$default = \iterator_to_array($tagConf['defaultAttributes'], true);
$tagName = $name == 'vartag' ? 'var' : $name;
$tagValue = static::getTagContent($arguments, $hasValue);
$attributes = static::getTagAttributes($arguments, $hasValue);
$attributes = static::clearAttributes($attributes, $clear);
$attributes = static::setDefaultAttributes($attributes, $default);
$newLine = '';
if (\is_array($tagValue)) {
$tagValue = \implode(static::CRLF, $tagValue);
$newLine = static::CRLF;
} elseif (\in_array($tagName, ['body', 'head', 'html'])) {
$newLine = static::CRLF;
}
if ($hasValue === true) {
return \sprintf(
'<%s%s>%s%s%s</%s>%s',
$tagName,
static::extractAttributes($attributes),
$newLine,
\rtrim(\str_replace(static::CRLF.static::CRLF, static::CRLF, $tagValue), static::CRLF),
$newLine,
$tagName,
$newLine
);
}
if (\in_array($tagName, ['iframe'])) {
return \sprintf('<%s%s></%s>', $tagName, static::extractAttributes($attributes), $tagName);
}
return \sprintf('<%s%s/>', $tagName, static::extractAttributes($attributes));
} | php | private static function buildTag(string $name, $arguments): string
{
$tagConf = static::$tagsData[$name];
$hasValue = (boolean)$tagConf['hasValue'];
$clear = \iterator_to_array($tagConf['clearAttributes'], true);
$default = \iterator_to_array($tagConf['defaultAttributes'], true);
$tagName = $name == 'vartag' ? 'var' : $name;
$tagValue = static::getTagContent($arguments, $hasValue);
$attributes = static::getTagAttributes($arguments, $hasValue);
$attributes = static::clearAttributes($attributes, $clear);
$attributes = static::setDefaultAttributes($attributes, $default);
$newLine = '';
if (\is_array($tagValue)) {
$tagValue = \implode(static::CRLF, $tagValue);
$newLine = static::CRLF;
} elseif (\in_array($tagName, ['body', 'head', 'html'])) {
$newLine = static::CRLF;
}
if ($hasValue === true) {
return \sprintf(
'<%s%s>%s%s%s</%s>%s',
$tagName,
static::extractAttributes($attributes),
$newLine,
\rtrim(\str_replace(static::CRLF.static::CRLF, static::CRLF, $tagValue), static::CRLF),
$newLine,
$tagName,
$newLine
);
}
if (\in_array($tagName, ['iframe'])) {
return \sprintf('<%s%s></%s>', $tagName, static::extractAttributes($attributes), $tagName);
}
return \sprintf('<%s%s/>', $tagName, static::extractAttributes($attributes));
} | [
"private",
"static",
"function",
"buildTag",
"(",
"string",
"$",
"name",
",",
"$",
"arguments",
")",
":",
"string",
"{",
"$",
"tagConf",
"=",
"static",
"::",
"$",
"tagsData",
"[",
"$",
"name",
"]",
";",
"$",
"hasValue",
"=",
"(",
"boolean",
")",
"$",... | Builds html tag
@param string $name
@param $arguments
@return string | [
"Builds",
"html",
"tag"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Tags.php#L257-L296 |
5,955 | mszewcz/php-light-framework | src/Html/Tags.php | Tags.comment | public static function comment(string $text = '', bool $addSpaces = false): string
{
$space = $addSpaces === true ? ' ' : '';
return \sprintf('<!--%s%s%s-->', $space, $text, $space);
} | php | public static function comment(string $text = '', bool $addSpaces = false): string
{
$space = $addSpaces === true ? ' ' : '';
return \sprintf('<!--%s%s%s-->', $space, $text, $space);
} | [
"public",
"static",
"function",
"comment",
"(",
"string",
"$",
"text",
"=",
"''",
",",
"bool",
"$",
"addSpaces",
"=",
"false",
")",
":",
"string",
"{",
"$",
"space",
"=",
"$",
"addSpaces",
"===",
"true",
"?",
"' '",
":",
"''",
";",
"return",
"\\",
... | This method returns html comment
@param string $text
@param bool $addSpaces
@return string | [
"This",
"method",
"returns",
"html",
"comment"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Tags.php#L305-L309 |
5,956 | benkle-libs/feed-parser | src/Traits/WithRuleSetTrait.php | WithRuleSetTrait.getRules | public function getRules()
{
if (!isset($this->ruleSet)) {
$this->ruleSet = new PriorityList(RuleInterface::class);
}
return $this->ruleSet;
} | php | public function getRules()
{
if (!isset($this->ruleSet)) {
$this->ruleSet = new PriorityList(RuleInterface::class);
}
return $this->ruleSet;
} | [
"public",
"function",
"getRules",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"ruleSet",
")",
")",
"{",
"$",
"this",
"->",
"ruleSet",
"=",
"new",
"PriorityList",
"(",
"RuleInterface",
"::",
"class",
")",
";",
"}",
"return",
"$",
... | Get the standards rule set.
@return PriorityList | [
"Get",
"the",
"standards",
"rule",
"set",
"."
] | 8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f | https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Traits/WithRuleSetTrait.php#L35-L41 |
5,957 | glynnforrest/reform | src/Reform/Validation/Result.php | Result.getFirstErrors | public function getFirstErrors()
{
$errors = array();
foreach (array_keys($this->errors) as $name) {
$errors[$name] = current($this->errors[$name]);
}
return $errors;
} | php | public function getFirstErrors()
{
$errors = array();
foreach (array_keys($this->errors) as $name) {
$errors[$name] = current($this->errors[$name]);
}
return $errors;
} | [
"public",
"function",
"getFirstErrors",
"(",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"errors",
")",
"as",
"$",
"name",
")",
"{",
"$",
"errors",
"[",
"$",
"name",
"]",
"=",
"current... | Get the first error for each value. | [
"Get",
"the",
"first",
"error",
"for",
"each",
"value",
"."
] | a2a33dfa73933875f9c1dd0691b21e678a541a9e | https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Validation/Result.php#L86-L94 |
5,958 | vinala/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.onlyForCommandLine | public function onlyForCommandLine($onlyForCommandLine = null)
{
if (func_num_args() == 0) {
return $this->onlyForCommandLine;
}
$this->onlyForCommandLine = (bool) $onlyForCommandLine;
} | php | public function onlyForCommandLine($onlyForCommandLine = null)
{
if (func_num_args() == 0) {
return $this->onlyForCommandLine;
}
$this->onlyForCommandLine = (bool) $onlyForCommandLine;
} | [
"public",
"function",
"onlyForCommandLine",
"(",
"$",
"onlyForCommandLine",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"onlyForCommandLine",
";",
"}",
"$",
"this",
"->",
"onlyForCommandLine"... | Restrict error handling to command line calls.
@param bool|null $onlyForCommandLine
@return null|bool | [
"Restrict",
"error",
"handling",
"to",
"command",
"line",
"calls",
"."
] | 5d542d111446812e7cc5cb9fdf344e9342af5582 | https://github.com/vinala/whoops/blob/5d542d111446812e7cc5cb9fdf344e9342af5582/src/Whoops/Handler/PlainTextHandler.php#L162-L168 |
5,959 | vinala/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.outputOnlyIfCommandLine | public function outputOnlyIfCommandLine($outputOnlyIfCommandLine = null)
{
if (func_num_args() == 0) {
return $this->outputOnlyIfCommandLine;
}
$this->outputOnlyIfCommandLine = (bool) $outputOnlyIfCommandLine;
} | php | public function outputOnlyIfCommandLine($outputOnlyIfCommandLine = null)
{
if (func_num_args() == 0) {
return $this->outputOnlyIfCommandLine;
}
$this->outputOnlyIfCommandLine = (bool) $outputOnlyIfCommandLine;
} | [
"public",
"function",
"outputOnlyIfCommandLine",
"(",
"$",
"outputOnlyIfCommandLine",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"outputOnlyIfCommandLine",
";",
"}",
"$",
"this",
"->",
"outp... | Output the error message only if using command line.
else, output to logger if available.
Allow to safely add this handler to web pages.
@param bool|null $outputOnlyIfCommandLine
@return null|bool | [
"Output",
"the",
"error",
"message",
"only",
"if",
"using",
"command",
"line",
".",
"else",
"output",
"to",
"logger",
"if",
"available",
".",
"Allow",
"to",
"safely",
"add",
"this",
"handler",
"to",
"web",
"pages",
"."
] | 5d542d111446812e7cc5cb9fdf344e9342af5582 | https://github.com/vinala/whoops/blob/5d542d111446812e7cc5cb9fdf344e9342af5582/src/Whoops/Handler/PlainTextHandler.php#L177-L183 |
5,960 | vinala/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.root | protected function root()
{
if(isset($_GET['_framework_url_']))
{
$url = $_GET['_framework_url_'];
}
else return false;
$parts = explode('/', $url);
$count = count($parts)-2;
//
$path = $parts > 1 ? '../' : '';
for ($i=0; $i <$count; $i++)
{
$path .= '../';
}
\Vinala\Kernel\Foundation\Application::$path = $path;
return $path;
} | php | protected function root()
{
if(isset($_GET['_framework_url_']))
{
$url = $_GET['_framework_url_'];
}
else return false;
$parts = explode('/', $url);
$count = count($parts)-2;
//
$path = $parts > 1 ? '../' : '';
for ($i=0; $i <$count; $i++)
{
$path .= '../';
}
\Vinala\Kernel\Foundation\Application::$path = $path;
return $path;
} | [
"protected",
"function",
"root",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'_framework_url_'",
"]",
")",
")",
"{",
"$",
"url",
"=",
"$",
"_GET",
"[",
"'_framework_url_'",
"]",
";",
"}",
"else",
"return",
"false",
";",
"$",
"parts",
... | Set the app root
@param string $url
@return string | [
"Set",
"the",
"app",
"root"
] | 5d542d111446812e7cc5cb9fdf344e9342af5582 | https://github.com/vinala/whoops/blob/5d542d111446812e7cc5cb9fdf344e9342af5582/src/Whoops/Handler/PlainTextHandler.php#L413-L433 |
5,961 | Trellmor/php-framework | Application/BaseApplication.php | BaseApplication.loadConfig | protected function loadConfig() {
$app_root = Registry::getInstance()->app_root;
if (file_exists($app_root . '/Application/config.php')) {
require_once $app_root . '/Application/config.php';
}
if (file_exists($app_root . '/Application/localconfig.php')) {
require_once $app_root . '/Application/localconfig.php';
}
if (isset($config)) {
Registry::getInstance()->config = $config;
} else {
Registry::getInstance()->config = [];
}
} | php | protected function loadConfig() {
$app_root = Registry::getInstance()->app_root;
if (file_exists($app_root . '/Application/config.php')) {
require_once $app_root . '/Application/config.php';
}
if (file_exists($app_root . '/Application/localconfig.php')) {
require_once $app_root . '/Application/localconfig.php';
}
if (isset($config)) {
Registry::getInstance()->config = $config;
} else {
Registry::getInstance()->config = [];
}
} | [
"protected",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"app_root",
"=",
"Registry",
"::",
"getInstance",
"(",
")",
"->",
"app_root",
";",
"if",
"(",
"file_exists",
"(",
"$",
"app_root",
".",
"'/Application/config.php'",
")",
")",
"{",
"require_once",
"$"... | Load application config | [
"Load",
"application",
"config"
] | 5fda0dd52e0bc3ac4e0ed3b26125739904b2201e | https://github.com/Trellmor/php-framework/blob/5fda0dd52e0bc3ac4e0ed3b26125739904b2201e/Application/BaseApplication.php#L44-L59 |
5,962 | sebardo/ecommerce | EcommerceBundle/Factory/Providers/PayPalDirectPaymentProvider.php | PayPalDirectPaymentProvider.initialize | public function initialize($container, PaymentServiceProvider $psp)
{
parent::initialize($container, $psp);
if(isset($this->parameters['host'])) $this->setHost($this->parameters['host']);
if(isset($this->parameters['client_id'])) $this->setClientId($this->parameters['client_id']);
if(isset($this->parameters['secret'])) $this->setSecret($this->parameters['secret']);
if(isset($this->parameters['return_url'])) $this->setReturnUrl($this->parameters['return_url']);
if(isset($this->parameters['cancel_url'])) $this->setCancelUrl($this->parameters['cancel_url']);
return $this;
} | php | public function initialize($container, PaymentServiceProvider $psp)
{
parent::initialize($container, $psp);
if(isset($this->parameters['host'])) $this->setHost($this->parameters['host']);
if(isset($this->parameters['client_id'])) $this->setClientId($this->parameters['client_id']);
if(isset($this->parameters['secret'])) $this->setSecret($this->parameters['secret']);
if(isset($this->parameters['return_url'])) $this->setReturnUrl($this->parameters['return_url']);
if(isset($this->parameters['cancel_url'])) $this->setCancelUrl($this->parameters['cancel_url']);
return $this;
} | [
"public",
"function",
"initialize",
"(",
"$",
"container",
",",
"PaymentServiceProvider",
"$",
"psp",
")",
"{",
"parent",
"::",
"initialize",
"(",
"$",
"container",
",",
"$",
"psp",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",... | Constructor with Paypal configuration
@param string $container
@param PaymentServiceProvider $psp | [
"Constructor",
"with",
"Paypal",
"configuration"
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Factory/Providers/PayPalDirectPaymentProvider.php#L73-L83 |
5,963 | sebardo/ecommerce | EcommerceBundle/Factory/Providers/PayPalDirectPaymentProvider.php | PayPalDirectPaymentProvider.cancelation | public function cancelation(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
if( $request->get('token') != '' ){
//Search on transaction paymentDetails the $paymentId
$token = $request->get('token');
$transaction = $em->getRepository('EcommerceBundle:Transaction')->findOnPaymentDetails($token);
//UPDATE TRANSACTION
if($transaction instanceof Transaction){
$transaction->setStatus(Transaction::STATUS_CANCELLED);
$em->flush();
}
$this->container->get('session')->getFlashBag()->add(
'danger',
'transaction.cancel'
);
return $this->redirect($this->generateUrl('core_profile_index', array('transactions' => true)));
}
} | php | public function cancelation(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
if( $request->get('token') != '' ){
//Search on transaction paymentDetails the $paymentId
$token = $request->get('token');
$transaction = $em->getRepository('EcommerceBundle:Transaction')->findOnPaymentDetails($token);
//UPDATE TRANSACTION
if($transaction instanceof Transaction){
$transaction->setStatus(Transaction::STATUS_CANCELLED);
$em->flush();
}
$this->container->get('session')->getFlashBag()->add(
'danger',
'transaction.cancel'
);
return $this->redirect($this->generateUrl('core_profile_index', array('transactions' => true)));
}
} | [
"public",
"function",
"cancelation",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine'",
")",
"->",
"getManager",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"get",
"(",
"'toke... | Cancelation payment OK
@param Request $request
@return stdClass | [
"Cancelation",
"payment",
"OK"
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Factory/Providers/PayPalDirectPaymentProvider.php#L597-L618 |
5,964 | bishopb/vanilla | library/core/class.cookieidentity.php | Gdn_CookieIdentity._HashHMAC | protected static function _HashHMAC($HashMethod, $Data, $Key) {
$PackFormats = array('md5' => 'H32', 'sha1' => 'H40');
if (!isset($PackFormats[$HashMethod]))
return false;
$PackFormat = $PackFormats[$HashMethod];
// this is the equivalent of "strlen($Key) > 64":
if (isset($Key[63]))
$Key = pack($PackFormat, $HashMethod($Key));
else
$Key = str_pad($Key, 64, chr(0));
$InnerPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x36), 64));
$OuterPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x5C), 64));
return $HashMethod($OuterPad . pack($PackFormat, $HashMethod($InnerPad . $Data)));
} | php | protected static function _HashHMAC($HashMethod, $Data, $Key) {
$PackFormats = array('md5' => 'H32', 'sha1' => 'H40');
if (!isset($PackFormats[$HashMethod]))
return false;
$PackFormat = $PackFormats[$HashMethod];
// this is the equivalent of "strlen($Key) > 64":
if (isset($Key[63]))
$Key = pack($PackFormat, $HashMethod($Key));
else
$Key = str_pad($Key, 64, chr(0));
$InnerPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x36), 64));
$OuterPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x5C), 64));
return $HashMethod($OuterPad . pack($PackFormat, $HashMethod($InnerPad . $Data)));
} | [
"protected",
"static",
"function",
"_HashHMAC",
"(",
"$",
"HashMethod",
",",
"$",
"Data",
",",
"$",
"Key",
")",
"{",
"$",
"PackFormats",
"=",
"array",
"(",
"'md5'",
"=>",
"'H32'",
",",
"'sha1'",
"=>",
"'H40'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
... | Returns the provided data hashed with the specified method using the
specified key.
@param string $HashMethod The hashing method to use on $Data. Options are MD5 or SHA1.
@param string $Data The data to place in the hash.
@param string $Key The key to use when hashing the data. | [
"Returns",
"the",
"provided",
"data",
"hashed",
"with",
"the",
"specified",
"method",
"using",
"the",
"specified",
"key",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cookieidentity.php#L118-L135 |
5,965 | bishopb/vanilla | library/core/class.cookieidentity.php | Gdn_CookieIdentity.SetIdentity | public function SetIdentity($UserID, $Persist = FALSE) {
if (is_null($UserID)) {
$this->_ClearIdentity();
return;
}
$this->UserID = $UserID;
// If we're persisting, both the cookie and its payload expire in 30days
$PayloadExpires = time();
if ($Persist) {
$PayloadExpires += (86400 * self::COOKIE_PERSIST_DAYS);
$CookieExpires = $PayloadExpires;
// Otherwise the payload expires in 2 days and the cookie expires on borwser restart
} else {
// Note: $CookieExpires = 0 causes cookie to die when browser closes.
$PayloadExpires += (86400 * self::COOKIE_SESSION_DAYS);
$CookieExpires = 0;
}
// Create the cookie
$KeyData = $UserID.'-'.$PayloadExpires;
$this->_SetCookie($this->CookieName, $KeyData, array($UserID, $PayloadExpires), $CookieExpires);
$this->SetVolatileMarker($UserID);
} | php | public function SetIdentity($UserID, $Persist = FALSE) {
if (is_null($UserID)) {
$this->_ClearIdentity();
return;
}
$this->UserID = $UserID;
// If we're persisting, both the cookie and its payload expire in 30days
$PayloadExpires = time();
if ($Persist) {
$PayloadExpires += (86400 * self::COOKIE_PERSIST_DAYS);
$CookieExpires = $PayloadExpires;
// Otherwise the payload expires in 2 days and the cookie expires on borwser restart
} else {
// Note: $CookieExpires = 0 causes cookie to die when browser closes.
$PayloadExpires += (86400 * self::COOKIE_SESSION_DAYS);
$CookieExpires = 0;
}
// Create the cookie
$KeyData = $UserID.'-'.$PayloadExpires;
$this->_SetCookie($this->CookieName, $KeyData, array($UserID, $PayloadExpires), $CookieExpires);
$this->SetVolatileMarker($UserID);
} | [
"public",
"function",
"SetIdentity",
"(",
"$",
"UserID",
",",
"$",
"Persist",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"UserID",
")",
")",
"{",
"$",
"this",
"->",
"_ClearIdentity",
"(",
")",
";",
"return",
";",
"}",
"$",
"this",
"->"... | Generates the user's session cookie.
@param int $UserID The unique id assigned to the user in the database.
@param boolean $Persist Should the user's session remain persistent across visits? | [
"Generates",
"the",
"user",
"s",
"session",
"cookie",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cookieidentity.php#L143-L170 |
5,966 | bishopb/vanilla | library/core/class.cookieidentity.php | Gdn_CookieIdentity._SetCookie | protected function _SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires) {
self::SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires, $this->CookiePath, $this->CookieDomain, $this->CookieHashMethod, $this->CookieSalt);
} | php | protected function _SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires) {
self::SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires, $this->CookiePath, $this->CookieDomain, $this->CookieHashMethod, $this->CookieSalt);
} | [
"protected",
"function",
"_SetCookie",
"(",
"$",
"CookieName",
",",
"$",
"KeyData",
",",
"$",
"CookieContents",
",",
"$",
"CookieExpires",
")",
"{",
"self",
"::",
"SetCookie",
"(",
"$",
"CookieName",
",",
"$",
"KeyData",
",",
"$",
"CookieContents",
",",
"$... | Set a cookie, using path, domain, salt, and hash method from core config
@param string $CookieName Name of the cookie
@param string $KeyData
@param mixed $CookieContents
@param integer $CookieExpires
@return void | [
"Set",
"a",
"cookie",
"using",
"path",
"domain",
"salt",
"and",
"hash",
"method",
"from",
"core",
"config"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cookieidentity.php#L200-L202 |
5,967 | bishopb/vanilla | library/core/class.cookieidentity.php | Gdn_CookieIdentity.SetCookie | public static function SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires, $Path = NULL, $Domain = NULL, $CookieHashMethod = NULL, $CookieSalt = NULL) {
if (is_null($Path))
$Path = Gdn::Config('Garden.Cookie.Path', '/');
if (is_null($Domain))
$Domain = Gdn::Config('Garden.Cookie.Domain', '');
// If the domain being set is completely incompatible with the current domain then make the domain work.
$CurrentHost = Gdn::Request()->Host();
if (!StringEndsWith($CurrentHost, trim($Domain, '.')))
$Domain = '';
if (!$CookieHashMethod)
$CookieHashMethod = Gdn::Config('Garden.Cookie.HashMethod');
if (!$CookieSalt)
$CookieSalt = Gdn::Config('Garden.Cookie.Salt');
// Create the cookie signature
$KeyHash = self::_Hash($KeyData, $CookieHashMethod, $CookieSalt);
$KeyHashHash = self::_HashHMAC($CookieHashMethod, $KeyData, $KeyHash);
$Cookie = array($KeyData, $KeyHashHash, time());
// Attach cookie payload
if (!is_null($CookieContents)) {
$CookieContents = (array)$CookieContents;
$Cookie = array_merge($Cookie, $CookieContents);
}
$CookieContents = implode('|',$Cookie);
// Create the cookie.
setcookie($CookieName, $CookieContents, $CookieExpires, $Path, $Domain, NULL, TRUE);
$_COOKIE[$CookieName] = $CookieContents;
} | php | public static function SetCookie($CookieName, $KeyData, $CookieContents, $CookieExpires, $Path = NULL, $Domain = NULL, $CookieHashMethod = NULL, $CookieSalt = NULL) {
if (is_null($Path))
$Path = Gdn::Config('Garden.Cookie.Path', '/');
if (is_null($Domain))
$Domain = Gdn::Config('Garden.Cookie.Domain', '');
// If the domain being set is completely incompatible with the current domain then make the domain work.
$CurrentHost = Gdn::Request()->Host();
if (!StringEndsWith($CurrentHost, trim($Domain, '.')))
$Domain = '';
if (!$CookieHashMethod)
$CookieHashMethod = Gdn::Config('Garden.Cookie.HashMethod');
if (!$CookieSalt)
$CookieSalt = Gdn::Config('Garden.Cookie.Salt');
// Create the cookie signature
$KeyHash = self::_Hash($KeyData, $CookieHashMethod, $CookieSalt);
$KeyHashHash = self::_HashHMAC($CookieHashMethod, $KeyData, $KeyHash);
$Cookie = array($KeyData, $KeyHashHash, time());
// Attach cookie payload
if (!is_null($CookieContents)) {
$CookieContents = (array)$CookieContents;
$Cookie = array_merge($Cookie, $CookieContents);
}
$CookieContents = implode('|',$Cookie);
// Create the cookie.
setcookie($CookieName, $CookieContents, $CookieExpires, $Path, $Domain, NULL, TRUE);
$_COOKIE[$CookieName] = $CookieContents;
} | [
"public",
"static",
"function",
"SetCookie",
"(",
"$",
"CookieName",
",",
"$",
"KeyData",
",",
"$",
"CookieContents",
",",
"$",
"CookieExpires",
",",
"$",
"Path",
"=",
"NULL",
",",
"$",
"Domain",
"=",
"NULL",
",",
"$",
"CookieHashMethod",
"=",
"NULL",
",... | Set a cookie, using specified path, domain, salt and hash method
@param string $CookieName Name of the cookie
@param string $KeyData
@param mixed $CookieContents
@param integer $CookieExpires
@param string $Path Optional. Cookie path (auto load from config)
@param string $Domain Optional. Cookie domain (auto load from config)
@param string $CookieHashMethod Optional. Cookie hash method (auto load from config)
@param string $CookieSalt Optional. Cookie salt (auto load from config)
@return void | [
"Set",
"a",
"cookie",
"using",
"specified",
"path",
"domain",
"salt",
"and",
"hash",
"method"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cookieidentity.php#L217-L252 |
5,968 | lucidphp/mux-cache | src/CacheLoader.php | CacheLoader.isValid | private function isValid($forceValidate)
{
if ($this->storage->exists() && $this->resources->isValid($this->storage->getLastWriteTime())) {
return ($forceValidate || $this->isDebugging()) ? $this->validateManifest() : true;
}
return false;
} | php | private function isValid($forceValidate)
{
if ($this->storage->exists() && $this->resources->isValid($this->storage->getLastWriteTime())) {
return ($forceValidate || $this->isDebugging()) ? $this->validateManifest() : true;
}
return false;
} | [
"private",
"function",
"isValid",
"(",
"$",
"forceValidate",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"storage",
"->",
"exists",
"(",
")",
"&&",
"$",
"this",
"->",
"resources",
"->",
"isValid",
"(",
"$",
"this",
"->",
"storage",
"->",
"getLastWriteTime",
... | Checks if the cache is valid.
@param bool $forceValidate;
@return bool | [
"Checks",
"if",
"the",
"cache",
"is",
"valid",
"."
] | 5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43 | https://github.com/lucidphp/mux-cache/blob/5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43/src/CacheLoader.php#L82-L89 |
5,969 | lucidphp/mux-cache | src/CacheLoader.php | CacheLoader.load | public function load(RouteLoaderInterface $loader, $forceValidate = false)
{
if (!$this->isValid($forceValidate)) {
$loader->addListener($this);
$this->doLoadResources($loader, $forceValidate);
$loader->removeListener($this);
}
return $this->storage->read();
} | php | public function load(RouteLoaderInterface $loader, $forceValidate = false)
{
if (!$this->isValid($forceValidate)) {
$loader->addListener($this);
$this->doLoadResources($loader, $forceValidate);
$loader->removeListener($this);
}
return $this->storage->read();
} | [
"public",
"function",
"load",
"(",
"RouteLoaderInterface",
"$",
"loader",
",",
"$",
"forceValidate",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
"$",
"forceValidate",
")",
")",
"{",
"$",
"loader",
"->",
"addListener",
"(",
... | Loads the routes into a collection.
Loads the resources from cache if the cache is still valid, or re-loads
and re-creates the cache if neccessary.
@return RouteCollectionInterface | [
"Loads",
"the",
"routes",
"into",
"a",
"collection",
"."
] | 5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43 | https://github.com/lucidphp/mux-cache/blob/5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43/src/CacheLoader.php#L99-L108 |
5,970 | lucidphp/mux-cache | src/CacheLoader.php | CacheLoader.onLoaded | public function onLoaded(ResourceInterface $resource)
{
if (!$this->isDebugging() || $this->current === $resource) {
return;
}
$this->ensureCollector($this->current);
$this->meta[$this->current]->addResource($resource);
} | php | public function onLoaded(ResourceInterface $resource)
{
if (!$this->isDebugging() || $this->current === $resource) {
return;
}
$this->ensureCollector($this->current);
$this->meta[$this->current]->addResource($resource);
} | [
"public",
"function",
"onLoaded",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isDebugging",
"(",
")",
"||",
"$",
"this",
"->",
"current",
"===",
"$",
"resource",
")",
"{",
"return",
";",
"}",
"$",
"this",
... | Loading callback.
Collects files that've been included during the loading process of the
main resource files.
@param string $resource
@return void | [
"Loading",
"callback",
"."
] | 5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43 | https://github.com/lucidphp/mux-cache/blob/5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43/src/CacheLoader.php#L120-L128 |
5,971 | lucidphp/mux-cache | src/CacheLoader.php | CacheLoader.setResources | private function setResources($resources)
{
if (!$resources instanceof ResourcesInterface) {
$files = (array)$resources;
$resources = new Resources;
array_walk($files, [$resources, 'addFileResource']);
}
$this->resources = $resources;
} | php | private function setResources($resources)
{
if (!$resources instanceof ResourcesInterface) {
$files = (array)$resources;
$resources = new Resources;
array_walk($files, [$resources, 'addFileResource']);
}
$this->resources = $resources;
} | [
"private",
"function",
"setResources",
"(",
"$",
"resources",
")",
"{",
"if",
"(",
"!",
"$",
"resources",
"instanceof",
"ResourcesInterface",
")",
"{",
"$",
"files",
"=",
"(",
"array",
")",
"$",
"resources",
";",
"$",
"resources",
"=",
"new",
"Resources",
... | Set the main resource files.
@param string|array|ResourcesInterface $resources
@return void | [
"Set",
"the",
"main",
"resource",
"files",
"."
] | 5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43 | https://github.com/lucidphp/mux-cache/blob/5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43/src/CacheLoader.php#L147-L157 |
5,972 | lucidphp/mux-cache | src/CacheLoader.php | CacheLoader.doLoadResources | private function doLoadResources(RouteLoaderInterface $loader, $forceValidate)
{
$collection = [];
foreach ($this->resources->all() as $i => $resource) {
// dont't add the prmary resource to
$this->current = (string)$resource;
if ($loaded = $loader->loadRoutes($resource)) {
$collection[] = $loaded->all();
}
}
$routes = call_user_func_array('array_merge', $collection);
if ($this->isDebugging() || $forceValidate) {
$this->writeManifests();
}
$this->current = null;
$this->storage->write(new Routes($routes));
} | php | private function doLoadResources(RouteLoaderInterface $loader, $forceValidate)
{
$collection = [];
foreach ($this->resources->all() as $i => $resource) {
// dont't add the prmary resource to
$this->current = (string)$resource;
if ($loaded = $loader->loadRoutes($resource)) {
$collection[] = $loaded->all();
}
}
$routes = call_user_func_array('array_merge', $collection);
if ($this->isDebugging() || $forceValidate) {
$this->writeManifests();
}
$this->current = null;
$this->storage->write(new Routes($routes));
} | [
"private",
"function",
"doLoadResources",
"(",
"RouteLoaderInterface",
"$",
"loader",
",",
"$",
"forceValidate",
")",
"{",
"$",
"collection",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"resources",
"->",
"all",
"(",
")",
"as",
"$",
"i",
"=>",... | Loads the main resources and caches the results.
If debuggin, all included resources will be put into a manifest file to
keep track of their changes.
@return void | [
"Loads",
"the",
"main",
"resources",
"and",
"caches",
"the",
"results",
"."
] | 5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43 | https://github.com/lucidphp/mux-cache/blob/5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43/src/CacheLoader.php#L167-L188 |
5,973 | rozaverta/cmf | core/Route/Url.php | Url.makeContextUrl | public function makeContextUrl( Context $context, $path = '', array $query = [] ): string
{
if( $context->isHost() )
{
$url = $context->isSsl() ? "https://" : "http://";
$url .= $context->getHost();
$port = $context->getPort();
if( $port > 0 && $port !== 80 )
{
$url .= ":" . $port;
}
$url .= $this->isBasePrefix() ? $this->base_prefix : "/";
}
else
{
$url = $this->getPrefix();
}
if( $context->isQuery() )
{
foreach($context->getQuery() as $name => $value)
{
if( is_array($value) )
{
if( ! isset($query[$name]) || ! in_array($query[$name], $value) )
{
$query[$name] = current($value);
}
}
else
{
$query[$name] = $value;
}
}
}
if( is_array($path) )
{
$path = implode("/", $path);
}
else if( strlen($path) && $path[0] === "/" )
{
$path = substr($path, 1);
}
if( $context->isPath() )
{
$path = trim($context->getPath(), "/") . "/" . $path;
}
return $this->getModeUrl($url, $path, $query);
} | php | public function makeContextUrl( Context $context, $path = '', array $query = [] ): string
{
if( $context->isHost() )
{
$url = $context->isSsl() ? "https://" : "http://";
$url .= $context->getHost();
$port = $context->getPort();
if( $port > 0 && $port !== 80 )
{
$url .= ":" . $port;
}
$url .= $this->isBasePrefix() ? $this->base_prefix : "/";
}
else
{
$url = $this->getPrefix();
}
if( $context->isQuery() )
{
foreach($context->getQuery() as $name => $value)
{
if( is_array($value) )
{
if( ! isset($query[$name]) || ! in_array($query[$name], $value) )
{
$query[$name] = current($value);
}
}
else
{
$query[$name] = $value;
}
}
}
if( is_array($path) )
{
$path = implode("/", $path);
}
else if( strlen($path) && $path[0] === "/" )
{
$path = substr($path, 1);
}
if( $context->isPath() )
{
$path = trim($context->getPath(), "/") . "/" . $path;
}
return $this->getModeUrl($url, $path, $query);
} | [
"public",
"function",
"makeContextUrl",
"(",
"Context",
"$",
"context",
",",
"$",
"path",
"=",
"''",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
":",
"string",
"{",
"if",
"(",
"$",
"context",
"->",
"isHost",
"(",
")",
")",
"{",
"$",
"url",
"=... | Get full url scheme string
@param Context $context
@param string $path
@param array $query
@return string | [
"Get",
"full",
"url",
"scheme",
"string"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Route/Url.php#L507-L558 |
5,974 | rozaverta/cmf | core/Route/Url.php | Url.makeUrl | public function makeUrl( $path = '', array $query = [], bool $context = false, bool $full = null ): string
{
if( is_null($full) )
{
$url = $this->base;
}
else if( $full )
{
$url = $this->getPrefix();
}
else
{
$url = $this->isBasePrefix() ? $this->base_prefix : "/";
}
if( is_array($path) )
{
$path = implode('/', $path);
}
else if( strlen($path) && $path[0] === "/" )
{
$path = substr($path, 1);
}
if( $context && $this->isContext() )
{
if( strlen($path) )
{
$path = substr($this->context, 1) . $path;
}
else
{
$path = trim($this->context, "/");
}
}
return $this->getModeUrl($url, $path, $query);
} | php | public function makeUrl( $path = '', array $query = [], bool $context = false, bool $full = null ): string
{
if( is_null($full) )
{
$url = $this->base;
}
else if( $full )
{
$url = $this->getPrefix();
}
else
{
$url = $this->isBasePrefix() ? $this->base_prefix : "/";
}
if( is_array($path) )
{
$path = implode('/', $path);
}
else if( strlen($path) && $path[0] === "/" )
{
$path = substr($path, 1);
}
if( $context && $this->isContext() )
{
if( strlen($path) )
{
$path = substr($this->context, 1) . $path;
}
else
{
$path = trim($this->context, "/");
}
}
return $this->getModeUrl($url, $path, $query);
} | [
"public",
"function",
"makeUrl",
"(",
"$",
"path",
"=",
"''",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"bool",
"$",
"context",
"=",
"false",
",",
"bool",
"$",
"full",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"is_null",
"(",
"$",
... | Get url string
@param string $path
@param array $query
@param bool $context
@param bool|null $full
@return string | [
"Get",
"url",
"string"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Route/Url.php#L569-L606 |
5,975 | phootwork/json | src/Json.php | Json.decode | public static function decode($json, $options = 0, $depth = 512) {
$data = json_decode($json, true, $depth, $options);
self::throwExceptionOnError($data);
return $data;
} | php | public static function decode($json, $options = 0, $depth = 512) {
$data = json_decode($json, true, $depth, $options);
self::throwExceptionOnError($data);
return $data;
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"json",
",",
"$",
"options",
"=",
"0",
",",
"$",
"depth",
"=",
"512",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
",",
"$",
"depth",
",",
"$",
"options",
")",
";",
... | Decodes a JSON string to an array.
@param string $json The json string being decoded. This only works with UTF-8 encoded strings.
@param int $options Bitmask of JSON decode options. Currently only OBJECT_AS_ARRAY, BIGINT_AS_STRING is supported (default is to cast large integers as floats)
@param int $depth User specified recursion depth.
@throws JsonException if something gone wrong
@return array Returns the value encoded in json in appropriate PHP type. Values true, false and null are returned as TRUE, FALSE and NULL respectively. | [
"Decodes",
"a",
"JSON",
"string",
"to",
"an",
"array",
"."
] | fc568d82aa83d607fadd840bdca4e7cf025d9388 | https://github.com/phootwork/json/blob/fc568d82aa83d607fadd840bdca4e7cf025d9388/src/Json.php#L223-L228 |
5,976 | indigophp-archive/pdf | src/Indigo/Pdf/Adapter/AbstractAdapter.php | AbstractAdapter.resolvePageOptions | protected function resolvePageOptions(array $options = array())
{
$resolver = new OptionsResolver;
$this->setDefaultPageOptions($resolver);
if (!empty($this->pageOptions)) {
$resolver->setDefaults($this->pageOptions);
}
return $resolver->resolve($options);
} | php | protected function resolvePageOptions(array $options = array())
{
$resolver = new OptionsResolver;
$this->setDefaultPageOptions($resolver);
if (!empty($this->pageOptions)) {
$resolver->setDefaults($this->pageOptions);
}
return $resolver->resolve($options);
} | [
"protected",
"function",
"resolvePageOptions",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
";",
"$",
"this",
"->",
"setDefaultPageOptions",
"(",
"$",
"resolver",
")",
";",
"if",
"(",
"!",
... | Resolve page options
@param array $options
@return Options | [
"Resolve",
"page",
"options"
] | 060dcccbcd33066d012bc3d5c8300a5310e87a7a | https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/AbstractAdapter.php#L136-L146 |
5,977 | edunola13/core-modules | src/Cache/CacheDataBase.php | CacheDataBase.setConnection | public function setConnection($nameDB, $table){
$this->nameDB= $nameDB;
$this->table= $table;
$this->connection= $this->connection->changeConnection($nameDB);
} | php | public function setConnection($nameDB, $table){
$this->nameDB= $nameDB;
$this->table= $table;
$this->connection= $this->connection->changeConnection($nameDB);
} | [
"public",
"function",
"setConnection",
"(",
"$",
"nameDB",
",",
"$",
"table",
")",
"{",
"$",
"this",
"->",
"nameDB",
"=",
"$",
"nameDB",
";",
"$",
"this",
"->",
"table",
"=",
"$",
"table",
";",
"$",
"this",
"->",
"connection",
"=",
"$",
"this",
"->... | Setea la conexion a la base de datos en base a la definicion seleccionada y la tabla indicada
@param string $nameDB
@param string $table | [
"Setea",
"la",
"conexion",
"a",
"la",
"base",
"de",
"datos",
"en",
"base",
"a",
"la",
"definicion",
"seleccionada",
"y",
"la",
"tabla",
"indicada"
] | 2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364 | https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/Cache/CacheDataBase.php#L35-L39 |
5,978 | fab2s/ContextException | src/ContextException.php | ContextException.mergeContext | public function mergeContext(array $moreContext)
{
$this->context = array_replace_recursive(isset($this->context) ? $this->context : [], $moreContext);
return $this;
} | php | public function mergeContext(array $moreContext)
{
$this->context = array_replace_recursive(isset($this->context) ? $this->context : [], $moreContext);
return $this;
} | [
"public",
"function",
"mergeContext",
"(",
"array",
"$",
"moreContext",
")",
"{",
"$",
"this",
"->",
"context",
"=",
"array_replace_recursive",
"(",
"isset",
"(",
"$",
"this",
"->",
"context",
")",
"?",
"$",
"this",
"->",
"context",
":",
"[",
"]",
",",
... | Merge more context to current context
@param array $moreContext The context to merge to the (eventually) existing one
@return $this | [
"Merge",
"more",
"context",
"to",
"current",
"context"
] | a835ffd87e798c1e5f47853b23ff9c75e28fa0a9 | https://github.com/fab2s/ContextException/blob/a835ffd87e798c1e5f47853b23ff9c75e28fa0a9/src/ContextException.php#L68-L73 |
5,979 | sellerlabs/nucleus | src/SellerLabs/Nucleus/Meditation/SpecGraphFactory.php | SpecGraphFactory.done | public function done()
{
$graph = clone $this->graph;
foreach ($this->nodeFactories as $factory) {
if (!$factory->isValid()) {
throw new LackOfCoffeeException(
vsprintf(
'Definition for the node "%s" is invalid.',
[$factory->getName()]
)
);
}
$graph->add(
$factory->getName(),
$factory->getDependencies(),
$factory->getSpec()
);
}
return $graph;
} | php | public function done()
{
$graph = clone $this->graph;
foreach ($this->nodeFactories as $factory) {
if (!$factory->isValid()) {
throw new LackOfCoffeeException(
vsprintf(
'Definition for the node "%s" is invalid.',
[$factory->getName()]
)
);
}
$graph->add(
$factory->getName(),
$factory->getDependencies(),
$factory->getSpec()
);
}
return $graph;
} | [
"public",
"function",
"done",
"(",
")",
"{",
"$",
"graph",
"=",
"clone",
"$",
"this",
"->",
"graph",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodeFactories",
"as",
"$",
"factory",
")",
"{",
"if",
"(",
"!",
"$",
"factory",
"->",
"isValid",
"(",
")",... | Return the finished SpecGraph.
@throws LackOfCoffeeException
@return SpecGraph | [
"Return",
"the",
"finished",
"SpecGraph",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Meditation/SpecGraphFactory.php#L97-L119 |
5,980 | lukaszmakuch/haringo | src/BuildingStrategy/Impl/FactoryProductBuildingStrategyTpl.php | FactoryProductBuildingStrategyTpl.findFactoryMethod | protected function findFactoryMethod(
ReflectionClass $reflectedFactoryClass,
MethodSelector $factoryMethodSelector
) {
$allMatchingMethods = $this->findMatchingMethods(
$reflectedFactoryClass,
$factoryMethodSelector
);
$this->throwExceptionIfWrongNumberOfFactoryMethods($allMatchingMethods);
return $allMatchingMethods[0];
} | php | protected function findFactoryMethod(
ReflectionClass $reflectedFactoryClass,
MethodSelector $factoryMethodSelector
) {
$allMatchingMethods = $this->findMatchingMethods(
$reflectedFactoryClass,
$factoryMethodSelector
);
$this->throwExceptionIfWrongNumberOfFactoryMethods($allMatchingMethods);
return $allMatchingMethods[0];
} | [
"protected",
"function",
"findFactoryMethod",
"(",
"ReflectionClass",
"$",
"reflectedFactoryClass",
",",
"MethodSelector",
"$",
"factoryMethodSelector",
")",
"{",
"$",
"allMatchingMethods",
"=",
"$",
"this",
"->",
"findMatchingMethods",
"(",
"$",
"reflectedFactoryClass",
... | Gets the factory method. The selector must pick exactly 1 object.
@param ReflectionClass $reflectedFactoryClass
@param MethodSelector $factoryMethodSelector
@return ReflectionMethod | [
"Gets",
"the",
"factory",
"method",
".",
"The",
"selector",
"must",
"pick",
"exactly",
"1",
"object",
"."
] | 7a2ff30f4e7b215b2573a9562ed449f6495d303d | https://github.com/lukaszmakuch/haringo/blob/7a2ff30f4e7b215b2573a9562ed449f6495d303d/src/BuildingStrategy/Impl/FactoryProductBuildingStrategyTpl.php#L30-L40 |
5,981 | easy-system/es-services | src/ServiceLocator.php | ServiceLocator.set | public function set($name, $service)
{
if (isset($this->registry[$name])) {
unset($this->registry[$name]);
}
if (isset($this->instances[$name])) {
unset($this->instances[$name]);
}
if (null === $service) {
return $this;
}
if (! is_string($service)) {
$this->instances[$name] = $service;
return $this;
}
$this->registry[$name] = $service;
return $this;
} | php | public function set($name, $service)
{
if (isset($this->registry[$name])) {
unset($this->registry[$name]);
}
if (isset($this->instances[$name])) {
unset($this->instances[$name]);
}
if (null === $service) {
return $this;
}
if (! is_string($service)) {
$this->instances[$name] = $service;
return $this;
}
$this->registry[$name] = $service;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"service",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"name",
"]",
")",... | Sets the service.
@param string $name The service name
@param mixed $service The service specification or instance of a
service or null. If the service set as null, it
will be removed.
@return self | [
"Sets",
"the",
"service",
"."
] | c68dfa8c7811117d3da5d25857c7856ec4a23c5f | https://github.com/easy-system/es-services/blob/c68dfa8c7811117d3da5d25857c7856ec4a23c5f/src/ServiceLocator.php#L111-L130 |
5,982 | easy-system/es-services | src/ServiceLocator.php | ServiceLocator.get | public function get($name)
{
if (isset($this->instances[$name])) {
return $this->instances[$name];
}
if (! isset($this->registry[$name])) {
$exceptionClass = static::NOT_FOUND_EXCEPTION;
throw new $exceptionClass(
sprintf(static::NOT_FOUND_MESSAGE, $name)
);
}
try {
$this->instances[$name] = $this->build($this->registry[$name], $name);
} catch (Exception $e) {
throw new RuntimeException(
sprintf(static::BUILD_FAILURE_MESSAGE, $name),
null,
$e
);
}
return $this->instances[$name];
} | php | public function get($name)
{
if (isset($this->instances[$name])) {
return $this->instances[$name];
}
if (! isset($this->registry[$name])) {
$exceptionClass = static::NOT_FOUND_EXCEPTION;
throw new $exceptionClass(
sprintf(static::NOT_FOUND_MESSAGE, $name)
);
}
try {
$this->instances[$name] = $this->build($this->registry[$name], $name);
} catch (Exception $e) {
throw new RuntimeException(
sprintf(static::BUILD_FAILURE_MESSAGE, $name),
null,
$e
);
}
return $this->instances[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"!",
... | Gets the service.
@param string $name The service name
@throws Exception\ServiceNotFoundException If the specified service not fount
@throws \RunimeException If failled build a service
@return mixed The requested service | [
"Gets",
"the",
"service",
"."
] | c68dfa8c7811117d3da5d25857c7856ec4a23c5f | https://github.com/easy-system/es-services/blob/c68dfa8c7811117d3da5d25857c7856ec4a23c5f/src/ServiceLocator.php#L158-L180 |
5,983 | easy-system/es-services | src/ServiceLocator.php | ServiceLocator.build | public function build($classNameOrSpecification, $serviceName = '')
{
/*
* Builds uses static factory method
*/
if (false !== strpos($classNameOrSpecification, '::')) {
$specification = explode('::', $classNameOrSpecification);
$className = $specification[0];
$factoryMethod = $specification[1];
if (! class_exists($className, true)) {
throw new RuntimeException(
sprintf(
'Factory "%s" not found.',
$className
)
);
}
if (! is_callable([$className, $factoryMethod])) {
throw new RuntimeException(
sprintf(
'Factory method "%s" of class "%s" is not callable.',
$factoryMethod,
$className
)
);
}
if (count($specification) > 2) {
/*
* The special case of factory specification.
* Abstract Factory takes the service name as an argument.
*
* Abstract factory method specification
* as 'FactoryClassName::methodName::'
*/
$instance = call_user_func(
[$className, $factoryMethod],
(string) $serviceName
);
} else {
/*
* Calls the factory method.
*
* Factory method specification
* as 'FactoryClassName::methodName'
*/
$instance = call_user_func([$className, $factoryMethod]);
}
/*
* Builds uses "new" operator
*/
} else {
$className = $classNameOrSpecification;
if (! class_exists($className, true)) {
throw new RuntimeException(
sprintf(
'Class "%s" not found.',
$className
)
);
}
$instance = new $className();
}
return $instance;
} | php | public function build($classNameOrSpecification, $serviceName = '')
{
/*
* Builds uses static factory method
*/
if (false !== strpos($classNameOrSpecification, '::')) {
$specification = explode('::', $classNameOrSpecification);
$className = $specification[0];
$factoryMethod = $specification[1];
if (! class_exists($className, true)) {
throw new RuntimeException(
sprintf(
'Factory "%s" not found.',
$className
)
);
}
if (! is_callable([$className, $factoryMethod])) {
throw new RuntimeException(
sprintf(
'Factory method "%s" of class "%s" is not callable.',
$factoryMethod,
$className
)
);
}
if (count($specification) > 2) {
/*
* The special case of factory specification.
* Abstract Factory takes the service name as an argument.
*
* Abstract factory method specification
* as 'FactoryClassName::methodName::'
*/
$instance = call_user_func(
[$className, $factoryMethod],
(string) $serviceName
);
} else {
/*
* Calls the factory method.
*
* Factory method specification
* as 'FactoryClassName::methodName'
*/
$instance = call_user_func([$className, $factoryMethod]);
}
/*
* Builds uses "new" operator
*/
} else {
$className = $classNameOrSpecification;
if (! class_exists($className, true)) {
throw new RuntimeException(
sprintf(
'Class "%s" not found.',
$className
)
);
}
$instance = new $className();
}
return $instance;
} | [
"public",
"function",
"build",
"(",
"$",
"classNameOrSpecification",
",",
"$",
"serviceName",
"=",
"''",
")",
"{",
"/*\n * Builds uses static factory method\n */",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"classNameOrSpecification",
",",
"'::'",
... | Builds an object.
@param string $classNameOrSpecification The class of service or the
service specification
@param string $serviceName Optional; a abstract factory
takes the service name as an
argument
@throws \RuntimeException If unable build an object
@return object New object | [
"Builds",
"an",
"object",
"."
] | c68dfa8c7811117d3da5d25857c7856ec4a23c5f | https://github.com/easy-system/es-services/blob/c68dfa8c7811117d3da5d25857c7856ec4a23c5f/src/ServiceLocator.php#L195-L260 |
5,984 | xpl-php/Common | src/Storage/Bin.php | Bin.set | public function set($key, $value) {
if (null === $key) {
$this->_data[] = $value;
} else {
$this->_data[$key] = $value;
}
} | php | public function set($key, $value) {
if (null === $key) {
$this->_data[] = $value;
} else {
$this->_data[$key] = $value;
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
... | Set an item value by key.
Accepts null as a key (item key will be an index).
@param string|null $key
@param mixed $value | [
"Set",
"an",
"item",
"value",
"by",
"key",
"."
] | 0669bdcca29f1f8835297c2397c62fee3be5dce3 | https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Bin.php#L24-L30 |
5,985 | Danzabar/masquerade | src/Data/ClassExtraction.php | ClassExtraction.extract | public function extract()
{
$method = NULL;
$name = explode(',', $this->match['raw']);
// Get the method
if(strpos($name[0], '.'))
{
$parts = explode('.', $name[0]);
$method = str_replace(array('[', ']'), '', $parts[1]);
} elseif(isset($this->match['params']['method']))
{
$method = $this->match['params']['method'];
unset($this->match['params']['method']);
}
if(!is_null($method))
{
return $this->fireMethod($method);
}
throw new InvalidClassMethodCalled($method, $this->match['raw']);
} | php | public function extract()
{
$method = NULL;
$name = explode(',', $this->match['raw']);
// Get the method
if(strpos($name[0], '.'))
{
$parts = explode('.', $name[0]);
$method = str_replace(array('[', ']'), '', $parts[1]);
} elseif(isset($this->match['params']['method']))
{
$method = $this->match['params']['method'];
unset($this->match['params']['method']);
}
if(!is_null($method))
{
return $this->fireMethod($method);
}
throw new InvalidClassMethodCalled($method, $this->match['raw']);
} | [
"public",
"function",
"extract",
"(",
")",
"{",
"$",
"method",
"=",
"NULL",
";",
"$",
"name",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"match",
"[",
"'raw'",
"]",
")",
";",
"// Get the method",
"if",
"(",
"strpos",
"(",
"$",
"name",
"[",... | Returns the mask value based on mask and params;
@return String
@author Dan Cox | [
"Returns",
"the",
"mask",
"value",
"based",
"on",
"mask",
"and",
"params",
";"
] | f2db0b23a6765031a59fa41c7c0109a288815396 | https://github.com/Danzabar/masquerade/blob/f2db0b23a6765031a59fa41c7c0109a288815396/src/Data/ClassExtraction.php#L46-L70 |
5,986 | Danzabar/masquerade | src/Data/ClassExtraction.php | ClassExtraction.fireMethod | public function fireMethod($methodName)
{
if($this->reflection->hasMethod($methodName))
{
$method = $this->reflection->getMethod($methodName);
$instance = $this->reflection->newInstance();
return $method->invokeArgs($instance, $this->match['params']);
}
throw new InvalidClassMethodCalled($methodName, $this->match['raw']);
} | php | public function fireMethod($methodName)
{
if($this->reflection->hasMethod($methodName))
{
$method = $this->reflection->getMethod($methodName);
$instance = $this->reflection->newInstance();
return $method->invokeArgs($instance, $this->match['params']);
}
throw new InvalidClassMethodCalled($methodName, $this->match['raw']);
} | [
"public",
"function",
"fireMethod",
"(",
"$",
"methodName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reflection",
"->",
"hasMethod",
"(",
"$",
"methodName",
")",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"reflection",
"->",
"getMethod",
"(",
"$"... | Fires the chosen method of the class
@return String
@author Dan Cox | [
"Fires",
"the",
"chosen",
"method",
"of",
"the",
"class"
] | f2db0b23a6765031a59fa41c7c0109a288815396 | https://github.com/Danzabar/masquerade/blob/f2db0b23a6765031a59fa41c7c0109a288815396/src/Data/ClassExtraction.php#L78-L88 |
5,987 | FiveLab/Resource | src/Resource/Error/ErrorPresentationFactory.php | ErrorPresentationFactory.create | public static function create(
int $statusCode,
string $message,
$reason = null,
string $path = null,
array $attributes = [],
$identifier = null
): PresentationInterface {
$error = new ErrorResource($message, $reason, $path, $attributes, $identifier);
return PresentationFactory::create($statusCode, $error);
} | php | public static function create(
int $statusCode,
string $message,
$reason = null,
string $path = null,
array $attributes = [],
$identifier = null
): PresentationInterface {
$error = new ErrorResource($message, $reason, $path, $attributes, $identifier);
return PresentationFactory::create($statusCode, $error);
} | [
"public",
"static",
"function",
"create",
"(",
"int",
"$",
"statusCode",
",",
"string",
"$",
"message",
",",
"$",
"reason",
"=",
"null",
",",
"string",
"$",
"path",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"identifier",
... | Create default error presentation.
@param int $statusCode
@param string $message
@param string|null $reason
@param string|null $path
@param array $attributes
@param string|int $identifier
@return PresentationInterface | [
"Create",
"default",
"error",
"presentation",
"."
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Resource/Error/ErrorPresentationFactory.php#L38-L49 |
5,988 | FiveLab/Resource | src/Resource/Error/ErrorPresentationFactory.php | ErrorPresentationFactory.badRequest | public static function badRequest(
string $message,
$reason = null,
string $path = null,
array $attributes = [],
$identifier = null
): PresentationInterface {
$error = new ErrorResource($message, $reason, $path, $attributes, $identifier);
return PresentationFactory::badRequest($error);
} | php | public static function badRequest(
string $message,
$reason = null,
string $path = null,
array $attributes = [],
$identifier = null
): PresentationInterface {
$error = new ErrorResource($message, $reason, $path, $attributes, $identifier);
return PresentationFactory::badRequest($error);
} | [
"public",
"static",
"function",
"badRequest",
"(",
"string",
"$",
"message",
",",
"$",
"reason",
"=",
"null",
",",
"string",
"$",
"path",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"identifier",
"=",
"null",
")",
":",
"Pre... | Create the bad request error presentation.
@param string $message
@param string $reason
@param string $path
@param array $attributes
@param string|int $identifier
@return PresentationInterface | [
"Create",
"the",
"bad",
"request",
"error",
"presentation",
"."
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Resource/Error/ErrorPresentationFactory.php#L62-L72 |
5,989 | rozaverta/cmf | core/Module/ModuleHelper.php | ModuleHelper.toNameStrict | public static function toNameStrict( string $name )
{
$len = strlen($name);
if( $len < 1 || $len > 50 )
{
return false;
}
$name = str_replace("-", "_", $name);
if(strpos($name, "__") !== false || $name[0] === "_" || $len > 1 && $name[$len-1] === "_")
{
return false;
}
if( strpos($name, "_") !== false || ! ctype_upper($name[0]) )
{
$name = self::toName($name);
}
if( is_numeric($name[0]) || preg_match('/[^a-zA-Z0-9]/', $name ) )
{
return false;
}
return $name;
} | php | public static function toNameStrict( string $name )
{
$len = strlen($name);
if( $len < 1 || $len > 50 )
{
return false;
}
$name = str_replace("-", "_", $name);
if(strpos($name, "__") !== false || $name[0] === "_" || $len > 1 && $name[$len-1] === "_")
{
return false;
}
if( strpos($name, "_") !== false || ! ctype_upper($name[0]) )
{
$name = self::toName($name);
}
if( is_numeric($name[0]) || preg_match('/[^a-zA-Z0-9]/', $name ) )
{
return false;
}
return $name;
} | [
"public",
"static",
"function",
"toNameStrict",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"len",
"<",
"1",
"||",
"$",
"len",
">",
"50",
")",
"{",
"return",
"false",
";",
"}",
"$... | Format and validate module name
@param string $name
@return bool|string | [
"Format",
"and",
"validate",
"module",
"name"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Module/ModuleHelper.php#L28-L53 |
5,990 | rozaverta/cmf | core/Module/ModuleHelper.php | ModuleHelper.hasInstall | public static function hasInstall( string $name, bool $result_id = false ): bool
{
if( $name === "@core" )
{
return Helper::isSystemInstall(true) ? ($result_id ? 0 : true) : false;
}
try {
$row = self::getModuleScheme($name, false, ["id", "install"]);
}
catch(NotFoundException $e) {
return false;
}
if( $row->install < 1 )
{
return false;
}
return $result_id ? (int) $row->id : true;
} | php | public static function hasInstall( string $name, bool $result_id = false ): bool
{
if( $name === "@core" )
{
return Helper::isSystemInstall(true) ? ($result_id ? 0 : true) : false;
}
try {
$row = self::getModuleScheme($name, false, ["id", "install"]);
}
catch(NotFoundException $e) {
return false;
}
if( $row->install < 1 )
{
return false;
}
return $result_id ? (int) $row->id : true;
} | [
"public",
"static",
"function",
"hasInstall",
"(",
"string",
"$",
"name",
",",
"bool",
"$",
"result_id",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"name",
"===",
"\"@core\"",
")",
"{",
"return",
"Helper",
"::",
"isSystemInstall",
"(",
"true",
... | Has module install
@param string $name
@param bool $result_id
@return bool | [
"Has",
"module",
"install"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Module/ModuleHelper.php#L84-L104 |
5,991 | 0x20h/phloppy | src/Job.php | Job.create | public static function create(array $args)
{
$job = new Job($args['body']);
if (isset($args['id'])) {
$job->setId($args['id']);
$job->setTtl(hexdec(substr($job->getId(), -4)));
}
if (isset($args['queue'])) {
$job->setQueue($args['queue']);
}
if (isset($args['ttl'])) {
$job->setTtl($args['ttl']);
}
if (isset($args['retry'])) {
$job->setRetry($args['retry']);
}
return $job;
} | php | public static function create(array $args)
{
$job = new Job($args['body']);
if (isset($args['id'])) {
$job->setId($args['id']);
$job->setTtl(hexdec(substr($job->getId(), -4)));
}
if (isset($args['queue'])) {
$job->setQueue($args['queue']);
}
if (isset($args['ttl'])) {
$job->setTtl($args['ttl']);
}
if (isset($args['retry'])) {
$job->setRetry($args['retry']);
}
return $job;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"job",
"=",
"new",
"Job",
"(",
"$",
"args",
"[",
"'body'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"job",
"... | Job Factory method.
@param array $args
@return Job | [
"Job",
"Factory",
"method",
"."
] | d917f0578360395899bd583724046d36ac459535 | https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Job.php#L168-L190 |
5,992 | tarsana/filesystem | src/Directory.php | Directory.create | public function create()
{
if (! $this->exists() && $this->canCreate()) {
$this->adapter->mkdir($this->path, 0755, true);
}
return $this;
} | php | public function create()
{
if (! $this->exists() && $this->canCreate()) {
$this->adapter->mkdir($this->path, 0755, true);
}
return $this;
} | [
"public",
"function",
"create",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
")",
"&&",
"$",
"this",
"->",
"canCreate",
"(",
")",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"mkdir",
"(",
"$",
"this",
"->",
"path",
",",
"0... | Creates the directory if it doesn't exist.
@return Tarsana\Filesystem\Directory | [
"Creates",
"the",
"directory",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Directory.php#L25-L31 |
5,993 | tarsana/filesystem | src/Directory.php | Directory.copyAs | public function copyAs($dest)
{
$dest = rtrim($dest, '/') . '/';
$copy = new Directory($dest, $this->adapter); // create the destination directory
foreach ($this->fs()->find('*')->asArray() as $file) {
$file->copyAs($dest . $file->name());
}
return $copy;
} | php | public function copyAs($dest)
{
$dest = rtrim($dest, '/') . '/';
$copy = new Directory($dest, $this->adapter); // create the destination directory
foreach ($this->fs()->find('*')->asArray() as $file) {
$file->copyAs($dest . $file->name());
}
return $copy;
} | [
"public",
"function",
"copyAs",
"(",
"$",
"dest",
")",
"{",
"$",
"dest",
"=",
"rtrim",
"(",
"$",
"dest",
",",
"'/'",
")",
".",
"'/'",
";",
"$",
"copy",
"=",
"new",
"Directory",
"(",
"$",
"dest",
",",
"$",
"this",
"->",
"adapter",
")",
";",
"// ... | Copies the directory to the provided destination and returns the copy.
@param string $dest
@return Tarsana\Filesystem\Directory
@throws Tarsana\Filesystem\Exceptions\FilesystemException if unable to create the destination directory. | [
"Copies",
"the",
"directory",
"to",
"the",
"provided",
"destination",
"and",
"returns",
"the",
"copy",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Directory.php#L62-L73 |
5,994 | vox-tecnologia/pdf | src/Pdf/Pdf.php | Pdf.registerPageMargins | public function registerPageMargins(): PdfInterface
{
$mpdf = $this->mpdf;
/* Set the margins and page current page width */
$mpdf->SetLeftMargin($this->marginLeft);
$mpdf->SetTopMargin($this->marginTop);
$mpdf->SetRightMargin($this->marginRight);
$mpdf->SetAutoPageBreak(true, $this->marginBottom);
$mpdf->margin_header = $this->marginHeader;
$mpdf->margin_footer = $this->marginFooter;
$mpdf->orig_lMargin = $mpdf->DeflMargin = $mpdf->lMargin = $this->marginLeft;
$mpdf->orig_tMargin = $mpdf->tMargin = $this->marginTop;
$mpdf->orig_rMargin = $mpdf->DefrMargin = $mpdf->rMargin = $this->marginRight;
$mpdf->orig_bMargin = $mpdf->bMargin = $this->marginBottom;
$mpdf->orig_hMargin = $mpdf->margin_header = $this->marginHeader;
$mpdf->orig_fMargin = $mpdf->margin_footer = $this->marginFooter;
$mpdf->pgwidth = $mpdf->w - $mpdf->lMargin - $mpdf->rMargin;
return $this;
} | php | public function registerPageMargins(): PdfInterface
{
$mpdf = $this->mpdf;
/* Set the margins and page current page width */
$mpdf->SetLeftMargin($this->marginLeft);
$mpdf->SetTopMargin($this->marginTop);
$mpdf->SetRightMargin($this->marginRight);
$mpdf->SetAutoPageBreak(true, $this->marginBottom);
$mpdf->margin_header = $this->marginHeader;
$mpdf->margin_footer = $this->marginFooter;
$mpdf->orig_lMargin = $mpdf->DeflMargin = $mpdf->lMargin = $this->marginLeft;
$mpdf->orig_tMargin = $mpdf->tMargin = $this->marginTop;
$mpdf->orig_rMargin = $mpdf->DefrMargin = $mpdf->rMargin = $this->marginRight;
$mpdf->orig_bMargin = $mpdf->bMargin = $this->marginBottom;
$mpdf->orig_hMargin = $mpdf->margin_header = $this->marginHeader;
$mpdf->orig_fMargin = $mpdf->margin_footer = $this->marginFooter;
$mpdf->pgwidth = $mpdf->w - $mpdf->lMargin - $mpdf->rMargin;
return $this;
} | [
"public",
"function",
"registerPageMargins",
"(",
")",
":",
"PdfInterface",
"{",
"$",
"mpdf",
"=",
"$",
"this",
"->",
"mpdf",
";",
"/* Set the margins and page current page width */",
"$",
"mpdf",
"->",
"SetLeftMargin",
"(",
"$",
"this",
"->",
"marginLeft",
")",
... | Registering the page size and margins.
@return PdfInterface The current interface
@api | [
"Registering",
"the",
"page",
"size",
"and",
"margins",
"."
] | c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969 | https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/Pdf.php#L92-L112 |
5,995 | vox-tecnologia/pdf | src/Pdf/Pdf.php | Pdf.setFontSize | public function setFontSize(int $size): PdfInterface
{
$this->fontSize = (int) $size;
$this->mpdf->SetDefaultFontSize($this->fontSize);
return $this;
} | php | public function setFontSize(int $size): PdfInterface
{
$this->fontSize = (int) $size;
$this->mpdf->SetDefaultFontSize($this->fontSize);
return $this;
} | [
"public",
"function",
"setFontSize",
"(",
"int",
"$",
"size",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"fontSize",
"=",
"(",
"int",
")",
"$",
"size",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetDefaultFontSize",
"(",
"$",
"this",
"->",
"fontSize... | Set the default font size.
@param int $size The font size (pt.)
@return PdfInterface The current interface
@api | [
"Set",
"the",
"default",
"font",
"size",
"."
] | c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969 | https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/Pdf.php#L125-L131 |
5,996 | vox-tecnologia/pdf | src/Pdf/Pdf.php | Pdf.importPages | public function importPages(string $filePath): PdfInterface
{
if (!is_file($filePath)) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $filePath));
}
$numberPagesCurrentFile = count($this->mpdf->pages);
$numberPagesExternalFile = $this->mpdf->setSourceFile($filePath);
$numberTotalPages = $numberPagesCurrentFile + $numberPagesExternalFile;
$this->mpdf->setImportUse();
for ($i = 1; $i <= $numberPagesExternalFile; $i++) {
if ($i < $numberTotalPages) {
$this->mpdf->addPage();
}
$this->mpdf->useTemplate($this->mpdf->importPage($i));
}
return $this;
} | php | public function importPages(string $filePath): PdfInterface
{
if (!is_file($filePath)) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $filePath));
}
$numberPagesCurrentFile = count($this->mpdf->pages);
$numberPagesExternalFile = $this->mpdf->setSourceFile($filePath);
$numberTotalPages = $numberPagesCurrentFile + $numberPagesExternalFile;
$this->mpdf->setImportUse();
for ($i = 1; $i <= $numberPagesExternalFile; $i++) {
if ($i < $numberTotalPages) {
$this->mpdf->addPage();
}
$this->mpdf->useTemplate($this->mpdf->importPage($i));
}
return $this;
} | [
"public",
"function",
"importPages",
"(",
"string",
"$",
"filePath",
")",
":",
"PdfInterface",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The file \"%s\" does no... | Import external file pages and merge with current.
@param string $filePath The path of the file to merge
@return PdfInterface The current interface
@throws \InvalidArgumentException if the parameter file does not exist
@api | [
"Import",
"external",
"file",
"pages",
"and",
"merge",
"with",
"current",
"."
] | c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969 | https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/Pdf.php#L146-L164 |
5,997 | vox-tecnologia/pdf | src/Pdf/Pdf.php | Pdf.setOutputDestination | public function setOutputDestination(string $destination): PdfInterface
{
/**
* Destinations can be sent to the following:
* - I/B [Inline] - Sends output to browser (browser plug-in is used if avaialble)
* If a $filename is given, the browser's "Save as..." option is provided
* - D [Download] - Forces browser to download the file
* - F [File] - Saves the file to the server's filesystem cache
* - S [String] - Returns the PDF as a string
*/
$this->setProperty(
'outputDestination',
strtoupper($destination[0]) === 'B' ? 'I' : strtoupper($destination[0])
);
return $this;
} | php | public function setOutputDestination(string $destination): PdfInterface
{
/**
* Destinations can be sent to the following:
* - I/B [Inline] - Sends output to browser (browser plug-in is used if avaialble)
* If a $filename is given, the browser's "Save as..." option is provided
* - D [Download] - Forces browser to download the file
* - F [File] - Saves the file to the server's filesystem cache
* - S [String] - Returns the PDF as a string
*/
$this->setProperty(
'outputDestination',
strtoupper($destination[0]) === 'B' ? 'I' : strtoupper($destination[0])
);
return $this;
} | [
"public",
"function",
"setOutputDestination",
"(",
"string",
"$",
"destination",
")",
":",
"PdfInterface",
"{",
"/**\n * Destinations can be sent to the following:\n * - I/B [Inline] - Sends output to browser (browser plug-in is used if avaialble)\n * ... | Set the output destination.
@param string $destination The destination to send the PDF
@return PdfInterface The current interface
@api | [
"Set",
"the",
"output",
"destination",
"."
] | c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969 | https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/Pdf.php#L195-L211 |
5,998 | vox-tecnologia/pdf | src/Pdf/Pdf.php | Pdf.initializePageSetup | public function initializePageSetup(string $pageSize = null, string $orientation = null): PdfInterface
{
in_array($pageSize, $this->pageTypes)
? $this->setProperty(
'mpdf',
new \mPDF(
'utf-8',
$pageSize . '-' . $orientation[0],
$this->fontSize,
$this->fontType,
$this->marginLeft,
$this->marginRight,
$this->marginTop,
$this->marginBottom,
$this->marginHeader,
$this->marginFooter,
$orientation[0]
)
)
: $this->setProperty('mpdf', new \mPDF('UTF-8', 'Letter-P'));
return $this;
} | php | public function initializePageSetup(string $pageSize = null, string $orientation = null): PdfInterface
{
in_array($pageSize, $this->pageTypes)
? $this->setProperty(
'mpdf',
new \mPDF(
'utf-8',
$pageSize . '-' . $orientation[0],
$this->fontSize,
$this->fontType,
$this->marginLeft,
$this->marginRight,
$this->marginTop,
$this->marginBottom,
$this->marginHeader,
$this->marginFooter,
$orientation[0]
)
)
: $this->setProperty('mpdf', new \mPDF('UTF-8', 'Letter-P'));
return $this;
} | [
"public",
"function",
"initializePageSetup",
"(",
"string",
"$",
"pageSize",
"=",
"null",
",",
"string",
"$",
"orientation",
"=",
"null",
")",
":",
"PdfInterface",
"{",
"in_array",
"(",
"$",
"pageSize",
",",
"$",
"this",
"->",
"pageTypes",
")",
"?",
"$",
... | Initialize a new PDF document by specifying page size and orientation.
@param string $pageSize The page size ('Letter','Legal','A4')
@param string $orientation The page orientation ('Portrait','Landscape')
@return PdfInterface The current interface
@api | [
"Initialize",
"a",
"new",
"PDF",
"document",
"by",
"specifying",
"page",
"size",
"and",
"orientation",
"."
] | c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969 | https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/Pdf.php#L225-L247 |
5,999 | bugotech/io | src/Template.php | Template.filter | public function filter($filter)
{
if (is_array($filter) != true) {
$filter = [$filter];
}
foreach ($filter as $item) {
$this->filters[] = str_replace('./', $this->outpath . '/', $item);
}
return $this;
} | php | public function filter($filter)
{
if (is_array($filter) != true) {
$filter = [$filter];
}
foreach ($filter as $item) {
$this->filters[] = str_replace('./', $this->outpath . '/', $item);
}
return $this;
} | [
"public",
"function",
"filter",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"filter",
")",
"!=",
"true",
")",
"{",
"$",
"filter",
"=",
"[",
"$",
"filter",
"]",
";",
"}",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"item",
")",
... | Registrar filtro do template. | [
"Registrar",
"filtro",
"do",
"template",
"."
] | 3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0 | https://github.com/bugotech/io/blob/3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0/src/Template.php#L80-L91 |
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.