id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
228,300
|
antaresproject/core
|
src/utils/customfield/src/Traits/Customfields.php
|
Customfields.customfields
|
public function customfields($fieldset = null)
{
$return = [];
$customfields = $this->getAssignedCustomfields();
foreach ($customfields as $customfield) {
if (is_null($customfield)) {
continue;
}
$value = $customfield->setModel($this)->getValue();
array_set($return, $customfield->getName(), ['label' => $customfield->label, 'value' => $value]);
}
return $return;
}
|
php
|
public function customfields($fieldset = null)
{
$return = [];
$customfields = $this->getAssignedCustomfields();
foreach ($customfields as $customfield) {
if (is_null($customfield)) {
continue;
}
$value = $customfield->setModel($this)->getValue();
array_set($return, $customfield->getName(), ['label' => $customfield->label, 'value' => $value]);
}
return $return;
}
|
[
"public",
"function",
"customfields",
"(",
"$",
"fieldset",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"$",
"customfields",
"=",
"$",
"this",
"->",
"getAssignedCustomfields",
"(",
")",
";",
"foreach",
"(",
"$",
"customfields",
"as",
"$",
"customfield",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"customfield",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"customfield",
"->",
"setModel",
"(",
"$",
"this",
")",
"->",
"getValue",
"(",
")",
";",
"array_set",
"(",
"$",
"return",
",",
"$",
"customfield",
"->",
"getName",
"(",
")",
",",
"[",
"'label'",
"=>",
"$",
"customfield",
"->",
"label",
",",
"'value'",
"=>",
"$",
"value",
"]",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Gets all customfields available in model
@param String $fieldset
@return array
|
[
"Gets",
"all",
"customfields",
"available",
"in",
"model"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/customfield/src/Traits/Customfields.php#L84-L97
|
228,301
|
lawoole/framework
|
src/Homer/Components/ServiceComponent.php
|
ServiceComponent.export
|
public function export()
{
if ($this->config == null) {
throw new LogicException('Context must be set before export the service.');
}
if ($this->dispatcher == null) {
throw new LogicException('Dispatcher must be set before export the service.');
}
$this->dispatcher->exportInvoker(
$this->getInvoker()
);
}
|
php
|
public function export()
{
if ($this->config == null) {
throw new LogicException('Context must be set before export the service.');
}
if ($this->dispatcher == null) {
throw new LogicException('Dispatcher must be set before export the service.');
}
$this->dispatcher->exportInvoker(
$this->getInvoker()
);
}
|
[
"public",
"function",
"export",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"==",
"null",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Context must be set before export the service.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"dispatcher",
"==",
"null",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Dispatcher must be set before export the service.'",
")",
";",
"}",
"$",
"this",
"->",
"dispatcher",
"->",
"exportInvoker",
"(",
"$",
"this",
"->",
"getInvoker",
"(",
")",
")",
";",
"}"
] |
Export the interface.
|
[
"Export",
"the",
"interface",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/ServiceComponent.php#L64-L77
|
228,302
|
lawoole/framework
|
src/Homer/Components/ServiceComponent.php
|
ServiceComponent.getInvoker
|
public function getInvoker()
{
if ($this->invoker !== null) {
return $this->invoker;
}
return $this->invoker = $this->createInvoker();
}
|
php
|
public function getInvoker()
{
if ($this->invoker !== null) {
return $this->invoker;
}
return $this->invoker = $this->createInvoker();
}
|
[
"public",
"function",
"getInvoker",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"invoker",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
";",
"}",
"return",
"$",
"this",
"->",
"invoker",
"=",
"$",
"this",
"->",
"createInvoker",
"(",
")",
";",
"}"
] |
Get invoker for the interface.
@return \Lawoole\Homer\Calling\Invokers\Invoker
|
[
"Get",
"invoker",
"for",
"the",
"interface",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/ServiceComponent.php#L84-L91
|
228,303
|
lawoole/framework
|
src/Homer/Components/ServiceComponent.php
|
ServiceComponent.createInvoker
|
protected function createInvoker()
{
$config = $this->config;
$interface = Arr::pull($config, 'interface');
$concrete = Arr::pull($config, 'refer', $interface);
$invoker = new ConcreteInvoker($this->context, $interface, $concrete, $config);
return $this->withMiddleware($invoker, $interface, $config);
}
|
php
|
protected function createInvoker()
{
$config = $this->config;
$interface = Arr::pull($config, 'interface');
$concrete = Arr::pull($config, 'refer', $interface);
$invoker = new ConcreteInvoker($this->context, $interface, $concrete, $config);
return $this->withMiddleware($invoker, $interface, $config);
}
|
[
"protected",
"function",
"createInvoker",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"$",
"interface",
"=",
"Arr",
"::",
"pull",
"(",
"$",
"config",
",",
"'interface'",
")",
";",
"$",
"concrete",
"=",
"Arr",
"::",
"pull",
"(",
"$",
"config",
",",
"'refer'",
",",
"$",
"interface",
")",
";",
"$",
"invoker",
"=",
"new",
"ConcreteInvoker",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"interface",
",",
"$",
"concrete",
",",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"withMiddleware",
"(",
"$",
"invoker",
",",
"$",
"interface",
",",
"$",
"config",
")",
";",
"}"
] |
Create the invoker.
@return \Lawoole\Homer\Calling\Invokers\Invoker
|
[
"Create",
"the",
"invoker",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/ServiceComponent.php#L98-L108
|
228,304
|
gggeek/ggwebservices
|
classes/gghttpresponse.php
|
ggHTTPResponse.decodeStream
|
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" )
{
$this->decodeStreamCommon( $request, $stream, $headers, $cookies, $statuscode );
$this->Value = $stream;
}
|
php
|
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" )
{
$this->decodeStreamCommon( $request, $stream, $headers, $cookies, $statuscode );
$this->Value = $stream;
}
|
[
"function",
"decodeStream",
"(",
"$",
"request",
",",
"$",
"stream",
",",
"$",
"headers",
"=",
"false",
",",
"$",
"cookies",
"=",
"array",
"(",
")",
",",
"$",
"statuscode",
"=",
"\"200\"",
")",
"{",
"$",
"this",
"->",
"decodeStreamCommon",
"(",
"$",
"request",
",",
"$",
"stream",
",",
"$",
"headers",
",",
"$",
"cookies",
",",
"$",
"statuscode",
")",
";",
"$",
"this",
"->",
"Value",
"=",
"$",
"stream",
";",
"}"
] |
Decodes the HTTP response stream.
|
[
"Decodes",
"the",
"HTTP",
"response",
"stream",
"."
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/gghttpresponse.php#L23-L28
|
228,305
|
gggeek/ggwebservices
|
classes/ggwebservicesclient.php
|
ggWebservicesClient.decode_chunked
|
protected static function decode_chunked( $buffer )
{
$length = 0;
$new = '';
// read chunk-size, chunk-extension (if any) and crlf
// get the position of the linebreak
$chunkend = strpos($buffer,"\r\n") + 2;
$temp = substr($buffer,0,$chunkend);
$chunk_size = hexdec( trim($temp) );
$chunkstart = $chunkend;
while($chunk_size > 0)
{
$chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size);
// just in case we got a broken connection
if($chunkend == false)
{
$chunk = substr($buffer,$chunkstart);
// append chunk-data to entity-body
$new .= $chunk;
$length += strlen($chunk);
break;
}
// read chunk-data and crlf
$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
// append chunk-data to entity-body
$new .= $chunk;
// length := length + chunk-size
$length += strlen($chunk);
// read chunk-size and crlf
$chunkstart = $chunkend + 2;
$chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
if($chunkend == false)
{
break; //just in case we got a broken connection
}
$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
$chunk_size = hexdec( trim($temp) );
$chunkstart = $chunkend;
}
return $new;
}
|
php
|
protected static function decode_chunked( $buffer )
{
$length = 0;
$new = '';
// read chunk-size, chunk-extension (if any) and crlf
// get the position of the linebreak
$chunkend = strpos($buffer,"\r\n") + 2;
$temp = substr($buffer,0,$chunkend);
$chunk_size = hexdec( trim($temp) );
$chunkstart = $chunkend;
while($chunk_size > 0)
{
$chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size);
// just in case we got a broken connection
if($chunkend == false)
{
$chunk = substr($buffer,$chunkstart);
// append chunk-data to entity-body
$new .= $chunk;
$length += strlen($chunk);
break;
}
// read chunk-data and crlf
$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
// append chunk-data to entity-body
$new .= $chunk;
// length := length + chunk-size
$length += strlen($chunk);
// read chunk-size and crlf
$chunkstart = $chunkend + 2;
$chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
if($chunkend == false)
{
break; //just in case we got a broken connection
}
$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
$chunk_size = hexdec( trim($temp) );
$chunkstart = $chunkend;
}
return $new;
}
|
[
"protected",
"static",
"function",
"decode_chunked",
"(",
"$",
"buffer",
")",
"{",
"$",
"length",
"=",
"0",
";",
"$",
"new",
"=",
"''",
";",
"// read chunk-size, chunk-extension (if any) and crlf",
"// get the position of the linebreak",
"$",
"chunkend",
"=",
"strpos",
"(",
"$",
"buffer",
",",
"\"\\r\\n\"",
")",
"+",
"2",
";",
"$",
"temp",
"=",
"substr",
"(",
"$",
"buffer",
",",
"0",
",",
"$",
"chunkend",
")",
";",
"$",
"chunk_size",
"=",
"hexdec",
"(",
"trim",
"(",
"$",
"temp",
")",
")",
";",
"$",
"chunkstart",
"=",
"$",
"chunkend",
";",
"while",
"(",
"$",
"chunk_size",
">",
"0",
")",
"{",
"$",
"chunkend",
"=",
"strpos",
"(",
"$",
"buffer",
",",
"\"\\r\\n\"",
",",
"$",
"chunkstart",
"+",
"$",
"chunk_size",
")",
";",
"// just in case we got a broken connection",
"if",
"(",
"$",
"chunkend",
"==",
"false",
")",
"{",
"$",
"chunk",
"=",
"substr",
"(",
"$",
"buffer",
",",
"$",
"chunkstart",
")",
";",
"// append chunk-data to entity-body",
"$",
"new",
".=",
"$",
"chunk",
";",
"$",
"length",
"+=",
"strlen",
"(",
"$",
"chunk",
")",
";",
"break",
";",
"}",
"// read chunk-data and crlf",
"$",
"chunk",
"=",
"substr",
"(",
"$",
"buffer",
",",
"$",
"chunkstart",
",",
"$",
"chunkend",
"-",
"$",
"chunkstart",
")",
";",
"// append chunk-data to entity-body",
"$",
"new",
".=",
"$",
"chunk",
";",
"// length := length + chunk-size",
"$",
"length",
"+=",
"strlen",
"(",
"$",
"chunk",
")",
";",
"// read chunk-size and crlf",
"$",
"chunkstart",
"=",
"$",
"chunkend",
"+",
"2",
";",
"$",
"chunkend",
"=",
"strpos",
"(",
"$",
"buffer",
",",
"\"\\r\\n\"",
",",
"$",
"chunkstart",
")",
"+",
"2",
";",
"if",
"(",
"$",
"chunkend",
"==",
"false",
")",
"{",
"break",
";",
"//just in case we got a broken connection",
"}",
"$",
"temp",
"=",
"substr",
"(",
"$",
"buffer",
",",
"$",
"chunkstart",
",",
"$",
"chunkend",
"-",
"$",
"chunkstart",
")",
";",
"$",
"chunk_size",
"=",
"hexdec",
"(",
"trim",
"(",
"$",
"temp",
")",
")",
";",
"$",
"chunkstart",
"=",
"$",
"chunkend",
";",
"}",
"return",
"$",
"new",
";",
"}"
] |
Decode a string that is encoded w. "chunked" transfer encoding
as defined in rfc2068 par. 19.4.6
Code shamelessly stolen from nusoap library by Dietrich Ayala
@param string $buffer the string to be decoded
@return string
|
[
"Decode",
"a",
"string",
"that",
"is",
"encoded",
"w",
".",
"chunked",
"transfer",
"encoding",
"as",
"defined",
"in",
"rfc2068",
"par",
".",
"19",
".",
"4",
".",
"6",
"Code",
"shamelessly",
"stolen",
"from",
"nusoap",
"library",
"by",
"Dietrich",
"Ayala"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesclient.php#L752-L796
|
228,306
|
gggeek/ggwebservices
|
classes/ggwebservicesclient.php
|
ggWebservicesClient.setOption
|
function setOption( $option, $value )
{
if ( !in_array( $option, $this->Options ) )
{
// throwing an exception would make more sense, but we did not before - keep this for compat
return false;
//throw new Exception( "Option $option not supported" );
}
switch( $option )
{
case 'timeout':
$this->Timeout = (int)$value;
break;
case 'login':
$this->Login = $value;
break;
case 'password':
$this->Password = $value;
break;
case 'authType':
$this->AuthType = (int)$value;
if ( $value != 1 )
{
$this->ForceCURL = true;
}
break;
case 'requestCompression':
$this->RequestCompression = $value;
break;
case 'method':
$this->Verb = strtoupper( $value );
break;
case 'acceptedCompression':
$this->AcceptedCompression = $value;
break;
case 'proxyHost':
$this->Proxy = $value;
break;
case 'proxyPort':
$this->ProxyPort = ( (int)$value != 0 ? (int)$value : 8080 );
break;
case 'proxyUser':
$this->ProxyLogin = $value;
break;
case 'proxyPassword':
$this->ProxyPassword = $value;
break;
case 'proxyAuthType':
$this->ProxyAuthType = (int)$value;
if ( $value != 1 )
{
$this->ForceCURL = true;
}
break;
case 'forceCURL':
$this->ForceCURL = (bool)$value;
break;
case 'debug':
$this->Debug = (int)$value;
break;
case 'SSLVerifyHost':
$this->SSLVerifyHost = (int)$value;
break;
case 'SSLVerifyPeer':
$this->SSLVerifyPeer = (bool)$value;
break;
case 'SSLCAInfo':
$this->SSLCAInfo = $value;
break;
}
return true;
}
|
php
|
function setOption( $option, $value )
{
if ( !in_array( $option, $this->Options ) )
{
// throwing an exception would make more sense, but we did not before - keep this for compat
return false;
//throw new Exception( "Option $option not supported" );
}
switch( $option )
{
case 'timeout':
$this->Timeout = (int)$value;
break;
case 'login':
$this->Login = $value;
break;
case 'password':
$this->Password = $value;
break;
case 'authType':
$this->AuthType = (int)$value;
if ( $value != 1 )
{
$this->ForceCURL = true;
}
break;
case 'requestCompression':
$this->RequestCompression = $value;
break;
case 'method':
$this->Verb = strtoupper( $value );
break;
case 'acceptedCompression':
$this->AcceptedCompression = $value;
break;
case 'proxyHost':
$this->Proxy = $value;
break;
case 'proxyPort':
$this->ProxyPort = ( (int)$value != 0 ? (int)$value : 8080 );
break;
case 'proxyUser':
$this->ProxyLogin = $value;
break;
case 'proxyPassword':
$this->ProxyPassword = $value;
break;
case 'proxyAuthType':
$this->ProxyAuthType = (int)$value;
if ( $value != 1 )
{
$this->ForceCURL = true;
}
break;
case 'forceCURL':
$this->ForceCURL = (bool)$value;
break;
case 'debug':
$this->Debug = (int)$value;
break;
case 'SSLVerifyHost':
$this->SSLVerifyHost = (int)$value;
break;
case 'SSLVerifyPeer':
$this->SSLVerifyPeer = (bool)$value;
break;
case 'SSLCAInfo':
$this->SSLCAInfo = $value;
break;
}
return true;
}
|
[
"function",
"setOption",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"Options",
")",
")",
"{",
"// throwing an exception would make more sense, but we did not before - keep this for compat",
"return",
"false",
";",
"//throw new Exception( \"Option $option not supported\" );",
"}",
"switch",
"(",
"$",
"option",
")",
"{",
"case",
"'timeout'",
":",
"$",
"this",
"->",
"Timeout",
"=",
"(",
"int",
")",
"$",
"value",
";",
"break",
";",
"case",
"'login'",
":",
"$",
"this",
"->",
"Login",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'password'",
":",
"$",
"this",
"->",
"Password",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'authType'",
":",
"$",
"this",
"->",
"AuthType",
"=",
"(",
"int",
")",
"$",
"value",
";",
"if",
"(",
"$",
"value",
"!=",
"1",
")",
"{",
"$",
"this",
"->",
"ForceCURL",
"=",
"true",
";",
"}",
"break",
";",
"case",
"'requestCompression'",
":",
"$",
"this",
"->",
"RequestCompression",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'method'",
":",
"$",
"this",
"->",
"Verb",
"=",
"strtoupper",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'acceptedCompression'",
":",
"$",
"this",
"->",
"AcceptedCompression",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'proxyHost'",
":",
"$",
"this",
"->",
"Proxy",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'proxyPort'",
":",
"$",
"this",
"->",
"ProxyPort",
"=",
"(",
"(",
"int",
")",
"$",
"value",
"!=",
"0",
"?",
"(",
"int",
")",
"$",
"value",
":",
"8080",
")",
";",
"break",
";",
"case",
"'proxyUser'",
":",
"$",
"this",
"->",
"ProxyLogin",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'proxyPassword'",
":",
"$",
"this",
"->",
"ProxyPassword",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'proxyAuthType'",
":",
"$",
"this",
"->",
"ProxyAuthType",
"=",
"(",
"int",
")",
"$",
"value",
";",
"if",
"(",
"$",
"value",
"!=",
"1",
")",
"{",
"$",
"this",
"->",
"ForceCURL",
"=",
"true",
";",
"}",
"break",
";",
"case",
"'forceCURL'",
":",
"$",
"this",
"->",
"ForceCURL",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"break",
";",
"case",
"'debug'",
":",
"$",
"this",
"->",
"Debug",
"=",
"(",
"int",
")",
"$",
"value",
";",
"break",
";",
"case",
"'SSLVerifyHost'",
":",
"$",
"this",
"->",
"SSLVerifyHost",
"=",
"(",
"int",
")",
"$",
"value",
";",
"break",
";",
"case",
"'SSLVerifyPeer'",
":",
"$",
"this",
"->",
"SSLVerifyPeer",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"break",
";",
"case",
"'SSLCAInfo'",
":",
"$",
"this",
"->",
"SSLCAInfo",
"=",
"$",
"value",
";",
"break",
";",
"}",
"return",
"true",
";",
"}"
] |
One-stop shop for setting all configuration options
without having to write a hundred method calls
@param string $option
@param mixed $value
@return bool false if option does not exist
|
[
"One",
"-",
"stop",
"shop",
"for",
"setting",
"all",
"configuration",
"options",
"without",
"having",
"to",
"write",
"a",
"hundred",
"method",
"calls"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesclient.php#L805-L877
|
228,307
|
gggeek/ggwebservices
|
classes/ggwebservicesclient.php
|
ggWebservicesClient.setOptions
|
function setOptions( $optionArray )
{
foreach( $optionArray as $name => $value )
{
$this->setOption( $name, $value );
}
}
|
php
|
function setOptions( $optionArray )
{
foreach( $optionArray as $name => $value )
{
$this->setOption( $name, $value );
}
}
|
[
"function",
"setOptions",
"(",
"$",
"optionArray",
")",
"{",
"foreach",
"(",
"$",
"optionArray",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Set many options in one fell swoop
@param array $optionArray
@throws Exception if an option does not exist
|
[
"Set",
"many",
"options",
"in",
"one",
"fell",
"swoop"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesclient.php#L884-L890
|
228,308
|
gggeek/ggwebservices
|
classes/ggwebservicesclient.php
|
ggWebservicesClient.getOption
|
function getOption( $option )
{
if ( !in_array( $option, $this->Options ) )
{
throw new Exception( "Option $option not supported" );
}
switch( $option )
{
case 'timeout':
return $this->Timeout;
case 'login':
return $this->Login;
case 'password':
return $this->Password;
case 'authType':
return $this->AuthType;
case 'requestCompression':
return $this->RequestCompression;
case 'method':
return $this->Verb;
case 'acceptedCompression':
return $this->AcceptedCompression;
case 'proxyHost':
return $this->Proxy;
case 'proxyPort':
return $this->ProxyPort;
case 'proxyUser':
return $this->ProxyLogin;
case 'proxyPassword':
return $this->ProxyPassword;
case 'proxyAuthType':
return $this->ProxyAuthType;
case 'forceCURL':
return $this->ForceCURL;
case 'debug':
return $this->Debug;
case 'SSLVerifyHost':
return $this->SSLVerifyHost;
case 'SSLVerifyPeer':
return $this->SSLVerifyPeer;
case 'SSLCAInfo':
return $this->SSLCAInfo;
}
}
|
php
|
function getOption( $option )
{
if ( !in_array( $option, $this->Options ) )
{
throw new Exception( "Option $option not supported" );
}
switch( $option )
{
case 'timeout':
return $this->Timeout;
case 'login':
return $this->Login;
case 'password':
return $this->Password;
case 'authType':
return $this->AuthType;
case 'requestCompression':
return $this->RequestCompression;
case 'method':
return $this->Verb;
case 'acceptedCompression':
return $this->AcceptedCompression;
case 'proxyHost':
return $this->Proxy;
case 'proxyPort':
return $this->ProxyPort;
case 'proxyUser':
return $this->ProxyLogin;
case 'proxyPassword':
return $this->ProxyPassword;
case 'proxyAuthType':
return $this->ProxyAuthType;
case 'forceCURL':
return $this->ForceCURL;
case 'debug':
return $this->Debug;
case 'SSLVerifyHost':
return $this->SSLVerifyHost;
case 'SSLVerifyPeer':
return $this->SSLVerifyPeer;
case 'SSLCAInfo':
return $this->SSLCAInfo;
}
}
|
[
"function",
"getOption",
"(",
"$",
"option",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"Options",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Option $option not supported\"",
")",
";",
"}",
"switch",
"(",
"$",
"option",
")",
"{",
"case",
"'timeout'",
":",
"return",
"$",
"this",
"->",
"Timeout",
";",
"case",
"'login'",
":",
"return",
"$",
"this",
"->",
"Login",
";",
"case",
"'password'",
":",
"return",
"$",
"this",
"->",
"Password",
";",
"case",
"'authType'",
":",
"return",
"$",
"this",
"->",
"AuthType",
";",
"case",
"'requestCompression'",
":",
"return",
"$",
"this",
"->",
"RequestCompression",
";",
"case",
"'method'",
":",
"return",
"$",
"this",
"->",
"Verb",
";",
"case",
"'acceptedCompression'",
":",
"return",
"$",
"this",
"->",
"AcceptedCompression",
";",
"case",
"'proxyHost'",
":",
"return",
"$",
"this",
"->",
"Proxy",
";",
"case",
"'proxyPort'",
":",
"return",
"$",
"this",
"->",
"ProxyPort",
";",
"case",
"'proxyUser'",
":",
"return",
"$",
"this",
"->",
"ProxyLogin",
";",
"case",
"'proxyPassword'",
":",
"return",
"$",
"this",
"->",
"ProxyPassword",
";",
"case",
"'proxyAuthType'",
":",
"return",
"$",
"this",
"->",
"ProxyAuthType",
";",
"case",
"'forceCURL'",
":",
"return",
"$",
"this",
"->",
"ForceCURL",
";",
"case",
"'debug'",
":",
"return",
"$",
"this",
"->",
"Debug",
";",
"case",
"'SSLVerifyHost'",
":",
"return",
"$",
"this",
"->",
"SSLVerifyHost",
";",
"case",
"'SSLVerifyPeer'",
":",
"return",
"$",
"this",
"->",
"SSLVerifyPeer",
";",
"case",
"'SSLCAInfo'",
":",
"return",
"$",
"this",
"->",
"SSLCAInfo",
";",
"}",
"}"
] |
Retrieves the current value for any option
@param string $option
@return bool|int|string
@throws Exception if option does not exist
|
[
"Retrieves",
"the",
"current",
"value",
"for",
"any",
"option"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesclient.php#L898-L942
|
228,309
|
antaresproject/core
|
src/ui/components/templates/src/Adapter/AbstractTemplate.php
|
AbstractTemplate.setDefaults
|
protected function setDefaults()
{
$this->attributes['name'] = $this->name;
$this->attributes['classname'] = get_called_class();
$attributesAdapter = new AttributesAdapter($this->name);
$defaults = $attributesAdapter->defaults();
if (!isset($this->attributes['width']) && isset($this->attributes['default_width'])) {
$this->attributes['width'] = $this->attributes['default_width'];
}
if (!isset($this->attributes['height']) && isset($this->attributes['default_height'])) {
$this->attributes['height'] = $this->attributes['default_height'];
}
$this->attributes = array_merge($defaults, $this->attributes);
$attributes = app(Service::class)->findOne(array_merge($defaults, $this->attributes), uri());
$this->attributes = array_merge($this->attributes, $attributes);
$this->attributes['desktop'] = array_only($this->attributes, ['x', 'y', 'width', 'height']);
return $this->attributes;
}
|
php
|
protected function setDefaults()
{
$this->attributes['name'] = $this->name;
$this->attributes['classname'] = get_called_class();
$attributesAdapter = new AttributesAdapter($this->name);
$defaults = $attributesAdapter->defaults();
if (!isset($this->attributes['width']) && isset($this->attributes['default_width'])) {
$this->attributes['width'] = $this->attributes['default_width'];
}
if (!isset($this->attributes['height']) && isset($this->attributes['default_height'])) {
$this->attributes['height'] = $this->attributes['default_height'];
}
$this->attributes = array_merge($defaults, $this->attributes);
$attributes = app(Service::class)->findOne(array_merge($defaults, $this->attributes), uri());
$this->attributes = array_merge($this->attributes, $attributes);
$this->attributes['desktop'] = array_only($this->attributes, ['x', 'y', 'width', 'height']);
return $this->attributes;
}
|
[
"protected",
"function",
"setDefaults",
"(",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"name",
";",
"$",
"this",
"->",
"attributes",
"[",
"'classname'",
"]",
"=",
"get_called_class",
"(",
")",
";",
"$",
"attributesAdapter",
"=",
"new",
"AttributesAdapter",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"defaults",
"=",
"$",
"attributesAdapter",
"->",
"defaults",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'width'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'default_width'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'width'",
"]",
"=",
"$",
"this",
"->",
"attributes",
"[",
"'default_width'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'height'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'default_height'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'height'",
"]",
"=",
"$",
"this",
"->",
"attributes",
"[",
"'default_height'",
"]",
";",
"}",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"$",
"attributes",
"=",
"app",
"(",
"Service",
"::",
"class",
")",
"->",
"findOne",
"(",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"this",
"->",
"attributes",
")",
",",
"uri",
"(",
")",
")",
";",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'desktop'",
"]",
"=",
"array_only",
"(",
"$",
"this",
"->",
"attributes",
",",
"[",
"'x'",
",",
"'y'",
",",
"'width'",
",",
"'height'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"attributes",
";",
"}"
] |
set default widget attributes
@return array
|
[
"set",
"default",
"widget",
"attributes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Adapter/AbstractTemplate.php#L147-L167
|
228,310
|
antaresproject/core
|
src/ui/components/templates/src/Adapter/AbstractTemplate.php
|
AbstractTemplate.fill
|
public function fill()
{
$params = array_merge($this->attributes, [
'id' => $this->id,
'widget' => $this->model,
'name' => $this->name,
'title' => strlen($this->title) > 0 ? $this->title : $this->name,
'description' => $this->description,
'editable' => $this->editable(),
'widgets' => $this->widgets,
'template' => $this->template,
'only_template' => $this->renderOnlyWithTemplate
]);
$reflectionClass = new ReflectionClass(get_called_class());
if ($reflectionClass->getParentClass()->getName() === "Antares\UI\UIComponents\Templates\Datatables") {
array_set($params, 'datatable', true);
}
array_set($params, 'content', $this->templateAdapter->share($params)->decorate($this->render()));
return $params;
}
|
php
|
public function fill()
{
$params = array_merge($this->attributes, [
'id' => $this->id,
'widget' => $this->model,
'name' => $this->name,
'title' => strlen($this->title) > 0 ? $this->title : $this->name,
'description' => $this->description,
'editable' => $this->editable(),
'widgets' => $this->widgets,
'template' => $this->template,
'only_template' => $this->renderOnlyWithTemplate
]);
$reflectionClass = new ReflectionClass(get_called_class());
if ($reflectionClass->getParentClass()->getName() === "Antares\UI\UIComponents\Templates\Datatables") {
array_set($params, 'datatable', true);
}
array_set($params, 'content', $this->templateAdapter->share($params)->decorate($this->render()));
return $params;
}
|
[
"public",
"function",
"fill",
"(",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'widget'",
"=>",
"$",
"this",
"->",
"model",
",",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'title'",
"=>",
"strlen",
"(",
"$",
"this",
"->",
"title",
")",
">",
"0",
"?",
"$",
"this",
"->",
"title",
":",
"$",
"this",
"->",
"name",
",",
"'description'",
"=>",
"$",
"this",
"->",
"description",
",",
"'editable'",
"=>",
"$",
"this",
"->",
"editable",
"(",
")",
",",
"'widgets'",
"=>",
"$",
"this",
"->",
"widgets",
",",
"'template'",
"=>",
"$",
"this",
"->",
"template",
",",
"'only_template'",
"=>",
"$",
"this",
"->",
"renderOnlyWithTemplate",
"]",
")",
";",
"$",
"reflectionClass",
"=",
"new",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"if",
"(",
"$",
"reflectionClass",
"->",
"getParentClass",
"(",
")",
"->",
"getName",
"(",
")",
"===",
"\"Antares\\UI\\UIComponents\\Templates\\Datatables\"",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'datatable'",
",",
"true",
")",
";",
"}",
"array_set",
"(",
"$",
"params",
",",
"'content'",
",",
"$",
"this",
"->",
"templateAdapter",
"->",
"share",
"(",
"$",
"params",
")",
"->",
"decorate",
"(",
"$",
"this",
"->",
"render",
"(",
")",
")",
")",
";",
"return",
"$",
"params",
";",
"}"
] |
fill widget params
@return array
|
[
"fill",
"widget",
"params"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Adapter/AbstractTemplate.php#L211-L230
|
228,311
|
antaresproject/core
|
src/ui/components/templates/src/Adapter/AbstractTemplate.php
|
AbstractTemplate.controls
|
public function controls()
{
$this->form();
$form = app('antares.form')->of("antares.ui-components: custom");
$fieldsets = $form->grid->fieldsets();
$controls = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->controls as $control) {
array_push($controls, $control->name);
}
}
return $controls;
}
|
php
|
public function controls()
{
$this->form();
$form = app('antares.form')->of("antares.ui-components: custom");
$fieldsets = $form->grid->fieldsets();
$controls = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->controls as $control) {
array_push($controls, $control->name);
}
}
return $controls;
}
|
[
"public",
"function",
"controls",
"(",
")",
"{",
"$",
"this",
"->",
"form",
"(",
")",
";",
"$",
"form",
"=",
"app",
"(",
"'antares.form'",
")",
"->",
"of",
"(",
"\"antares.ui-components: custom\"",
")",
";",
"$",
"fieldsets",
"=",
"$",
"form",
"->",
"grid",
"->",
"fieldsets",
"(",
")",
";",
"$",
"controls",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fieldsets",
"as",
"$",
"fieldset",
")",
"{",
"foreach",
"(",
"$",
"fieldset",
"->",
"controls",
"as",
"$",
"control",
")",
"{",
"array_push",
"(",
"$",
"controls",
",",
"$",
"control",
"->",
"name",
")",
";",
"}",
"}",
"return",
"$",
"controls",
";",
"}"
] |
getting all controls available in edition form of widget
@return array
|
[
"getting",
"all",
"controls",
"available",
"in",
"edition",
"form",
"of",
"widget"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Adapter/AbstractTemplate.php#L237-L249
|
228,312
|
antaresproject/core
|
src/components/support/src/Support/Traits/UploadableTrait.php
|
UploadableTrait.saveUploadedFile
|
protected function saveUploadedFile(UploadedFile $file, $path)
{
$file->move($path, $filename = $this->getUploadedFilename($file));
return $filename;
}
|
php
|
protected function saveUploadedFile(UploadedFile $file, $path)
{
$file->move($path, $filename = $this->getUploadedFilename($file));
return $filename;
}
|
[
"protected",
"function",
"saveUploadedFile",
"(",
"UploadedFile",
"$",
"file",
",",
"$",
"path",
")",
"{",
"$",
"file",
"->",
"move",
"(",
"$",
"path",
",",
"$",
"filename",
"=",
"$",
"this",
"->",
"getUploadedFilename",
"(",
"$",
"file",
")",
")",
";",
"return",
"$",
"filename",
";",
"}"
] |
Save uploaded file into directory.
@param \Symfony\Component\HttpFoundation\File\UploadedFile $file
@param string $path
@return string
|
[
"Save",
"uploaded",
"file",
"into",
"directory",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Traits/UploadableTrait.php#L37-L42
|
228,313
|
antaresproject/core
|
src/foundation/src/Processor/Extension/ModuleViewer.php
|
ModuleViewer.index
|
public function index(Listener $listener, $category = null)
{
$presenter = $this->presenter->setCategory($category);
$modules = $presenter->modules();
return $listener->show(compact('modules', 'category'));
}
|
php
|
public function index(Listener $listener, $category = null)
{
$presenter = $this->presenter->setCategory($category);
$modules = $presenter->modules();
return $listener->show(compact('modules', 'category'));
}
|
[
"public",
"function",
"index",
"(",
"Listener",
"$",
"listener",
",",
"$",
"category",
"=",
"null",
")",
"{",
"$",
"presenter",
"=",
"$",
"this",
"->",
"presenter",
"->",
"setCategory",
"(",
"$",
"category",
")",
";",
"$",
"modules",
"=",
"$",
"presenter",
"->",
"modules",
"(",
")",
";",
"return",
"$",
"listener",
"->",
"show",
"(",
"compact",
"(",
"'modules'",
",",
"'category'",
")",
")",
";",
"}"
] |
View modules page.
@param \Antares\Contracts\Extension\Listener\Viewer $listener
@return mixed
|
[
"View",
"modules",
"page",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Extension/ModuleViewer.php#L66-L71
|
228,314
|
antaresproject/core
|
src/components/memory/src/Repository/Resource.php
|
Resource.add
|
public function add(array $attributes = array())
{
if (!$this->contains($attributes)) {
$this->model->getModel()->newInstance($attributes)->save();
$this->cache->forget($this->cacheKey);
}
return $this;
}
|
php
|
public function add(array $attributes = array())
{
if (!$this->contains($attributes)) {
$this->model->getModel()->newInstance($attributes)->save();
$this->cache->forget($this->cacheKey);
}
return $this;
}
|
[
"public",
"function",
"add",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"contains",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"getModel",
"(",
")",
"->",
"newInstance",
"(",
"$",
"attributes",
")",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"cacheKey",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
add resource do resource stack
@param array $attributes
@return \Antares\Memory\Repository\Resource
|
[
"add",
"resource",
"do",
"resource",
"stack"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Repository/Resource.php#L89-L96
|
228,315
|
antaresproject/core
|
src/components/memory/src/Repository/Resource.php
|
Resource.contains
|
protected function contains(array $attributes = array())
{
$collection = $this->findAll();
$filtered = $collection->filter(function($value, $key) use($attributes) {
foreach ($attributes as $keyname => $attrVal) {
if ($value->{$keyname} != $attrVal) {
return false;
}
}
return true;
});
return $filtered->count() > 0;
}
|
php
|
protected function contains(array $attributes = array())
{
$collection = $this->findAll();
$filtered = $collection->filter(function($value, $key) use($attributes) {
foreach ($attributes as $keyname => $attrVal) {
if ($value->{$keyname} != $attrVal) {
return false;
}
}
return true;
});
return $filtered->count() > 0;
}
|
[
"protected",
"function",
"contains",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"findAll",
"(",
")",
";",
"$",
"filtered",
"=",
"$",
"collection",
"->",
"filter",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"use",
"(",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"keyname",
"=>",
"$",
"attrVal",
")",
"{",
"if",
"(",
"$",
"value",
"->",
"{",
"$",
"keyname",
"}",
"!=",
"$",
"attrVal",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
")",
";",
"return",
"$",
"filtered",
"->",
"count",
"(",
")",
">",
"0",
";",
"}"
] |
whether resource stack contains parametrized row with component and action name
@param array $attributes
@return boolean
|
[
"whether",
"resource",
"stack",
"contains",
"parametrized",
"row",
"with",
"component",
"and",
"action",
"name"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Repository/Resource.php#L104-L116
|
228,316
|
antaresproject/core
|
src/components/memory/src/Repository/Resource.php
|
Resource.findOneByAttributes
|
public function findOneByAttributes(array $attributes = array(), $columns = array('*'))
{
if (empty($attributes)) {
throw new Exception('Unable to find entity');
}
return $this->model->where($attributes)->first($columns);
}
|
php
|
public function findOneByAttributes(array $attributes = array(), $columns = array('*'))
{
if (empty($attributes)) {
throw new Exception('Unable to find entity');
}
return $this->model->where($attributes)->first($columns);
}
|
[
"public",
"function",
"findOneByAttributes",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"columns",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attributes",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to find entity'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"$",
"attributes",
")",
"->",
"first",
"(",
"$",
"columns",
")",
";",
"}"
] |
find item by attributes
@param array $attributes
@param array $columns
@return mixed
@throws Exception
|
[
"find",
"item",
"by",
"attributes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Repository/Resource.php#L126-L132
|
228,317
|
tomwalder/php-appengine-search
|
src/Search/Document.php
|
Document.getExpression
|
public function getExpression($str_name)
{
if(isset($this->arr_expressions[$str_name])) {
return $this->arr_expressions[$str_name];
}
return null;
}
|
php
|
public function getExpression($str_name)
{
if(isset($this->arr_expressions[$str_name])) {
return $this->arr_expressions[$str_name];
}
return null;
}
|
[
"public",
"function",
"getExpression",
"(",
"$",
"str_name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"arr_expressions",
"[",
"$",
"str_name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"arr_expressions",
"[",
"$",
"str_name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get a specific returned expression
@param $str_name
@return null
|
[
"Get",
"a",
"specific",
"returned",
"expression"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Document.php#L186-L192
|
228,318
|
lawoole/framework
|
src/Homer/Transport/Whisper/WhisperClient.php
|
WhisperClient.send
|
protected function send($data)
{
try {
$result = $this->client->send($data);
if ($result === false) {
$errorCode = $this->client->errCode;
throw new TransportException('Send data failed, cause: '.socket_strerror($errorCode).'.',
TransportException::CONNECTION);
}
} catch (TransportException $e) {
throw $e;
} catch (Throwable $e) {
if ($this->causedByConnectionProblem($e)) {
throw new TransportException($e->getMessage(), TransportException::CONNECTION, $e);
}
throw new TransportException($e->getMessage(), 0, $e);
}
return $result;
}
|
php
|
protected function send($data)
{
try {
$result = $this->client->send($data);
if ($result === false) {
$errorCode = $this->client->errCode;
throw new TransportException('Send data failed, cause: '.socket_strerror($errorCode).'.',
TransportException::CONNECTION);
}
} catch (TransportException $e) {
throw $e;
} catch (Throwable $e) {
if ($this->causedByConnectionProblem($e)) {
throw new TransportException($e->getMessage(), TransportException::CONNECTION, $e);
}
throw new TransportException($e->getMessage(), 0, $e);
}
return $result;
}
|
[
"protected",
"function",
"send",
"(",
"$",
"data",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"errorCode",
"=",
"$",
"this",
"->",
"client",
"->",
"errCode",
";",
"throw",
"new",
"TransportException",
"(",
"'Send data failed, cause: '",
".",
"socket_strerror",
"(",
"$",
"errorCode",
")",
".",
"'.'",
",",
"TransportException",
"::",
"CONNECTION",
")",
";",
"}",
"}",
"catch",
"(",
"TransportException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"causedByConnectionProblem",
"(",
"$",
"e",
")",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"TransportException",
"::",
"CONNECTION",
",",
"$",
"e",
")",
";",
"}",
"throw",
"new",
"TransportException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Send data.
@param string $data
@return int
|
[
"Send",
"data",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Transport/Whisper/WhisperClient.php#L137-L159
|
228,319
|
lawoole/framework
|
src/Homer/Transport/Whisper/WhisperClient.php
|
WhisperClient.receive
|
protected function receive()
{
try {
$data = $this->client->recv();
if ($data === false) {
$errorCode = $this->client->errCode;
if ($errorCode == 11) {
throw new TransportException('Receive timeout in '.$this->getTimeout().' ms.',
TransportException::TIMEOUT);
}
throw new TransportException('Receive data failed, cause: '.socket_strerror($errorCode).'.',
TransportException::CONNECTION);
} elseif ($data === '') {
throw new TransportException('Receive data failed, cause the connection has been closed.',
TransportException::CONNECTION);
}
} catch (TransportException $e) {
throw $e;
} catch (Throwable $e) {
if ($this->causedByTimeout($e)) {
throw new TransportException('Receive timeout in '.$this->getTimeout().' ms.',
TransportException::TIMEOUT, $e);
}
throw new TransportException($e->getMessage(), 0, $e);
}
return $data;
}
|
php
|
protected function receive()
{
try {
$data = $this->client->recv();
if ($data === false) {
$errorCode = $this->client->errCode;
if ($errorCode == 11) {
throw new TransportException('Receive timeout in '.$this->getTimeout().' ms.',
TransportException::TIMEOUT);
}
throw new TransportException('Receive data failed, cause: '.socket_strerror($errorCode).'.',
TransportException::CONNECTION);
} elseif ($data === '') {
throw new TransportException('Receive data failed, cause the connection has been closed.',
TransportException::CONNECTION);
}
} catch (TransportException $e) {
throw $e;
} catch (Throwable $e) {
if ($this->causedByTimeout($e)) {
throw new TransportException('Receive timeout in '.$this->getTimeout().' ms.',
TransportException::TIMEOUT, $e);
}
throw new TransportException($e->getMessage(), 0, $e);
}
return $data;
}
|
[
"protected",
"function",
"receive",
"(",
")",
"{",
"try",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"client",
"->",
"recv",
"(",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"$",
"errorCode",
"=",
"$",
"this",
"->",
"client",
"->",
"errCode",
";",
"if",
"(",
"$",
"errorCode",
"==",
"11",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"'Receive timeout in '",
".",
"$",
"this",
"->",
"getTimeout",
"(",
")",
".",
"' ms.'",
",",
"TransportException",
"::",
"TIMEOUT",
")",
";",
"}",
"throw",
"new",
"TransportException",
"(",
"'Receive data failed, cause: '",
".",
"socket_strerror",
"(",
"$",
"errorCode",
")",
".",
"'.'",
",",
"TransportException",
"::",
"CONNECTION",
")",
";",
"}",
"elseif",
"(",
"$",
"data",
"===",
"''",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"'Receive data failed, cause the connection has been closed.'",
",",
"TransportException",
"::",
"CONNECTION",
")",
";",
"}",
"}",
"catch",
"(",
"TransportException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"causedByTimeout",
"(",
"$",
"e",
")",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"'Receive timeout in '",
".",
"$",
"this",
"->",
"getTimeout",
"(",
")",
".",
"' ms.'",
",",
"TransportException",
"::",
"TIMEOUT",
",",
"$",
"e",
")",
";",
"}",
"throw",
"new",
"TransportException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Receive result.
@return string
|
[
"Receive",
"result",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Transport/Whisper/WhisperClient.php#L200-L231
|
228,320
|
antaresproject/core
|
src/foundation/src/Repository/AbstractRepository.php
|
AbstractRepository.getBy
|
public function getBy($attribute, $value, $columns = array('*'))
{
return $this->model->where($attribute, '=', $value)->get($columns);
}
|
php
|
public function getBy($attribute, $value, $columns = array('*'))
{
return $this->model->where($attribute, '=', $value)->get($columns);
}
|
[
"public",
"function",
"getBy",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"columns",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"$",
"attribute",
",",
"'='",
",",
"$",
"value",
")",
"->",
"get",
"(",
"$",
"columns",
")",
";",
"}"
] |
gets rows by attribute
@param array $columns
@return mixed
|
[
"gets",
"rows",
"by",
"attribute"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Repository/AbstractRepository.php#L73-L76
|
228,321
|
antaresproject/core
|
src/utils/customfield/src/Twig/Customfield.php
|
Customfield.hasCustomfield
|
protected function hasCustomfield()
{
$function = function ($object, $name) {
return method_exists($object, 'hasCustomfield') ? $object->hasCustomfield($name) : false;
};
return new Twig_SimpleFunction(
'hasCustomfield', $function
);
}
|
php
|
protected function hasCustomfield()
{
$function = function ($object, $name) {
return method_exists($object, 'hasCustomfield') ? $object->hasCustomfield($name) : false;
};
return new Twig_SimpleFunction(
'hasCustomfield', $function
);
}
|
[
"protected",
"function",
"hasCustomfield",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
"$",
"object",
",",
"$",
"name",
")",
"{",
"return",
"method_exists",
"(",
"$",
"object",
",",
"'hasCustomfield'",
")",
"?",
"$",
"object",
"->",
"hasCustomfield",
"(",
"$",
"name",
")",
":",
"false",
";",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'hasCustomfield'",
",",
"$",
"function",
")",
";",
"}"
] |
create widget view helper for get brand title
@return Twig_SimpleFunction
|
[
"create",
"widget",
"view",
"helper",
"for",
"get",
"brand",
"title"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/customfield/src/Twig/Customfield.php#L43-L52
|
228,322
|
antaresproject/core
|
src/components/support/src/Support/Traits/ValidationTrait.php
|
ValidationTrait.runValidationEvents
|
protected function runValidationEvents($events, array $phrases)
{
is_array($events) || $events = (array) $events;
$events = array_merge($this->getValidationEvents(), $events);
$rules = new Fluent($this->getBindedRules());
$phrases = new Fluent(array_merge($this->getValidationPhrases(), $phrases));
foreach ((array) $events as $event) {
$this->validationDispatcher->fire($event, [& $rules, & $phrases]);
}
return [
$rules->getAttributes(),
$phrases->getAttributes(),
];
}
|
php
|
protected function runValidationEvents($events, array $phrases)
{
is_array($events) || $events = (array) $events;
$events = array_merge($this->getValidationEvents(), $events);
$rules = new Fluent($this->getBindedRules());
$phrases = new Fluent(array_merge($this->getValidationPhrases(), $phrases));
foreach ((array) $events as $event) {
$this->validationDispatcher->fire($event, [& $rules, & $phrases]);
}
return [
$rules->getAttributes(),
$phrases->getAttributes(),
];
}
|
[
"protected",
"function",
"runValidationEvents",
"(",
"$",
"events",
",",
"array",
"$",
"phrases",
")",
"{",
"is_array",
"(",
"$",
"events",
")",
"||",
"$",
"events",
"=",
"(",
"array",
")",
"$",
"events",
";",
"$",
"events",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getValidationEvents",
"(",
")",
",",
"$",
"events",
")",
";",
"$",
"rules",
"=",
"new",
"Fluent",
"(",
"$",
"this",
"->",
"getBindedRules",
"(",
")",
")",
";",
"$",
"phrases",
"=",
"new",
"Fluent",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getValidationPhrases",
"(",
")",
",",
"$",
"phrases",
")",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"validationDispatcher",
"->",
"fire",
"(",
"$",
"event",
",",
"[",
"&",
"$",
"rules",
",",
"&",
"$",
"phrases",
"]",
")",
";",
"}",
"return",
"[",
"$",
"rules",
"->",
"getAttributes",
"(",
")",
",",
"$",
"phrases",
"->",
"getAttributes",
"(",
")",
",",
"]",
";",
"}"
] |
Run validation events and return the finalize rules and phrases.
@param array|string $events
@param array $phrases
@return array
|
[
"Run",
"validation",
"events",
"and",
"return",
"the",
"finalize",
"rules",
"and",
"phrases",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Traits/ValidationTrait.php#L173-L190
|
228,323
|
joomla-framework/google-api
|
src/Data/Picasa/Album.php
|
Album.save
|
public function save($match = '*')
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
{
$match = $this->xml->xpath('./@gd:etag');
$match = $match[0];
}
try
{
$headers = array('GData-Version' => 2, 'Content-type' => 'application/atom+xml', 'If-Match' => $match);
$jdata = $this->query($url, $this->xml->asXML(), $headers, 'put');
}
catch (\Exception $e)
{
if (strpos($e->getMessage(), 'Error code 412 received requesting data: Mismatch: etags') === 0)
{
throw new \RuntimeException("Etag match failed: `$match`.");
}
throw $e;
}
$this->xml = $this->safeXml($jdata->body);
return $this;
}
return false;
}
|
php
|
public function save($match = '*')
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
{
$match = $this->xml->xpath('./@gd:etag');
$match = $match[0];
}
try
{
$headers = array('GData-Version' => 2, 'Content-type' => 'application/atom+xml', 'If-Match' => $match);
$jdata = $this->query($url, $this->xml->asXML(), $headers, 'put');
}
catch (\Exception $e)
{
if (strpos($e->getMessage(), 'Error code 412 received requesting data: Mismatch: etags') === 0)
{
throw new \RuntimeException("Etag match failed: `$match`.");
}
throw $e;
}
$this->xml = $this->safeXml($jdata->body);
return $this;
}
return false;
}
|
[
"public",
"function",
"save",
"(",
"$",
"match",
"=",
"'*'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getLink",
"(",
")",
";",
"if",
"(",
"$",
"match",
"===",
"true",
")",
"{",
"$",
"match",
"=",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'./@gd:etag'",
")",
";",
"$",
"match",
"=",
"$",
"match",
"[",
"0",
"]",
";",
"}",
"try",
"{",
"$",
"headers",
"=",
"array",
"(",
"'GData-Version'",
"=>",
"2",
",",
"'Content-type'",
"=>",
"'application/atom+xml'",
",",
"'If-Match'",
"=>",
"$",
"match",
")",
";",
"$",
"jdata",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"xml",
"->",
"asXML",
"(",
")",
",",
"$",
"headers",
",",
"'put'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'Error code 412 received requesting data: Mismatch: etags'",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Etag match failed: `$match`.\"",
")",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"safeXml",
"(",
"$",
"jdata",
"->",
"body",
")",
";",
"return",
"$",
"this",
";",
"}",
"return",
"false",
";",
"}"
] |
Method to modify a Picasa Album
@param string $match Optional eTag matching parameter
@return mixed Data from Google.
@since 1.0
@throws \Exception
@throws \RuntimeException
|
[
"Method",
"to",
"modify",
"a",
"Picasa",
"Album"
] |
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
|
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Picasa/Album.php#L276-L309
|
228,324
|
joomla-framework/google-api
|
src/Data/Picasa/Album.php
|
Album.refresh
|
public function refresh()
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
$jdata = $this->query($url, null, array('GData-Version' => 2));
$this->xml = $this->safeXml($jdata->body);
return $this;
}
return false;
}
|
php
|
public function refresh()
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
$jdata = $this->query($url, null, array('GData-Version' => 2));
$this->xml = $this->safeXml($jdata->body);
return $this;
}
return false;
}
|
[
"public",
"function",
"refresh",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getLink",
"(",
")",
";",
"$",
"jdata",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"url",
",",
"null",
",",
"array",
"(",
"'GData-Version'",
"=>",
"2",
")",
")",
";",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"safeXml",
"(",
"$",
"jdata",
"->",
"body",
")",
";",
"return",
"$",
"this",
";",
"}",
"return",
"false",
";",
"}"
] |
Refresh Picasa Album
@return mixed Data from Google
@since 1.0
|
[
"Refresh",
"Picasa",
"Album"
] |
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
|
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Picasa/Album.php#L318-L330
|
228,325
|
antaresproject/core
|
src/components/extension/src/Repositories/ComponentsRepository.php
|
ComponentsRepository.getRequired
|
public function getRequired() : array {
$required = [];
foreach($this->required as $component) {
$required[$component] = $this->getTargetBranch($component);
}
return $required;
}
|
php
|
public function getRequired() : array {
$required = [];
foreach($this->required as $component) {
$required[$component] = $this->getTargetBranch($component);
}
return $required;
}
|
[
"public",
"function",
"getRequired",
"(",
")",
":",
"array",
"{",
"$",
"required",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"required",
"as",
"$",
"component",
")",
"{",
"$",
"required",
"[",
"$",
"component",
"]",
"=",
"$",
"this",
"->",
"getTargetBranch",
"(",
"$",
"component",
")",
";",
"}",
"return",
"$",
"required",
";",
"}"
] |
Returns an array of required components with branches.
@return array
|
[
"Returns",
"an",
"array",
"of",
"required",
"components",
"with",
"branches",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Repositories/ComponentsRepository.php#L57-L65
|
228,326
|
antaresproject/core
|
src/components/extension/src/Repositories/ComponentsRepository.php
|
ComponentsRepository.getOptional
|
public function getOptional() : array {
$optional = [];
foreach($this->optional as $component) {
$optional[$component] = $this->getTargetBranch($component);
}
return $optional;
}
|
php
|
public function getOptional() : array {
$optional = [];
foreach($this->optional as $component) {
$optional[$component] = $this->getTargetBranch($component);
}
return $optional;
}
|
[
"public",
"function",
"getOptional",
"(",
")",
":",
"array",
"{",
"$",
"optional",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"optional",
"as",
"$",
"component",
")",
"{",
"$",
"optional",
"[",
"$",
"component",
"]",
"=",
"$",
"this",
"->",
"getTargetBranch",
"(",
"$",
"component",
")",
";",
"}",
"return",
"$",
"optional",
";",
"}"
] |
Returns an array of optional components with branches.
@return array
|
[
"Returns",
"an",
"array",
"of",
"optional",
"components",
"with",
"branches",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Repositories/ComponentsRepository.php#L72-L80
|
228,327
|
antaresproject/core
|
src/components/extension/src/Repositories/ComponentsRepository.php
|
ComponentsRepository.getWithBranches
|
public function getWithBranches(array $components) : array {
$data = [];
foreach($components as $component) {
$data[$component] = $this->getTargetBranch($component);
}
return $data;
}
|
php
|
public function getWithBranches(array $components) : array {
$data = [];
foreach($components as $component) {
$data[$component] = $this->getTargetBranch($component);
}
return $data;
}
|
[
"public",
"function",
"getWithBranches",
"(",
"array",
"$",
"components",
")",
":",
"array",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"data",
"[",
"$",
"component",
"]",
"=",
"$",
"this",
"->",
"getTargetBranch",
"(",
"$",
"component",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Returns the given components with branches.
@param array $components
@return array
|
[
"Returns",
"the",
"given",
"components",
"with",
"branches",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Repositories/ComponentsRepository.php#L88-L96
|
228,328
|
antaresproject/core
|
src/components/extension/src/Repositories/ComponentsRepository.php
|
ComponentsRepository.getTargetBranch
|
public function getTargetBranch(string $component) : string {
return array_key_exists($component, $this->branches)
? $this->branches[$component]
: self::$defaultBranch;
}
|
php
|
public function getTargetBranch(string $component) : string {
return array_key_exists($component, $this->branches)
? $this->branches[$component]
: self::$defaultBranch;
}
|
[
"public",
"function",
"getTargetBranch",
"(",
"string",
"$",
"component",
")",
":",
"string",
"{",
"return",
"array_key_exists",
"(",
"$",
"component",
",",
"$",
"this",
"->",
"branches",
")",
"?",
"$",
"this",
"->",
"branches",
"[",
"$",
"component",
"]",
":",
"self",
"::",
"$",
"defaultBranch",
";",
"}"
] |
Returns the target branch.
@param string $component
@return string
|
[
"Returns",
"the",
"target",
"branch",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Repositories/ComponentsRepository.php#L104-L108
|
228,329
|
antaresproject/customfields
|
src/CustomFieldsServiceProvider.php
|
CustomFieldsServiceProvider.register
|
public function register()
{
$this->app->bind('antares.customfields.model', function() {
return new Field();
});
$this->app->bind('antares.customfields.model.view', function() {
return new FieldView();
});
$this->app->bind('antares.customfields.model.category', function() {
return new FieldCategory();
});
$this->app->bind('antares.customfields.model.group', function() {
return new FieldGroup();
});
$this->app->bind('antares.customfields.model.type', function() {
return new FieldType();
});
$this->app->bind('antares.customfields.model.type.option', function() {
return new FieldTypeOption();
});
$this->app->bind('antares.customfields.model.validator', function() {
return new FieldValidator();
});
$this->app->bind('antares.customfields.model.validator.config', function() {
return new FieldValidatorConfig();
});
$this->commands([
CustomfieldSync::class
]);
}
|
php
|
public function register()
{
$this->app->bind('antares.customfields.model', function() {
return new Field();
});
$this->app->bind('antares.customfields.model.view', function() {
return new FieldView();
});
$this->app->bind('antares.customfields.model.category', function() {
return new FieldCategory();
});
$this->app->bind('antares.customfields.model.group', function() {
return new FieldGroup();
});
$this->app->bind('antares.customfields.model.type', function() {
return new FieldType();
});
$this->app->bind('antares.customfields.model.type.option', function() {
return new FieldTypeOption();
});
$this->app->bind('antares.customfields.model.validator', function() {
return new FieldValidator();
});
$this->app->bind('antares.customfields.model.validator.config', function() {
return new FieldValidatorConfig();
});
$this->commands([
CustomfieldSync::class
]);
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"Field",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.view'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldView",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.category'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldCategory",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.group'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldGroup",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.type'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldType",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.type.option'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldTypeOption",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.validator'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldValidator",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'antares.customfields.model.validator.config'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"FieldValidatorConfig",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"[",
"CustomfieldSync",
"::",
"class",
"]",
")",
";",
"}"
] |
registering service provider
|
[
"registering",
"service",
"provider"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/CustomFieldsServiceProvider.php#L80-L109
|
228,330
|
antaresproject/customfields
|
src/CustomFieldsServiceProvider.php
|
CustomFieldsServiceProvider.bootFormEvents
|
protected function bootFormEvents()
{
$categoriesCollection = Foundation::make('antares.customfields.model.category')
->select(['name'])->with(['group' => function($query) {
$query->select(['name']);
}])->get();
$formHandler = 'Antares\Customfields\Events\FormHandler';
$validatorHandler = 'Antares\Customfields\Events\ValidatorHandler';
$processorHandler = 'Antares\Customfields\Events\ProcessorHandler';
$categoriesCollection->each(function($category) use($formHandler, $validatorHandler, $processorHandler) {
$category->group->each(function($group) use($category, $formHandler, $validatorHandler, $processorHandler) {
$accessor = implode('.', [$category->name, $group->name]);
$events = $this->app->make('events');
$events->listen('antares.form: ' . $accessor, "{$formHandler}@onViewForm");
$events->listen($accessor . '.customfields.validate', "{$validatorHandler}@onSubmitForm");
$events->listen('antares.form: ' . $accessor . '.save', "{$processorHandler}@onSave");
});
});
}
|
php
|
protected function bootFormEvents()
{
$categoriesCollection = Foundation::make('antares.customfields.model.category')
->select(['name'])->with(['group' => function($query) {
$query->select(['name']);
}])->get();
$formHandler = 'Antares\Customfields\Events\FormHandler';
$validatorHandler = 'Antares\Customfields\Events\ValidatorHandler';
$processorHandler = 'Antares\Customfields\Events\ProcessorHandler';
$categoriesCollection->each(function($category) use($formHandler, $validatorHandler, $processorHandler) {
$category->group->each(function($group) use($category, $formHandler, $validatorHandler, $processorHandler) {
$accessor = implode('.', [$category->name, $group->name]);
$events = $this->app->make('events');
$events->listen('antares.form: ' . $accessor, "{$formHandler}@onViewForm");
$events->listen($accessor . '.customfields.validate', "{$validatorHandler}@onSubmitForm");
$events->listen('antares.form: ' . $accessor . '.save', "{$processorHandler}@onSave");
});
});
}
|
[
"protected",
"function",
"bootFormEvents",
"(",
")",
"{",
"$",
"categoriesCollection",
"=",
"Foundation",
"::",
"make",
"(",
"'antares.customfields.model.category'",
")",
"->",
"select",
"(",
"[",
"'name'",
"]",
")",
"->",
"with",
"(",
"[",
"'group'",
"=>",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"select",
"(",
"[",
"'name'",
"]",
")",
";",
"}",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"formHandler",
"=",
"'Antares\\Customfields\\Events\\FormHandler'",
";",
"$",
"validatorHandler",
"=",
"'Antares\\Customfields\\Events\\ValidatorHandler'",
";",
"$",
"processorHandler",
"=",
"'Antares\\Customfields\\Events\\ProcessorHandler'",
";",
"$",
"categoriesCollection",
"->",
"each",
"(",
"function",
"(",
"$",
"category",
")",
"use",
"(",
"$",
"formHandler",
",",
"$",
"validatorHandler",
",",
"$",
"processorHandler",
")",
"{",
"$",
"category",
"->",
"group",
"->",
"each",
"(",
"function",
"(",
"$",
"group",
")",
"use",
"(",
"$",
"category",
",",
"$",
"formHandler",
",",
"$",
"validatorHandler",
",",
"$",
"processorHandler",
")",
"{",
"$",
"accessor",
"=",
"implode",
"(",
"'.'",
",",
"[",
"$",
"category",
"->",
"name",
",",
"$",
"group",
"->",
"name",
"]",
")",
";",
"$",
"events",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
";",
"$",
"events",
"->",
"listen",
"(",
"'antares.form: '",
".",
"$",
"accessor",
",",
"\"{$formHandler}@onViewForm\"",
")",
";",
"$",
"events",
"->",
"listen",
"(",
"$",
"accessor",
".",
"'.customfields.validate'",
",",
"\"{$validatorHandler}@onSubmitForm\"",
")",
";",
"$",
"events",
"->",
"listen",
"(",
"'antares.form: '",
".",
"$",
"accessor",
".",
"'.save'",
",",
"\"{$processorHandler}@onSave\"",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
booting form events
|
[
"booting",
"form",
"events"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/CustomFieldsServiceProvider.php#L153-L174
|
228,331
|
antaresproject/core
|
src/utils/twig/Extension/Avatar.php
|
Avatar.createInitials
|
protected function createInitials($filename, $fullname, $width = null, $height = null)
{
$width = is_null($width) ? config('avatar.width') : $width;
$height = is_null($height) ? config('avatar.height') : $height;
$defaultWidth = config('avatar.width');
$fontSize = config('avatar.fontSize');
$fontSize = (((int) $width - $defaultWidth) >= 10) ? $fontSize += ($width - $defaultWidth) / 2 : $fontSize;
$avatar = AvatarFacade::create($fullname)->setDimension($width, $height)->setFontSize($fontSize)->setShape('circle')->setBorder(1, '#3bc975');
$avatar->save($filename, 100);
return $avatar;
}
|
php
|
protected function createInitials($filename, $fullname, $width = null, $height = null)
{
$width = is_null($width) ? config('avatar.width') : $width;
$height = is_null($height) ? config('avatar.height') : $height;
$defaultWidth = config('avatar.width');
$fontSize = config('avatar.fontSize');
$fontSize = (((int) $width - $defaultWidth) >= 10) ? $fontSize += ($width - $defaultWidth) / 2 : $fontSize;
$avatar = AvatarFacade::create($fullname)->setDimension($width, $height)->setFontSize($fontSize)->setShape('circle')->setBorder(1, '#3bc975');
$avatar->save($filename, 100);
return $avatar;
}
|
[
"protected",
"function",
"createInitials",
"(",
"$",
"filename",
",",
"$",
"fullname",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"$",
"width",
"=",
"is_null",
"(",
"$",
"width",
")",
"?",
"config",
"(",
"'avatar.width'",
")",
":",
"$",
"width",
";",
"$",
"height",
"=",
"is_null",
"(",
"$",
"height",
")",
"?",
"config",
"(",
"'avatar.height'",
")",
":",
"$",
"height",
";",
"$",
"defaultWidth",
"=",
"config",
"(",
"'avatar.width'",
")",
";",
"$",
"fontSize",
"=",
"config",
"(",
"'avatar.fontSize'",
")",
";",
"$",
"fontSize",
"=",
"(",
"(",
"(",
"int",
")",
"$",
"width",
"-",
"$",
"defaultWidth",
")",
">=",
"10",
")",
"?",
"$",
"fontSize",
"+=",
"(",
"$",
"width",
"-",
"$",
"defaultWidth",
")",
"/",
"2",
":",
"$",
"fontSize",
";",
"$",
"avatar",
"=",
"AvatarFacade",
"::",
"create",
"(",
"$",
"fullname",
")",
"->",
"setDimension",
"(",
"$",
"width",
",",
"$",
"height",
")",
"->",
"setFontSize",
"(",
"$",
"fontSize",
")",
"->",
"setShape",
"(",
"'circle'",
")",
"->",
"setBorder",
"(",
"1",
",",
"'#3bc975'",
")",
";",
"$",
"avatar",
"->",
"save",
"(",
"$",
"filename",
",",
"100",
")",
";",
"return",
"$",
"avatar",
";",
"}"
] |
create initials from string
@param String $filename
@param String $fullname
@param mixed $width
@param mixed $height
@return Avatar
|
[
"create",
"initials",
"from",
"string"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/twig/Extension/Avatar.php#L152-L163
|
228,332
|
antaresproject/core
|
src/utils/twig/Extension/Avatar.php
|
Avatar.createWidgetInitials
|
protected function createWidgetInitials($filename, $title, $width = null, $height = null)
{
$avatar = AvatarFacade::create($title)->setDimension($width, $height)->setBackground('#02a8f3')->setFontSize(40)->setShape('square');
$avatar->save($filename, 100);
return $avatar;
}
|
php
|
protected function createWidgetInitials($filename, $title, $width = null, $height = null)
{
$avatar = AvatarFacade::create($title)->setDimension($width, $height)->setBackground('#02a8f3')->setFontSize(40)->setShape('square');
$avatar->save($filename, 100);
return $avatar;
}
|
[
"protected",
"function",
"createWidgetInitials",
"(",
"$",
"filename",
",",
"$",
"title",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"$",
"avatar",
"=",
"AvatarFacade",
"::",
"create",
"(",
"$",
"title",
")",
"->",
"setDimension",
"(",
"$",
"width",
",",
"$",
"height",
")",
"->",
"setBackground",
"(",
"'#02a8f3'",
")",
"->",
"setFontSize",
"(",
"40",
")",
"->",
"setShape",
"(",
"'square'",
")",
";",
"$",
"avatar",
"->",
"save",
"(",
"$",
"filename",
",",
"100",
")",
";",
"return",
"$",
"avatar",
";",
"}"
] |
create widget initials from string
@param String $filename
@param String $title
@param mixed $width
@param mixed $height
@return Avatar
|
[
"create",
"widget",
"initials",
"from",
"string"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/twig/Extension/Avatar.php#L174-L180
|
228,333
|
antaresproject/core
|
src/utils/twig/Extension/Avatar.php
|
Avatar.response
|
protected function response($filename)
{
Image::make($filename)->response('png', 100);
return str_replace([public_path(), DIRECTORY_SEPARATOR], ['', '/'], $filename);
}
|
php
|
protected function response($filename)
{
Image::make($filename)->response('png', 100);
return str_replace([public_path(), DIRECTORY_SEPARATOR], ['', '/'], $filename);
}
|
[
"protected",
"function",
"response",
"(",
"$",
"filename",
")",
"{",
"Image",
"::",
"make",
"(",
"$",
"filename",
")",
"->",
"response",
"(",
"'png'",
",",
"100",
")",
";",
"return",
"str_replace",
"(",
"[",
"public_path",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
"]",
",",
"[",
"''",
",",
"'/'",
"]",
",",
"$",
"filename",
")",
";",
"}"
] |
create image response
@param String $filename
@return Response
|
[
"create",
"image",
"response"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/twig/Extension/Avatar.php#L188-L193
|
228,334
|
lawoole/framework
|
src/Homer/Serialize/Serializations/ObjectSerialization.php
|
ObjectSerialization.recover
|
public function recover()
{
$instance = $this->values;
foreach (get_object_vars($instance) as $key => $value) {
$instance->$key = $value instanceof Serialization ? $value->recover() : $value;
}
return $instance;
}
|
php
|
public function recover()
{
$instance = $this->values;
foreach (get_object_vars($instance) as $key => $value) {
$instance->$key = $value instanceof Serialization ? $value->recover() : $value;
}
return $instance;
}
|
[
"public",
"function",
"recover",
"(",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"values",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"instance",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"instance",
"->",
"$",
"key",
"=",
"$",
"value",
"instanceof",
"Serialization",
"?",
"$",
"value",
"->",
"recover",
"(",
")",
":",
"$",
"value",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Recover the instance from the serialization.
@return \stdClass
|
[
"Recover",
"the",
"instance",
"from",
"the",
"serialization",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Serializations/ObjectSerialization.php#L34-L43
|
228,335
|
antaresproject/core
|
src/components/publisher/src/Publishing/Publisher.php
|
Publisher.publish
|
public function publish($package, $source)
{
$name = trim(str_replace(['modules', 'components'], '', $package), '/');
$destination = $this->getDestinationPath($name);
$this->makeDestination($destination);
return app('antares.asset.publisher')->publishAndPropagate($this->files->allFiles($source), $name);
}
|
php
|
public function publish($package, $source)
{
$name = trim(str_replace(['modules', 'components'], '', $package), '/');
$destination = $this->getDestinationPath($name);
$this->makeDestination($destination);
return app('antares.asset.publisher')->publishAndPropagate($this->files->allFiles($source), $name);
}
|
[
"public",
"function",
"publish",
"(",
"$",
"package",
",",
"$",
"source",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"str_replace",
"(",
"[",
"'modules'",
",",
"'components'",
"]",
",",
"''",
",",
"$",
"package",
")",
",",
"'/'",
")",
";",
"$",
"destination",
"=",
"$",
"this",
"->",
"getDestinationPath",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"makeDestination",
"(",
"$",
"destination",
")",
";",
"return",
"app",
"(",
"'antares.asset.publisher'",
")",
"->",
"publishAndPropagate",
"(",
"$",
"this",
"->",
"files",
"->",
"allFiles",
"(",
"$",
"source",
")",
",",
"$",
"name",
")",
";",
"}"
] |
Publish files from a given path.
@param string $package
@param string $source
@return bool
|
[
"Publish",
"files",
"from",
"a",
"given",
"path",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/Publishing/Publisher.php#L83-L89
|
228,336
|
antaresproject/core
|
src/components/support/src/Providers/Traits/FilterProviderTrait.php
|
FilterProviderTrait.registerRouteFilters
|
protected function registerRouteFilters(Router $router) {
foreach ( ( array ) $this->before as $before ) {
$router->before ( $before );
}
foreach ( ( array ) $this->after as $after ) {
$router->after ( $after );
}
foreach ( ( array ) $this->filters as $name => $filter ) {
$router->filter ( $name, $filter );
}
}
|
php
|
protected function registerRouteFilters(Router $router) {
foreach ( ( array ) $this->before as $before ) {
$router->before ( $before );
}
foreach ( ( array ) $this->after as $after ) {
$router->after ( $after );
}
foreach ( ( array ) $this->filters as $name => $filter ) {
$router->filter ( $name, $filter );
}
}
|
[
"protected",
"function",
"registerRouteFilters",
"(",
"Router",
"$",
"router",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"before",
"as",
"$",
"before",
")",
"{",
"$",
"router",
"->",
"before",
"(",
"$",
"before",
")",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"after",
"as",
"$",
"after",
")",
"{",
"$",
"router",
"->",
"after",
"(",
"$",
"after",
")",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"filters",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"$",
"router",
"->",
"filter",
"(",
"$",
"name",
",",
"$",
"filter",
")",
";",
"}",
"}"
] |
Register route filters.
@param \Illuminate\Routing\Router $router
@return void
|
[
"Register",
"route",
"filters",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Providers/Traits/FilterProviderTrait.php#L36-L48
|
228,337
|
antaresproject/core
|
src/components/html/src/Memory/Handler.php
|
Handler.initiate
|
public function initiate()
{
$items = [];
$memories = $this->cache instanceof Repository ? $this->getItemsFromCache() : $this->getItemsFromDatabase();
foreach ($memories as $memory) {
$value = $memory->value;
$items[$memory->name] = unserialize($value);
$this->addKey($memory->name, [
'id' => $memory->id,
'value' => $value,
]);
}
return $items;
}
|
php
|
public function initiate()
{
$items = [];
$memories = $this->cache instanceof Repository ? $this->getItemsFromCache() : $this->getItemsFromDatabase();
foreach ($memories as $memory) {
$value = $memory->value;
$items[$memory->name] = unserialize($value);
$this->addKey($memory->name, [
'id' => $memory->id,
'value' => $value,
]);
}
return $items;
}
|
[
"public",
"function",
"initiate",
"(",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"$",
"memories",
"=",
"$",
"this",
"->",
"cache",
"instanceof",
"Repository",
"?",
"$",
"this",
"->",
"getItemsFromCache",
"(",
")",
":",
"$",
"this",
"->",
"getItemsFromDatabase",
"(",
")",
";",
"foreach",
"(",
"$",
"memories",
"as",
"$",
"memory",
")",
"{",
"$",
"value",
"=",
"$",
"memory",
"->",
"value",
";",
"$",
"items",
"[",
"$",
"memory",
"->",
"name",
"]",
"=",
"unserialize",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"addKey",
"(",
"$",
"memory",
"->",
"name",
",",
"[",
"'id'",
"=>",
"$",
"memory",
"->",
"id",
",",
"'value'",
"=>",
"$",
"value",
",",
"]",
")",
";",
"}",
"return",
"$",
"items",
";",
"}"
] |
Load the data from database.
@return array
|
[
"Load",
"the",
"data",
"from",
"database",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Memory/Handler.php#L115-L129
|
228,338
|
gggeek/ggwebservices
|
classes/ggwebservicesjscfunctions.php
|
ggwebservicesJSCFunctions.listMethods
|
static function listMethods( )
{
$methods = array();
$ini = eZINI::Instance( 'ezjscore.ini' );
foreach( $ini->groups() as $blockname => $data )
{
if ( strpos( $blockname, 'ezjscServer_' ) === 0 )
{
$classname = substr( $blockname, 12 );
// replicate same logic as ezjscore
if ( $ini->hasVariable( $blockname, 'TemplateFunction' ) )
{
// unluckily any function name is accepted here
$methods[] = "$classname::*";
}
else
{
// load file if defined, else use autoload (same as ezjsc does)
if ( $ini->hasVariable( $blockname, 'File' ) )
include_once( $ini->variable( $blockname, 'File' ) );
// get class name if defined, else use first argument as class name
if ( $ini->hasVariable( $blockname, 'Class' ) )
$realclassname = $ini->variable( $blockname, 'Class' );
else
$realclassname = $classname;
if ( class_exists( $realclassname ) )
{
$reflectionClass = new ReflectionClass( $realclassname );
foreach( $reflectionClass->getMethods() as $reflectionMethod )
{
if ( $reflectionMethod->isStatic() )
{
$methods[] = "$classname::" . $reflectionMethod->name;
}
}
}
else
{
/// @todo log config error
}
}
}
}
return $methods;
}
|
php
|
static function listMethods( )
{
$methods = array();
$ini = eZINI::Instance( 'ezjscore.ini' );
foreach( $ini->groups() as $blockname => $data )
{
if ( strpos( $blockname, 'ezjscServer_' ) === 0 )
{
$classname = substr( $blockname, 12 );
// replicate same logic as ezjscore
if ( $ini->hasVariable( $blockname, 'TemplateFunction' ) )
{
// unluckily any function name is accepted here
$methods[] = "$classname::*";
}
else
{
// load file if defined, else use autoload (same as ezjsc does)
if ( $ini->hasVariable( $blockname, 'File' ) )
include_once( $ini->variable( $blockname, 'File' ) );
// get class name if defined, else use first argument as class name
if ( $ini->hasVariable( $blockname, 'Class' ) )
$realclassname = $ini->variable( $blockname, 'Class' );
else
$realclassname = $classname;
if ( class_exists( $realclassname ) )
{
$reflectionClass = new ReflectionClass( $realclassname );
foreach( $reflectionClass->getMethods() as $reflectionMethod )
{
if ( $reflectionMethod->isStatic() )
{
$methods[] = "$classname::" . $reflectionMethod->name;
}
}
}
else
{
/// @todo log config error
}
}
}
}
return $methods;
}
|
[
"static",
"function",
"listMethods",
"(",
")",
"{",
"$",
"methods",
"=",
"array",
"(",
")",
";",
"$",
"ini",
"=",
"eZINI",
"::",
"Instance",
"(",
"'ezjscore.ini'",
")",
";",
"foreach",
"(",
"$",
"ini",
"->",
"groups",
"(",
")",
"as",
"$",
"blockname",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"blockname",
",",
"'ezjscServer_'",
")",
"===",
"0",
")",
"{",
"$",
"classname",
"=",
"substr",
"(",
"$",
"blockname",
",",
"12",
")",
";",
"// replicate same logic as ezjscore\r",
"if",
"(",
"$",
"ini",
"->",
"hasVariable",
"(",
"$",
"blockname",
",",
"'TemplateFunction'",
")",
")",
"{",
"// unluckily any function name is accepted here\r",
"$",
"methods",
"[",
"]",
"=",
"\"$classname::*\"",
";",
"}",
"else",
"{",
"// load file if defined, else use autoload (same as ezjsc does)\r",
"if",
"(",
"$",
"ini",
"->",
"hasVariable",
"(",
"$",
"blockname",
",",
"'File'",
")",
")",
"include_once",
"(",
"$",
"ini",
"->",
"variable",
"(",
"$",
"blockname",
",",
"'File'",
")",
")",
";",
"// get class name if defined, else use first argument as class name\r",
"if",
"(",
"$",
"ini",
"->",
"hasVariable",
"(",
"$",
"blockname",
",",
"'Class'",
")",
")",
"$",
"realclassname",
"=",
"$",
"ini",
"->",
"variable",
"(",
"$",
"blockname",
",",
"'Class'",
")",
";",
"else",
"$",
"realclassname",
"=",
"$",
"classname",
";",
"if",
"(",
"class_exists",
"(",
"$",
"realclassname",
")",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"ReflectionClass",
"(",
"$",
"realclassname",
")",
";",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
")",
"as",
"$",
"reflectionMethod",
")",
"{",
"if",
"(",
"$",
"reflectionMethod",
"->",
"isStatic",
"(",
")",
")",
"{",
"$",
"methods",
"[",
"]",
"=",
"\"$classname::\"",
".",
"$",
"reflectionMethod",
"->",
"name",
";",
"}",
"}",
"}",
"else",
"{",
"/// @todo log config error\r",
"}",
"}",
"}",
"}",
"return",
"$",
"methods",
";",
"}"
] |
Returns the list of all webservices available on this server
@return array
|
[
"Returns",
"the",
"list",
"of",
"all",
"webservices",
"available",
"on",
"this",
"server"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesjscfunctions.php#L19-L65
|
228,339
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.chomp
|
public static function chomp($str)
{
if (true === self::isEmpty($str)) {
return $str;
}
if (1 === self::length($str)) {
$firstChar = self::charAt($str, 0);
if ("\r" === $firstChar || "\n" === $firstChar) {
return self::EMPTY_STR;
}
return $str;
}
$lastIndex = self::length($str) - 1;
$lastChar = self::charAt($str, $lastIndex);
if ("\n" === $lastChar) {
if ("\r" === self::charAt($str, $lastIndex - 1)) {
--$lastIndex;
}
} elseif ("\r" !== $lastChar) {
++$lastIndex;
}
return self::substring($str, 0, $lastIndex);
}
|
php
|
public static function chomp($str)
{
if (true === self::isEmpty($str)) {
return $str;
}
if (1 === self::length($str)) {
$firstChar = self::charAt($str, 0);
if ("\r" === $firstChar || "\n" === $firstChar) {
return self::EMPTY_STR;
}
return $str;
}
$lastIndex = self::length($str) - 1;
$lastChar = self::charAt($str, $lastIndex);
if ("\n" === $lastChar) {
if ("\r" === self::charAt($str, $lastIndex - 1)) {
--$lastIndex;
}
} elseif ("\r" !== $lastChar) {
++$lastIndex;
}
return self::substring($str, 0, $lastIndex);
}
|
[
"public",
"static",
"function",
"chomp",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"1",
"===",
"self",
"::",
"length",
"(",
"$",
"str",
")",
")",
"{",
"$",
"firstChar",
"=",
"self",
"::",
"charAt",
"(",
"$",
"str",
",",
"0",
")",
";",
"if",
"(",
"\"\\r\"",
"===",
"$",
"firstChar",
"||",
"\"\\n\"",
"===",
"$",
"firstChar",
")",
"{",
"return",
"self",
"::",
"EMPTY_STR",
";",
"}",
"return",
"$",
"str",
";",
"}",
"$",
"lastIndex",
"=",
"self",
"::",
"length",
"(",
"$",
"str",
")",
"-",
"1",
";",
"$",
"lastChar",
"=",
"self",
"::",
"charAt",
"(",
"$",
"str",
",",
"$",
"lastIndex",
")",
";",
"if",
"(",
"\"\\n\"",
"===",
"$",
"lastChar",
")",
"{",
"if",
"(",
"\"\\r\"",
"===",
"self",
"::",
"charAt",
"(",
"$",
"str",
",",
"$",
"lastIndex",
"-",
"1",
")",
")",
"{",
"--",
"$",
"lastIndex",
";",
"}",
"}",
"elseif",
"(",
"\"\\r\"",
"!==",
"$",
"lastChar",
")",
"{",
"++",
"$",
"lastIndex",
";",
"}",
"return",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"0",
",",
"$",
"lastIndex",
")",
";",
"}"
] |
Removes one newline from end of a string if it's there, otherwise leave
it alone.
A newline is "`\n`", "`\r`", or "`\r\n`".
StringUtils::chomp(null); // null
StringUtils::chomp(''); // ''
StringUtils::chomp("abc \r"); // 'abc '
StringUtils::chomp("abc\n"); // 'abc'
StringUtils::chomp("abc\r\n"); // 'abc'
StringUtils::chomp("abc\r\n\r\n"); // "abc\r\n"
StringUtils::chomp("abc\n\r"); // "abc\n"
StringUtils::chomp("abc\n\rabc"); // "abc\n\rabc"
StringUtils::chomp("\r"); // ''
StringUtils::chomp("\n"); // ''
StringUtils::chomp("\r\n"); // ''
@param string $str The `string` to chomp a newline from.
@return string The `string` $str without newline, `null` if `null`
`string` input.
|
[
"Removes",
"one",
"newline",
"from",
"end",
"of",
"a",
"string",
"if",
"it",
"s",
"there",
"otherwise",
"leave",
"it",
"alone",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L105-L133
|
228,340
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.chop
|
public static function chop($str)
{
if (true === self::isEmpty($str)) {
return $str;
}
if ("\r\n" === \substr($str, -2)) {
return \substr($str, 0, -2);
}
return \substr($str, 0, -1);
}
|
php
|
public static function chop($str)
{
if (true === self::isEmpty($str)) {
return $str;
}
if ("\r\n" === \substr($str, -2)) {
return \substr($str, 0, -2);
}
return \substr($str, 0, -1);
}
|
[
"public",
"static",
"function",
"chop",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"\"\\r\\n\"",
"===",
"\\",
"substr",
"(",
"$",
"str",
",",
"-",
"2",
")",
")",
"{",
"return",
"\\",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"-",
"2",
")",
";",
"}",
"return",
"\\",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"-",
"1",
")",
";",
"}"
] |
Remove the specified last character from a `string`.
If the `string` ends in `\r\n`, then remove both of them.
StringUtils::chop(null); // null
StringUtils::chop(''); // ''
StringUtils::chop("abc \r"); // 'abc '
StringUtils::chop("abc\n"); // 'abc'
StringUtils::chop("abc\r\n"); // 'abc'
StringUtils::chop('abc'); // 'ab'
StringUtils::chop("abc\nabc"); // "abc\nab"
StringUtils::chop('a'); // ''
StringUtils::chop("\r"); // ''
StringUtils::chop("\n"); // ''
StringUtils::chop("\r\n"); // ''
@param string $str The `string` to chop the last character from.
@return string|null The `string` without the last character; `null` if
`null` `string` input.
|
[
"Remove",
"the",
"specified",
"last",
"character",
"from",
"a",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L157-L168
|
228,341
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.replace
|
public static function replace($text, $search, $replace, $max = -1)
{
if ((true === self::isEmpty($text))
|| (true === self::isEmpty($search))
|| (null === $replace)
|| (0 === $max)
) {
return $text;
}
return \preg_replace(
'/' . \preg_quote($search) . '/',
$replace,
$text,
$max
);
}
|
php
|
public static function replace($text, $search, $replace, $max = -1)
{
if ((true === self::isEmpty($text))
|| (true === self::isEmpty($search))
|| (null === $replace)
|| (0 === $max)
) {
return $text;
}
return \preg_replace(
'/' . \preg_quote($search) . '/',
$replace,
$text,
$max
);
}
|
[
"public",
"static",
"function",
"replace",
"(",
"$",
"text",
",",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"max",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"text",
")",
")",
"||",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"search",
")",
")",
"||",
"(",
"null",
"===",
"$",
"replace",
")",
"||",
"(",
"0",
"===",
"$",
"max",
")",
")",
"{",
"return",
"$",
"text",
";",
"}",
"return",
"\\",
"preg_replace",
"(",
"'/'",
".",
"\\",
"preg_quote",
"(",
"$",
"search",
")",
".",
"'/'",
",",
"$",
"replace",
",",
"$",
"text",
",",
"$",
"max",
")",
";",
"}"
] |
Replaces a `string` with another `string` inside a larger `string`, for
the first maximum number of values to replace of the search `string`.
StringUtils::replace(null, *, *, *) // null
StringUtils::replace('', *, *, *) // ''
StringUtils::replace('any', null, *, *) // 'any'
StringUtils::replace('any', *, null, *) // 'any'
StringUtils::replace('any', '', *, *) // 'any'
StringUtils::replace('any', *, *, 0) // 'any'
StringUtils::replace('abaa', 'a', null, -1) // 'abaa'
StringUtils::replace('abaa', 'a', '', -1) // 'b'
StringUtils::replace('abaa', 'a', 'z', 0) // 'abaa'
StringUtils::replace('abaa', 'a', 'z', 1) // 'zbaa'
StringUtils::replace('abaa', 'a', 'z', 2) // 'zbza'
StringUtils::replace('abaa', 'a', 'z', -1) // 'zbzz'
@param string $text The `string` to search and replace in.
@param string $search The `string` to search for.
@param string $replace The `string` to replace $search with.
@param integer $max The maximum number of values to replace, or `-1`
if no maximum.
@return string The text with any replacements processed or `null` if
`null` `string` input.
|
[
"Replaces",
"a",
"string",
"with",
"another",
"string",
"inside",
"a",
"larger",
"string",
"for",
"the",
"first",
"maximum",
"number",
"of",
"values",
"to",
"replace",
"of",
"the",
"search",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L328-L344
|
228,342
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.strip
|
public static function strip($str, $chars)
{
return (true === self::isEmpty($str))
? $str
: self::stripEnd(self::stripStart($str, $chars), $chars);
}
|
php
|
public static function strip($str, $chars)
{
return (true === self::isEmpty($str))
? $str
: self::stripEnd(self::stripStart($str, $chars), $chars);
}
|
[
"public",
"static",
"function",
"strip",
"(",
"$",
"str",
",",
"$",
"chars",
")",
"{",
"return",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"?",
"$",
"str",
":",
"self",
"::",
"stripEnd",
"(",
"self",
"::",
"stripStart",
"(",
"$",
"str",
",",
"$",
"chars",
")",
",",
"$",
"chars",
")",
";",
"}"
] |
Strips any of a set of characters from the start and end of a `string`.
This is similar to {@see trim} but allows the characters to be stripped
to be controlled.
A `null` input `string` returns `null`.
An empty string (`''`) input returns the empty `string`.
If the `string` for the characters to remove is `null`, whitespace is
stripped.
StringUtils::strip(null, *); // null
StringUtils::strip('', *); // ''
StringUtils::strip('abc', null); // 'abc'
StringUtils::strip(' abc', null); // 'abc'
StringUtils::strip('abc ', null); // 'abc'
StringUtils::strip(' abc ', null); // 'abc'
StringUtils::strip(' abcyx', 'xyz'); // ' abc'
@param string $str The `string` to remove characters from.
@param string $chars The characters to remove. `null` is treated as
whitespace.
@return string|null The stripped `string` or `null` if `null` `string`
input.
|
[
"Strips",
"any",
"of",
"a",
"set",
"of",
"characters",
"from",
"the",
"start",
"and",
"end",
"of",
"a",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L458-L463
|
228,343
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.stripToEmpty
|
public static function stripToEmpty($str)
{
return (null === $str)
? self::EMPTY_STR
: self::strip($str, null);
}
|
php
|
public static function stripToEmpty($str)
{
return (null === $str)
? self::EMPTY_STR
: self::strip($str, null);
}
|
[
"public",
"static",
"function",
"stripToEmpty",
"(",
"$",
"str",
")",
"{",
"return",
"(",
"null",
"===",
"$",
"str",
")",
"?",
"self",
"::",
"EMPTY_STR",
":",
"self",
"::",
"strip",
"(",
"$",
"str",
",",
"null",
")",
";",
"}"
] |
Strips whitespace from the start and end of a `string` returning an empty
`string` if `null` input.
This is similar to {@see trimToEmpty} but removes whitespace.
StringUtils::stripToEmpty(null); // ''
StringUtils::stripToEmpty(''); // ''
StringUtils::stripToEmpty(' '); // ''
StringUtils::stripToEmpty('abc'); // 'abc'
StringUtils::stripToEmpty(' abc'); // 'abc'
StringUtils::stripToEmpty('abc '); // 'abc'
StringUtils::stripToEmpty(' abc '); // 'abc'
StringUtils::stripToEmpty(' ab c '); // 'ab c'
@param string $str The `string` to be stripped.
@return string The stripped `string` or an empty `string` if `null`
input.
|
[
"Strips",
"whitespace",
"from",
"the",
"start",
"and",
"end",
"of",
"a",
"string",
"returning",
"an",
"empty",
"string",
"if",
"null",
"input",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L485-L490
|
228,344
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.stripStart
|
public static function stripStart($str, $chars)
{
if (true === self::isEmpty($str)) {
return $str;
}
return (null === $chars)
? \ltrim($str)
: \ltrim($str, $chars);
}
|
php
|
public static function stripStart($str, $chars)
{
if (true === self::isEmpty($str)) {
return $str;
}
return (null === $chars)
? \ltrim($str)
: \ltrim($str, $chars);
}
|
[
"public",
"static",
"function",
"stripStart",
"(",
"$",
"str",
",",
"$",
"chars",
")",
"{",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"return",
"(",
"null",
"===",
"$",
"chars",
")",
"?",
"\\",
"ltrim",
"(",
"$",
"str",
")",
":",
"\\",
"ltrim",
"(",
"$",
"str",
",",
"$",
"chars",
")",
";",
"}"
] |
Strips any of a set of characters from the start of a `string`.
A `null` input `string` returns `null`.
An empty string (`''`) input returns the empty `string`.
If the `string` for the characters to remove is `null`, whitespace is
stripped.
StringUtils::stripStart(null, *); // null
StringUtils::stripStart('', *); // ''
StringUtils::stripStart('abc', ''); // 'abc'
StringUtils::stripStart('abc', null); // 'abc'
StringUtils::stripStart(' abc', null); // 'abc'
StringUtils::stripStart('abc ', null); // 'abc '
StringUtils::stripStart(' abc ', null); // 'abc '
StringUtils::stripStart('yxabc ', 'xyz'); // 'abc '
@param string $str The `string` to remove characters from.
@param string $chars The characters to remove. `null` is treated as
whitespace.
@return string|null The stripped `string` or `null` if `null` `string`
input.
|
[
"Strips",
"any",
"of",
"a",
"set",
"of",
"characters",
"from",
"the",
"start",
"of",
"a",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L546-L555
|
228,345
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.stripEnd
|
public static function stripEnd($str, $chars)
{
if (true === self::isEmpty($str)) {
return $str;
}
return (null === $chars)
? \rtrim($str)
: \rtrim($str, $chars);
}
|
php
|
public static function stripEnd($str, $chars)
{
if (true === self::isEmpty($str)) {
return $str;
}
return (null === $chars)
? \rtrim($str)
: \rtrim($str, $chars);
}
|
[
"public",
"static",
"function",
"stripEnd",
"(",
"$",
"str",
",",
"$",
"chars",
")",
"{",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"return",
"(",
"null",
"===",
"$",
"chars",
")",
"?",
"\\",
"rtrim",
"(",
"$",
"str",
")",
":",
"\\",
"rtrim",
"(",
"$",
"str",
",",
"$",
"chars",
")",
";",
"}"
] |
Strips any of a set of characters from the end of a `string`.
A `null` input `string` returns `null`.
An empty string (`''`) input returns the empty `string`.
If the `string` for the characters to remove is `null`, whitespace is
stripped.
StringUtils::stripEnd(null, *) = null
StringUtils::stripEnd('', *) = ''
StringUtils::stripEnd('abc', '') = 'abc'
StringUtils::stripEnd('abc', null) = 'abc'
StringUtils::stripEnd(' abc', null) = ' abc'
StringUtils::stripEnd('abc ', null) = 'abc'
StringUtils::stripEnd(' abc ', null) = ' abc'
StringUtils::stripEnd(' abcyx', 'xyz') = ' abc'
@param string $str The `string` to remove characters from.
@param string $chars The characters to remove. `null` is treated as
whitespace.
@return string|null The stripped `string` or `null` if `null` `string`
input.
|
[
"Strips",
"any",
"of",
"a",
"set",
"of",
"characters",
"from",
"the",
"end",
"of",
"a",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L582-L591
|
228,346
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.equalsIgnoreCase
|
public static function equalsIgnoreCase($str1, $str2)
{
return (null === $str1)
? (null === $str2)
: (self::lowercase($str1) === self::lowercase($str2));
}
|
php
|
public static function equalsIgnoreCase($str1, $str2)
{
return (null === $str1)
? (null === $str2)
: (self::lowercase($str1) === self::lowercase($str2));
}
|
[
"public",
"static",
"function",
"equalsIgnoreCase",
"(",
"$",
"str1",
",",
"$",
"str2",
")",
"{",
"return",
"(",
"null",
"===",
"$",
"str1",
")",
"?",
"(",
"null",
"===",
"$",
"str2",
")",
":",
"(",
"self",
"::",
"lowercase",
"(",
"$",
"str1",
")",
"===",
"self",
"::",
"lowercase",
"(",
"$",
"str2",
")",
")",
";",
"}"
] |
Compares two `string`s, returning `true` if they are equal ignoring the
case.
`null`s are handled without exceptions. Two `null` references are
considered to be equal. The comparison is case insensitive.
StringUtils::equalsIgnoreCase(null, null); // true
StringUtils::equalsIgnoreCase(null, 'abc'); // false
StringUtils::equalsIgnoreCase('abc', null); // false
StringUtils::equalsIgnoreCase('abc', 'abc'); // true
StringUtils::equalsIgnoreCase('abc', 'ABC'); // true
@param string $str1 The first `string`.
@param string $str2 The second `string`.
@return boolean `true` if the `string`s are equal, case insensitive, or
both `null`.
|
[
"Compares",
"two",
"string",
"s",
"returning",
"true",
"if",
"they",
"are",
"equal",
"ignoring",
"the",
"case",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L689-L694
|
228,347
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.indexOf
|
public static function indexOf($str, $search, $startPos = 0)
{
$result = self::validateIndexOf($str, $search, $startPos);
if (true !== $result) {
return $result;
}
if (true === self::isEmpty($search)) {
return $startPos;
}
$pos = \strpos($str, $search, $startPos);
return (false === $pos)
? -1
: $pos;
}
|
php
|
public static function indexOf($str, $search, $startPos = 0)
{
$result = self::validateIndexOf($str, $search, $startPos);
if (true !== $result) {
return $result;
}
if (true === self::isEmpty($search)) {
return $startPos;
}
$pos = \strpos($str, $search, $startPos);
return (false === $pos)
? -1
: $pos;
}
|
[
"public",
"static",
"function",
"indexOf",
"(",
"$",
"str",
",",
"$",
"search",
",",
"$",
"startPos",
"=",
"0",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"validateIndexOf",
"(",
"$",
"str",
",",
"$",
"search",
",",
"$",
"startPos",
")",
";",
"if",
"(",
"true",
"!==",
"$",
"result",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"search",
")",
")",
"{",
"return",
"$",
"startPos",
";",
"}",
"$",
"pos",
"=",
"\\",
"strpos",
"(",
"$",
"str",
",",
"$",
"search",
",",
"$",
"startPos",
")",
";",
"return",
"(",
"false",
"===",
"$",
"pos",
")",
"?",
"-",
"1",
":",
"$",
"pos",
";",
"}"
] |
Finds the first index within a `string` from a start position, handling
`null`.
A `null` or empty (`''`) `string` will return `-1`.
A negative start position is treated as zero.
A start position greater than the string length returns `-1`.
StringUtils::indexOf(null, *, *); // -1
StringUtils::indexOf(*, null, *); // -1
StringUtils::indexOf('', '', 0); // 0
StringUtils::indexOf('aabaabaa', 'a', 0); // 0
StringUtils::indexOf('aabaabaa', 'b', 0); // 2
StringUtils::indexOf('aabaabaa', 'ab', 0); // 1
StringUtils::indexOf('aabaabaa', 'b', 3); // 5
StringUtils::indexOf('aabaabaa', 'b', 9); // -1
StringUtils::indexOf('aabaabaa', 'b', -1); // 2
StringUtils::indexOf('aabaabaa', '', 2); // 2
StringUtils::indexOf('abc', '', 9); // 3
@param string $str The `string` to check.
@param string $search The `string` to find.
@param integer $startPos The start position, negative treated as zero.
@return integer The first index of the search character, `-1` if no match
or `null` `string` input.
|
[
"Finds",
"the",
"first",
"index",
"within",
"a",
"string",
"from",
"a",
"start",
"position",
"handling",
"null",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L723-L739
|
228,348
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.lastIndexOf
|
public static function lastIndexOf($str, $search, $startPos = 0)
{
$result = self::validateIndexOf($str, $search, $startPos);
if (true !== $result) {
return $result;
}
if (true === self::isEmpty($search)) {
return $startPos;
}
$pos = \strrpos($str, $search, $startPos);
return (false === $pos)
? -1
: $pos;
}
|
php
|
public static function lastIndexOf($str, $search, $startPos = 0)
{
$result = self::validateIndexOf($str, $search, $startPos);
if (true !== $result) {
return $result;
}
if (true === self::isEmpty($search)) {
return $startPos;
}
$pos = \strrpos($str, $search, $startPos);
return (false === $pos)
? -1
: $pos;
}
|
[
"public",
"static",
"function",
"lastIndexOf",
"(",
"$",
"str",
",",
"$",
"search",
",",
"$",
"startPos",
"=",
"0",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"validateIndexOf",
"(",
"$",
"str",
",",
"$",
"search",
",",
"$",
"startPos",
")",
";",
"if",
"(",
"true",
"!==",
"$",
"result",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"search",
")",
")",
"{",
"return",
"$",
"startPos",
";",
"}",
"$",
"pos",
"=",
"\\",
"strrpos",
"(",
"$",
"str",
",",
"$",
"search",
",",
"$",
"startPos",
")",
";",
"return",
"(",
"false",
"===",
"$",
"pos",
")",
"?",
"-",
"1",
":",
"$",
"pos",
";",
"}"
] |
Finds the first index within a `string`, handling `null`.
A `null` `string` will return `-1`.
A negative start position returns `-1`. An empty (`''`) search `string`
always matches unless the start position is negative.
A start position greater than the `string` length searches the whole
`string`.
StringUtils::lastIndexOf(null, *, *); // -1
StringUtils::lastIndexOf(*, null, *); // -1
StringUtils::lastIndexOf('aabaabaa', 'a', 8); // 7
StringUtils::lastIndexOf('aabaabaa', 'b', 8); // 5
StringUtils::lastIndexOf('aabaabaa', 'ab', 8); // 4
StringUtils::lastIndexOf('aabaabaa', 'b', 9); // 5
StringUtils::lastIndexOf('aabaabaa', 'b', -1); // -1
StringUtils::lastIndexOf('aabaabaa', 'a', 0); // 0
StringUtils::lastIndexOf('aabaabaa', 'b', 0); // -1
@param string $str The `string` to check.
@param string $search The `string` to find.
@param integer $startPos The start position, negative treated as zero.
@return integer The first index of the search `string`, `-1` if no match
or null `string` input.
|
[
"Finds",
"the",
"first",
"index",
"within",
"a",
"string",
"handling",
"null",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L801-L817
|
228,349
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.split
|
public static function split($str, $chars = null, $max = 0)
{
$result = self::EMPTY_STR;
if (null === $str) {
return null;
}
if (self::EMPTY_STR === $str) {
return array();
}
if (null === $chars) {
$result = \preg_split('/\s+/', $str, $max);
} elseif ($max > 0) {
$result = \explode($chars, $str, $max);
} else {
$result = \explode($chars, $str);
}
return $result;
}
|
php
|
public static function split($str, $chars = null, $max = 0)
{
$result = self::EMPTY_STR;
if (null === $str) {
return null;
}
if (self::EMPTY_STR === $str) {
return array();
}
if (null === $chars) {
$result = \preg_split('/\s+/', $str, $max);
} elseif ($max > 0) {
$result = \explode($chars, $str, $max);
} else {
$result = \explode($chars, $str);
}
return $result;
}
|
[
"public",
"static",
"function",
"split",
"(",
"$",
"str",
",",
"$",
"chars",
"=",
"null",
",",
"$",
"max",
"=",
"0",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"EMPTY_STR",
";",
"if",
"(",
"null",
"===",
"$",
"str",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"self",
"::",
"EMPTY_STR",
"===",
"$",
"str",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"chars",
")",
"{",
"$",
"result",
"=",
"\\",
"preg_split",
"(",
"'/\\s+/'",
",",
"$",
"str",
",",
"$",
"max",
")",
";",
"}",
"elseif",
"(",
"$",
"max",
">",
"0",
")",
"{",
"$",
"result",
"=",
"\\",
"explode",
"(",
"$",
"chars",
",",
"$",
"str",
",",
"$",
"max",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"\\",
"explode",
"(",
"$",
"chars",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Splits the provided text into an `array` with a maximum length,
separators specified.
The separator is not included in the returned `string` `array`. Adjacent
separators are treated as one separator. A `null` input `string` returns
`null`. A `null` $chars splits on whitespace. If more than $max
delimited substrings are found, the returned `string` includes all
characters after the first `$max - 1` returned `string`s (including
separator characters).
StringUtils::split(null, null, null); // null
StringUtils::split('', null, null); // []
StringUtils::split('ab cd ef', null, 0); // ['ab', 'cd', 'ef']
StringUtils::split('ab cd ef', null, 0); // ['ab', 'cd', 'ef']
StringUtils::split('ab:cd:ef', ':', 0); // ['ab', 'cd', 'ef']
StringUtils::split('ab:cd:ef', ':', 2); // ['ab', 'cd:ef']
@param string $str The `string` to parse.
@param string $chars The characters used as the delimiters, `null`
splits on whitespace.
@param integer $max The maximum number of elements to include in the
`array.` A zero or negative value implies no limit.
@return array|null An `array` of parsed `string`s, `null` if `null`
`string` input.
|
[
"Splits",
"the",
"provided",
"text",
"into",
"an",
"array",
"with",
"a",
"maximum",
"length",
"separators",
"specified",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L850-L871
|
228,350
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.substring
|
public static function substring($str, $start, $end = null)
{
if ((0 > $start) && (0 < $end)) {
$start = 0;
}
if (null === $end) {
$end = self::length($str);
}
return \substr($str, $start, $end - $start);
}
|
php
|
public static function substring($str, $start, $end = null)
{
if ((0 > $start) && (0 < $end)) {
$start = 0;
}
if (null === $end) {
$end = self::length($str);
}
return \substr($str, $start, $end - $start);
}
|
[
"public",
"static",
"function",
"substring",
"(",
"$",
"str",
",",
"$",
"start",
",",
"$",
"end",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"0",
">",
"$",
"start",
")",
"&&",
"(",
"0",
"<",
"$",
"end",
")",
")",
"{",
"$",
"start",
"=",
"0",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"end",
")",
"{",
"$",
"end",
"=",
"self",
"::",
"length",
"(",
"$",
"str",
")",
";",
"}",
"return",
"\\",
"substr",
"(",
"$",
"str",
",",
"$",
"start",
",",
"$",
"end",
"-",
"$",
"start",
")",
";",
"}"
] |
Gets a substring from the specified `string` avoiding exceptions.
A negative start position can be used to start/end *n* characters from
the end of the `string`.
The returned substring starts with the character in the `$start` position
and ends before the `$end` position. All position counting is zero-based
-- i.e., to start at the beginning of the `string` use `$start = 0`.
Negative start and end positions can be used to specify offsets relative
to the end of the `string`.
If `$start` is not strictly to the left of `$end`, the empty string is
returned.
StringUtils::substring(null, *); // null
StringUtils::substring('', *); // ''
StringUtils::substring('abc', 0); // 'abc'
StringUtils::substring('abc', 2); // 'c'
StringUtils::substring('abc', 4); // ''
StringUtils::substring('abc', -2); // 'bc'
StringUtils::substring('abc', -4); // 'abc'
StringUtils::substring(null, *, *); // null
StringUtils::substring('', * , *); // '';
StringUtils::substring('abc', 0, 2); // 'ab'
StringUtils::substring('abc', 2, 0); // ''
StringUtils::substring('abc', 2, 4); // 'c'
StringUtils::substring('abc', 4, 6); // ''
StringUtils::substring('abc', 2, 2); // ''
StringUtils::substring('abc', -2, -1); // 'b'
StringUtils::substring('abc', -4, 2); // 'ab'
@param string $str The `string` to get the substring from.
@param integer $start The position to start from, negative means count
back from the end of the `string` by this many characters.
@param integer $end The position to end at (exclusive), negative means
count back from the end of the `string` by this many characters.
@return string|null The substring from start position to end position,
`null` if `null` `string` input.
|
[
"Gets",
"a",
"substring",
"from",
"the",
"specified",
"string",
"avoiding",
"exceptions",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L915-L926
|
228,351
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.substringAfter
|
public static function substringAfter($str, $separator)
{
if (true === self::isEmpty($str)) {
return $str;
}
if (null === $separator) {
return self::EMPTY_STR;
}
$pos = self::indexOf($str, $separator);
if (self::INDEX_NOT_FOUND === $pos) {
return self::EMPTY_STR;
}
return self::substring($str, $pos + self::length($separator));
}
|
php
|
public static function substringAfter($str, $separator)
{
if (true === self::isEmpty($str)) {
return $str;
}
if (null === $separator) {
return self::EMPTY_STR;
}
$pos = self::indexOf($str, $separator);
if (self::INDEX_NOT_FOUND === $pos) {
return self::EMPTY_STR;
}
return self::substring($str, $pos + self::length($separator));
}
|
[
"public",
"static",
"function",
"substringAfter",
"(",
"$",
"str",
",",
"$",
"separator",
")",
"{",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"separator",
")",
"{",
"return",
"self",
"::",
"EMPTY_STR",
";",
"}",
"$",
"pos",
"=",
"self",
"::",
"indexOf",
"(",
"$",
"str",
",",
"$",
"separator",
")",
";",
"if",
"(",
"self",
"::",
"INDEX_NOT_FOUND",
"===",
"$",
"pos",
")",
"{",
"return",
"self",
"::",
"EMPTY_STR",
";",
"}",
"return",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"$",
"pos",
"+",
"self",
"::",
"length",
"(",
"$",
"separator",
")",
")",
";",
"}"
] |
Gets the substring after the first occurrence of a separator.
The separator is not returned.
A `null` `string` input will return `null`.
An empty (`''`) `string` input will return the empty `string`.
A `null` separator will return the empty `string` if the input `string`
is not `null`.
If nothing is found, the empty `string` is returned.
StringUtils::substringAfter(null, *); // null
StringUtils::substringAfter('', *); // ''
StringUtils::substringAfter(*, null); // ''
StringUtils::substringAfter('abc', 'a'); // 'bc'
StringUtils::substringAfter('abcba', 'b'); // 'cba'
StringUtils::substringAfter('abc', 'c'); // ''
StringUtils::substringAfter('abc', 'd'); // ''
StringUtils::substringAfter('abc', ''); // 'abc'
@param string $str The `string` to get a substring from.
@param string $separator The `string` to search for.
@return string|null The substring after the first occurrence of the
separator, `null` if `null` `string` input.
|
[
"Gets",
"the",
"substring",
"after",
"the",
"first",
"occurrence",
"of",
"a",
"separator",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L955-L972
|
228,352
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.substringAfterLast
|
public static function substringAfterLast($str, $separator)
{
if (true === self::isEmpty($str)) {
return $str;
}
if (true === self::isEmpty($separator)) {
return self::EMPTY_STR;
}
$pos = self::lastIndexOf($str, $separator);
if (self::INDEX_NOT_FOUND === $pos
|| (self::length($str) - self::length($separator)) === $pos
) {
return self::EMPTY_STR;
}
return self::substring($str, $pos + self::length($separator));
}
|
php
|
public static function substringAfterLast($str, $separator)
{
if (true === self::isEmpty($str)) {
return $str;
}
if (true === self::isEmpty($separator)) {
return self::EMPTY_STR;
}
$pos = self::lastIndexOf($str, $separator);
if (self::INDEX_NOT_FOUND === $pos
|| (self::length($str) - self::length($separator)) === $pos
) {
return self::EMPTY_STR;
}
return self::substring($str, $pos + self::length($separator));
}
|
[
"public",
"static",
"function",
"substringAfterLast",
"(",
"$",
"str",
",",
"$",
"separator",
")",
"{",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"separator",
")",
")",
"{",
"return",
"self",
"::",
"EMPTY_STR",
";",
"}",
"$",
"pos",
"=",
"self",
"::",
"lastIndexOf",
"(",
"$",
"str",
",",
"$",
"separator",
")",
";",
"if",
"(",
"self",
"::",
"INDEX_NOT_FOUND",
"===",
"$",
"pos",
"||",
"(",
"self",
"::",
"length",
"(",
"$",
"str",
")",
"-",
"self",
"::",
"length",
"(",
"$",
"separator",
")",
")",
"===",
"$",
"pos",
")",
"{",
"return",
"self",
"::",
"EMPTY_STR",
";",
"}",
"return",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"$",
"pos",
"+",
"self",
"::",
"length",
"(",
"$",
"separator",
")",
")",
";",
"}"
] |
Gets the substring after the last occurrence of a separator.
The separator is not returned.
A `null` `string` input will return `null`.
An empty (`''`) `string` input will return the empty `string`.
An empty or `null` separator will return the empty `string` if the input
`string` is not `null`.
If nothing is found, the empty `string` is returned.
StringUtils::substringAfterLast(null, *); // null
StringUtils::substringAfterLast('', *); // ''
StringUtils::substringAfterLast(*, ''); // ''
StringUtils::substringAfterLast(*, null); // ''
StringUtils::substringAfterLast('abc', 'a'); // 'bc'
StringUtils::substringAfterLast('abcba', 'b'); // 'a'
StringUtils::substringAfterLast('abc', 'c'); // ''
StringUtils::substringAfterLast('a', 'a'); // ''
StringUtils::substringAfterLast('a', 'z'); // ''
@param string $str The `string` to get a substring from.
@param string $separator The `string` to search for.
@return string|null The substring after the last occurrence of the
separator, `null` if `null` `string` input.
|
[
"Gets",
"the",
"substring",
"after",
"the",
"last",
"occurrence",
"of",
"a",
"separator",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1002-L1021
|
228,353
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.substringBeforeLast
|
public static function substringBeforeLast($str, $separator)
{
if ((true === self::isEmpty($str))
|| (true === self::isEmpty($separator))
) {
return $str;
}
$pos = self::lastIndexOf($str, $separator);
if (self::INDEX_NOT_FOUND === $pos) {
return $str;
}
return self::substring($str, 0, $pos);
}
|
php
|
public static function substringBeforeLast($str, $separator)
{
if ((true === self::isEmpty($str))
|| (true === self::isEmpty($separator))
) {
return $str;
}
$pos = self::lastIndexOf($str, $separator);
if (self::INDEX_NOT_FOUND === $pos) {
return $str;
}
return self::substring($str, 0, $pos);
}
|
[
"public",
"static",
"function",
"substringBeforeLast",
"(",
"$",
"str",
",",
"$",
"separator",
")",
"{",
"if",
"(",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"||",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"separator",
")",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"$",
"pos",
"=",
"self",
"::",
"lastIndexOf",
"(",
"$",
"str",
",",
"$",
"separator",
")",
";",
"if",
"(",
"self",
"::",
"INDEX_NOT_FOUND",
"===",
"$",
"pos",
")",
"{",
"return",
"$",
"str",
";",
"}",
"return",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"0",
",",
"$",
"pos",
")",
";",
"}"
] |
Gets the substring before the last occurrence of a separator.
The separator is not returned.
A `null` `string` input will return `null`.
An empty (`''`) `string` input will return the empty `string`.
An empty or `null` separator will return the input `string`.
If nothing is found, the `string` input is returned.
StringUtils::substringBeforeLast(null, *); // null
StringUtils::substringBeforeLast('', *); // ''
StringUtils::substringBeforeLast('abcba', 'b'); // 'abc'
StringUtils::substringBeforeLast('abc', 'c'); // 'ab'
StringUtils::substringBeforeLast('a', 'a'); // ''
StringUtils::substringBeforeLast('a', 'z'); // 'a'
StringUtils::substringBeforeLast('a', null); // 'a'
StringUtils::substringBeforeLast('a', ''); // 'a'
@param string $str The `string` to get a substring from.
@param string $separator The `string` to search for.
@return string|null The substring before the last occurrence of the
seperator, `null` if `null` `string` input.
|
[
"Gets",
"the",
"substring",
"before",
"the",
"last",
"occurrence",
"of",
"a",
"separator",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1094-L1109
|
228,354
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.substringBetween
|
public static function substringBetween($str, $open, $close = null)
{
$result = null;
if (null === $close) {
$close = $open;
}
$startPos = self::indexOf($str, $open);
if (self::INDEX_NOT_FOUND !== $startPos) {
$startPos += self::length($open);
$endPos = self::indexOf($str, $close, $startPos);
if (self::INDEX_NOT_FOUND !== $endPos) {
$result = self::substring($str, $startPos, $endPos);
}
}
return $result;
}
|
php
|
public static function substringBetween($str, $open, $close = null)
{
$result = null;
if (null === $close) {
$close = $open;
}
$startPos = self::indexOf($str, $open);
if (self::INDEX_NOT_FOUND !== $startPos) {
$startPos += self::length($open);
$endPos = self::indexOf($str, $close, $startPos);
if (self::INDEX_NOT_FOUND !== $endPos) {
$result = self::substring($str, $startPos, $endPos);
}
}
return $result;
}
|
[
"public",
"static",
"function",
"substringBetween",
"(",
"$",
"str",
",",
"$",
"open",
",",
"$",
"close",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"null",
"===",
"$",
"close",
")",
"{",
"$",
"close",
"=",
"$",
"open",
";",
"}",
"$",
"startPos",
"=",
"self",
"::",
"indexOf",
"(",
"$",
"str",
",",
"$",
"open",
")",
";",
"if",
"(",
"self",
"::",
"INDEX_NOT_FOUND",
"!==",
"$",
"startPos",
")",
"{",
"$",
"startPos",
"+=",
"self",
"::",
"length",
"(",
"$",
"open",
")",
";",
"$",
"endPos",
"=",
"self",
"::",
"indexOf",
"(",
"$",
"str",
",",
"$",
"close",
",",
"$",
"startPos",
")",
";",
"if",
"(",
"self",
"::",
"INDEX_NOT_FOUND",
"!==",
"$",
"endPos",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"$",
"startPos",
",",
"$",
"endPos",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Gets the `string` that is nested in between two `string`s.
Only the first match is returned.
A `null` input `string` returns `null`. A `null` `$open`/`$close` returns
`null` (no match). An empty (`''`) `$open` and `$close` returns an empty
`string`.
StringUtils::substringBetween('wx[b]yz', '[', ']'); // 'b'
StringUtils::substringBetween(null, *, *); // null
StringUtils::substringBetween(*, null, *); // null
StringUtils::substringBetween(*, *, null); // null
StringUtils::substringBetween('', '', ''); // ''
StringUtils::substringBetween('', '', ']'); // null
StringUtils::substringBetween('', '[', ']'); // null
StringUtils::substringBetween('yabcz', '', ''); // ''
StringUtils::substringBetween('yabcz', 'y', 'z'); // 'abc'
StringUtils::substringBetween('yabczyabcz', 'y', 'z'); // 'abc'
@param string $str The `string` containing the substrings, `null`
returns `null`, empty returns empty.
@param string $open The `string` identifying the start of the substring,
empty returns `null`.
@param string $close The `string` identifying the end of the substring,
empty returns `null`.
@return string|null The `string` after the substring, `null` if no match.
|
[
"Gets",
"the",
"string",
"that",
"is",
"nested",
"in",
"between",
"two",
"string",
"s",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1140-L1160
|
228,355
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.repeat
|
public static function repeat($str, $repeat, $separator = null)
{
$result = self::EMPTY_STR;
if ((null === $str) || (null === $separator)) {
$result = \str_repeat($str, $repeat);
} else {
$result = \str_repeat($str . $separator, $repeat);
if (true === self::isNotEmpty($str)) {
$result = self::removeEnd($result, $separator);
}
}
return $result;
}
|
php
|
public static function repeat($str, $repeat, $separator = null)
{
$result = self::EMPTY_STR;
if ((null === $str) || (null === $separator)) {
$result = \str_repeat($str, $repeat);
} else {
$result = \str_repeat($str . $separator, $repeat);
if (true === self::isNotEmpty($str)) {
$result = self::removeEnd($result, $separator);
}
}
return $result;
}
|
[
"public",
"static",
"function",
"repeat",
"(",
"$",
"str",
",",
"$",
"repeat",
",",
"$",
"separator",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"EMPTY_STR",
";",
"if",
"(",
"(",
"null",
"===",
"$",
"str",
")",
"||",
"(",
"null",
"===",
"$",
"separator",
")",
")",
"{",
"$",
"result",
"=",
"\\",
"str_repeat",
"(",
"$",
"str",
",",
"$",
"repeat",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"\\",
"str_repeat",
"(",
"$",
"str",
".",
"$",
"separator",
",",
"$",
"repeat",
")",
";",
"if",
"(",
"true",
"===",
"self",
"::",
"isNotEmpty",
"(",
"$",
"str",
")",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"removeEnd",
"(",
"$",
"result",
",",
"$",
"separator",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Repeats a `string` the specified number of times to form a new `string`,
with a specified `string` injected each time.
StringUtils::repeat(null, 2, null); // null
StringUtils::repeat(null, 2, 'x'); // null
StringUtils::repeat('', 0, null); // ''
StringUtils::repeat('', 2, ''); // ''
StringUtils::repeat('', 3, 'x'); // 'xxx'
StringUtils::repeat('?', 3, ', '); // '?, ?, ?'
@param string $str The `string` to repeat.
@param integer $repeat The number of times to repeat $str, negative
treated as zero.
@param string $separator The `string` to inject.
@return string|null The capitalized `string` or `null` if `null` `string`
input.
|
[
"Repeats",
"a",
"string",
"the",
"specified",
"number",
"of",
"times",
"to",
"form",
"a",
"new",
"string",
"with",
"a",
"specified",
"string",
"injected",
"each",
"time",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1233-L1248
|
228,356
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.endsWith
|
public static function endsWith($str, $suffix)
{
return ((null === $str) && (null === $suffix))
? true
: self::substring(
$str,
self::length($str) - self::length($suffix)
) === $suffix;
}
|
php
|
public static function endsWith($str, $suffix)
{
return ((null === $str) && (null === $suffix))
? true
: self::substring(
$str,
self::length($str) - self::length($suffix)
) === $suffix;
}
|
[
"public",
"static",
"function",
"endsWith",
"(",
"$",
"str",
",",
"$",
"suffix",
")",
"{",
"return",
"(",
"(",
"null",
"===",
"$",
"str",
")",
"&&",
"(",
"null",
"===",
"$",
"suffix",
")",
")",
"?",
"true",
":",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"self",
"::",
"length",
"(",
"$",
"str",
")",
"-",
"self",
"::",
"length",
"(",
"$",
"suffix",
")",
")",
"===",
"$",
"suffix",
";",
"}"
] |
Checks if a `string` ends with a specified suffix.
`null`s are handled without exceptions. Two `null` references are
considered to be equal. The comparison is case sensitive.
StringUtils::endsWith(null, null); // true
StringUtils::endsWith(null, 'def'); // false
StringUtils::endsWith('abcdef', null); // false
StringUtils::endsWith('abcdef', 'def'); // true
StringUtils::endsWith('ABCDEF', 'def'); // false
StringUtils::endsWith('ABCDEF', 'cde'); // false
@param string $str The `string` to check.
@param string $suffix The suffix to find.
@return boolean `true` if the `string` $str ends with the suffix $suffix,
case sensitive, or both `null`.
|
[
"Checks",
"if",
"a",
"string",
"ends",
"with",
"a",
"specified",
"suffix",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1273-L1281
|
228,357
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.startsWith
|
public static function startsWith($str, $prefix)
{
return ((null === $str) && (null === $prefix))
? true
: self::substring($str, 0, self::length($prefix)) === $prefix;
}
|
php
|
public static function startsWith($str, $prefix)
{
return ((null === $str) && (null === $prefix))
? true
: self::substring($str, 0, self::length($prefix)) === $prefix;
}
|
[
"public",
"static",
"function",
"startsWith",
"(",
"$",
"str",
",",
"$",
"prefix",
")",
"{",
"return",
"(",
"(",
"null",
"===",
"$",
"str",
")",
"&&",
"(",
"null",
"===",
"$",
"prefix",
")",
")",
"?",
"true",
":",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"0",
",",
"self",
"::",
"length",
"(",
"$",
"prefix",
")",
")",
"===",
"$",
"prefix",
";",
"}"
] |
Checks if a `string` starts with a specified prefix.
`null`s are handled without exceptions. Two `null` references are
considered to be equal. The comparison is case sensitive.
StringUtils::startsWith(null, null); // true
StringUtils::startsWith(null, 'abc'); // false
StringUtils::startsWith('abcdef', null); // false
StringUtils::startsWith('abcdef', 'abc'); // true
StringUtils::startsWith('ABCDEF', 'abc'); // false
@param string $str The `string` to check.
@param string $prefix The prefix to find.
@return boolean `true` if the `string` `$str` starts with the prefix
`$prefix`, case sensitive, or both `null`.
|
[
"Checks",
"if",
"a",
"string",
"starts",
"with",
"a",
"specified",
"prefix",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1301-L1306
|
228,358
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.removeEnd
|
public static function removeEnd($str, $remove)
{
if ((true === self::isEmpty($str))
|| (true === self::isEmpty($remove))
) {
return $str;
}
if (true === self::endsWith($str, $remove)) {
return self::substring(
$str,
0,
self::length($str) - self::length($remove)
);
}
return $str;
}
|
php
|
public static function removeEnd($str, $remove)
{
if ((true === self::isEmpty($str))
|| (true === self::isEmpty($remove))
) {
return $str;
}
if (true === self::endsWith($str, $remove)) {
return self::substring(
$str,
0,
self::length($str) - self::length($remove)
);
}
return $str;
}
|
[
"public",
"static",
"function",
"removeEnd",
"(",
"$",
"str",
",",
"$",
"remove",
")",
"{",
"if",
"(",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"||",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"remove",
")",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"true",
"===",
"self",
"::",
"endsWith",
"(",
"$",
"str",
",",
"$",
"remove",
")",
")",
"{",
"return",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"0",
",",
"self",
"::",
"length",
"(",
"$",
"str",
")",
"-",
"self",
"::",
"length",
"(",
"$",
"remove",
")",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Removes a substring only if it is at the end of a source `string`,
otherwise returns the source `string`.
A `null` source `string` will return `null`.
An empty (`''`) source `string` will return the empty `string`.
A `null` search `string` will return the source `string`.
StringUtils::removeEnd(null, *); // null
StringUtils::removeEnd('', *); // ''
StringUtils::removeEnd(*, null); // *
StringUtils::removeEnd('www.domain.com', '.com.'); // 'www.domain.com'
StringUtils::removeEnd('www.domain.com', '.com'); // 'www.domain'
StringUtils::removeEnd('www.domain.com', 'domain'); // 'www.domain.com'
StringUtils::removeEnd('abc', ''); // 'abc'
@param string $str The source `string` to search.
@param string $remove The `string` to search for and remove.
@return string|null The substring with the `string` removed if found,
`null` if `null` `string` input.
|
[
"Removes",
"a",
"substring",
"only",
"if",
"it",
"is",
"at",
"the",
"end",
"of",
"a",
"source",
"string",
"otherwise",
"returns",
"the",
"source",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1334-L1351
|
228,359
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/StringUtils.php
|
StringUtils.removeStart
|
public static function removeStart($str, $remove)
{
if ((true === self::isEmpty($str))
|| (true === self::isEmpty($remove))
) {
return $str;
}
if (true === self::startsWith($str, $remove)) {
return self::substring($str, self::length($remove));
}
return $str;
}
|
php
|
public static function removeStart($str, $remove)
{
if ((true === self::isEmpty($str))
|| (true === self::isEmpty($remove))
) {
return $str;
}
if (true === self::startsWith($str, $remove)) {
return self::substring($str, self::length($remove));
}
return $str;
}
|
[
"public",
"static",
"function",
"removeStart",
"(",
"$",
"str",
",",
"$",
"remove",
")",
"{",
"if",
"(",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"str",
")",
")",
"||",
"(",
"true",
"===",
"self",
"::",
"isEmpty",
"(",
"$",
"remove",
")",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"true",
"===",
"self",
"::",
"startsWith",
"(",
"$",
"str",
",",
"$",
"remove",
")",
")",
"{",
"return",
"self",
"::",
"substring",
"(",
"$",
"str",
",",
"self",
"::",
"length",
"(",
"$",
"remove",
")",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Removes a substring only if it is at the beginning of a source `string`,
otherwise returns the source `string`.
A `null` source string will return `null`.
An empty (`''`) source `string` will return the empty `string`.
A `null` search `string` will return the source `string`.
StringUtils::removeStart(null, *); // null
StringUtils::removeStart('', *); // ''
StringUtils::removeStart(*, null); // *
StringUtils::removeStart('www.domain.com', 'www.'); // 'domain.com'
StringUtils::removeStart('domain.com', 'www.'); // 'domain.com'
StringUtils::removeStart('www.domain.com', 'domain'); // 'www.domain.com'
StringUtils::removeStart('abc', ''); // 'abc'
@param string $str The source `string` to search.
@param string $remove The `string` to search for and remove.
@return string|null The substring with the `string` removed if found,
`null` if `null` `string` input.
|
[
"Removes",
"a",
"substring",
"only",
"if",
"it",
"is",
"at",
"the",
"beginning",
"of",
"a",
"source",
"string",
"otherwise",
"returns",
"the",
"source",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringUtils.php#L1375-L1388
|
228,360
|
antaresproject/core
|
src/components/html/src/Adapter/CustomfieldAdapter.php
|
CustomfieldAdapter.adapt
|
public function adapt(Grid &$grid)
{
$this->grid = $grid;
$customfields = app('customfields')->get();
if (empty($customfields)) {
return;
}
foreach ($customfields as $classname => $customfield) {
if (is_array($grid->row)) {
continue;
}
if (get_class($grid->row) !== $classname) {
continue;
}
if (!is_array($customfield)) {
$customfield = [$customfield];
}
foreach ($customfield as $instance) {
if (!is_object($instance)) {
continue;
}
$this->addToForm($instance);
}
}
if (extension_active('customfields')) {
$map = config('antares/customfields::map', []);
$types = [];
foreach ($map as $type => $classnames) {
foreach ($classnames as $classname) {
if (is_array($this->grid->row)) {
continue;
}
if (get_class($this->grid->row) !== $classname) {
continue;
}
array_push($types, $type);
}
}
if (!empty($types)) {
$this->getFields($types);
}
}
}
|
php
|
public function adapt(Grid &$grid)
{
$this->grid = $grid;
$customfields = app('customfields')->get();
if (empty($customfields)) {
return;
}
foreach ($customfields as $classname => $customfield) {
if (is_array($grid->row)) {
continue;
}
if (get_class($grid->row) !== $classname) {
continue;
}
if (!is_array($customfield)) {
$customfield = [$customfield];
}
foreach ($customfield as $instance) {
if (!is_object($instance)) {
continue;
}
$this->addToForm($instance);
}
}
if (extension_active('customfields')) {
$map = config('antares/customfields::map', []);
$types = [];
foreach ($map as $type => $classnames) {
foreach ($classnames as $classname) {
if (is_array($this->grid->row)) {
continue;
}
if (get_class($this->grid->row) !== $classname) {
continue;
}
array_push($types, $type);
}
}
if (!empty($types)) {
$this->getFields($types);
}
}
}
|
[
"public",
"function",
"adapt",
"(",
"Grid",
"&",
"$",
"grid",
")",
"{",
"$",
"this",
"->",
"grid",
"=",
"$",
"grid",
";",
"$",
"customfields",
"=",
"app",
"(",
"'customfields'",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"customfields",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"customfields",
"as",
"$",
"classname",
"=>",
"$",
"customfield",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"grid",
"->",
"row",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"grid",
"->",
"row",
")",
"!==",
"$",
"classname",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"customfield",
")",
")",
"{",
"$",
"customfield",
"=",
"[",
"$",
"customfield",
"]",
";",
"}",
"foreach",
"(",
"$",
"customfield",
"as",
"$",
"instance",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"instance",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"addToForm",
"(",
"$",
"instance",
")",
";",
"}",
"}",
"if",
"(",
"extension_active",
"(",
"'customfields'",
")",
")",
"{",
"$",
"map",
"=",
"config",
"(",
"'antares/customfields::map'",
",",
"[",
"]",
")",
";",
"$",
"types",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"type",
"=>",
"$",
"classnames",
")",
"{",
"foreach",
"(",
"$",
"classnames",
"as",
"$",
"classname",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"grid",
"->",
"row",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"this",
"->",
"grid",
"->",
"row",
")",
"!==",
"$",
"classname",
")",
"{",
"continue",
";",
"}",
"array_push",
"(",
"$",
"types",
",",
"$",
"type",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"types",
")",
")",
"{",
"$",
"this",
"->",
"getFields",
"(",
"$",
"types",
")",
";",
"}",
"}",
"}"
] |
Adapts customfields to form grid
@param Grid $grid
|
[
"Adapts",
"customfields",
"to",
"form",
"grid"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Adapter/CustomfieldAdapter.php#L44-L93
|
228,361
|
antaresproject/core
|
src/components/html/src/Adapter/CustomfieldAdapter.php
|
CustomfieldAdapter.addToForm
|
protected function addToForm(CustomField $customfield)
{
if (!$customfield->formAutoDisplay()) {
return false;
}
$field = $customfield->setModel($this->grid->row);
$this->grid->fieldset(function (Fieldset $fieldset) use($field) {
$fieldset->add($field);
});
$this->grid->rules(array_merge($this->grid->rules, $field->getRules()));
$this->grid->row->saved(function($row) use($field) {
$field->onSave($row);
});
return $this;
}
|
php
|
protected function addToForm(CustomField $customfield)
{
if (!$customfield->formAutoDisplay()) {
return false;
}
$field = $customfield->setModel($this->grid->row);
$this->grid->fieldset(function (Fieldset $fieldset) use($field) {
$fieldset->add($field);
});
$this->grid->rules(array_merge($this->grid->rules, $field->getRules()));
$this->grid->row->saved(function($row) use($field) {
$field->onSave($row);
});
return $this;
}
|
[
"protected",
"function",
"addToForm",
"(",
"CustomField",
"$",
"customfield",
")",
"{",
"if",
"(",
"!",
"$",
"customfield",
"->",
"formAutoDisplay",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"field",
"=",
"$",
"customfield",
"->",
"setModel",
"(",
"$",
"this",
"->",
"grid",
"->",
"row",
")",
";",
"$",
"this",
"->",
"grid",
"->",
"fieldset",
"(",
"function",
"(",
"Fieldset",
"$",
"fieldset",
")",
"use",
"(",
"$",
"field",
")",
"{",
"$",
"fieldset",
"->",
"add",
"(",
"$",
"field",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"grid",
"->",
"rules",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"grid",
"->",
"rules",
",",
"$",
"field",
"->",
"getRules",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"grid",
"->",
"row",
"->",
"saved",
"(",
"function",
"(",
"$",
"row",
")",
"use",
"(",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"onSave",
"(",
"$",
"row",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assigns customfield to form
@param CustomField $customfield
@return $this
|
[
"Assigns",
"customfield",
"to",
"form"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Adapter/CustomfieldAdapter.php#L101-L123
|
228,362
|
lawoole/framework
|
src/Server/Console/ReloadCommand.php
|
ReloadCommand.getServerRuntime
|
protected function getServerRuntime()
{
$filename = $this->option('filename') ?? storage_path('framework/server.runtime');
if (! file_exists($filename)) {
return null;
}
return json_decode(file_get_contents($filename), true);
}
|
php
|
protected function getServerRuntime()
{
$filename = $this->option('filename') ?? storage_path('framework/server.runtime');
if (! file_exists($filename)) {
return null;
}
return json_decode(file_get_contents($filename), true);
}
|
[
"protected",
"function",
"getServerRuntime",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"option",
"(",
"'filename'",
")",
"??",
"storage_path",
"(",
"'framework/server.runtime'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
",",
"true",
")",
";",
"}"
] |
Get the running info.
@return array
|
[
"Get",
"the",
"running",
"info",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Console/ReloadCommand.php#L46-L55
|
228,363
|
antaresproject/core
|
src/components/model/src/UserMeta.php
|
UserMeta.scopeSearch
|
public function scopeSearch(Builder $query, $name, $userId)
{
return $query->where('user_id', '=', $userId)->where('name', '=', $name);
}
|
php
|
public function scopeSearch(Builder $query, $name, $userId)
{
return $query->where('user_id', '=', $userId)->where('name', '=', $name);
}
|
[
"public",
"function",
"scopeSearch",
"(",
"Builder",
"$",
"query",
",",
"$",
"name",
",",
"$",
"userId",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"'user_id'",
",",
"'='",
",",
"$",
"userId",
")",
"->",
"where",
"(",
"'name'",
",",
"'='",
",",
"$",
"name",
")",
";",
"}"
] |
Return a meta data belong to a user.
@param \Illuminate\Database\Eloquent\Builder $query
@param string $name
@param int $userId
@return \Illuminate\Database\Eloquent\Builder
|
[
"Return",
"a",
"meta",
"data",
"belong",
"to",
"a",
"user",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/UserMeta.php#L65-L68
|
228,364
|
antaresproject/core
|
src/components/html/src/HtmlBuilder.php
|
HtmlBuilder.decorate
|
public function decorate(array $attributes, array $defaults = [])
{
$class = $this->buildClassDecorate($attributes, $defaults);
$attributes = array_merge($defaults, $attributes);
empty($class) || $attributes['class'] = $class;
return $attributes;
}
|
php
|
public function decorate(array $attributes, array $defaults = [])
{
$class = $this->buildClassDecorate($attributes, $defaults);
$attributes = array_merge($defaults, $attributes);
empty($class) || $attributes['class'] = $class;
return $attributes;
}
|
[
"public",
"function",
"decorate",
"(",
"array",
"$",
"attributes",
",",
"array",
"$",
"defaults",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"buildClassDecorate",
"(",
"$",
"attributes",
",",
"$",
"defaults",
")",
";",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"attributes",
")",
";",
"empty",
"(",
"$",
"class",
")",
"||",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"class",
";",
"return",
"$",
"attributes",
";",
"}"
] |
Build a list of HTML attributes from one or two array.
@param array $attributes
@param array $defaults
@return array
|
[
"Build",
"a",
"list",
"of",
"HTML",
"attributes",
"from",
"one",
"or",
"two",
"array",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/HtmlBuilder.php#L88-L97
|
228,365
|
antaresproject/core
|
src/components/html/src/HtmlBuilder.php
|
HtmlBuilder.buildClassDecorate
|
protected function buildClassDecorate(array $attributes, array $defaults = [])
{
$default = Arr::get($defaults, 'class', '');
$attribute = Arr::get($attributes, 'class', '');
$classes = explode(' ', trim($default.' '.$attribute));
$current = array_unique($classes);
$excludes = [];
foreach ($current as $c) {
if (Str::startsWith($c, '!')) {
$excludes[] = substr($c, 1);
$excludes[] = $c;
}
}
return implode(' ', array_diff($current, $excludes));
}
|
php
|
protected function buildClassDecorate(array $attributes, array $defaults = [])
{
$default = Arr::get($defaults, 'class', '');
$attribute = Arr::get($attributes, 'class', '');
$classes = explode(' ', trim($default.' '.$attribute));
$current = array_unique($classes);
$excludes = [];
foreach ($current as $c) {
if (Str::startsWith($c, '!')) {
$excludes[] = substr($c, 1);
$excludes[] = $c;
}
}
return implode(' ', array_diff($current, $excludes));
}
|
[
"protected",
"function",
"buildClassDecorate",
"(",
"array",
"$",
"attributes",
",",
"array",
"$",
"defaults",
"=",
"[",
"]",
")",
"{",
"$",
"default",
"=",
"Arr",
"::",
"get",
"(",
"$",
"defaults",
",",
"'class'",
",",
"''",
")",
";",
"$",
"attribute",
"=",
"Arr",
"::",
"get",
"(",
"$",
"attributes",
",",
"'class'",
",",
"''",
")",
";",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"trim",
"(",
"$",
"default",
".",
"' '",
".",
"$",
"attribute",
")",
")",
";",
"$",
"current",
"=",
"array_unique",
"(",
"$",
"classes",
")",
";",
"$",
"excludes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"current",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"c",
",",
"'!'",
")",
")",
"{",
"$",
"excludes",
"[",
"]",
"=",
"substr",
"(",
"$",
"c",
",",
"1",
")",
";",
"$",
"excludes",
"[",
"]",
"=",
"$",
"c",
";",
"}",
"}",
"return",
"implode",
"(",
"' '",
",",
"array_diff",
"(",
"$",
"current",
",",
"$",
"excludes",
")",
")",
";",
"}"
] |
Build class attribute from one or two array.
@param array $attributes
@param array $defaults
@return string
|
[
"Build",
"class",
"attribute",
"from",
"one",
"or",
"two",
"array",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/HtmlBuilder.php#L107-L124
|
228,366
|
antaresproject/core
|
src/components/auth/src/Authorization/AuthorizationTrait.php
|
AuthorizationTrait.groupedAssignAction
|
protected function groupedAssignAction($role, array $actions, $allow = true)
{
foreach ($actions as $action) {
if (!$this->actions->has($action)) {
throw new InvalidArgumentException("Action {$action} does not exist.");
}
$this->assign($role, $action, $allow);
}
return true;
}
|
php
|
protected function groupedAssignAction($role, array $actions, $allow = true)
{
foreach ($actions as $action) {
if (!$this->actions->has($action)) {
throw new InvalidArgumentException("Action {$action} does not exist.");
}
$this->assign($role, $action, $allow);
}
return true;
}
|
[
"protected",
"function",
"groupedAssignAction",
"(",
"$",
"role",
",",
"array",
"$",
"actions",
",",
"$",
"allow",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"actions",
"->",
"has",
"(",
"$",
"action",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Action {$action} does not exist.\"",
")",
";",
"}",
"$",
"this",
"->",
"assign",
"(",
"$",
"role",
",",
"$",
"action",
",",
"$",
"allow",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Grouped assign actions to have access.
@param string $role
@param array $actions
@param bool $allow
@return bool
@throws \InvalidArgumentException
|
[
"Grouped",
"assign",
"actions",
"to",
"have",
"access",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/AuthorizationTrait.php#L126-L137
|
228,367
|
antaresproject/core
|
src/components/memory/resources/database/migrations/2016_11_16_152342_create_tbl_brand_options_table.php
|
CreateTblBrandOptionsTable.setDefaultOptions
|
protected function setDefaultOptions()
{
$areas = array_keys(config('areas.areas'));
$default = config('areas.default');
$configuration = require_once(modules_path('core/brands/resources/config/install.php'));
$countryId = Country::where('code', 'pl')->first()->id;
$languageId = Languages::where('code', 'en')->first()->id;
$dateFormatId = DateFormat::first()->id;
$brandId = Brands::where('default', 1)->first()->id;
$email = require_once(modules_path('core/brands/resources/config/config.php'));
$defaults = [
'brand_id' => $brandId,
'country_id' => $countryId,
'language_id' => $languageId,
'date_format_id' => $dateFormatId,
'maintenance' => 0,
'url' => url('/'),
'header' => array_get($email, 'default.header')->render(),
'styles' => array_get($email, 'default.styles')->render(),
'footer' => array_get($email, 'default.footer')->render()
];
Schema::table('tbl_brand_options', function(Blueprint $table) use($defaults) {
DB::table('tbl_brand_options')->insert($defaults);
});
foreach ($areas as $area) {
$keyname = ($area != $default) ? 'optional' : 'default';
Schema::table('tbl_brand_templates', function(Blueprint $table) use($configuration, $keyname, $area, $brandId) {
$config = array_get($configuration, $keyname);
DB::table('tbl_brand_templates')->insert([
'brand_id' => $brandId,
'area' => $area,
'composition' => array_get($config, 'composition'),
'styleset' => array_get($config, 'styleset'),
'logo' => array_get($config, 'logo'),
'favicon' => array_get($config, 'favicon'),
'colors' => serialize(array_get($config, 'colors')),
]);
});
}
return;
}
|
php
|
protected function setDefaultOptions()
{
$areas = array_keys(config('areas.areas'));
$default = config('areas.default');
$configuration = require_once(modules_path('core/brands/resources/config/install.php'));
$countryId = Country::where('code', 'pl')->first()->id;
$languageId = Languages::where('code', 'en')->first()->id;
$dateFormatId = DateFormat::first()->id;
$brandId = Brands::where('default', 1)->first()->id;
$email = require_once(modules_path('core/brands/resources/config/config.php'));
$defaults = [
'brand_id' => $brandId,
'country_id' => $countryId,
'language_id' => $languageId,
'date_format_id' => $dateFormatId,
'maintenance' => 0,
'url' => url('/'),
'header' => array_get($email, 'default.header')->render(),
'styles' => array_get($email, 'default.styles')->render(),
'footer' => array_get($email, 'default.footer')->render()
];
Schema::table('tbl_brand_options', function(Blueprint $table) use($defaults) {
DB::table('tbl_brand_options')->insert($defaults);
});
foreach ($areas as $area) {
$keyname = ($area != $default) ? 'optional' : 'default';
Schema::table('tbl_brand_templates', function(Blueprint $table) use($configuration, $keyname, $area, $brandId) {
$config = array_get($configuration, $keyname);
DB::table('tbl_brand_templates')->insert([
'brand_id' => $brandId,
'area' => $area,
'composition' => array_get($config, 'composition'),
'styleset' => array_get($config, 'styleset'),
'logo' => array_get($config, 'logo'),
'favicon' => array_get($config, 'favicon'),
'colors' => serialize(array_get($config, 'colors')),
]);
});
}
return;
}
|
[
"protected",
"function",
"setDefaultOptions",
"(",
")",
"{",
"$",
"areas",
"=",
"array_keys",
"(",
"config",
"(",
"'areas.areas'",
")",
")",
";",
"$",
"default",
"=",
"config",
"(",
"'areas.default'",
")",
";",
"$",
"configuration",
"=",
"require_once",
"(",
"modules_path",
"(",
"'core/brands/resources/config/install.php'",
")",
")",
";",
"$",
"countryId",
"=",
"Country",
"::",
"where",
"(",
"'code'",
",",
"'pl'",
")",
"->",
"first",
"(",
")",
"->",
"id",
";",
"$",
"languageId",
"=",
"Languages",
"::",
"where",
"(",
"'code'",
",",
"'en'",
")",
"->",
"first",
"(",
")",
"->",
"id",
";",
"$",
"dateFormatId",
"=",
"DateFormat",
"::",
"first",
"(",
")",
"->",
"id",
";",
"$",
"brandId",
"=",
"Brands",
"::",
"where",
"(",
"'default'",
",",
"1",
")",
"->",
"first",
"(",
")",
"->",
"id",
";",
"$",
"email",
"=",
"require_once",
"(",
"modules_path",
"(",
"'core/brands/resources/config/config.php'",
")",
")",
";",
"$",
"defaults",
"=",
"[",
"'brand_id'",
"=>",
"$",
"brandId",
",",
"'country_id'",
"=>",
"$",
"countryId",
",",
"'language_id'",
"=>",
"$",
"languageId",
",",
"'date_format_id'",
"=>",
"$",
"dateFormatId",
",",
"'maintenance'",
"=>",
"0",
",",
"'url'",
"=>",
"url",
"(",
"'/'",
")",
",",
"'header'",
"=>",
"array_get",
"(",
"$",
"email",
",",
"'default.header'",
")",
"->",
"render",
"(",
")",
",",
"'styles'",
"=>",
"array_get",
"(",
"$",
"email",
",",
"'default.styles'",
")",
"->",
"render",
"(",
")",
",",
"'footer'",
"=>",
"array_get",
"(",
"$",
"email",
",",
"'default.footer'",
")",
"->",
"render",
"(",
")",
"]",
";",
"Schema",
"::",
"table",
"(",
"'tbl_brand_options'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"use",
"(",
"$",
"defaults",
")",
"{",
"DB",
"::",
"table",
"(",
"'tbl_brand_options'",
")",
"->",
"insert",
"(",
"$",
"defaults",
")",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"areas",
"as",
"$",
"area",
")",
"{",
"$",
"keyname",
"=",
"(",
"$",
"area",
"!=",
"$",
"default",
")",
"?",
"'optional'",
":",
"'default'",
";",
"Schema",
"::",
"table",
"(",
"'tbl_brand_templates'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"use",
"(",
"$",
"configuration",
",",
"$",
"keyname",
",",
"$",
"area",
",",
"$",
"brandId",
")",
"{",
"$",
"config",
"=",
"array_get",
"(",
"$",
"configuration",
",",
"$",
"keyname",
")",
";",
"DB",
"::",
"table",
"(",
"'tbl_brand_templates'",
")",
"->",
"insert",
"(",
"[",
"'brand_id'",
"=>",
"$",
"brandId",
",",
"'area'",
"=>",
"$",
"area",
",",
"'composition'",
"=>",
"array_get",
"(",
"$",
"config",
",",
"'composition'",
")",
",",
"'styleset'",
"=>",
"array_get",
"(",
"$",
"config",
",",
"'styleset'",
")",
",",
"'logo'",
"=>",
"array_get",
"(",
"$",
"config",
",",
"'logo'",
")",
",",
"'favicon'",
"=>",
"array_get",
"(",
"$",
"config",
",",
"'favicon'",
")",
",",
"'colors'",
"=>",
"serialize",
"(",
"array_get",
"(",
"$",
"config",
",",
"'colors'",
")",
")",
",",
"]",
")",
";",
"}",
")",
";",
"}",
"return",
";",
"}"
] |
Sets brand default options
@return void
|
[
"Sets",
"brand",
"default",
"options"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/resources/database/migrations/2016_11_16_152342_create_tbl_brand_options_table.php#L81-L127
|
228,368
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/RandomStringUtils.php
|
RandomStringUtils.random
|
public static function random(
$count,
$startPosition = 0,
$endPosition = 0,
$letters = true,
$numbers = true,
array $characters = array()
) {
if (0 === $count) {
return StringUtils::EMPTY_STR;
}
if (0 > $count) {
throw new InvalidArgumentException(
'Requested random string length ' . $count . ' is less than 0.'
);
}
foreach ($characters as $intValue) {
if (false === CharUtils::isAscii($intValue)) {
throw new InvalidArgumentException(
'Requested set of characters does not contain characters only.'
);
}
}
if (false === \is_int($startPosition)) {
$startPosition = CharUtils::fromAsciiCharToValue($startPosition);
}
if (false === \is_int($endPosition)) {
$endPosition = CharUtils::fromAsciiCharToValue($endPosition);
}
if (0 > $startPosition) {
throw new InvalidArgumentException(
'Requested start position ' . $startPosition . ' is less than 0.'
);
}
if (0 > $endPosition) {
throw new InvalidArgumentException(
'Requested end position ' . $endPosition . ' is less than 0.'
);
}
if ((0 === $startPosition) && (0 === $endPosition)) {
$startPosition = 32;
$endPosition = 123;
if ((false === $letters) && (false === $numbers)) {
$characters = \array_values(
\array_diff(
CharUtils::charAsciiPrintableArray(),
CharUtils::charAsciiAlphanumericArray()
)
);
}
}
$charactersUpperBound = (\count($characters) - 1);
$result = '';
while (0 !== $count--) {
if (!$characters) {
$intValue = \rand($startPosition, $endPosition);
} else {
$intValue = CharUtils::fromAsciiCharToValue(
$characters[\rand(0, $charactersUpperBound)]
);
}
$charValue = CharUtils::fromAsciiValueToChar($intValue);
if ((true === $letters) && (true === CharUtils::isAsciiAlpha($charValue))
|| (true === $numbers) && (true === CharUtils::isAsciiNumeric($charValue))
|| (false === $letters) && (false === $numbers)
) {
$result .= $charValue;
} else {
++$count;
}
}
return $result;
}
|
php
|
public static function random(
$count,
$startPosition = 0,
$endPosition = 0,
$letters = true,
$numbers = true,
array $characters = array()
) {
if (0 === $count) {
return StringUtils::EMPTY_STR;
}
if (0 > $count) {
throw new InvalidArgumentException(
'Requested random string length ' . $count . ' is less than 0.'
);
}
foreach ($characters as $intValue) {
if (false === CharUtils::isAscii($intValue)) {
throw new InvalidArgumentException(
'Requested set of characters does not contain characters only.'
);
}
}
if (false === \is_int($startPosition)) {
$startPosition = CharUtils::fromAsciiCharToValue($startPosition);
}
if (false === \is_int($endPosition)) {
$endPosition = CharUtils::fromAsciiCharToValue($endPosition);
}
if (0 > $startPosition) {
throw new InvalidArgumentException(
'Requested start position ' . $startPosition . ' is less than 0.'
);
}
if (0 > $endPosition) {
throw new InvalidArgumentException(
'Requested end position ' . $endPosition . ' is less than 0.'
);
}
if ((0 === $startPosition) && (0 === $endPosition)) {
$startPosition = 32;
$endPosition = 123;
if ((false === $letters) && (false === $numbers)) {
$characters = \array_values(
\array_diff(
CharUtils::charAsciiPrintableArray(),
CharUtils::charAsciiAlphanumericArray()
)
);
}
}
$charactersUpperBound = (\count($characters) - 1);
$result = '';
while (0 !== $count--) {
if (!$characters) {
$intValue = \rand($startPosition, $endPosition);
} else {
$intValue = CharUtils::fromAsciiCharToValue(
$characters[\rand(0, $charactersUpperBound)]
);
}
$charValue = CharUtils::fromAsciiValueToChar($intValue);
if ((true === $letters) && (true === CharUtils::isAsciiAlpha($charValue))
|| (true === $numbers) && (true === CharUtils::isAsciiNumeric($charValue))
|| (false === $letters) && (false === $numbers)
) {
$result .= $charValue;
} else {
++$count;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"random",
"(",
"$",
"count",
",",
"$",
"startPosition",
"=",
"0",
",",
"$",
"endPosition",
"=",
"0",
",",
"$",
"letters",
"=",
"true",
",",
"$",
"numbers",
"=",
"true",
",",
"array",
"$",
"characters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"count",
")",
"{",
"return",
"StringUtils",
"::",
"EMPTY_STR",
";",
"}",
"if",
"(",
"0",
">",
"$",
"count",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Requested random string length '",
".",
"$",
"count",
".",
"' is less than 0.'",
")",
";",
"}",
"foreach",
"(",
"$",
"characters",
"as",
"$",
"intValue",
")",
"{",
"if",
"(",
"false",
"===",
"CharUtils",
"::",
"isAscii",
"(",
"$",
"intValue",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Requested set of characters does not contain characters only.'",
")",
";",
"}",
"}",
"if",
"(",
"false",
"===",
"\\",
"is_int",
"(",
"$",
"startPosition",
")",
")",
"{",
"$",
"startPosition",
"=",
"CharUtils",
"::",
"fromAsciiCharToValue",
"(",
"$",
"startPosition",
")",
";",
"}",
"if",
"(",
"false",
"===",
"\\",
"is_int",
"(",
"$",
"endPosition",
")",
")",
"{",
"$",
"endPosition",
"=",
"CharUtils",
"::",
"fromAsciiCharToValue",
"(",
"$",
"endPosition",
")",
";",
"}",
"if",
"(",
"0",
">",
"$",
"startPosition",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Requested start position '",
".",
"$",
"startPosition",
".",
"' is less than 0.'",
")",
";",
"}",
"if",
"(",
"0",
">",
"$",
"endPosition",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Requested end position '",
".",
"$",
"endPosition",
".",
"' is less than 0.'",
")",
";",
"}",
"if",
"(",
"(",
"0",
"===",
"$",
"startPosition",
")",
"&&",
"(",
"0",
"===",
"$",
"endPosition",
")",
")",
"{",
"$",
"startPosition",
"=",
"32",
";",
"$",
"endPosition",
"=",
"123",
";",
"if",
"(",
"(",
"false",
"===",
"$",
"letters",
")",
"&&",
"(",
"false",
"===",
"$",
"numbers",
")",
")",
"{",
"$",
"characters",
"=",
"\\",
"array_values",
"(",
"\\",
"array_diff",
"(",
"CharUtils",
"::",
"charAsciiPrintableArray",
"(",
")",
",",
"CharUtils",
"::",
"charAsciiAlphanumericArray",
"(",
")",
")",
")",
";",
"}",
"}",
"$",
"charactersUpperBound",
"=",
"(",
"\\",
"count",
"(",
"$",
"characters",
")",
"-",
"1",
")",
";",
"$",
"result",
"=",
"''",
";",
"while",
"(",
"0",
"!==",
"$",
"count",
"--",
")",
"{",
"if",
"(",
"!",
"$",
"characters",
")",
"{",
"$",
"intValue",
"=",
"\\",
"rand",
"(",
"$",
"startPosition",
",",
"$",
"endPosition",
")",
";",
"}",
"else",
"{",
"$",
"intValue",
"=",
"CharUtils",
"::",
"fromAsciiCharToValue",
"(",
"$",
"characters",
"[",
"\\",
"rand",
"(",
"0",
",",
"$",
"charactersUpperBound",
")",
"]",
")",
";",
"}",
"$",
"charValue",
"=",
"CharUtils",
"::",
"fromAsciiValueToChar",
"(",
"$",
"intValue",
")",
";",
"if",
"(",
"(",
"true",
"===",
"$",
"letters",
")",
"&&",
"(",
"true",
"===",
"CharUtils",
"::",
"isAsciiAlpha",
"(",
"$",
"charValue",
")",
")",
"||",
"(",
"true",
"===",
"$",
"numbers",
")",
"&&",
"(",
"true",
"===",
"CharUtils",
"::",
"isAsciiNumeric",
"(",
"$",
"charValue",
")",
")",
"||",
"(",
"false",
"===",
"$",
"letters",
")",
"&&",
"(",
"false",
"===",
"$",
"numbers",
")",
")",
"{",
"$",
"result",
".=",
"$",
"charValue",
";",
"}",
"else",
"{",
"++",
"$",
"count",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Creates a random string based on a variety of options.
If start and end are both `0`, `$startPosition` is set to `' '` and
`$endPosition` is set to `'z'`, the ASCII printable characters, will be
used, unless letters and numbers are both `false`, in which case, all
printable characters are used that are *not* alphanumeric.
If `$characters` is not an empty array, characters will be chosen from
the set of characters specified.
@param integer $count The length of the random string to
create.
@param integer|string $startPosition The position in the set of
characters to start at.
@param integer|string $endPosition The position in the set of
characters to end before.
@param boolean $letters `true` if only letters are allowed.
@param boolean $numbers `true` if only numbers are allowed.
@param array $characters The set of characters to choose
randoms from.
@return string The random string.
@throws InvalidArgumentException If `$count` is less than `0`.
|
[
"Creates",
"a",
"random",
"string",
"based",
"on",
"a",
"variety",
"of",
"options",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/RandomStringUtils.php#L165-L249
|
228,369
|
gggeek/ggwebservices
|
classes/ggsimpletemplatexml.php
|
ggSimpleTemplateXML.toArray
|
function toArray()
{
$out = array ();
$attributes = $this->attribute( 'attributes' );
if ( count( $attributes ) )
{
$out['attributes'] = $attributes;
}
$children = $this->attribute( 'children' );
foreach( $children as $name => $value )
{
if ( is_object( $value ) )
{
$out['children'][$name] = $value->toArray();
}
else if ( is_array( $value ) )
{
foreach( $value as $key => $val )
{
if ( is_object( $val ) )
{
$value[$key] = $val->toArray();
}
}
$out['children'][$name] = $value;
}
else
{
$out['children'][$name] = $value;
}
}
if ( !count( $children ) )
{
$textContent = $this->attribute( 'textContent' );
if ( $textContent != '' )
{
$out['textContent'] = $textContent;
}
}
return $out;
}
|
php
|
function toArray()
{
$out = array ();
$attributes = $this->attribute( 'attributes' );
if ( count( $attributes ) )
{
$out['attributes'] = $attributes;
}
$children = $this->attribute( 'children' );
foreach( $children as $name => $value )
{
if ( is_object( $value ) )
{
$out['children'][$name] = $value->toArray();
}
else if ( is_array( $value ) )
{
foreach( $value as $key => $val )
{
if ( is_object( $val ) )
{
$value[$key] = $val->toArray();
}
}
$out['children'][$name] = $value;
}
else
{
$out['children'][$name] = $value;
}
}
if ( !count( $children ) )
{
$textContent = $this->attribute( 'textContent' );
if ( $textContent != '' )
{
$out['textContent'] = $textContent;
}
}
return $out;
}
|
[
"function",
"toArray",
"(",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'attributes'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"out",
"[",
"'attributes'",
"]",
"=",
"$",
"attributes",
";",
"}",
"$",
"children",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'children'",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"out",
"[",
"'children'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
"->",
"toArray",
"(",
")",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"val",
")",
")",
"{",
"$",
"value",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"$",
"out",
"[",
"'children'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"out",
"[",
"'children'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"!",
"count",
"(",
"$",
"children",
")",
")",
"{",
"$",
"textContent",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'textContent'",
")",
";",
"if",
"(",
"$",
"textContent",
"!=",
"''",
")",
"{",
"$",
"out",
"[",
"'textContent'",
"]",
"=",
"$",
"textContent",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] |
Try a useful conversion to an array structure. Useful for eg. dump calls
|
[
"Try",
"a",
"useful",
"conversion",
"to",
"an",
"array",
"structure",
".",
"Useful",
"for",
"eg",
".",
"dump",
"calls"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggsimpletemplatexml.php#L157-L201
|
228,370
|
gggeek/ggwebservices
|
classes/ggsimpletemplatexml.php
|
ggSimpleTemplateXML.domNode2STX
|
protected static function domNode2STX( $node )
{
if ( $node->hasAttributes() )
{
return new ggSimpleTemplateXML( $node );
}
foreach( $node->childNodes as $childNode )
{
if ( $childNode->nodeType == XML_ELEMENT_NODE )
{
return new ggSimpleTemplateXML( $node );
}
}
return $node->textContent;
}
|
php
|
protected static function domNode2STX( $node )
{
if ( $node->hasAttributes() )
{
return new ggSimpleTemplateXML( $node );
}
foreach( $node->childNodes as $childNode )
{
if ( $childNode->nodeType == XML_ELEMENT_NODE )
{
return new ggSimpleTemplateXML( $node );
}
}
return $node->textContent;
}
|
[
"protected",
"static",
"function",
"domNode2STX",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"hasAttributes",
"(",
")",
")",
"{",
"return",
"new",
"ggSimpleTemplateXML",
"(",
"$",
"node",
")",
";",
"}",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"childNode",
")",
"{",
"if",
"(",
"$",
"childNode",
"->",
"nodeType",
"==",
"XML_ELEMENT_NODE",
")",
"{",
"return",
"new",
"ggSimpleTemplateXML",
"(",
"$",
"node",
")",
";",
"}",
"}",
"return",
"$",
"node",
"->",
"textContent",
";",
"}"
] |
Returns either a ggSimpleTemplateXML wrapping a dom element or a string,
based on whether the element has any attribute or child or none
|
[
"Returns",
"either",
"a",
"ggSimpleTemplateXML",
"wrapping",
"a",
"dom",
"element",
"or",
"a",
"string",
"based",
"on",
"whether",
"the",
"element",
"has",
"any",
"attribute",
"or",
"child",
"or",
"none"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggsimpletemplatexml.php#L215-L229
|
228,371
|
akramfares/rundeck-sdk-php
|
src/Resources/Project.php
|
Project.resource
|
public function resource($name, $alt = "xml")
{
$response = $this->client->get('/project/'.$this->name. '/resource/' .$name, $alt);
return $response;
}
|
php
|
public function resource($name, $alt = "xml")
{
$response = $this->client->get('/project/'.$this->name. '/resource/' .$name, $alt);
return $response;
}
|
[
"public",
"function",
"resource",
"(",
"$",
"name",
",",
"$",
"alt",
"=",
"\"xml\"",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"'/project/'",
".",
"$",
"this",
"->",
"name",
".",
"'/resource/'",
".",
"$",
"name",
",",
"$",
"alt",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Get project resource
@param $name
@param string $alt xml|json
@return array
|
[
"Get",
"project",
"resource"
] |
6a806c2830787b875dc8033e5c6883cbcb4b5abd
|
https://github.com/akramfares/rundeck-sdk-php/blob/6a806c2830787b875dc8033e5c6883cbcb4b5abd/src/Resources/Project.php#L65-L69
|
228,372
|
antaresproject/core
|
src/utils/asset/src/Factory.php
|
Factory.scriptsByParams
|
public function scriptsByParams(array $params = array())
{
if (!isset($params['resources']) or ! isset($params['position'])) {
return $this;
}
if (empty($params['resources'])) {
return $this;
}
$container = $this->container($params['position']);
foreach ($params['resources'] as $name => $path) {
$container->add($name, $path);
}
return $this;
}
|
php
|
public function scriptsByParams(array $params = array())
{
if (!isset($params['resources']) or ! isset($params['position'])) {
return $this;
}
if (empty($params['resources'])) {
return $this;
}
$container = $this->container($params['position']);
foreach ($params['resources'] as $name => $path) {
$container->add($name, $path);
}
return $this;
}
|
[
"public",
"function",
"scriptsByParams",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'resources'",
"]",
")",
"or",
"!",
"isset",
"(",
"$",
"params",
"[",
"'position'",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'resources'",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"container",
"=",
"$",
"this",
"->",
"container",
"(",
"$",
"params",
"[",
"'position'",
"]",
")",
";",
"foreach",
"(",
"$",
"params",
"[",
"'resources'",
"]",
"as",
"$",
"name",
"=>",
"$",
"path",
")",
"{",
"$",
"container",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
add scripts from params
@param array $params
@return \Antares\Asset\Factory
|
[
"add",
"scripts",
"from",
"params"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/Factory.php#L121-L135
|
228,373
|
lawoole/framework
|
src/Homer/Transport/ClientFactory.php
|
ClientFactory.client
|
public function client(array $config)
{
$key = $this->getClientKey($config);
if (isset($this->clients[$key])) {
return $this->clients[$key];
}
return $this->clients[$key] = $this->createClient($config);
}
|
php
|
public function client(array $config)
{
$key = $this->getClientKey($config);
if (isset($this->clients[$key])) {
return $this->clients[$key];
}
return $this->clients[$key] = $this->createClient($config);
}
|
[
"public",
"function",
"client",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getClientKey",
"(",
"$",
"config",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"clients",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"clients",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"clients",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"createClient",
"(",
"$",
"config",
")",
";",
"}"
] |
Get client instance.
@param array $config
@return \Lawoole\Homer\Transport\Client
|
[
"Get",
"client",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Transport/ClientFactory.php#L53-L62
|
228,374
|
lawoole/framework
|
src/Homer/Transport/ClientFactory.php
|
ClientFactory.createClient
|
protected function createClient(array $config)
{
$url = Arr::pull($config, 'url');
$urls = parse_url($url);
$config['host'] = $urls['host'];
$config['port'] = $urls['port'];
switch ($urls['scheme']) {
case 'http':
return new HttpClient($this->app, $this->serializerFactory, $config);
case 'whisper':
return new WhisperClient($this->app, $this->serializerFactory, $config);
default:
throw new InvalidArgumentException('Protocol '.$urls['scheme'].' is not supported for Homer.');
}
}
|
php
|
protected function createClient(array $config)
{
$url = Arr::pull($config, 'url');
$urls = parse_url($url);
$config['host'] = $urls['host'];
$config['port'] = $urls['port'];
switch ($urls['scheme']) {
case 'http':
return new HttpClient($this->app, $this->serializerFactory, $config);
case 'whisper':
return new WhisperClient($this->app, $this->serializerFactory, $config);
default:
throw new InvalidArgumentException('Protocol '.$urls['scheme'].' is not supported for Homer.');
}
}
|
[
"protected",
"function",
"createClient",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"url",
"=",
"Arr",
"::",
"pull",
"(",
"$",
"config",
",",
"'url'",
")",
";",
"$",
"urls",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"config",
"[",
"'host'",
"]",
"=",
"$",
"urls",
"[",
"'host'",
"]",
";",
"$",
"config",
"[",
"'port'",
"]",
"=",
"$",
"urls",
"[",
"'port'",
"]",
";",
"switch",
"(",
"$",
"urls",
"[",
"'scheme'",
"]",
")",
"{",
"case",
"'http'",
":",
"return",
"new",
"HttpClient",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"this",
"->",
"serializerFactory",
",",
"$",
"config",
")",
";",
"case",
"'whisper'",
":",
"return",
"new",
"WhisperClient",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"this",
"->",
"serializerFactory",
",",
"$",
"config",
")",
";",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Protocol '",
".",
"$",
"urls",
"[",
"'scheme'",
"]",
".",
"' is not supported for Homer.'",
")",
";",
"}",
"}"
] |
Create the client instance.
@param array $config
@return \Lawoole\Homer\Transport\Client
|
[
"Create",
"the",
"client",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Transport/ClientFactory.php#L71-L88
|
228,375
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.proxy
|
public function proxy(Invoker $invoker)
{
$interface = $invoker->getInterface();
$className = $this->generateClassName($interface);
$code = $this->populateStub($this->getStub(), $className, $interface);
$this->load($className, $code);
return $this->createProxyInstance($className, $interface, $invoker);
}
|
php
|
public function proxy(Invoker $invoker)
{
$interface = $invoker->getInterface();
$className = $this->generateClassName($interface);
$code = $this->populateStub($this->getStub(), $className, $interface);
$this->load($className, $code);
return $this->createProxyInstance($className, $interface, $invoker);
}
|
[
"public",
"function",
"proxy",
"(",
"Invoker",
"$",
"invoker",
")",
"{",
"$",
"interface",
"=",
"$",
"invoker",
"->",
"getInterface",
"(",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"generateClassName",
"(",
"$",
"interface",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"populateStub",
"(",
"$",
"this",
"->",
"getStub",
"(",
")",
",",
"$",
"className",
",",
"$",
"interface",
")",
";",
"$",
"this",
"->",
"load",
"(",
"$",
"className",
",",
"$",
"code",
")",
";",
"return",
"$",
"this",
"->",
"createProxyInstance",
"(",
"$",
"className",
",",
"$",
"interface",
",",
"$",
"invoker",
")",
";",
"}"
] |
Get a invoking proxy instance.
@param \Lawoole\Homer\Calling\Invokers\Invoker $invoker
@return mixed
|
[
"Get",
"a",
"invoking",
"proxy",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L27-L38
|
228,376
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.createProxyInstance
|
protected function createProxyInstance($className, $interface, Invoker $invoker)
{
$className = $this->getFullClassName($className);
return new $className($interface, $invoker);
}
|
php
|
protected function createProxyInstance($className, $interface, Invoker $invoker)
{
$className = $this->getFullClassName($className);
return new $className($interface, $invoker);
}
|
[
"protected",
"function",
"createProxyInstance",
"(",
"$",
"className",
",",
"$",
"interface",
",",
"Invoker",
"$",
"invoker",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"getFullClassName",
"(",
"$",
"className",
")",
";",
"return",
"new",
"$",
"className",
"(",
"$",
"interface",
",",
"$",
"invoker",
")",
";",
"}"
] |
Create a invoking proxy instance.
@param string $className
@param string $interface
@param \Lawoole\Homer\Calling\Invokers\Invoker $invoker
@return mixed
|
[
"Create",
"a",
"invoking",
"proxy",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L49-L54
|
228,377
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.load
|
protected function load($className, $code)
{
if (class_exists($this->getFullClassName($className), false)) {
return;
}
eval('?>'.$code);
}
|
php
|
protected function load($className, $code)
{
if (class_exists($this->getFullClassName($className), false)) {
return;
}
eval('?>'.$code);
}
|
[
"protected",
"function",
"load",
"(",
"$",
"className",
",",
"$",
"code",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"this",
"->",
"getFullClassName",
"(",
"$",
"className",
")",
",",
"false",
")",
")",
"{",
"return",
";",
"}",
"eval",
"(",
"'?>'",
".",
"$",
"code",
")",
";",
"}"
] |
Load the proxy class.
@param string $className
@param string $code
|
[
"Load",
"the",
"proxy",
"class",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L62-L69
|
228,378
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.populateStub
|
protected function populateStub($stub, $className, $interface)
{
$stub = str_replace('ProxyClass', $className, $stub);
$stub = str_replace('ProxyInterface', '\\'.$interface, $stub);
$stub = str_replace('// ## Implemented Methods ##', $this->getMethodDefinitions($interface), $stub);
return $stub;
}
|
php
|
protected function populateStub($stub, $className, $interface)
{
$stub = str_replace('ProxyClass', $className, $stub);
$stub = str_replace('ProxyInterface', '\\'.$interface, $stub);
$stub = str_replace('// ## Implemented Methods ##', $this->getMethodDefinitions($interface), $stub);
return $stub;
}
|
[
"protected",
"function",
"populateStub",
"(",
"$",
"stub",
",",
"$",
"className",
",",
"$",
"interface",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"'ProxyClass'",
",",
"$",
"className",
",",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'ProxyInterface'",
",",
"'\\\\'",
".",
"$",
"interface",
",",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'// ## Implemented Methods ##'",
",",
"$",
"this",
"->",
"getMethodDefinitions",
"(",
"$",
"interface",
")",
",",
"$",
"stub",
")",
";",
"return",
"$",
"stub",
";",
"}"
] |
Populate the place-holders in the proxy stub.
@param string $stub
@param string $className
@param string $interface
@return string
|
[
"Populate",
"the",
"place",
"-",
"holders",
"in",
"the",
"proxy",
"stub",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L92-L100
|
228,379
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.getMethodDefinitions
|
protected function getMethodDefinitions($interface)
{
$definitions = [];
try {
$reflection = new ReflectionClass($interface);
if (! $reflection->isInterface()) {
throw new InvalidArgumentException("{$interface} must be an interface.");
}
foreach ($reflection->getMethods() as $method) {
$definition = 'public function ';
$definition .= $method->getName();
$definition .= $this->renderMethodParameters($method);
$definition .= $this->renderMethodReturnType($method);
$definition .= $this->renderMethodBody($method);
$definitions[] = $definition;
}
} catch (Throwable $e) {
Log::channel('homer')->warning("Reflect {$interface} failed.", [
'exception' => $e,
]);
throw $e;
}
return implode("\n\n", $definitions);
}
|
php
|
protected function getMethodDefinitions($interface)
{
$definitions = [];
try {
$reflection = new ReflectionClass($interface);
if (! $reflection->isInterface()) {
throw new InvalidArgumentException("{$interface} must be an interface.");
}
foreach ($reflection->getMethods() as $method) {
$definition = 'public function ';
$definition .= $method->getName();
$definition .= $this->renderMethodParameters($method);
$definition .= $this->renderMethodReturnType($method);
$definition .= $this->renderMethodBody($method);
$definitions[] = $definition;
}
} catch (Throwable $e) {
Log::channel('homer')->warning("Reflect {$interface} failed.", [
'exception' => $e,
]);
throw $e;
}
return implode("\n\n", $definitions);
}
|
[
"protected",
"function",
"getMethodDefinitions",
"(",
"$",
"interface",
")",
"{",
"$",
"definitions",
"=",
"[",
"]",
";",
"try",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"interface",
")",
";",
"if",
"(",
"!",
"$",
"reflection",
"->",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"{$interface} must be an interface.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"reflection",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"definition",
"=",
"'public function '",
";",
"$",
"definition",
".=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"$",
"definition",
".=",
"$",
"this",
"->",
"renderMethodParameters",
"(",
"$",
"method",
")",
";",
"$",
"definition",
".=",
"$",
"this",
"->",
"renderMethodReturnType",
"(",
"$",
"method",
")",
";",
"$",
"definition",
".=",
"$",
"this",
"->",
"renderMethodBody",
"(",
"$",
"method",
")",
";",
"$",
"definitions",
"[",
"]",
"=",
"$",
"definition",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"Log",
"::",
"channel",
"(",
"'homer'",
")",
"->",
"warning",
"(",
"\"Reflect {$interface} failed.\"",
",",
"[",
"'exception'",
"=>",
"$",
"e",
",",
"]",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"implode",
"(",
"\"\\n\\n\"",
",",
"$",
"definitions",
")",
";",
"}"
] |
Get interface's method definitions.
@param string $interface
@return string
|
[
"Get",
"interface",
"s",
"method",
"definitions",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L109-L139
|
228,380
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.renderMethodParameters
|
protected function renderMethodParameters($method)
{
$parameters = [];
foreach ($method->getParameters() as $parameter) {
if ($parameter->isPassedByReference()) {
throw new InvalidArgumentException(sprintf(
'Parameter [%s] in %s->%s cannot declared as a reference.',
$parameter->getName(), $method->getDeclaringClass(), $method->getName()
));
}
$definition = $this->renderParameterTypeHint($parameter);
$definition .= $parameter->isVariadic() ? '...' : '';
$definition .= '$'.$parameter->getName();
if (! $parameter->isVariadic()) {
if ($parameter->isDefaultValueAvailable()) {
$definition .= ' = '.var_export($parameter->getDefaultValue(), true);
} elseif ($parameter->isOptional()) {
$definition .= ' = null';
}
}
$parameters[] = $definition;
}
return '('.implode(', ', $parameters).')';
}
|
php
|
protected function renderMethodParameters($method)
{
$parameters = [];
foreach ($method->getParameters() as $parameter) {
if ($parameter->isPassedByReference()) {
throw new InvalidArgumentException(sprintf(
'Parameter [%s] in %s->%s cannot declared as a reference.',
$parameter->getName(), $method->getDeclaringClass(), $method->getName()
));
}
$definition = $this->renderParameterTypeHint($parameter);
$definition .= $parameter->isVariadic() ? '...' : '';
$definition .= '$'.$parameter->getName();
if (! $parameter->isVariadic()) {
if ($parameter->isDefaultValueAvailable()) {
$definition .= ' = '.var_export($parameter->getDefaultValue(), true);
} elseif ($parameter->isOptional()) {
$definition .= ' = null';
}
}
$parameters[] = $definition;
}
return '('.implode(', ', $parameters).')';
}
|
[
"protected",
"function",
"renderMethodParameters",
"(",
"$",
"method",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"parameter",
"->",
"isPassedByReference",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Parameter [%s] in %s->%s cannot declared as a reference.'",
",",
"$",
"parameter",
"->",
"getName",
"(",
")",
",",
"$",
"method",
"->",
"getDeclaringClass",
"(",
")",
",",
"$",
"method",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"definition",
"=",
"$",
"this",
"->",
"renderParameterTypeHint",
"(",
"$",
"parameter",
")",
";",
"$",
"definition",
".=",
"$",
"parameter",
"->",
"isVariadic",
"(",
")",
"?",
"'...'",
":",
"''",
";",
"$",
"definition",
".=",
"'$'",
".",
"$",
"parameter",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parameter",
"->",
"isVariadic",
"(",
")",
")",
"{",
"if",
"(",
"$",
"parameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"definition",
".=",
"' = '",
".",
"var_export",
"(",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"$",
"parameter",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"definition",
".=",
"' = null'",
";",
"}",
"}",
"$",
"parameters",
"[",
"]",
"=",
"$",
"definition",
";",
"}",
"return",
"'('",
".",
"implode",
"(",
"', '",
",",
"$",
"parameters",
")",
".",
"')'",
";",
"}"
] |
Render method parameters definition.
@param \ReflectionMethod $method
@return string
|
[
"Render",
"method",
"parameters",
"definition",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L148-L176
|
228,381
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.renderParameterTypeHint
|
protected function renderParameterTypeHint($parameter)
{
$typeHint = $parameter->hasType() ? (string) $parameter->getType() : '';
$typeHint = trim($typeHint);
if ($typeHint) {
// If the type is not a built in types, we should add a leading slash
// in the type hint be make the class name not confusing.
if (
! in_array($typeHint, [
'self', 'array', 'callable', 'bool', 'float', 'int', 'string',
'object', 'iterable', 'void'
])
) {
$typeHint = '\\'.$typeHint;
}
if ($parameter->allowsNull()) {
$typeHint = '?'.$typeHint;
}
$typeHint .= ' ';
}
return $typeHint;
}
|
php
|
protected function renderParameterTypeHint($parameter)
{
$typeHint = $parameter->hasType() ? (string) $parameter->getType() : '';
$typeHint = trim($typeHint);
if ($typeHint) {
// If the type is not a built in types, we should add a leading slash
// in the type hint be make the class name not confusing.
if (
! in_array($typeHint, [
'self', 'array', 'callable', 'bool', 'float', 'int', 'string',
'object', 'iterable', 'void'
])
) {
$typeHint = '\\'.$typeHint;
}
if ($parameter->allowsNull()) {
$typeHint = '?'.$typeHint;
}
$typeHint .= ' ';
}
return $typeHint;
}
|
[
"protected",
"function",
"renderParameterTypeHint",
"(",
"$",
"parameter",
")",
"{",
"$",
"typeHint",
"=",
"$",
"parameter",
"->",
"hasType",
"(",
")",
"?",
"(",
"string",
")",
"$",
"parameter",
"->",
"getType",
"(",
")",
":",
"''",
";",
"$",
"typeHint",
"=",
"trim",
"(",
"$",
"typeHint",
")",
";",
"if",
"(",
"$",
"typeHint",
")",
"{",
"// If the type is not a built in types, we should add a leading slash",
"// in the type hint be make the class name not confusing.",
"if",
"(",
"!",
"in_array",
"(",
"$",
"typeHint",
",",
"[",
"'self'",
",",
"'array'",
",",
"'callable'",
",",
"'bool'",
",",
"'float'",
",",
"'int'",
",",
"'string'",
",",
"'object'",
",",
"'iterable'",
",",
"'void'",
"]",
")",
")",
"{",
"$",
"typeHint",
"=",
"'\\\\'",
".",
"$",
"typeHint",
";",
"}",
"if",
"(",
"$",
"parameter",
"->",
"allowsNull",
"(",
")",
")",
"{",
"$",
"typeHint",
"=",
"'?'",
".",
"$",
"typeHint",
";",
"}",
"$",
"typeHint",
".=",
"' '",
";",
"}",
"return",
"$",
"typeHint",
";",
"}"
] |
Render method parameter's type hint.
@param \ReflectionParameter $parameter
@return string
|
[
"Render",
"method",
"parameter",
"s",
"type",
"hint",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L185-L211
|
228,382
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.renderMethodBody
|
protected function renderMethodBody($method)
{
$body = '{';
$body .= '$arguments = func_get_args();';
$body .= '$result = $this->__call(__FUNCTION__, $arguments);';
if ($method->getReturnType() !== 'void') {
$body .= 'return $result;';
}
$body .= '}';
return $body;
}
|
php
|
protected function renderMethodBody($method)
{
$body = '{';
$body .= '$arguments = func_get_args();';
$body .= '$result = $this->__call(__FUNCTION__, $arguments);';
if ($method->getReturnType() !== 'void') {
$body .= 'return $result;';
}
$body .= '}';
return $body;
}
|
[
"protected",
"function",
"renderMethodBody",
"(",
"$",
"method",
")",
"{",
"$",
"body",
"=",
"'{'",
";",
"$",
"body",
".=",
"'$arguments = func_get_args();'",
";",
"$",
"body",
".=",
"'$result = $this->__call(__FUNCTION__, $arguments);'",
";",
"if",
"(",
"$",
"method",
"->",
"getReturnType",
"(",
")",
"!==",
"'void'",
")",
"{",
"$",
"body",
".=",
"'return $result;'",
";",
"}",
"$",
"body",
".=",
"'}'",
";",
"return",
"$",
"body",
";",
"}"
] |
Render method body definition.
@param string $method
@return string
|
[
"Render",
"method",
"body",
"definition",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L234-L247
|
228,383
|
lawoole/framework
|
src/Homer/Calling/ProxyFactory.php
|
ProxyFactory.getStub
|
protected function getStub()
{
if ($this->proxyStub == null) {
$this->proxyStub = file_get_contents($this->stubPath().'/proxy.stub');
}
return $this->proxyStub;
}
|
php
|
protected function getStub()
{
if ($this->proxyStub == null) {
$this->proxyStub = file_get_contents($this->stubPath().'/proxy.stub');
}
return $this->proxyStub;
}
|
[
"protected",
"function",
"getStub",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyStub",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"proxyStub",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"stubPath",
"(",
")",
".",
"'/proxy.stub'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyStub",
";",
"}"
] |
Get the proxy stub file.
@return string
|
[
"Get",
"the",
"proxy",
"stub",
"file",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/ProxyFactory.php#L266-L273
|
228,384
|
antaresproject/core
|
src/components/kernel/src/Http/RouteManager.php
|
RouteManager.sandbox
|
protected function sandbox(&$locate, UrlGenerator $url, array $options = [])
{
$sandbox = (isset($options['sandbox']) && $options['sandbox'] == false) ? null : $url->getRequest()->query('sandbox');
if (!is_null($sandbox)) {
$separator = (parse_url($locate, PHP_URL_QUERY) == NULL) ? '?' : '&';
$locate .= $separator . 'sandbox=' . $sandbox;
}
return $locate;
}
|
php
|
protected function sandbox(&$locate, UrlGenerator $url, array $options = [])
{
$sandbox = (isset($options['sandbox']) && $options['sandbox'] == false) ? null : $url->getRequest()->query('sandbox');
if (!is_null($sandbox)) {
$separator = (parse_url($locate, PHP_URL_QUERY) == NULL) ? '?' : '&';
$locate .= $separator . 'sandbox=' . $sandbox;
}
return $locate;
}
|
[
"protected",
"function",
"sandbox",
"(",
"&",
"$",
"locate",
",",
"UrlGenerator",
"$",
"url",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"sandbox",
"=",
"(",
"isset",
"(",
"$",
"options",
"[",
"'sandbox'",
"]",
")",
"&&",
"$",
"options",
"[",
"'sandbox'",
"]",
"==",
"false",
")",
"?",
"null",
":",
"$",
"url",
"->",
"getRequest",
"(",
")",
"->",
"query",
"(",
"'sandbox'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"sandbox",
")",
")",
"{",
"$",
"separator",
"=",
"(",
"parse_url",
"(",
"$",
"locate",
",",
"PHP_URL_QUERY",
")",
"==",
"NULL",
")",
"?",
"'?'",
":",
"'&'",
";",
"$",
"locate",
".=",
"$",
"separator",
".",
"'sandbox='",
".",
"$",
"sandbox",
";",
"}",
"return",
"$",
"locate",
";",
"}"
] |
Creates url with sandbox param
@param String $locate
@param UrlGenerator $url
@param array $options
@return String
|
[
"Creates",
"url",
"with",
"sandbox",
"param"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/kernel/src/Http/RouteManager.php#L153-L161
|
228,385
|
antaresproject/core
|
src/components/html/src/Form/Control.php
|
Control.generate
|
public function generate($type)
{
return function ($row, $control, $templates = []) use ($type) {
$data = $this->buildFieldByType($type, $row, $control);
return $this->render($templates, $data);
};
}
|
php
|
public function generate($type)
{
return function ($row, $control, $templates = []) use ($type) {
$data = $this->buildFieldByType($type, $row, $control);
return $this->render($templates, $data);
};
}
|
[
"public",
"function",
"generate",
"(",
"$",
"type",
")",
"{",
"return",
"function",
"(",
"$",
"row",
",",
"$",
"control",
",",
"$",
"templates",
"=",
"[",
"]",
")",
"use",
"(",
"$",
"type",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"buildFieldByType",
"(",
"$",
"type",
",",
"$",
"row",
",",
"$",
"control",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"templates",
",",
"$",
"data",
")",
";",
"}",
";",
"}"
] |
Generate Field.
@param string $type
@return \Closure
|
[
"Generate",
"Field",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Control.php#L142-L148
|
228,386
|
lawoole/framework
|
src/Snowflake/Snowflake.php
|
Snowflake.nextId
|
public function nextId()
{
$timestamp = time() - static::BASE_TIME;
if ($this->lastTimestamp >= $timestamp) {
$timestamp = $this->lastTimestamp;
$sequence = ++ $this->sequence;
if ($sequence > 0x7ff) {
$this->lastTimestamp = ++ $timestamp;
$sequence = $this->sequence = 0;
}
} else {
$this->lastTimestamp = $timestamp;
$sequence = $this->sequence = 0;
}
return ($timestamp << 32) | $this->mask | ($sequence & 0x7ff);
}
|
php
|
public function nextId()
{
$timestamp = time() - static::BASE_TIME;
if ($this->lastTimestamp >= $timestamp) {
$timestamp = $this->lastTimestamp;
$sequence = ++ $this->sequence;
if ($sequence > 0x7ff) {
$this->lastTimestamp = ++ $timestamp;
$sequence = $this->sequence = 0;
}
} else {
$this->lastTimestamp = $timestamp;
$sequence = $this->sequence = 0;
}
return ($timestamp << 32) | $this->mask | ($sequence & 0x7ff);
}
|
[
"public",
"function",
"nextId",
"(",
")",
"{",
"$",
"timestamp",
"=",
"time",
"(",
")",
"-",
"static",
"::",
"BASE_TIME",
";",
"if",
"(",
"$",
"this",
"->",
"lastTimestamp",
">=",
"$",
"timestamp",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"lastTimestamp",
";",
"$",
"sequence",
"=",
"++",
"$",
"this",
"->",
"sequence",
";",
"if",
"(",
"$",
"sequence",
">",
"0x7ff",
")",
"{",
"$",
"this",
"->",
"lastTimestamp",
"=",
"++",
"$",
"timestamp",
";",
"$",
"sequence",
"=",
"$",
"this",
"->",
"sequence",
"=",
"0",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"lastTimestamp",
"=",
"$",
"timestamp",
";",
"$",
"sequence",
"=",
"$",
"this",
"->",
"sequence",
"=",
"0",
";",
"}",
"return",
"(",
"$",
"timestamp",
"<<",
"32",
")",
"|",
"$",
"this",
"->",
"mask",
"|",
"(",
"$",
"sequence",
"&",
"0x7ff",
")",
";",
"}"
] |
Generate a new snowflake id.
@return string
|
[
"Generate",
"a",
"new",
"snowflake",
"id",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Snowflake/Snowflake.php#L119-L140
|
228,387
|
antaresproject/core
|
src/components/memory/src/Handler.php
|
Handler.generateNewChecksum
|
protected function generateNewChecksum($value)
{
!is_string($value) && $value = (is_object($value) ? spl_object_hash($value) : serialize($value));
return md5($value);
}
|
php
|
protected function generateNewChecksum($value)
{
!is_string($value) && $value = (is_object($value) ? spl_object_hash($value) : serialize($value));
return md5($value);
}
|
[
"protected",
"function",
"generateNewChecksum",
"(",
"$",
"value",
")",
"{",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"=",
"(",
"is_object",
"(",
"$",
"value",
")",
"?",
"spl_object_hash",
"(",
"$",
"value",
")",
":",
"serialize",
"(",
"$",
"value",
")",
")",
";",
"return",
"md5",
"(",
"$",
"value",
")",
";",
"}"
] |
Generate a checksum from given value.
@param mixed $value
@return string
|
[
"Generate",
"a",
"checksum",
"from",
"given",
"value",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Handler.php#L129-L134
|
228,388
|
antaresproject/core
|
src/components/memory/src/Handler.php
|
Handler.forgetCache
|
public function forgetCache()
{
return !is_null($this->cache) ? $this->cache->forget($this->cacheKey) : true;
}
|
php
|
public function forgetCache()
{
return !is_null($this->cache) ? $this->cache->forget($this->cacheKey) : true;
}
|
[
"public",
"function",
"forgetCache",
"(",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"this",
"->",
"cache",
")",
"?",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"cacheKey",
")",
":",
"true",
";",
"}"
] |
force forgetting cache each driver
@return mixed
|
[
"force",
"forgetting",
"cache",
"each",
"driver"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Handler.php#L185-L188
|
228,389
|
lawoole/framework
|
src/Homer/Calling/Dispatcher.php
|
Dispatcher.exportInvoker
|
public function exportInvoker(Invoker $invoker)
{
$interface = $invoker->getInterface();
if (isset($this->invokers[$interface])) {
return;
}
Log::channel('homer')->info("Service {$interface} has been exported.");
$this->invokers[$interface] = $invoker;
}
|
php
|
public function exportInvoker(Invoker $invoker)
{
$interface = $invoker->getInterface();
if (isset($this->invokers[$interface])) {
return;
}
Log::channel('homer')->info("Service {$interface} has been exported.");
$this->invokers[$interface] = $invoker;
}
|
[
"public",
"function",
"exportInvoker",
"(",
"Invoker",
"$",
"invoker",
")",
"{",
"$",
"interface",
"=",
"$",
"invoker",
"->",
"getInterface",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"invokers",
"[",
"$",
"interface",
"]",
")",
")",
"{",
"return",
";",
"}",
"Log",
"::",
"channel",
"(",
"'homer'",
")",
"->",
"info",
"(",
"\"Service {$interface} has been exported.\"",
")",
";",
"$",
"this",
"->",
"invokers",
"[",
"$",
"interface",
"]",
"=",
"$",
"invoker",
";",
"}"
] |
Export the invoker.
@param \Lawoole\Homer\Calling\Invokers\Invoker $invoker
|
[
"Export",
"the",
"invoker",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Dispatcher.php#L23-L34
|
228,390
|
lawoole/framework
|
src/Homer/Calling/Dispatcher.php
|
Dispatcher.handleMessage
|
public function handleMessage($message)
{
try {
if ($message instanceof Invocation) {
return $this->handleInvocation($message);
}
return $message;
} catch (HomerException $e) {
throw $e;
} catch (Throwable $e) {
Log::channel('homer')->warning($e->getMessage(), [
'exception' => $e
]);
throw $e;
}
}
|
php
|
public function handleMessage($message)
{
try {
if ($message instanceof Invocation) {
return $this->handleInvocation($message);
}
return $message;
} catch (HomerException $e) {
throw $e;
} catch (Throwable $e) {
Log::channel('homer')->warning($e->getMessage(), [
'exception' => $e
]);
throw $e;
}
}
|
[
"public",
"function",
"handleMessage",
"(",
"$",
"message",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"message",
"instanceof",
"Invocation",
")",
"{",
"return",
"$",
"this",
"->",
"handleInvocation",
"(",
"$",
"message",
")",
";",
"}",
"return",
"$",
"message",
";",
"}",
"catch",
"(",
"HomerException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"Log",
"::",
"channel",
"(",
"'homer'",
")",
"->",
"warning",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"[",
"'exception'",
"=>",
"$",
"e",
"]",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Handler the invoking request.
@param mixed $message
@return mixed
|
[
"Handler",
"the",
"invoking",
"request",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Dispatcher.php#L43-L60
|
228,391
|
lawoole/framework
|
src/Homer/Calling/Dispatcher.php
|
Dispatcher.handleInvocation
|
protected function handleInvocation(Invocation $invocation)
{
$invoker = $this->dispatchInvocation($invocation);
return $invoker->invoke($invocation);
}
|
php
|
protected function handleInvocation(Invocation $invocation)
{
$invoker = $this->dispatchInvocation($invocation);
return $invoker->invoke($invocation);
}
|
[
"protected",
"function",
"handleInvocation",
"(",
"Invocation",
"$",
"invocation",
")",
"{",
"$",
"invoker",
"=",
"$",
"this",
"->",
"dispatchInvocation",
"(",
"$",
"invocation",
")",
";",
"return",
"$",
"invoker",
"->",
"invoke",
"(",
"$",
"invocation",
")",
";",
"}"
] |
Handle the invocation.
@param \Lawoole\Homer\Calling\Invocation $invocation
@return \Lawoole\Homer\Calling\Result
|
[
"Handle",
"the",
"invocation",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Dispatcher.php#L69-L74
|
228,392
|
lawoole/framework
|
src/Homer/Calling/Dispatcher.php
|
Dispatcher.dispatchInvocation
|
protected function dispatchInvocation(Invocation $invocation)
{
$interface = $invocation->getInterface();
if (isset($this->invokers[$interface])) {
return $this->invokers[$interface];
}
throw new CallingException("No invoker found for {$interface}.");
}
|
php
|
protected function dispatchInvocation(Invocation $invocation)
{
$interface = $invocation->getInterface();
if (isset($this->invokers[$interface])) {
return $this->invokers[$interface];
}
throw new CallingException("No invoker found for {$interface}.");
}
|
[
"protected",
"function",
"dispatchInvocation",
"(",
"Invocation",
"$",
"invocation",
")",
"{",
"$",
"interface",
"=",
"$",
"invocation",
"->",
"getInterface",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"invokers",
"[",
"$",
"interface",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"invokers",
"[",
"$",
"interface",
"]",
";",
"}",
"throw",
"new",
"CallingException",
"(",
"\"No invoker found for {$interface}.\"",
")",
";",
"}"
] |
Dispatch the invocation.
@param \Lawoole\Homer\Calling\Invocation $invocation
@return \Lawoole\Homer\Calling\Invokers\Invoker
|
[
"Dispatch",
"the",
"invocation",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Dispatcher.php#L83-L92
|
228,393
|
alexinator1/yii2-jta
|
src/ActiveQuery.php
|
ActiveQuery.joinWithRelations
|
private function joinWithRelations($model, $with, $joinType)
{
$relations = [];
foreach ($with as $name => $callback) {
if (is_int($name)) {
$name = $callback;
$callback = null;
}
$primaryModel = $model;
$parent = $this;
$prefix = '';
while (($pos = strpos($name, '.')) !== false) {
$childName = substr($name, $pos + 1);
$name = substr($name, 0, $pos);
$fullName = $prefix === '' ? $name : "$prefix.$name";
if (!isset($relations[$fullName])) {
$relations[$fullName] = $relation = $primaryModel->getRelation($name);
$this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName));
} else {
$relation = $relations[$fullName];
}
$primaryModel = new $relation->modelClass;
$parent = $relation;
$prefix = $fullName;
$name = $childName;
}
$fullName = $prefix === '' ? $name : "$prefix.$name";
if (!isset($relations[$fullName])) {
$relations[$fullName] = $relation = $primaryModel->getRelation($name);
if ($callback !== null) {
call_user_func($callback, $relation);
}
if (!empty($relation->joinWith)) {
$relation->buildJoinWith();
}
$this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName));
}
}
}
|
php
|
private function joinWithRelations($model, $with, $joinType)
{
$relations = [];
foreach ($with as $name => $callback) {
if (is_int($name)) {
$name = $callback;
$callback = null;
}
$primaryModel = $model;
$parent = $this;
$prefix = '';
while (($pos = strpos($name, '.')) !== false) {
$childName = substr($name, $pos + 1);
$name = substr($name, 0, $pos);
$fullName = $prefix === '' ? $name : "$prefix.$name";
if (!isset($relations[$fullName])) {
$relations[$fullName] = $relation = $primaryModel->getRelation($name);
$this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName));
} else {
$relation = $relations[$fullName];
}
$primaryModel = new $relation->modelClass;
$parent = $relation;
$prefix = $fullName;
$name = $childName;
}
$fullName = $prefix === '' ? $name : "$prefix.$name";
if (!isset($relations[$fullName])) {
$relations[$fullName] = $relation = $primaryModel->getRelation($name);
if ($callback !== null) {
call_user_func($callback, $relation);
}
if (!empty($relation->joinWith)) {
$relation->buildJoinWith();
}
$this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName));
}
}
}
|
[
"private",
"function",
"joinWithRelations",
"(",
"$",
"model",
",",
"$",
"with",
",",
"$",
"joinType",
")",
"{",
"$",
"relations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"with",
"as",
"$",
"name",
"=>",
"$",
"callback",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"callback",
";",
"$",
"callback",
"=",
"null",
";",
"}",
"$",
"primaryModel",
"=",
"$",
"model",
";",
"$",
"parent",
"=",
"$",
"this",
";",
"$",
"prefix",
"=",
"''",
";",
"while",
"(",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"name",
",",
"'.'",
")",
")",
"!==",
"false",
")",
"{",
"$",
"childName",
"=",
"substr",
"(",
"$",
"name",
",",
"$",
"pos",
"+",
"1",
")",
";",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"fullName",
"=",
"$",
"prefix",
"===",
"''",
"?",
"$",
"name",
":",
"\"$prefix.$name\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"relations",
"[",
"$",
"fullName",
"]",
")",
")",
"{",
"$",
"relations",
"[",
"$",
"fullName",
"]",
"=",
"$",
"relation",
"=",
"$",
"primaryModel",
"->",
"getRelation",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"joinWithRelation",
"(",
"$",
"parent",
",",
"$",
"relation",
",",
"$",
"this",
"->",
"getJoinType",
"(",
"$",
"joinType",
",",
"$",
"fullName",
")",
")",
";",
"}",
"else",
"{",
"$",
"relation",
"=",
"$",
"relations",
"[",
"$",
"fullName",
"]",
";",
"}",
"$",
"primaryModel",
"=",
"new",
"$",
"relation",
"->",
"modelClass",
";",
"$",
"parent",
"=",
"$",
"relation",
";",
"$",
"prefix",
"=",
"$",
"fullName",
";",
"$",
"name",
"=",
"$",
"childName",
";",
"}",
"$",
"fullName",
"=",
"$",
"prefix",
"===",
"''",
"?",
"$",
"name",
":",
"\"$prefix.$name\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"relations",
"[",
"$",
"fullName",
"]",
")",
")",
"{",
"$",
"relations",
"[",
"$",
"fullName",
"]",
"=",
"$",
"relation",
"=",
"$",
"primaryModel",
"->",
"getRelation",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"callback",
"!==",
"null",
")",
"{",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"relation",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"relation",
"->",
"joinWith",
")",
")",
"{",
"$",
"relation",
"->",
"buildJoinWith",
"(",
")",
";",
"}",
"$",
"this",
"->",
"joinWithRelation",
"(",
"$",
"parent",
",",
"$",
"relation",
",",
"$",
"this",
"->",
"getJoinType",
"(",
"$",
"joinType",
",",
"$",
"fullName",
")",
")",
";",
"}",
"}",
"}"
] |
Modifies the current query by adding join fragments based on the given relations.
@param ActiveRecord $model the primary model
@param array $with the relations to be joined
@param string|array $joinType the join type
|
[
"Modifies",
"the",
"current",
"query",
"by",
"adding",
"join",
"fragments",
"based",
"on",
"the",
"given",
"relations",
"."
] |
540d767883fdfebedf64ceedbe1c1ca48082f230
|
https://github.com/alexinator1/yii2-jta/blob/540d767883fdfebedf64ceedbe1c1ca48082f230/src/ActiveQuery.php#L207-L248
|
228,394
|
alexinator1/yii2-jta
|
src/ActiveQuery.php
|
ActiveQuery.getJoinType
|
private function getJoinType($joinType, $name)
{
if (is_array($joinType) && isset($joinType[$name])) {
return $joinType[$name];
} else {
return is_string($joinType) ? $joinType : 'INNER JOIN';
}
}
|
php
|
private function getJoinType($joinType, $name)
{
if (is_array($joinType) && isset($joinType[$name])) {
return $joinType[$name];
} else {
return is_string($joinType) ? $joinType : 'INNER JOIN';
}
}
|
[
"private",
"function",
"getJoinType",
"(",
"$",
"joinType",
",",
"$",
"name",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"joinType",
")",
"&&",
"isset",
"(",
"$",
"joinType",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"joinType",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"return",
"is_string",
"(",
"$",
"joinType",
")",
"?",
"$",
"joinType",
":",
"'INNER JOIN'",
";",
"}",
"}"
] |
Returns the join type based on the given join type parameter and the relation name.
@param string|array $joinType the given join type(s)
@param string $name relation name
@return string the real join type
|
[
"Returns",
"the",
"join",
"type",
"based",
"on",
"the",
"given",
"join",
"type",
"parameter",
"and",
"the",
"relation",
"name",
"."
] |
540d767883fdfebedf64ceedbe1c1ca48082f230
|
https://github.com/alexinator1/yii2-jta/blob/540d767883fdfebedf64ceedbe1c1ca48082f230/src/ActiveQuery.php#L256-L263
|
228,395
|
antaresproject/core
|
src/foundation/src/Support/Providers/Traits/RouteProviderTrait.php
|
RouteProviderTrait.resolveRouteGroupAttributes
|
protected function resolveRouteGroupAttributes($namespace = null, array $attributes = [])
{
if (is_array($namespace)) {
$attributes = $namespace;
$namespace = '';
}
if (!is_null($namespace)) {
$attributes['namespace'] = empty($namespace) ? $this->namespace : "{$this->namespace}\\{$namespace}";
}
return $attributes;
}
|
php
|
protected function resolveRouteGroupAttributes($namespace = null, array $attributes = [])
{
if (is_array($namespace)) {
$attributes = $namespace;
$namespace = '';
}
if (!is_null($namespace)) {
$attributes['namespace'] = empty($namespace) ? $this->namespace : "{$this->namespace}\\{$namespace}";
}
return $attributes;
}
|
[
"protected",
"function",
"resolveRouteGroupAttributes",
"(",
"$",
"namespace",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"attributes",
"=",
"$",
"namespace",
";",
"$",
"namespace",
"=",
"''",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"attributes",
"[",
"'namespace'",
"]",
"=",
"empty",
"(",
"$",
"namespace",
")",
"?",
"$",
"this",
"->",
"namespace",
":",
"\"{$this->namespace}\\\\{$namespace}\"",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Resolve route group attributes.
@param array|string|null $namespace
@param array $attributes
@return array
|
[
"Resolve",
"route",
"group",
"attributes",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/Traits/RouteProviderTrait.php#L88-L98
|
228,396
|
soberwp/unravel
|
src/Migrate.php
|
Migrate.setDestinationPath
|
protected function setDestinationPath($folder)
{
$this->destinationPath = wp_upload_dir();
$this->destinationPath = rtrim($this->destinationPath['basedir'], 'uploads') . $folder; // fix rtrim uploads name
}
|
php
|
protected function setDestinationPath($folder)
{
$this->destinationPath = wp_upload_dir();
$this->destinationPath = rtrim($this->destinationPath['basedir'], 'uploads') . $folder; // fix rtrim uploads name
}
|
[
"protected",
"function",
"setDestinationPath",
"(",
"$",
"folder",
")",
"{",
"$",
"this",
"->",
"destinationPath",
"=",
"wp_upload_dir",
"(",
")",
";",
"$",
"this",
"->",
"destinationPath",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"destinationPath",
"[",
"'basedir'",
"]",
",",
"'uploads'",
")",
".",
"$",
"folder",
";",
"// fix rtrim uploads name",
"}"
] |
Set destination path
|
[
"Set",
"destination",
"path"
] |
e9ad06ae8bb1b92b612c1b5ee4f38a462272c265
|
https://github.com/soberwp/unravel/blob/e9ad06ae8bb1b92b612c1b5ee4f38a462272c265/src/Migrate.php#L19-L23
|
228,397
|
soberwp/unravel
|
src/Migrate.php
|
Migrate.setOriginPath
|
protected function setOriginPath($filter)
{
$this->originPath = (has_filter($filter) ? apply_filters($filter, rtrim($this->originPath)) : get_stylesheet_directory() . '/' . $this->pathDefault);
}
|
php
|
protected function setOriginPath($filter)
{
$this->originPath = (has_filter($filter) ? apply_filters($filter, rtrim($this->originPath)) : get_stylesheet_directory() . '/' . $this->pathDefault);
}
|
[
"protected",
"function",
"setOriginPath",
"(",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"originPath",
"=",
"(",
"has_filter",
"(",
"$",
"filter",
")",
"?",
"apply_filters",
"(",
"$",
"filter",
",",
"rtrim",
"(",
"$",
"this",
"->",
"originPath",
")",
")",
":",
"get_stylesheet_directory",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"pathDefault",
")",
";",
"}"
] |
Get origin path
|
[
"Get",
"origin",
"path"
] |
e9ad06ae8bb1b92b612c1b5ee4f38a462272c265
|
https://github.com/soberwp/unravel/blob/e9ad06ae8bb1b92b612c1b5ee4f38a462272c265/src/Migrate.php#L36-L39
|
228,398
|
soberwp/unravel
|
src/Migrate.php
|
Migrate.deregister
|
public function deregister()
{
$this->pathOrigin = get_stylesheet_directory() . '/' . $this->pathDefault;
if ($this->folderExist($this->pathOrigin)) return;
rename($this->destinationPath, $this->pathOrigin);
}
|
php
|
public function deregister()
{
$this->pathOrigin = get_stylesheet_directory() . '/' . $this->pathDefault;
if ($this->folderExist($this->pathOrigin)) return;
rename($this->destinationPath, $this->pathOrigin);
}
|
[
"public",
"function",
"deregister",
"(",
")",
"{",
"$",
"this",
"->",
"pathOrigin",
"=",
"get_stylesheet_directory",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"pathDefault",
";",
"if",
"(",
"$",
"this",
"->",
"folderExist",
"(",
"$",
"this",
"->",
"pathOrigin",
")",
")",
"return",
";",
"rename",
"(",
"$",
"this",
"->",
"destinationPath",
",",
"$",
"this",
"->",
"pathOrigin",
")",
";",
"}"
] |
make it work for advanced custom fields
|
[
"make",
"it",
"work",
"for",
"advanced",
"custom",
"fields"
] |
e9ad06ae8bb1b92b612c1b5ee4f38a462272c265
|
https://github.com/soberwp/unravel/blob/e9ad06ae8bb1b92b612c1b5ee4f38a462272c265/src/Migrate.php#L64-L69
|
228,399
|
lawoole/framework
|
src/Homer/Calling/Invokers/Invoker.php
|
Invoker.invoke
|
public function invoke(Invocation $invocation)
{
try {
return $this->doInvoke($invocation);
} catch (Throwable $e) {
return $this->createExceptionResult($e);
}
}
|
php
|
public function invoke(Invocation $invocation)
{
try {
return $this->doInvoke($invocation);
} catch (Throwable $e) {
return $this->createExceptionResult($e);
}
}
|
[
"public",
"function",
"invoke",
"(",
"Invocation",
"$",
"invocation",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"doInvoke",
"(",
"$",
"invocation",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"createExceptionResult",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Do invoking.
@param \Lawoole\Homer\Calling\Invocation $invocation
@return \Lawoole\Homer\Calling\Result
|
[
"Do",
"invoking",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Invokers/Invoker.php#L63-L70
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.