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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
227,400
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/IncomingPort.php
|
IncomingPort.getFromId
|
public function getFromId( $IncomingPortId){
$rest = $this->getService( self::API_NAT_INCOMING . $IncomingPortId);
$rest->GET();
return $rest->getResult( models\NAT\IncomingPortConfig::class);
}
|
php
|
public function getFromId( $IncomingPortId){
$rest = $this->getService( self::API_NAT_INCOMING . $IncomingPortId);
$rest->GET();
return $rest->getResult( models\NAT\IncomingPortConfig::class);
}
|
[
"public",
"function",
"getFromId",
"(",
"$",
"IncomingPortId",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_INCOMING",
".",
"$",
"IncomingPortId",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"IncomingPortConfig",
"::",
"class",
")",
";",
"}"
] |
Getting a specific incoming port
@param string $IncomingPortId
@return models\NAT\IncomingPortConfig
|
[
"Getting",
"a",
"specific",
"incoming",
"port"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/IncomingPort.php#L32-L37
|
227,401
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/IncomingPort.php
|
IncomingPort.update
|
public function update( models\NAT\IncomingPortConfig $incomingPortConfig){
$rest = $this->getService( self::API_NAT_INCOMING . $incomingPortConfig->getId());
$rest->PUT( $incomingPortConfig);
return $rest->getResult( models\NAT\IncomingPortConfig::class);
}
|
php
|
public function update( models\NAT\IncomingPortConfig $incomingPortConfig){
$rest = $this->getService( self::API_NAT_INCOMING . $incomingPortConfig->getId());
$rest->PUT( $incomingPortConfig);
return $rest->getResult( models\NAT\IncomingPortConfig::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"NAT",
"\\",
"IncomingPortConfig",
"$",
"incomingPortConfig",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_INCOMING",
".",
"$",
"incomingPortConfig",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"incomingPortConfig",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"IncomingPortConfig",
"::",
"class",
")",
";",
"}"
] |
Updating an incoming port
@param models\NAT\IncomingPortConfig $incomingPortConfig
@return models\NAT\IncomingPortConfig
@throws \Exception
|
[
"Updating",
"an",
"incoming",
"port"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/IncomingPort.php#L45-L50
|
227,402
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/LAN/Browser.php
|
Browser.getBrowsableInterfaces
|
public function getBrowsableInterfaces(){
$rest = $this->getService( self::API_LAN_BROWSER_INTERFACES);
$rest->GET();
return $rest->getResultAsArray( models\LAN\LanInterface::class);
}
|
php
|
public function getBrowsableInterfaces(){
$rest = $this->getService( self::API_LAN_BROWSER_INTERFACES);
$rest->GET();
return $rest->getResultAsArray( models\LAN\LanInterface::class);
}
|
[
"public",
"function",
"getBrowsableInterfaces",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_LAN_BROWSER_INTERFACES",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"LAN",
"\\",
"LanInterface",
"::",
"class",
")",
";",
"}"
] |
Get all Lan interfaces
@return models\LAN\LanInterface
|
[
"Get",
"all",
"Lan",
"interfaces"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/LAN/Browser.php#L22-L27
|
227,403
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/LAN/Browser.php
|
Browser.getHostsFromInterfaceName
|
public function getHostsFromInterfaceName( $lanInterfaceId){
$service = sprintf( self::API_LAN_BROWSER_INTERFACE, $lanInterfaceId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\LAN\LanHost::class);
}
|
php
|
public function getHostsFromInterfaceName( $lanInterfaceId){
$service = sprintf( self::API_LAN_BROWSER_INTERFACE, $lanInterfaceId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\LAN\LanHost::class);
}
|
[
"public",
"function",
"getHostsFromInterfaceName",
"(",
"$",
"lanInterfaceId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_LAN_BROWSER_INTERFACE",
",",
"$",
"lanInterfaceId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"LAN",
"\\",
"LanHost",
"::",
"class",
")",
";",
"}"
] |
Get the LanHosts of the specified interface name
@param string $lanInterfaceId
@return models\LAN\LanHost[]
|
[
"Get",
"the",
"LanHosts",
"of",
"the",
"specified",
"interface",
"name"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/LAN/Browser.php#L43-L49
|
227,404
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/LAN/Browser.php
|
Browser.getHostFromId
|
public function getHostFromId( $lanInterfaceId, $hostId){
$service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $hostId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResult( models\LAN\LanHost::class);
}
|
php
|
public function getHostFromId( $lanInterfaceId, $hostId){
$service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $hostId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResult( models\LAN\LanHost::class);
}
|
[
"public",
"function",
"getHostFromId",
"(",
"$",
"lanInterfaceId",
",",
"$",
"hostId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_LAN_BROWSER_HOST",
",",
"$",
"lanInterfaceId",
",",
"$",
"hostId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"LAN",
"\\",
"LanHost",
"::",
"class",
")",
";",
"}"
] |
Get a specific LanHost
@param string $lanInterfaceId
@param string $hostId
@return models\LAN\LanHost
|
[
"Get",
"a",
"specific",
"LanHost"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/LAN/Browser.php#L57-L63
|
227,405
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/LAN/Browser.php
|
Browser.updateHostFromInterfaceId
|
public function updateHostFromInterfaceId( models\LAN\LanHost $LanHost, $lanInterfaceId){
$service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $LanHost->getId());
$rest = $this->getService( $service);
$rest->PUT( $LanHost);
return $rest->getResult( models\LAN\LanHost::class);
}
|
php
|
public function updateHostFromInterfaceId( models\LAN\LanHost $LanHost, $lanInterfaceId){
$service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $LanHost->getId());
$rest = $this->getService( $service);
$rest->PUT( $LanHost);
return $rest->getResult( models\LAN\LanHost::class);
}
|
[
"public",
"function",
"updateHostFromInterfaceId",
"(",
"models",
"\\",
"LAN",
"\\",
"LanHost",
"$",
"LanHost",
",",
"$",
"lanInterfaceId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_LAN_BROWSER_HOST",
",",
"$",
"lanInterfaceId",
",",
"$",
"LanHost",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"LanHost",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"LAN",
"\\",
"LanHost",
"::",
"class",
")",
";",
"}"
] |
Update a LanHost
@param models\LAN\LanHost $LanHost
@param string $lanInterfaceId
@return models\LAN\LanHost
|
[
"Update",
"a",
"LanHost"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/LAN/Browser.php#L71-L77
|
227,406
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/LAN/Browser.php
|
Browser.wakeOnLan
|
public function wakeOnLan( models\LAN\LanInterface $lanInterface, models\LAN\LanHost $lanHost, $password = ''){
$service = sprintf( self::API_WAKE_ON_LAN, $lanInterface->getName());
$rest = $this->getService( $service);
$rest->PUT([
'mac' => $lanHost->getId(),
'password' => $password,
]);
return $rest->getSuccess();
}
|
php
|
public function wakeOnLan( models\LAN\LanInterface $lanInterface, models\LAN\LanHost $lanHost, $password = ''){
$service = sprintf( self::API_WAKE_ON_LAN, $lanInterface->getName());
$rest = $this->getService( $service);
$rest->PUT([
'mac' => $lanHost->getId(),
'password' => $password,
]);
return $rest->getSuccess();
}
|
[
"public",
"function",
"wakeOnLan",
"(",
"models",
"\\",
"LAN",
"\\",
"LanInterface",
"$",
"lanInterface",
",",
"models",
"\\",
"LAN",
"\\",
"LanHost",
"$",
"lanHost",
",",
"$",
"password",
"=",
"''",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_WAKE_ON_LAN",
",",
"$",
"lanInterface",
"->",
"getName",
"(",
")",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"[",
"'mac'",
"=>",
"$",
"lanHost",
"->",
"getId",
"(",
")",
",",
"'password'",
"=>",
"$",
"password",
",",
"]",
")",
";",
"return",
"$",
"rest",
"->",
"getSuccess",
"(",
")",
";",
"}"
] |
Send Wake ok Lan packet to an host
@param models\LAN\LanInterface $lanInterface
@param models\LAN\LanHost $lanHost
@param string $password
@return bool
|
[
"Send",
"Wake",
"ok",
"Lan",
"packet",
"to",
"an",
"host"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/LAN/Browser.php#L86-L95
|
227,407
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEmail.php
|
ContactEmail.create
|
public function create( models\Call\ContactEmail $ContactEmail){
$rest = $this->getService( self::API_EMAIL);
$rest->POST( $ContactEmail);
return $rest->getResult( models\Call\ContactEmail::class);
}
|
php
|
public function create( models\Call\ContactEmail $ContactEmail){
$rest = $this->getService( self::API_EMAIL);
$rest->POST( $ContactEmail);
return $rest->getResult( models\Call\ContactEmail::class);
}
|
[
"public",
"function",
"create",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEmail",
"$",
"ContactEmail",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_EMAIL",
")",
";",
"$",
"rest",
"->",
"POST",
"(",
"$",
"ContactEmail",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEmail",
"::",
"class",
")",
";",
"}"
] |
Create a new email contact
@param models\Call\ContactEmail $ContactEmail
@return models\Call\ContactEmail
|
[
"Create",
"a",
"new",
"email",
"contact"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEmail.php#L32-L37
|
227,408
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEmail.php
|
ContactEmail.update
|
public function update( models\Call\ContactEmail $ContactEmail){
$rest = $this->getService( self::API_EMAIL . $ContactEmail->getId());
$rest->PUT( $ContactEmail);
return $rest->getResult( models\Call\ContactEmail::class);
}
|
php
|
public function update( models\Call\ContactEmail $ContactEmail){
$rest = $this->getService( self::API_EMAIL . $ContactEmail->getId());
$rest->PUT( $ContactEmail);
return $rest->getResult( models\Call\ContactEmail::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEmail",
"$",
"ContactEmail",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_EMAIL",
".",
"$",
"ContactEmail",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"ContactEmail",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEmail",
"::",
"class",
")",
";",
"}"
] |
Update an email contact
@param models\Call\ContactEmail $ContactEmail
@return models\Call\ContactEmail
|
[
"Update",
"an",
"email",
"contact"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEmail.php#L65-L70
|
227,409
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/Connection/Connection.php
|
Connection.getIPv6Configuration
|
public function getIPv6Configuration(){
$rest = $this->getService( self::API_CONNECTION_IPV6_CONFIG);
$rest->GET();
return $rest->getResult( models\Connection\Ipv6\Configuration::class);
}
|
php
|
public function getIPv6Configuration(){
$rest = $this->getService( self::API_CONNECTION_IPV6_CONFIG);
$rest->GET();
return $rest->getResult( models\Connection\Ipv6\Configuration::class);
}
|
[
"public",
"function",
"getIPv6Configuration",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_CONNECTION_IPV6_CONFIG",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Connection",
"\\",
"Ipv6",
"\\",
"Configuration",
"::",
"class",
")",
";",
"}"
] |
Get the current IPv6 Connection configuration
|
[
"Get",
"the",
"current",
"IPv6",
"Connection",
"configuration"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/Connection/Connection.php#L54-L59
|
227,410
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/Connection/Connection.php
|
Connection.setIPv6Configuration
|
public function setIPv6Configuration(models\Connection\Ipv6\Configuration $connectionIpv6Configuration){
$rest = $this->getService( self::API_CONNECTION_IPV6_CONFIG);
$rest->PUT( $connectionIpv6Configuration);
return $rest->getResult( models\Connection\Ipv6\Configuration::class);
}
|
php
|
public function setIPv6Configuration(models\Connection\Ipv6\Configuration $connectionIpv6Configuration){
$rest = $this->getService( self::API_CONNECTION_IPV6_CONFIG);
$rest->PUT( $connectionIpv6Configuration);
return $rest->getResult( models\Connection\Ipv6\Configuration::class);
}
|
[
"public",
"function",
"setIPv6Configuration",
"(",
"models",
"\\",
"Connection",
"\\",
"Ipv6",
"\\",
"Configuration",
"$",
"connectionIpv6Configuration",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_CONNECTION_IPV6_CONFIG",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"connectionIpv6Configuration",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Connection",
"\\",
"Ipv6",
"\\",
"Configuration",
"::",
"class",
")",
";",
"}"
] |
Update the IPv6 Connection configuration
@param \alphayax\freebox\api\v3\models\Connection\Ipv6\Configuration $connectionIpv6Configuration
@return \alphayax\freebox\api\v3\models\Connection\Ipv6\Configuration
|
[
"Update",
"the",
"IPv6",
"Connection",
"configuration"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/Connection/Connection.php#L66-L71
|
227,411
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.create_hold
|
public static function create_hold($mode, $channels, $response, $timeout = null)
{
$channels = self::parse_channels($channels);
$ichannels = self::get_hold_channels($channels);
$hold = array();
$hold['mode'] = $mode;
$hold['channels'] = $ichannels;
if (!is_null($timeout)) {
$hold['timeout'] = $timeout;
}
$iresponse = self::get_hold_response($response);
$instruct = array();
$instruct['hold'] = $hold;
if (!is_null($iresponse)) {
$instruct['response'] = $iresponse;
}
return json_encode($instruct);
}
|
php
|
public static function create_hold($mode, $channels, $response, $timeout = null)
{
$channels = self::parse_channels($channels);
$ichannels = self::get_hold_channels($channels);
$hold = array();
$hold['mode'] = $mode;
$hold['channels'] = $ichannels;
if (!is_null($timeout)) {
$hold['timeout'] = $timeout;
}
$iresponse = self::get_hold_response($response);
$instruct = array();
$instruct['hold'] = $hold;
if (!is_null($iresponse)) {
$instruct['response'] = $iresponse;
}
return json_encode($instruct);
}
|
[
"public",
"static",
"function",
"create_hold",
"(",
"$",
"mode",
",",
"$",
"channels",
",",
"$",
"response",
",",
"$",
"timeout",
"=",
"null",
")",
"{",
"$",
"channels",
"=",
"self",
"::",
"parse_channels",
"(",
"$",
"channels",
")",
";",
"$",
"ichannels",
"=",
"self",
"::",
"get_hold_channels",
"(",
"$",
"channels",
")",
";",
"$",
"hold",
"=",
"array",
"(",
")",
";",
"$",
"hold",
"[",
"'mode'",
"]",
"=",
"$",
"mode",
";",
"$",
"hold",
"[",
"'channels'",
"]",
"=",
"$",
"ichannels",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"timeout",
")",
")",
"{",
"$",
"hold",
"[",
"'timeout'",
"]",
"=",
"$",
"timeout",
";",
"}",
"$",
"iresponse",
"=",
"self",
"::",
"get_hold_response",
"(",
"$",
"response",
")",
";",
"$",
"instruct",
"=",
"array",
"(",
")",
";",
"$",
"instruct",
"[",
"'hold'",
"]",
"=",
"$",
"hold",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"iresponse",
")",
")",
"{",
"$",
"instruct",
"[",
"'response'",
"]",
"=",
"$",
"iresponse",
";",
"}",
"return",
"json_encode",
"(",
"$",
"instruct",
")",
";",
"}"
] |
either a string representing the response body or a Response instance.
|
[
"either",
"a",
"string",
"representing",
"the",
"response",
"body",
"or",
"a",
"Response",
"instance",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L27-L44
|
227,412
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.parse_grip_uri
|
public static function parse_grip_uri($uri)
{
$uri = parse_url($uri);
$params = array();
if (array_key_exists('query', $uri)) {
parse_str($uri['query'], $params);
}
$iss = null;
$key = null;
if (array_key_exists('iss', $params)) {
$iss = $params['iss'];
unset($params['iss']);
}
if (array_key_exists('key', $params)) {
$key = $params['key'];
unset($params['key']);
}
if (!is_null($key) && substr($key, 0, strlen('base64:')) === 'base64:') {
$key = base64_decode(substr($key, 7));
}
$qs = http_build_query($params);
$path = $uri['path'];
if (substr($path, strlen($path) - 1) === '/') {
$path = substr($path, 0, strlen($path) - 1);
}
$port = '';
if (array_key_exists('port', $uri) && $uri['port'] != '' && $uri['port'] != '80') {
$port = ':' . $uri['port'];
}
$control_uri = $uri['scheme'] . '://' . $uri['host'] . $port . $path;
if (!is_null($qs) && $qs != '') {
$control_uri .= '?' . $qs;
}
$out = array('control_uri' => $control_uri);
if (!is_null($iss)) {
$out['control_iss'] = $iss;
}
if (!is_null($key)) {
$out['key'] = $key;
}
return $out;
}
|
php
|
public static function parse_grip_uri($uri)
{
$uri = parse_url($uri);
$params = array();
if (array_key_exists('query', $uri)) {
parse_str($uri['query'], $params);
}
$iss = null;
$key = null;
if (array_key_exists('iss', $params)) {
$iss = $params['iss'];
unset($params['iss']);
}
if (array_key_exists('key', $params)) {
$key = $params['key'];
unset($params['key']);
}
if (!is_null($key) && substr($key, 0, strlen('base64:')) === 'base64:') {
$key = base64_decode(substr($key, 7));
}
$qs = http_build_query($params);
$path = $uri['path'];
if (substr($path, strlen($path) - 1) === '/') {
$path = substr($path, 0, strlen($path) - 1);
}
$port = '';
if (array_key_exists('port', $uri) && $uri['port'] != '' && $uri['port'] != '80') {
$port = ':' . $uri['port'];
}
$control_uri = $uri['scheme'] . '://' . $uri['host'] . $port . $path;
if (!is_null($qs) && $qs != '') {
$control_uri .= '?' . $qs;
}
$out = array('control_uri' => $control_uri);
if (!is_null($iss)) {
$out['control_iss'] = $iss;
}
if (!is_null($key)) {
$out['key'] = $key;
}
return $out;
}
|
[
"public",
"static",
"function",
"parse_grip_uri",
"(",
"$",
"uri",
")",
"{",
"$",
"uri",
"=",
"parse_url",
"(",
"$",
"uri",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'query'",
",",
"$",
"uri",
")",
")",
"{",
"parse_str",
"(",
"$",
"uri",
"[",
"'query'",
"]",
",",
"$",
"params",
")",
";",
"}",
"$",
"iss",
"=",
"null",
";",
"$",
"key",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"'iss'",
",",
"$",
"params",
")",
")",
"{",
"$",
"iss",
"=",
"$",
"params",
"[",
"'iss'",
"]",
";",
"unset",
"(",
"$",
"params",
"[",
"'iss'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'key'",
",",
"$",
"params",
")",
")",
"{",
"$",
"key",
"=",
"$",
"params",
"[",
"'key'",
"]",
";",
"unset",
"(",
"$",
"params",
"[",
"'key'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
"&&",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"strlen",
"(",
"'base64:'",
")",
")",
"===",
"'base64:'",
")",
"{",
"$",
"key",
"=",
"base64_decode",
"(",
"substr",
"(",
"$",
"key",
",",
"7",
")",
")",
";",
"}",
"$",
"qs",
"=",
"http_build_query",
"(",
"$",
"params",
")",
";",
"$",
"path",
"=",
"$",
"uri",
"[",
"'path'",
"]",
";",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"strlen",
"(",
"$",
"path",
")",
"-",
"1",
")",
"===",
"'/'",
")",
"{",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"strlen",
"(",
"$",
"path",
")",
"-",
"1",
")",
";",
"}",
"$",
"port",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'port'",
",",
"$",
"uri",
")",
"&&",
"$",
"uri",
"[",
"'port'",
"]",
"!=",
"''",
"&&",
"$",
"uri",
"[",
"'port'",
"]",
"!=",
"'80'",
")",
"{",
"$",
"port",
"=",
"':'",
".",
"$",
"uri",
"[",
"'port'",
"]",
";",
"}",
"$",
"control_uri",
"=",
"$",
"uri",
"[",
"'scheme'",
"]",
".",
"'://'",
".",
"$",
"uri",
"[",
"'host'",
"]",
".",
"$",
"port",
".",
"$",
"path",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"qs",
")",
"&&",
"$",
"qs",
"!=",
"''",
")",
"{",
"$",
"control_uri",
".=",
"'?'",
".",
"$",
"qs",
";",
"}",
"$",
"out",
"=",
"array",
"(",
"'control_uri'",
"=>",
"$",
"control_uri",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"iss",
")",
")",
"{",
"$",
"out",
"[",
"'control_iss'",
"]",
"=",
"$",
"iss",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"$",
"out",
"[",
"'key'",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
encoded format.
|
[
"encoded",
"format",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L51-L92
|
227,413
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.validate_sig
|
public static function validate_sig($token, $key)
{
try {
\Firebase\JWT\JWT::decode($token, $key, array('HS256', 'HS384', 'HS512', 'RS256'));
return true;
} catch (\Exception $e) {
return false;
}
}
|
php
|
public static function validate_sig($token, $key)
{
try {
\Firebase\JWT\JWT::decode($token, $key, array('HS256', 'HS384', 'HS512', 'RS256'));
return true;
} catch (\Exception $e) {
return false;
}
}
|
[
"public",
"static",
"function",
"validate_sig",
"(",
"$",
"token",
",",
"$",
"key",
")",
"{",
"try",
"{",
"\\",
"Firebase",
"\\",
"JWT",
"\\",
"JWT",
"::",
"decode",
"(",
"$",
"token",
",",
"$",
"key",
",",
"array",
"(",
"'HS256'",
",",
"'HS384'",
",",
"'HS512'",
",",
"'RS256'",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Note that the token expiration is also verified.
|
[
"Note",
"that",
"the",
"token",
"expiration",
"is",
"also",
"verified",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L97-L105
|
227,414
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.create_grip_channel_header
|
public static function create_grip_channel_header($channels)
{
$channels = self::parse_channels($channels);
$parts = array();
foreach ($channels as $channel) {
$s = $channel->name;
if (!is_null($channel->prev_id)) {
$s .= "; prev-id={$channel->prev_id}";
}
$parts[] = $s;
}
return implode(', ', $parts);
}
|
php
|
public static function create_grip_channel_header($channels)
{
$channels = self::parse_channels($channels);
$parts = array();
foreach ($channels as $channel) {
$s = $channel->name;
if (!is_null($channel->prev_id)) {
$s .= "; prev-id={$channel->prev_id}";
}
$parts[] = $s;
}
return implode(', ', $parts);
}
|
[
"public",
"static",
"function",
"create_grip_channel_header",
"(",
"$",
"channels",
")",
"{",
"$",
"channels",
"=",
"self",
"::",
"parse_channels",
"(",
"$",
"channels",
")",
";",
"$",
"parts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"channels",
"as",
"$",
"channel",
")",
"{",
"$",
"s",
"=",
"$",
"channel",
"->",
"name",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"channel",
"->",
"prev_id",
")",
")",
"{",
"$",
"s",
".=",
"\"; prev-id={$channel->prev_id}\"",
";",
"}",
"$",
"parts",
"[",
"]",
"=",
"$",
"s",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"parts",
")",
";",
"}"
] |
HTTP headers.
|
[
"HTTP",
"headers",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L112-L124
|
227,415
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.create_hold_response
|
public static function create_hold_response($channels, $response = null, $timeout = null)
{
return self::create_hold('response', $channels, $response, $timeout);
}
|
php
|
public static function create_hold_response($channels, $response = null, $timeout = null)
{
return self::create_hold('response', $channels, $response, $timeout);
}
|
[
"public",
"static",
"function",
"create_hold_response",
"(",
"$",
"channels",
",",
"$",
"response",
"=",
"null",
",",
"$",
"timeout",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"create_hold",
"(",
"'response'",
",",
"$",
"channels",
",",
"$",
"response",
",",
"$",
"timeout",
")",
";",
"}"
] |
create_hold method with 'response' as the hold mode.
|
[
"create_hold",
"method",
"with",
"response",
"as",
"the",
"hold",
"mode",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L129-L132
|
227,416
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.decode_websocket_events
|
public static function decode_websocket_events($body)
{
$out = array();
$start = 0;
while ($start < strlen($body)) {
$at = strpos($body, "\r\n", $start);
if ($at === false) {
throw new \RuntimeException('bad format');
}
$typeline = substr($body, $start, $at - $start);
$start = $at + 2;
$at = strpos($typeline, ' ');
$e = null;
if (!($at === false)) {
$etype = substr($typeline, 0, $at);
$clen = intval('0x' . substr($typeline, $at + 1), 16);
$content = substr($body, $start, $clen);
$start += $clen + 2;
$e = new WebSocketEvent($etype, $content);
} else {
$e = new WebSocketEvent($typeline);
}
$out[] = $e;
}
return $out;
}
|
php
|
public static function decode_websocket_events($body)
{
$out = array();
$start = 0;
while ($start < strlen($body)) {
$at = strpos($body, "\r\n", $start);
if ($at === false) {
throw new \RuntimeException('bad format');
}
$typeline = substr($body, $start, $at - $start);
$start = $at + 2;
$at = strpos($typeline, ' ');
$e = null;
if (!($at === false)) {
$etype = substr($typeline, 0, $at);
$clen = intval('0x' . substr($typeline, $at + 1), 16);
$content = substr($body, $start, $clen);
$start += $clen + 2;
$e = new WebSocketEvent($etype, $content);
} else {
$e = new WebSocketEvent($typeline);
}
$out[] = $e;
}
return $out;
}
|
[
"public",
"static",
"function",
"decode_websocket_events",
"(",
"$",
"body",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"$",
"start",
"=",
"0",
";",
"while",
"(",
"$",
"start",
"<",
"strlen",
"(",
"$",
"body",
")",
")",
"{",
"$",
"at",
"=",
"strpos",
"(",
"$",
"body",
",",
"\"\\r\\n\"",
",",
"$",
"start",
")",
";",
"if",
"(",
"$",
"at",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'bad format'",
")",
";",
"}",
"$",
"typeline",
"=",
"substr",
"(",
"$",
"body",
",",
"$",
"start",
",",
"$",
"at",
"-",
"$",
"start",
")",
";",
"$",
"start",
"=",
"$",
"at",
"+",
"2",
";",
"$",
"at",
"=",
"strpos",
"(",
"$",
"typeline",
",",
"' '",
")",
";",
"$",
"e",
"=",
"null",
";",
"if",
"(",
"!",
"(",
"$",
"at",
"===",
"false",
")",
")",
"{",
"$",
"etype",
"=",
"substr",
"(",
"$",
"typeline",
",",
"0",
",",
"$",
"at",
")",
";",
"$",
"clen",
"=",
"intval",
"(",
"'0x'",
".",
"substr",
"(",
"$",
"typeline",
",",
"$",
"at",
"+",
"1",
")",
",",
"16",
")",
";",
"$",
"content",
"=",
"substr",
"(",
"$",
"body",
",",
"$",
"start",
",",
"$",
"clen",
")",
";",
"$",
"start",
"+=",
"$",
"clen",
"+",
"2",
";",
"$",
"e",
"=",
"new",
"WebSocketEvent",
"(",
"$",
"etype",
",",
"$",
"content",
")",
";",
"}",
"else",
"{",
"$",
"e",
"=",
"new",
"WebSocketEvent",
"(",
"$",
"typeline",
")",
";",
"}",
"$",
"out",
"[",
"]",
"=",
"$",
"e",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
is raised if the format is invalid.
|
[
"is",
"raised",
"if",
"the",
"format",
"is",
"invalid",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L145-L170
|
227,417
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.encode_websocket_events
|
public static function encode_websocket_events($events)
{
$out = '';
foreach ($events as $event) {
if (!is_null($event->content)) {
$content_length = dechex(strlen($event->content));
$out .= "{$event->type} {$content_length}\r\n" .
"{$event->content}\r\n";
} else {
$out .= "{$event->type}\r\n";
}
}
return $out;
}
|
php
|
public static function encode_websocket_events($events)
{
$out = '';
foreach ($events as $event) {
if (!is_null($event->content)) {
$content_length = dechex(strlen($event->content));
$out .= "{$event->type} {$content_length}\r\n" .
"{$event->content}\r\n";
} else {
$out .= "{$event->type}\r\n";
}
}
return $out;
}
|
[
"public",
"static",
"function",
"encode_websocket_events",
"(",
"$",
"events",
")",
"{",
"$",
"out",
"=",
"''",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"event",
"->",
"content",
")",
")",
"{",
"$",
"content_length",
"=",
"dechex",
"(",
"strlen",
"(",
"$",
"event",
"->",
"content",
")",
")",
";",
"$",
"out",
".=",
"\"{$event->type} {$content_length}\\r\\n\"",
".",
"\"{$event->content}\\r\\n\"",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"\"{$event->type}\\r\\n\"",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] |
when using the WebSocket-over-HTTP protocol.
|
[
"when",
"using",
"the",
"WebSocket",
"-",
"over",
"-",
"HTTP",
"protocol",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L175-L188
|
227,418
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.parse_channels
|
protected static function parse_channels($channels)
{
if ($channels instanceof Channel) {
$channels = array($channels);
} elseif (is_string($channels)) {
$channels = array(new Channel($channels));
}
if (count($channels) == 0) {
throw new \RuntimeException('channels length is 0');
}
return $channels;
}
|
php
|
protected static function parse_channels($channels)
{
if ($channels instanceof Channel) {
$channels = array($channels);
} elseif (is_string($channels)) {
$channels = array(new Channel($channels));
}
if (count($channels) == 0) {
throw new \RuntimeException('channels length is 0');
}
return $channels;
}
|
[
"protected",
"static",
"function",
"parse_channels",
"(",
"$",
"channels",
")",
"{",
"if",
"(",
"$",
"channels",
"instanceof",
"Channel",
")",
"{",
"$",
"channels",
"=",
"array",
"(",
"$",
"channels",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"channels",
")",
")",
"{",
"$",
"channels",
"=",
"array",
"(",
"new",
"Channel",
"(",
"$",
"channels",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"channels",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'channels length is 0'",
")",
";",
"}",
"return",
"$",
"channels",
";",
"}"
] |
Channel instance, or an array of Channel instances.
|
[
"Channel",
"instance",
"or",
"an",
"array",
"of",
"Channel",
"instances",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L207-L218
|
227,419
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.get_hold_channels
|
protected static function get_hold_channels($channels)
{
$ichannels = array();
foreach ($channels as $channel) {
if (is_string($channel)) {
$channel = new Channel($channel);
}
$ichannel = array();
$ichannel['name'] = $channel->name;
if (!is_null($channel->prev_id)) {
$ichannel['prev-id'] = $channel->prev_id;
}
$ichannels[] = $ichannel;
}
return $ichannels;
}
|
php
|
protected static function get_hold_channels($channels)
{
$ichannels = array();
foreach ($channels as $channel) {
if (is_string($channel)) {
$channel = new Channel($channel);
}
$ichannel = array();
$ichannel['name'] = $channel->name;
if (!is_null($channel->prev_id)) {
$ichannel['prev-id'] = $channel->prev_id;
}
$ichannels[] = $ichannel;
}
return $ichannels;
}
|
[
"protected",
"static",
"function",
"get_hold_channels",
"(",
"$",
"channels",
")",
"{",
"$",
"ichannels",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"channels",
"as",
"$",
"channel",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"channel",
")",
")",
"{",
"$",
"channel",
"=",
"new",
"Channel",
"(",
"$",
"channel",
")",
";",
"}",
"$",
"ichannel",
"=",
"array",
"(",
")",
";",
"$",
"ichannel",
"[",
"'name'",
"]",
"=",
"$",
"channel",
"->",
"name",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"channel",
"->",
"prev_id",
")",
")",
"{",
"$",
"ichannel",
"[",
"'prev-id'",
"]",
"=",
"$",
"channel",
"->",
"prev_id",
";",
"}",
"$",
"ichannels",
"[",
"]",
"=",
"$",
"ichannel",
";",
"}",
"return",
"$",
"ichannels",
";",
"}"
] |
GRIP proxy hold instructions.
|
[
"GRIP",
"proxy",
"hold",
"instructions",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L223-L238
|
227,420
|
fanout/php-gripcontrol
|
src/gripcontrol.php
|
GripControl.get_hold_response
|
protected static function get_hold_response($response)
{
$iresponse = null;
if (!is_null($response)) {
if (is_string($response)) {
$response = new Response(null, null, null, $response);
}
$iresponse = array();
if (!is_null($response->code)) {
$iresponse['code'] = $response->code;
}
if (!is_null($response->reason)) {
$iresponse['reason'] = $response->reason;
}
if (!is_null($response->headers) && count($response->headers) > 0) {
$iresponse['headers'] = $response->headers;
}
if (!is_null($response->body)) {
if (Encoding::is_binary_data($response->body)) {
$iresponse['body-bin'] = base64_encode($response->body);
} else {
$iresponse['body'] = $response->body;
}
}
}
return $iresponse;
}
|
php
|
protected static function get_hold_response($response)
{
$iresponse = null;
if (!is_null($response)) {
if (is_string($response)) {
$response = new Response(null, null, null, $response);
}
$iresponse = array();
if (!is_null($response->code)) {
$iresponse['code'] = $response->code;
}
if (!is_null($response->reason)) {
$iresponse['reason'] = $response->reason;
}
if (!is_null($response->headers) && count($response->headers) > 0) {
$iresponse['headers'] = $response->headers;
}
if (!is_null($response->body)) {
if (Encoding::is_binary_data($response->body)) {
$iresponse['body-bin'] = base64_encode($response->body);
} else {
$iresponse['body'] = $response->body;
}
}
}
return $iresponse;
}
|
[
"protected",
"static",
"function",
"get_hold_response",
"(",
"$",
"response",
")",
"{",
"$",
"iresponse",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"response",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"response",
")",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"null",
",",
"null",
",",
"null",
",",
"$",
"response",
")",
";",
"}",
"$",
"iresponse",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"response",
"->",
"code",
")",
")",
"{",
"$",
"iresponse",
"[",
"'code'",
"]",
"=",
"$",
"response",
"->",
"code",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"response",
"->",
"reason",
")",
")",
"{",
"$",
"iresponse",
"[",
"'reason'",
"]",
"=",
"$",
"response",
"->",
"reason",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"response",
"->",
"headers",
")",
"&&",
"count",
"(",
"$",
"response",
"->",
"headers",
")",
">",
"0",
")",
"{",
"$",
"iresponse",
"[",
"'headers'",
"]",
"=",
"$",
"response",
"->",
"headers",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"response",
"->",
"body",
")",
")",
"{",
"if",
"(",
"Encoding",
"::",
"is_binary_data",
"(",
"$",
"response",
"->",
"body",
")",
")",
"{",
"$",
"iresponse",
"[",
"'body-bin'",
"]",
"=",
"base64_encode",
"(",
"$",
"response",
"->",
"body",
")",
";",
"}",
"else",
"{",
"$",
"iresponse",
"[",
"'body'",
"]",
"=",
"$",
"response",
"->",
"body",
";",
"}",
"}",
"}",
"return",
"$",
"iresponse",
";",
"}"
] |
proxy hold instructions.
|
[
"proxy",
"hold",
"instructions",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/gripcontrol.php#L243-L269
|
227,421
|
alphayax/freebox_api_php
|
freebox/api/v3/services/ParentalControl/FilterPlanning.php
|
FilterPlanning.getFromFilterId
|
public function getFromFilterId( $filterId) {
$service = sprintf( self::API_PARENTAL_FILTER_PLANNING, $filterId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResult( models\ParentalControl\FilterPlanning::class);
}
|
php
|
public function getFromFilterId( $filterId) {
$service = sprintf( self::API_PARENTAL_FILTER_PLANNING, $filterId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResult( models\ParentalControl\FilterPlanning::class);
}
|
[
"public",
"function",
"getFromFilterId",
"(",
"$",
"filterId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_PARENTAL_FILTER_PLANNING",
",",
"$",
"filterId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"ParentalControl",
"\\",
"FilterPlanning",
"::",
"class",
")",
";",
"}"
] |
Get the filer planning associated with the given filter id
@param int $filterId
@return models\ParentalControl\FilterPlanning
|
[
"Get",
"the",
"filer",
"planning",
"associated",
"with",
"the",
"given",
"filter",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/ParentalControl/FilterPlanning.php#L19-L25
|
227,422
|
alphayax/freebox_api_php
|
freebox/api/v3/services/ParentalControl/FilterPlanning.php
|
FilterPlanning.setFromFilterId
|
public function setFromFilterId( models\ParentalControl\FilterPlanning $filterPlanning, $filterId) {
$service = sprintf( self::API_PARENTAL_FILTER_PLANNING, $filterId);
$rest = $this->getService( $service);
$rest->PUT( $filterPlanning);
return $rest->getResult( models\ParentalControl\FilterPlanning::class);
}
|
php
|
public function setFromFilterId( models\ParentalControl\FilterPlanning $filterPlanning, $filterId) {
$service = sprintf( self::API_PARENTAL_FILTER_PLANNING, $filterId);
$rest = $this->getService( $service);
$rest->PUT( $filterPlanning);
return $rest->getResult( models\ParentalControl\FilterPlanning::class);
}
|
[
"public",
"function",
"setFromFilterId",
"(",
"models",
"\\",
"ParentalControl",
"\\",
"FilterPlanning",
"$",
"filterPlanning",
",",
"$",
"filterId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_PARENTAL_FILTER_PLANNING",
",",
"$",
"filterId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"filterPlanning",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"ParentalControl",
"\\",
"FilterPlanning",
"::",
"class",
")",
";",
"}"
] |
Update the filer planning associated with the given filter id
@param \alphayax\freebox\api\v3\models\ParentalControl\FilterPlanning $filterPlanning
@param int $filterId
@return \alphayax\freebox\api\v3\models\ParentalControl\FilterPlanning
|
[
"Update",
"the",
"filer",
"planning",
"associated",
"with",
"the",
"given",
"filter",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/ParentalControl/FilterPlanning.php#L33-L39
|
227,423
|
toplan/task-balancer
|
src/TaskBalancer/Driver.php
|
Driver.create
|
public static function create(Task $task, $name, $weight = 1, $backup = false, \Closure $work = null)
{
return new self($task, $name, $weight, $backup, $work);
}
|
php
|
public static function create(Task $task, $name, $weight = 1, $backup = false, \Closure $work = null)
{
return new self($task, $name, $weight, $backup, $work);
}
|
[
"public",
"static",
"function",
"create",
"(",
"Task",
"$",
"task",
",",
"$",
"name",
",",
"$",
"weight",
"=",
"1",
",",
"$",
"backup",
"=",
"false",
",",
"\\",
"Closure",
"$",
"work",
"=",
"null",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"task",
",",
"$",
"name",
",",
"$",
"weight",
",",
"$",
"backup",
",",
"$",
"work",
")",
";",
"}"
] |
create a driver instance.
@param Task $task
@param string $name
@param int $weight
@param \Closure $work
@param bool $backup
@return static
|
[
"create",
"a",
"driver",
"instance",
"."
] |
6ba16aafbf6888de0f0c53ea93dfff844b6ef27f
|
https://github.com/toplan/task-balancer/blob/6ba16aafbf6888de0f0c53ea93dfff844b6ef27f/src/TaskBalancer/Driver.php#L108-L111
|
227,424
|
toplan/task-balancer
|
src/TaskBalancer/Driver.php
|
Driver.run
|
public function run()
{
if (!$this->beforeRun()) {
return;
}
$result = null;
if (is_callable($this->work)) {
$result = call_user_func_array($this->work, [$this, $this->getData()]);
}
return $this->afterRun($result);
}
|
php
|
public function run()
{
if (!$this->beforeRun()) {
return;
}
$result = null;
if (is_callable($this->work)) {
$result = call_user_func_array($this->work, [$this, $this->getData()]);
}
return $this->afterRun($result);
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"beforeRun",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"work",
")",
")",
"{",
"$",
"result",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"work",
",",
"[",
"$",
"this",
",",
"$",
"this",
"->",
"getData",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"afterRun",
"(",
"$",
"result",
")",
";",
"}"
] |
run driver`s work.
@return mixed
|
[
"run",
"driver",
"s",
"work",
"."
] |
6ba16aafbf6888de0f0c53ea93dfff844b6ef27f
|
https://github.com/toplan/task-balancer/blob/6ba16aafbf6888de0f0c53ea93dfff844b6ef27f/src/TaskBalancer/Driver.php#L130-L141
|
227,425
|
toplan/task-balancer
|
src/TaskBalancer/Driver.php
|
Driver.backup
|
public function backup($is = true)
{
$is = (bool) $is;
if ($this->backup === $is) {
return $this;
}
$this->backup = $is;
if ($this->backup) {
$this->task->appendToBackupDrivers($this);
} else {
$this->task->removeFromBackupDrivers($this);
}
return $this;
}
|
php
|
public function backup($is = true)
{
$is = (bool) $is;
if ($this->backup === $is) {
return $this;
}
$this->backup = $is;
if ($this->backup) {
$this->task->appendToBackupDrivers($this);
} else {
$this->task->removeFromBackupDrivers($this);
}
return $this;
}
|
[
"public",
"function",
"backup",
"(",
"$",
"is",
"=",
"true",
")",
"{",
"$",
"is",
"=",
"(",
"bool",
")",
"$",
"is",
";",
"if",
"(",
"$",
"this",
"->",
"backup",
"===",
"$",
"is",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"backup",
"=",
"$",
"is",
";",
"if",
"(",
"$",
"this",
"->",
"backup",
")",
"{",
"$",
"this",
"->",
"task",
"->",
"appendToBackupDrivers",
"(",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"task",
"->",
"removeFromBackupDrivers",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
set current driver to be a backup driver.
@param bool $is
@return $this
|
[
"set",
"current",
"driver",
"to",
"be",
"a",
"backup",
"driver",
"."
] |
6ba16aafbf6888de0f0c53ea93dfff844b6ef27f
|
https://github.com/toplan/task-balancer/blob/6ba16aafbf6888de0f0c53ea93dfff844b6ef27f/src/TaskBalancer/Driver.php#L212-L226
|
227,426
|
toplan/task-balancer
|
src/TaskBalancer/Driver.php
|
Driver.reset
|
public function reset()
{
$args = func_get_args();
extract(self::parseArgs($args));
if ($this->weight !== $weight) {
$this->weight($weight);
}
if ($this->backup !== $backup) {
$this->backup($backup);
}
if (is_callable($work) && $this->work !== $work) {
$this->work($work);
}
return $this;
}
|
php
|
public function reset()
{
$args = func_get_args();
extract(self::parseArgs($args));
if ($this->weight !== $weight) {
$this->weight($weight);
}
if ($this->backup !== $backup) {
$this->backup($backup);
}
if (is_callable($work) && $this->work !== $work) {
$this->work($work);
}
return $this;
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"extract",
"(",
"self",
"::",
"parseArgs",
"(",
"$",
"args",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"weight",
"!==",
"$",
"weight",
")",
"{",
"$",
"this",
"->",
"weight",
"(",
"$",
"weight",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"backup",
"!==",
"$",
"backup",
")",
"{",
"$",
"this",
"->",
"backup",
"(",
"$",
"backup",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"work",
")",
"&&",
"$",
"this",
"->",
"work",
"!==",
"$",
"work",
")",
"{",
"$",
"this",
"->",
"work",
"(",
"$",
"work",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
reset driver's properties.
|
[
"reset",
"driver",
"s",
"properties",
"."
] |
6ba16aafbf6888de0f0c53ea93dfff844b6ef27f
|
https://github.com/toplan/task-balancer/blob/6ba16aafbf6888de0f0c53ea93dfff844b6ef27f/src/TaskBalancer/Driver.php#L245-L260
|
227,427
|
toplan/task-balancer
|
src/TaskBalancer/Driver.php
|
Driver.parseArgs
|
public static function parseArgs(array $args)
{
$result = [
'name' => null,
'work' => null,
'weight' => 1,
'backup' => false,
];
foreach ($args as $arg) {
//find work
if (is_callable($arg)) {
$result['work'] = $arg;
}
//find weight, backup, name
if (is_string($arg) || is_numeric($arg)) {
$arg = preg_replace('/\s+/', ' ', "$arg");
$subArgs = explode(' ', trim($arg));
foreach ($subArgs as $subArg) {
if (preg_match('/^[0-9]+$/', $subArg)) {
$result['weight'] = intval($subArg);
} elseif (preg_match('/(backup)/', strtolower($subArg))) {
$result['backup'] = true;
} else {
$result['name'] = $subArg;
}
}
}
}
return $result;
}
|
php
|
public static function parseArgs(array $args)
{
$result = [
'name' => null,
'work' => null,
'weight' => 1,
'backup' => false,
];
foreach ($args as $arg) {
//find work
if (is_callable($arg)) {
$result['work'] = $arg;
}
//find weight, backup, name
if (is_string($arg) || is_numeric($arg)) {
$arg = preg_replace('/\s+/', ' ', "$arg");
$subArgs = explode(' ', trim($arg));
foreach ($subArgs as $subArg) {
if (preg_match('/^[0-9]+$/', $subArg)) {
$result['weight'] = intval($subArg);
} elseif (preg_match('/(backup)/', strtolower($subArg))) {
$result['backup'] = true;
} else {
$result['name'] = $subArg;
}
}
}
}
return $result;
}
|
[
"public",
"static",
"function",
"parseArgs",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"result",
"=",
"[",
"'name'",
"=>",
"null",
",",
"'work'",
"=>",
"null",
",",
"'weight'",
"=>",
"1",
",",
"'backup'",
"=>",
"false",
",",
"]",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"//find work",
"if",
"(",
"is_callable",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"result",
"[",
"'work'",
"]",
"=",
"$",
"arg",
";",
"}",
"//find weight, backup, name",
"if",
"(",
"is_string",
"(",
"$",
"arg",
")",
"||",
"is_numeric",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"arg",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"\"$arg\"",
")",
";",
"$",
"subArgs",
"=",
"explode",
"(",
"' '",
",",
"trim",
"(",
"$",
"arg",
")",
")",
";",
"foreach",
"(",
"$",
"subArgs",
"as",
"$",
"subArg",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^[0-9]+$/'",
",",
"$",
"subArg",
")",
")",
"{",
"$",
"result",
"[",
"'weight'",
"]",
"=",
"intval",
"(",
"$",
"subArg",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/(backup)/'",
",",
"strtolower",
"(",
"$",
"subArg",
")",
")",
")",
"{",
"$",
"result",
"[",
"'backup'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"'name'",
"]",
"=",
"$",
"subArg",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
parse arguments to driver properties.
@param array $args
@return array
|
[
"parse",
"arguments",
"to",
"driver",
"properties",
"."
] |
6ba16aafbf6888de0f0c53ea93dfff844b6ef27f
|
https://github.com/toplan/task-balancer/blob/6ba16aafbf6888de0f0c53ea93dfff844b6ef27f/src/TaskBalancer/Driver.php#L324-L354
|
227,428
|
jk/RestServer
|
src/JK/RestServer/Utilities.php
|
Utilities.sortByPriority
|
public static function sortByPriority($accept)
{
if ($accept == '') {
return array();
}
$tmp_accept_list = array();
$accepts = explode(',', strtolower($accept));
foreach ($accepts as $pos => $accept) {
$parts = explode(';q=', trim($accept));
$type = $parts[0];
$quality = isset($parts[1]) ? floatval($parts[1]) : 1;
$tmp_accept_list[] = array('type' => $type, 'quality' => $quality);
}
// Attention: $acceptList has to be decorated since all PHP sorting functions aren't stable
// for more information a deeper explamentation of the issue, have a look here:
// @see http://stackoverflow.com/questions/17364127/reference-all-basic-ways-to-sort-arrays-and-data-in-php/17365409#17365409
array_walk($tmp_accept_list, function (&$element, $index) {
$element = array($element, $index); // decorate
});
usort($tmp_accept_list, function ($a, $b) {
// $a[0] and $b[0] contain the primary sort key
// $a[1] and $b[1] contain the secondary sort key
$tmp = strcmp($b[0]['quality'], $a[0]['quality']); // a<=>b swapped, because reveresed sort
if ($tmp != 0) {
return $tmp; // use primary key comparison results
}
return $a[1] - $b[1]; // use secondary key
});
array_walk($tmp_accept_list, function (&$element) {
$element = $element[0];
});
$output = array();
foreach ($tmp_accept_list as $accept_entry) {
$type = $accept_entry['type'];
$quality = $accept_entry['quality'];
$output[$type] = $quality;
}
return $output;
}
|
php
|
public static function sortByPriority($accept)
{
if ($accept == '') {
return array();
}
$tmp_accept_list = array();
$accepts = explode(',', strtolower($accept));
foreach ($accepts as $pos => $accept) {
$parts = explode(';q=', trim($accept));
$type = $parts[0];
$quality = isset($parts[1]) ? floatval($parts[1]) : 1;
$tmp_accept_list[] = array('type' => $type, 'quality' => $quality);
}
// Attention: $acceptList has to be decorated since all PHP sorting functions aren't stable
// for more information a deeper explamentation of the issue, have a look here:
// @see http://stackoverflow.com/questions/17364127/reference-all-basic-ways-to-sort-arrays-and-data-in-php/17365409#17365409
array_walk($tmp_accept_list, function (&$element, $index) {
$element = array($element, $index); // decorate
});
usort($tmp_accept_list, function ($a, $b) {
// $a[0] and $b[0] contain the primary sort key
// $a[1] and $b[1] contain the secondary sort key
$tmp = strcmp($b[0]['quality'], $a[0]['quality']); // a<=>b swapped, because reveresed sort
if ($tmp != 0) {
return $tmp; // use primary key comparison results
}
return $a[1] - $b[1]; // use secondary key
});
array_walk($tmp_accept_list, function (&$element) {
$element = $element[0];
});
$output = array();
foreach ($tmp_accept_list as $accept_entry) {
$type = $accept_entry['type'];
$quality = $accept_entry['quality'];
$output[$type] = $quality;
}
return $output;
}
|
[
"public",
"static",
"function",
"sortByPriority",
"(",
"$",
"accept",
")",
"{",
"if",
"(",
"$",
"accept",
"==",
"''",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"tmp_accept_list",
"=",
"array",
"(",
")",
";",
"$",
"accepts",
"=",
"explode",
"(",
"','",
",",
"strtolower",
"(",
"$",
"accept",
")",
")",
";",
"foreach",
"(",
"$",
"accepts",
"as",
"$",
"pos",
"=>",
"$",
"accept",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"';q='",
",",
"trim",
"(",
"$",
"accept",
")",
")",
";",
"$",
"type",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"quality",
"=",
"isset",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
"?",
"floatval",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
":",
"1",
";",
"$",
"tmp_accept_list",
"[",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'quality'",
"=>",
"$",
"quality",
")",
";",
"}",
"// Attention: $acceptList has to be decorated since all PHP sorting functions aren't stable",
"// for more information a deeper explamentation of the issue, have a look here:",
"// @see http://stackoverflow.com/questions/17364127/reference-all-basic-ways-to-sort-arrays-and-data-in-php/17365409#17365409",
"array_walk",
"(",
"$",
"tmp_accept_list",
",",
"function",
"(",
"&",
"$",
"element",
",",
"$",
"index",
")",
"{",
"$",
"element",
"=",
"array",
"(",
"$",
"element",
",",
"$",
"index",
")",
";",
"// decorate",
"}",
")",
";",
"usort",
"(",
"$",
"tmp_accept_list",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"// $a[0] and $b[0] contain the primary sort key",
"// $a[1] and $b[1] contain the secondary sort key",
"$",
"tmp",
"=",
"strcmp",
"(",
"$",
"b",
"[",
"0",
"]",
"[",
"'quality'",
"]",
",",
"$",
"a",
"[",
"0",
"]",
"[",
"'quality'",
"]",
")",
";",
"// a<=>b swapped, because reveresed sort",
"if",
"(",
"$",
"tmp",
"!=",
"0",
")",
"{",
"return",
"$",
"tmp",
";",
"// use primary key comparison results",
"}",
"return",
"$",
"a",
"[",
"1",
"]",
"-",
"$",
"b",
"[",
"1",
"]",
";",
"// use secondary key",
"}",
")",
";",
"array_walk",
"(",
"$",
"tmp_accept_list",
",",
"function",
"(",
"&",
"$",
"element",
")",
"{",
"$",
"element",
"=",
"$",
"element",
"[",
"0",
"]",
";",
"}",
")",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tmp_accept_list",
"as",
"$",
"accept_entry",
")",
"{",
"$",
"type",
"=",
"$",
"accept_entry",
"[",
"'type'",
"]",
";",
"$",
"quality",
"=",
"$",
"accept_entry",
"[",
"'quality'",
"]",
";",
"$",
"output",
"[",
"$",
"type",
"]",
"=",
"$",
"quality",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Pass any content negotiation header such as Accept,
Accept-Language to break it up and sort the resulting array by
the order of negotiation.
@static
@param string $accept header value
@return array sorted by the priority
|
[
"Pass",
"any",
"content",
"negotiation",
"header",
"such",
"as",
"Accept",
"Accept",
"-",
"Language",
"to",
"break",
"it",
"up",
"and",
"sort",
"the",
"resulting",
"array",
"by",
"the",
"order",
"of",
"negotiation",
"."
] |
477e6a0f0b601008bf96db9767492d5b35637d0b
|
https://github.com/jk/RestServer/blob/477e6a0f0b601008bf96db9767492d5b35637d0b/src/JK/RestServer/Utilities.php#L23-L69
|
227,429
|
jk/RestServer
|
src/JK/RestServer/Utilities.php
|
Utilities.objectToArray
|
public static function objectToArray($data)
{
if (is_object($data)) {
// Gets the properties of the given object
// with get_object_vars function
$data = get_object_vars($data);
}
if (is_array($data)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
$self_name = 'self::' . __FUNCTION__;
return array_map($self_name, $data);
} else {
// Return array
return $data;
}
}
|
php
|
public static function objectToArray($data)
{
if (is_object($data)) {
// Gets the properties of the given object
// with get_object_vars function
$data = get_object_vars($data);
}
if (is_array($data)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
$self_name = 'self::' . __FUNCTION__;
return array_map($self_name, $data);
} else {
// Return array
return $data;
}
}
|
[
"public",
"static",
"function",
"objectToArray",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"// Gets the properties of the given object",
"// with get_object_vars function",
"$",
"data",
"=",
"get_object_vars",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"/*\n * Return array converted to object\n * Using __FUNCTION__ (Magic constant)\n * for recursive call\n */",
"$",
"self_name",
"=",
"'self::'",
".",
"__FUNCTION__",
";",
"return",
"array_map",
"(",
"$",
"self_name",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"// Return array",
"return",
"$",
"data",
";",
"}",
"}"
] |
Converts an object into an array
@param object $data object
@return array Array
|
[
"Converts",
"an",
"object",
"into",
"an",
"array"
] |
477e6a0f0b601008bf96db9767492d5b35637d0b
|
https://github.com/jk/RestServer/blob/477e6a0f0b601008bf96db9767492d5b35637d0b/src/JK/RestServer/Utilities.php#L77-L98
|
227,430
|
jk/RestServer
|
src/JK/RestServer/Utilities.php
|
Utilities.arrayToObject
|
public static function arrayToObject($data)
{
if (is_array($data)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
$self_name = 'self::' . __FUNCTION__;
return (object)array_map($self_name, $data);
} else {
// Return object
return $data;
}
}
|
php
|
public static function arrayToObject($data)
{
if (is_array($data)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
$self_name = 'self::' . __FUNCTION__;
return (object)array_map($self_name, $data);
} else {
// Return object
return $data;
}
}
|
[
"public",
"static",
"function",
"arrayToObject",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"/*\n * Return array converted to object\n * Using __FUNCTION__ (Magic constant)\n * for recursive call\n */",
"$",
"self_name",
"=",
"'self::'",
".",
"__FUNCTION__",
";",
"return",
"(",
"object",
")",
"array_map",
"(",
"$",
"self_name",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"// Return object",
"return",
"$",
"data",
";",
"}",
"}"
] |
Converts an array into an object
@param array|string $data Array data
@return object|string Object
|
[
"Converts",
"an",
"array",
"into",
"an",
"object"
] |
477e6a0f0b601008bf96db9767492d5b35637d0b
|
https://github.com/jk/RestServer/blob/477e6a0f0b601008bf96db9767492d5b35637d0b/src/JK/RestServer/Utilities.php#L106-L121
|
227,431
|
jk/RestServer
|
src/JK/RestServer/Utilities.php
|
Utilities.arrayToXml
|
public static function arrayToXml(array $data)
{
$xml = '';
foreach ($data as $key => $value) {
$tag = (is_numeric($key)) ? 'item' : $key;
$xml = (!empty($xml)) ? $xml : '';
if (is_array($value)) {
$xml .= "<$tag index=\"" . $key . "\">" . self::arrayToXml($value) . "</$tag>";
} else {
$xml .= "<$tag>" . $value . "</$tag>";
}
}
return $xml;
}
|
php
|
public static function arrayToXml(array $data)
{
$xml = '';
foreach ($data as $key => $value) {
$tag = (is_numeric($key)) ? 'item' : $key;
$xml = (!empty($xml)) ? $xml : '';
if (is_array($value)) {
$xml .= "<$tag index=\"" . $key . "\">" . self::arrayToXml($value) . "</$tag>";
} else {
$xml .= "<$tag>" . $value . "</$tag>";
}
}
return $xml;
}
|
[
"public",
"static",
"function",
"arrayToXml",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"xml",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"tag",
"=",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"?",
"'item'",
":",
"$",
"key",
";",
"$",
"xml",
"=",
"(",
"!",
"empty",
"(",
"$",
"xml",
")",
")",
"?",
"$",
"xml",
":",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"xml",
".=",
"\"<$tag index=\\\"\"",
".",
"$",
"key",
".",
"\"\\\">\"",
".",
"self",
"::",
"arrayToXml",
"(",
"$",
"value",
")",
".",
"\"</$tag>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$tag>\"",
".",
"$",
"value",
".",
"\"</$tag>\"",
";",
"}",
"}",
"return",
"$",
"xml",
";",
"}"
] |
Auxiliary method to help converting a PHP array into a XML representation.
This XML representation is one of various possible representation.
@access protected
@param array $data PHP array
@return string XML representation
|
[
"Auxiliary",
"method",
"to",
"help",
"converting",
"a",
"PHP",
"array",
"into",
"a",
"XML",
"representation",
"."
] |
477e6a0f0b601008bf96db9767492d5b35637d0b
|
https://github.com/jk/RestServer/blob/477e6a0f0b601008bf96db9767492d5b35637d0b/src/JK/RestServer/Utilities.php#L132-L147
|
227,432
|
jk/RestServer
|
src/JK/RestServer/Utilities.php
|
Utilities.reflectionClassFromObjectOrClass
|
public static function reflectionClassFromObjectOrClass($object_or_class)
{
$reflection = null;
if (is_object($object_or_class)) {
$reflection = new ReflectionObject($object_or_class);
} elseif (class_exists($object_or_class)) {
$reflection = new ReflectionClass($object_or_class);
}
return $reflection;
}
|
php
|
public static function reflectionClassFromObjectOrClass($object_or_class)
{
$reflection = null;
if (is_object($object_or_class)) {
$reflection = new ReflectionObject($object_or_class);
} elseif (class_exists($object_or_class)) {
$reflection = new ReflectionClass($object_or_class);
}
return $reflection;
}
|
[
"public",
"static",
"function",
"reflectionClassFromObjectOrClass",
"(",
"$",
"object_or_class",
")",
"{",
"$",
"reflection",
"=",
"null",
";",
"if",
"(",
"is_object",
"(",
"$",
"object_or_class",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionObject",
"(",
"$",
"object_or_class",
")",
";",
"}",
"elseif",
"(",
"class_exists",
"(",
"$",
"object_or_class",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"object_or_class",
")",
";",
"}",
"return",
"$",
"reflection",
";",
"}"
] |
Returns a ReflectionClass object from a living instance or a class name
@param object|string $object_or_class Object (instance of a class) or class name
@return ReflectionClass
|
[
"Returns",
"a",
"ReflectionClass",
"object",
"from",
"a",
"living",
"instance",
"or",
"a",
"class",
"name"
] |
477e6a0f0b601008bf96db9767492d5b35637d0b
|
https://github.com/jk/RestServer/blob/477e6a0f0b601008bf96db9767492d5b35637d0b/src/JK/RestServer/Utilities.php#L155-L166
|
227,433
|
codecasts/aws-sdk-php
|
src/S3/BatchDelete.php
|
BatchDelete.fromIterator
|
public static function fromIterator(
AwsClientInterface $client,
$bucket,
\Iterator $iter,
array $options = []
) {
$fn = function (BatchDelete $that) use ($iter) {
return \GuzzleHttp\Promise\coroutine(function () use ($that, $iter) {
foreach ($iter as $obj) {
if ($promise = $that->enqueue($obj)) {
yield $promise;
}
}
});
};
return new self($client, $bucket, $fn, $options);
}
|
php
|
public static function fromIterator(
AwsClientInterface $client,
$bucket,
\Iterator $iter,
array $options = []
) {
$fn = function (BatchDelete $that) use ($iter) {
return \GuzzleHttp\Promise\coroutine(function () use ($that, $iter) {
foreach ($iter as $obj) {
if ($promise = $that->enqueue($obj)) {
yield $promise;
}
}
});
};
return new self($client, $bucket, $fn, $options);
}
|
[
"public",
"static",
"function",
"fromIterator",
"(",
"AwsClientInterface",
"$",
"client",
",",
"$",
"bucket",
",",
"\\",
"Iterator",
"$",
"iter",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"fn",
"=",
"function",
"(",
"BatchDelete",
"$",
"that",
")",
"use",
"(",
"$",
"iter",
")",
"{",
"return",
"\\",
"GuzzleHttp",
"\\",
"Promise",
"\\",
"coroutine",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"that",
",",
"$",
"iter",
")",
"{",
"foreach",
"(",
"$",
"iter",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"promise",
"=",
"$",
"that",
"->",
"enqueue",
"(",
"$",
"obj",
")",
")",
"{",
"yield",
"$",
"promise",
";",
"}",
"}",
"}",
")",
";",
"}",
";",
"return",
"new",
"self",
"(",
"$",
"client",
",",
"$",
"bucket",
",",
"$",
"fn",
",",
"$",
"options",
")",
";",
"}"
] |
Creates a BatchDelete object from an iterator that yields results.
@param AwsClientInterface $client AWS Client to use to execute commands
@param string $bucket Bucket where the objects are stored
@param \Iterator $iter Iterator that yields assoc arrays
@param array $options BatchDelete options
@return BatchDelete
|
[
"Creates",
"a",
"BatchDelete",
"object",
"from",
"an",
"iterator",
"that",
"yields",
"results",
"."
] |
4f22b5a422c8fbebca46de12ac2422e7cb66ec70
|
https://github.com/codecasts/aws-sdk-php/blob/4f22b5a422c8fbebca46de12ac2422e7cb66ec70/src/S3/BatchDelete.php#L96-L113
|
227,434
|
codecasts/aws-sdk-php
|
src/CloudFront/Signer.php
|
Signer.getSignature
|
public function getSignature($resource = null, $expires = null, $policy = null)
{
$signatureHash = [];
if ($policy) {
$policy = preg_replace('/\s/s', '', $policy);
$signatureHash['Policy'] = $this->encode($policy);
} elseif ($resource && $expires) {
$policy = $this->createCannedPolicy($resource, $expires);
$signatureHash['Expires'] = $expires;
} else {
throw new \InvalidArgumentException('Either a policy or a resource'
. ' and an expiration time must be provided.');
}
$signatureHash['Signature'] = $this->encode($this->sign($policy));
$signatureHash['Key-Pair-Id'] = $this->keyPairId;
return $signatureHash;
}
|
php
|
public function getSignature($resource = null, $expires = null, $policy = null)
{
$signatureHash = [];
if ($policy) {
$policy = preg_replace('/\s/s', '', $policy);
$signatureHash['Policy'] = $this->encode($policy);
} elseif ($resource && $expires) {
$policy = $this->createCannedPolicy($resource, $expires);
$signatureHash['Expires'] = $expires;
} else {
throw new \InvalidArgumentException('Either a policy or a resource'
. ' and an expiration time must be provided.');
}
$signatureHash['Signature'] = $this->encode($this->sign($policy));
$signatureHash['Key-Pair-Id'] = $this->keyPairId;
return $signatureHash;
}
|
[
"public",
"function",
"getSignature",
"(",
"$",
"resource",
"=",
"null",
",",
"$",
"expires",
"=",
"null",
",",
"$",
"policy",
"=",
"null",
")",
"{",
"$",
"signatureHash",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"policy",
")",
"{",
"$",
"policy",
"=",
"preg_replace",
"(",
"'/\\s/s'",
",",
"''",
",",
"$",
"policy",
")",
";",
"$",
"signatureHash",
"[",
"'Policy'",
"]",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"policy",
")",
";",
"}",
"elseif",
"(",
"$",
"resource",
"&&",
"$",
"expires",
")",
"{",
"$",
"policy",
"=",
"$",
"this",
"->",
"createCannedPolicy",
"(",
"$",
"resource",
",",
"$",
"expires",
")",
";",
"$",
"signatureHash",
"[",
"'Expires'",
"]",
"=",
"$",
"expires",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Either a policy or a resource'",
".",
"' and an expiration time must be provided.'",
")",
";",
"}",
"$",
"signatureHash",
"[",
"'Signature'",
"]",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"this",
"->",
"sign",
"(",
"$",
"policy",
")",
")",
";",
"$",
"signatureHash",
"[",
"'Key-Pair-Id'",
"]",
"=",
"$",
"this",
"->",
"keyPairId",
";",
"return",
"$",
"signatureHash",
";",
"}"
] |
Create the values used to construct signed URLs and cookies.
@param string $resource The CloudFront resource to which
this signature will grant access.
Not used when a custom policy is
provided.
@param string|integer|null $expires UTC Unix timestamp used when
signing with a canned policy.
Not required when passing a
custom $policy.
@param string $policy JSON policy. Use this option when
creating a signature for a custom
policy.
@return array The values needed to construct a signed URL or cookie
@throws \InvalidArgumentException when not provided either a policy or a
resource and a expires
@link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-cookies.html
|
[
"Create",
"the",
"values",
"used",
"to",
"construct",
"signed",
"URLs",
"and",
"cookies",
"."
] |
4f22b5a422c8fbebca46de12ac2422e7cb66ec70
|
https://github.com/codecasts/aws-sdk-php/blob/4f22b5a422c8fbebca46de12ac2422e7cb66ec70/src/CloudFront/Signer.php#L62-L80
|
227,435
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/FTP.php
|
FTP.getConfiguration
|
public function getConfiguration(){
$rest = $this->getService( self::API_FTP_CONFIG);
$rest->GET();
return $rest->getResult( models\FtpConfig::class);
}
|
php
|
public function getConfiguration(){
$rest = $this->getService( self::API_FTP_CONFIG);
$rest->GET();
return $rest->getResult( models\FtpConfig::class);
}
|
[
"public",
"function",
"getConfiguration",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_FTP_CONFIG",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"FtpConfig",
"::",
"class",
")",
";",
"}"
] |
Get the current FTP configuration
@return models\FtpConfig
|
[
"Get",
"the",
"current",
"FTP",
"configuration"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/FTP.php#L20-L25
|
227,436
|
middlewares/filesystem
|
src/Writer.php
|
Writer.isWritable
|
private function isWritable(ServerRequestInterface $request, ResponseInterface $response): bool
{
if ($request->getMethod() !== 'GET') {
return false;
}
if ($response->getStatusCode() !== 200) {
return false;
}
$cacheControl = $response->getHeaderLine('Cache-Control');
if (stripos($cacheControl, 'no-cache') !== false || stripos($cacheControl, 'no-store') !== false) {
return false;
}
return true;
}
|
php
|
private function isWritable(ServerRequestInterface $request, ResponseInterface $response): bool
{
if ($request->getMethod() !== 'GET') {
return false;
}
if ($response->getStatusCode() !== 200) {
return false;
}
$cacheControl = $response->getHeaderLine('Cache-Control');
if (stripos($cacheControl, 'no-cache') !== false || stripos($cacheControl, 'no-store') !== false) {
return false;
}
return true;
}
|
[
"private",
"function",
"isWritable",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"!==",
"'GET'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cacheControl",
"=",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'Cache-Control'",
")",
";",
"if",
"(",
"stripos",
"(",
"$",
"cacheControl",
",",
"'no-cache'",
")",
"!==",
"false",
"||",
"stripos",
"(",
"$",
"cacheControl",
",",
"'no-store'",
")",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check whether the response is writable or not.
|
[
"Check",
"whether",
"the",
"response",
"is",
"writable",
"or",
"not",
"."
] |
f25168893ca9b0e3d74228b88576099e29892bdd
|
https://github.com/middlewares/filesystem/blob/f25168893ca9b0e3d74228b88576099e29892bdd/src/Writer.php#L69-L86
|
227,437
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/DMZ.php
|
DMZ.getConfiguration
|
public function getConfiguration(){
$rest = $this->getService( self::API_NAT_DMZ);
$rest->GET();
return $rest->getResult( models\NAT\DmzConfig::class);
}
|
php
|
public function getConfiguration(){
$rest = $this->getService( self::API_NAT_DMZ);
$rest->GET();
return $rest->getResult( models\NAT\DmzConfig::class);
}
|
[
"public",
"function",
"getConfiguration",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_DMZ",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"DmzConfig",
"::",
"class",
")",
";",
"}"
] |
Get the current Dmz configuration
@return models\NAT\DmzConfig
|
[
"Get",
"the",
"current",
"Dmz",
"configuration"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/DMZ.php#L20-L25
|
227,438
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/DMZ.php
|
DMZ.setConfiguration
|
public function setConfiguration( models\NAT\DmzConfig $dmzConfig){
$rest = $this->getService( self::API_NAT_DMZ);
$rest->PUT( $dmzConfig);
return $rest->getResult( models\NAT\DmzConfig::class);
}
|
php
|
public function setConfiguration( models\NAT\DmzConfig $dmzConfig){
$rest = $this->getService( self::API_NAT_DMZ);
$rest->PUT( $dmzConfig);
return $rest->getResult( models\NAT\DmzConfig::class);
}
|
[
"public",
"function",
"setConfiguration",
"(",
"models",
"\\",
"NAT",
"\\",
"DmzConfig",
"$",
"dmzConfig",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_DMZ",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"dmzConfig",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"DmzConfig",
"::",
"class",
")",
";",
"}"
] |
Update the current Dmz configuration
@param models\NAT\DmzConfig $dmzConfig
@return models\NAT\DmzConfig
|
[
"Update",
"the",
"current",
"Dmz",
"configuration"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/DMZ.php#L32-L37
|
227,439
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactAddress.php
|
ContactAddress.create
|
public function create( models\Call\ContactAddress $contactAddress){
$rest = $this->getService( self::API_ADDRESS);
$rest->POST( $contactAddress);
return $rest->getResult( models\Call\ContactAddress::class);
}
|
php
|
public function create( models\Call\ContactAddress $contactAddress){
$rest = $this->getService( self::API_ADDRESS);
$rest->POST( $contactAddress);
return $rest->getResult( models\Call\ContactAddress::class);
}
|
[
"public",
"function",
"create",
"(",
"models",
"\\",
"Call",
"\\",
"ContactAddress",
"$",
"contactAddress",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_ADDRESS",
")",
";",
"$",
"rest",
"->",
"POST",
"(",
"$",
"contactAddress",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactAddress",
"::",
"class",
")",
";",
"}"
] |
Add an address
@param models\Call\ContactAddress $contactAddress
@return models\Call\ContactAddress
|
[
"Add",
"an",
"address"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactAddress.php#L32-L37
|
227,440
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactAddress.php
|
ContactAddress.update
|
public function update( models\Call\ContactAddress $contactAddress){
$rest = $this->getService( self::API_ADDRESS . $contactAddress->getId());
$rest->PUT( $contactAddress);
return $rest->getResult( models\Call\ContactAddress::class);
}
|
php
|
public function update( models\Call\ContactAddress $contactAddress){
$rest = $this->getService( self::API_ADDRESS . $contactAddress->getId());
$rest->PUT( $contactAddress);
return $rest->getResult( models\Call\ContactAddress::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"Call",
"\\",
"ContactAddress",
"$",
"contactAddress",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_ADDRESS",
".",
"$",
"contactAddress",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"contactAddress",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactAddress",
"::",
"class",
")",
";",
"}"
] |
Update an address
@param models\Call\ContactAddress $contactAddress
@return models\Call\ContactAddress
|
[
"Update",
"an",
"address"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactAddress.php#L65-L70
|
227,441
|
canax/database
|
src/Database/Database.php
|
Database.setOption
|
public function setOption(string $option, $value) : object
{
$this->options[$option] = $value;
return $this;
}
|
php
|
public function setOption(string $option, $value) : object
{
$this->options[$option] = $value;
return $this;
}
|
[
"public",
"function",
"setOption",
"(",
"string",
"$",
"option",
",",
"$",
"value",
")",
":",
"object",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a single option for configuration and connection details.
@param string $option which to set.
@param mixed $value to set.
@return self
|
[
"Set",
"a",
"single",
"option",
"for",
"configuration",
"and",
"connection",
"details",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L71-L75
|
227,442
|
canax/database
|
src/Database/Database.php
|
Database.connect
|
public function connect() : object
{
if ($this->pdo) {
return $this;
}
if (!isset($this->options["dsn"])) {
throw new Exception("You can not connect, missing dsn.");
}
try {
$this->pdo = new \PDO(
$this->options["dsn"],
$this->options["username"],
$this->options["password"],
$this->options["driver_options"]
);
$this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, $this->options['fetch_mode']);
$this->pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, $this->options['emulate_prepares']);
} catch (\PDOException $e) {
if ($this->options["debug_connect"]) {
throw $e;
}
throw new Exception("Could not connect to database, hiding connection details.");
}
return $this;
}
|
php
|
public function connect() : object
{
if ($this->pdo) {
return $this;
}
if (!isset($this->options["dsn"])) {
throw new Exception("You can not connect, missing dsn.");
}
try {
$this->pdo = new \PDO(
$this->options["dsn"],
$this->options["username"],
$this->options["password"],
$this->options["driver_options"]
);
$this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, $this->options['fetch_mode']);
$this->pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, $this->options['emulate_prepares']);
} catch (\PDOException $e) {
if ($this->options["debug_connect"]) {
throw $e;
}
throw new Exception("Could not connect to database, hiding connection details.");
}
return $this;
}
|
[
"public",
"function",
"connect",
"(",
")",
":",
"object",
"{",
"if",
"(",
"$",
"this",
"->",
"pdo",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"\"dsn\"",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"You can not connect, missing dsn.\"",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"pdo",
"=",
"new",
"\\",
"PDO",
"(",
"$",
"this",
"->",
"options",
"[",
"\"dsn\"",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"\"username\"",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"\"password\"",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"\"driver_options\"",
"]",
")",
";",
"$",
"this",
"->",
"pdo",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_DEFAULT_FETCH_MODE",
",",
"$",
"this",
"->",
"options",
"[",
"'fetch_mode'",
"]",
")",
";",
"$",
"this",
"->",
"pdo",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_EMULATE_PREPARES",
",",
"$",
"this",
"->",
"options",
"[",
"'emulate_prepares'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"\"debug_connect\"",
"]",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"Could not connect to database, hiding connection details.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Connect to the database, allow being called multiple times
but ignore when connection is already made.
@throws \Anax\Database\Exception
@return self
|
[
"Connect",
"to",
"the",
"database",
"allow",
"being",
"called",
"multiple",
"times",
"but",
"ignore",
"when",
"connection",
"is",
"already",
"made",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L87-L114
|
227,443
|
canax/database
|
src/Database/Database.php
|
Database.executeFetchClass
|
public function executeFetchClass(
string $query,
array $params,
string $class
) :? object {
return $this->execute($query, $params)->fetchClass($class);
}
|
php
|
public function executeFetchClass(
string $query,
array $params,
string $class
) :? object {
return $this->execute($query, $params)->fetchClass($class);
}
|
[
"public",
"function",
"executeFetchClass",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"params",
",",
"string",
"$",
"class",
")",
":",
"?",
"object",
"{",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
",",
"$",
"params",
")",
"->",
"fetchClass",
"(",
"$",
"class",
")",
";",
"}"
] |
Execute a select-query with arguments and insert the results into
a new object of the class.
@param string $query the SQL statement
@param array $params the params array
@param string $class the class to create an object of and insert into
@return null|object with resultset, null when no resultset
|
[
"Execute",
"a",
"select",
"-",
"query",
"with",
"arguments",
"and",
"insert",
"the",
"results",
"into",
"a",
"new",
"object",
"of",
"the",
"class",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L198-L204
|
227,444
|
canax/database
|
src/Database/Database.php
|
Database.executeFetchInto
|
public function executeFetchInto(
string $query,
array $params,
object $object
) :? object {
return $this->execute($query, $params)->fetchInto($object);
}
|
php
|
public function executeFetchInto(
string $query,
array $params,
object $object
) :? object {
return $this->execute($query, $params)->fetchInto($object);
}
|
[
"public",
"function",
"executeFetchInto",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"params",
",",
"object",
"$",
"object",
")",
":",
"?",
"object",
"{",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
",",
"$",
"params",
")",
"->",
"fetchInto",
"(",
"$",
"object",
")",
";",
"}"
] |
Execute a select-query with arguments and insert the results into
an existing object.
@param string $query the SQL statement
@param array $params the params array
@param object $object the existing object to insert into
@return null|object with resultset or null when no match
|
[
"Execute",
"a",
"select",
"-",
"query",
"with",
"arguments",
"and",
"insert",
"the",
"results",
"into",
"an",
"existing",
"object",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L218-L224
|
227,445
|
canax/database
|
src/Database/Database.php
|
Database.fetchClass
|
public function fetchClass(string $classname) :? object
{
$this->stmt->setFetchMode(\PDO::FETCH_CLASS, $classname);
return $this->fetch();
}
|
php
|
public function fetchClass(string $classname) :? object
{
$this->stmt->setFetchMode(\PDO::FETCH_CLASS, $classname);
return $this->fetch();
}
|
[
"public",
"function",
"fetchClass",
"(",
"string",
"$",
"classname",
")",
":",
"?",
"object",
"{",
"$",
"this",
"->",
"stmt",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"classname",
")",
";",
"return",
"$",
"this",
"->",
"fetch",
"(",
")",
";",
"}"
] |
Fetch one resultset as a new object from this class.
@param string $classname which type of object to instantiate.
@return null|object with details, null when no resultset
|
[
"Fetch",
"one",
"resultset",
"as",
"a",
"new",
"object",
"from",
"this",
"class",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L260-L264
|
227,446
|
canax/database
|
src/Database/Database.php
|
Database.fetchAllClass
|
public function fetchAllClass(string $classname) : array
{
$this->stmt->setFetchMode(\PDO::FETCH_CLASS, $classname);
return $this->stmt->fetchAll();
}
|
php
|
public function fetchAllClass(string $classname) : array
{
$this->stmt->setFetchMode(\PDO::FETCH_CLASS, $classname);
return $this->stmt->fetchAll();
}
|
[
"public",
"function",
"fetchAllClass",
"(",
"string",
"$",
"classname",
")",
":",
"array",
"{",
"$",
"this",
"->",
"stmt",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"classname",
")",
";",
"return",
"$",
"this",
"->",
"stmt",
"->",
"fetchAll",
"(",
")",
";",
"}"
] |
Fetch all rows as the resultset instantiated as new objects from
this class.
@param string $classname which type of object to instantiate.
@return array with resultset containing objects of $classname.
|
[
"Fetch",
"all",
"rows",
"as",
"the",
"resultset",
"instantiated",
"as",
"new",
"objects",
"from",
"this",
"class",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L276-L280
|
227,447
|
canax/database
|
src/Database/Database.php
|
Database.createException
|
protected function createException(
string $msg,
string $query,
array $params
) : void {
throw new Exception(
$msg
. "<br><br>SQL ("
. substr_count($query, "?")
. " params):<br><pre>$query</pre><br>PARAMS ("
. count($params)
. "):<br><pre>"
. implode($params, "\n")
. "</pre>"
);
}
|
php
|
protected function createException(
string $msg,
string $query,
array $params
) : void {
throw new Exception(
$msg
. "<br><br>SQL ("
. substr_count($query, "?")
. " params):<br><pre>$query</pre><br>PARAMS ("
. count($params)
. "):<br><pre>"
. implode($params, "\n")
. "</pre>"
);
}
|
[
"protected",
"function",
"createException",
"(",
"string",
"$",
"msg",
",",
"string",
"$",
"query",
",",
"array",
"$",
"params",
")",
":",
"void",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"msg",
".",
"\"<br><br>SQL (\"",
".",
"substr_count",
"(",
"$",
"query",
",",
"\"?\"",
")",
".",
"\" params):<br><pre>$query</pre><br>PARAMS (\"",
".",
"count",
"(",
"$",
"params",
")",
".",
"\"):<br><pre>\"",
".",
"implode",
"(",
"$",
"params",
",",
"\"\\n\"",
")",
".",
"\"</pre>\"",
")",
";",
"}"
] |
Throw exception with detailed message.
@param string $msg detailed error message from PDO
@param string $query query to execute
@param array $params to match ? in statement
@throws Anax\Database\Exception
@return void
|
[
"Throw",
"exception",
"with",
"detailed",
"message",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L348-L363
|
227,448
|
canax/database
|
src/Database/Database.php
|
Database.pdoException
|
protected function pdoException(string $query, array $params) : void
{
$this->createException($this->pdo->errorInfo()[2], $query, $params);
}
|
php
|
protected function pdoException(string $query, array $params) : void
{
$this->createException($this->pdo->errorInfo()[2], $query, $params);
}
|
[
"protected",
"function",
"pdoException",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"params",
")",
":",
"void",
"{",
"$",
"this",
"->",
"createException",
"(",
"$",
"this",
"->",
"pdo",
"->",
"errorInfo",
"(",
")",
"[",
"2",
"]",
",",
"$",
"query",
",",
"$",
"params",
")",
";",
"}"
] |
Throw exception when pdo failed using detailed message.
@param string $query query to execute
@param array $params to match ? in statement
@return void
|
[
"Throw",
"exception",
"when",
"pdo",
"failed",
"using",
"detailed",
"message",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L375-L378
|
227,449
|
canax/database
|
src/Database/Database.php
|
Database.statementException
|
protected function statementException(string $query, array $params) : void
{
$this->createException($this->stmt->errorInfo()[2], $query, $params);
}
|
php
|
protected function statementException(string $query, array $params) : void
{
$this->createException($this->stmt->errorInfo()[2], $query, $params);
}
|
[
"protected",
"function",
"statementException",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"params",
")",
":",
"void",
"{",
"$",
"this",
"->",
"createException",
"(",
"$",
"this",
"->",
"stmt",
"->",
"errorInfo",
"(",
")",
"[",
"2",
"]",
",",
"$",
"query",
",",
"$",
"params",
")",
";",
"}"
] |
Throw exception when statement failed using detailed message.
@param string $query query to execute
@param array $params to match ? in statement
@return void
|
[
"Throw",
"exception",
"when",
"statement",
"failed",
"using",
"detailed",
"message",
"."
] |
ea78a5b3eee8998be0e5a401247b9455ff240fb4
|
https://github.com/canax/database/blob/ea78a5b3eee8998be0e5a401247b9455ff240fb4/src/Database/Database.php#L390-L393
|
227,450
|
allebb/distical
|
src/Calculator.php
|
Calculator.between
|
public function between(LatLong $pointA, LatLong $pointB)
{
if (!empty($this->points)) {
throw new \RuntimeException('The between() method can only be called when it is the first set or co-ordinates.');
}
$this->addPoint($pointA);
$this->addPoint($pointB);
return $this;
}
|
php
|
public function between(LatLong $pointA, LatLong $pointB)
{
if (!empty($this->points)) {
throw new \RuntimeException('The between() method can only be called when it is the first set or co-ordinates.');
}
$this->addPoint($pointA);
$this->addPoint($pointB);
return $this;
}
|
[
"public",
"function",
"between",
"(",
"LatLong",
"$",
"pointA",
",",
"LatLong",
"$",
"pointB",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"points",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The between() method can only be called when it is the first set or co-ordinates.'",
")",
";",
"}",
"$",
"this",
"->",
"addPoint",
"(",
"$",
"pointA",
")",
";",
"$",
"this",
"->",
"addPoint",
"(",
"$",
"pointB",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Helper method to get distance between two points.
@param LatLong $pointA Point A (eg. Departure point)
@param LatLong $pointB Point B (eg. Arrival point)
@return \Ballen\Distical\Calculator
@throws \RuntimeException
|
[
"Helper",
"method",
"to",
"get",
"distance",
"between",
"two",
"points",
"."
] |
34f65f70517ccfa6bdc8c68fa5a463fedc59f6cd
|
https://github.com/allebb/distical/blob/34f65f70517ccfa6bdc8c68fa5a463fedc59f6cd/src/Calculator.php#L84-L92
|
227,451
|
allebb/distical
|
src/Calculator.php
|
Calculator.calculate
|
private function calculate()
{
if (count($this->points) < 2) {
throw new \RuntimeException('There must be two or more points (co-ordinates) before a calculation can be performed.');
}
$total = 0;
foreach ($this->points as $point) {
if (isset($previous)) {
$total += $this->distanceBetweenPoints($previous, $point);
}
$previous = $point;
}
return $total;
}
|
php
|
private function calculate()
{
if (count($this->points) < 2) {
throw new \RuntimeException('There must be two or more points (co-ordinates) before a calculation can be performed.');
}
$total = 0;
foreach ($this->points as $point) {
if (isset($previous)) {
$total += $this->distanceBetweenPoints($previous, $point);
}
$previous = $point;
}
return $total;
}
|
[
"private",
"function",
"calculate",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"points",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'There must be two or more points (co-ordinates) before a calculation can be performed.'",
")",
";",
"}",
"$",
"total",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"points",
"as",
"$",
"point",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"previous",
")",
")",
"{",
"$",
"total",
"+=",
"$",
"this",
"->",
"distanceBetweenPoints",
"(",
"$",
"previous",
",",
"$",
"point",
")",
";",
"}",
"$",
"previous",
"=",
"$",
"point",
";",
"}",
"return",
"$",
"total",
";",
"}"
] |
Calculates the distance between each of the points.
@return double Distance in kilometres.
|
[
"Calculates",
"the",
"distance",
"between",
"each",
"of",
"the",
"points",
"."
] |
34f65f70517ccfa6bdc8c68fa5a463fedc59f6cd
|
https://github.com/allebb/distical/blob/34f65f70517ccfa6bdc8c68fa5a463fedc59f6cd/src/Calculator.php#L118-L131
|
227,452
|
brucepc/sum-up
|
src/OAuth/AccessToken.php
|
AccessToken.canAccess
|
public function canAccess(string $scope)
{
$scopes = func_get_args();
$diff = array_diff($scopes, $this->scope);
return count($diff)>0;
}
|
php
|
public function canAccess(string $scope)
{
$scopes = func_get_args();
$diff = array_diff($scopes, $this->scope);
return count($diff)>0;
}
|
[
"public",
"function",
"canAccess",
"(",
"string",
"$",
"scope",
")",
"{",
"$",
"scopes",
"=",
"func_get_args",
"(",
")",
";",
"$",
"diff",
"=",
"array_diff",
"(",
"$",
"scopes",
",",
"$",
"this",
"->",
"scope",
")",
";",
"return",
"count",
"(",
"$",
"diff",
")",
">",
"0",
";",
"}"
] |
Check if token can access one or more scope
@param string $scope[,$scope[,$scope[,...]]]
@return boolean
|
[
"Check",
"if",
"token",
"can",
"access",
"one",
"or",
"more",
"scope"
] |
4b9b046b6c629000b74dc762a96cb24208dc758e
|
https://github.com/brucepc/sum-up/blob/4b9b046b6c629000b74dc762a96cb24208dc758e/src/OAuth/AccessToken.php#L90-L95
|
227,453
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Storage/Disk.php
|
Disk.getAll
|
public function getAll(){
$rest = $this->getService( self::API_STORAGE_DISK);
$rest->GET();
return $rest->getResultAsArray( models\Storage\StorageDisk::class);
}
|
php
|
public function getAll(){
$rest = $this->getService( self::API_STORAGE_DISK);
$rest->GET();
return $rest->getResultAsArray( models\Storage\StorageDisk::class);
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_STORAGE_DISK",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Storage",
"\\",
"StorageDisk",
"::",
"class",
")",
";",
"}"
] |
Get the list of disks
@throws \Exception
@return models\Storage\StorageDisk[]
|
[
"Get",
"the",
"list",
"of",
"disks"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Storage/Disk.php#L21-L26
|
227,454
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Storage/Disk.php
|
Disk.getFromId
|
public function getFromId( $diskId){
$rest = $this->getService( self::API_STORAGE_DISK . $diskId);
$rest->GET();
return $rest->getResult( models\Storage\StorageDisk::class);
}
|
php
|
public function getFromId( $diskId){
$rest = $this->getService( self::API_STORAGE_DISK . $diskId);
$rest->GET();
return $rest->getResult( models\Storage\StorageDisk::class);
}
|
[
"public",
"function",
"getFromId",
"(",
"$",
"diskId",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_STORAGE_DISK",
".",
"$",
"diskId",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Storage",
"\\",
"StorageDisk",
"::",
"class",
")",
";",
"}"
] |
Get a given disk info
@param $diskId
@return \alphayax\freebox\api\v3\models\Storage\StorageDisk
|
[
"Get",
"a",
"given",
"disk",
"info"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Storage/Disk.php#L33-L38
|
227,455
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Storage/Disk.php
|
Disk.update
|
public function update( models\Storage\StorageDisk $storageDisk){
$rest = $this->getService( self::API_STORAGE_DISK . $storageDisk->getId());
$rest->PUT( $storageDisk);
return $rest->getResult( models\Storage\StorageDisk::class);
}
|
php
|
public function update( models\Storage\StorageDisk $storageDisk){
$rest = $this->getService( self::API_STORAGE_DISK . $storageDisk->getId());
$rest->PUT( $storageDisk);
return $rest->getResult( models\Storage\StorageDisk::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"Storage",
"\\",
"StorageDisk",
"$",
"storageDisk",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_STORAGE_DISK",
".",
"$",
"storageDisk",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"storageDisk",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Storage",
"\\",
"StorageDisk",
"::",
"class",
")",
";",
"}"
] |
Update a disk state
@param \alphayax\freebox\api\v3\models\Storage\StorageDisk $storageDisk
@return \alphayax\freebox\api\v3\models\Storage\StorageDisk
|
[
"Update",
"a",
"disk",
"state"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Storage/Disk.php#L45-L50
|
227,456
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Storage/Disk.php
|
Disk.format
|
public function format( models\Storage\StorageDisk $storageDisk, $label, $fsType, $tableType){
$rest = $this->getService( self::API_STORAGE_DISK . $storageDisk->getId());
$rest->PUT([
'label' => $label,
'fs_type' => $fsType,
'table_type' => $tableType,
]);
return $rest->getSuccess();
}
|
php
|
public function format( models\Storage\StorageDisk $storageDisk, $label, $fsType, $tableType){
$rest = $this->getService( self::API_STORAGE_DISK . $storageDisk->getId());
$rest->PUT([
'label' => $label,
'fs_type' => $fsType,
'table_type' => $tableType,
]);
return $rest->getSuccess();
}
|
[
"public",
"function",
"format",
"(",
"models",
"\\",
"Storage",
"\\",
"StorageDisk",
"$",
"storageDisk",
",",
"$",
"label",
",",
"$",
"fsType",
",",
"$",
"tableType",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_STORAGE_DISK",
".",
"$",
"storageDisk",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"[",
"'label'",
"=>",
"$",
"label",
",",
"'fs_type'",
"=>",
"$",
"fsType",
",",
"'table_type'",
"=>",
"$",
"tableType",
",",
"]",
")",
";",
"return",
"$",
"rest",
"->",
"getSuccess",
"(",
")",
";",
"}"
] |
Format the disk with the given id
There will be one partition using all the available space on disk. All previous data will be lost.
Parameters will be ignored if you format the Freebox internal disk
@param \alphayax\freebox\api\v3\models\Storage\StorageDisk $storageDisk
@param string $label
@param string $fsType
@param string $tableType
@see symbols\Storage\DiskPartition\FsType
@see symbols\Storage\StorageDisk\TableType
@return bool
|
[
"Format",
"the",
"disk",
"with",
"the",
"given",
"id",
"There",
"will",
"be",
"one",
"partition",
"using",
"all",
"the",
"available",
"space",
"on",
"disk",
".",
"All",
"previous",
"data",
"will",
"be",
"lost",
".",
"Parameters",
"will",
"be",
"ignored",
"if",
"you",
"format",
"the",
"Freebox",
"internal",
"disk"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Storage/Disk.php#L64-L73
|
227,457
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.createBatch
|
public function createBatch(EntityInterface $entity)
{
if (is_null($this->putBatch)) {
$this->putBatch = WriteRequestBatch::factory($this->dynamoDb);
}
$this->putBatch->add(new PutRequest(Item::fromArray($entity->getArrayCopy()), $this->getEntityTable($entity)));
}
|
php
|
public function createBatch(EntityInterface $entity)
{
if (is_null($this->putBatch)) {
$this->putBatch = WriteRequestBatch::factory($this->dynamoDb);
}
$this->putBatch->add(new PutRequest(Item::fromArray($entity->getArrayCopy()), $this->getEntityTable($entity)));
}
|
[
"public",
"function",
"createBatch",
"(",
"EntityInterface",
"$",
"entity",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"putBatch",
")",
")",
"{",
"$",
"this",
"->",
"putBatch",
"=",
"WriteRequestBatch",
"::",
"factory",
"(",
"$",
"this",
"->",
"dynamoDb",
")",
";",
"}",
"$",
"this",
"->",
"putBatch",
"->",
"add",
"(",
"new",
"PutRequest",
"(",
"Item",
"::",
"fromArray",
"(",
"$",
"entity",
"->",
"getArrayCopy",
"(",
")",
")",
",",
"$",
"this",
"->",
"getEntityTable",
"(",
"$",
"entity",
")",
")",
")",
";",
"}"
] |
Add entity to the batch creation
@param EntityInterface $entity
@throws \Aws\DynamoDb\Exception\DynamoDBException
|
[
"Add",
"entity",
"to",
"the",
"batch",
"creation"
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L270-L276
|
227,458
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.deleteBatch
|
public function deleteBatch(EntityInterface $entity)
{
if (is_null($this->deleteBatch)) {
$this->deleteBatch = WriteRequestBatch::factory($this->dynamoDb);
}
$this->deleteBatch->add(new DeleteRequest($this->formatKeyCondition($entity), $this->getEntityTable($entity)));
}
|
php
|
public function deleteBatch(EntityInterface $entity)
{
if (is_null($this->deleteBatch)) {
$this->deleteBatch = WriteRequestBatch::factory($this->dynamoDb);
}
$this->deleteBatch->add(new DeleteRequest($this->formatKeyCondition($entity), $this->getEntityTable($entity)));
}
|
[
"public",
"function",
"deleteBatch",
"(",
"EntityInterface",
"$",
"entity",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"deleteBatch",
")",
")",
"{",
"$",
"this",
"->",
"deleteBatch",
"=",
"WriteRequestBatch",
"::",
"factory",
"(",
"$",
"this",
"->",
"dynamoDb",
")",
";",
"}",
"$",
"this",
"->",
"deleteBatch",
"->",
"add",
"(",
"new",
"DeleteRequest",
"(",
"$",
"this",
"->",
"formatKeyCondition",
"(",
"$",
"entity",
")",
",",
"$",
"this",
"->",
"getEntityTable",
"(",
"$",
"entity",
")",
")",
")",
";",
"}"
] |
Add entity to the batch deletion
@param EntityInterface $entity
@throws \Aws\DynamoDb\Exception\DynamoDBException
|
[
"Add",
"entity",
"to",
"the",
"batch",
"deletion"
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L283-L289
|
227,459
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.setEntityArguments
|
public function setEntityArguments($entityClass, array $arguments)
{
$this->entityArguments[$this->getEntityClass($entityClass)] = $arguments;
return $this;
}
|
php
|
public function setEntityArguments($entityClass, array $arguments)
{
$this->entityArguments[$this->getEntityClass($entityClass)] = $arguments;
return $this;
}
|
[
"public",
"function",
"setEntityArguments",
"(",
"$",
"entityClass",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"this",
"->",
"entityArguments",
"[",
"$",
"this",
"->",
"getEntityClass",
"(",
"$",
"entityClass",
")",
"]",
"=",
"$",
"arguments",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the additional arguments used to instantiate an entity.
@param string $entityClass
@param array $arguments
@return \Cpliakas\DynamoDb\ODM\DocumentManager
|
[
"Set",
"the",
"additional",
"arguments",
"used",
"to",
"instantiate",
"an",
"entity",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L383-L387
|
227,460
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.getEntityClass
|
protected function getEntityClass($entityClass)
{
if (!isset($this->entityClasses[$entityClass])) {
$found = class_exists($entityClass);
if ($found) {
$reflection = new \ReflectionClass($entityClass);
$fqcn = '\\' . $reflection->getName();
} elseif (strpos('\\', $entityClass) !== 0) {
foreach ($this->entityNamespaces as $namespace) {
$fqcn = '\\' . trim($namespace, '\\') . '\\' . $entityClass;
if (class_exists($fqcn)) {
$found = true;
break;
}
}
}
if (!$found) {
throw new \DomainException('Entity class not found: ' . $entityClass);
}
$this->entityClasses[$entityClass] = $fqcn;
}
return $this->entityClasses[$entityClass];
}
|
php
|
protected function getEntityClass($entityClass)
{
if (!isset($this->entityClasses[$entityClass])) {
$found = class_exists($entityClass);
if ($found) {
$reflection = new \ReflectionClass($entityClass);
$fqcn = '\\' . $reflection->getName();
} elseif (strpos('\\', $entityClass) !== 0) {
foreach ($this->entityNamespaces as $namespace) {
$fqcn = '\\' . trim($namespace, '\\') . '\\' . $entityClass;
if (class_exists($fqcn)) {
$found = true;
break;
}
}
}
if (!$found) {
throw new \DomainException('Entity class not found: ' . $entityClass);
}
$this->entityClasses[$entityClass] = $fqcn;
}
return $this->entityClasses[$entityClass];
}
|
[
"protected",
"function",
"getEntityClass",
"(",
"$",
"entityClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityClasses",
"[",
"$",
"entityClass",
"]",
")",
")",
"{",
"$",
"found",
"=",
"class_exists",
"(",
"$",
"entityClass",
")",
";",
"if",
"(",
"$",
"found",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entityClass",
")",
";",
"$",
"fqcn",
"=",
"'\\\\'",
".",
"$",
"reflection",
"->",
"getName",
"(",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"'\\\\'",
",",
"$",
"entityClass",
")",
"!==",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entityNamespaces",
"as",
"$",
"namespace",
")",
"{",
"$",
"fqcn",
"=",
"'\\\\'",
".",
"trim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
".",
"'\\\\'",
".",
"$",
"entityClass",
";",
"if",
"(",
"class_exists",
"(",
"$",
"fqcn",
")",
")",
"{",
"$",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Entity class not found: '",
".",
"$",
"entityClass",
")",
";",
"}",
"$",
"this",
"->",
"entityClasses",
"[",
"$",
"entityClass",
"]",
"=",
"$",
"fqcn",
";",
"}",
"return",
"$",
"this",
"->",
"entityClasses",
"[",
"$",
"entityClass",
"]",
";",
"}"
] |
Returns the entity's fully qualified class name.
@param string $entityClass
@throws \DomainException
|
[
"Returns",
"the",
"entity",
"s",
"fully",
"qualified",
"class",
"name",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L434-L461
|
227,461
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.getEntityTable
|
protected function getEntityTable($entity)
{
if (!$entity instanceof EntityInterface) {
$entity = $this->getEntityClass($entity);
}
return $this->tablePrefix . $entity::getTable() . $this->tableSuffix;
}
|
php
|
protected function getEntityTable($entity)
{
if (!$entity instanceof EntityInterface) {
$entity = $this->getEntityClass($entity);
}
return $this->tablePrefix . $entity::getTable() . $this->tableSuffix;
}
|
[
"protected",
"function",
"getEntityTable",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getEntityClass",
"(",
"$",
"entity",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tablePrefix",
".",
"$",
"entity",
"::",
"getTable",
"(",
")",
".",
"$",
"this",
"->",
"tableSuffix",
";",
"}"
] |
Returns the entity's table name as defined in DynamoDB.
@param string $entityClass
@return \Cpliakas\DynamoDb\ODM\EntityInterface|string
@throws \DomainException
|
[
"Returns",
"the",
"entity",
"s",
"table",
"name",
"as",
"defined",
"in",
"DynamoDB",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L472-L478
|
227,462
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.initEntity
|
protected function initEntity($entityClass, $primaryKey)
{
$primaryKey = (array) $primaryKey;
if (!isset($primaryKey[0])) {
throw new \InvalidArgumentException('Hash key is required');
}
$entity = $this->entityFactory($entityClass)->setHashKey($primaryKey[0]);
if (isset($primaryKey[1])) {
$entity->setRangeKey($primaryKey[1]);
}
return $entity;
}
|
php
|
protected function initEntity($entityClass, $primaryKey)
{
$primaryKey = (array) $primaryKey;
if (!isset($primaryKey[0])) {
throw new \InvalidArgumentException('Hash key is required');
}
$entity = $this->entityFactory($entityClass)->setHashKey($primaryKey[0]);
if (isset($primaryKey[1])) {
$entity->setRangeKey($primaryKey[1]);
}
return $entity;
}
|
[
"protected",
"function",
"initEntity",
"(",
"$",
"entityClass",
",",
"$",
"primaryKey",
")",
"{",
"$",
"primaryKey",
"=",
"(",
"array",
")",
"$",
"primaryKey",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"primaryKey",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Hash key is required'",
")",
";",
"}",
"$",
"entity",
"=",
"$",
"this",
"->",
"entityFactory",
"(",
"$",
"entityClass",
")",
"->",
"setHashKey",
"(",
"$",
"primaryKey",
"[",
"0",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"primaryKey",
"[",
"1",
"]",
")",
")",
"{",
"$",
"entity",
"->",
"setRangeKey",
"(",
"$",
"primaryKey",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"entity",
";",
"}"
] |
Initializes an entity with a primary and range key.
@param string $entityClass
@param mixed $primaryKey
@return \Cpliakas\DynamoDb\ODM\EntityInterface
@throw new \InvalidArgumentException
|
[
"Initializes",
"an",
"entity",
"with",
"a",
"primary",
"and",
"range",
"key",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L490-L504
|
227,463
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.formatPutItemCommandOptions
|
protected function formatPutItemCommandOptions(EntityInterface $entity, $mustExist)
{
$attributes = array($entity::getHashKeyAttribute() => $entity->getHashKey());
$rangeKeyAttribute = $entity::getRangeKeyAttribute();
if ($rangeKeyAttribute) {
$attributes[$rangeKeyAttribute] = $entity->getRangeKey();
}
$commandOptions = array(
'TableName' => $this->getEntityTable($entity),
'Item' => $this->formatEntityAttributes($entity),
'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
);
// Adds conditions based on whether items is being added or updated.
if ($entity::enforceEntityIntegrity()) {
if ($mustExist) {
$entityClass = get_class($entity);
$commandOptions['Expected'] = $this->formatAttributes($entityClass, $attributes, Attribute::FORMAT_EXPECTED);
} else {
foreach ($attributes as $attribute => $value) {
$commandOptions['Expected'][$attribute] = array('Exists' => false);
}
}
}
return $commandOptions;
}
|
php
|
protected function formatPutItemCommandOptions(EntityInterface $entity, $mustExist)
{
$attributes = array($entity::getHashKeyAttribute() => $entity->getHashKey());
$rangeKeyAttribute = $entity::getRangeKeyAttribute();
if ($rangeKeyAttribute) {
$attributes[$rangeKeyAttribute] = $entity->getRangeKey();
}
$commandOptions = array(
'TableName' => $this->getEntityTable($entity),
'Item' => $this->formatEntityAttributes($entity),
'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
);
// Adds conditions based on whether items is being added or updated.
if ($entity::enforceEntityIntegrity()) {
if ($mustExist) {
$entityClass = get_class($entity);
$commandOptions['Expected'] = $this->formatAttributes($entityClass, $attributes, Attribute::FORMAT_EXPECTED);
} else {
foreach ($attributes as $attribute => $value) {
$commandOptions['Expected'][$attribute] = array('Exists' => false);
}
}
}
return $commandOptions;
}
|
[
"protected",
"function",
"formatPutItemCommandOptions",
"(",
"EntityInterface",
"$",
"entity",
",",
"$",
"mustExist",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"$",
"entity",
"::",
"getHashKeyAttribute",
"(",
")",
"=>",
"$",
"entity",
"->",
"getHashKey",
"(",
")",
")",
";",
"$",
"rangeKeyAttribute",
"=",
"$",
"entity",
"::",
"getRangeKeyAttribute",
"(",
")",
";",
"if",
"(",
"$",
"rangeKeyAttribute",
")",
"{",
"$",
"attributes",
"[",
"$",
"rangeKeyAttribute",
"]",
"=",
"$",
"entity",
"->",
"getRangeKey",
"(",
")",
";",
"}",
"$",
"commandOptions",
"=",
"array",
"(",
"'TableName'",
"=>",
"$",
"this",
"->",
"getEntityTable",
"(",
"$",
"entity",
")",
",",
"'Item'",
"=>",
"$",
"this",
"->",
"formatEntityAttributes",
"(",
"$",
"entity",
")",
",",
"'ReturnConsumedCapacity'",
"=>",
"$",
"this",
"->",
"returnConsumedCapacity",
",",
")",
";",
"// Adds conditions based on whether items is being added or updated.",
"if",
"(",
"$",
"entity",
"::",
"enforceEntityIntegrity",
"(",
")",
")",
"{",
"if",
"(",
"$",
"mustExist",
")",
"{",
"$",
"entityClass",
"=",
"get_class",
"(",
"$",
"entity",
")",
";",
"$",
"commandOptions",
"[",
"'Expected'",
"]",
"=",
"$",
"this",
"->",
"formatAttributes",
"(",
"$",
"entityClass",
",",
"$",
"attributes",
",",
"Attribute",
"::",
"FORMAT_EXPECTED",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"$",
"commandOptions",
"[",
"'Expected'",
"]",
"[",
"$",
"attribute",
"]",
"=",
"array",
"(",
"'Exists'",
"=>",
"false",
")",
";",
"}",
"}",
"}",
"return",
"$",
"commandOptions",
";",
"}"
] |
Returns baseline options for putItem commands.
@param \Cpliakas\DynamoDb\ODM\EntityInterface $entity
@param bool $exists
@return array
@throws \Aws\DynamoDb\Exception\DynamoDBException
@see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_putItem
|
[
"Returns",
"baseline",
"options",
"for",
"putItem",
"commands",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L518-L545
|
227,464
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.formatEntityAttributes
|
protected function formatEntityAttributes(EntityInterface $entity, $format = Attribute::FORMAT_PUT)
{
return $this->formatAttributes(get_class($entity), $entity->getAttributes());
}
|
php
|
protected function formatEntityAttributes(EntityInterface $entity, $format = Attribute::FORMAT_PUT)
{
return $this->formatAttributes(get_class($entity), $entity->getAttributes());
}
|
[
"protected",
"function",
"formatEntityAttributes",
"(",
"EntityInterface",
"$",
"entity",
",",
"$",
"format",
"=",
"Attribute",
"::",
"FORMAT_PUT",
")",
"{",
"return",
"$",
"this",
"->",
"formatAttributes",
"(",
"get_class",
"(",
"$",
"entity",
")",
",",
"$",
"entity",
"->",
"getAttributes",
"(",
")",
")",
";",
"}"
] |
Formats an entity's attributes to the SDK's native data structure.
@param \Cpliakas\DynamoDb\ODM\EntityInterface $entity
@param string $format
@return array
|
[
"Formats",
"an",
"entity",
"s",
"attributes",
"to",
"the",
"SDK",
"s",
"native",
"data",
"structure",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L555-L558
|
227,465
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.formatAttributes
|
protected function formatAttributes($entityClass, array $attributes, $format = Attribute::FORMAT_PUT)
{
$entityClass = $this->getEntityClass($entityClass);
$formatted = array();
$mappings = $entityClass::getDataTypeMappings();
foreach ($attributes as $attribute => $value) {
if (isset($mappings[$attribute])) {
$dataType = $mappings[$attribute];
if (Attribute::FORMAT_PUT == $format) {
$formatted[$attribute] = array($dataType => $value);
} else {
$formatted[$attribute] = array('Value' => array($dataType => $value));
}
} else {
$formatted[$attribute] = Attribute::factory($value)->getFormatted($format);
}
}
return $formatted;
}
|
php
|
protected function formatAttributes($entityClass, array $attributes, $format = Attribute::FORMAT_PUT)
{
$entityClass = $this->getEntityClass($entityClass);
$formatted = array();
$mappings = $entityClass::getDataTypeMappings();
foreach ($attributes as $attribute => $value) {
if (isset($mappings[$attribute])) {
$dataType = $mappings[$attribute];
if (Attribute::FORMAT_PUT == $format) {
$formatted[$attribute] = array($dataType => $value);
} else {
$formatted[$attribute] = array('Value' => array($dataType => $value));
}
} else {
$formatted[$attribute] = Attribute::factory($value)->getFormatted($format);
}
}
return $formatted;
}
|
[
"protected",
"function",
"formatAttributes",
"(",
"$",
"entityClass",
",",
"array",
"$",
"attributes",
",",
"$",
"format",
"=",
"Attribute",
"::",
"FORMAT_PUT",
")",
"{",
"$",
"entityClass",
"=",
"$",
"this",
"->",
"getEntityClass",
"(",
"$",
"entityClass",
")",
";",
"$",
"formatted",
"=",
"array",
"(",
")",
";",
"$",
"mappings",
"=",
"$",
"entityClass",
"::",
"getDataTypeMappings",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"mappings",
"[",
"$",
"attribute",
"]",
")",
")",
"{",
"$",
"dataType",
"=",
"$",
"mappings",
"[",
"$",
"attribute",
"]",
";",
"if",
"(",
"Attribute",
"::",
"FORMAT_PUT",
"==",
"$",
"format",
")",
"{",
"$",
"formatted",
"[",
"$",
"attribute",
"]",
"=",
"array",
"(",
"$",
"dataType",
"=>",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"formatted",
"[",
"$",
"attribute",
"]",
"=",
"array",
"(",
"'Value'",
"=>",
"array",
"(",
"$",
"dataType",
"=>",
"$",
"value",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"formatted",
"[",
"$",
"attribute",
"]",
"=",
"Attribute",
"::",
"factory",
"(",
"$",
"value",
")",
"->",
"getFormatted",
"(",
"$",
"format",
")",
";",
"}",
"}",
"return",
"$",
"formatted",
";",
"}"
] |
Formats an array of attributes to the SDK's native data structure.
@param string $entityClass
@param array $attributes
@param string $format
@return array
@throws \InvalidArgumentException
@see \Aws\DynamoDb\DynamoDbClient::formatAttributes()
|
[
"Formats",
"an",
"array",
"of",
"attributes",
"to",
"the",
"SDK",
"s",
"native",
"data",
"structure",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L573-L593
|
227,466
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.formatConditions
|
protected function formatConditions($entityClass, ConditionsInterface $conditions)
{
$rendered = array();
foreach ($conditions->getConditions() as $attribute => $condition) {
$rendered[$attribute] = array(
'ComparisonOperator' => $condition['operator'],
);
if (isset($condition['values'])) {
$rendered[$attribute]['AttributeValueList'] = $this->formatAttributes($entityClass, $condition['values']);
}
}
return $rendered;
}
|
php
|
protected function formatConditions($entityClass, ConditionsInterface $conditions)
{
$rendered = array();
foreach ($conditions->getConditions() as $attribute => $condition) {
$rendered[$attribute] = array(
'ComparisonOperator' => $condition['operator'],
);
if (isset($condition['values'])) {
$rendered[$attribute]['AttributeValueList'] = $this->formatAttributes($entityClass, $condition['values']);
}
}
return $rendered;
}
|
[
"protected",
"function",
"formatConditions",
"(",
"$",
"entityClass",
",",
"ConditionsInterface",
"$",
"conditions",
")",
"{",
"$",
"rendered",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"conditions",
"->",
"getConditions",
"(",
")",
"as",
"$",
"attribute",
"=>",
"$",
"condition",
")",
"{",
"$",
"rendered",
"[",
"$",
"attribute",
"]",
"=",
"array",
"(",
"'ComparisonOperator'",
"=>",
"$",
"condition",
"[",
"'operator'",
"]",
",",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"condition",
"[",
"'values'",
"]",
")",
")",
"{",
"$",
"rendered",
"[",
"$",
"attribute",
"]",
"[",
"'AttributeValueList'",
"]",
"=",
"$",
"this",
"->",
"formatAttributes",
"(",
"$",
"entityClass",
",",
"$",
"condition",
"[",
"'values'",
"]",
")",
";",
"}",
"}",
"return",
"$",
"rendered",
";",
"}"
] |
Renders the key conditions.
@param \Cpliakas\DynamoDb\ODM\CommandConditionsInterface $conditions
@return array
|
[
"Renders",
"the",
"key",
"conditions",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L621-L633
|
227,467
|
cpliakas/dynamo-db-odm
|
src/DocumentManager.php
|
DocumentManager.executeSearchCommand
|
protected function executeSearchCommand($entityClass, $commandOptions, $command, $optionKey)
{
if ($commandOptions instanceof ConditionsInterface) {
$commandOptions = array(
$optionKey => $this->formatConditions($entityClass, $commandOptions)
) + $commandOptions->getOptions();
} elseif (!is_array($commandOptions)) {
throw new \InvalidArgumentException('Expecting command options to be an array or instance of \Cpliakas\DynamoDb\ODM\KeyConditionsInterface');
}
$commandOptions['TableName'] = $this->getEntityTable($entityClass);
$commandOptions += array(
'ConsistentRead' => $this->consistentRead,
'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
);
$command = strtolower($command);
$eventNamePrefix = 'dynamo_db.search.';
$this->dispatchSearchRequestEvent($eventNamePrefix . 'pre_' . $command, $entityClass);
$iterator = $this->dynamoDb->getIterator($command, $commandOptions);
$this->dispatchSearchResponseEvent($eventNamePrefix . 'post_' . $command, $entityClass, $iterator);
$entities = array();
foreach ($iterator as $item) {
$data = array();
foreach ($item as $attribute => $value) {
$data[$attribute] = current($value);
}
$entities[] = $this->entityFactory($entityClass, $data);
}
return $entities;
}
|
php
|
protected function executeSearchCommand($entityClass, $commandOptions, $command, $optionKey)
{
if ($commandOptions instanceof ConditionsInterface) {
$commandOptions = array(
$optionKey => $this->formatConditions($entityClass, $commandOptions)
) + $commandOptions->getOptions();
} elseif (!is_array($commandOptions)) {
throw new \InvalidArgumentException('Expecting command options to be an array or instance of \Cpliakas\DynamoDb\ODM\KeyConditionsInterface');
}
$commandOptions['TableName'] = $this->getEntityTable($entityClass);
$commandOptions += array(
'ConsistentRead' => $this->consistentRead,
'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
);
$command = strtolower($command);
$eventNamePrefix = 'dynamo_db.search.';
$this->dispatchSearchRequestEvent($eventNamePrefix . 'pre_' . $command, $entityClass);
$iterator = $this->dynamoDb->getIterator($command, $commandOptions);
$this->dispatchSearchResponseEvent($eventNamePrefix . 'post_' . $command, $entityClass, $iterator);
$entities = array();
foreach ($iterator as $item) {
$data = array();
foreach ($item as $attribute => $value) {
$data[$attribute] = current($value);
}
$entities[] = $this->entityFactory($entityClass, $data);
}
return $entities;
}
|
[
"protected",
"function",
"executeSearchCommand",
"(",
"$",
"entityClass",
",",
"$",
"commandOptions",
",",
"$",
"command",
",",
"$",
"optionKey",
")",
"{",
"if",
"(",
"$",
"commandOptions",
"instanceof",
"ConditionsInterface",
")",
"{",
"$",
"commandOptions",
"=",
"array",
"(",
"$",
"optionKey",
"=>",
"$",
"this",
"->",
"formatConditions",
"(",
"$",
"entityClass",
",",
"$",
"commandOptions",
")",
")",
"+",
"$",
"commandOptions",
"->",
"getOptions",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"commandOptions",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expecting command options to be an array or instance of \\Cpliakas\\DynamoDb\\ODM\\KeyConditionsInterface'",
")",
";",
"}",
"$",
"commandOptions",
"[",
"'TableName'",
"]",
"=",
"$",
"this",
"->",
"getEntityTable",
"(",
"$",
"entityClass",
")",
";",
"$",
"commandOptions",
"+=",
"array",
"(",
"'ConsistentRead'",
"=>",
"$",
"this",
"->",
"consistentRead",
",",
"'ReturnConsumedCapacity'",
"=>",
"$",
"this",
"->",
"returnConsumedCapacity",
",",
")",
";",
"$",
"command",
"=",
"strtolower",
"(",
"$",
"command",
")",
";",
"$",
"eventNamePrefix",
"=",
"'dynamo_db.search.'",
";",
"$",
"this",
"->",
"dispatchSearchRequestEvent",
"(",
"$",
"eventNamePrefix",
".",
"'pre_'",
".",
"$",
"command",
",",
"$",
"entityClass",
")",
";",
"$",
"iterator",
"=",
"$",
"this",
"->",
"dynamoDb",
"->",
"getIterator",
"(",
"$",
"command",
",",
"$",
"commandOptions",
")",
";",
"$",
"this",
"->",
"dispatchSearchResponseEvent",
"(",
"$",
"eventNamePrefix",
".",
"'post_'",
".",
"$",
"command",
",",
"$",
"entityClass",
",",
"$",
"iterator",
")",
";",
"$",
"entities",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"item",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"item",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"attribute",
"]",
"=",
"current",
"(",
"$",
"value",
")",
";",
"}",
"$",
"entities",
"[",
"]",
"=",
"$",
"this",
"->",
"entityFactory",
"(",
"$",
"entityClass",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"entities",
";",
"}"
] |
Executes a scan or query command.
@param string $entityClass
@param array|\Cpliakas\DynamoDb\ODM\KeyConditionsInterface $options
@param string $command
@param string $optionKey
@return \Cpliakas\DynamoDb\ODM\EntityInterface[]
@throws \InvalidArgumentException
@throws \Aws\DynamoDb\Exception\DynamoDBException
|
[
"Executes",
"a",
"scan",
"or",
"query",
"command",
"."
] |
a9599e1b87a959a159145f3ac843e02ee2006d42
|
https://github.com/cpliakas/dynamo-db-odm/blob/a9599e1b87a959a159145f3ac843e02ee2006d42/src/DocumentManager.php#L648-L681
|
227,468
|
brucepc/sum-up
|
src/Context.php
|
Context.loadContextFromFile
|
public static function loadContextFromFile(string $filePath): ContextInterface
{
if(!file_exists($filePath)){
throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath);
}
$contents = file_get_contents($filePath);
$context_array = json_decode($contents, true);
if($context_array === null){
throw new Exception\MalformedJsonException('JSON sintax error.');
}
return new self($context_array);
}
|
php
|
public static function loadContextFromFile(string $filePath): ContextInterface
{
if(!file_exists($filePath)){
throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath);
}
$contents = file_get_contents($filePath);
$context_array = json_decode($contents, true);
if($context_array === null){
throw new Exception\MalformedJsonException('JSON sintax error.');
}
return new self($context_array);
}
|
[
"public",
"static",
"function",
"loadContextFromFile",
"(",
"string",
"$",
"filePath",
")",
":",
"ContextInterface",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"FileNotFoundException",
"(",
"'Context file not found: '",
".",
"$",
"filePath",
",",
"404",
",",
"null",
",",
"$",
"filePath",
")",
";",
"}",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"filePath",
")",
";",
"$",
"context_array",
"=",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
";",
"if",
"(",
"$",
"context_array",
"===",
"null",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"MalformedJsonException",
"(",
"'JSON sintax error.'",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"context_array",
")",
";",
"}"
] |
Load Context From file
the file must have only json context inside.
@param string $filePath
@return Context
|
[
"Load",
"Context",
"From",
"file",
"the",
"file",
"must",
"have",
"only",
"json",
"context",
"inside",
"."
] |
4b9b046b6c629000b74dc762a96cb24208dc758e
|
https://github.com/brucepc/sum-up/blob/4b9b046b6c629000b74dc762a96cb24208dc758e/src/Context.php#L82-L96
|
227,469
|
brucepc/sum-up
|
src/Context.php
|
Context.getContextData
|
public function getContextData(): Array
{
return [
'id' => $this->getId(),
'name' => $this->getName(),
'client_id' => $this->getClientId(),
'client_secret' => $this->getClientSecret(),
'application_type' => $this->getApplicationType(),
'redirect_uris' => $this->getRedirectUris(),
'cors_uris' => $this->getCorsUris()
];
}
|
php
|
public function getContextData(): Array
{
return [
'id' => $this->getId(),
'name' => $this->getName(),
'client_id' => $this->getClientId(),
'client_secret' => $this->getClientSecret(),
'application_type' => $this->getApplicationType(),
'redirect_uris' => $this->getRedirectUris(),
'cors_uris' => $this->getCorsUris()
];
}
|
[
"public",
"function",
"getContextData",
"(",
")",
":",
"Array",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'client_id'",
"=>",
"$",
"this",
"->",
"getClientId",
"(",
")",
",",
"'client_secret'",
"=>",
"$",
"this",
"->",
"getClientSecret",
"(",
")",
",",
"'application_type'",
"=>",
"$",
"this",
"->",
"getApplicationType",
"(",
")",
",",
"'redirect_uris'",
"=>",
"$",
"this",
"->",
"getRedirectUris",
"(",
")",
",",
"'cors_uris'",
"=>",
"$",
"this",
"->",
"getCorsUris",
"(",
")",
"]",
";",
"}"
] |
Get context data as array
@return Array
|
[
"Get",
"context",
"data",
"as",
"array"
] |
4b9b046b6c629000b74dc762a96cb24208dc758e
|
https://github.com/brucepc/sum-up/blob/4b9b046b6c629000b74dc762a96cb24208dc758e/src/Context.php#L103-L114
|
227,470
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/Freeplug.php
|
Freeplug.getNetworks
|
public function getNetworks(){
$rest = $this->getService( self::API_FREEPLUG);
$rest->GET();
return $rest->getResultAsArray( models\Freeplug\FreeplugNetwork::class);
}
|
php
|
public function getNetworks(){
$rest = $this->getService( self::API_FREEPLUG);
$rest->GET();
return $rest->getResultAsArray( models\Freeplug\FreeplugNetwork::class);
}
|
[
"public",
"function",
"getNetworks",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_FREEPLUG",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Freeplug",
"\\",
"FreeplugNetwork",
"::",
"class",
")",
";",
"}"
] |
Get the freeplug networks information
@throws \Exception
@return models\Freeplug\FreeplugNetwork[]
|
[
"Get",
"the",
"freeplug",
"networks",
"information"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/Freeplug.php#L21-L26
|
227,471
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/Freeplug.php
|
Freeplug.getFromId
|
public function getFromId( $FreeplugId){
$rest = $this->getService( self::API_FREEPLUG . $FreeplugId . DIRECTORY_SEPARATOR);
$rest->GET();
return $rest->getResult( models\Freeplug\Freeplug::class);
}
|
php
|
public function getFromId( $FreeplugId){
$rest = $this->getService( self::API_FREEPLUG . $FreeplugId . DIRECTORY_SEPARATOR);
$rest->GET();
return $rest->getResult( models\Freeplug\Freeplug::class);
}
|
[
"public",
"function",
"getFromId",
"(",
"$",
"FreeplugId",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_FREEPLUG",
".",
"$",
"FreeplugId",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Freeplug",
"\\",
"Freeplug",
"::",
"class",
")",
";",
"}"
] |
Get a particular Freeplug information
@param $FreeplugId
@return models\Freeplug\Freeplug
|
[
"Get",
"a",
"particular",
"Freeplug",
"information"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/Freeplug.php#L33-L38
|
227,472
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/Freeplug.php
|
Freeplug.resetFromId
|
public function resetFromId( $FreeplugId){
$Service = sprintf( self::API_FREEPLUG_RESET, $FreeplugId);
$rest = $this->getService( $Service);
$rest->POST();
return $rest->getSuccess();
}
|
php
|
public function resetFromId( $FreeplugId){
$Service = sprintf( self::API_FREEPLUG_RESET, $FreeplugId);
$rest = $this->getService( $Service);
$rest->POST();
return $rest->getSuccess();
}
|
[
"public",
"function",
"resetFromId",
"(",
"$",
"FreeplugId",
")",
"{",
"$",
"Service",
"=",
"sprintf",
"(",
"self",
"::",
"API_FREEPLUG_RESET",
",",
"$",
"FreeplugId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"Service",
")",
";",
"$",
"rest",
"->",
"POST",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getSuccess",
"(",
")",
";",
"}"
] |
Reset a Freeplug
@param $FreeplugId
@return models\Freeplug\FreeplugNetwork
|
[
"Reset",
"a",
"Freeplug"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/Freeplug.php#L45-L51
|
227,473
|
codecasts/aws-sdk-php
|
src/S3/S3Client.php
|
S3Client.getEncodingTypeMiddleware
|
private function getEncodingTypeMiddleware()
{
return static function (callable $handler) {
return function (Command $command, $request = null) use ($handler) {
$autoSet = false;
if ($command->getName() === 'ListObjects'
&& empty($command['EncodingType'])
) {
$command['EncodingType'] = 'url';
$autoSet = true;
}
return $handler($command, $request)
->then(function (ResultInterface $result) use ($autoSet) {
if ($result['EncodingType'] === 'url' && $autoSet) {
static $topLevel = [
'Delimiter',
'Marker',
'NextMarker',
'Prefix',
];
static $nested = [
['Contents', 'Key'],
['CommonPrefixes', 'Prefix'],
];
foreach ($topLevel as $key) {
if (isset($result[$key])) {
$result[$key] = urldecode($result[$key]);
}
}
foreach ($nested as $steps) {
if (isset($result[$steps[0]])) {
foreach ($result[$steps[0]] as &$part) {
if (isset($part[$steps[1]])) {
$part[$steps[1]]
= urldecode($part[$steps[1]]);
}
}
}
}
}
return $result;
});
};
};
}
|
php
|
private function getEncodingTypeMiddleware()
{
return static function (callable $handler) {
return function (Command $command, $request = null) use ($handler) {
$autoSet = false;
if ($command->getName() === 'ListObjects'
&& empty($command['EncodingType'])
) {
$command['EncodingType'] = 'url';
$autoSet = true;
}
return $handler($command, $request)
->then(function (ResultInterface $result) use ($autoSet) {
if ($result['EncodingType'] === 'url' && $autoSet) {
static $topLevel = [
'Delimiter',
'Marker',
'NextMarker',
'Prefix',
];
static $nested = [
['Contents', 'Key'],
['CommonPrefixes', 'Prefix'],
];
foreach ($topLevel as $key) {
if (isset($result[$key])) {
$result[$key] = urldecode($result[$key]);
}
}
foreach ($nested as $steps) {
if (isset($result[$steps[0]])) {
foreach ($result[$steps[0]] as &$part) {
if (isset($part[$steps[1]])) {
$part[$steps[1]]
= urldecode($part[$steps[1]]);
}
}
}
}
}
return $result;
});
};
};
}
|
[
"private",
"function",
"getEncodingTypeMiddleware",
"(",
")",
"{",
"return",
"static",
"function",
"(",
"callable",
"$",
"handler",
")",
"{",
"return",
"function",
"(",
"Command",
"$",
"command",
",",
"$",
"request",
"=",
"null",
")",
"use",
"(",
"$",
"handler",
")",
"{",
"$",
"autoSet",
"=",
"false",
";",
"if",
"(",
"$",
"command",
"->",
"getName",
"(",
")",
"===",
"'ListObjects'",
"&&",
"empty",
"(",
"$",
"command",
"[",
"'EncodingType'",
"]",
")",
")",
"{",
"$",
"command",
"[",
"'EncodingType'",
"]",
"=",
"'url'",
";",
"$",
"autoSet",
"=",
"true",
";",
"}",
"return",
"$",
"handler",
"(",
"$",
"command",
",",
"$",
"request",
")",
"->",
"then",
"(",
"function",
"(",
"ResultInterface",
"$",
"result",
")",
"use",
"(",
"$",
"autoSet",
")",
"{",
"if",
"(",
"$",
"result",
"[",
"'EncodingType'",
"]",
"===",
"'url'",
"&&",
"$",
"autoSet",
")",
"{",
"static",
"$",
"topLevel",
"=",
"[",
"'Delimiter'",
",",
"'Marker'",
",",
"'NextMarker'",
",",
"'Prefix'",
",",
"]",
";",
"static",
"$",
"nested",
"=",
"[",
"[",
"'Contents'",
",",
"'Key'",
"]",
",",
"[",
"'CommonPrefixes'",
",",
"'Prefix'",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"topLevel",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"urldecode",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"nested",
"as",
"$",
"steps",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"steps",
"[",
"0",
"]",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"result",
"[",
"$",
"steps",
"[",
"0",
"]",
"]",
"as",
"&",
"$",
"part",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"part",
"[",
"$",
"steps",
"[",
"1",
"]",
"]",
")",
")",
"{",
"$",
"part",
"[",
"$",
"steps",
"[",
"1",
"]",
"]",
"=",
"urldecode",
"(",
"$",
"part",
"[",
"$",
"steps",
"[",
"1",
"]",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}",
")",
";",
"}",
";",
"}",
";",
"}"
] |
Provides a middleware that autopopulates the EncodingType parameter on
ListObjects commands.
@return \Closure
|
[
"Provides",
"a",
"middleware",
"that",
"autopopulates",
"the",
"EncodingType",
"parameter",
"on",
"ListObjects",
"commands",
"."
] |
4f22b5a422c8fbebca46de12ac2422e7cb66ec70
|
https://github.com/codecasts/aws-sdk-php/blob/4f22b5a422c8fbebca46de12ac2422e7cb66ec70/src/S3/S3Client.php#L365-L413
|
227,474
|
phossa2/uuid
|
src/Uuid/Traits/UtilityTrait.php
|
UtilityTrait.convertBase
|
protected static function convertBase(
/*# string */ $input,
/*# string */ $fromBase,
/*# string */ $toBase
)/*# : string */ {
if ($fromBase === $toBase) {
return $input;
} elseif ($fromBase === self::BASE10) {
return static::fromBase10($input, $toBase);
} elseif ($toBase === self::BASE10) {
return static::toBase10($input, $fromBase);
} else {
return static::fromBase10(static::toBase10($input, $fromBase), $toBase);
}
}
|
php
|
protected static function convertBase(
/*# string */ $input,
/*# string */ $fromBase,
/*# string */ $toBase
)/*# : string */ {
if ($fromBase === $toBase) {
return $input;
} elseif ($fromBase === self::BASE10) {
return static::fromBase10($input, $toBase);
} elseif ($toBase === self::BASE10) {
return static::toBase10($input, $fromBase);
} else {
return static::fromBase10(static::toBase10($input, $fromBase), $toBase);
}
}
|
[
"protected",
"static",
"function",
"convertBase",
"(",
"/*# string */",
"$",
"input",
",",
"/*# string */",
"$",
"fromBase",
",",
"/*# string */",
"$",
"toBase",
")",
"/*# : string */",
"{",
"if",
"(",
"$",
"fromBase",
"===",
"$",
"toBase",
")",
"{",
"return",
"$",
"input",
";",
"}",
"elseif",
"(",
"$",
"fromBase",
"===",
"self",
"::",
"BASE10",
")",
"{",
"return",
"static",
"::",
"fromBase10",
"(",
"$",
"input",
",",
"$",
"toBase",
")",
";",
"}",
"elseif",
"(",
"$",
"toBase",
"===",
"self",
"::",
"BASE10",
")",
"{",
"return",
"static",
"::",
"toBase10",
"(",
"$",
"input",
",",
"$",
"fromBase",
")",
";",
"}",
"else",
"{",
"return",
"static",
"::",
"fromBase10",
"(",
"static",
"::",
"toBase10",
"(",
"$",
"input",
",",
"$",
"fromBase",
")",
",",
"$",
"toBase",
")",
";",
"}",
"}"
] |
Convert numerical string between bases
@param string $input
@param string $fromBase
@param string $toBase
@return string
@access protected
@static
|
[
"Convert",
"numerical",
"string",
"between",
"bases"
] |
3b6aa326e15c444683bee645c1cbffbc6c421659
|
https://github.com/phossa2/uuid/blob/3b6aa326e15c444683bee645c1cbffbc6c421659/src/Uuid/Traits/UtilityTrait.php#L118-L132
|
227,475
|
phossa2/uuid
|
src/Uuid/Traits/UtilityTrait.php
|
UtilityTrait.toBase10
|
protected static function toBase10(
/*# string */ $input,
/*# string */ $fromBase
)/*# string */ {
$len = strlen($fromBase);
$res = '0';
foreach (str_split($input) as $char) {
$res = bcadd((int) strpos($fromBase, $char), bcmul($res, $len));
}
return $res;
}
|
php
|
protected static function toBase10(
/*# string */ $input,
/*# string */ $fromBase
)/*# string */ {
$len = strlen($fromBase);
$res = '0';
foreach (str_split($input) as $char) {
$res = bcadd((int) strpos($fromBase, $char), bcmul($res, $len));
}
return $res;
}
|
[
"protected",
"static",
"function",
"toBase10",
"(",
"/*# string */",
"$",
"input",
",",
"/*# string */",
"$",
"fromBase",
")",
"/*# string */",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"fromBase",
")",
";",
"$",
"res",
"=",
"'0'",
";",
"foreach",
"(",
"str_split",
"(",
"$",
"input",
")",
"as",
"$",
"char",
")",
"{",
"$",
"res",
"=",
"bcadd",
"(",
"(",
"int",
")",
"strpos",
"(",
"$",
"fromBase",
",",
"$",
"char",
")",
",",
"bcmul",
"(",
"$",
"res",
",",
"$",
"len",
")",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Convert to decimal string
@param string $input
@param string $fromBase
@return string
@access protected
|
[
"Convert",
"to",
"decimal",
"string"
] |
3b6aa326e15c444683bee645c1cbffbc6c421659
|
https://github.com/phossa2/uuid/blob/3b6aa326e15c444683bee645c1cbffbc6c421659/src/Uuid/Traits/UtilityTrait.php#L142-L152
|
227,476
|
phossa2/uuid
|
src/Uuid/Traits/UtilityTrait.php
|
UtilityTrait.fromBase10
|
protected static function fromBase10(
/*# string */ $input,
/*# string */ $toBase
)/*# string */ {
$len = strlen($toBase);
$res = '';
do {
$digit = bcmod($input, $len);
$res = $toBase[(int) $digit] . $res;
$input = bcdiv($input, $len, 0);
} while ($input != '0');
return $res;
}
|
php
|
protected static function fromBase10(
/*# string */ $input,
/*# string */ $toBase
)/*# string */ {
$len = strlen($toBase);
$res = '';
do {
$digit = bcmod($input, $len);
$res = $toBase[(int) $digit] . $res;
$input = bcdiv($input, $len, 0);
} while ($input != '0');
return $res;
}
|
[
"protected",
"static",
"function",
"fromBase10",
"(",
"/*# string */",
"$",
"input",
",",
"/*# string */",
"$",
"toBase",
")",
"/*# string */",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"toBase",
")",
";",
"$",
"res",
"=",
"''",
";",
"do",
"{",
"$",
"digit",
"=",
"bcmod",
"(",
"$",
"input",
",",
"$",
"len",
")",
";",
"$",
"res",
"=",
"$",
"toBase",
"[",
"(",
"int",
")",
"$",
"digit",
"]",
".",
"$",
"res",
";",
"$",
"input",
"=",
"bcdiv",
"(",
"$",
"input",
",",
"$",
"len",
",",
"0",
")",
";",
"}",
"while",
"(",
"$",
"input",
"!=",
"'0'",
")",
";",
"return",
"$",
"res",
";",
"}"
] |
Convert from decimal string
@param string $input
@param string $toBase
@return string
@access protected
|
[
"Convert",
"from",
"decimal",
"string"
] |
3b6aa326e15c444683bee645c1cbffbc6c421659
|
https://github.com/phossa2/uuid/blob/3b6aa326e15c444683bee645c1cbffbc6c421659/src/Uuid/Traits/UtilityTrait.php#L162-L174
|
227,477
|
phossa2/uuid
|
src/Uuid/Traits/UtilityTrait.php
|
UtilityTrait.getTimestamp
|
protected function getTimestamp()/*# : string */
{
$num = bcadd(
bcmul((microtime(true) - strtotime(static::$epoch)), 100000000),
$this->getSequence() % 10000
);
return substr('00' . static::fromBase10($num, self::BASE16), -15);
}
|
php
|
protected function getTimestamp()/*# : string */
{
$num = bcadd(
bcmul((microtime(true) - strtotime(static::$epoch)), 100000000),
$this->getSequence() % 10000
);
return substr('00' . static::fromBase10($num, self::BASE16), -15);
}
|
[
"protected",
"function",
"getTimestamp",
"(",
")",
"/*# : string */",
"{",
"$",
"num",
"=",
"bcadd",
"(",
"bcmul",
"(",
"(",
"microtime",
"(",
"true",
")",
"-",
"strtotime",
"(",
"static",
"::",
"$",
"epoch",
")",
")",
",",
"100000000",
")",
",",
"$",
"this",
"->",
"getSequence",
"(",
")",
"%",
"10000",
")",
";",
"return",
"substr",
"(",
"'00'",
".",
"static",
"::",
"fromBase10",
"(",
"$",
"num",
",",
"self",
"::",
"BASE16",
")",
",",
"-",
"15",
")",
";",
"}"
] |
Time related part
@return string 15-char string
@access protected
|
[
"Time",
"related",
"part"
] |
3b6aa326e15c444683bee645c1cbffbc6c421659
|
https://github.com/phossa2/uuid/blob/3b6aa326e15c444683bee645c1cbffbc6c421659/src/Uuid/Traits/UtilityTrait.php#L196-L203
|
227,478
|
middlewares/filesystem
|
src/Filesystem.php
|
Filesystem.getFilename
|
protected static function getFilename(string $path): string
{
$parts = pathinfo(urldecode($path));
$path = isset($parts['dirname']) ? $parts['dirname'] : '';
$filename = isset($parts['basename']) ? $parts['basename'] : '';
//if has not extension, assume it's a directory and append index.html
if (empty($parts['extension'])) {
$filename .= '/index.html';
}
return str_replace('//', '/', $path.'/'.$filename);
}
|
php
|
protected static function getFilename(string $path): string
{
$parts = pathinfo(urldecode($path));
$path = isset($parts['dirname']) ? $parts['dirname'] : '';
$filename = isset($parts['basename']) ? $parts['basename'] : '';
//if has not extension, assume it's a directory and append index.html
if (empty($parts['extension'])) {
$filename .= '/index.html';
}
return str_replace('//', '/', $path.'/'.$filename);
}
|
[
"protected",
"static",
"function",
"getFilename",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"$",
"parts",
"=",
"pathinfo",
"(",
"urldecode",
"(",
"$",
"path",
")",
")",
";",
"$",
"path",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'dirname'",
"]",
")",
"?",
"$",
"parts",
"[",
"'dirname'",
"]",
":",
"''",
";",
"$",
"filename",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'basename'",
"]",
")",
"?",
"$",
"parts",
"[",
"'basename'",
"]",
":",
"''",
";",
"//if has not extension, assume it's a directory and append index.html",
"if",
"(",
"empty",
"(",
"$",
"parts",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"filename",
".=",
"'/index.html'",
";",
"}",
"return",
"str_replace",
"(",
"'//'",
",",
"'/'",
",",
"$",
"path",
".",
"'/'",
".",
"$",
"filename",
")",
";",
"}"
] |
Resolve the filename of the response file.
|
[
"Resolve",
"the",
"filename",
"of",
"the",
"response",
"file",
"."
] |
f25168893ca9b0e3d74228b88576099e29892bdd
|
https://github.com/middlewares/filesystem/blob/f25168893ca9b0e3d74228b88576099e29892bdd/src/Filesystem.php#L20-L32
|
227,479
|
eloquent/php-lcs
|
src/LcsSolver.php
|
LcsSolver.longestCommonSubsequence
|
public function longestCommonSubsequence(array $sequenceA, array $sequenceB)
{
if (func_num_args() > 2) {
$arguments = func_get_args();
array_splice(
$arguments,
0,
2,
array($this->longestCommonSubsequence($sequenceA, $sequenceB))
);
return call_user_func_array(
array($this, 'longestCommonSubsequence'),
$arguments
);
}
$comparator = $this->comparator();
$m = count($sequenceA);
$n = count($sequenceB);
// $a[$i][$j] = length of LCS of $sequenceA[$i..$m] and $sequenceB[$j..$n]
$a = array();
// compute length of LCS and all subproblems via dynamic programming
for ($i = $m - 1; $i >= 0; $i--) {
for ($j = $n - 1; $j >= 0; $j--) {
if ($comparator($sequenceA[$i], $sequenceB[$j])) {
$a[$i][$j] =
(isset($a[$i + 1][$j + 1]) ? $a[$i + 1][$j + 1] : 0) +
1;
} else {
$a[$i][$j] = max(
(isset($a[$i + 1][$j]) ? $a[$i + 1][$j] : 0),
(isset($a[$i][$j + 1]) ? $a[$i][$j + 1] : 0)
);
}
}
}
// recover LCS itself
$i = 0;
$j = 0;
$lcs = array();
while ($i < $m && $j < $n) {
if ($comparator($sequenceA[$i], $sequenceB[$j])) {
$lcs[] = $sequenceA[$i];
$i++;
$j++;
} elseif (
(isset($a[$i + 1][$j]) ? $a[$i + 1][$j] : 0) >=
(isset($a[$i][$j + 1]) ? $a[$i][$j + 1] : 0)
) {
$i++;
} else {
$j++;
}
}
return $lcs;
}
|
php
|
public function longestCommonSubsequence(array $sequenceA, array $sequenceB)
{
if (func_num_args() > 2) {
$arguments = func_get_args();
array_splice(
$arguments,
0,
2,
array($this->longestCommonSubsequence($sequenceA, $sequenceB))
);
return call_user_func_array(
array($this, 'longestCommonSubsequence'),
$arguments
);
}
$comparator = $this->comparator();
$m = count($sequenceA);
$n = count($sequenceB);
// $a[$i][$j] = length of LCS of $sequenceA[$i..$m] and $sequenceB[$j..$n]
$a = array();
// compute length of LCS and all subproblems via dynamic programming
for ($i = $m - 1; $i >= 0; $i--) {
for ($j = $n - 1; $j >= 0; $j--) {
if ($comparator($sequenceA[$i], $sequenceB[$j])) {
$a[$i][$j] =
(isset($a[$i + 1][$j + 1]) ? $a[$i + 1][$j + 1] : 0) +
1;
} else {
$a[$i][$j] = max(
(isset($a[$i + 1][$j]) ? $a[$i + 1][$j] : 0),
(isset($a[$i][$j + 1]) ? $a[$i][$j + 1] : 0)
);
}
}
}
// recover LCS itself
$i = 0;
$j = 0;
$lcs = array();
while ($i < $m && $j < $n) {
if ($comparator($sequenceA[$i], $sequenceB[$j])) {
$lcs[] = $sequenceA[$i];
$i++;
$j++;
} elseif (
(isset($a[$i + 1][$j]) ? $a[$i + 1][$j] : 0) >=
(isset($a[$i][$j + 1]) ? $a[$i][$j + 1] : 0)
) {
$i++;
} else {
$j++;
}
}
return $lcs;
}
|
[
"public",
"function",
"longestCommonSubsequence",
"(",
"array",
"$",
"sequenceA",
",",
"array",
"$",
"sequenceB",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"2",
")",
"{",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"array_splice",
"(",
"$",
"arguments",
",",
"0",
",",
"2",
",",
"array",
"(",
"$",
"this",
"->",
"longestCommonSubsequence",
"(",
"$",
"sequenceA",
",",
"$",
"sequenceB",
")",
")",
")",
";",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"'longestCommonSubsequence'",
")",
",",
"$",
"arguments",
")",
";",
"}",
"$",
"comparator",
"=",
"$",
"this",
"->",
"comparator",
"(",
")",
";",
"$",
"m",
"=",
"count",
"(",
"$",
"sequenceA",
")",
";",
"$",
"n",
"=",
"count",
"(",
"$",
"sequenceB",
")",
";",
"// $a[$i][$j] = length of LCS of $sequenceA[$i..$m] and $sequenceB[$j..$n]",
"$",
"a",
"=",
"array",
"(",
")",
";",
"// compute length of LCS and all subproblems via dynamic programming",
"for",
"(",
"$",
"i",
"=",
"$",
"m",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"$",
"n",
"-",
"1",
";",
"$",
"j",
">=",
"0",
";",
"$",
"j",
"--",
")",
"{",
"if",
"(",
"$",
"comparator",
"(",
"$",
"sequenceA",
"[",
"$",
"i",
"]",
",",
"$",
"sequenceB",
"[",
"$",
"j",
"]",
")",
")",
"{",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"$",
"j",
"+",
"1",
"]",
")",
"?",
"$",
"a",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"$",
"j",
"+",
"1",
"]",
":",
"0",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"max",
"(",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"$",
"j",
"]",
")",
"?",
"$",
"a",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"$",
"j",
"]",
":",
"0",
")",
",",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"+",
"1",
"]",
")",
"?",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"+",
"1",
"]",
":",
"0",
")",
")",
";",
"}",
"}",
"}",
"// recover LCS itself",
"$",
"i",
"=",
"0",
";",
"$",
"j",
"=",
"0",
";",
"$",
"lcs",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"i",
"<",
"$",
"m",
"&&",
"$",
"j",
"<",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"comparator",
"(",
"$",
"sequenceA",
"[",
"$",
"i",
"]",
",",
"$",
"sequenceB",
"[",
"$",
"j",
"]",
")",
")",
"{",
"$",
"lcs",
"[",
"]",
"=",
"$",
"sequenceA",
"[",
"$",
"i",
"]",
";",
"$",
"i",
"++",
";",
"$",
"j",
"++",
";",
"}",
"elseif",
"(",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"$",
"j",
"]",
")",
"?",
"$",
"a",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"$",
"j",
"]",
":",
"0",
")",
">=",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"+",
"1",
"]",
")",
"?",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"+",
"1",
"]",
":",
"0",
")",
")",
"{",
"$",
"i",
"++",
";",
"}",
"else",
"{",
"$",
"j",
"++",
";",
"}",
"}",
"return",
"$",
"lcs",
";",
"}"
] |
Returns the longest common subsequence of the given sequences.
@link http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
@param array<integer,mixed> $sequenceA The first sequence.
@param array<integer,mixed> $sequenceB The second sequence.
@param array<integer,mixed> $additional,... Any number of additional sequences.
@return array<integer,mixed> The longest common subsequence.
|
[
"Returns",
"the",
"longest",
"common",
"subsequence",
"of",
"the",
"given",
"sequences",
"."
] |
d1fc697ed82b7c7dc61ea3183654ce4e5acd08ae
|
https://github.com/eloquent/php-lcs/blob/d1fc697ed82b7c7dc61ea3183654ce4e5acd08ae/src/LcsSolver.php#L59-L122
|
227,480
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/WiFi/Bss.php
|
Bss.getAll
|
public function getAll() {
$rest = $this->getService( self::API_WIFI_BSS);
$rest->GET();
return $rest->getResultAsArray( models\WiFi\Bss\Bss::class);
}
|
php
|
public function getAll() {
$rest = $this->getService( self::API_WIFI_BSS);
$rest->GET();
return $rest->getResultAsArray( models\WiFi\Bss\Bss::class);
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_WIFI_BSS",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"WiFi",
"\\",
"Bss",
"\\",
"Bss",
"::",
"class",
")",
";",
"}"
] |
Get the list of Freebox BSS
@return models\WiFi\Bss\Bss[]
|
[
"Get",
"the",
"list",
"of",
"Freebox",
"BSS"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/WiFi/Bss.php#L18-L23
|
227,481
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/WiFi/Bss.php
|
Bss.getFromId
|
public function getFromId( $BssId) {
$rest = $this->getService( self::API_WIFI_BSS . $BssId);
$rest->GET();
return $rest->getResult( models\WiFi\Bss\Bss::class);
}
|
php
|
public function getFromId( $BssId) {
$rest = $this->getService( self::API_WIFI_BSS . $BssId);
$rest->GET();
return $rest->getResult( models\WiFi\Bss\Bss::class);
}
|
[
"public",
"function",
"getFromId",
"(",
"$",
"BssId",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_WIFI_BSS",
".",
"$",
"BssId",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"WiFi",
"\\",
"Bss",
"\\",
"Bss",
"::",
"class",
")",
";",
"}"
] |
Get a specific BSS
@param $BssId
@return models\WiFi\Bss\Bss
|
[
"Get",
"a",
"specific",
"BSS"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/WiFi/Bss.php#L30-L35
|
227,482
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/WiFi/Bss.php
|
Bss.update
|
public function update( models\WiFi\Bss\Bss $Bss) {
$rest = $this->getService( self::API_WIFI_BSS . $Bss->getId());
$rest->PUT( $Bss);
return $rest->getResult( models\WiFi\Bss\Bss::class);
}
|
php
|
public function update( models\WiFi\Bss\Bss $Bss) {
$rest = $this->getService( self::API_WIFI_BSS . $Bss->getId());
$rest->PUT( $Bss);
return $rest->getResult( models\WiFi\Bss\Bss::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"WiFi",
"\\",
"Bss",
"\\",
"Bss",
"$",
"Bss",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_WIFI_BSS",
".",
"$",
"Bss",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"Bss",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"WiFi",
"\\",
"Bss",
"\\",
"Bss",
"::",
"class",
")",
";",
"}"
] |
Update a BSS
@param models\WiFi\Bss\Bss $Bss
@return models\WiFi\Bss\Bss
|
[
"Update",
"a",
"BSS"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/WiFi/Bss.php#L42-L47
|
227,483
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.getAll
|
public function getAll(){
$rest = $this->getService( self::API_CONTACT);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactEntry::class);
}
|
php
|
public function getAll(){
$rest = $this->getService( self::API_CONTACT);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactEntry::class);
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_CONTACT",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEntry",
"::",
"class",
")",
";",
"}"
] |
List all contacts
@return models\Call\ContactEntry[]
|
[
"List",
"all",
"contacts"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L23-L28
|
227,484
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.getFromId
|
public function getFromId( $ContactEntryId){
$rest = $this->getService( self::API_CONTACT . $ContactEntryId);
$rest->GET();
return $rest->getResult( models\Call\ContactEntry::class);
}
|
php
|
public function getFromId( $ContactEntryId){
$rest = $this->getService( self::API_CONTACT . $ContactEntryId);
$rest->GET();
return $rest->getResult( models\Call\ContactEntry::class);
}
|
[
"public",
"function",
"getFromId",
"(",
"$",
"ContactEntryId",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_CONTACT",
".",
"$",
"ContactEntryId",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEntry",
"::",
"class",
")",
";",
"}"
] |
Get a specific contact entry
@param int $ContactEntryId
@return models\Call\ContactEntry
|
[
"Get",
"a",
"specific",
"contact",
"entry"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L35-L40
|
227,485
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.create
|
public function create( models\Call\ContactEntry $ContactEntry){
$rest = $this->getService( self::API_CONTACT);
$rest->POST( $ContactEntry);
return $rest->getResult( models\Call\ContactEntry::class);
}
|
php
|
public function create( models\Call\ContactEntry $ContactEntry){
$rest = $this->getService( self::API_CONTACT);
$rest->POST( $ContactEntry);
return $rest->getResult( models\Call\ContactEntry::class);
}
|
[
"public",
"function",
"create",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEntry",
"$",
"ContactEntry",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_CONTACT",
")",
";",
"$",
"rest",
"->",
"POST",
"(",
"$",
"ContactEntry",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEntry",
"::",
"class",
")",
";",
"}"
] |
Add a contact entry
@param models\Call\ContactEntry $ContactEntry
@return models\Call\ContactEntry
|
[
"Add",
"a",
"contact",
"entry"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L47-L52
|
227,486
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.update
|
public function update( models\Call\ContactEntry $ContactEntry){
$rest = $this->getService( self::API_CONTACT . $ContactEntry->getId());
$rest->PUT( $ContactEntry);
return $rest->getResult( models\Call\ContactEntry::class);
}
|
php
|
public function update( models\Call\ContactEntry $ContactEntry){
$rest = $this->getService( self::API_CONTACT . $ContactEntry->getId());
$rest->PUT( $ContactEntry);
return $rest->getResult( models\Call\ContactEntry::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEntry",
"$",
"ContactEntry",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_CONTACT",
".",
"$",
"ContactEntry",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"ContactEntry",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEntry",
"::",
"class",
")",
";",
"}"
] |
Update a contact entry
@param models\Call\ContactEntry $ContactEntry
@return models\Call\ContactEntry
|
[
"Update",
"a",
"contact",
"entry"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L59-L64
|
227,487
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.getContactNumbersFromContactId
|
public function getContactNumbersFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_NUMBERS, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactNumber::class);
}
|
php
|
public function getContactNumbersFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_NUMBERS, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactNumber::class);
}
|
[
"public",
"function",
"getContactNumbersFromContactId",
"(",
"$",
"ContactEntryId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_CONTACT_NUMBERS",
",",
"$",
"ContactEntryId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Call",
"\\",
"ContactNumber",
"::",
"class",
")",
";",
"}"
] |
Get all numbers associated to a given contact id
@param int $ContactEntryId
@return models\Call\ContactNumber[]
|
[
"Get",
"all",
"numbers",
"associated",
"to",
"a",
"given",
"contact",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L92-L98
|
227,488
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.getContactAddressesFromContactId
|
public function getContactAddressesFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_ADDRESSES, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactAddress::class);
}
|
php
|
public function getContactAddressesFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_ADDRESSES, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactAddress::class);
}
|
[
"public",
"function",
"getContactAddressesFromContactId",
"(",
"$",
"ContactEntryId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_CONTACT_ADDRESSES",
",",
"$",
"ContactEntryId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Call",
"\\",
"ContactAddress",
"::",
"class",
")",
";",
"}"
] |
Get all addresses associated to a given contact id
@param int $ContactEntryId
@return models\Call\ContactAddress[]
|
[
"Get",
"all",
"addresses",
"associated",
"to",
"a",
"given",
"contact",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L105-L111
|
227,489
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.getContactEmailsFromContactId
|
public function getContactEmailsFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_EMAILS, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactEmail::class);
}
|
php
|
public function getContactEmailsFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_EMAILS, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactEmail::class);
}
|
[
"public",
"function",
"getContactEmailsFromContactId",
"(",
"$",
"ContactEntryId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_CONTACT_EMAILS",
",",
"$",
"ContactEntryId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Call",
"\\",
"ContactEmail",
"::",
"class",
")",
";",
"}"
] |
Get all email addresses associated to a given contact id
@param int $ContactEntryId
@return models\Call\ContactEmail[]
|
[
"Get",
"all",
"email",
"addresses",
"associated",
"to",
"a",
"given",
"contact",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L118-L124
|
227,490
|
alphayax/freebox_api_php
|
freebox/api/v3/services/Call/Contact/ContactEntry.php
|
ContactEntry.getContactUrlsFromContactId
|
public function getContactUrlsFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_URLS, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactUrl::class);
}
|
php
|
public function getContactUrlsFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_URLS, $ContactEntryId);
$rest = $this->getService( $service);
$rest->GET();
return $rest->getResultAsArray( models\Call\ContactUrl::class);
}
|
[
"public",
"function",
"getContactUrlsFromContactId",
"(",
"$",
"ContactEntryId",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"self",
"::",
"API_CONTACT_URLS",
",",
"$",
"ContactEntryId",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"service",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"Call",
"\\",
"ContactUrl",
"::",
"class",
")",
";",
"}"
] |
Get all URLs associated to a given contact id
@param int $ContactEntryId
@return models\Call\ContactUrl[]
|
[
"Get",
"all",
"URLs",
"associated",
"to",
"a",
"given",
"contact",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/Call/Contact/ContactEntry.php#L131-L137
|
227,491
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/PortForwarding.php
|
PortForwarding.getAll
|
public function getAll(){
$rest = $this->getService( self::API_NAT_REDIR);
$rest->GET();
return $rest->getResultAsArray( models\NAT\PortForwardingConfig::class);
}
|
php
|
public function getAll(){
$rest = $this->getService( self::API_NAT_REDIR);
$rest->GET();
return $rest->getResultAsArray( models\NAT\PortForwardingConfig::class);
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_REDIR",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"NAT",
"\\",
"PortForwardingConfig",
"::",
"class",
")",
";",
"}"
] |
Getting the list of port forwarding
@throws \Exception
@return models\NAT\PortForwardingConfig[]
|
[
"Getting",
"the",
"list",
"of",
"port",
"forwarding"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/PortForwarding.php#L21-L26
|
227,492
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/PortForwarding.php
|
PortForwarding.getById
|
public function getById( $PortForwarding_id){
$rest = $this->getService( self::API_NAT_REDIR . $PortForwarding_id);
$rest->GET();
return $rest->getResult( models\NAT\PortForwardingConfig::class);
}
|
php
|
public function getById( $PortForwarding_id){
$rest = $this->getService( self::API_NAT_REDIR . $PortForwarding_id);
$rest->GET();
return $rest->getResult( models\NAT\PortForwardingConfig::class);
}
|
[
"public",
"function",
"getById",
"(",
"$",
"PortForwarding_id",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_REDIR",
".",
"$",
"PortForwarding_id",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"PortForwardingConfig",
"::",
"class",
")",
";",
"}"
] |
Getting a specific port forwarding
@param $PortForwarding_id
@return models\NAT\PortForwardingConfig
|
[
"Getting",
"a",
"specific",
"port",
"forwarding"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/PortForwarding.php#L33-L38
|
227,493
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/PortForwarding.php
|
PortForwarding.update
|
public function update( models\NAT\PortForwardingConfig $portForwardingConfig){
$rest = $this->getService( self::API_NAT_REDIR . $portForwardingConfig->getId());
$rest->PUT( $portForwardingConfig);
return $rest->getResult( models\NAT\PortForwardingConfig::class);
}
|
php
|
public function update( models\NAT\PortForwardingConfig $portForwardingConfig){
$rest = $this->getService( self::API_NAT_REDIR . $portForwardingConfig->getId());
$rest->PUT( $portForwardingConfig);
return $rest->getResult( models\NAT\PortForwardingConfig::class);
}
|
[
"public",
"function",
"update",
"(",
"models",
"\\",
"NAT",
"\\",
"PortForwardingConfig",
"$",
"portForwardingConfig",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_REDIR",
".",
"$",
"portForwardingConfig",
"->",
"getId",
"(",
")",
")",
";",
"$",
"rest",
"->",
"PUT",
"(",
"$",
"portForwardingConfig",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"PortForwardingConfig",
"::",
"class",
")",
";",
"}"
] |
Update a specific port forwarding
@param models\NAT\PortForwardingConfig $portForwardingConfig
@return models\NAT\PortForwardingConfig
|
[
"Update",
"a",
"specific",
"port",
"forwarding"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/PortForwarding.php#L45-L50
|
227,494
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/PortForwarding.php
|
PortForwarding.add
|
public function add( models\NAT\PortForwardingConfig $portForwardingConfig){
$rest = $this->getService( self::API_NAT_REDIR);
$rest->POST( $portForwardingConfig);
return $rest->getResult( models\NAT\PortForwardingConfig::class);
}
|
php
|
public function add( models\NAT\PortForwardingConfig $portForwardingConfig){
$rest = $this->getService( self::API_NAT_REDIR);
$rest->POST( $portForwardingConfig);
return $rest->getResult( models\NAT\PortForwardingConfig::class);
}
|
[
"public",
"function",
"add",
"(",
"models",
"\\",
"NAT",
"\\",
"PortForwardingConfig",
"$",
"portForwardingConfig",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_REDIR",
")",
";",
"$",
"rest",
"->",
"POST",
"(",
"$",
"portForwardingConfig",
")",
";",
"return",
"$",
"rest",
"->",
"getResult",
"(",
"models",
"\\",
"NAT",
"\\",
"PortForwardingConfig",
"::",
"class",
")",
";",
"}"
] |
Add a port forwarding
@param models\NAT\PortForwardingConfig $portForwardingConfig
@return models\NAT\PortForwardingConfig
|
[
"Add",
"a",
"port",
"forwarding"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/PortForwarding.php#L57-L62
|
227,495
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/NAT/PortForwarding.php
|
PortForwarding.deleteById
|
public function deleteById( $PortForwardingId){
$rest = $this->getService( self::API_NAT_REDIR . $PortForwardingId);
$rest->DELETE();
return $rest->getSuccess();
}
|
php
|
public function deleteById( $PortForwardingId){
$rest = $this->getService( self::API_NAT_REDIR . $PortForwardingId);
$rest->DELETE();
return $rest->getSuccess();
}
|
[
"public",
"function",
"deleteById",
"(",
"$",
"PortForwardingId",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_NAT_REDIR",
".",
"$",
"PortForwardingId",
")",
";",
"$",
"rest",
"->",
"DELETE",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getSuccess",
"(",
")",
";",
"}"
] |
Delete a port forwarding with the specified id
@param int $PortForwardingId
@return boolean success
|
[
"Delete",
"a",
"port",
"forwarding",
"with",
"the",
"specified",
"id"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/NAT/PortForwarding.php#L78-L83
|
227,496
|
fanout/php-gripcontrol
|
src/encoding.php
|
Encoding.is_binary_data
|
public static function is_binary_data($data)
{
if (preg_match('!!u', $data)) {
return false;
}
$characters = str_split($data);
foreach ($characters as $character) {
$ord_value = ord($character);
if ($ord_value < 0x20 or $ord_value >= 0x7f) {
return true;
}
}
return false;
}
|
php
|
public static function is_binary_data($data)
{
if (preg_match('!!u', $data)) {
return false;
}
$characters = str_split($data);
foreach ($characters as $character) {
$ord_value = ord($character);
if ($ord_value < 0x20 or $ord_value >= 0x7f) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"is_binary_data",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'!!u'",
",",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"characters",
"=",
"str_split",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"characters",
"as",
"$",
"character",
")",
"{",
"$",
"ord_value",
"=",
"ord",
"(",
"$",
"character",
")",
";",
"if",
"(",
"$",
"ord_value",
"<",
"0x20",
"or",
"$",
"ord_value",
">=",
"0x7f",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determine whether the specified data is binary or not.
|
[
"Determine",
"whether",
"the",
"specified",
"data",
"is",
"binary",
"or",
"not",
"."
] |
ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff
|
https://github.com/fanout/php-gripcontrol/blob/ee187ddcf8b6e4a0e88584ffc5c89cf96a47d3ff/src/encoding.php#L17-L30
|
227,497
|
codecasts/aws-sdk-php
|
src/Sqs/SqsClient.php
|
SqsClient.queueUrl
|
private function queueUrl()
{
return static function (callable $handler) {
return function (
CommandInterface $c,
RequestInterface $r = null
) use ($handler) {
if ($c->hasParam('QueueUrl')) {
$uri = Uri::resolve($r->getUri(), $c['QueueUrl']);
$r = $r->withUri($uri);
}
return $handler($c, $r);
};
};
}
|
php
|
private function queueUrl()
{
return static function (callable $handler) {
return function (
CommandInterface $c,
RequestInterface $r = null
) use ($handler) {
if ($c->hasParam('QueueUrl')) {
$uri = Uri::resolve($r->getUri(), $c['QueueUrl']);
$r = $r->withUri($uri);
}
return $handler($c, $r);
};
};
}
|
[
"private",
"function",
"queueUrl",
"(",
")",
"{",
"return",
"static",
"function",
"(",
"callable",
"$",
"handler",
")",
"{",
"return",
"function",
"(",
"CommandInterface",
"$",
"c",
",",
"RequestInterface",
"$",
"r",
"=",
"null",
")",
"use",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"c",
"->",
"hasParam",
"(",
"'QueueUrl'",
")",
")",
"{",
"$",
"uri",
"=",
"Uri",
"::",
"resolve",
"(",
"$",
"r",
"->",
"getUri",
"(",
")",
",",
"$",
"c",
"[",
"'QueueUrl'",
"]",
")",
";",
"$",
"r",
"=",
"$",
"r",
"->",
"withUri",
"(",
"$",
"uri",
")",
";",
"}",
"return",
"$",
"handler",
"(",
"$",
"c",
",",
"$",
"r",
")",
";",
"}",
";",
"}",
";",
"}"
] |
Moves the URI of the queue to the URI in the input parameter.
@return callable
|
[
"Moves",
"the",
"URI",
"of",
"the",
"queue",
"to",
"the",
"URI",
"in",
"the",
"input",
"parameter",
"."
] |
4f22b5a422c8fbebca46de12ac2422e7cb66ec70
|
https://github.com/codecasts/aws-sdk-php/blob/4f22b5a422c8fbebca46de12ac2422e7cb66ec70/src/Sqs/SqsClient.php#L82-L96
|
227,498
|
codecasts/aws-sdk-php
|
src/Sqs/SqsClient.php
|
SqsClient.validateMd5
|
private function validateMd5()
{
return static function (callable $handler) {
return function (
CommandInterface $c,
RequestInterface $r = null
) use ($handler) {
if ($c->getName() !== 'ReceiveMessage') {
return $handler($c, $r);
}
return $handler($c, $r)
->then(
function ($result) use ($c, $r) {
foreach ((array) $result['Messages'] as $msg) {
if (isset($msg['MD5OfBody'])
&& md5($msg['Body']) !== $msg['MD5OfBody']
) {
throw new SqsException(
sprintf(
'MD5 mismatch. Expected %s, found %s',
$msg['MD5OfBody'],
md5($msg['Body'])
),
$c,
[
'code' => 'ClientChecksumMismatch',
'request' => $r
]
);
}
}
return $result;
}
);
};
};
}
|
php
|
private function validateMd5()
{
return static function (callable $handler) {
return function (
CommandInterface $c,
RequestInterface $r = null
) use ($handler) {
if ($c->getName() !== 'ReceiveMessage') {
return $handler($c, $r);
}
return $handler($c, $r)
->then(
function ($result) use ($c, $r) {
foreach ((array) $result['Messages'] as $msg) {
if (isset($msg['MD5OfBody'])
&& md5($msg['Body']) !== $msg['MD5OfBody']
) {
throw new SqsException(
sprintf(
'MD5 mismatch. Expected %s, found %s',
$msg['MD5OfBody'],
md5($msg['Body'])
),
$c,
[
'code' => 'ClientChecksumMismatch',
'request' => $r
]
);
}
}
return $result;
}
);
};
};
}
|
[
"private",
"function",
"validateMd5",
"(",
")",
"{",
"return",
"static",
"function",
"(",
"callable",
"$",
"handler",
")",
"{",
"return",
"function",
"(",
"CommandInterface",
"$",
"c",
",",
"RequestInterface",
"$",
"r",
"=",
"null",
")",
"use",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"c",
"->",
"getName",
"(",
")",
"!==",
"'ReceiveMessage'",
")",
"{",
"return",
"$",
"handler",
"(",
"$",
"c",
",",
"$",
"r",
")",
";",
"}",
"return",
"$",
"handler",
"(",
"$",
"c",
",",
"$",
"r",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"$",
"c",
",",
"$",
"r",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"result",
"[",
"'Messages'",
"]",
"as",
"$",
"msg",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"msg",
"[",
"'MD5OfBody'",
"]",
")",
"&&",
"md5",
"(",
"$",
"msg",
"[",
"'Body'",
"]",
")",
"!==",
"$",
"msg",
"[",
"'MD5OfBody'",
"]",
")",
"{",
"throw",
"new",
"SqsException",
"(",
"sprintf",
"(",
"'MD5 mismatch. Expected %s, found %s'",
",",
"$",
"msg",
"[",
"'MD5OfBody'",
"]",
",",
"md5",
"(",
"$",
"msg",
"[",
"'Body'",
"]",
")",
")",
",",
"$",
"c",
",",
"[",
"'code'",
"=>",
"'ClientChecksumMismatch'",
",",
"'request'",
"=>",
"$",
"r",
"]",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}",
")",
";",
"}",
";",
"}",
";",
"}"
] |
Validates ReceiveMessage body MD5s
@return callable
|
[
"Validates",
"ReceiveMessage",
"body",
"MD5s"
] |
4f22b5a422c8fbebca46de12ac2422e7cb66ec70
|
https://github.com/codecasts/aws-sdk-php/blob/4f22b5a422c8fbebca46de12ac2422e7cb66ec70/src/Sqs/SqsClient.php#L103-L140
|
227,499
|
alphayax/freebox_api_php
|
freebox/api/v3/services/config/VPN/Server/User.php
|
User.getAll
|
public function getAll(){
$rest = $this->getService( self::API_VPN_USER);
$rest->GET();
return $rest->getResultAsArray( models\VPN\Server\User::class);
}
|
php
|
public function getAll(){
$rest = $this->getService( self::API_VPN_USER);
$rest->GET();
return $rest->getResultAsArray( models\VPN\Server\User::class);
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"rest",
"=",
"$",
"this",
"->",
"getService",
"(",
"self",
"::",
"API_VPN_USER",
")",
";",
"$",
"rest",
"->",
"GET",
"(",
")",
";",
"return",
"$",
"rest",
"->",
"getResultAsArray",
"(",
"models",
"\\",
"VPN",
"\\",
"Server",
"\\",
"User",
"::",
"class",
")",
";",
"}"
] |
Get the list of VPNUser
@return models\VPN\Server\User[]
|
[
"Get",
"the",
"list",
"of",
"VPNUser"
] |
6b90f932fca9d74053dc0af9664881664a29cefb
|
https://github.com/alphayax/freebox_api_php/blob/6b90f932fca9d74053dc0af9664881664a29cefb/freebox/api/v3/services/config/VPN/Server/User.php#L19-L24
|
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.