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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
12,500 | vinala/kernel | src/Foundation/Bus.php | Bus.translator | private static function translator()
{
$files = ['Lang', 'Smiley'];
$folder = static::$root.'Translator'.'/';
self::call($files, $folder);
$files = ['LanguageKeyNotFoundException', 'LanguageNotSupportedException'];
$folder = static::$root.'Translator/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function translator()
{
$files = ['Lang', 'Smiley'];
$folder = static::$root.'Translator'.'/';
self::call($files, $folder);
$files = ['LanguageKeyNotFoundException', 'LanguageNotSupportedException'];
$folder = static::$root.'Translator/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"translator",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'Lang'",
",",
"'Smiley'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Translator'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'LanguageKeyNotFoundException'",
",",
"'LanguageNotSupportedException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Translator/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Translator surface.
@return null | [
"Call",
"the",
"Translator",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L855-L866 |
12,501 | vinala/kernel | src/Foundation/Bus.php | Bus.model | private static function model()
{
$files = ['ORM_', 'CRUD', 'ORM', 'Collection', 'ModelArray'];
$folder = static::$root.'MVC/Model'.'/';
self::call($files, $folder);
$files = ['ForeingKeyMethodException', 'ColumnNotEmptyException', 'ManyPrimaryKeysException', 'TableNotFoundException', 'ModelNotFoundException', 'PrimaryKeyNotFoundException'];
$folder = static::$root.'MVC/Model/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function model()
{
$files = ['ORM_', 'CRUD', 'ORM', 'Collection', 'ModelArray'];
$folder = static::$root.'MVC/Model'.'/';
self::call($files, $folder);
$files = ['ForeingKeyMethodException', 'ColumnNotEmptyException', 'ManyPrimaryKeysException', 'TableNotFoundException', 'ModelNotFoundException', 'PrimaryKeyNotFoundException'];
$folder = static::$root.'MVC/Model/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"model",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'ORM_'",
",",
"'CRUD'",
",",
"'ORM'",
",",
"'Collection'",
",",
"'ModelArray'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/Model'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'ForeingKeyMethodException'",
",",
"'ColumnNotEmptyException'",
",",
"'ManyPrimaryKeysException'",
",",
"'TableNotFoundException'",
",",
"'ModelNotFoundException'",
",",
"'PrimaryKeyNotFoundException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/Model/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Model surface.
@return null | [
"Call",
"the",
"Model",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L873-L884 |
12,502 | vinala/kernel | src/Foundation/Bus.php | Bus.relations | private static function relations()
{
$files = ['OneToOne', 'OneToMany', 'ManyToMany', 'BelongsTo'];
$folder = static::$root.'MVC/Relations'.'/';
self::call($files, $folder);
$files = ['ManyRelationException', 'ModelNotFindedException'];
$folder = static::$root.'MVC/Relations/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function relations()
{
$files = ['OneToOne', 'OneToMany', 'ManyToMany', 'BelongsTo'];
$folder = static::$root.'MVC/Relations'.'/';
self::call($files, $folder);
$files = ['ManyRelationException', 'ModelNotFindedException'];
$folder = static::$root.'MVC/Relations/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"relations",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'OneToOne'",
",",
"'OneToMany'",
",",
"'ManyToMany'",
",",
"'BelongsTo'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/Relations'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'ManyRelationException'",
",",
"'ModelNotFindedException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/Relations/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Realtons surface.
@return null | [
"Call",
"the",
"Realtons",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L891-L902 |
12,503 | vinala/kernel | src/Foundation/Bus.php | Bus.view | private static function view()
{
$files = ['View'];
$folder = static::$root.'MVC/View'.'/';
self::call($files, $folder);
$files = ['Template', 'Views'];
$folder = static::$root.'MVC/View/Libs'.'/';
self::call($files, $folder);
$files = ['ViewNotFoundException'];
$folder = static::$root.'MVC/View/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function view()
{
$files = ['View'];
$folder = static::$root.'MVC/View'.'/';
self::call($files, $folder);
$files = ['Template', 'Views'];
$folder = static::$root.'MVC/View/Libs'.'/';
self::call($files, $folder);
$files = ['ViewNotFoundException'];
$folder = static::$root.'MVC/View/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"view",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'View'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/View'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'Template'",
",",
"'Views'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/View/Libs'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'ViewNotFoundException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'MVC/View/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the View surface.
@return null | [
"Call",
"the",
"View",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L922-L938 |
12,504 | vinala/kernel | src/Foundation/Bus.php | Bus.mail | private static function mail()
{
$files = ['Mail', 'Mailable', 'SMTP'];
$folder = static::$root.'Mailing'.'/';
self::call($files, $folder);
$files = ['SmtpParameterNotFoundException', 'MailViewNotFoundException'];
$folder = $folder.'Exceptions/';
self::call($files, $folder);
} | php | private static function mail()
{
$files = ['Mail', 'Mailable', 'SMTP'];
$folder = static::$root.'Mailing'.'/';
self::call($files, $folder);
$files = ['SmtpParameterNotFoundException', 'MailViewNotFoundException'];
$folder = $folder.'Exceptions/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"mail",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'Mail'",
",",
"'Mailable'",
",",
"'SMTP'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Mailing'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'SmtpParameterNotFoundException'",
",",
"'MailViewNotFoundException'",
"]",
";",
"$",
"folder",
"=",
"$",
"folder",
".",
"'Exceptions/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Mail surface.
@return null | [
"Call",
"the",
"Mail",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L958-L969 |
12,505 | vinala/kernel | src/Foundation/Bus.php | Bus.file | private static function file()
{
$files = ['File', 'Filesystem'];
$folder = static::$root.'Filesystem'.'/';
self::call($files, $folder);
$files = ['FileNotFoundException', 'DirectoryNotFoundException'];
$folder = static::$root.'Filesystem/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function file()
{
$files = ['File', 'Filesystem'];
$folder = static::$root.'Filesystem'.'/';
self::call($files, $folder);
$files = ['FileNotFoundException', 'DirectoryNotFoundException'];
$folder = static::$root.'Filesystem/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"file",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'File'",
",",
"'Filesystem'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Filesystem'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'FileNotFoundException'",
",",
"'DirectoryNotFoundException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Filesystem/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Files surface.
@return null | [
"Call",
"the",
"Files",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L989-L1000 |
12,506 | vinala/kernel | src/Foundation/Bus.php | Bus.plugins | private static function plugins()
{
$files = ['Plugins'];
$folder = static::$root.'Plugins'.'/';
self::call($files, $folder);
$files = ['AutoloadFileNotFoundException', 'InfoStructureException'];
$folder = static::$root.'Plugins/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function plugins()
{
$files = ['Plugins'];
$folder = static::$root.'Plugins'.'/';
self::call($files, $folder);
$files = ['AutoloadFileNotFoundException', 'InfoStructureException'];
$folder = static::$root.'Plugins/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"plugins",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'Plugins'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Plugins'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'AutoloadFileNotFoundException'",
",",
"'InfoStructureException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Plugins/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Plugins surface.
@return null | [
"Call",
"the",
"Plugins",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L1020-L1031 |
12,507 | vinala/kernel | src/Foundation/Bus.php | Bus.lumos | private static function lumos()
{
$files = ['cmdOutput', 'bashOutput', 'Argument', 'Option', 'Commands'];
$folder = static::$root.'Lumos'.'/';
self::call($files, $folder);
// Call Kernel commands
static::commands();
$files = ['Console'];
$folder = static::$root.'Lumos'.'/';
self::call($files, $folder);
$files = ['ConfigSetting'];
$folder = static::$root.'Lumos/Response'.'/';
self::call($files, $folder);
} | php | private static function lumos()
{
$files = ['cmdOutput', 'bashOutput', 'Argument', 'Option', 'Commands'];
$folder = static::$root.'Lumos'.'/';
self::call($files, $folder);
// Call Kernel commands
static::commands();
$files = ['Console'];
$folder = static::$root.'Lumos'.'/';
self::call($files, $folder);
$files = ['ConfigSetting'];
$folder = static::$root.'Lumos/Response'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"lumos",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'cmdOutput'",
",",
"'bashOutput'",
",",
"'Argument'",
",",
"'Option'",
",",
"'Commands'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Lumos'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"// Call Kernel commands",
"static",
"::",
"commands",
"(",
")",
";",
"$",
"files",
"=",
"[",
"'Console'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Lumos'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'ConfigSetting'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Lumos/Response'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Lumos surface.
@return null | [
"Call",
"the",
"Lumos",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L1038-L1057 |
12,508 | vinala/kernel | src/Foundation/Bus.php | Bus.atomium | private static function atomium()
{
$path = static::$root.'Atomium/';
$files = ['Atomium', 'Compiler'];
$folder = $path;
self::call($files, $folder);
$files = [
'AtomiumUserTags',
//
'AtomiumCompileCSS', 'AtomiumCompileJS', 'AtomiumCompileAssign', 'AtomiumCompileRun',
//
'AtomiumCompileComments', 'AtomiumCompileComment',
//
'AtomiumCompileInstruction', 'AtomiumCompileInstructions', 'AtomiumCompileIf', 'AtomiumCompileFor', 'AtomiumCompileEndFor', 'AtomiumCompileBreak', 'AtomiumCompileOneLineComment', 'AtomiumCompileElse', 'AtomiumCompileEndIf', 'AtomiumCompileElseIf', 'AtomiumCompileForeach', 'AtomiumCompileEndForeach', 'AtomiumCompileWhile', 'AtomiumCompileEndWhile', 'AtomiumCompileUntil', 'AtomiumCompileEndUntil', 'AtomiumCompileSub', 'AtomiumCompileExec',
//
'AtomiumCompileLang',
//
'AtomiumCompileTake', 'AtomiumCompileCapture',
];
$folder = $path.'Compiler'.'/';
self::call($files, $folder);
$files = ['AromiumCaptureNotFoundException'];
$folder = $path.'Exception/';
self::call($files, $folder);
Compiler::setUserTags();
} | php | private static function atomium()
{
$path = static::$root.'Atomium/';
$files = ['Atomium', 'Compiler'];
$folder = $path;
self::call($files, $folder);
$files = [
'AtomiumUserTags',
//
'AtomiumCompileCSS', 'AtomiumCompileJS', 'AtomiumCompileAssign', 'AtomiumCompileRun',
//
'AtomiumCompileComments', 'AtomiumCompileComment',
//
'AtomiumCompileInstruction', 'AtomiumCompileInstructions', 'AtomiumCompileIf', 'AtomiumCompileFor', 'AtomiumCompileEndFor', 'AtomiumCompileBreak', 'AtomiumCompileOneLineComment', 'AtomiumCompileElse', 'AtomiumCompileEndIf', 'AtomiumCompileElseIf', 'AtomiumCompileForeach', 'AtomiumCompileEndForeach', 'AtomiumCompileWhile', 'AtomiumCompileEndWhile', 'AtomiumCompileUntil', 'AtomiumCompileEndUntil', 'AtomiumCompileSub', 'AtomiumCompileExec',
//
'AtomiumCompileLang',
//
'AtomiumCompileTake', 'AtomiumCompileCapture',
];
$folder = $path.'Compiler'.'/';
self::call($files, $folder);
$files = ['AromiumCaptureNotFoundException'];
$folder = $path.'Exception/';
self::call($files, $folder);
Compiler::setUserTags();
} | [
"private",
"static",
"function",
"atomium",
"(",
")",
"{",
"$",
"path",
"=",
"static",
"::",
"$",
"root",
".",
"'Atomium/'",
";",
"$",
"files",
"=",
"[",
"'Atomium'",
",",
"'Compiler'",
"]",
";",
"$",
"folder",
"=",
"$",
"path",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'AtomiumUserTags'",
",",
"//",
"'AtomiumCompileCSS'",
",",
"'AtomiumCompileJS'",
",",
"'AtomiumCompileAssign'",
",",
"'AtomiumCompileRun'",
",",
"//",
"'AtomiumCompileComments'",
",",
"'AtomiumCompileComment'",
",",
"//",
"'AtomiumCompileInstruction'",
",",
"'AtomiumCompileInstructions'",
",",
"'AtomiumCompileIf'",
",",
"'AtomiumCompileFor'",
",",
"'AtomiumCompileEndFor'",
",",
"'AtomiumCompileBreak'",
",",
"'AtomiumCompileOneLineComment'",
",",
"'AtomiumCompileElse'",
",",
"'AtomiumCompileEndIf'",
",",
"'AtomiumCompileElseIf'",
",",
"'AtomiumCompileForeach'",
",",
"'AtomiumCompileEndForeach'",
",",
"'AtomiumCompileWhile'",
",",
"'AtomiumCompileEndWhile'",
",",
"'AtomiumCompileUntil'",
",",
"'AtomiumCompileEndUntil'",
",",
"'AtomiumCompileSub'",
",",
"'AtomiumCompileExec'",
",",
"//",
"'AtomiumCompileLang'",
",",
"//",
"'AtomiumCompileTake'",
",",
"'AtomiumCompileCapture'",
",",
"]",
";",
"$",
"folder",
"=",
"$",
"path",
".",
"'Compiler'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'AromiumCaptureNotFoundException'",
"]",
";",
"$",
"folder",
"=",
"$",
"path",
".",
"'Exception/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"Compiler",
"::",
"setUserTags",
"(",
")",
";",
"}"
] | Call the Atomium surface.
@return null | [
"Call",
"the",
"Atomium",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L1076-L1108 |
12,509 | vinala/kernel | src/Foundation/Bus.php | Bus.proccess | private static function proccess()
{
$files = ['Process', 'Command', 'Translator', 'Migrations', 'Links', 'Tag', 'Model', 'View', 'Controller', 'Seeds', 'Router', 'Exception', 'Events', 'Alias', 'Middleware', 'Helper', 'Tests', 'Mail', 'Query'];
$folder = static::$root.'Processes'.'/';
self::call($files, $folder);
$files = ['TranslatorFolderNeededException', 'TranslatorManyFolderException'];
$folder = static::$root.'Processes/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function proccess()
{
$files = ['Process', 'Command', 'Translator', 'Migrations', 'Links', 'Tag', 'Model', 'View', 'Controller', 'Seeds', 'Router', 'Exception', 'Events', 'Alias', 'Middleware', 'Helper', 'Tests', 'Mail', 'Query'];
$folder = static::$root.'Processes'.'/';
self::call($files, $folder);
$files = ['TranslatorFolderNeededException', 'TranslatorManyFolderException'];
$folder = static::$root.'Processes/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"proccess",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'Process'",
",",
"'Command'",
",",
"'Translator'",
",",
"'Migrations'",
",",
"'Links'",
",",
"'Tag'",
",",
"'Model'",
",",
"'View'",
",",
"'Controller'",
",",
"'Seeds'",
",",
"'Router'",
",",
"'Exception'",
",",
"'Events'",
",",
"'Alias'",
",",
"'Middleware'",
",",
"'Helper'",
",",
"'Tests'",
",",
"'Mail'",
",",
"'Query'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Processes'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'TranslatorFolderNeededException'",
",",
"'TranslatorManyFolderException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Processes/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Process surface.
@return null | [
"Call",
"the",
"Process",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L1115-L1126 |
12,510 | vinala/kernel | src/Foundation/Bus.php | Bus.setup | private static function setup()
{
$files = ['Routes', 'Setup', 'Response'];
$folder = static::$root.'Setup'.'/';
self::call($files, $folder);
$files = ['Database', 'Panel', 'Security', 'Maintenance', 'Loggin', 'Translator', 'App', 'Robots'];
$folder = static::$root.'Setup/Documentations'.'/';
self::call($files, $folder);
$files = ['AppSetupException'];
$folder = static::$root.'Setup/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function setup()
{
$files = ['Routes', 'Setup', 'Response'];
$folder = static::$root.'Setup'.'/';
self::call($files, $folder);
$files = ['Database', 'Panel', 'Security', 'Maintenance', 'Loggin', 'Translator', 'App', 'Robots'];
$folder = static::$root.'Setup/Documentations'.'/';
self::call($files, $folder);
$files = ['AppSetupException'];
$folder = static::$root.'Setup/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"setup",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'Routes'",
",",
"'Setup'",
",",
"'Response'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Setup'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'Database'",
",",
"'Panel'",
",",
"'Security'",
",",
"'Maintenance'",
",",
"'Loggin'",
",",
"'Translator'",
",",
"'App'",
",",
"'Robots'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Setup/Documentations'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'AppSetupException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Setup/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Setup surface.
@return null | [
"Call",
"the",
"Setup",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L1133-L1149 |
12,511 | vinala/kernel | src/Foundation/Bus.php | Bus.event | private static function event()
{
$files = ['Event', 'EventListener'];
$folder = static::$root.'Event'.'/';
self::call($files, $folder);
$files = ['ManyListenersArgumentsException'];
$folder = static::$root.'Event/Exceptions'.'/';
self::call($files, $folder);
} | php | private static function event()
{
$files = ['Event', 'EventListener'];
$folder = static::$root.'Event'.'/';
self::call($files, $folder);
$files = ['ManyListenersArgumentsException'];
$folder = static::$root.'Event/Exceptions'.'/';
self::call($files, $folder);
} | [
"private",
"static",
"function",
"event",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"'Event'",
",",
"'EventListener'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Event'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"$",
"files",
"=",
"[",
"'ManyListenersArgumentsException'",
"]",
";",
"$",
"folder",
"=",
"static",
"::",
"$",
"root",
".",
"'Event/Exceptions'",
".",
"'/'",
";",
"self",
"::",
"call",
"(",
"$",
"files",
",",
"$",
"folder",
")",
";",
"}"
] | Call the Event surface.
@return null | [
"Call",
"the",
"Event",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Bus.php#L1156-L1167 |
12,512 | 0x20h/phloppy | src/Client/Cluster.php | Cluster.meet | public function meet(array $nodeUrls)
{
$current = $this->stream->getNodeUrl();
return array_filter($nodeUrls, function($url) use ($current) {
if ($url === $current) {
return true;
}
$parts = parse_url($url);
try {
$response = $this->send(['CLUSTER', 'MEET', $parts['host'], (int) $parts['port']]);
$this->log->debug('CLUSTER MEET', ['host' => $url, 'response' => $response]);
return 'OK' === $response;
} catch (Exception $e) {
$this->log->error($e->getMessage(), array('url' => $url, 'exception' => $e));
return false;
}
});
} | php | public function meet(array $nodeUrls)
{
$current = $this->stream->getNodeUrl();
return array_filter($nodeUrls, function($url) use ($current) {
if ($url === $current) {
return true;
}
$parts = parse_url($url);
try {
$response = $this->send(['CLUSTER', 'MEET', $parts['host'], (int) $parts['port']]);
$this->log->debug('CLUSTER MEET', ['host' => $url, 'response' => $response]);
return 'OK' === $response;
} catch (Exception $e) {
$this->log->error($e->getMessage(), array('url' => $url, 'exception' => $e));
return false;
}
});
} | [
"public",
"function",
"meet",
"(",
"array",
"$",
"nodeUrls",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"stream",
"->",
"getNodeUrl",
"(",
")",
";",
"return",
"array_filter",
"(",
"$",
"nodeUrls",
",",
"function",
"(",
"$",
"url",
")",
"use",
"(",
"$",
"current",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"$",
"current",
")",
"{",
"return",
"true",
";",
"}",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"send",
"(",
"[",
"'CLUSTER'",
",",
"'MEET'",
",",
"$",
"parts",
"[",
"'host'",
"]",
",",
"(",
"int",
")",
"$",
"parts",
"[",
"'port'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'CLUSTER MEET'",
",",
"[",
"'host'",
"=>",
"$",
"url",
",",
"'response'",
"=>",
"$",
"response",
"]",
")",
";",
"return",
"'OK'",
"===",
"$",
"response",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'exception'",
"=>",
"$",
"e",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"}"
] | Introduce the provided nodes to the connected Disque instance.
@param string[] $nodeUrls
@return string[]
@see http://redis.io/commands/cluster-meet | [
"Introduce",
"the",
"provided",
"nodes",
"to",
"the",
"connected",
"Disque",
"instance",
"."
] | d917f0578360395899bd583724046d36ac459535 | https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Client/Cluster.php#L24-L44 |
12,513 | CakeCMS/Community | src/Model/Table/UsersTable.php | UsersTable.save | public function save(EntityInterface $entity, $options = [])
{
EventManager::trigger('Model.User.beforeSave', $this, [
'user' => $entity
]);
$success = parent::save($entity, $options);
EventManager::trigger('Model.User.afterSave', $this, [
'user' => $entity,
'success' => $success
]);
return $success;
} | php | public function save(EntityInterface $entity, $options = [])
{
EventManager::trigger('Model.User.beforeSave', $this, [
'user' => $entity
]);
$success = parent::save($entity, $options);
EventManager::trigger('Model.User.afterSave', $this, [
'user' => $entity,
'success' => $success
]);
return $success;
} | [
"public",
"function",
"save",
"(",
"EntityInterface",
"$",
"entity",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"EventManager",
"::",
"trigger",
"(",
"'Model.User.beforeSave'",
",",
"$",
"this",
",",
"[",
"'user'",
"=>",
"$",
"entity",
"]",
")",
";",
"$",
"success",
"=",
"parent",
"::",
"save",
"(",
"$",
"entity",
",",
"$",
"options",
")",
";",
"EventManager",
"::",
"trigger",
"(",
"'Model.User.afterSave'",
",",
"$",
"this",
",",
"[",
"'user'",
"=>",
"$",
"entity",
",",
"'success'",
"=>",
"$",
"success",
"]",
")",
";",
"return",
"$",
"success",
";",
"}"
] | Persists an entity based on the fields that are marked as dirty and
returns the same entity after a successful save or false in case
of any error.
@param \Cake\Datasource\EntityInterface $entity the entity to be saved
@param array|\ArrayAccess $options The options to use when saving.
@return \Cake\Datasource\EntityInterface|false | [
"Persists",
"an",
"entity",
"based",
"on",
"the",
"fields",
"that",
"are",
"marked",
"as",
"dirty",
"and",
"returns",
"the",
"same",
"entity",
"after",
"a",
"successful",
"save",
"or",
"false",
"in",
"case",
"of",
"any",
"error",
"."
] | cc2bdb596dd9617d42fd81f59e981024caa062e8 | https://github.com/CakeCMS/Community/blob/cc2bdb596dd9617d42fd81f59e981024caa062e8/src/Model/Table/UsersTable.php#L76-L90 |
12,514 | WellCommerce/DataSet | Context/FlatTreeContext.php | FlatTreeContext.makeTree | private function makeTree(array $result)
{
$tree = [];
foreach ($result as $row) {
$this->makeNode($row, $tree);
}
return $tree;
} | php | private function makeTree(array $result)
{
$tree = [];
foreach ($result as $row) {
$this->makeNode($row, $tree);
}
return $tree;
} | [
"private",
"function",
"makeTree",
"(",
"array",
"$",
"result",
")",
"{",
"$",
"tree",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"makeNode",
"(",
"$",
"row",
",",
"$",
"tree",
")",
";",
"}",
"return",
"$",
"tree",
";",
"}"
] | Creates flat tree structure from result rows
@param array $result
@return array | [
"Creates",
"flat",
"tree",
"structure",
"from",
"result",
"rows"
] | 18720dc5416f245d22c502ceafce1a1b2db2b905 | https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Context/FlatTreeContext.php#L45-L54 |
12,515 | WellCommerce/DataSet | Context/FlatTreeContext.php | FlatTreeContext.makeNode | private function makeNode(&$row, &$tree)
{
$hasChildren = $this->propertyAccessor->getValue($row, "[{$this->options['children_column']}]");
$weight = $this->propertyAccessor->getValue($row, "[{$this->options['hierarchy_column']}]");
$row['hasChildren'] = (bool)($hasChildren > 0);
$row['weight'] = $weight;
$tree[$row['id']] = $row;
} | php | private function makeNode(&$row, &$tree)
{
$hasChildren = $this->propertyAccessor->getValue($row, "[{$this->options['children_column']}]");
$weight = $this->propertyAccessor->getValue($row, "[{$this->options['hierarchy_column']}]");
$row['hasChildren'] = (bool)($hasChildren > 0);
$row['weight'] = $weight;
$tree[$row['id']] = $row;
} | [
"private",
"function",
"makeNode",
"(",
"&",
"$",
"row",
",",
"&",
"$",
"tree",
")",
"{",
"$",
"hasChildren",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"row",
",",
"\"[{$this->options['children_column']}]\"",
")",
";",
"$",
"weight",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"row",
",",
"\"[{$this->options['hierarchy_column']}]\"",
")",
";",
"$",
"row",
"[",
"'hasChildren'",
"]",
"=",
"(",
"bool",
")",
"(",
"$",
"hasChildren",
">",
"0",
")",
";",
"$",
"row",
"[",
"'weight'",
"]",
"=",
"$",
"weight",
";",
"$",
"tree",
"[",
"$",
"row",
"[",
"'id'",
"]",
"]",
"=",
"$",
"row",
";",
"}"
] | Converts single row to flat-tree node
@param array $row
@param array $tree | [
"Converts",
"single",
"row",
"to",
"flat",
"-",
"tree",
"node"
] | 18720dc5416f245d22c502ceafce1a1b2db2b905 | https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Context/FlatTreeContext.php#L62-L70 |
12,516 | infinity-se/infinity-base | src/InfinityBase/EntityManager/EntityManagerAwareTrait.php | EntityManagerAwareTrait.getEntityManager | public function getEntityManager()
{
if (!isset($this->_entityManager)) {
$this->_entityManager = $this->getServiceLocator()
->get('Doctrine\ORM\EntityManager');
}
return $this->_entityManager;
} | php | public function getEntityManager()
{
if (!isset($this->_entityManager)) {
$this->_entityManager = $this->getServiceLocator()
->get('Doctrine\ORM\EntityManager');
}
return $this->_entityManager;
} | [
"public",
"function",
"getEntityManager",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_entityManager",
")",
")",
"{",
"$",
"this",
"->",
"_entityManager",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'Doctrine\\ORM\\EntityManager'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_entityManager",
";",
"}"
] | Get entity manager
@return EntityManager | [
"Get",
"entity",
"manager"
] | 4f869ae4b549e779560a83528d2ed2664f6deb5b | https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/EntityManager/EntityManagerAwareTrait.php#L23-L30 |
12,517 | morrelinko/simple-photo | src/SimplePhoto.php | SimplePhoto.collection | public function collection(array $ids, array $options = array())
{
$photos = $this->dataStore->getPhotos($ids);
if (empty($photos) && !$this->storageManager->hasFallback()) {
// If no fallback has been defined, and no photo was found
// lets just skip the computation that follows.
return $this->createPhotoCollection();
}
$found = array();
array_map(function ($photo) use ($ids, &$found) {
// This will be used to build found Photos
return $found[$photo['id']] = $photo;
}, $photos);
$sorted = array();
foreach ($ids as $index => $id) {
$photo = array();
if (array_key_exists($id, $found)) {
$photo = $found[$id];
}
$sorted[$index] = $photo;
}
$photos = $this->createPhotoCollection($sorted);
$simplePhoto = $this; // php 5.3 compatibility
$photos->transform(function ($photo) use ($simplePhoto, $options) {
return $simplePhoto->build($photo, $options);
})->ksort();
return $photos;
} | php | public function collection(array $ids, array $options = array())
{
$photos = $this->dataStore->getPhotos($ids);
if (empty($photos) && !$this->storageManager->hasFallback()) {
// If no fallback has been defined, and no photo was found
// lets just skip the computation that follows.
return $this->createPhotoCollection();
}
$found = array();
array_map(function ($photo) use ($ids, &$found) {
// This will be used to build found Photos
return $found[$photo['id']] = $photo;
}, $photos);
$sorted = array();
foreach ($ids as $index => $id) {
$photo = array();
if (array_key_exists($id, $found)) {
$photo = $found[$id];
}
$sorted[$index] = $photo;
}
$photos = $this->createPhotoCollection($sorted);
$simplePhoto = $this; // php 5.3 compatibility
$photos->transform(function ($photo) use ($simplePhoto, $options) {
return $simplePhoto->build($photo, $options);
})->ksort();
return $photos;
} | [
"public",
"function",
"collection",
"(",
"array",
"$",
"ids",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"photos",
"=",
"$",
"this",
"->",
"dataStore",
"->",
"getPhotos",
"(",
"$",
"ids",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"photos",
")",
"&&",
"!",
"$",
"this",
"->",
"storageManager",
"->",
"hasFallback",
"(",
")",
")",
"{",
"// If no fallback has been defined, and no photo was found",
"// lets just skip the computation that follows.",
"return",
"$",
"this",
"->",
"createPhotoCollection",
"(",
")",
";",
"}",
"$",
"found",
"=",
"array",
"(",
")",
";",
"array_map",
"(",
"function",
"(",
"$",
"photo",
")",
"use",
"(",
"$",
"ids",
",",
"&",
"$",
"found",
")",
"{",
"// This will be used to build found Photos",
"return",
"$",
"found",
"[",
"$",
"photo",
"[",
"'id'",
"]",
"]",
"=",
"$",
"photo",
";",
"}",
",",
"$",
"photos",
")",
";",
"$",
"sorted",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"index",
"=>",
"$",
"id",
")",
"{",
"$",
"photo",
"=",
"array",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"found",
")",
")",
"{",
"$",
"photo",
"=",
"$",
"found",
"[",
"$",
"id",
"]",
";",
"}",
"$",
"sorted",
"[",
"$",
"index",
"]",
"=",
"$",
"photo",
";",
"}",
"$",
"photos",
"=",
"$",
"this",
"->",
"createPhotoCollection",
"(",
"$",
"sorted",
")",
";",
"$",
"simplePhoto",
"=",
"$",
"this",
";",
"// php 5.3 compatibility",
"$",
"photos",
"->",
"transform",
"(",
"function",
"(",
"$",
"photo",
")",
"use",
"(",
"$",
"simplePhoto",
",",
"$",
"options",
")",
"{",
"return",
"$",
"simplePhoto",
"->",
"build",
"(",
"$",
"photo",
",",
"$",
"options",
")",
";",
"}",
")",
"->",
"ksort",
"(",
")",
";",
"return",
"$",
"photos",
";",
"}"
] | Gets multiple photos
@param array $ids List of photo ids
@param array $options
@see SimplePhoto::build()
@return mixed|PhotoCollection | [
"Gets",
"multiple",
"photos"
] | be1fbe3139d32eb39e88cff93f847154bb6a8cb2 | https://github.com/morrelinko/simple-photo/blob/be1fbe3139d32eb39e88cff93f847154bb6a8cb2/src/SimplePhoto.php#L282-L315 |
12,518 | buybrain/nervus-php | src/Buybrain/Nervus/Util/Tcp.php | Tcp.dial | public static function dial($addr)
{
$socket = stream_socket_client('tcp://' . $addr);
if ($socket === false) {
throw new Exception('Could not dial to ' . $addr . ': ' . socket_strerror(socket_last_error()));
}
return $socket;
} | php | public static function dial($addr)
{
$socket = stream_socket_client('tcp://' . $addr);
if ($socket === false) {
throw new Exception('Could not dial to ' . $addr . ': ' . socket_strerror(socket_last_error()));
}
return $socket;
} | [
"public",
"static",
"function",
"dial",
"(",
"$",
"addr",
")",
"{",
"$",
"socket",
"=",
"stream_socket_client",
"(",
"'tcp://'",
".",
"$",
"addr",
")",
";",
"if",
"(",
"$",
"socket",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not dial to '",
".",
"$",
"addr",
".",
"': '",
".",
"socket_strerror",
"(",
"socket_last_error",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"socket",
";",
"}"
] | Connect to a TCP address and return a stream resource
@param $addr string
@return resource | [
"Connect",
"to",
"a",
"TCP",
"address",
"and",
"return",
"a",
"stream",
"resource"
] | 96e00e30571b3ea4cf3494cd26c930ffa336c3bf | https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Util/Tcp.php#L17-L24 |
12,519 | cyberspectrum/i18n-xliff | src/WritableXliffDictionary.php | WritableXliffDictionary.markChanged | public function markChanged(): void
{
$this->changed = true;
$this->xliff->setDate(new \DateTime());
if (!$this->buffering) {
$this->xliff->save($this->filename);
}
} | php | public function markChanged(): void
{
$this->changed = true;
$this->xliff->setDate(new \DateTime());
if (!$this->buffering) {
$this->xliff->save($this->filename);
}
} | [
"public",
"function",
"markChanged",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"changed",
"=",
"true",
";",
"$",
"this",
"->",
"xliff",
"->",
"setDate",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"buffering",
")",
"{",
"$",
"this",
"->",
"xliff",
"->",
"save",
"(",
"$",
"this",
"->",
"filename",
")",
";",
"}",
"}"
] | Mark the file as changed.
@return void
@internal Should only be called from Xliff dictionary classes. | [
"Mark",
"the",
"file",
"as",
"changed",
"."
] | 9d03f85a33c8f6fc9acd99770f23800679f130b3 | https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/WritableXliffDictionary.php#L169-L176 |
12,520 | cyberspectrum/i18n-xliff | src/WritableXliffDictionary.php | WritableXliffDictionary.setOriginal | public function setOriginal(string $source): void
{
$this->xliff->setOriginal($source);
$this->markChanged();
} | php | public function setOriginal(string $source): void
{
$this->xliff->setOriginal($source);
$this->markChanged();
} | [
"public",
"function",
"setOriginal",
"(",
"string",
"$",
"source",
")",
":",
"void",
"{",
"$",
"this",
"->",
"xliff",
"->",
"setOriginal",
"(",
"$",
"source",
")",
";",
"$",
"this",
"->",
"markChanged",
"(",
")",
";",
"}"
] | Set the original.
@param string $source The original.
@return void | [
"Set",
"the",
"original",
"."
] | 9d03f85a33c8f6fc9acd99770f23800679f130b3 | https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/WritableXliffDictionary.php#L211-L215 |
12,521 | uthando-cms/uthando-common | src/UthandoCommon/Service/AbstractRelationalMapperService.php | AbstractRelationalMapperService.populate | public function populate($model, $children)
{
$allChildren = ($children === true) ? true : false;
$children = (is_array($children)) ? $children : [];
foreach ($this->getReferenceMap() as $name => $options) {
if ($allChildren || in_array($name, $children)) {
$service = $this->getRelatedService($name);
$getIdMethod = 'get' . ucfirst($options['refCol']);
$setMethod = $options['setMethod'] ?? 'set' . ucfirst($name);
$getMethod = $options['getMethod'] ?? 'getById';
$childModel = $service->$getMethod($model->$getIdMethod(), $options['refCol']);
if ($childModel instanceof HydratingResultSet) {
$childModelObjects = [];
foreach ($childModel as $row) {
$childModelObjects[] = $row;
}
$childModel = $childModelObjects;
}
$model->$setMethod($childModel);
}
}
return $model;
} | php | public function populate($model, $children)
{
$allChildren = ($children === true) ? true : false;
$children = (is_array($children)) ? $children : [];
foreach ($this->getReferenceMap() as $name => $options) {
if ($allChildren || in_array($name, $children)) {
$service = $this->getRelatedService($name);
$getIdMethod = 'get' . ucfirst($options['refCol']);
$setMethod = $options['setMethod'] ?? 'set' . ucfirst($name);
$getMethod = $options['getMethod'] ?? 'getById';
$childModel = $service->$getMethod($model->$getIdMethod(), $options['refCol']);
if ($childModel instanceof HydratingResultSet) {
$childModelObjects = [];
foreach ($childModel as $row) {
$childModelObjects[] = $row;
}
$childModel = $childModelObjects;
}
$model->$setMethod($childModel);
}
}
return $model;
} | [
"public",
"function",
"populate",
"(",
"$",
"model",
",",
"$",
"children",
")",
"{",
"$",
"allChildren",
"=",
"(",
"$",
"children",
"===",
"true",
")",
"?",
"true",
":",
"false",
";",
"$",
"children",
"=",
"(",
"is_array",
"(",
"$",
"children",
")",
")",
"?",
"$",
"children",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getReferenceMap",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"allChildren",
"||",
"in_array",
"(",
"$",
"name",
",",
"$",
"children",
")",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getRelatedService",
"(",
"$",
"name",
")",
";",
"$",
"getIdMethod",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"options",
"[",
"'refCol'",
"]",
")",
";",
"$",
"setMethod",
"=",
"$",
"options",
"[",
"'setMethod'",
"]",
"??",
"'set'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"$",
"getMethod",
"=",
"$",
"options",
"[",
"'getMethod'",
"]",
"??",
"'getById'",
";",
"$",
"childModel",
"=",
"$",
"service",
"->",
"$",
"getMethod",
"(",
"$",
"model",
"->",
"$",
"getIdMethod",
"(",
")",
",",
"$",
"options",
"[",
"'refCol'",
"]",
")",
";",
"if",
"(",
"$",
"childModel",
"instanceof",
"HydratingResultSet",
")",
"{",
"$",
"childModelObjects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"childModel",
"as",
"$",
"row",
")",
"{",
"$",
"childModelObjects",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"childModel",
"=",
"$",
"childModelObjects",
";",
"}",
"$",
"model",
"->",
"$",
"setMethod",
"(",
"$",
"childModel",
")",
";",
"}",
"}",
"return",
"$",
"model",
";",
"}"
] | populate relational records.
@param \UthandoCommon\Model\Model $model
@param bool|array $children
@return \UthandoCommon\Model\Model | [
"populate",
"relational",
"records",
"."
] | feb915da5d26b60f536282e1bc3ad5c22e53f485 | https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Service/AbstractRelationalMapperService.php#L77-L106 |
12,522 | detailnet/dfw-bernard | src/Detail/Bernard/Message/Messenger.php | Messenger.encodeMessage | public function encodeMessage($message, $queue)
{
$messageFactory = $this->getMessageFactory();
if (!$this->messageFactory->accepts($message)) {
throw new Exception\RuntimeException(
sprintf(
'%s does not accept message of type "%s"',
get_class($messageFactory),
(is_object($message) ? get_class($message) : gettype($message))
)
);
}
return new BernardDefaultMessage(
$queue,
array(
self::MESSAGE_CLASS_KEY => get_class($message),
self::MESSAGE_KEY => $this->getMessageFactory()->toArray($message),
)
);
} | php | public function encodeMessage($message, $queue)
{
$messageFactory = $this->getMessageFactory();
if (!$this->messageFactory->accepts($message)) {
throw new Exception\RuntimeException(
sprintf(
'%s does not accept message of type "%s"',
get_class($messageFactory),
(is_object($message) ? get_class($message) : gettype($message))
)
);
}
return new BernardDefaultMessage(
$queue,
array(
self::MESSAGE_CLASS_KEY => get_class($message),
self::MESSAGE_KEY => $this->getMessageFactory()->toArray($message),
)
);
} | [
"public",
"function",
"encodeMessage",
"(",
"$",
"message",
",",
"$",
"queue",
")",
"{",
"$",
"messageFactory",
"=",
"$",
"this",
"->",
"getMessageFactory",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"messageFactory",
"->",
"accepts",
"(",
"$",
"message",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'%s does not accept message of type \"%s\"'",
",",
"get_class",
"(",
"$",
"messageFactory",
")",
",",
"(",
"is_object",
"(",
"$",
"message",
")",
"?",
"get_class",
"(",
"$",
"message",
")",
":",
"gettype",
"(",
"$",
"message",
")",
")",
")",
")",
";",
"}",
"return",
"new",
"BernardDefaultMessage",
"(",
"$",
"queue",
",",
"array",
"(",
"self",
"::",
"MESSAGE_CLASS_KEY",
"=>",
"get_class",
"(",
"$",
"message",
")",
",",
"self",
"::",
"MESSAGE_KEY",
"=>",
"$",
"this",
"->",
"getMessageFactory",
"(",
")",
"->",
"toArray",
"(",
"$",
"message",
")",
",",
")",
")",
";",
"}"
] | Encode message for Bernard.
@param mixed $message
@param string $queue
@throws Exception\RuntimeException
@return BernardDefaultMessage | [
"Encode",
"message",
"for",
"Bernard",
"."
] | 44fc049b4392095ba328fafb49012c136edb56c8 | https://github.com/detailnet/dfw-bernard/blob/44fc049b4392095ba328fafb49012c136edb56c8/src/Detail/Bernard/Message/Messenger.php#L133-L154 |
12,523 | detailnet/dfw-bernard | src/Detail/Bernard/Message/Messenger.php | Messenger.decodeMessage | public function decodeMessage(BernardMessage $message)
{
if (!isset($message->{self::MESSAGE_CLASS_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message is missing key "%s"', self::MESSAGE_CLASS_KEY)
);
}
if (!is_string($message->{self::MESSAGE_CLASS_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message has invalid value for key "%s"; must be a string', self::MESSAGE_CLASS_KEY)
);
}
if (!isset($message->{self::MESSAGE_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message is missing key "%s"', self::MESSAGE_KEY)
);
}
if (!is_array($message->{self::MESSAGE_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message has invalid value for key "%s"; must be an array', self::MESSAGE_KEY)
);
}
return $this->getMessageFactory()->createFromArray(
$message->{self::MESSAGE_KEY},
$message->{self::MESSAGE_CLASS_KEY}
);
} | php | public function decodeMessage(BernardMessage $message)
{
if (!isset($message->{self::MESSAGE_CLASS_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message is missing key "%s"', self::MESSAGE_CLASS_KEY)
);
}
if (!is_string($message->{self::MESSAGE_CLASS_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message has invalid value for key "%s"; must be a string', self::MESSAGE_CLASS_KEY)
);
}
if (!isset($message->{self::MESSAGE_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message is missing key "%s"', self::MESSAGE_KEY)
);
}
if (!is_array($message->{self::MESSAGE_KEY})) {
throw new Exception\RuntimeException(
sprintf('Message has invalid value for key "%s"; must be an array', self::MESSAGE_KEY)
);
}
return $this->getMessageFactory()->createFromArray(
$message->{self::MESSAGE_KEY},
$message->{self::MESSAGE_CLASS_KEY}
);
} | [
"public",
"function",
"decodeMessage",
"(",
"BernardMessage",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"message",
"->",
"{",
"self",
"::",
"MESSAGE_CLASS_KEY",
"}",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Message is missing key \"%s\"'",
",",
"self",
"::",
"MESSAGE_CLASS_KEY",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"message",
"->",
"{",
"self",
"::",
"MESSAGE_CLASS_KEY",
"}",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Message has invalid value for key \"%s\"; must be a string'",
",",
"self",
"::",
"MESSAGE_CLASS_KEY",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"message",
"->",
"{",
"self",
"::",
"MESSAGE_KEY",
"}",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Message is missing key \"%s\"'",
",",
"self",
"::",
"MESSAGE_KEY",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"message",
"->",
"{",
"self",
"::",
"MESSAGE_KEY",
"}",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Message has invalid value for key \"%s\"; must be an array'",
",",
"self",
"::",
"MESSAGE_KEY",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getMessageFactory",
"(",
")",
"->",
"createFromArray",
"(",
"$",
"message",
"->",
"{",
"self",
"::",
"MESSAGE_KEY",
"}",
",",
"$",
"message",
"->",
"{",
"self",
"::",
"MESSAGE_CLASS_KEY",
"}",
")",
";",
"}"
] | Decode message from Bernard.
@param BernardMessage $message
@return mixed
@throws Exception\RuntimeException | [
"Decode",
"message",
"from",
"Bernard",
"."
] | 44fc049b4392095ba328fafb49012c136edb56c8 | https://github.com/detailnet/dfw-bernard/blob/44fc049b4392095ba328fafb49012c136edb56c8/src/Detail/Bernard/Message/Messenger.php#L163-L193 |
12,524 | dmitrymomot/slim-mvc | src/Controller.php | Controller.param | public function param($key = NULL, $default = NULL)
{
$params = $this->app->router->getCurrentRoute()->getParams();
return (array_key_exists($key, $params))
? $params[$key]
: $default;
} | php | public function param($key = NULL, $default = NULL)
{
$params = $this->app->router->getCurrentRoute()->getParams();
return (array_key_exists($key, $params))
? $params[$key]
: $default;
} | [
"public",
"function",
"param",
"(",
"$",
"key",
"=",
"NULL",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"app",
"->",
"router",
"->",
"getCurrentRoute",
"(",
")",
"->",
"getParams",
"(",
")",
";",
"return",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"params",
")",
")",
"?",
"$",
"params",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}"
] | Gets route params
@param string $key
@param string $default
@return string | [
"Gets",
"route",
"params"
] | 432f694bc7263204e09a1261177d5df84353a8af | https://github.com/dmitrymomot/slim-mvc/blob/432f694bc7263204e09a1261177d5df84353a8af/src/Controller.php#L79-L86 |
12,525 | znframework/package-image | ImageTypeCreator.php | ImageTypeCreator.create | public static function create($files, $path, $quality = 0)
{
switch( self::getFileExtension($path) )
{
case 'png' :
if( $quality > 10 )
{
$quality = (int) ($quality / 10);
}
return imagepng($files, $path, $quality ?: 8 );
case 'gif' : return imagegif($files, $path);
case 'jpg' :
case 'jpeg':
default : return imagejpeg($files, $path, $quality ?: 80);
}
} | php | public static function create($files, $path, $quality = 0)
{
switch( self::getFileExtension($path) )
{
case 'png' :
if( $quality > 10 )
{
$quality = (int) ($quality / 10);
}
return imagepng($files, $path, $quality ?: 8 );
case 'gif' : return imagegif($files, $path);
case 'jpg' :
case 'jpeg':
default : return imagejpeg($files, $path, $quality ?: 80);
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"files",
",",
"$",
"path",
",",
"$",
"quality",
"=",
"0",
")",
"{",
"switch",
"(",
"self",
"::",
"getFileExtension",
"(",
"$",
"path",
")",
")",
"{",
"case",
"'png'",
":",
"if",
"(",
"$",
"quality",
">",
"10",
")",
"{",
"$",
"quality",
"=",
"(",
"int",
")",
"(",
"$",
"quality",
"/",
"10",
")",
";",
"}",
"return",
"imagepng",
"(",
"$",
"files",
",",
"$",
"path",
",",
"$",
"quality",
"?",
":",
"8",
")",
";",
"case",
"'gif'",
":",
"return",
"imagegif",
"(",
"$",
"files",
",",
"$",
"path",
")",
";",
"case",
"'jpg'",
":",
"case",
"'jpeg'",
":",
"default",
":",
"return",
"imagejpeg",
"(",
"$",
"files",
",",
"$",
"path",
",",
"$",
"quality",
"?",
":",
"80",
")",
";",
"}",
"}"
] | Image type creator
@param resources $files
@param string $path
@param int $quality = 0
@return bool | [
"Image",
"type",
"creator"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/ImageTypeCreator.php#L25-L40 |
12,526 | znframework/package-image | ImageTypeCreator.php | ImageTypeCreator.from | public static function from($path)
{
switch( self::getFileExtension($path) )
{
case 'png' : return imagecreatefrompng($path);
case 'gif' : return imagecreatefromgif($path);
case 'jpg' :
case 'jpeg':
default : return imagecreatefromjpeg($path);
}
} | php | public static function from($path)
{
switch( self::getFileExtension($path) )
{
case 'png' : return imagecreatefrompng($path);
case 'gif' : return imagecreatefromgif($path);
case 'jpg' :
case 'jpeg':
default : return imagecreatefromjpeg($path);
}
} | [
"public",
"static",
"function",
"from",
"(",
"$",
"path",
")",
"{",
"switch",
"(",
"self",
"::",
"getFileExtension",
"(",
"$",
"path",
")",
")",
"{",
"case",
"'png'",
":",
"return",
"imagecreatefrompng",
"(",
"$",
"path",
")",
";",
"case",
"'gif'",
":",
"return",
"imagecreatefromgif",
"(",
"$",
"path",
")",
";",
"case",
"'jpg'",
":",
"case",
"'jpeg'",
":",
"default",
":",
"return",
"imagecreatefromjpeg",
"(",
"$",
"path",
")",
";",
"}",
"}"
] | Image create from | [
"Image",
"create",
"from"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/ImageTypeCreator.php#L45-L55 |
12,527 | keeko/api-app | src/ApiApplication.php | ApiApplication.postProcessing | private function postProcessing(JsonResponse $response) {
$apiUrl = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences()->getApiUrl();
$response->setContent(str_replace('%apiurl%', $apiUrl, $response->getContent()));
return $response;
} | php | private function postProcessing(JsonResponse $response) {
$apiUrl = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences()->getApiUrl();
$response->setContent(str_replace('%apiurl%', $apiUrl, $response->getContent()));
return $response;
} | [
"private",
"function",
"postProcessing",
"(",
"JsonResponse",
"$",
"response",
")",
"{",
"$",
"apiUrl",
"=",
"$",
"this",
"->",
"getServiceContainer",
"(",
")",
"->",
"getPreferenceLoader",
"(",
")",
"->",
"getSystemPreferences",
"(",
")",
"->",
"getApiUrl",
"(",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"str_replace",
"(",
"'%apiurl%'",
",",
"$",
"apiUrl",
",",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Some post processing on the generated result. Replacing some variables.
@param JsonResponse $response
@return JsonResponse | [
"Some",
"post",
"processing",
"on",
"the",
"generated",
"result",
".",
"Replacing",
"some",
"variables",
"."
] | 245f9e64777005518894c5ec93a7f9ce9ab28bfb | https://github.com/keeko/api-app/blob/245f9e64777005518894c5ec93a7f9ce9ab28bfb/src/ApiApplication.php#L92-L96 |
12,528 | rseyferth/activerecord | lib/Config.php | Config.setConnections | public function setConnections($connections, $defaultConnection=null)
{
if (!is_array($connections)) {
throw new ConfigException("Connections must be an array");
}
if ($defaultConnection) {
$this->setDefaultConnection($defaultConnection);
}
// Store it!
$this->_connections = $connections;
} | php | public function setConnections($connections, $defaultConnection=null)
{
if (!is_array($connections)) {
throw new ConfigException("Connections must be an array");
}
if ($defaultConnection) {
$this->setDefaultConnection($defaultConnection);
}
// Store it!
$this->_connections = $connections;
} | [
"public",
"function",
"setConnections",
"(",
"$",
"connections",
",",
"$",
"defaultConnection",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"connections",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"Connections must be an array\"",
")",
";",
"}",
"if",
"(",
"$",
"defaultConnection",
")",
"{",
"$",
"this",
"->",
"setDefaultConnection",
"(",
"$",
"defaultConnection",
")",
";",
"}",
"// Store it!",
"$",
"this",
"->",
"_connections",
"=",
"$",
"connections",
";",
"}"
] | Sets the list of database connection strings.
<code>
$config->setConnections(array(
'development' => 'mysql://username:[email protected]/database_name'));
</code>
@param array Array of connections
@param string Optionally specify the default_connection
@return void
@throws ActiveRecord\ConfigException | [
"Sets",
"the",
"list",
"of",
"database",
"connection",
"strings",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Config.php#L125-L138 |
12,529 | rseyferth/activerecord | lib/Config.php | Config.getConnection | public function getConnection($name)
{
if (array_key_exists($name, $this->_connections))
return $this->_connections[$name];
return null;
} | php | public function getConnection($name)
{
if (array_key_exists($name, $this->_connections))
return $this->_connections[$name];
return null;
} | [
"public",
"function",
"getConnection",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_connections",
")",
")",
"return",
"$",
"this",
"->",
"_connections",
"[",
"$",
"name",
"]",
";",
"return",
"null",
";",
"}"
] | Returns a connection string if found otherwise null.
@param string $name Name of connection to retrieve
@return string connection info for specified connection name | [
"Returns",
"a",
"connection",
"string",
"if",
"found",
"otherwise",
"null",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Config.php#L156-L162 |
12,530 | rseyferth/activerecord | lib/Config.php | Config.getDefaultConnectionString | public function getDefaultConnectionString()
{
return array_key_exists($this->_defaultConnection, $this->_connections) ?
$this->_connections[$this->_defaultConnection] : null;
} | php | public function getDefaultConnectionString()
{
return array_key_exists($this->_defaultConnection, $this->_connections) ?
$this->_connections[$this->_defaultConnection] : null;
} | [
"public",
"function",
"getDefaultConnectionString",
"(",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"this",
"->",
"_defaultConnection",
",",
"$",
"this",
"->",
"_connections",
")",
"?",
"$",
"this",
"->",
"_connections",
"[",
"$",
"this",
"->",
"_defaultConnection",
"]",
":",
"null",
";",
"}"
] | Returns the default connection string or null if there is none.
@return string | [
"Returns",
"the",
"default",
"connection",
"string",
"or",
"null",
"if",
"there",
"is",
"none",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Config.php#L169-L173 |
12,531 | rseyferth/activerecord | lib/Config.php | Config.getModelDirectory | public function getModelDirectory()
{
if ($this->_modelDirectory && !file_exists($this->_modelDirectory))
throw new ConfigException('Invalid or non-existent directory: '.$this->_modelDirectory);
return $this->_modelDirectory;
} | php | public function getModelDirectory()
{
if ($this->_modelDirectory && !file_exists($this->_modelDirectory))
throw new ConfigException('Invalid or non-existent directory: '.$this->_modelDirectory);
return $this->_modelDirectory;
} | [
"public",
"function",
"getModelDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_modelDirectory",
"&&",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"_modelDirectory",
")",
")",
"throw",
"new",
"ConfigException",
"(",
"'Invalid or non-existent directory: '",
".",
"$",
"this",
"->",
"_modelDirectory",
")",
";",
"return",
"$",
"this",
"->",
"_modelDirectory",
";",
"}"
] | Returns the model directory.
@return string
@throws ConfigException if specified directory was not found | [
"Returns",
"the",
"model",
"directory",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Config.php#L213-L219 |
12,532 | wpplex/wp-mvc | Admin/Controller.php | Controller.add_menu | public function add_menu() {
if ( !isset( $this->page_id ) && !isset( $this->title ) && !isset( $this->name ) && !isset( $this->parent ) && !isset( $this->cap ) ) {
return;
}
if ( $this->parent ) {
$this->screen_name = add_submenu_page( $this->parent, $this->title, $this->name, $this->cap, $this->page_id, array( &$this, 'render_page' ) );
} else {
$this->screen_name = add_menu_page( $this->title, $this->name, $this->cap, $this->page_id, array( &$this, 'render_page' ) );
}
} | php | public function add_menu() {
if ( !isset( $this->page_id ) && !isset( $this->title ) && !isset( $this->name ) && !isset( $this->parent ) && !isset( $this->cap ) ) {
return;
}
if ( $this->parent ) {
$this->screen_name = add_submenu_page( $this->parent, $this->title, $this->name, $this->cap, $this->page_id, array( &$this, 'render_page' ) );
} else {
$this->screen_name = add_menu_page( $this->title, $this->name, $this->cap, $this->page_id, array( &$this, 'render_page' ) );
}
} | [
"public",
"function",
"add_menu",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"page_id",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"title",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"name",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"parent",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"cap",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"parent",
")",
"{",
"$",
"this",
"->",
"screen_name",
"=",
"add_submenu_page",
"(",
"$",
"this",
"->",
"parent",
",",
"$",
"this",
"->",
"title",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"cap",
",",
"$",
"this",
"->",
"page_id",
",",
"array",
"(",
"&",
"$",
"this",
",",
"'render_page'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"screen_name",
"=",
"add_menu_page",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"cap",
",",
"$",
"this",
"->",
"page_id",
",",
"array",
"(",
"&",
"$",
"this",
",",
"'render_page'",
")",
")",
";",
"}",
"}"
] | Add the Admin PAge to the WordPress Menu
@return void | [
"Add",
"the",
"Admin",
"PAge",
"to",
"the",
"WordPress",
"Menu"
] | 9778379d42f949462e76d969fb45ec37fc789a75 | https://github.com/wpplex/wp-mvc/blob/9778379d42f949462e76d969fb45ec37fc789a75/Admin/Controller.php#L95-L105 |
12,533 | wpplex/wp-mvc | Admin/Controller.php | Controller.validate_screen | public function validate_screen() {
$screen = get_current_screen();
if ( $screen->id === $this->screen_name ) {
// Load the Page resources
add_action( 'admin_print_scripts', array( &$this, 'load_scripts' ) );
add_action( 'admin_print_styles', array( &$this, 'load_styles' ) );
// WordPress Contextual Help
add_filter( 'contextual_help', array( &$this, 'contextual_help' ) );
// Load the Model File
require_once( WPBP_DIR . '/app/models/admin/' . $this->page_id . '.php' );
// Load the View File
require_once( WPBP_DIR . '/app/views/admin/' . $this->page_id . '.php' );
// Initialize the model
$this->model = new $this->model();
// Initialize the view
$this->view = new $this->view( $this->model->get_data() );
$this->view->controller = $this;
// Process GET requests
$this->process_get();
// Process POST requests
$this->process_post();
$this->init();
}
} | php | public function validate_screen() {
$screen = get_current_screen();
if ( $screen->id === $this->screen_name ) {
// Load the Page resources
add_action( 'admin_print_scripts', array( &$this, 'load_scripts' ) );
add_action( 'admin_print_styles', array( &$this, 'load_styles' ) );
// WordPress Contextual Help
add_filter( 'contextual_help', array( &$this, 'contextual_help' ) );
// Load the Model File
require_once( WPBP_DIR . '/app/models/admin/' . $this->page_id . '.php' );
// Load the View File
require_once( WPBP_DIR . '/app/views/admin/' . $this->page_id . '.php' );
// Initialize the model
$this->model = new $this->model();
// Initialize the view
$this->view = new $this->view( $this->model->get_data() );
$this->view->controller = $this;
// Process GET requests
$this->process_get();
// Process POST requests
$this->process_post();
$this->init();
}
} | [
"public",
"function",
"validate_screen",
"(",
")",
"{",
"$",
"screen",
"=",
"get_current_screen",
"(",
")",
";",
"if",
"(",
"$",
"screen",
"->",
"id",
"===",
"$",
"this",
"->",
"screen_name",
")",
"{",
"// Load the Page resources",
"add_action",
"(",
"'admin_print_scripts'",
",",
"array",
"(",
"&",
"$",
"this",
",",
"'load_scripts'",
")",
")",
";",
"add_action",
"(",
"'admin_print_styles'",
",",
"array",
"(",
"&",
"$",
"this",
",",
"'load_styles'",
")",
")",
";",
"// WordPress Contextual Help",
"add_filter",
"(",
"'contextual_help'",
",",
"array",
"(",
"&",
"$",
"this",
",",
"'contextual_help'",
")",
")",
";",
"// Load the Model File",
"require_once",
"(",
"WPBP_DIR",
".",
"'/app/models/admin/'",
".",
"$",
"this",
"->",
"page_id",
".",
"'.php'",
")",
";",
"// Load the View File",
"require_once",
"(",
"WPBP_DIR",
".",
"'/app/views/admin/'",
".",
"$",
"this",
"->",
"page_id",
".",
"'.php'",
")",
";",
"// Initialize the model",
"$",
"this",
"->",
"model",
"=",
"new",
"$",
"this",
"->",
"model",
"(",
")",
";",
"// Initialize the view",
"$",
"this",
"->",
"view",
"=",
"new",
"$",
"this",
"->",
"view",
"(",
"$",
"this",
"->",
"model",
"->",
"get_data",
"(",
")",
")",
";",
"$",
"this",
"->",
"view",
"->",
"controller",
"=",
"$",
"this",
";",
"// Process GET requests",
"$",
"this",
"->",
"process_get",
"(",
")",
";",
"// Process POST requests",
"$",
"this",
"->",
"process_post",
"(",
")",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"}",
"}"
] | Verify that we are on the correct screen
@return void | [
"Verify",
"that",
"we",
"are",
"on",
"the",
"correct",
"screen"
] | 9778379d42f949462e76d969fb45ec37fc789a75 | https://github.com/wpplex/wp-mvc/blob/9778379d42f949462e76d969fb45ec37fc789a75/Admin/Controller.php#L112-L142 |
12,534 | octris/db | libs/Db/Type/DataObject.php | DataObject.merge | public function merge(array $data)
{
if (array_key_exists('_id', $data)) {
throw new \Exception('Property "_id" is read-only');
} else {
$this->import($data);
parent::merge($data);
}
} | php | public function merge(array $data)
{
if (array_key_exists('_id', $data)) {
throw new \Exception('Property "_id" is read-only');
} else {
$this->import($data);
parent::merge($data);
}
} | [
"public",
"function",
"merge",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'_id'",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Property \"_id\" is read-only'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"import",
"(",
"$",
"data",
")",
";",
"parent",
"::",
"merge",
"(",
"$",
"data",
")",
";",
"}",
"}"
] | Merge specified data into dataobject. Note, that the method will throw an exception, if the data to
merge contains a new object ID.
@param array $data Data to merge. | [
"Merge",
"specified",
"data",
"into",
"dataobject",
".",
"Note",
"that",
"the",
"method",
"will",
"throw",
"an",
"exception",
"if",
"the",
"data",
"to",
"merge",
"contains",
"a",
"new",
"object",
"ID",
"."
] | d34d143ea057e3912c7d4113662ebdb8dfd061c7 | https://github.com/octris/db/blob/d34d143ea057e3912c7d4113662ebdb8dfd061c7/libs/Db/Type/DataObject.php#L85-L94 |
12,535 | octris/db | libs/Db/Type/DataObject.php | DataObject.save | public function save($new_key = null)
{
$return = true;
$cn = $this->device->getConnection(\Octris\Db::DB_MASTER);
$cl = $cn->getCollection($this->collection);
if (is_null($this->_id) || (!is_null($new_key) && $this->_id !== $new_key)) {
// insert new object
if (($return = !!($new_key = $cl->insert($this, $new_key)))) {
$this->_id = $new_key;
}
} else {
// update object
$return = $cl->update($this, $this->_id);
}
$cn->release();
return $return;
} | php | public function save($new_key = null)
{
$return = true;
$cn = $this->device->getConnection(\Octris\Db::DB_MASTER);
$cl = $cn->getCollection($this->collection);
if (is_null($this->_id) || (!is_null($new_key) && $this->_id !== $new_key)) {
// insert new object
if (($return = !!($new_key = $cl->insert($this, $new_key)))) {
$this->_id = $new_key;
}
} else {
// update object
$return = $cl->update($this, $this->_id);
}
$cn->release();
return $return;
} | [
"public",
"function",
"save",
"(",
"$",
"new_key",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"true",
";",
"$",
"cn",
"=",
"$",
"this",
"->",
"device",
"->",
"getConnection",
"(",
"\\",
"Octris",
"\\",
"Db",
"::",
"DB_MASTER",
")",
";",
"$",
"cl",
"=",
"$",
"cn",
"->",
"getCollection",
"(",
"$",
"this",
"->",
"collection",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_id",
")",
"||",
"(",
"!",
"is_null",
"(",
"$",
"new_key",
")",
"&&",
"$",
"this",
"->",
"_id",
"!==",
"$",
"new_key",
")",
")",
"{",
"// insert new object",
"if",
"(",
"(",
"$",
"return",
"=",
"!",
"!",
"(",
"$",
"new_key",
"=",
"$",
"cl",
"->",
"insert",
"(",
"$",
"this",
",",
"$",
"new_key",
")",
")",
")",
")",
"{",
"$",
"this",
"->",
"_id",
"=",
"$",
"new_key",
";",
"}",
"}",
"else",
"{",
"// update object",
"$",
"return",
"=",
"$",
"cl",
"->",
"update",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"_id",
")",
";",
"}",
"$",
"cn",
"->",
"release",
"(",
")",
";",
"return",
"$",
"return",
";",
"}"
] | Save dataobject to bucket.
@param string $new_key Force inserting with the specified key. The method will fall back to an update,
if the specified key and the object internal key are identically.
@return bool Returns true on success otherwise false. | [
"Save",
"dataobject",
"to",
"bucket",
"."
] | d34d143ea057e3912c7d4113662ebdb8dfd061c7 | https://github.com/octris/db/blob/d34d143ea057e3912c7d4113662ebdb8dfd061c7/libs/Db/Type/DataObject.php#L103-L123 |
12,536 | octris/db | libs/Db/Type/DataObject.php | DataObject.export | protected function export(array &$data)
{
array_walk_recursive($data, function (&$value, $name) {
$value = $this->castPhpToDb($value, $name);
});
} | php | protected function export(array &$data)
{
array_walk_recursive($data, function (&$value, $name) {
$value = $this->castPhpToDb($value, $name);
});
} | [
"protected",
"function",
"export",
"(",
"array",
"&",
"$",
"data",
")",
"{",
"array_walk_recursive",
"(",
"$",
"data",
",",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"castPhpToDb",
"(",
"$",
"value",
",",
"$",
"name",
")",
";",
"}",
")",
";",
"}"
] | Recursive data iteration and casting for preparing data for export to database.
@param array $data Data to process. | [
"Recursive",
"data",
"iteration",
"and",
"casting",
"for",
"preparing",
"data",
"for",
"export",
"to",
"database",
"."
] | d34d143ea057e3912c7d4113662ebdb8dfd061c7 | https://github.com/octris/db/blob/d34d143ea057e3912c7d4113662ebdb8dfd061c7/libs/Db/Type/DataObject.php#L196-L201 |
12,537 | octris/db | libs/Db/Type/DataObject.php | DataObject.import | protected function import(array &$data)
{
array_walk_recursive($data, function (&$value, $name) {
$value = $this->castDbToPhp($value, $name);
});
} | php | protected function import(array &$data)
{
array_walk_recursive($data, function (&$value, $name) {
$value = $this->castDbToPhp($value, $name);
});
} | [
"protected",
"function",
"import",
"(",
"array",
"&",
"$",
"data",
")",
"{",
"array_walk_recursive",
"(",
"$",
"data",
",",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"castDbToPhp",
"(",
"$",
"value",
",",
"$",
"name",
")",
";",
"}",
")",
";",
"}"
] | Recursive data iteration and casting for preparing data for import into dataobject.
@param array $data Data to process. | [
"Recursive",
"data",
"iteration",
"and",
"casting",
"for",
"preparing",
"data",
"for",
"import",
"into",
"dataobject",
"."
] | d34d143ea057e3912c7d4113662ebdb8dfd061c7 | https://github.com/octris/db/blob/d34d143ea057e3912c7d4113662ebdb8dfd061c7/libs/Db/Type/DataObject.php#L208-L213 |
12,538 | felixarntz/config | src/ConfigAwareTrait.php | ConfigAwareTrait.setConfig | protected function setConfig(Config $config, ConfigSchema $schema = null)
{
if ($schema) {
$schema->validate($config);
}
$config->validate();
$this->config = $config;
} | php | protected function setConfig(Config $config, ConfigSchema $schema = null)
{
if ($schema) {
$schema->validate($config);
}
$config->validate();
$this->config = $config;
} | [
"protected",
"function",
"setConfig",
"(",
"Config",
"$",
"config",
",",
"ConfigSchema",
"$",
"schema",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"schema",
")",
"{",
"$",
"schema",
"->",
"validate",
"(",
"$",
"config",
")",
";",
"}",
"$",
"config",
"->",
"validate",
"(",
")",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"config",
";",
"}"
] | Validates and sets the configuration object.
@since 1.0.0
@param Config $config Configuration object.
@param ConfigSchema|null $schema Optional. Extra configuration schema to validate the configuration object
against. Default null.
@throws ConfigValidationException Thrown when validation fails. | [
"Validates",
"and",
"sets",
"the",
"configuration",
"object",
"."
] | 7e4d6041927974800f850336a51e5dad11b4bdd8 | https://github.com/felixarntz/config/blob/7e4d6041927974800f850336a51e5dad11b4bdd8/src/ConfigAwareTrait.php#L42-L51 |
12,539 | tweedegolf/generator | src/TweedeGolf/Generator/Action/TemplateAction.php | TemplateAction.getTemplateContent | public function getTemplateContent($template, array $variables)
{
$dir = dirname($template);
$file = basename($template);
$twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array($dir)), array(
'debug' => true,
'cache' => false,
'strict_variables' => true,
'autoescape' => false,
));
return $twig->render($file, $variables);
} | php | public function getTemplateContent($template, array $variables)
{
$dir = dirname($template);
$file = basename($template);
$twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array($dir)), array(
'debug' => true,
'cache' => false,
'strict_variables' => true,
'autoescape' => false,
));
return $twig->render($file, $variables);
} | [
"public",
"function",
"getTemplateContent",
"(",
"$",
"template",
",",
"array",
"$",
"variables",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"template",
")",
";",
"$",
"file",
"=",
"basename",
"(",
"$",
"template",
")",
";",
"$",
"twig",
"=",
"new",
"\\",
"Twig_Environment",
"(",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
"array",
"(",
"$",
"dir",
")",
")",
",",
"array",
"(",
"'debug'",
"=>",
"true",
",",
"'cache'",
"=>",
"false",
",",
"'strict_variables'",
"=>",
"true",
",",
"'autoescape'",
"=>",
"false",
",",
")",
")",
";",
"return",
"$",
"twig",
"->",
"render",
"(",
"$",
"file",
",",
"$",
"variables",
")",
";",
"}"
] | Return the rendered content of a template.
@param string $template
@param array $variables
@return string | [
"Return",
"the",
"rendered",
"content",
"of",
"a",
"template",
"."
] | f931d659ddf6a531ebf00bbfc11d417c527cd21b | https://github.com/tweedegolf/generator/blob/f931d659ddf6a531ebf00bbfc11d417c527cd21b/src/TweedeGolf/Generator/Action/TemplateAction.php#L51-L63 |
12,540 | anonymous-php/containers | src/NestedContainer.php | NestedContainer.setHasCache | protected function setHasCache($id, $value)
{
if (!$this->useHasCache) {
return true;
}
unset($this->hasCache[$id]);
$this->hasCache[$id] = $value;
if (count($this->hasCache) > $this->hasCacheLength) {
$this->hasCache = array_slice($this->hasCache, -$this->hasCacheLength, null, true);
}
return true;
} | php | protected function setHasCache($id, $value)
{
if (!$this->useHasCache) {
return true;
}
unset($this->hasCache[$id]);
$this->hasCache[$id] = $value;
if (count($this->hasCache) > $this->hasCacheLength) {
$this->hasCache = array_slice($this->hasCache, -$this->hasCacheLength, null, true);
}
return true;
} | [
"protected",
"function",
"setHasCache",
"(",
"$",
"id",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"useHasCache",
")",
"{",
"return",
"true",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"hasCache",
"[",
"$",
"id",
"]",
")",
";",
"$",
"this",
"->",
"hasCache",
"[",
"$",
"id",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"hasCache",
")",
">",
"$",
"this",
"->",
"hasCacheLength",
")",
"{",
"$",
"this",
"->",
"hasCache",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"hasCache",
",",
"-",
"$",
"this",
"->",
"hasCacheLength",
",",
"null",
",",
"true",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Stores index of the container to the cache
@param $id
@param $value
@return bool | [
"Stores",
"index",
"of",
"the",
"container",
"to",
"the",
"cache"
] | c16275f05f14d188cf4d3043e7f037aea40aa7ba | https://github.com/anonymous-php/containers/blob/c16275f05f14d188cf4d3043e7f037aea40aa7ba/src/NestedContainer.php#L130-L144 |
12,541 | anonymous-php/containers | src/NestedContainer.php | NestedContainer.getHasCache | protected function getHasCache($id)
{
return $this->useHasCache && array_key_exists($id, $this->hasCache)
? $this->hasCache[$id]
: false;
} | php | protected function getHasCache($id)
{
return $this->useHasCache && array_key_exists($id, $this->hasCache)
? $this->hasCache[$id]
: false;
} | [
"protected",
"function",
"getHasCache",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"useHasCache",
"&&",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"hasCache",
")",
"?",
"$",
"this",
"->",
"hasCache",
"[",
"$",
"id",
"]",
":",
"false",
";",
"}"
] | Gets index of the container from the cache
@param $id
@return bool|mixed | [
"Gets",
"index",
"of",
"the",
"container",
"from",
"the",
"cache"
] | c16275f05f14d188cf4d3043e7f037aea40aa7ba | https://github.com/anonymous-php/containers/blob/c16275f05f14d188cf4d3043e7f037aea40aa7ba/src/NestedContainer.php#L151-L156 |
12,542 | anonymous-php/containers | src/NestedContainer.php | NestedContainer.add | public function add(ContainerInterface $container, $name = null)
{
if ($name !== null) {
$this->containers[$name] = $container;
} else {
array_push($this->containers, $container);
}
} | php | public function add(ContainerInterface $container, $name = null)
{
if ($name !== null) {
$this->containers[$name] = $container;
} else {
array_push($this->containers, $container);
}
} | [
"public",
"function",
"add",
"(",
"ContainerInterface",
"$",
"container",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"containers",
"[",
"$",
"name",
"]",
"=",
"$",
"container",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"containers",
",",
"$",
"container",
")",
";",
"}",
"}"
] | Adds container to the collection
@param ContainerInterface $container
@param string $name | [
"Adds",
"container",
"to",
"the",
"collection"
] | c16275f05f14d188cf4d3043e7f037aea40aa7ba | https://github.com/anonymous-php/containers/blob/c16275f05f14d188cf4d3043e7f037aea40aa7ba/src/NestedContainer.php#L163-L170 |
12,543 | anonymous-php/containers | src/NestedContainer.php | NestedContainer.addPrepend | public function addPrepend(ContainerInterface $container, $name = null)
{
if ($name !== null) {
unset($this->containers[$name]);
$this->containers = array_merge([$name => $container], $this->containers);
} else {
array_unshift($this->containers, $container);
}
} | php | public function addPrepend(ContainerInterface $container, $name = null)
{
if ($name !== null) {
unset($this->containers[$name]);
$this->containers = array_merge([$name => $container], $this->containers);
} else {
array_unshift($this->containers, $container);
}
} | [
"public",
"function",
"addPrepend",
"(",
"ContainerInterface",
"$",
"container",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"containers",
"[",
"$",
"name",
"]",
")",
";",
"$",
"this",
"->",
"containers",
"=",
"array_merge",
"(",
"[",
"$",
"name",
"=>",
"$",
"container",
"]",
",",
"$",
"this",
"->",
"containers",
")",
";",
"}",
"else",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"containers",
",",
"$",
"container",
")",
";",
"}",
"}"
] | Adds container to the beginning of the collection
@param ContainerInterface $container
@param string $name | [
"Adds",
"container",
"to",
"the",
"beginning",
"of",
"the",
"collection"
] | c16275f05f14d188cf4d3043e7f037aea40aa7ba | https://github.com/anonymous-php/containers/blob/c16275f05f14d188cf4d3043e7f037aea40aa7ba/src/NestedContainer.php#L187-L195 |
12,544 | anonymous-php/containers | src/NestedContainer.php | NestedContainer.getContainer | public function getContainer($name)
{
if (!array_key_exists($name, $this->containers)) {
throw new ContainerNotFoundException("No container with name '{$name}' found");
}
return $this->containers[$name];
} | php | public function getContainer($name)
{
if (!array_key_exists($name, $this->containers)) {
throw new ContainerNotFoundException("No container with name '{$name}' found");
}
return $this->containers[$name];
} | [
"public",
"function",
"getContainer",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"containers",
")",
")",
"{",
"throw",
"new",
"ContainerNotFoundException",
"(",
"\"No container with name '{$name}' found\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"containers",
"[",
"$",
"name",
"]",
";",
"}"
] | Gets named container
@param $name
@return ContainerInterface
@throws ContainerNotFoundException | [
"Gets",
"named",
"container"
] | c16275f05f14d188cf4d3043e7f037aea40aa7ba | https://github.com/anonymous-php/containers/blob/c16275f05f14d188cf4d3043e7f037aea40aa7ba/src/NestedContainer.php#L203-L210 |
12,545 | anonymous-php/containers | src/NestedContainer.php | NestedContainer.setUseHasCache | public function setUseHasCache($useHasCache = true, $hasCacheLength = null)
{
$this->useHasCache = (bool)$useHasCache;
if ($hasCacheLength !== null) {
$this->hasCacheLength = (int)$hasCacheLength;
}
return $this;
} | php | public function setUseHasCache($useHasCache = true, $hasCacheLength = null)
{
$this->useHasCache = (bool)$useHasCache;
if ($hasCacheLength !== null) {
$this->hasCacheLength = (int)$hasCacheLength;
}
return $this;
} | [
"public",
"function",
"setUseHasCache",
"(",
"$",
"useHasCache",
"=",
"true",
",",
"$",
"hasCacheLength",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"useHasCache",
"=",
"(",
"bool",
")",
"$",
"useHasCache",
";",
"if",
"(",
"$",
"hasCacheLength",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"hasCacheLength",
"=",
"(",
"int",
")",
"$",
"hasCacheLength",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the property useHasCache and size of cache
@param bool $useHasCache
@param null $hasCacheLength
@return $this | [
"Sets",
"the",
"property",
"useHasCache",
"and",
"size",
"of",
"cache"
] | c16275f05f14d188cf4d3043e7f037aea40aa7ba | https://github.com/anonymous-php/containers/blob/c16275f05f14d188cf4d3043e7f037aea40aa7ba/src/NestedContainer.php#L218-L227 |
12,546 | cyruscollier/phpspec-php-mock | src/Runner/Maintainer/FunctionCollaboratorMaintainer.php | FunctionCollaboratorMaintainer.teardown | public function teardown(
ExampleNode $example,
Specification $context,
MatcherManager $matchers,
CollaboratorManager $collaborators
) {
if (!isset($this->collaborator)) return false;
$this->collaborator->checkProphetPredictions();
return true;
} | php | public function teardown(
ExampleNode $example,
Specification $context,
MatcherManager $matchers,
CollaboratorManager $collaborators
) {
if (!isset($this->collaborator)) return false;
$this->collaborator->checkProphetPredictions();
return true;
} | [
"public",
"function",
"teardown",
"(",
"ExampleNode",
"$",
"example",
",",
"Specification",
"$",
"context",
",",
"MatcherManager",
"$",
"matchers",
",",
"CollaboratorManager",
"$",
"collaborators",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"collaborator",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"collaborator",
"->",
"checkProphetPredictions",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Adds call to unmock all registered mocked functions
{@inheritDoc}
@see \PhpSpec\Runner\Maintainer\CollaboratorsMaintainer::teardown() | [
"Adds",
"call",
"to",
"unmock",
"all",
"registered",
"mocked",
"functions"
] | 30668b7dcaa6163c2f1277af50fafd96e7f20a25 | https://github.com/cyruscollier/phpspec-php-mock/blob/30668b7dcaa6163c2f1277af50fafd96e7f20a25/src/Runner/Maintainer/FunctionCollaboratorMaintainer.php#L62-L71 |
12,547 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Service/ProductOrderItemService.php | ProductOrderItemService.findAll | public function findAll($page = 1, $max = 50)
{
$offset = (($page - 1) * $max);
$productOrderItems = $this->productOrderItemRepository->findBy(array(), array(), $max, $offset);
return $productOrderItems;
} | php | public function findAll($page = 1, $max = 50)
{
$offset = (($page - 1) * $max);
$productOrderItems = $this->productOrderItemRepository->findBy(array(), array(), $max, $offset);
return $productOrderItems;
} | [
"public",
"function",
"findAll",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"max",
"=",
"50",
")",
"{",
"$",
"offset",
"=",
"(",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"max",
")",
";",
"$",
"productOrderItems",
"=",
"$",
"this",
"->",
"productOrderItemRepository",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
")",
",",
"$",
"max",
",",
"$",
"offset",
")",
";",
"return",
"$",
"productOrderItems",
";",
"}"
] | Find al ProductOrderItems with pagination options.
@param integer $page [description]
@param integer $max [description]
@return ArrayCollection ProductOrderItems. | [
"Find",
"al",
"ProductOrderItems",
"with",
"pagination",
"options",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderItemService.php#L35-L40 |
12,548 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Service/ProductOrderItemService.php | ProductOrderItemService.create | public function create(ProductOrderItem $productOrderItem)
{
$this->getEm()->persist($productOrderItem);
$this->getEm()->flush();
return $productOrderItem;
} | php | public function create(ProductOrderItem $productOrderItem)
{
$this->getEm()->persist($productOrderItem);
$this->getEm()->flush();
return $productOrderItem;
} | [
"public",
"function",
"create",
"(",
"ProductOrderItem",
"$",
"productOrderItem",
")",
"{",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"persist",
"(",
"$",
"productOrderItem",
")",
";",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"productOrderItem",
";",
"}"
] | Create a new ProductOrderItem.
@param ProductOrderItem $productOrderItem the productOrderItem instance.
@return ProductOrderItem the productOrderItem instance. | [
"Create",
"a",
"new",
"ProductOrderItem",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderItemService.php#L57-L63 |
12,549 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Service/ProductOrderItemService.php | ProductOrderItemService.save | public function save(ProductOrderItem $productOrderItem)
{
if (!$productOrderItem->getId()) {
$this->getEm()->persist($productOrderItem);
}
$this->getEm()->flush();
return $productOrderItem;
} | php | public function save(ProductOrderItem $productOrderItem)
{
if (!$productOrderItem->getId()) {
$this->getEm()->persist($productOrderItem);
}
$this->getEm()->flush();
return $productOrderItem;
} | [
"public",
"function",
"save",
"(",
"ProductOrderItem",
"$",
"productOrderItem",
")",
"{",
"if",
"(",
"!",
"$",
"productOrderItem",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"persist",
"(",
"$",
"productOrderItem",
")",
";",
"}",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"productOrderItem",
";",
"}"
] | Save or update ProductOrderItem.
@param ProductOrderItem $productOrderItem the productOrderItem instance.
@return ProductOrderItem the productOrderItem instance. | [
"Save",
"or",
"update",
"ProductOrderItem",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderItemService.php#L70-L78 |
12,550 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Service/ProductOrderItemService.php | ProductOrderItemService.delete | public function delete(ProductOrderItem $productOrderItem)
{
$this->getEm()->remove($productOrderItem);
$this->getEm()->flush();
} | php | public function delete(ProductOrderItem $productOrderItem)
{
$this->getEm()->remove($productOrderItem);
$this->getEm()->flush();
} | [
"public",
"function",
"delete",
"(",
"ProductOrderItem",
"$",
"productOrderItem",
")",
"{",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"remove",
"(",
"$",
"productOrderItem",
")",
";",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}"
] | Delete an ProductOrderItem.
@param ProductOrderItem $productOrderItem the productOrderItem instance. | [
"Delete",
"an",
"ProductOrderItem",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderItemService.php#L90-L94 |
12,551 | Flowpack/Flowpack.SingleSignOn.Client | Classes/Flowpack/SingleSignOn/Client/Command/SsoKeyCommandController.php | SsoKeyCommandController.exportPublicKeyCommand | public function exportPublicKeyCommand($publicKeyFingerprint) {
$publicKey = $this->rsaWalletService->getPublicKey($publicKeyFingerprint);
$this->output($publicKey->getKeyString());
} | php | public function exportPublicKeyCommand($publicKeyFingerprint) {
$publicKey = $this->rsaWalletService->getPublicKey($publicKeyFingerprint);
$this->output($publicKey->getKeyString());
} | [
"public",
"function",
"exportPublicKeyCommand",
"(",
"$",
"publicKeyFingerprint",
")",
"{",
"$",
"publicKey",
"=",
"$",
"this",
"->",
"rsaWalletService",
"->",
"getPublicKey",
"(",
"$",
"publicKeyFingerprint",
")",
";",
"$",
"this",
"->",
"output",
"(",
"$",
"publicKey",
"->",
"getKeyString",
"(",
")",
")",
";",
"}"
] | Export a public key
@param string $publicKeyFingerprint
@return void | [
"Export",
"a",
"public",
"key"
] | 0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00 | https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Command/SsoKeyCommandController.php#L43-L46 |
12,552 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.assert | public function assert(callable $callback): bool
{
foreach ($this->items as $key => $item) {
if ($callback($item, $key) === false) {
return false;
}
}
return true;
} | php | public function assert(callable $callback): bool
{
foreach ($this->items as $key => $item) {
if ($callback($item, $key) === false) {
return false;
}
}
return true;
} | [
"public",
"function",
"assert",
"(",
"callable",
"$",
"callback",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"callback",
"(",
"$",
"item",
",",
"$",
"key",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Assert that all elements pass the test provided by the callback
@param callable $callback
@return bool | [
"Assert",
"that",
"all",
"elements",
"pass",
"the",
"test",
"provided",
"by",
"the",
"callback"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L150-L159 |
12,553 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.contains | public function contains($value): bool
{
return \in_array($value, $this->items, (is_scalar($value) ? false : true));
} | php | public function contains($value): bool
{
return \in_array($value, $this->items, (is_scalar($value) ? false : true));
} | [
"public",
"function",
"contains",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"return",
"\\",
"in_array",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"items",
",",
"(",
"is_scalar",
"(",
"$",
"value",
")",
"?",
"false",
":",
"true",
")",
")",
";",
"}"
] | Returns true if the value is in the Collection
@link http://ca.php.net/in_array
@param mixed $value
@return boolean | [
"Returns",
"true",
"if",
"the",
"value",
"is",
"in",
"the",
"Collection"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L183-L186 |
12,554 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.match | public function match($regex)
{
$col = new static();
foreach ($this as $key => $value) {
if (\preg_match($regex, $key)) {
$col[$key] = $value;
}
}
return $col;
} | php | public function match($regex)
{
$col = new static();
foreach ($this as $key => $value) {
if (\preg_match($regex, $key)) {
$col[$key] = $value;
}
}
return $col;
} | [
"public",
"function",
"match",
"(",
"$",
"regex",
")",
"{",
"$",
"col",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"key",
")",
")",
"{",
"$",
"col",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"col",
";",
"}"
] | Find keys and values using a regular expression, returning a new Collection
Similar to {@link keys} but allows any PERL regular expression to be
used for locating a matching key. Returns a new Collection containing matching
keys and values.
@param string $regex PERL regular expression
@return static | [
"Find",
"keys",
"and",
"values",
"using",
"a",
"regular",
"expression",
"returning",
"a",
"new",
"Collection"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L578-L589 |
12,555 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.max | public function max($key = null)
{
$callback = $this->valueAccessor($key);
return $this->filter(function ($value) {
return !is_null($value);
})->reduce(function ($result, $item) use ($callback) {
$value = $callback($item);
return is_null($result) || $value > $result ? $value : $result;
});
} | php | public function max($key = null)
{
$callback = $this->valueAccessor($key);
return $this->filter(function ($value) {
return !is_null($value);
})->reduce(function ($result, $item) use ($callback) {
$value = $callback($item);
return is_null($result) || $value > $result ? $value : $result;
});
} | [
"public",
"function",
"max",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"valueAccessor",
"(",
"$",
"key",
")",
";",
"return",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"value",
")",
";",
"}",
")",
"->",
"reduce",
"(",
"function",
"(",
"$",
"result",
",",
"$",
"item",
")",
"use",
"(",
"$",
"callback",
")",
"{",
"$",
"value",
"=",
"$",
"callback",
"(",
"$",
"item",
")",
";",
"return",
"is_null",
"(",
"$",
"result",
")",
"||",
"$",
"value",
">",
"$",
"result",
"?",
"$",
"value",
":",
"$",
"result",
";",
"}",
")",
";",
"}"
] | Returns the highest value from the collection of values
Key can be a string key or callable. Based on Laravel: Illuminate\Support\Collection.max
@param null|string $key
@return mixed | [
"Returns",
"the",
"highest",
"value",
"from",
"the",
"collection",
"of",
"values"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L600-L611 |
12,556 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.only | public function only($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
return $this->filter(function ($value, $key) use ($keys) {
return in_array($key, $keys, true);
});
} | php | public function only($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
return $this->filter(function ($value, $key) use ($keys) {
return in_array($key, $keys, true);
});
} | [
"public",
"function",
"only",
"(",
"$",
"keys",
")",
"{",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"keys",
")",
"?",
"$",
"keys",
":",
"func_get_args",
"(",
")",
";",
"return",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"use",
"(",
"$",
"keys",
")",
"{",
"return",
"in_array",
"(",
"$",
"key",
",",
"$",
"keys",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] | Returns a new collection containing only these keys
@param mixed $keys Array of key names, or multiple arguments
@return Collection | [
"Returns",
"a",
"new",
"collection",
"containing",
"only",
"these",
"keys"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L662-L669 |
12,557 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.pad | public function pad($size, $value)
{
$this->items = \array_pad($this->items, $size, $value);
return $this;
} | php | public function pad($size, $value)
{
$this->items = \array_pad($this->items, $size, $value);
return $this;
} | [
"public",
"function",
"pad",
"(",
"$",
"size",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"\\",
"array_pad",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"size",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Pads the Collection to size using value as the value of the new elements
@link http://ca.php.net/array_pad
@param integer $size
@param mixed $value
@return $this | [
"Pads",
"the",
"Collection",
"to",
"size",
"using",
"value",
"as",
"the",
"value",
"of",
"the",
"new",
"elements"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L681-L686 |
12,558 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.partition | public function partition($callback)
{
$partitions = [new static, new static];
$callback = $this->valueAccessor($callback);
foreach ($this->items as $key => $item) {
$partitions[(int) ! $callback($item)][$key] = $item;
}
return new static($partitions);
} | php | public function partition($callback)
{
$partitions = [new static, new static];
$callback = $this->valueAccessor($callback);
foreach ($this->items as $key => $item) {
$partitions[(int) ! $callback($item)][$key] = $item;
}
return new static($partitions);
} | [
"public",
"function",
"partition",
"(",
"$",
"callback",
")",
"{",
"$",
"partitions",
"=",
"[",
"new",
"static",
",",
"new",
"static",
"]",
";",
"$",
"callback",
"=",
"$",
"this",
"->",
"valueAccessor",
"(",
"$",
"callback",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"partitions",
"[",
"(",
"int",
")",
"!",
"$",
"callback",
"(",
"$",
"item",
")",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"partitions",
")",
";",
"}"
] | Partition the Collection into two Collections using the given callback or key.
Based on Laravel: Illuminate\Support\Collection.partition
@param callable|string $callback
@return static[static, static] | [
"Partition",
"the",
"Collection",
"into",
"two",
"Collections",
"using",
"the",
"given",
"callback",
"or",
"key",
"."
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L697-L707 |
12,559 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.pipe | public function pipe(iterable $items, $through)
{
foreach ($this->items as $key => $operator) {
$new = new static();
if (!Support::isCallable($through)) {
$through = function ($operator, $item, $key) use ($through)
{
return $operator->{$through}($item);
};
}
foreach ($items as $item) {
$new->set($key, $through($operator, $item, $key));
}
$items = $new;
}
return $items;
} | php | public function pipe(iterable $items, $through)
{
foreach ($this->items as $key => $operator) {
$new = new static();
if (!Support::isCallable($through)) {
$through = function ($operator, $item, $key) use ($through)
{
return $operator->{$through}($item);
};
}
foreach ($items as $item) {
$new->set($key, $through($operator, $item, $key));
}
$items = $new;
}
return $items;
} | [
"public",
"function",
"pipe",
"(",
"iterable",
"$",
"items",
",",
"$",
"through",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"operator",
")",
"{",
"$",
"new",
"=",
"new",
"static",
"(",
")",
";",
"if",
"(",
"!",
"Support",
"::",
"isCallable",
"(",
"$",
"through",
")",
")",
"{",
"$",
"through",
"=",
"function",
"(",
"$",
"operator",
",",
"$",
"item",
",",
"$",
"key",
")",
"use",
"(",
"$",
"through",
")",
"{",
"return",
"$",
"operator",
"->",
"{",
"$",
"through",
"}",
"(",
"$",
"item",
")",
";",
"}",
";",
"}",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"new",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"through",
"(",
"$",
"operator",
",",
"$",
"item",
",",
"$",
"key",
")",
")",
";",
"}",
"$",
"items",
"=",
"$",
"new",
";",
"}",
"return",
"$",
"items",
";",
"}"
] | Transformer a passed Collection of items using an Operator method
Given a set of Operators that all implement the same interface, pass the Collection of
items to each Operator, calling a method on the operator that will transform each item
in the items Collection, creating a new Collection that is passed to subsequent Operators.
In other words, if the Collection contains e.g. decorators that will add / modify an entity,
then `pipe` will pass each item in turn through each decorator. Each time a new Collection
is built from the output of the previous decorator. This allows chaining the decorator calls.
A method name for the Operator can be used as the second argument, otherwise a callable
must be provided that is passed: the operator object, an item from the items iterable
and the key. The callable should return the transformed item. The created Collection
preserves the keys, hence order, of the original items.
This method can be used to modify a set of read-only objects via a series of independent,
but linked transformations. This is similar to the pipeline pattern, except it works on a
Collection instead of a single item.
@param iterable $items
@param string|callable $through Method name to call on the operator, or a closure
@return static | [
"Transformer",
"a",
"passed",
"Collection",
"of",
"items",
"using",
"an",
"Operator",
"method"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L734-L754 |
12,560 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.removeEmpty | public function removeEmpty(array $empty = [false, null, ''])
{
return $this->filter(function ($item) use ($empty) {
return !in_array($item, $empty, true);
});
} | php | public function removeEmpty(array $empty = [false, null, ''])
{
return $this->filter(function ($item) use ($empty) {
return !in_array($item, $empty, true);
});
} | [
"public",
"function",
"removeEmpty",
"(",
"array",
"$",
"empty",
"=",
"[",
"false",
",",
"null",
",",
"''",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"empty",
")",
"{",
"return",
"!",
"in_array",
"(",
"$",
"item",
",",
"$",
"empty",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] | Removes values that are matched as empty through an equivalence check
@param array $empty Array of values considered to be "empty"
@return Collection | [
"Removes",
"values",
"that",
"are",
"matched",
"as",
"empty",
"through",
"an",
"equivalence",
"check"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L820-L825 |
12,561 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.set | public function set($key, $value = null)
{
if (\is_array($key) && $value === null) {
$this->items = $key;
trigger_error('Replacing collection contents via set is deprecated', E_USER_DEPRECATED);
} else {
$this->offsetSet($key, $value);
}
return $this;
} | php | public function set($key, $value = null)
{
if (\is_array($key) && $value === null) {
$this->items = $key;
trigger_error('Replacing collection contents via set is deprecated', E_USER_DEPRECATED);
} else {
$this->offsetSet($key, $value);
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"key",
")",
"&&",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"$",
"key",
";",
"trigger_error",
"(",
"'Replacing collection contents via set is deprecated'",
",",
"E_USER_DEPRECATED",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"offsetSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add the item with key to the Collection
If item is an array and value is null, the Collection will be replaced with
the items.
Note: replacing the Collection contents is considered deprecated and will be removed
in the next major version.
@param mixed $key
@param mixed $value
@return $this | [
"Add",
"the",
"item",
"with",
"key",
"to",
"the",
"Collection"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L894-L904 |
12,562 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.slice | public function slice($offset, $limit = null, $keys = true)
{
return new static(\array_slice($this->items, $offset, $limit, $keys));
} | php | public function slice($offset, $limit = null, $keys = true)
{
return new static(\array_slice($this->items, $offset, $limit, $keys));
} | [
"public",
"function",
"slice",
"(",
"$",
"offset",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"keys",
"=",
"true",
")",
"{",
"return",
"new",
"static",
"(",
"\\",
"array_slice",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"offset",
",",
"$",
"limit",
",",
"$",
"keys",
")",
")",
";",
"}"
] | Extracts a portion of the Collection, returning a new Collection
By default, preserves the keys.
@link http://ca.php.net/array_slice
@param int $offset
@param int|null $limit
@param bool $keys
@return static | [
"Extracts",
"a",
"portion",
"of",
"the",
"Collection",
"returning",
"a",
"new",
"Collection"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L946-L949 |
12,563 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.transform | public function transform(callable $callable)
{
$ret = new static();
foreach ($this as $key => $value) {
$ret->set($key, $callable($value, $key));
}
return $ret;
} | php | public function transform(callable $callable)
{
$ret = new static();
foreach ($this as $key => $value) {
$ret->set($key, $callable($value, $key));
}
return $ret;
} | [
"public",
"function",
"transform",
"(",
"callable",
"$",
"callable",
")",
"{",
"$",
"ret",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"ret",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"callable",
"(",
"$",
"value",
",",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Creates a new Collection containing the results of the callable in the same keys
For example: with a collection of the same objects, call a method to export
part of each object into a new collection. Similar to using each() or walk()
except the callable should return the new value for the key.
Note: this method preserves the array keys from the original Collection.
@param callable $callable Receives: $value, $key
@return static | [
"Creates",
"a",
"new",
"Collection",
"containing",
"the",
"results",
"of",
"the",
"callable",
"in",
"the",
"same",
"keys"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L982-L991 |
12,564 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.value | public function value($key, $default = null)
{
$value = $this->get($key);
if (!$value) {
return $this->valueExecutor($default, $value, $key);
}
return $value;
} | php | public function value($key, $default = null)
{
$value = $this->get($key);
if (!$value) {
return $this->valueExecutor($default, $value, $key);
}
return $value;
} | [
"public",
"function",
"value",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"valueExecutor",
"(",
"$",
"default",
",",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Returns the value for the specified key or if there is no value, returns the default
Default can be a callable (closure) that will be executed. This method differs to
{@link static::get()} in that the default will be returned even when the key exists and
has no "truthy" value (null, false, empty string etc). Default can be a callable; this will
be passed the value (if any) and the key as arguments.
@param string $key
@param mixed|callable $default
@return mixed | [
"Returns",
"the",
"value",
"for",
"the",
"specified",
"key",
"or",
"if",
"there",
"is",
"no",
"value",
"returns",
"the",
"default"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L1016-L1025 |
12,565 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.walk | public function walk($callback, $userdata = null)
{
$elements = $this->items;
\array_walk($elements, $callback, $userdata);
return new static($elements);
} | php | public function walk($callback, $userdata = null)
{
$elements = $this->items;
\array_walk($elements, $callback, $userdata);
return new static($elements);
} | [
"public",
"function",
"walk",
"(",
"$",
"callback",
",",
"$",
"userdata",
"=",
"null",
")",
"{",
"$",
"elements",
"=",
"$",
"this",
"->",
"items",
";",
"\\",
"array_walk",
"(",
"$",
"elements",
",",
"$",
"callback",
",",
"$",
"userdata",
")",
";",
"return",
"new",
"static",
"(",
"$",
"elements",
")",
";",
"}"
] | Applies the callback to all elements in the Collection, returning a new Collection
@link http://ca.php.net/array_walk
@param callable $callback Receives: (&$value, $key, ?$userdata)
@param mixed $userdata (optional) additional user data for the callback
@return static | [
"Applies",
"the",
"callback",
"to",
"all",
"elements",
"in",
"the",
"Collection",
"returning",
"a",
"new",
"Collection"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L1075-L1081 |
12,566 | dave-redfern/somnambulist-collection | src/Collection.php | Collection.valueAccessor | protected function valueAccessor($value, $returnNull = false)
{
if (Support::isCallable($value)) {
return $value;
}
return function ($item) use ($value, $returnNull) {
if (is_null($value)) {
return $returnNull ? null : $item;
}
if (Support::isTraversable($item)) {
return array_key_exists($value, $item) ? $item[$value] : null;
}
if (is_object($item) && isset($item->{$value})) {
return $item->{$value};
}
if (is_object($item) && method_exists($item, $value)) {
return $item->{$value}();
}
if (is_object($item) && method_exists($item, 'get' . ucwords($value))) {
return $item->{'get' . ucwords($value)}();
}
return $returnNull ? null : $item;
};
} | php | protected function valueAccessor($value, $returnNull = false)
{
if (Support::isCallable($value)) {
return $value;
}
return function ($item) use ($value, $returnNull) {
if (is_null($value)) {
return $returnNull ? null : $item;
}
if (Support::isTraversable($item)) {
return array_key_exists($value, $item) ? $item[$value] : null;
}
if (is_object($item) && isset($item->{$value})) {
return $item->{$value};
}
if (is_object($item) && method_exists($item, $value)) {
return $item->{$value}();
}
if (is_object($item) && method_exists($item, 'get' . ucwords($value))) {
return $item->{'get' . ucwords($value)}();
}
return $returnNull ? null : $item;
};
} | [
"protected",
"function",
"valueAccessor",
"(",
"$",
"value",
",",
"$",
"returnNull",
"=",
"false",
")",
"{",
"if",
"(",
"Support",
"::",
"isCallable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"value",
",",
"$",
"returnNull",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"returnNull",
"?",
"null",
":",
"$",
"item",
";",
"}",
"if",
"(",
"Support",
"::",
"isTraversable",
"(",
"$",
"item",
")",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"item",
")",
"?",
"$",
"item",
"[",
"$",
"value",
"]",
":",
"null",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"isset",
"(",
"$",
"item",
"->",
"{",
"$",
"value",
"}",
")",
")",
"{",
"return",
"$",
"item",
"->",
"{",
"$",
"value",
"}",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"method_exists",
"(",
"$",
"item",
",",
"$",
"value",
")",
")",
"{",
"return",
"$",
"item",
"->",
"{",
"$",
"value",
"}",
"(",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"method_exists",
"(",
"$",
"item",
",",
"'get'",
".",
"ucwords",
"(",
"$",
"value",
")",
")",
")",
"{",
"return",
"$",
"item",
"->",
"{",
"'get'",
".",
"ucwords",
"(",
"$",
"value",
")",
"}",
"(",
")",
";",
"}",
"return",
"$",
"returnNull",
"?",
"null",
":",
"$",
"item",
";",
"}",
";",
"}"
] | Providers a callable for fetching data from a collection item
Based on Laravel: Illuminate\Support\Collection.valueRetriever
@param string|callable $value
@param bool $returnNull If true, returns null instead of the item
@return callable | [
"Providers",
"a",
"callable",
"for",
"fetching",
"data",
"from",
"a",
"collection",
"item"
] | 82cf33c333b00ff375c403fbc7f32e4b476ee0b1 | https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Collection.php#L1095-L1120 |
12,567 | php-packages/dumpy | src/PhpPackages/Dumpy/Dumpy.php | Dumpy.getConfigOption | public function getConfigOption($option)
{
// An exception will be thrown instead of returning NULL or something similar.
if ( ! array_key_exists($option, $this->config)) {
throw new UnexpectedValueException("Unexpected option name: {$option}");
}
return $this->config[$option];
} | php | public function getConfigOption($option)
{
// An exception will be thrown instead of returning NULL or something similar.
if ( ! array_key_exists($option, $this->config)) {
throw new UnexpectedValueException("Unexpected option name: {$option}");
}
return $this->config[$option];
} | [
"public",
"function",
"getConfigOption",
"(",
"$",
"option",
")",
"{",
"// An exception will be thrown instead of returning NULL or something similar.",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"config",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"Unexpected option name: {$option}\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"[",
"$",
"option",
"]",
";",
"}"
] | Returns the value of given configuration option.
@throws \UnexpectedValueException
@param string $option
@return mixed | [
"Returns",
"the",
"value",
"of",
"given",
"configuration",
"option",
"."
] | 220820139a2b1361a1bd122d59bbc41b1533b41e | https://github.com/php-packages/dumpy/blob/220820139a2b1361a1bd122d59bbc41b1533b41e/src/PhpPackages/Dumpy/Dumpy.php#L57-L65 |
12,568 | php-packages/dumpy | src/PhpPackages/Dumpy/Dumpy.php | Dumpy.configure | public function configure($option, $value)
{
// Dumpy won't let you add any custom config options, only update the existing ones.
if ( ! array_key_exists($option, $this->config)) {
// Note: something really weird is going to happen if $option is, say, an array.
throw new InvalidArgumentException("Invalid option name: {$option}");
}
// Note that:
// 1) the passed value can be of any type and contain anything
// 2) the option value will be overridden permanently, no way back
$this->config[$option] = $value;
} | php | public function configure($option, $value)
{
// Dumpy won't let you add any custom config options, only update the existing ones.
if ( ! array_key_exists($option, $this->config)) {
// Note: something really weird is going to happen if $option is, say, an array.
throw new InvalidArgumentException("Invalid option name: {$option}");
}
// Note that:
// 1) the passed value can be of any type and contain anything
// 2) the option value will be overridden permanently, no way back
$this->config[$option] = $value;
} | [
"public",
"function",
"configure",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"// Dumpy won't let you add any custom config options, only update the existing ones.",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"config",
")",
")",
"{",
"// Note: something really weird is going to happen if $option is, say, an array.",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Invalid option name: {$option}\"",
")",
";",
"}",
"// Note that:",
"// 1) the passed value can be of any type and contain anything",
"// 2) the option value will be overridden permanently, no way back",
"$",
"this",
"->",
"config",
"[",
"$",
"option",
"]",
"=",
"$",
"value",
";",
"}"
] | Sets a configuration option to given value.
@throws \InvalidArgumentException
@param string $option
@param mixed $value
@return void | [
"Sets",
"a",
"configuration",
"option",
"to",
"given",
"value",
"."
] | 220820139a2b1361a1bd122d59bbc41b1533b41e | https://github.com/php-packages/dumpy/blob/220820139a2b1361a1bd122d59bbc41b1533b41e/src/PhpPackages/Dumpy/Dumpy.php#L75-L87 |
12,569 | php-packages/dumpy | src/PhpPackages/Dumpy/Dumpy.php | Dumpy.dump | public function dump($value)
{
switch (gettype($value)) {
// Handle boolean values.
case "boolean": {
$output = $value ? "true" : "false";
// You can represent booleans (and NULLs) in either lower- or uppercase format.
return $this->config["bool_lowercase"] ? $output : strtoupper($output);
}
// Handle NULL values.
case "NULL": {
return $this->config["null_lowercase"] ? "null" : "NULL";
}
// Handle integers.
case "integer": {
return (string) $value;
}
// Handle floats (doubles).
case "double": {
// Dumpy allows you to round floats to round_double decimal points.
if ($this->config["round_double"] !== false) {
$value = round($value, $this->config["round_double"], PHP_ROUND_HALF_UP);
}
return (string) $value;
}
// Handle strings.
case "string": {
// @suggestion Multibyte support?
// Look above for the detailed explanation.
if (strlen($value) > $this->config["str_max_length"]) {
$value = substr($value, 0, $this->config["str_max_length"]) . "...";
}
// Dumpy allows you to replace newline characters with "\\n".
if ($this->config["replace_newline"]) {
$value = str_replace(PHP_EOL, "\\n", $value);
}
return "\"{$value}\"";
}
// Handle arrays.
case "array": {
return $this->printArray($value) . PHP_EOL;
}
// Handle objects.
case "object": {
return $this->printObject($value);
}
// @codeCoverageIgnoreStart
}
} | php | public function dump($value)
{
switch (gettype($value)) {
// Handle boolean values.
case "boolean": {
$output = $value ? "true" : "false";
// You can represent booleans (and NULLs) in either lower- or uppercase format.
return $this->config["bool_lowercase"] ? $output : strtoupper($output);
}
// Handle NULL values.
case "NULL": {
return $this->config["null_lowercase"] ? "null" : "NULL";
}
// Handle integers.
case "integer": {
return (string) $value;
}
// Handle floats (doubles).
case "double": {
// Dumpy allows you to round floats to round_double decimal points.
if ($this->config["round_double"] !== false) {
$value = round($value, $this->config["round_double"], PHP_ROUND_HALF_UP);
}
return (string) $value;
}
// Handle strings.
case "string": {
// @suggestion Multibyte support?
// Look above for the detailed explanation.
if (strlen($value) > $this->config["str_max_length"]) {
$value = substr($value, 0, $this->config["str_max_length"]) . "...";
}
// Dumpy allows you to replace newline characters with "\\n".
if ($this->config["replace_newline"]) {
$value = str_replace(PHP_EOL, "\\n", $value);
}
return "\"{$value}\"";
}
// Handle arrays.
case "array": {
return $this->printArray($value) . PHP_EOL;
}
// Handle objects.
case "object": {
return $this->printObject($value);
}
// @codeCoverageIgnoreStart
}
} | [
"public",
"function",
"dump",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
"{",
"// Handle boolean values.",
"case",
"\"boolean\"",
":",
"{",
"$",
"output",
"=",
"$",
"value",
"?",
"\"true\"",
":",
"\"false\"",
";",
"// You can represent booleans (and NULLs) in either lower- or uppercase format.",
"return",
"$",
"this",
"->",
"config",
"[",
"\"bool_lowercase\"",
"]",
"?",
"$",
"output",
":",
"strtoupper",
"(",
"$",
"output",
")",
";",
"}",
"// Handle NULL values.",
"case",
"\"NULL\"",
":",
"{",
"return",
"$",
"this",
"->",
"config",
"[",
"\"null_lowercase\"",
"]",
"?",
"\"null\"",
":",
"\"NULL\"",
";",
"}",
"// Handle integers.",
"case",
"\"integer\"",
":",
"{",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}",
"// Handle floats (doubles).",
"case",
"\"double\"",
":",
"{",
"// Dumpy allows you to round floats to round_double decimal points.",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"\"round_double\"",
"]",
"!==",
"false",
")",
"{",
"$",
"value",
"=",
"round",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"config",
"[",
"\"round_double\"",
"]",
",",
"PHP_ROUND_HALF_UP",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}",
"// Handle strings.",
"case",
"\"string\"",
":",
"{",
"// @suggestion Multibyte support?",
"// Look above for the detailed explanation.",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
">",
"$",
"this",
"->",
"config",
"[",
"\"str_max_length\"",
"]",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"$",
"this",
"->",
"config",
"[",
"\"str_max_length\"",
"]",
")",
".",
"\"...\"",
";",
"}",
"// Dumpy allows you to replace newline characters with \"\\\\n\".",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"\"replace_newline\"",
"]",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"PHP_EOL",
",",
"\"\\\\n\"",
",",
"$",
"value",
")",
";",
"}",
"return",
"\"\\\"{$value}\\\"\"",
";",
"}",
"// Handle arrays.",
"case",
"\"array\"",
":",
"{",
"return",
"$",
"this",
"->",
"printArray",
"(",
"$",
"value",
")",
".",
"PHP_EOL",
";",
"}",
"// Handle objects.",
"case",
"\"object\"",
":",
"{",
"return",
"$",
"this",
"->",
"printObject",
"(",
"$",
"value",
")",
";",
"}",
"// @codeCoverageIgnoreStart",
"}",
"}"
] | This method helps you get string representations of various PHP data types.
@param mixed $value
@return string | [
"This",
"method",
"helps",
"you",
"get",
"string",
"representations",
"of",
"various",
"PHP",
"data",
"types",
"."
] | 220820139a2b1361a1bd122d59bbc41b1533b41e | https://github.com/php-packages/dumpy/blob/220820139a2b1361a1bd122d59bbc41b1533b41e/src/PhpPackages/Dumpy/Dumpy.php#L95-L153 |
12,570 | php-packages/dumpy | src/PhpPackages/Dumpy/Dumpy.php | Dumpy.printArray | protected function printArray(array $value, $level = 1)
{
if (count($value) < 1) {
return "[]";
}
// Open bracket.
$result = "[" . PHP_EOL;
// This approach is much faster than the one that uses array_values function.
// To make it even faster, we cache the value.
$isAssoc = (array_keys($value) !== range(0, count($value) - 1));
// We'll need this variable to determine whether we need to omit remaining elements.
$counter = 0;
foreach ($value as $key => $element) {
$counter++;
// Decide whether to omit the rest of the values in given array
// depending on array_max_elements value.
if ($counter > $this->config["array_max_elements"]) {
$result .= str_repeat($this->config["array_indenting"], $level);
$result .= "..." . PHP_EOL;
break;
}
if (is_array($element)) {
$element = $this->printArray($element, $level + 1);
} elseif (is_object($element)) {
$element = $this->printObject($element, $level + 1);
} else {
$element = $this->dump($element);
}
// Maintain the proper indenting.
$result .= str_repeat($this->config["array_indenting"], $level);
if ( ! $isAssoc) {
$result .= $element;
} else {
$result .= sprintf("%s => %s", $this->dump($key), $element);
}
$result .= "," . PHP_EOL;
}
// Maintain proper indenting.
$result .= str_repeat($this->config["array_indenting"], $level - 1);
// Closing bracket.
$result .= "]";
return $result;
} | php | protected function printArray(array $value, $level = 1)
{
if (count($value) < 1) {
return "[]";
}
// Open bracket.
$result = "[" . PHP_EOL;
// This approach is much faster than the one that uses array_values function.
// To make it even faster, we cache the value.
$isAssoc = (array_keys($value) !== range(0, count($value) - 1));
// We'll need this variable to determine whether we need to omit remaining elements.
$counter = 0;
foreach ($value as $key => $element) {
$counter++;
// Decide whether to omit the rest of the values in given array
// depending on array_max_elements value.
if ($counter > $this->config["array_max_elements"]) {
$result .= str_repeat($this->config["array_indenting"], $level);
$result .= "..." . PHP_EOL;
break;
}
if (is_array($element)) {
$element = $this->printArray($element, $level + 1);
} elseif (is_object($element)) {
$element = $this->printObject($element, $level + 1);
} else {
$element = $this->dump($element);
}
// Maintain the proper indenting.
$result .= str_repeat($this->config["array_indenting"], $level);
if ( ! $isAssoc) {
$result .= $element;
} else {
$result .= sprintf("%s => %s", $this->dump($key), $element);
}
$result .= "," . PHP_EOL;
}
// Maintain proper indenting.
$result .= str_repeat($this->config["array_indenting"], $level - 1);
// Closing bracket.
$result .= "]";
return $result;
} | [
"protected",
"function",
"printArray",
"(",
"array",
"$",
"value",
",",
"$",
"level",
"=",
"1",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"value",
")",
"<",
"1",
")",
"{",
"return",
"\"[]\"",
";",
"}",
"// Open bracket.",
"$",
"result",
"=",
"\"[\"",
".",
"PHP_EOL",
";",
"// This approach is much faster than the one that uses array_values function.",
"// To make it even faster, we cache the value.",
"$",
"isAssoc",
"=",
"(",
"array_keys",
"(",
"$",
"value",
")",
"!==",
"range",
"(",
"0",
",",
"count",
"(",
"$",
"value",
")",
"-",
"1",
")",
")",
";",
"// We'll need this variable to determine whether we need to omit remaining elements.",
"$",
"counter",
"=",
"0",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"$",
"counter",
"++",
";",
"// Decide whether to omit the rest of the values in given array",
"// depending on array_max_elements value.",
"if",
"(",
"$",
"counter",
">",
"$",
"this",
"->",
"config",
"[",
"\"array_max_elements\"",
"]",
")",
"{",
"$",
"result",
".=",
"str_repeat",
"(",
"$",
"this",
"->",
"config",
"[",
"\"array_indenting\"",
"]",
",",
"$",
"level",
")",
";",
"$",
"result",
".=",
"\"...\"",
".",
"PHP_EOL",
";",
"break",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"element",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"printArray",
"(",
"$",
"element",
",",
"$",
"level",
"+",
"1",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"element",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"printObject",
"(",
"$",
"element",
",",
"$",
"level",
"+",
"1",
")",
";",
"}",
"else",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"dump",
"(",
"$",
"element",
")",
";",
"}",
"// Maintain the proper indenting.",
"$",
"result",
".=",
"str_repeat",
"(",
"$",
"this",
"->",
"config",
"[",
"\"array_indenting\"",
"]",
",",
"$",
"level",
")",
";",
"if",
"(",
"!",
"$",
"isAssoc",
")",
"{",
"$",
"result",
".=",
"$",
"element",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"sprintf",
"(",
"\"%s => %s\"",
",",
"$",
"this",
"->",
"dump",
"(",
"$",
"key",
")",
",",
"$",
"element",
")",
";",
"}",
"$",
"result",
".=",
"\",\"",
".",
"PHP_EOL",
";",
"}",
"// Maintain proper indenting.",
"$",
"result",
".=",
"str_repeat",
"(",
"$",
"this",
"->",
"config",
"[",
"\"array_indenting\"",
"]",
",",
"$",
"level",
"-",
"1",
")",
";",
"// Closing bracket.",
"$",
"result",
".=",
"\"]\"",
";",
"return",
"$",
"result",
";",
"}"
] | Returns a string representation of given array.
@param array $value
@param integer $level
@return string | [
"Returns",
"a",
"string",
"representation",
"of",
"given",
"array",
"."
] | 220820139a2b1361a1bd122d59bbc41b1533b41e | https://github.com/php-packages/dumpy/blob/220820139a2b1361a1bd122d59bbc41b1533b41e/src/PhpPackages/Dumpy/Dumpy.php#L162-L214 |
12,571 | php-packages/dumpy | src/PhpPackages/Dumpy/Dumpy.php | Dumpy.printObject | protected function printObject($value, $level = 0)
{
$reflector = new ReflectionClass($value);
// Display the general information about given object.
$result = $this->getGeneralObjectInfo($value) . PHP_EOL;
if ( ! $this->config["object_limited_info"]) {
// Display all parent classes.
if (count($parents = $this->getAllParentClassNames($reflector)) > 0) {
$result .= sprintf("Classes: %s" . PHP_EOL, implode(", ", $parents));
}
// Display all interfaces (interface inheritance is supported).
if (count($interfaces = $reflector->getInterfaceNames()) > 0) {
$result .= sprintf("Interfaces: %s" . PHP_EOL, implode(", ", $interfaces));
}
// Display all class traits.
if (count($traits = $this->getAllTraitNames($reflector)) > 0) {
$result .= sprintf("Traits: %s" . PHP_EOL, implode(", ", $traits));
}
}
// Display property values.
if ($info = $this->getPropertyValues($reflector, $value, $level + 1)) {
$result .=
str_repeat($this->config["array_indenting"], $level)
. "Properties:" . PHP_EOL . $info;
}
return $result;
} | php | protected function printObject($value, $level = 0)
{
$reflector = new ReflectionClass($value);
// Display the general information about given object.
$result = $this->getGeneralObjectInfo($value) . PHP_EOL;
if ( ! $this->config["object_limited_info"]) {
// Display all parent classes.
if (count($parents = $this->getAllParentClassNames($reflector)) > 0) {
$result .= sprintf("Classes: %s" . PHP_EOL, implode(", ", $parents));
}
// Display all interfaces (interface inheritance is supported).
if (count($interfaces = $reflector->getInterfaceNames()) > 0) {
$result .= sprintf("Interfaces: %s" . PHP_EOL, implode(", ", $interfaces));
}
// Display all class traits.
if (count($traits = $this->getAllTraitNames($reflector)) > 0) {
$result .= sprintf("Traits: %s" . PHP_EOL, implode(", ", $traits));
}
}
// Display property values.
if ($info = $this->getPropertyValues($reflector, $value, $level + 1)) {
$result .=
str_repeat($this->config["array_indenting"], $level)
. "Properties:" . PHP_EOL . $info;
}
return $result;
} | [
"protected",
"function",
"printObject",
"(",
"$",
"value",
",",
"$",
"level",
"=",
"0",
")",
"{",
"$",
"reflector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"value",
")",
";",
"// Display the general information about given object.",
"$",
"result",
"=",
"$",
"this",
"->",
"getGeneralObjectInfo",
"(",
"$",
"value",
")",
".",
"PHP_EOL",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"\"object_limited_info\"",
"]",
")",
"{",
"// Display all parent classes.",
"if",
"(",
"count",
"(",
"$",
"parents",
"=",
"$",
"this",
"->",
"getAllParentClassNames",
"(",
"$",
"reflector",
")",
")",
">",
"0",
")",
"{",
"$",
"result",
".=",
"sprintf",
"(",
"\"Classes: %s\"",
".",
"PHP_EOL",
",",
"implode",
"(",
"\", \"",
",",
"$",
"parents",
")",
")",
";",
"}",
"// Display all interfaces (interface inheritance is supported).",
"if",
"(",
"count",
"(",
"$",
"interfaces",
"=",
"$",
"reflector",
"->",
"getInterfaceNames",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"result",
".=",
"sprintf",
"(",
"\"Interfaces: %s\"",
".",
"PHP_EOL",
",",
"implode",
"(",
"\", \"",
",",
"$",
"interfaces",
")",
")",
";",
"}",
"// Display all class traits.",
"if",
"(",
"count",
"(",
"$",
"traits",
"=",
"$",
"this",
"->",
"getAllTraitNames",
"(",
"$",
"reflector",
")",
")",
">",
"0",
")",
"{",
"$",
"result",
".=",
"sprintf",
"(",
"\"Traits: %s\"",
".",
"PHP_EOL",
",",
"implode",
"(",
"\", \"",
",",
"$",
"traits",
")",
")",
";",
"}",
"}",
"// Display property values.",
"if",
"(",
"$",
"info",
"=",
"$",
"this",
"->",
"getPropertyValues",
"(",
"$",
"reflector",
",",
"$",
"value",
",",
"$",
"level",
"+",
"1",
")",
")",
"{",
"$",
"result",
".=",
"str_repeat",
"(",
"$",
"this",
"->",
"config",
"[",
"\"array_indenting\"",
"]",
",",
"$",
"level",
")",
".",
"\"Properties:\"",
".",
"PHP_EOL",
".",
"$",
"info",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns a string representation of given object.
@param object $value
@param integer $level
@return string | [
"Returns",
"a",
"string",
"representation",
"of",
"given",
"object",
"."
] | 220820139a2b1361a1bd122d59bbc41b1533b41e | https://github.com/php-packages/dumpy/blob/220820139a2b1361a1bd122d59bbc41b1533b41e/src/PhpPackages/Dumpy/Dumpy.php#L223-L255 |
12,572 | jeromeklam/freefw | src/FreeFW/Core/Model.php | Model.initWithJson | public function initWithJson(array $p_datas = [])
{
$props = $this->getProperties();
$this->init();
foreach ($p_datas as $name => $value) {
foreach ($props as $prp => $property) {
$test = $prp;
if (array_key_exists(FFCST::PROPERTY_PUBLIC, $property)) {
$test = $property[FFCST::PROPERTY_PUBLIC];
}
if ($test == $name) {
$setter = 'set' . \FreeFW\Tools\PBXString::toCamelCase($name, true);
$this->$setter($value);
break;
}
}
}
return $this;
} | php | public function initWithJson(array $p_datas = [])
{
$props = $this->getProperties();
$this->init();
foreach ($p_datas as $name => $value) {
foreach ($props as $prp => $property) {
$test = $prp;
if (array_key_exists(FFCST::PROPERTY_PUBLIC, $property)) {
$test = $property[FFCST::PROPERTY_PUBLIC];
}
if ($test == $name) {
$setter = 'set' . \FreeFW\Tools\PBXString::toCamelCase($name, true);
$this->$setter($value);
break;
}
}
}
return $this;
} | [
"public",
"function",
"initWithJson",
"(",
"array",
"$",
"p_datas",
"=",
"[",
"]",
")",
"{",
"$",
"props",
"=",
"$",
"this",
"->",
"getProperties",
"(",
")",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"foreach",
"(",
"$",
"p_datas",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"props",
"as",
"$",
"prp",
"=>",
"$",
"property",
")",
"{",
"$",
"test",
"=",
"$",
"prp",
";",
"if",
"(",
"array_key_exists",
"(",
"FFCST",
"::",
"PROPERTY_PUBLIC",
",",
"$",
"property",
")",
")",
"{",
"$",
"test",
"=",
"$",
"property",
"[",
"FFCST",
"::",
"PROPERTY_PUBLIC",
"]",
";",
"}",
"if",
"(",
"$",
"test",
"==",
"$",
"name",
")",
"{",
"$",
"setter",
"=",
"'set'",
".",
"\\",
"FreeFW",
"\\",
"Tools",
"\\",
"PBXString",
"::",
"toCamelCase",
"(",
"$",
"name",
",",
"true",
")",
";",
"$",
"this",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Init object with datas
@param array $p_datas
@return \FreeFW\Core\Model | [
"Init",
"object",
"with",
"datas"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Core/Model.php#L91-L109 |
12,573 | canis-io/yii2-canis-lib | lib/web/grid/Grid.php | Grid.setCells | public function setCells($items)
{
Yii::beginProfile(__CLASS__ . ':' . __FUNCTION__);
while (!empty($items)) {
$this->currentRow->addCells($items);
if (!empty($items)) {
$this->_currentRow = null;
}
}
Yii::endProfile(__CLASS__ . ':' . __FUNCTION__);
} | php | public function setCells($items)
{
Yii::beginProfile(__CLASS__ . ':' . __FUNCTION__);
while (!empty($items)) {
$this->currentRow->addCells($items);
if (!empty($items)) {
$this->_currentRow = null;
}
}
Yii::endProfile(__CLASS__ . ':' . __FUNCTION__);
} | [
"public",
"function",
"setCells",
"(",
"$",
"items",
")",
"{",
"Yii",
"::",
"beginProfile",
"(",
"__CLASS__",
".",
"':'",
".",
"__FUNCTION__",
")",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"items",
")",
")",
"{",
"$",
"this",
"->",
"currentRow",
"->",
"addCells",
"(",
"$",
"items",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"items",
")",
")",
"{",
"$",
"this",
"->",
"_currentRow",
"=",
"null",
";",
"}",
"}",
"Yii",
"::",
"endProfile",
"(",
"__CLASS__",
".",
"':'",
".",
"__FUNCTION__",
")",
";",
"}"
] | Set cells.
@param [[@doctodo param_type:items]] $items [[@doctodo param_description:items]] | [
"Set",
"cells",
"."
] | 97d533521f65b084dc805c5f312c364b469142d2 | https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Grid.php#L146-L156 |
12,574 | canis-io/yii2-canis-lib | lib/web/grid/Grid.php | Grid.getCurrentRow | public function getCurrentRow()
{
if (isset($this->_currentRow) && $this->_currentRow->isFilled()) {
$this->_currentRow = null;
}
if (is_null($this->_currentRow)) {
$this->_currentRow = Yii::createObject(array_merge(['class' => $this->rowClass], $this->baseRow));
$this->_rows[] = $this->_currentRow;
}
return $this->_currentRow;
} | php | public function getCurrentRow()
{
if (isset($this->_currentRow) && $this->_currentRow->isFilled()) {
$this->_currentRow = null;
}
if (is_null($this->_currentRow)) {
$this->_currentRow = Yii::createObject(array_merge(['class' => $this->rowClass], $this->baseRow));
$this->_rows[] = $this->_currentRow;
}
return $this->_currentRow;
} | [
"public",
"function",
"getCurrentRow",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_currentRow",
")",
"&&",
"$",
"this",
"->",
"_currentRow",
"->",
"isFilled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_currentRow",
"=",
"null",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_currentRow",
")",
")",
"{",
"$",
"this",
"->",
"_currentRow",
"=",
"Yii",
"::",
"createObject",
"(",
"array_merge",
"(",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"rowClass",
"]",
",",
"$",
"this",
"->",
"baseRow",
")",
")",
";",
"$",
"this",
"->",
"_rows",
"[",
"]",
"=",
"$",
"this",
"->",
"_currentRow",
";",
"}",
"return",
"$",
"this",
"->",
"_currentRow",
";",
"}"
] | Get current row.
@return [[@doctodo return_type:getCurrentRow]] [[@doctodo return_description:getCurrentRow]] | [
"Get",
"current",
"row",
"."
] | 97d533521f65b084dc805c5f312c364b469142d2 | https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Grid.php#L163-L174 |
12,575 | osflab/view | Component.php | Component.buildComponent | protected static function buildComponent(string $className)
{
if (!isset(self::$components[$className])) {
self::$components[$className] = Container::buildObject("\\Osf\\View\\Component\\" . $className);
if (!(self::$components[$className] instanceof Component\AbstractComponent)) {
throw new ArchException('Component [' . $className . '] must be an AbstractComponent');
}
}
return self::$components[$className];
} | php | protected static function buildComponent(string $className)
{
if (!isset(self::$components[$className])) {
self::$components[$className] = Container::buildObject("\\Osf\\View\\Component\\" . $className);
if (!(self::$components[$className] instanceof Component\AbstractComponent)) {
throw new ArchException('Component [' . $className . '] must be an AbstractComponent');
}
}
return self::$components[$className];
} | [
"protected",
"static",
"function",
"buildComponent",
"(",
"string",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"components",
"[",
"$",
"className",
"]",
")",
")",
"{",
"self",
"::",
"$",
"components",
"[",
"$",
"className",
"]",
"=",
"Container",
"::",
"buildObject",
"(",
"\"\\\\Osf\\\\View\\\\Component\\\\\"",
".",
"$",
"className",
")",
";",
"if",
"(",
"!",
"(",
"self",
"::",
"$",
"components",
"[",
"$",
"className",
"]",
"instanceof",
"Component",
"\\",
"AbstractComponent",
")",
")",
"{",
"throw",
"new",
"ArchException",
"(",
"'Component ['",
".",
"$",
"className",
".",
"'] must be an AbstractComponent'",
")",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"components",
"[",
"$",
"className",
"]",
";",
"}"
] | Manage components instances
@param string $className
@return type
@throws \Osf\Exception\ArchException
@return \Osf\View\Component\AbstractComponent | [
"Manage",
"components",
"instances"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Component.php#L37-L46 |
12,576 | osflab/view | Component.php | Component.registerScripts | public static function registerScripts(HelperInterface $layout)
{
foreach (self::$components as $component) {
foreach ($component->getScripts() as $script) {
switch ($script[0]) {
case 'headjs' :
$layout->headTags->appendFile($script[1], $script[2], $script[3]);
break;
case 'headcss' :
$layout->headTags->appendStylesheet($script[1], $script[2], $script[3]);
break;
case 'footjs' :
$layout->footTags->appendFile($script[1], $script[2], $script[3]);
break;
case 'footcss' :
$layout->footTags->appendStylesheet($script[1], $script[2], $script[3]);
break;
case 'script' :
$layout->footTags->appendScript($script[1]);
break;
}
}
}
} | php | public static function registerScripts(HelperInterface $layout)
{
foreach (self::$components as $component) {
foreach ($component->getScripts() as $script) {
switch ($script[0]) {
case 'headjs' :
$layout->headTags->appendFile($script[1], $script[2], $script[3]);
break;
case 'headcss' :
$layout->headTags->appendStylesheet($script[1], $script[2], $script[3]);
break;
case 'footjs' :
$layout->footTags->appendFile($script[1], $script[2], $script[3]);
break;
case 'footcss' :
$layout->footTags->appendStylesheet($script[1], $script[2], $script[3]);
break;
case 'script' :
$layout->footTags->appendScript($script[1]);
break;
}
}
}
} | [
"public",
"static",
"function",
"registerScripts",
"(",
"HelperInterface",
"$",
"layout",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"foreach",
"(",
"$",
"component",
"->",
"getScripts",
"(",
")",
"as",
"$",
"script",
")",
"{",
"switch",
"(",
"$",
"script",
"[",
"0",
"]",
")",
"{",
"case",
"'headjs'",
":",
"$",
"layout",
"->",
"headTags",
"->",
"appendFile",
"(",
"$",
"script",
"[",
"1",
"]",
",",
"$",
"script",
"[",
"2",
"]",
",",
"$",
"script",
"[",
"3",
"]",
")",
";",
"break",
";",
"case",
"'headcss'",
":",
"$",
"layout",
"->",
"headTags",
"->",
"appendStylesheet",
"(",
"$",
"script",
"[",
"1",
"]",
",",
"$",
"script",
"[",
"2",
"]",
",",
"$",
"script",
"[",
"3",
"]",
")",
";",
"break",
";",
"case",
"'footjs'",
":",
"$",
"layout",
"->",
"footTags",
"->",
"appendFile",
"(",
"$",
"script",
"[",
"1",
"]",
",",
"$",
"script",
"[",
"2",
"]",
",",
"$",
"script",
"[",
"3",
"]",
")",
";",
"break",
";",
"case",
"'footcss'",
":",
"$",
"layout",
"->",
"footTags",
"->",
"appendStylesheet",
"(",
"$",
"script",
"[",
"1",
"]",
",",
"$",
"script",
"[",
"2",
"]",
",",
"$",
"script",
"[",
"3",
"]",
")",
";",
"break",
";",
"case",
"'script'",
":",
"$",
"layout",
"->",
"footTags",
"->",
"appendScript",
"(",
"$",
"script",
"[",
"1",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | Attache les fichiers et styles des composants au layout
@param \Osf\View\Helper $layout | [
"Attache",
"les",
"fichiers",
"et",
"styles",
"des",
"composants",
"au",
"layout"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Component.php#L132-L155 |
12,577 | didbot/didbot-api | src/Models/Source.php | Source.getSourceFromCurrentUser | public function getSourceFromCurrentUser($user)
{
$token = $user->token();
$client = $token->client;
if($client->personal_access_client){
$name = $token->name;
$sourceable_id = $token->token_id;
$sourceable_type = 'token';
} else {
$name = $client->name;
$sourceable_id = $client->id;
$sourceable_type = 'client';
}
// if the source already exists return it
$source = $user->sources()->sourceableFilter($sourceable_id, $sourceable_type)->first();
if($source) return $source;
// otherwise setup a new source
$source = new Source();
$source->sourceable_id = $sourceable_id;
$source->name = $name;
$source->sourceable_type = $sourceable_type;
$source->user_id = $user->id;
$source->save();
return $source;
} | php | public function getSourceFromCurrentUser($user)
{
$token = $user->token();
$client = $token->client;
if($client->personal_access_client){
$name = $token->name;
$sourceable_id = $token->token_id;
$sourceable_type = 'token';
} else {
$name = $client->name;
$sourceable_id = $client->id;
$sourceable_type = 'client';
}
// if the source already exists return it
$source = $user->sources()->sourceableFilter($sourceable_id, $sourceable_type)->first();
if($source) return $source;
// otherwise setup a new source
$source = new Source();
$source->sourceable_id = $sourceable_id;
$source->name = $name;
$source->sourceable_type = $sourceable_type;
$source->user_id = $user->id;
$source->save();
return $source;
} | [
"public",
"function",
"getSourceFromCurrentUser",
"(",
"$",
"user",
")",
"{",
"$",
"token",
"=",
"$",
"user",
"->",
"token",
"(",
")",
";",
"$",
"client",
"=",
"$",
"token",
"->",
"client",
";",
"if",
"(",
"$",
"client",
"->",
"personal_access_client",
")",
"{",
"$",
"name",
"=",
"$",
"token",
"->",
"name",
";",
"$",
"sourceable_id",
"=",
"$",
"token",
"->",
"token_id",
";",
"$",
"sourceable_type",
"=",
"'token'",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"client",
"->",
"name",
";",
"$",
"sourceable_id",
"=",
"$",
"client",
"->",
"id",
";",
"$",
"sourceable_type",
"=",
"'client'",
";",
"}",
"// if the source already exists return it",
"$",
"source",
"=",
"$",
"user",
"->",
"sources",
"(",
")",
"->",
"sourceableFilter",
"(",
"$",
"sourceable_id",
",",
"$",
"sourceable_type",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"source",
")",
"return",
"$",
"source",
";",
"// otherwise setup a new source",
"$",
"source",
"=",
"new",
"Source",
"(",
")",
";",
"$",
"source",
"->",
"sourceable_id",
"=",
"$",
"sourceable_id",
";",
"$",
"source",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"source",
"->",
"sourceable_type",
"=",
"$",
"sourceable_type",
";",
"$",
"source",
"->",
"user_id",
"=",
"$",
"user",
"->",
"id",
";",
"$",
"source",
"->",
"save",
"(",
")",
";",
"return",
"$",
"source",
";",
"}"
] | Why create this intermediary table rather then referring to the oauth_clients table directly?
We want every did record to have a source_id that identifies where the did
was created (web, android, ios, google home, ifttt.com, ect). Every did must have come from exactly one source
that source record should not be removed without cascading to all related dids.
However, depending on what type of token is being used we want to name the source using a different method.
It would make sense to refer to personal access tokens by token.name since a user might generate several
different tokens to use on various services. The user would want to know which of those services the dids came
from.
On the other hand an app that uses full oAuth2, such as the official didbot mobile app, will over time issue
multiple tokens to the same user. In this case it would make sense to use the client's name so all dids coming
from the same app will be labeled the same and share a common id.
We want to persist this source information to a separate table to easily search by user_id. In the case of oAuth2
clients, the clients owner isn't the same user as the one proving the access token. Additionally we don't want
to use a tag type for this since | [
"Why",
"create",
"this",
"intermediary",
"table",
"rather",
"then",
"referring",
"to",
"the",
"oauth_clients",
"table",
"directly?"
] | 5e4080ed8d2429acd46c4f2146eb60598a72021b | https://github.com/didbot/didbot-api/blob/5e4080ed8d2429acd46c4f2146eb60598a72021b/src/Models/Source.php#L104-L133 |
12,578 | joffreydemetz/registry | src/Format/JsonFormat.php | JsonFormat.stringToObject | public function stringToObject($data, array $options=[])
{
$data = trim($data);
if ( substr($data, 0, 1) !== '{' && substr($data, -1, 1) !== '}' ){
return Format::getInstance('Yaml')->stringToObject($data, $options);
}
$decoded = json_decode($data);
if ( $decoded === null ){
throw new \RuntimeException(sprintf('Error decoding JSON data: %s', json_last_error_msg()));
}
return (object)$decoded;
} | php | public function stringToObject($data, array $options=[])
{
$data = trim($data);
if ( substr($data, 0, 1) !== '{' && substr($data, -1, 1) !== '}' ){
return Format::getInstance('Yaml')->stringToObject($data, $options);
}
$decoded = json_decode($data);
if ( $decoded === null ){
throw new \RuntimeException(sprintf('Error decoding JSON data: %s', json_last_error_msg()));
}
return (object)$decoded;
} | [
"public",
"function",
"stringToObject",
"(",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"trim",
"(",
"$",
"data",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"1",
")",
"!==",
"'{'",
"&&",
"substr",
"(",
"$",
"data",
",",
"-",
"1",
",",
"1",
")",
"!==",
"'}'",
")",
"{",
"return",
"Format",
"::",
"getInstance",
"(",
"'Yaml'",
")",
"->",
"stringToObject",
"(",
"$",
"data",
",",
"$",
"options",
")",
";",
"}",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"decoded",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Error decoding JSON data: %s'",
",",
"json_last_error_msg",
"(",
")",
")",
")",
";",
"}",
"return",
"(",
"object",
")",
"$",
"decoded",
";",
"}"
] | Parse a JSON formatted string and convert it into an object
If not JSON tries YML.
@param string $data JSON formatted string to convert
@param array $options Options used by the formatter
@return object Data object | [
"Parse",
"a",
"JSON",
"formatted",
"string",
"and",
"convert",
"it",
"into",
"an",
"object"
] | b96f1a78f04871f62deb1187f54b80a742b17938 | https://github.com/joffreydemetz/registry/blob/b96f1a78f04871f62deb1187f54b80a742b17938/src/Format/JsonFormat.php#L38-L52 |
12,579 | Notifier/Notifier | src/ParameterBag/ParameterBagTrait.php | ParameterBagTrait.getParameterBag | public function getParameterBag($identifier)
{
if (isset($this->parameterBags[$identifier])) {
return $this->parameterBags[$identifier];
}
return null;
} | php | public function getParameterBag($identifier)
{
if (isset($this->parameterBags[$identifier])) {
return $this->parameterBags[$identifier];
}
return null;
} | [
"public",
"function",
"getParameterBag",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameterBags",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parameterBags",
"[",
"$",
"identifier",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get a specific ParameterBag based on identifier.
@param string $identifier
@return ParameterBagInterface | [
"Get",
"a",
"specific",
"ParameterBag",
"based",
"on",
"identifier",
"."
] | 1f95656ae963b68734935773c11e44c0af412303 | https://github.com/Notifier/Notifier/blob/1f95656ae963b68734935773c11e44c0af412303/src/ParameterBag/ParameterBagTrait.php#L38-L45 |
12,580 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.colors | public function colors( WP_Customize_Manager $wp_customize ) {
$wp_customize->add_panel(
'colors',
array(
'title' => esc_html__( 'Colors', 'rock' ),
'description' => 'Get what you need.',
'priority' => 40,
)
);
$wp_customize->add_section(
'colors-scheme',
array(
'title' => esc_html__( 'Color Schemes', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-header',
array(
'title' => esc_html__( 'Header', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-menu',
array(
'title' => esc_html__( 'Menu', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-buttons',
array(
'title' => esc_html__( 'Buttons', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-content',
array(
'title' => esc_html__( 'Content', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-footer',
array(
'title' => esc_html__( 'Footer', 'rock' ),
'panel' => 'colors',
)
);
foreach ( $this->colors as $name => $args ) {
$this->register_color_setting( $wp_customize, $name, $args );
}
} | php | public function colors( WP_Customize_Manager $wp_customize ) {
$wp_customize->add_panel(
'colors',
array(
'title' => esc_html__( 'Colors', 'rock' ),
'description' => 'Get what you need.',
'priority' => 40,
)
);
$wp_customize->add_section(
'colors-scheme',
array(
'title' => esc_html__( 'Color Schemes', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-header',
array(
'title' => esc_html__( 'Header', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-menu',
array(
'title' => esc_html__( 'Menu', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-buttons',
array(
'title' => esc_html__( 'Buttons', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-content',
array(
'title' => esc_html__( 'Content', 'rock' ),
'panel' => 'colors',
)
);
$wp_customize->add_section(
'colors-footer',
array(
'title' => esc_html__( 'Footer', 'rock' ),
'panel' => 'colors',
)
);
foreach ( $this->colors as $name => $args ) {
$this->register_color_setting( $wp_customize, $name, $args );
}
} | [
"public",
"function",
"colors",
"(",
"WP_Customize_Manager",
"$",
"wp_customize",
")",
"{",
"$",
"wp_customize",
"->",
"add_panel",
"(",
"'colors'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Colors'",
",",
"'rock'",
")",
",",
"'description'",
"=>",
"'Get what you need.'",
",",
"'priority'",
"=>",
"40",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_section",
"(",
"'colors-scheme'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Color Schemes'",
",",
"'rock'",
")",
",",
"'panel'",
"=>",
"'colors'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_section",
"(",
"'colors-header'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Header'",
",",
"'rock'",
")",
",",
"'panel'",
"=>",
"'colors'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_section",
"(",
"'colors-menu'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Menu'",
",",
"'rock'",
")",
",",
"'panel'",
"=>",
"'colors'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_section",
"(",
"'colors-buttons'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Buttons'",
",",
"'rock'",
")",
",",
"'panel'",
"=>",
"'colors'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_section",
"(",
"'colors-content'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Content'",
",",
"'rock'",
")",
",",
"'panel'",
"=>",
"'colors'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_section",
"(",
"'colors-footer'",
",",
"array",
"(",
"'title'",
"=>",
"esc_html__",
"(",
"'Footer'",
",",
"'rock'",
")",
",",
"'panel'",
"=>",
"'colors'",
",",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"colors",
"as",
"$",
"name",
"=>",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"register_color_setting",
"(",
"$",
"wp_customize",
",",
"$",
"name",
",",
"$",
"args",
")",
";",
"}",
"}"
] | Register color panel, sections, controls, and settings.
@action customize_register
@since 1.0.0
@param WP_Customize_Manager $wp_customize | [
"Register",
"color",
"panel",
"sections",
"controls",
"and",
"settings",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L706-L771 |
12,581 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.register_color_setting | public function register_color_setting( WP_Customize_Manager $wp_customize, $name, array $args ) {
if ( empty( $name ) || empty( $args['default'] ) ) {
return;
}
$name = sanitize_key( $name );
$wp_customize->add_setting(
$name,
array(
'default' => sanitize_hex_color_no_hash( $args['default'] ),
'sanitize_callback' => ( 'header_textcolor' === $name ) ? array( $wp_customize, '_sanitize_header_textcolor' ) : 'sanitize_hex_color_no_hash',
'sanitize_js_callback' => 'maybe_hash_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
$name,
array(
'label' => ! empty( $args['label'] ) ? $args['label'] : $name,
'description' => ! empty( $args['description'] ) ? $args['description'] : null,
'section' => ! empty( $args['section'] ) ? $args['section'] : 'colors-content',
'priority' => ! empty( $args['priority'] ) ? absint( $args['priority'] ) : null,
'active_callback' => ! empty( $args['active_callback'] ) ? $args['active_callback'] : null,
)
)
);
} | php | public function register_color_setting( WP_Customize_Manager $wp_customize, $name, array $args ) {
if ( empty( $name ) || empty( $args['default'] ) ) {
return;
}
$name = sanitize_key( $name );
$wp_customize->add_setting(
$name,
array(
'default' => sanitize_hex_color_no_hash( $args['default'] ),
'sanitize_callback' => ( 'header_textcolor' === $name ) ? array( $wp_customize, '_sanitize_header_textcolor' ) : 'sanitize_hex_color_no_hash',
'sanitize_js_callback' => 'maybe_hash_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
$name,
array(
'label' => ! empty( $args['label'] ) ? $args['label'] : $name,
'description' => ! empty( $args['description'] ) ? $args['description'] : null,
'section' => ! empty( $args['section'] ) ? $args['section'] : 'colors-content',
'priority' => ! empty( $args['priority'] ) ? absint( $args['priority'] ) : null,
'active_callback' => ! empty( $args['active_callback'] ) ? $args['active_callback'] : null,
)
)
);
} | [
"public",
"function",
"register_color_setting",
"(",
"WP_Customize_Manager",
"$",
"wp_customize",
",",
"$",
"name",
",",
"array",
"$",
"args",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"||",
"empty",
"(",
"$",
"args",
"[",
"'default'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"name",
"=",
"sanitize_key",
"(",
"$",
"name",
")",
";",
"$",
"wp_customize",
"->",
"add_setting",
"(",
"$",
"name",
",",
"array",
"(",
"'default'",
"=>",
"sanitize_hex_color_no_hash",
"(",
"$",
"args",
"[",
"'default'",
"]",
")",
",",
"'sanitize_callback'",
"=>",
"(",
"'header_textcolor'",
"===",
"$",
"name",
")",
"?",
"array",
"(",
"$",
"wp_customize",
",",
"'_sanitize_header_textcolor'",
")",
":",
"'sanitize_hex_color_no_hash'",
",",
"'sanitize_js_callback'",
"=>",
"'maybe_hash_hex_color'",
",",
"'transport'",
"=>",
"'postMessage'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_control",
"(",
"new",
"WP_Customize_Color_Control",
"(",
"$",
"wp_customize",
",",
"$",
"name",
",",
"array",
"(",
"'label'",
"=>",
"!",
"empty",
"(",
"$",
"args",
"[",
"'label'",
"]",
")",
"?",
"$",
"args",
"[",
"'label'",
"]",
":",
"$",
"name",
",",
"'description'",
"=>",
"!",
"empty",
"(",
"$",
"args",
"[",
"'description'",
"]",
")",
"?",
"$",
"args",
"[",
"'description'",
"]",
":",
"null",
",",
"'section'",
"=>",
"!",
"empty",
"(",
"$",
"args",
"[",
"'section'",
"]",
")",
"?",
"$",
"args",
"[",
"'section'",
"]",
":",
"'colors-content'",
",",
"'priority'",
"=>",
"!",
"empty",
"(",
"$",
"args",
"[",
"'priority'",
"]",
")",
"?",
"absint",
"(",
"$",
"args",
"[",
"'priority'",
"]",
")",
":",
"null",
",",
"'active_callback'",
"=>",
"!",
"empty",
"(",
"$",
"args",
"[",
"'active_callback'",
"]",
")",
"?",
"$",
"args",
"[",
"'active_callback'",
"]",
":",
"null",
",",
")",
")",
")",
";",
"}"
] | Register a custom color setting.
@since 1.0.0
@see $this->colors()
@param WP_Customize_Manager $wp_customize
@param string $name
@param array $args | [
"Register",
"a",
"custom",
"color",
"setting",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L783-L817 |
12,582 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.enqueue_colors_inline_css | public function enqueue_colors_inline_css() {
foreach ( $this->colors as $name => $args ) {
$this->add_color_inline_css( $name, $args );
}
} | php | public function enqueue_colors_inline_css() {
foreach ( $this->colors as $name => $args ) {
$this->add_color_inline_css( $name, $args );
}
} | [
"public",
"function",
"enqueue_colors_inline_css",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"colors",
"as",
"$",
"name",
"=>",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"add_color_inline_css",
"(",
"$",
"name",
",",
"$",
"args",
")",
";",
"}",
"}"
] | Enqueue inline CSS for custom colors.
@action wp_enqueue_scripts
@since 1.0.0 | [
"Enqueue",
"inline",
"CSS",
"for",
"custom",
"colors",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L825-L833 |
12,583 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.add_color_inline_css | public function add_color_inline_css( $name, array $args ) {
if ( empty( $name ) || empty( $args['css'] ) ) {
return;
}
$default = $this->get_default_color( $name, 'default' );
$hex = trim( get_theme_mod( $name, $default ), '#' );
$css = sprintf( Rock_Customizer::parse_css_rules( $args['css'] ), '#' . $hex );
if ( ! empty( $args['rgba_css'] ) ) {
$css .= sprintf(
Rock_Customizer::parse_css_rules( $args['rgba_css'] ),
implode( ', ', rock_hex2rgb( $hex ) )
);
}
wp_add_inline_style( Rock_Customizer::$stylesheet, $css );
} | php | public function add_color_inline_css( $name, array $args ) {
if ( empty( $name ) || empty( $args['css'] ) ) {
return;
}
$default = $this->get_default_color( $name, 'default' );
$hex = trim( get_theme_mod( $name, $default ), '#' );
$css = sprintf( Rock_Customizer::parse_css_rules( $args['css'] ), '#' . $hex );
if ( ! empty( $args['rgba_css'] ) ) {
$css .= sprintf(
Rock_Customizer::parse_css_rules( $args['rgba_css'] ),
implode( ', ', rock_hex2rgb( $hex ) )
);
}
wp_add_inline_style( Rock_Customizer::$stylesheet, $css );
} | [
"public",
"function",
"add_color_inline_css",
"(",
"$",
"name",
",",
"array",
"$",
"args",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"||",
"empty",
"(",
"$",
"args",
"[",
"'css'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"default",
"=",
"$",
"this",
"->",
"get_default_color",
"(",
"$",
"name",
",",
"'default'",
")",
";",
"$",
"hex",
"=",
"trim",
"(",
"get_theme_mod",
"(",
"$",
"name",
",",
"$",
"default",
")",
",",
"'#'",
")",
";",
"$",
"css",
"=",
"sprintf",
"(",
"Rock_Customizer",
"::",
"parse_css_rules",
"(",
"$",
"args",
"[",
"'css'",
"]",
")",
",",
"'#'",
".",
"$",
"hex",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"'rgba_css'",
"]",
")",
")",
"{",
"$",
"css",
".=",
"sprintf",
"(",
"Rock_Customizer",
"::",
"parse_css_rules",
"(",
"$",
"args",
"[",
"'rgba_css'",
"]",
")",
",",
"implode",
"(",
"', '",
",",
"rock_hex2rgb",
"(",
"$",
"hex",
")",
")",
")",
";",
"}",
"wp_add_inline_style",
"(",
"Rock_Customizer",
"::",
"$",
"stylesheet",
",",
"$",
"css",
")",
";",
"}"
] | Add color inline CSS.
@see $this->enqueue_colors_inline_css()
@since 1.0.0
@param string $name
@param array $args | [
"Add",
"color",
"inline",
"CSS",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L844-L867 |
12,584 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.get_default_color | public function get_default_color( $color, $scheme = '', $hash = false ) {
/**
* Load for backwards compatibility prior to WordPress 4.6.
*
* @link https://core.trac.wordpress.org/ticket/27583
* @since 1.0.0
*/
if ( ! function_exists( 'sanitize_hex_color' ) || ! function_exists( 'sanitize_hex_color_no_hash' ) ) {
require_once ABSPATH . 'wp-includes/class-wp-customize-manager.php';
}
$scheme = empty( $scheme ) ? $this->get_current_color_scheme_array() : $this->color_schemes[ $this->sanitize_color_scheme( $scheme ) ];
$hex = isset( $scheme['colors'][ $color ] ) ? trim( $scheme['colors'][ $color ], '#' ) : null;
return ( $hash ) ? sanitize_hex_color( '#' . $hex ) : sanitize_hex_color_no_hash( $hex );
} | php | public function get_default_color( $color, $scheme = '', $hash = false ) {
/**
* Load for backwards compatibility prior to WordPress 4.6.
*
* @link https://core.trac.wordpress.org/ticket/27583
* @since 1.0.0
*/
if ( ! function_exists( 'sanitize_hex_color' ) || ! function_exists( 'sanitize_hex_color_no_hash' ) ) {
require_once ABSPATH . 'wp-includes/class-wp-customize-manager.php';
}
$scheme = empty( $scheme ) ? $this->get_current_color_scheme_array() : $this->color_schemes[ $this->sanitize_color_scheme( $scheme ) ];
$hex = isset( $scheme['colors'][ $color ] ) ? trim( $scheme['colors'][ $color ], '#' ) : null;
return ( $hash ) ? sanitize_hex_color( '#' . $hex ) : sanitize_hex_color_no_hash( $hex );
} | [
"public",
"function",
"get_default_color",
"(",
"$",
"color",
",",
"$",
"scheme",
"=",
"''",
",",
"$",
"hash",
"=",
"false",
")",
"{",
"/**\n\t\t * Load for backwards compatibility prior to WordPress 4.6.\n\t\t *\n\t\t * @link https://core.trac.wordpress.org/ticket/27583\n\t\t * @since 1.0.0\n\t\t */",
"if",
"(",
"!",
"function_exists",
"(",
"'sanitize_hex_color'",
")",
"||",
"!",
"function_exists",
"(",
"'sanitize_hex_color_no_hash'",
")",
")",
"{",
"require_once",
"ABSPATH",
".",
"'wp-includes/class-wp-customize-manager.php'",
";",
"}",
"$",
"scheme",
"=",
"empty",
"(",
"$",
"scheme",
")",
"?",
"$",
"this",
"->",
"get_current_color_scheme_array",
"(",
")",
":",
"$",
"this",
"->",
"color_schemes",
"[",
"$",
"this",
"->",
"sanitize_color_scheme",
"(",
"$",
"scheme",
")",
"]",
";",
"$",
"hex",
"=",
"isset",
"(",
"$",
"scheme",
"[",
"'colors'",
"]",
"[",
"$",
"color",
"]",
")",
"?",
"trim",
"(",
"$",
"scheme",
"[",
"'colors'",
"]",
"[",
"$",
"color",
"]",
",",
"'#'",
")",
":",
"null",
";",
"return",
"(",
"$",
"hash",
")",
"?",
"sanitize_hex_color",
"(",
"'#'",
".",
"$",
"hex",
")",
":",
"sanitize_hex_color_no_hash",
"(",
"$",
"hex",
")",
";",
"}"
] | Return the default HEX value for a color in a scheme.
@param string $color
@param string $scheme (optional)
@param bool $hash (optional)
@return string|null | [
"Return",
"the",
"default",
"HEX",
"value",
"for",
"a",
"color",
"in",
"a",
"scheme",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L878-L897 |
12,585 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.get_rgba_css | public function get_rgba_css() {
$colors = array();
foreach ( $this->colors as $name => $args ) {
if ( ! empty( $name ) && ! empty( $args['rgba_css'] ) && is_array( $args['rgba_css'] ) ) {
$colors[ $name ] = $args['rgba_css'];
}
}
return $colors;
} | php | public function get_rgba_css() {
$colors = array();
foreach ( $this->colors as $name => $args ) {
if ( ! empty( $name ) && ! empty( $args['rgba_css'] ) && is_array( $args['rgba_css'] ) ) {
$colors[ $name ] = $args['rgba_css'];
}
}
return $colors;
} | [
"public",
"function",
"get_rgba_css",
"(",
")",
"{",
"$",
"colors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"colors",
"as",
"$",
"name",
"=>",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
"&&",
"!",
"empty",
"(",
"$",
"args",
"[",
"'rgba_css'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"args",
"[",
"'rgba_css'",
"]",
")",
")",
"{",
"$",
"colors",
"[",
"$",
"name",
"]",
"=",
"$",
"args",
"[",
"'rgba_css'",
"]",
";",
"}",
"}",
"return",
"$",
"colors",
";",
"}"
] | Return an array of CSS for colors supporting RGBA.
@return array | [
"Return",
"an",
"array",
"of",
"CSS",
"for",
"colors",
"supporting",
"RGBA",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L919-L935 |
12,586 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.color_scheme | public function color_scheme( WP_Customize_Manager $wp_customize ) {
if ( count( $this->color_schemes ) < 2 ) {
return;
}
$wp_customize->add_setting(
'color_scheme',
array(
'default' => 'default',
'sanitize_callback' => array( $this, 'sanitize_color_scheme' ),
'transport' => 'postMessage',
)
);
$choices = array_combine(
array_keys( $this->color_schemes ),
wp_list_pluck( $this->color_schemes, 'label' )
);
$wp_customize->add_control(
'color_scheme',
array(
'label' => esc_html__( 'Base Color Scheme', 'rock' ),
'section' => 'colors-scheme',
'type' => 'select',
'choices' => $choices,
'priority' => 1,
)
);
} | php | public function color_scheme( WP_Customize_Manager $wp_customize ) {
if ( count( $this->color_schemes ) < 2 ) {
return;
}
$wp_customize->add_setting(
'color_scheme',
array(
'default' => 'default',
'sanitize_callback' => array( $this, 'sanitize_color_scheme' ),
'transport' => 'postMessage',
)
);
$choices = array_combine(
array_keys( $this->color_schemes ),
wp_list_pluck( $this->color_schemes, 'label' )
);
$wp_customize->add_control(
'color_scheme',
array(
'label' => esc_html__( 'Base Color Scheme', 'rock' ),
'section' => 'colors-scheme',
'type' => 'select',
'choices' => $choices,
'priority' => 1,
)
);
} | [
"public",
"function",
"color_scheme",
"(",
"WP_Customize_Manager",
"$",
"wp_customize",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"color_schemes",
")",
"<",
"2",
")",
"{",
"return",
";",
"}",
"$",
"wp_customize",
"->",
"add_setting",
"(",
"'color_scheme'",
",",
"array",
"(",
"'default'",
"=>",
"'default'",
",",
"'sanitize_callback'",
"=>",
"array",
"(",
"$",
"this",
",",
"'sanitize_color_scheme'",
")",
",",
"'transport'",
"=>",
"'postMessage'",
",",
")",
")",
";",
"$",
"choices",
"=",
"array_combine",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"color_schemes",
")",
",",
"wp_list_pluck",
"(",
"$",
"this",
"->",
"color_schemes",
",",
"'label'",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_control",
"(",
"'color_scheme'",
",",
"array",
"(",
"'label'",
"=>",
"esc_html__",
"(",
"'Base Color Scheme'",
",",
"'rock'",
")",
",",
"'section'",
"=>",
"'colors-scheme'",
",",
"'type'",
"=>",
"'select'",
",",
"'choices'",
"=>",
"$",
"choices",
",",
"'priority'",
"=>",
"1",
",",
")",
")",
";",
"}"
] | Register a color scheme setting.
@action customize_register
@since 1.0.0
@param WP_Customize_Manager $wp_customize | [
"Register",
"a",
"color",
"scheme",
"setting",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L945-L978 |
12,587 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.colors_control_js | public function colors_control_js() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'rock-colors-control', get_template_directory_uri() . "/assets/js/admin/colors-control{$suffix}.js", array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), ROCK_VERSION, true );
wp_localize_script( 'rock-colors-control', 'colorSchemes', $this->color_schemes );
} | php | public function colors_control_js() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'rock-colors-control', get_template_directory_uri() . "/assets/js/admin/colors-control{$suffix}.js", array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), ROCK_VERSION, true );
wp_localize_script( 'rock-colors-control', 'colorSchemes', $this->color_schemes );
} | [
"public",
"function",
"colors_control_js",
"(",
")",
"{",
"$",
"suffix",
"=",
"SCRIPT_DEBUG",
"?",
"''",
":",
"'.min'",
";",
"wp_enqueue_script",
"(",
"'rock-colors-control'",
",",
"get_template_directory_uri",
"(",
")",
".",
"\"/assets/js/admin/colors-control{$suffix}.js\"",
",",
"array",
"(",
"'customize-controls'",
",",
"'iris'",
",",
"'underscore'",
",",
"'wp-util'",
")",
",",
"ROCK_VERSION",
",",
"true",
")",
";",
"wp_localize_script",
"(",
"'rock-colors-control'",
",",
"'colorSchemes'",
",",
"$",
"this",
"->",
"color_schemes",
")",
";",
"}"
] | Enqueue color scheme control in the Customizer.
@action customize_controls_enqueue_scripts
@since 1.0.0 | [
"Enqueue",
"color",
"scheme",
"control",
"in",
"the",
"Customizer",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L986-L994 |
12,588 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.colors_preview_css | public function colors_preview_css() {
?>
<script type="text/html" id="tmpl-rock-colors-css">
<?php
foreach ( $this->colors as $name => $args ) {
if ( empty( $name ) || empty( $args['css'] ) || ! is_array( $args['css'] ) ) {
continue;
}
printf(
Rock_Customizer::parse_css_rules( $args['css'] ),
sprintf( '{{ data.%s }}', $name )
);
}
?>
</script>
<?php
$rgba_colors = $this->get_rgba_css();
if ( ! $rgba_colors ) {
// Required for themes without rgba css rules
echo '<script type="text/html" id="tmpl-rock-colors-css-rgba"></script>';
}
?>
<script type="text/html" id="tmpl-rock-colors-css-rgba">
<?php
foreach ( $rgba_colors as $name => $css ) {
printf(
Rock_Customizer::parse_css_rules( $css ),
sprintf( '{{ data.%s }}', $name )
);
}
?>
</script>
<?php
} | php | public function colors_preview_css() {
?>
<script type="text/html" id="tmpl-rock-colors-css">
<?php
foreach ( $this->colors as $name => $args ) {
if ( empty( $name ) || empty( $args['css'] ) || ! is_array( $args['css'] ) ) {
continue;
}
printf(
Rock_Customizer::parse_css_rules( $args['css'] ),
sprintf( '{{ data.%s }}', $name )
);
}
?>
</script>
<?php
$rgba_colors = $this->get_rgba_css();
if ( ! $rgba_colors ) {
// Required for themes without rgba css rules
echo '<script type="text/html" id="tmpl-rock-colors-css-rgba"></script>';
}
?>
<script type="text/html" id="tmpl-rock-colors-css-rgba">
<?php
foreach ( $rgba_colors as $name => $css ) {
printf(
Rock_Customizer::parse_css_rules( $css ),
sprintf( '{{ data.%s }}', $name )
);
}
?>
</script>
<?php
} | [
"public",
"function",
"colors_preview_css",
"(",
")",
"{",
"?>\n\t\t<script type=\"text/html\" id=\"tmpl-rock-colors-css\">\n\t\t\t<?php",
"foreach",
"(",
"$",
"this",
"->",
"colors",
"as",
"$",
"name",
"=>",
"$",
"args",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"||",
"empty",
"(",
"$",
"args",
"[",
"'css'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"args",
"[",
"'css'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"printf",
"(",
"Rock_Customizer",
"::",
"parse_css_rules",
"(",
"$",
"args",
"[",
"'css'",
"]",
")",
",",
"sprintf",
"(",
"'{{ data.%s }}'",
",",
"$",
"name",
")",
")",
";",
"}",
"?>\n\t\t</script>\n\t\t<?php",
"$",
"rgba_colors",
"=",
"$",
"this",
"->",
"get_rgba_css",
"(",
")",
";",
"if",
"(",
"!",
"$",
"rgba_colors",
")",
"{",
"// Required for themes without rgba css rules",
"echo",
"'<script type=\"text/html\" id=\"tmpl-rock-colors-css-rgba\"></script>'",
";",
"}",
"?>\n\t\t<script type=\"text/html\" id=\"tmpl-rock-colors-css-rgba\">\n\t\t\t<?php",
"foreach",
"(",
"$",
"rgba_colors",
"as",
"$",
"name",
"=>",
"$",
"css",
")",
"{",
"printf",
"(",
"Rock_Customizer",
"::",
"parse_css_rules",
"(",
"$",
"css",
")",
",",
"sprintf",
"(",
"'{{ data.%s }}'",
",",
"$",
"name",
")",
")",
";",
"}",
"?>\n\t\t</script>\n\t\t<?php",
"}"
] | Inline style for color scheme
@action customize_controls_print_footer_scripts | [
"Inline",
"style",
"for",
"color",
"scheme"
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L1001-L1052 |
12,589 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.sanitize_color_scheme | public function sanitize_color_scheme( $scheme ) {
return ( $this->color_scheme_exists( $scheme ) && $this->is_valid_color_scheme_array( $this->color_schemes[ $scheme ] ) ) ? $scheme : 'default';
} | php | public function sanitize_color_scheme( $scheme ) {
return ( $this->color_scheme_exists( $scheme ) && $this->is_valid_color_scheme_array( $this->color_schemes[ $scheme ] ) ) ? $scheme : 'default';
} | [
"public",
"function",
"sanitize_color_scheme",
"(",
"$",
"scheme",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"color_scheme_exists",
"(",
"$",
"scheme",
")",
"&&",
"$",
"this",
"->",
"is_valid_color_scheme_array",
"(",
"$",
"this",
"->",
"color_schemes",
"[",
"$",
"scheme",
"]",
")",
")",
"?",
"$",
"scheme",
":",
"'default'",
";",
"}"
] | Sanitize a color scheme by ensuring it exists and is valid.
@since 1.0.0
@param string $scheme
@return string | [
"Sanitize",
"a",
"color",
"scheme",
"by",
"ensuring",
"it",
"exists",
"and",
"is",
"valid",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L1099-L1103 |
12,590 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.header | public function header() {
/**
* Filter the custom header args.
*
* @since 1.0.0
*
* @var array
*/
$args = (array) apply_filters( 'rock_custom_header_args',
array(
'default-text-color' => $this->get_default_color( 'header_textcolor', 'default' ),
'width' => 2400,
'height' => 1300,
'flex-height' => true,
'wp-head-callback' => array( $this, 'header_css' ),
)
);
add_theme_support( 'custom-header', $args );
/**
* Filter the default hero images.
*
* @var array
*/
$defaults = (array) apply_filters( 'rock_default_hero_images',
array(
'default' => array(
'url' => 'assets/images/hero.jpg',
'thumbnail_url' => 'assets/images/hero-thumbnail.jpg',
),
)
);
foreach ( $defaults as $name => &$args ) {
$path = trailingslashit( get_stylesheet_directory() );
$url = trailingslashit( get_stylesheet_directory_uri() );
if ( ! file_exists( $path . $args['url'] ) ) {
unset( $defaults[ $name ] );
continue;
}
$args['url'] = $url . $args['url'];
$args['thumbnail_url'] = file_exists( $path . $args['thumbnail_url'] ) ? $url . $args['thumbnail_url'] : $args['url'];
}
if ( $defaults ) {
register_default_headers( $defaults );
}
} | php | public function header() {
/**
* Filter the custom header args.
*
* @since 1.0.0
*
* @var array
*/
$args = (array) apply_filters( 'rock_custom_header_args',
array(
'default-text-color' => $this->get_default_color( 'header_textcolor', 'default' ),
'width' => 2400,
'height' => 1300,
'flex-height' => true,
'wp-head-callback' => array( $this, 'header_css' ),
)
);
add_theme_support( 'custom-header', $args );
/**
* Filter the default hero images.
*
* @var array
*/
$defaults = (array) apply_filters( 'rock_default_hero_images',
array(
'default' => array(
'url' => 'assets/images/hero.jpg',
'thumbnail_url' => 'assets/images/hero-thumbnail.jpg',
),
)
);
foreach ( $defaults as $name => &$args ) {
$path = trailingslashit( get_stylesheet_directory() );
$url = trailingslashit( get_stylesheet_directory_uri() );
if ( ! file_exists( $path . $args['url'] ) ) {
unset( $defaults[ $name ] );
continue;
}
$args['url'] = $url . $args['url'];
$args['thumbnail_url'] = file_exists( $path . $args['thumbnail_url'] ) ? $url . $args['thumbnail_url'] : $args['url'];
}
if ( $defaults ) {
register_default_headers( $defaults );
}
} | [
"public",
"function",
"header",
"(",
")",
"{",
"/**\n\t\t * Filter the custom header args.\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @var array\n\t\t */",
"$",
"args",
"=",
"(",
"array",
")",
"apply_filters",
"(",
"'rock_custom_header_args'",
",",
"array",
"(",
"'default-text-color'",
"=>",
"$",
"this",
"->",
"get_default_color",
"(",
"'header_textcolor'",
",",
"'default'",
")",
",",
"'width'",
"=>",
"2400",
",",
"'height'",
"=>",
"1300",
",",
"'flex-height'",
"=>",
"true",
",",
"'wp-head-callback'",
"=>",
"array",
"(",
"$",
"this",
",",
"'header_css'",
")",
",",
")",
")",
";",
"add_theme_support",
"(",
"'custom-header'",
",",
"$",
"args",
")",
";",
"/**\n\t\t * Filter the default hero images.\n\t\t *\n\t\t * @var array\n\t\t */",
"$",
"defaults",
"=",
"(",
"array",
")",
"apply_filters",
"(",
"'rock_default_hero_images'",
",",
"array",
"(",
"'default'",
"=>",
"array",
"(",
"'url'",
"=>",
"'assets/images/hero.jpg'",
",",
"'thumbnail_url'",
"=>",
"'assets/images/hero-thumbnail.jpg'",
",",
")",
",",
")",
")",
";",
"foreach",
"(",
"$",
"defaults",
"as",
"$",
"name",
"=>",
"&",
"$",
"args",
")",
"{",
"$",
"path",
"=",
"trailingslashit",
"(",
"get_stylesheet_directory",
"(",
")",
")",
";",
"$",
"url",
"=",
"trailingslashit",
"(",
"get_stylesheet_directory_uri",
"(",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
".",
"$",
"args",
"[",
"'url'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"defaults",
"[",
"$",
"name",
"]",
")",
";",
"continue",
";",
"}",
"$",
"args",
"[",
"'url'",
"]",
"=",
"$",
"url",
".",
"$",
"args",
"[",
"'url'",
"]",
";",
"$",
"args",
"[",
"'thumbnail_url'",
"]",
"=",
"file_exists",
"(",
"$",
"path",
".",
"$",
"args",
"[",
"'thumbnail_url'",
"]",
")",
"?",
"$",
"url",
".",
"$",
"args",
"[",
"'thumbnail_url'",
"]",
":",
"$",
"args",
"[",
"'url'",
"]",
";",
"}",
"if",
"(",
"$",
"defaults",
")",
"{",
"register_default_headers",
"(",
"$",
"defaults",
")",
";",
"}",
"}"
] | Add custom header support.
@action after_setup_theme
@since 1.0.0
@uses $this->header_css() | [
"Add",
"custom",
"header",
"support",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L1138-L1197 |
12,591 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.header_css | public function header_css() {
$color = get_header_textcolor();
$css = $this->get_color_css( 'header_textcolor' );
if ( 'blank' === $color ) {
$css = array(
'.site-title, .site-description' => array(
'position' => 'absolute',
'clip' => 'rect(1px, 1px, 1px, 1px)',
),
);
}
if ( $color && $css ) {
printf(
"<style type='text/css'>\n%s\n</style>",
sprintf( Rock_Customizer::parse_css_rules( $css ), $color )
);
}
} | php | public function header_css() {
$color = get_header_textcolor();
$css = $this->get_color_css( 'header_textcolor' );
if ( 'blank' === $color ) {
$css = array(
'.site-title, .site-description' => array(
'position' => 'absolute',
'clip' => 'rect(1px, 1px, 1px, 1px)',
),
);
}
if ( $color && $css ) {
printf(
"<style type='text/css'>\n%s\n</style>",
sprintf( Rock_Customizer::parse_css_rules( $css ), $color )
);
}
} | [
"public",
"function",
"header_css",
"(",
")",
"{",
"$",
"color",
"=",
"get_header_textcolor",
"(",
")",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"get_color_css",
"(",
"'header_textcolor'",
")",
";",
"if",
"(",
"'blank'",
"===",
"$",
"color",
")",
"{",
"$",
"css",
"=",
"array",
"(",
"'.site-title, .site-description'",
"=>",
"array",
"(",
"'position'",
"=>",
"'absolute'",
",",
"'clip'",
"=>",
"'rect(1px, 1px, 1px, 1px)'",
",",
")",
",",
")",
";",
"}",
"if",
"(",
"$",
"color",
"&&",
"$",
"css",
")",
"{",
"printf",
"(",
"\"<style type='text/css'>\\n%s\\n</style>\"",
",",
"sprintf",
"(",
"Rock_Customizer",
"::",
"parse_css_rules",
"(",
"$",
"css",
")",
",",
"$",
"color",
")",
")",
";",
"}",
"}"
] | Custom header CSS.
@see $this->header()
@since 1.0.0 | [
"Custom",
"header",
"CSS",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L1205-L1230 |
12,592 | faithmade/rock | inc/customizer/colors.php | Rock_Customizer_Colors.color_overlay_transparency | public function color_overlay_transparency( WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting(
'hero_image_color_overlay',
array(
'default' => $this->get_color_overlay_transparency_default_value(),
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'hero_image_color_overlay',
array(
'label' => esc_html__( 'Hero Background Overlay', 'rock' ),
'description' => esc_html__( 'Control the color overlay transparency when using a custom Header Image.', 'rock' ),
'section' => 'colors-header',
'priority' => 20,
'active_callback' => 'rock_has_hero_image',
'type' => 'range',
'input_attrs' => array(
'min' => 0,
'max' => 100,
'step' => 1,
),
)
);
} | php | public function color_overlay_transparency( WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting(
'hero_image_color_overlay',
array(
'default' => $this->get_color_overlay_transparency_default_value(),
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'hero_image_color_overlay',
array(
'label' => esc_html__( 'Hero Background Overlay', 'rock' ),
'description' => esc_html__( 'Control the color overlay transparency when using a custom Header Image.', 'rock' ),
'section' => 'colors-header',
'priority' => 20,
'active_callback' => 'rock_has_hero_image',
'type' => 'range',
'input_attrs' => array(
'min' => 0,
'max' => 100,
'step' => 1,
),
)
);
} | [
"public",
"function",
"color_overlay_transparency",
"(",
"WP_Customize_Manager",
"$",
"wp_customize",
")",
"{",
"$",
"wp_customize",
"->",
"add_setting",
"(",
"'hero_image_color_overlay'",
",",
"array",
"(",
"'default'",
"=>",
"$",
"this",
"->",
"get_color_overlay_transparency_default_value",
"(",
")",
",",
"'sanitize_callback'",
"=>",
"'absint'",
",",
"'transport'",
"=>",
"'postMessage'",
",",
")",
")",
";",
"$",
"wp_customize",
"->",
"add_control",
"(",
"'hero_image_color_overlay'",
",",
"array",
"(",
"'label'",
"=>",
"esc_html__",
"(",
"'Hero Background Overlay'",
",",
"'rock'",
")",
",",
"'description'",
"=>",
"esc_html__",
"(",
"'Control the color overlay transparency when using a custom Header Image.'",
",",
"'rock'",
")",
",",
"'section'",
"=>",
"'colors-header'",
",",
"'priority'",
"=>",
"20",
",",
"'active_callback'",
"=>",
"'rock_has_hero_image'",
",",
"'type'",
"=>",
"'range'",
",",
"'input_attrs'",
"=>",
"array",
"(",
"'min'",
"=>",
"0",
",",
"'max'",
"=>",
"100",
",",
"'step'",
"=>",
"1",
",",
")",
",",
")",
")",
";",
"}"
] | Add setting and control for the hero image color overlay transparency.
@action customize_register
@since 1.0.0
@param WP_Customize_Manager $wp_customize | [
"Add",
"setting",
"and",
"control",
"for",
"the",
"hero",
"image",
"color",
"overlay",
"transparency",
"."
] | 2a95ae1ed38cff3d0c20e21530bac30734e434ce | https://github.com/faithmade/rock/blob/2a95ae1ed38cff3d0c20e21530bac30734e434ce/inc/customizer/colors.php#L1265-L1293 |
12,593 | tadcka/Mapper | src/Tadcka/Mapper/Extension/Source/Tree/MapperTreeHelper.php | MapperTreeHelper.getTreeItemFullPath | public function getTreeItemFullPath($itemId, MapperTreeItemInterface $tree)
{
$path = $this->findRecursiveFullPath($itemId, $tree);
if (0 < count($path)) {
$path[$tree->getId()] = $tree->getTitle();
$path = array_reverse($path, true);
}
return $path;
} | php | public function getTreeItemFullPath($itemId, MapperTreeItemInterface $tree)
{
$path = $this->findRecursiveFullPath($itemId, $tree);
if (0 < count($path)) {
$path[$tree->getId()] = $tree->getTitle();
$path = array_reverse($path, true);
}
return $path;
} | [
"public",
"function",
"getTreeItemFullPath",
"(",
"$",
"itemId",
",",
"MapperTreeItemInterface",
"$",
"tree",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"findRecursiveFullPath",
"(",
"$",
"itemId",
",",
"$",
"tree",
")",
";",
"if",
"(",
"0",
"<",
"count",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"[",
"$",
"tree",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"tree",
"->",
"getTitle",
"(",
")",
";",
"$",
"path",
"=",
"array_reverse",
"(",
"$",
"path",
",",
"true",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Get mapper tree item full path.
@param string $itemId
@param MapperTreeItemInterface $tree
@return array | [
"Get",
"mapper",
"tree",
"item",
"full",
"path",
"."
] | 6853a2be08dcd35a1013c0a4aba9b71a727ff7da | https://github.com/tadcka/Mapper/blob/6853a2be08dcd35a1013c0a4aba9b71a727ff7da/src/Tadcka/Mapper/Extension/Source/Tree/MapperTreeHelper.php#L29-L39 |
12,594 | tadcka/Mapper | src/Tadcka/Mapper/Extension/Source/Tree/MapperTreeHelper.php | MapperTreeHelper.findRecursiveFullPath | private function findRecursiveFullPath($itemId, MapperTreeItemInterface $tree)
{
foreach ($tree->getChildren() as $child) {
if ($itemId === $child->getId()) {
return [$itemId => $child->getTitle()];
} else {
$path = $this->findRecursiveFullPath($itemId, $child);
if (0 < count($path)) {
$path[$child->getId()] = $child->getTitle();
return $path;
}
}
}
return [];
} | php | private function findRecursiveFullPath($itemId, MapperTreeItemInterface $tree)
{
foreach ($tree->getChildren() as $child) {
if ($itemId === $child->getId()) {
return [$itemId => $child->getTitle()];
} else {
$path = $this->findRecursiveFullPath($itemId, $child);
if (0 < count($path)) {
$path[$child->getId()] = $child->getTitle();
return $path;
}
}
}
return [];
} | [
"private",
"function",
"findRecursiveFullPath",
"(",
"$",
"itemId",
",",
"MapperTreeItemInterface",
"$",
"tree",
")",
"{",
"foreach",
"(",
"$",
"tree",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"itemId",
"===",
"$",
"child",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"[",
"$",
"itemId",
"=>",
"$",
"child",
"->",
"getTitle",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"findRecursiveFullPath",
"(",
"$",
"itemId",
",",
"$",
"child",
")",
";",
"if",
"(",
"0",
"<",
"count",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"[",
"$",
"child",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"child",
"->",
"getTitle",
"(",
")",
";",
"return",
"$",
"path",
";",
"}",
"}",
"}",
"return",
"[",
"]",
";",
"}"
] | Find recursive full path.
@param string $itemId
@param MapperTreeItemInterface $tree
@return array | [
"Find",
"recursive",
"full",
"path",
"."
] | 6853a2be08dcd35a1013c0a4aba9b71a727ff7da | https://github.com/tadcka/Mapper/blob/6853a2be08dcd35a1013c0a4aba9b71a727ff7da/src/Tadcka/Mapper/Extension/Source/Tree/MapperTreeHelper.php#L49-L65 |
12,595 | Apatis/Middleware | src/Middleware.php | Middleware.currentStackMiddleware | protected function currentStackMiddleware() : MiddlewareStorage
{
// add current object as first middleware middleware
if (count($this->middleware) === 0) {
$middleware = method_exists($this, '__invoke')
? $this
: new FakeMiddlewareInvokable();
$this->middleware[] = new MiddlewareStorage($middleware);
}
$middleware = end($this->middleware);
return $middleware;
} | php | protected function currentStackMiddleware() : MiddlewareStorage
{
// add current object as first middleware middleware
if (count($this->middleware) === 0) {
$middleware = method_exists($this, '__invoke')
? $this
: new FakeMiddlewareInvokable();
$this->middleware[] = new MiddlewareStorage($middleware);
}
$middleware = end($this->middleware);
return $middleware;
} | [
"protected",
"function",
"currentStackMiddleware",
"(",
")",
":",
"MiddlewareStorage",
"{",
"// add current object as first middleware middleware",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"middleware",
")",
"===",
"0",
")",
"{",
"$",
"middleware",
"=",
"method_exists",
"(",
"$",
"this",
",",
"'__invoke'",
")",
"?",
"$",
"this",
":",
"new",
"FakeMiddlewareInvokable",
"(",
")",
";",
"$",
"this",
"->",
"middleware",
"[",
"]",
"=",
"new",
"MiddlewareStorage",
"(",
"$",
"middleware",
")",
";",
"}",
"$",
"middleware",
"=",
"end",
"(",
"$",
"this",
"->",
"middleware",
")",
";",
"return",
"$",
"middleware",
";",
"}"
] | Initialize middleware stack
this recommended to intended for middleware empty
@access protected | [
"Initialize",
"middleware",
"stack",
"this",
"recommended",
"to",
"intended",
"for",
"middleware",
"empty"
] | 4335f7c9fa37992d5f7d66f99557c06d97f77abb | https://github.com/Apatis/Middleware/blob/4335f7c9fa37992d5f7d66f99557c06d97f77abb/src/Middleware.php#L52-L64 |
12,596 | diatem-net/jin-webapp | src/WebApp/Utils/Navigation.php | Navigation.clearQueryArg | public static function clearQueryArg($code)
{
if (StringTools::left($code, 1) == '/') {
$code = StringTools::right($code, StringTools::len($code)-1);
}
if (StringTools::right($code, 1) == '/') {
$code = StringTools::left($code, StringTools::len($code)-1);
}
return $code;
} | php | public static function clearQueryArg($code)
{
if (StringTools::left($code, 1) == '/') {
$code = StringTools::right($code, StringTools::len($code)-1);
}
if (StringTools::right($code, 1) == '/') {
$code = StringTools::left($code, StringTools::len($code)-1);
}
return $code;
} | [
"public",
"static",
"function",
"clearQueryArg",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"StringTools",
"::",
"left",
"(",
"$",
"code",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"code",
"=",
"StringTools",
"::",
"right",
"(",
"$",
"code",
",",
"StringTools",
"::",
"len",
"(",
"$",
"code",
")",
"-",
"1",
")",
";",
"}",
"if",
"(",
"StringTools",
"::",
"right",
"(",
"$",
"code",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"code",
"=",
"StringTools",
"::",
"left",
"(",
"$",
"code",
",",
"StringTools",
"::",
"len",
"(",
"$",
"code",
")",
"-",
"1",
")",
";",
"}",
"return",
"$",
"code",
";",
"}"
] | Clean the Url code
@param string $code Url code
@return string | [
"Clean",
"the",
"Url",
"code"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Utils/Navigation.php#L41-L51 |
12,597 | diatem-net/jin-webapp | src/WebApp/Utils/Navigation.php | Navigation.redirectToSame | public static function redirectToSame($exceptedArgs = array(), $addedArgs = array(), $anchor = null)
{
self::initialize();
header('Location: '.self::getCurrentUrl($exceptedArgs, $addedArgs, $anchor));
exit;
} | php | public static function redirectToSame($exceptedArgs = array(), $addedArgs = array(), $anchor = null)
{
self::initialize();
header('Location: '.self::getCurrentUrl($exceptedArgs, $addedArgs, $anchor));
exit;
} | [
"public",
"static",
"function",
"redirectToSame",
"(",
"$",
"exceptedArgs",
"=",
"array",
"(",
")",
",",
"$",
"addedArgs",
"=",
"array",
"(",
")",
",",
"$",
"anchor",
"=",
"null",
")",
"{",
"self",
"::",
"initialize",
"(",
")",
";",
"header",
"(",
"'Location: '",
".",
"self",
"::",
"getCurrentUrl",
"(",
"$",
"exceptedArgs",
",",
"$",
"addedArgs",
",",
"$",
"anchor",
")",
")",
";",
"exit",
";",
"}"
] | Redirect to the same page
@param array $exceptedArgs (optional) Arguments to remove during the redirection
@param array $addedArgs (optional) Arguments to add during the redirection
@param string $anchor (optional) Anchor | [
"Redirect",
"to",
"the",
"same",
"page"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Utils/Navigation.php#L75-L81 |
12,598 | diatem-net/jin-webapp | src/WebApp/Utils/Navigation.php | Navigation.getUrlFromCode | public static function getUrlFromCode($code, $addedArgs = array(), $anchor = null)
{
self::initialize();
$code = self::clearQueryArg($code);
if ($code == '_root') {
return WebApp::url();
}
if (StringTools::right($code, 1) != '/') {
$code .= '/';
}
$args = array('q' => $code);
$args = array_merge($args, $addedArgs);
return Url::getUrl(null, $args, true, $anchor);
} | php | public static function getUrlFromCode($code, $addedArgs = array(), $anchor = null)
{
self::initialize();
$code = self::clearQueryArg($code);
if ($code == '_root') {
return WebApp::url();
}
if (StringTools::right($code, 1) != '/') {
$code .= '/';
}
$args = array('q' => $code);
$args = array_merge($args, $addedArgs);
return Url::getUrl(null, $args, true, $anchor);
} | [
"public",
"static",
"function",
"getUrlFromCode",
"(",
"$",
"code",
",",
"$",
"addedArgs",
"=",
"array",
"(",
")",
",",
"$",
"anchor",
"=",
"null",
")",
"{",
"self",
"::",
"initialize",
"(",
")",
";",
"$",
"code",
"=",
"self",
"::",
"clearQueryArg",
"(",
"$",
"code",
")",
";",
"if",
"(",
"$",
"code",
"==",
"'_root'",
")",
"{",
"return",
"WebApp",
"::",
"url",
"(",
")",
";",
"}",
"if",
"(",
"StringTools",
"::",
"right",
"(",
"$",
"code",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"code",
".=",
"'/'",
";",
"}",
"$",
"args",
"=",
"array",
"(",
"'q'",
"=>",
"$",
"code",
")",
";",
"$",
"args",
"=",
"array_merge",
"(",
"$",
"args",
",",
"$",
"addedArgs",
")",
";",
"return",
"Url",
"::",
"getUrl",
"(",
"null",
",",
"$",
"args",
",",
"true",
",",
"$",
"anchor",
")",
";",
"}"
] | Get a full url from an url code
@param string $code Url code
@param array $addedArgs (optional) Additional arguments
@param string $anchor (optional) Anchor | [
"Get",
"a",
"full",
"url",
"from",
"an",
"url",
"code"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Utils/Navigation.php#L90-L107 |
12,599 | diatem-net/jin-webapp | src/WebApp/Utils/Navigation.php | Navigation.getCurrentUrl | public static function getCurrentUrl($exceptedArgs = array(), $addedArgs = array(), $anchor = null)
{
self::initialize();
return Url::getCurrentUrl(null, $addedArgs, $exceptedArgs, true, $anchor);
} | php | public static function getCurrentUrl($exceptedArgs = array(), $addedArgs = array(), $anchor = null)
{
self::initialize();
return Url::getCurrentUrl(null, $addedArgs, $exceptedArgs, true, $anchor);
} | [
"public",
"static",
"function",
"getCurrentUrl",
"(",
"$",
"exceptedArgs",
"=",
"array",
"(",
")",
",",
"$",
"addedArgs",
"=",
"array",
"(",
")",
",",
"$",
"anchor",
"=",
"null",
")",
"{",
"self",
"::",
"initialize",
"(",
")",
";",
"return",
"Url",
"::",
"getCurrentUrl",
"(",
"null",
",",
"$",
"addedArgs",
",",
"$",
"exceptedArgs",
",",
"true",
",",
"$",
"anchor",
")",
";",
"}"
] | Return the current url
@param array $exceptedArgs (optional) Arguments to remove from the current url
@param array $addedArgs (optional) Arguments to add to the current url
@param string $anchor (optional) Anchor | [
"Return",
"the",
"current",
"url"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Utils/Navigation.php#L116-L121 |
Subsets and Splits