repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
sanovskiy/traitlib | src/Traits/ArrayAccess.php | ArrayAccess.offsetSet | public function offsetSet($offset, $value)
{
if (is_null($offset) || empty($offset)) {
return null;
}
return $this->records[$offset] = $value;
} | php | public function offsetSet($offset, $value)
{
if (is_null($offset) || empty($offset)) {
return null;
}
return $this->records[$offset] = $value;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
"||",
"empty",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"records",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}"
]
| @param mixed $offset
@param mixed $value
@return mixed | [
"@param",
"mixed",
"$offset",
"@param",
"mixed",
"$value"
]
| train | https://github.com/sanovskiy/traitlib/blob/d3384da78fc2ac029cc9e835f7a5fa00d8aa6c23/src/Traits/ArrayAccess.php#L51-L57 |
gries/rcon | src/Connection.php | Connection.sendMessage | public function sendMessage(Message $message)
{
$this->currentId++;
$messageData = $message->convertToRconData($this->currentId);
$this->client->write($messageData);
return $this->getResponseMessage();
} | php | public function sendMessage(Message $message)
{
$this->currentId++;
$messageData = $message->convertToRconData($this->currentId);
$this->client->write($messageData);
return $this->getResponseMessage();
} | [
"public",
"function",
"sendMessage",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"currentId",
"++",
";",
"$",
"messageData",
"=",
"$",
"message",
"->",
"convertToRconData",
"(",
"$",
"this",
"->",
"currentId",
")",
";",
"$",
"this",
"->",
"client",
"->",
"write",
"(",
"$",
"messageData",
")",
";",
"return",
"$",
"this",
"->",
"getResponseMessage",
"(",
")",
";",
"}"
]
| Send a RCON message.
@param Message $message
@return Message | [
"Send",
"a",
"RCON",
"message",
"."
]
| train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L55-L62 |
gries/rcon | src/Connection.php | Connection.getResponseMessage | protected function getResponseMessage()
{
// read the first 4 bytes which include the length of the response
$lengthEncoded = $this->client->read(4);
if (strlen($lengthEncoded) < 4) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$lengthInBytes = unpack('V1size', $lengthEncoded)['size'];
if ($lengthInBytes <= 0) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseData = $this->client->read($lengthInBytes);
// return an empty message if the server did not send any response
if (null === $responseData) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseMessage = new Message();
$responseMessage->initializeFromRconData($responseData);
if ($lengthInBytes >= 4000) {
$this->handleFragmentedResponse($responseMessage);
}
return $responseMessage;
} | php | protected function getResponseMessage()
{
// read the first 4 bytes which include the length of the response
$lengthEncoded = $this->client->read(4);
if (strlen($lengthEncoded) < 4) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$lengthInBytes = unpack('V1size', $lengthEncoded)['size'];
if ($lengthInBytes <= 0) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseData = $this->client->read($lengthInBytes);
// return an empty message if the server did not send any response
if (null === $responseData) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseMessage = new Message();
$responseMessage->initializeFromRconData($responseData);
if ($lengthInBytes >= 4000) {
$this->handleFragmentedResponse($responseMessage);
}
return $responseMessage;
} | [
"protected",
"function",
"getResponseMessage",
"(",
")",
"{",
"// read the first 4 bytes which include the length of the response",
"$",
"lengthEncoded",
"=",
"$",
"this",
"->",
"client",
"->",
"read",
"(",
"4",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"lengthEncoded",
")",
"<",
"4",
")",
"{",
"return",
"new",
"Message",
"(",
"''",
",",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"}",
"$",
"lengthInBytes",
"=",
"unpack",
"(",
"'V1size'",
",",
"$",
"lengthEncoded",
")",
"[",
"'size'",
"]",
";",
"if",
"(",
"$",
"lengthInBytes",
"<=",
"0",
")",
"{",
"return",
"new",
"Message",
"(",
"''",
",",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"}",
"$",
"responseData",
"=",
"$",
"this",
"->",
"client",
"->",
"read",
"(",
"$",
"lengthInBytes",
")",
";",
"// return an empty message if the server did not send any response",
"if",
"(",
"null",
"===",
"$",
"responseData",
")",
"{",
"return",
"new",
"Message",
"(",
"''",
",",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"}",
"$",
"responseMessage",
"=",
"new",
"Message",
"(",
")",
";",
"$",
"responseMessage",
"->",
"initializeFromRconData",
"(",
"$",
"responseData",
")",
";",
"if",
"(",
"$",
"lengthInBytes",
">=",
"4000",
")",
"{",
"$",
"this",
"->",
"handleFragmentedResponse",
"(",
"$",
"responseMessage",
")",
";",
"}",
"return",
"$",
"responseMessage",
";",
"}"
]
| Get the response value of the server.
@return string | [
"Get",
"the",
"response",
"value",
"of",
"the",
"server",
"."
]
| train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L69-L100 |
gries/rcon | src/Connection.php | Connection.authenticate | protected function authenticate($password)
{
$message = new Message($password, Message::TYPE_AUTH);
$response = $this->sendMessage($message);
if ($response->getType() === Message::TYPE_AUTH_FAILURE) {
throw new AuthenticationFailedException('Could not authenticate to the server.');
}
} | php | protected function authenticate($password)
{
$message = new Message($password, Message::TYPE_AUTH);
$response = $this->sendMessage($message);
if ($response->getType() === Message::TYPE_AUTH_FAILURE) {
throw new AuthenticationFailedException('Could not authenticate to the server.');
}
} | [
"protected",
"function",
"authenticate",
"(",
"$",
"password",
")",
"{",
"$",
"message",
"=",
"new",
"Message",
"(",
"$",
"password",
",",
"Message",
"::",
"TYPE_AUTH",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendMessage",
"(",
"$",
"message",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getType",
"(",
")",
"===",
"Message",
"::",
"TYPE_AUTH_FAILURE",
")",
"{",
"throw",
"new",
"AuthenticationFailedException",
"(",
"'Could not authenticate to the server.'",
")",
";",
"}",
"}"
]
| Authenticate with the server.
@param $password
@throws Exception\AuthenticationFailedException | [
"Authenticate",
"with",
"the",
"server",
"."
]
| train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L109-L117 |
gries/rcon | src/Connection.php | Connection.handleFragmentedResponse | protected function handleFragmentedResponse(Message $responseMessage)
{
do {
usleep(20000); // some servers stop responding if we send to many packages so we wait 20ms
$this->client->write(Message::TYPE_RESPONSE_VALUE);
$responseData = $this->client->read(4096);
if (empty($responseData)) {
break;
}
$fragmentedMessage = new Message();
$fragmentedMessage->initializeFromRconData($responseData, true);
$responseMessage->append($fragmentedMessage);
if ($fragmentedMessage->getType() !== Message::TYPE_RESPONSE_VALUE) {
break;
}
} while (true);
} | php | protected function handleFragmentedResponse(Message $responseMessage)
{
do {
usleep(20000); // some servers stop responding if we send to many packages so we wait 20ms
$this->client->write(Message::TYPE_RESPONSE_VALUE);
$responseData = $this->client->read(4096);
if (empty($responseData)) {
break;
}
$fragmentedMessage = new Message();
$fragmentedMessage->initializeFromRconData($responseData, true);
$responseMessage->append($fragmentedMessage);
if ($fragmentedMessage->getType() !== Message::TYPE_RESPONSE_VALUE) {
break;
}
} while (true);
} | [
"protected",
"function",
"handleFragmentedResponse",
"(",
"Message",
"$",
"responseMessage",
")",
"{",
"do",
"{",
"usleep",
"(",
"20000",
")",
";",
"// some servers stop responding if we send to many packages so we wait 20ms",
"$",
"this",
"->",
"client",
"->",
"write",
"(",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"$",
"responseData",
"=",
"$",
"this",
"->",
"client",
"->",
"read",
"(",
"4096",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"responseData",
")",
")",
"{",
"break",
";",
"}",
"$",
"fragmentedMessage",
"=",
"new",
"Message",
"(",
")",
";",
"$",
"fragmentedMessage",
"->",
"initializeFromRconData",
"(",
"$",
"responseData",
",",
"true",
")",
";",
"$",
"responseMessage",
"->",
"append",
"(",
"$",
"fragmentedMessage",
")",
";",
"if",
"(",
"$",
"fragmentedMessage",
"->",
"getType",
"(",
")",
"!==",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
"{",
"break",
";",
"}",
"}",
"while",
"(",
"true",
")",
";",
"}"
]
| This handles a fragmented response.
(https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Multiple-packet_Responses)
We basically send a RESPONSE_VALUE Message to the server to force the response of the rest of the package,
until we receive another package or an empty response.
All the received data is then appended to the current ResponseMessage.
@param $responseMessage
@throws Exception\InvalidPacketException | [
"This",
"handles",
"a",
"fragmented",
"response",
".",
"(",
"https",
":",
"//",
"developer",
".",
"valvesoftware",
".",
"com",
"/",
"wiki",
"/",
"Source_RCON_Protocol#Multiple",
"-",
"packet_Responses",
")"
]
| train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L131-L151 |
vufind-org/vufinddate | src/Converter.php | Converter.convert | public function convert($inputFormat, $outputFormat, $dateString)
{
// These are date formats that we definitely know how to handle, and some
// benefit from special processing. However, items not found in this list
// will still be attempted in a generic fashion before giving up.
$validFormats = [
"m-d-Y", "m-d-y", "m/d/Y", "m/d/y", "U", "m-d-y H:i", "Y-m-d",
"Y-m-d H:i"
];
$isValid = in_array($inputFormat, $validFormats);
if ($isValid) {
if ($inputFormat == 'U') {
// Special case for Unix timestamps (including workaround for
// floating point numbers):
$dateString = '@'
. (is_float($dateString) ? intval($dateString) : $dateString);
} else {
// Strip leading zeroes from date string and normalize date separator
// to slashes:
$regEx = '/0*([0-9]+)(-|\/)0*([0-9]+)(-|\/)0*([0-9]+)/';
$dateString = trim(preg_replace($regEx, '$1/$3/$5', $dateString));
}
$errors = [
'warning_count' => 0, 'error_count' => 0, 'errors' => []
];
try {
$date = new DateTime($dateString, $this->timezone);
} catch (\Exception $e) {
$errors['error_count']++;
$errors['errors'][] = $e->getMessage();
}
} else {
$date = DateTime::createFromFormat(
$inputFormat, $dateString, $this->timezone
);
$errors = DateTime::getLastErrors();
}
if ($errors['warning_count'] == 0 && $errors['error_count'] == 0 && $date) {
$date->setTimeZone($this->timezone);
return $date->format($outputFormat);
}
throw new DateException($this->getDateExceptionMessage($errors));
} | php | public function convert($inputFormat, $outputFormat, $dateString)
{
// These are date formats that we definitely know how to handle, and some
// benefit from special processing. However, items not found in this list
// will still be attempted in a generic fashion before giving up.
$validFormats = [
"m-d-Y", "m-d-y", "m/d/Y", "m/d/y", "U", "m-d-y H:i", "Y-m-d",
"Y-m-d H:i"
];
$isValid = in_array($inputFormat, $validFormats);
if ($isValid) {
if ($inputFormat == 'U') {
// Special case for Unix timestamps (including workaround for
// floating point numbers):
$dateString = '@'
. (is_float($dateString) ? intval($dateString) : $dateString);
} else {
// Strip leading zeroes from date string and normalize date separator
// to slashes:
$regEx = '/0*([0-9]+)(-|\/)0*([0-9]+)(-|\/)0*([0-9]+)/';
$dateString = trim(preg_replace($regEx, '$1/$3/$5', $dateString));
}
$errors = [
'warning_count' => 0, 'error_count' => 0, 'errors' => []
];
try {
$date = new DateTime($dateString, $this->timezone);
} catch (\Exception $e) {
$errors['error_count']++;
$errors['errors'][] = $e->getMessage();
}
} else {
$date = DateTime::createFromFormat(
$inputFormat, $dateString, $this->timezone
);
$errors = DateTime::getLastErrors();
}
if ($errors['warning_count'] == 0 && $errors['error_count'] == 0 && $date) {
$date->setTimeZone($this->timezone);
return $date->format($outputFormat);
}
throw new DateException($this->getDateExceptionMessage($errors));
} | [
"public",
"function",
"convert",
"(",
"$",
"inputFormat",
",",
"$",
"outputFormat",
",",
"$",
"dateString",
")",
"{",
"// These are date formats that we definitely know how to handle, and some",
"// benefit from special processing. However, items not found in this list",
"// will still be attempted in a generic fashion before giving up.",
"$",
"validFormats",
"=",
"[",
"\"m-d-Y\"",
",",
"\"m-d-y\"",
",",
"\"m/d/Y\"",
",",
"\"m/d/y\"",
",",
"\"U\"",
",",
"\"m-d-y H:i\"",
",",
"\"Y-m-d\"",
",",
"\"Y-m-d H:i\"",
"]",
";",
"$",
"isValid",
"=",
"in_array",
"(",
"$",
"inputFormat",
",",
"$",
"validFormats",
")",
";",
"if",
"(",
"$",
"isValid",
")",
"{",
"if",
"(",
"$",
"inputFormat",
"==",
"'U'",
")",
"{",
"// Special case for Unix timestamps (including workaround for",
"// floating point numbers):",
"$",
"dateString",
"=",
"'@'",
".",
"(",
"is_float",
"(",
"$",
"dateString",
")",
"?",
"intval",
"(",
"$",
"dateString",
")",
":",
"$",
"dateString",
")",
";",
"}",
"else",
"{",
"// Strip leading zeroes from date string and normalize date separator",
"// to slashes:",
"$",
"regEx",
"=",
"'/0*([0-9]+)(-|\\/)0*([0-9]+)(-|\\/)0*([0-9]+)/'",
";",
"$",
"dateString",
"=",
"trim",
"(",
"preg_replace",
"(",
"$",
"regEx",
",",
"'$1/$3/$5'",
",",
"$",
"dateString",
")",
")",
";",
"}",
"$",
"errors",
"=",
"[",
"'warning_count'",
"=>",
"0",
",",
"'error_count'",
"=>",
"0",
",",
"'errors'",
"=>",
"[",
"]",
"]",
";",
"try",
"{",
"$",
"date",
"=",
"new",
"DateTime",
"(",
"$",
"dateString",
",",
"$",
"this",
"->",
"timezone",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"errors",
"[",
"'error_count'",
"]",
"++",
";",
"$",
"errors",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"date",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"inputFormat",
",",
"$",
"dateString",
",",
"$",
"this",
"->",
"timezone",
")",
";",
"$",
"errors",
"=",
"DateTime",
"::",
"getLastErrors",
"(",
")",
";",
"}",
"if",
"(",
"$",
"errors",
"[",
"'warning_count'",
"]",
"==",
"0",
"&&",
"$",
"errors",
"[",
"'error_count'",
"]",
"==",
"0",
"&&",
"$",
"date",
")",
"{",
"$",
"date",
"->",
"setTimeZone",
"(",
"$",
"this",
"->",
"timezone",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"$",
"outputFormat",
")",
";",
"}",
"throw",
"new",
"DateException",
"(",
"$",
"this",
"->",
"getDateExceptionMessage",
"(",
"$",
"errors",
")",
")",
";",
"}"
]
| Generic method for conversion of a time / date string
@param string $inputFormat The format of the time string to be changed
@param string $outputFormat The desired output format
@param string $dateString The date string
@throws DateException
@return string A re-formatted time string | [
"Generic",
"method",
"for",
"conversion",
"of",
"a",
"time",
"/",
"date",
"string"
]
| train | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L95-L138 |
vufind-org/vufinddate | src/Converter.php | Converter.getDateExceptionMessage | protected function getDateExceptionMessage($details)
{
$errors = "Date/time problem: Details: ";
if (is_array($details['errors']) && $details['error_count'] > 0) {
foreach ($details['errors'] as $error) {
$errors .= $error . " ";
}
} elseif (is_array($details['warnings'])) {
foreach ($details['warnings'] as $warning) {
$errors .= $warning . " ";
}
}
return $errors;
} | php | protected function getDateExceptionMessage($details)
{
$errors = "Date/time problem: Details: ";
if (is_array($details['errors']) && $details['error_count'] > 0) {
foreach ($details['errors'] as $error) {
$errors .= $error . " ";
}
} elseif (is_array($details['warnings'])) {
foreach ($details['warnings'] as $warning) {
$errors .= $warning . " ";
}
}
return $errors;
} | [
"protected",
"function",
"getDateExceptionMessage",
"(",
"$",
"details",
")",
"{",
"$",
"errors",
"=",
"\"Date/time problem: Details: \"",
";",
"if",
"(",
"is_array",
"(",
"$",
"details",
"[",
"'errors'",
"]",
")",
"&&",
"$",
"details",
"[",
"'error_count'",
"]",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"details",
"[",
"'errors'",
"]",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
".=",
"$",
"error",
".",
"\" \"",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"details",
"[",
"'warnings'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"details",
"[",
"'warnings'",
"]",
"as",
"$",
"warning",
")",
"{",
"$",
"errors",
".=",
"$",
"warning",
".",
"\" \"",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
]
| Build an exception message from a detailed error array.
@param array $details Error details
@return string | [
"Build",
"an",
"exception",
"message",
"from",
"a",
"detailed",
"error",
"array",
"."
]
| train | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L147-L160 |
vufind-org/vufinddate | src/Converter.php | Converter.convertToDisplayDateAndTime | public function convertToDisplayDateAndTime($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayDate($createFormat, $timeString)
. $separator . $this->convertToDisplayTime($createFormat, $timeString);
} | php | public function convertToDisplayDateAndTime($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayDate($createFormat, $timeString)
. $separator . $this->convertToDisplayTime($createFormat, $timeString);
} | [
"public",
"function",
"convertToDisplayDateAndTime",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
",",
"$",
"separator",
"=",
"' '",
")",
"{",
"return",
"$",
"this",
"->",
"convertToDisplayDate",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
".",
"$",
"separator",
".",
"$",
"this",
"->",
"convertToDisplayTime",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
";",
"}"
]
| Public method for getting a date prepended to a time.
@param string $createFormat The format of the time string to be changed
@param string $timeString The time string
@param string $separator String between time/date
@throws DateException
@return string A re-formatted time string | [
"Public",
"method",
"for",
"getting",
"a",
"date",
"prepended",
"to",
"a",
"time",
"."
]
| train | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L218-L223 |
vufind-org/vufinddate | src/Converter.php | Converter.convertToDisplayTimeAndDate | public function convertToDisplayTimeAndDate($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayTime($createFormat, $timeString)
. $separator . $this->convertToDisplayDate($createFormat, $timeString);
} | php | public function convertToDisplayTimeAndDate($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayTime($createFormat, $timeString)
. $separator . $this->convertToDisplayDate($createFormat, $timeString);
} | [
"public",
"function",
"convertToDisplayTimeAndDate",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
",",
"$",
"separator",
"=",
"' '",
")",
"{",
"return",
"$",
"this",
"->",
"convertToDisplayTime",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
".",
"$",
"separator",
".",
"$",
"this",
"->",
"convertToDisplayDate",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
";",
"}"
]
| Public method for getting a time prepended to a date.
@param string $createFormat The format of the time string to be changed
@param string $timeString The time string
@param string $separator String between time/date
@throws DateException
@return string A re-formatted time string | [
"Public",
"method",
"for",
"getting",
"a",
"time",
"prepended",
"to",
"a",
"date",
"."
]
| train | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L235-L240 |
flextype-components/form | Form.php | Form.open | public static function open($action = '', array $attributes = null) : string
{
// Add the form action to the attributes
$attributes['action'] = $action;
if ( ! isset($attributes['method'])) {
// Use POST method
$attributes['method'] = 'post';
}
return '<form'.Html::attributes($attributes).'>';
} | php | public static function open($action = '', array $attributes = null) : string
{
// Add the form action to the attributes
$attributes['action'] = $action;
if ( ! isset($attributes['method'])) {
// Use POST method
$attributes['method'] = 'post';
}
return '<form'.Html::attributes($attributes).'>';
} | [
"public",
"static",
"function",
"open",
"(",
"$",
"action",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Add the form action to the attributes",
"$",
"attributes",
"[",
"'action'",
"]",
"=",
"$",
"action",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'method'",
"]",
")",
")",
"{",
"// Use POST method",
"$",
"attributes",
"[",
"'method'",
"]",
"=",
"'post'",
";",
"}",
"return",
"'<form'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
";",
"}"
]
| Create an opening HTML form tag.
// Form will submit back to the current page using POST
echo Form::open();
// Form will submit to 'search' using GET
echo Form::open('search', array('method' => 'get'));
// When "file" inputs are present, you must include the "enctype"
echo Form::open(null, array('enctype' => 'multipart/form-data'));
@param string $action Form action, defaults to the current request URI.
@param array $attributes HTML attributes.
@return string | [
"Create",
"an",
"opening",
"HTML",
"form",
"tag",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L72-L84 |
flextype-components/form | Form.php | Form.input | public static function input(string $name, string $value = '', array $attributes = null) : string
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id'])) ? $attributes['id'] : $name;
// Set the input value
$attributes['value'] = $value;
if ( ! isset($attributes['type'])) {
// Default type is text
$attributes['type'] = 'text';
}
return '<input'.Html::attributes($attributes).'>';
} | php | public static function input(string $name, string $value = '', array $attributes = null) : string
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id'])) ? $attributes['id'] : $name;
// Set the input value
$attributes['value'] = $value;
if ( ! isset($attributes['type'])) {
// Default type is text
$attributes['type'] = 'text';
}
return '<input'.Html::attributes($attributes).'>';
} | [
"public",
"static",
"function",
"input",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"// Set the input id",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"// Set the input value",
"$",
"attributes",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'type'",
"]",
")",
")",
"{",
"// Default type is text",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'text'",
";",
"}",
"return",
"'<input'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
";",
"}"
]
| Create a form input.
Text is default input type.
echo Form::input('username', $username);
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@return string | [
"Create",
"a",
"form",
"input",
".",
"Text",
"is",
"default",
"input",
"type",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L97-L115 |
flextype-components/form | Form.php | Form.hidden | public static function hidden(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'hidden';
return Form::input($name, $value, $attributes);
} | php | public static function hidden(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'hidden';
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"hidden",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'hidden'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Create a hidden form input.
echo Form::hidden('user_id', $user_id);
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@return string | [
"Create",
"a",
"hidden",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L127-L133 |
flextype-components/form | Form.php | Form.password | public static function password(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'password';
return Form::input($name, $value, $attributes);
} | php | public static function password(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'password';
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"password",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'password'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a password form input.
echo Form::password('password');
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@return string | [
"Creates",
"a",
"password",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L145-L151 |
flextype-components/form | Form.php | Form.file | public static function file(string $name, array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'file';
return Form::input($name, '', $attributes);
} | php | public static function file(string $name, array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'file';
return Form::input($name, '', $attributes);
} | [
"public",
"static",
"function",
"file",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'file'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"''",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a file upload form input.
echo Form::file('image');
@param string $name Input name
@param array $attributes HTML attributes
@return string | [
"Creates",
"a",
"file",
"upload",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L162-L168 |
flextype-components/form | Form.php | Form.checkbox | public static function checkbox($name, $value = '', $checked = false, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'checkbox';
if ($checked === true) {
// Make the checkbox active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | php | public static function checkbox($name, $value = '', $checked = false, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'checkbox';
if ($checked === true) {
// Make the checkbox active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"checkbox",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"''",
",",
"$",
"checked",
"=",
"false",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'checkbox'",
";",
"if",
"(",
"$",
"checked",
"===",
"true",
")",
"{",
"// Make the checkbox active",
"$",
"attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a checkbox form input.
echo Form::checkbox('i_am_not_a_robot');
@param string $name Input name
@param string $input Input value
@param boolean $checked Checked status
@param array $attributes HTML attributes
@uses Form::input
@return string | [
"Creates",
"a",
"checkbox",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L182-L193 |
flextype-components/form | Form.php | Form.radio | public static function radio($name, $value = '', $checked = null, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'radio';
if ($checked === true) {
// Make the radio active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | php | public static function radio($name, $value = '', $checked = null, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'radio';
if ($checked === true) {
// Make the radio active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"radio",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"''",
",",
"$",
"checked",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'radio'",
";",
"if",
"(",
"$",
"checked",
"===",
"true",
")",
"{",
"// Make the radio active",
"$",
"attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a radio form input.
echo Form::radio('i_am_not_a_robot');
@param string $name Input name
@param string $value Input value
@param boolean $checked Checked status
@param array $attributes HTML attributes
@uses Form::input
@return string | [
"Creates",
"a",
"radio",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L207-L218 |
flextype-components/form | Form.php | Form.textarea | public static function textarea($name, $body = '', array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
return '<textarea'.Html::attributes($attributes).'>'.$body.'</textarea>';
} | php | public static function textarea($name, $body = '', array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
return '<textarea'.Html::attributes($attributes).'>'.$body.'</textarea>';
} | [
"public",
"static",
"function",
"textarea",
"(",
"$",
"name",
",",
"$",
"body",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"// Set the input id",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"return",
"'<textarea'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"body",
".",
"'</textarea>'",
";",
"}"
]
| Creates a textarea form input.
echo Form::textarea('text', $text);
@param string $name Name
@param string $body Body
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"textarea",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L231-L240 |
flextype-components/form | Form.php | Form.select | public static function select($name, array $options = null, $selected = null, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
$options_output = '';
foreach ($options as $value => $name) {
if ($selected == $value) $current = ' selected '; else $current = '';
$options_output .= '<option value="'.$value.'" '.$current.'>'.$name.'</option>';
}
return '<select'.Html::attributes($attributes).'>'.$options_output.'</select>';
} | php | public static function select($name, array $options = null, $selected = null, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
$options_output = '';
foreach ($options as $value => $name) {
if ($selected == $value) $current = ' selected '; else $current = '';
$options_output .= '<option value="'.$value.'" '.$current.'>'.$name.'</option>';
}
return '<select'.Html::attributes($attributes).'>'.$options_output.'</select>';
} | [
"public",
"static",
"function",
"select",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"null",
",",
"$",
"selected",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"// Set the input id",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"$",
"options_output",
"=",
"''",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"selected",
"==",
"$",
"value",
")",
"$",
"current",
"=",
"' selected '",
";",
"else",
"$",
"current",
"=",
"''",
";",
"$",
"options_output",
".=",
"'<option value=\"'",
".",
"$",
"value",
".",
"'\" '",
".",
"$",
"current",
".",
"'>'",
".",
"$",
"name",
".",
"'</option>'",
";",
"}",
"return",
"'<select'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"options_output",
".",
"'</select>'",
";",
"}"
]
| Creates a select form input.
<code>
echo Form::select('themes', array('default', 'classic', 'modern'));
</code>
@param string $name Name
@param array $options Options array
@param string $selected Selected option
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"select",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L256-L272 |
flextype-components/form | Form.php | Form.submit | public static function submit($name, $value, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'submit';
return Form::input($name, $value, $attributes);
} | php | public static function submit($name, $value, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'submit';
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"submit",
"(",
"$",
"name",
",",
"$",
"value",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'submit'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a submit form input.
<code>
echo Form::submit('save', 'Save');
</code>
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@uses Form::input
@return string | [
"Creates",
"a",
"submit",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L287-L293 |
flextype-components/form | Form.php | Form.button | public static function button($name, $body, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
return '<button'.Html::attributes($attributes).'>'.$body.'</button>';
} | php | public static function button($name, $body, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
return '<button'.Html::attributes($attributes).'>'.$body.'</button>';
} | [
"public",
"static",
"function",
"button",
"(",
"$",
"name",
",",
"$",
"body",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"return",
"'<button'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"body",
".",
"'</button>'",
";",
"}"
]
| Creates a button form input.
echo Form::button('save', 'Save Profile', array('type' => 'submit'));
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"button",
"form",
"input",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L306-L312 |
flextype-components/form | Form.php | Form.label | public static function label($input, $text, array $attributes = null)
{
// Set the label target
$attributes['for'] = $input;
return '<label'.Html::attributes($attributes).'>'.$text.'</label>';
} | php | public static function label($input, $text, array $attributes = null)
{
// Set the label target
$attributes['for'] = $input;
return '<label'.Html::attributes($attributes).'>'.$text.'</label>';
} | [
"public",
"static",
"function",
"label",
"(",
"$",
"input",
",",
"$",
"text",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the label target",
"$",
"attributes",
"[",
"'for'",
"]",
"=",
"$",
"input",
";",
"return",
"'<label'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"text",
".",
"'</label>'",
";",
"}"
]
| Creates a form label.
echo Form::label('username', 'Username');
@param string $input Target input
@param string $text Label text
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"form",
"label",
"."
]
| train | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L325-L331 |
4devs/ElfinderPhpConnector | Connector.php | Connector.run | public function run($cmd, array $args)
{
if (!isset($this->commands[$cmd])) {
$this->error(sprintf('command %s not exists', $cmd));
}
$response = new Response();
$driverId = isset($args['target']) ? $this->getDriverId($args['target']) : '';
$driverId = !$driverId && isset($args['targets']) ? $this->getDriverId(current($args['targets'])) : $driverId;
$interface = $this->getInterfaceByCmd($cmd);
/*
* @var string $name
* @var DriverInterface $driver
*/
$data = null;
foreach ($this->driverList as $name => $driver) {
if (!$driverId || $driverId == $name) {
if ($driver instanceof $interface) {
if ($driver->mount()) {
$data = $this->runCmd($driver, $cmd, $args, $response);
}
$driver->unmount();
} else {
$this->error(sprintf('command "%s" not supported, please use interface "%s"', $cmd, $interface));
}
$this->addDisabledCommand($driver);
$response->setOptions($driver->getOptions());
}
$response->addFile($driver->getRootFileInfo());
}
if (!empty($args['init'])) {
$response->setApi(DriverInterface::VERSION);
}
return $data ?: $response;
} | php | public function run($cmd, array $args)
{
if (!isset($this->commands[$cmd])) {
$this->error(sprintf('command %s not exists', $cmd));
}
$response = new Response();
$driverId = isset($args['target']) ? $this->getDriverId($args['target']) : '';
$driverId = !$driverId && isset($args['targets']) ? $this->getDriverId(current($args['targets'])) : $driverId;
$interface = $this->getInterfaceByCmd($cmd);
/*
* @var string $name
* @var DriverInterface $driver
*/
$data = null;
foreach ($this->driverList as $name => $driver) {
if (!$driverId || $driverId == $name) {
if ($driver instanceof $interface) {
if ($driver->mount()) {
$data = $this->runCmd($driver, $cmd, $args, $response);
}
$driver->unmount();
} else {
$this->error(sprintf('command "%s" not supported, please use interface "%s"', $cmd, $interface));
}
$this->addDisabledCommand($driver);
$response->setOptions($driver->getOptions());
}
$response->addFile($driver->getRootFileInfo());
}
if (!empty($args['init'])) {
$response->setApi(DriverInterface::VERSION);
}
return $data ?: $response;
} | [
"public",
"function",
"run",
"(",
"$",
"cmd",
",",
"array",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd",
"]",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'command %s not exists'",
",",
"$",
"cmd",
")",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"driverId",
"=",
"isset",
"(",
"$",
"args",
"[",
"'target'",
"]",
")",
"?",
"$",
"this",
"->",
"getDriverId",
"(",
"$",
"args",
"[",
"'target'",
"]",
")",
":",
"''",
";",
"$",
"driverId",
"=",
"!",
"$",
"driverId",
"&&",
"isset",
"(",
"$",
"args",
"[",
"'targets'",
"]",
")",
"?",
"$",
"this",
"->",
"getDriverId",
"(",
"current",
"(",
"$",
"args",
"[",
"'targets'",
"]",
")",
")",
":",
"$",
"driverId",
";",
"$",
"interface",
"=",
"$",
"this",
"->",
"getInterfaceByCmd",
"(",
"$",
"cmd",
")",
";",
"/*\n * @var string $name\n * @var DriverInterface $driver\n */",
"$",
"data",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"driverList",
"as",
"$",
"name",
"=>",
"$",
"driver",
")",
"{",
"if",
"(",
"!",
"$",
"driverId",
"||",
"$",
"driverId",
"==",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"driver",
"instanceof",
"$",
"interface",
")",
"{",
"if",
"(",
"$",
"driver",
"->",
"mount",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"runCmd",
"(",
"$",
"driver",
",",
"$",
"cmd",
",",
"$",
"args",
",",
"$",
"response",
")",
";",
"}",
"$",
"driver",
"->",
"unmount",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'command \"%s\" not supported, please use interface \"%s\"'",
",",
"$",
"cmd",
",",
"$",
"interface",
")",
")",
";",
"}",
"$",
"this",
"->",
"addDisabledCommand",
"(",
"$",
"driver",
")",
";",
"$",
"response",
"->",
"setOptions",
"(",
"$",
"driver",
"->",
"getOptions",
"(",
")",
")",
";",
"}",
"$",
"response",
"->",
"addFile",
"(",
"$",
"driver",
"->",
"getRootFileInfo",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"'init'",
"]",
")",
")",
"{",
"$",
"response",
"->",
"setApi",
"(",
"DriverInterface",
"::",
"VERSION",
")",
";",
"}",
"return",
"$",
"data",
"?",
":",
"$",
"response",
";",
"}"
]
| run command.
@param string $cmd
@param array $args
@return Response|HttpResponse | [
"run",
"command",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L105-L140 |
4devs/ElfinderPhpConnector | Connector.php | Connector.getResponse | public function getResponse($cmd, array $args)
{
$data = $this->run($cmd, $args);
return $data instanceof HttpResponse ? $data : new JsonResponse($data->toArray());
} | php | public function getResponse($cmd, array $args)
{
$data = $this->run($cmd, $args);
return $data instanceof HttpResponse ? $data : new JsonResponse($data->toArray());
} | [
"public",
"function",
"getResponse",
"(",
"$",
"cmd",
",",
"array",
"$",
"args",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"cmd",
",",
"$",
"args",
")",
";",
"return",
"$",
"data",
"instanceof",
"HttpResponse",
"?",
"$",
"data",
":",
"new",
"JsonResponse",
"(",
"$",
"data",
"->",
"toArray",
"(",
")",
")",
";",
"}"
]
| @param string $cmd
@param array $args
@return Response|JsonResponse | [
"@param",
"string",
"$cmd",
"@param",
"array",
"$args"
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L148-L153 |
4devs/ElfinderPhpConnector | Connector.php | Connector.addDriver | public function addDriver(DriverInterface $driver)
{
$driver->setConnector($this);
$this->driverList[$driver->getDriverId()] = $driver;
return $this;
} | php | public function addDriver(DriverInterface $driver)
{
$driver->setConnector($this);
$this->driverList[$driver->getDriverId()] = $driver;
return $this;
} | [
"public",
"function",
"addDriver",
"(",
"DriverInterface",
"$",
"driver",
")",
"{",
"$",
"driver",
"->",
"setConnector",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"driverList",
"[",
"$",
"driver",
"->",
"getDriverId",
"(",
")",
"]",
"=",
"$",
"driver",
";",
"return",
"$",
"this",
";",
"}"
]
| add Driver.
@param DriverInterface $driver
@return $this | [
"add",
"Driver",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L176-L182 |
4devs/ElfinderPhpConnector | Connector.php | Connector.setDrivers | public function setDrivers(array $drivers)
{
$this->driverList = array();
foreach ($drivers as $driver) {
$this->addDriver($driver);
}
return $this;
} | php | public function setDrivers(array $drivers)
{
$this->driverList = array();
foreach ($drivers as $driver) {
$this->addDriver($driver);
}
return $this;
} | [
"public",
"function",
"setDrivers",
"(",
"array",
"$",
"drivers",
")",
"{",
"$",
"this",
"->",
"driverList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"drivers",
"as",
"$",
"driver",
")",
"{",
"$",
"this",
"->",
"addDriver",
"(",
"$",
"driver",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| set All Drivers.
@param array $drivers
@return $this | [
"set",
"All",
"Drivers",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L191-L199 |
4devs/ElfinderPhpConnector | Connector.php | Connector.error | public function error($message)
{
if ($this->logger) {
$this->logger->error($message);
}
if (!$this->debug) {
throw new \RuntimeException($message);
}
} | php | public function error($message)
{
if ($this->logger) {
$this->logger->error($message);
}
if (!$this->debug) {
throw new \RuntimeException($message);
}
} | [
"public",
"function",
"error",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"message",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"debug",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"message",
")",
";",
"}",
"}"
]
| error Handling.
@param string $message
@throws \RuntimeException | [
"error",
"Handling",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L208-L216 |
4devs/ElfinderPhpConnector | Connector.php | Connector.getDriverId | public function getDriverId($targetHash)
{
if (is_array($targetHash)) {
$targetHash = current($targetHash);
}
return substr($targetHash, 0, strpos($targetHash, '_'));
} | php | public function getDriverId($targetHash)
{
if (is_array($targetHash)) {
$targetHash = current($targetHash);
}
return substr($targetHash, 0, strpos($targetHash, '_'));
} | [
"public",
"function",
"getDriverId",
"(",
"$",
"targetHash",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"targetHash",
")",
")",
"{",
"$",
"targetHash",
"=",
"current",
"(",
"$",
"targetHash",
")",
";",
"}",
"return",
"substr",
"(",
"$",
"targetHash",
",",
"0",
",",
"strpos",
"(",
"$",
"targetHash",
",",
"'_'",
")",
")",
";",
"}"
]
| get Driver Id from hash target.
@param string $targetHash
@return string | [
"get",
"Driver",
"Id",
"from",
"hash",
"target",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L239-L246 |
4devs/ElfinderPhpConnector | Connector.php | Connector.runCmd | private function runCmd(DriverInterface $driver, $cmd, array $args, Response $response)
{
$data = null;
try {
if ($driver->isAllowedCommand($cmd)) {
$data = call_user_func_array(
array($driver, $cmd),
$this->getArgs($args, $cmd, $response, $driver->getDriverId())
);
} else {
$this->error(sprintf('command "%s" not allowed', $cmd));
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
return $data instanceof HttpResponse ? $data : $response;
} | php | private function runCmd(DriverInterface $driver, $cmd, array $args, Response $response)
{
$data = null;
try {
if ($driver->isAllowedCommand($cmd)) {
$data = call_user_func_array(
array($driver, $cmd),
$this->getArgs($args, $cmd, $response, $driver->getDriverId())
);
} else {
$this->error(sprintf('command "%s" not allowed', $cmd));
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
return $data instanceof HttpResponse ? $data : $response;
} | [
"private",
"function",
"runCmd",
"(",
"DriverInterface",
"$",
"driver",
",",
"$",
"cmd",
",",
"array",
"$",
"args",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"data",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"$",
"driver",
"->",
"isAllowedCommand",
"(",
"$",
"cmd",
")",
")",
"{",
"$",
"data",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"driver",
",",
"$",
"cmd",
")",
",",
"$",
"this",
"->",
"getArgs",
"(",
"$",
"args",
",",
"$",
"cmd",
",",
"$",
"response",
",",
"$",
"driver",
"->",
"getDriverId",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'command \"%s\" not allowed'",
",",
"$",
"cmd",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"data",
"instanceof",
"HttpResponse",
"?",
"$",
"data",
":",
"$",
"response",
";",
"}"
]
| run cmd.
@param DriverInterface $driver
@param string $cmd
@param array $args
@param Response $response
@return Response | [
"run",
"cmd",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L258-L275 |
4devs/ElfinderPhpConnector | Connector.php | Connector.addDisabledCommand | private function addDisabledCommand(AbstractDriver $driver)
{
foreach ($this->commands as $name => $command) {
$interface = $this->getInterfaceByCmd($name);
if (!$driver instanceof $interface) {
$driver->addDisabledCmd($name);
}
}
return $this;
} | php | private function addDisabledCommand(AbstractDriver $driver)
{
foreach ($this->commands as $name => $command) {
$interface = $this->getInterfaceByCmd($name);
if (!$driver instanceof $interface) {
$driver->addDisabledCmd($name);
}
}
return $this;
} | [
"private",
"function",
"addDisabledCommand",
"(",
"AbstractDriver",
"$",
"driver",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"name",
"=>",
"$",
"command",
")",
"{",
"$",
"interface",
"=",
"$",
"this",
"->",
"getInterfaceByCmd",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"driver",
"instanceof",
"$",
"interface",
")",
"{",
"$",
"driver",
"->",
"addDisabledCmd",
"(",
"$",
"name",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| add Disabled Command.
@param AbstractDriver $driver
@return $this | [
"add",
"Disabled",
"Command",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L296-L306 |
4devs/ElfinderPhpConnector | Connector.php | Connector.getArgs | private function getArgs(array $args, $cmd, $response, $driverId)
{
$response = array($response);
$allowedArgs = $this->commands[$cmd];
unset($allowedArgs['interface']);
foreach ($allowedArgs as $key => $value) {
if (isset($args[$key])) {
$response[$key] = $args[$key];
if (isset($this->filenameInRequest[$key])) {
$response[$key] = self::getNameByTarget($args[$key], $driverId);
} elseif ($key == 'targets') {
$response[$key] = array_map(
function ($val) use ($driverId) {
return self::getNameByTarget($val, $driverId);
},
$args[$key]
);
}
} elseif (isset($this->defaultValues[$key])) {
$response[$key] = $this->defaultValues[$key];
} elseif ($value) {
$this->error(sprintf('parameter "%s" in cmd "%s" required', $key, $cmd));
}
}
return $response;
} | php | private function getArgs(array $args, $cmd, $response, $driverId)
{
$response = array($response);
$allowedArgs = $this->commands[$cmd];
unset($allowedArgs['interface']);
foreach ($allowedArgs as $key => $value) {
if (isset($args[$key])) {
$response[$key] = $args[$key];
if (isset($this->filenameInRequest[$key])) {
$response[$key] = self::getNameByTarget($args[$key], $driverId);
} elseif ($key == 'targets') {
$response[$key] = array_map(
function ($val) use ($driverId) {
return self::getNameByTarget($val, $driverId);
},
$args[$key]
);
}
} elseif (isset($this->defaultValues[$key])) {
$response[$key] = $this->defaultValues[$key];
} elseif ($value) {
$this->error(sprintf('parameter "%s" in cmd "%s" required', $key, $cmd));
}
}
return $response;
} | [
"private",
"function",
"getArgs",
"(",
"array",
"$",
"args",
",",
"$",
"cmd",
",",
"$",
"response",
",",
"$",
"driverId",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"$",
"response",
")",
";",
"$",
"allowedArgs",
"=",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd",
"]",
";",
"unset",
"(",
"$",
"allowedArgs",
"[",
"'interface'",
"]",
")",
";",
"foreach",
"(",
"$",
"allowedArgs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"$",
"args",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filenameInRequest",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"getNameByTarget",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
",",
"$",
"driverId",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'targets'",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"array_map",
"(",
"function",
"(",
"$",
"val",
")",
"use",
"(",
"$",
"driverId",
")",
"{",
"return",
"self",
"::",
"getNameByTarget",
"(",
"$",
"val",
",",
"$",
"driverId",
")",
";",
"}",
",",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"defaultValues",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"defaultValues",
"[",
"$",
"key",
"]",
";",
"}",
"elseif",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'parameter \"%s\" in cmd \"%s\" required'",
",",
"$",
"key",
",",
"$",
"cmd",
")",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
]
| get Allowed Arguments.
@param array $args
@param string $cmd
@param Response $response
@param string $driverId
@return array | [
"get",
"Allowed",
"Arguments",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L318-L344 |
jfusion/org.jfusion.framework | src/Plugin/Auth.php | Auth.checkPassword | function checkPassword(Userinfo $userinfo) {
return $this->comparePassword($userinfo->password, $this->generateEncryptedPassword($userinfo));
} | php | function checkPassword(Userinfo $userinfo) {
return $this->comparePassword($userinfo->password, $this->generateEncryptedPassword($userinfo));
} | [
"function",
"checkPassword",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"return",
"$",
"this",
"->",
"comparePassword",
"(",
"$",
"userinfo",
"->",
"password",
",",
"$",
"this",
"->",
"generateEncryptedPassword",
"(",
"$",
"userinfo",
")",
")",
";",
"}"
]
| used by framework to ensure a password test
@param Userinfo $userinfo userdata object containing the userdata
@return boolean | [
"used",
"by",
"framework",
"to",
"ensure",
"a",
"password",
"test"
]
| train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Auth.php#L61-L63 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.byteSplit | protected static function byteSplit($x, $bytes)
{
if (is_int($x)) {
if ($x < 0) {
$x = sprintf("%u", $x);
}
}
$res = array();
while ($bytes > 0) {
$b = bcmod($x, '256');
$res[] = (int)$b;
$x = bcdiv($x, '256', 0);
$bytes--;
}
$res = array_reverse($res);
// if ($x != 0) {
// throw new \Exception('Value too big!');
// }
return $res;
} | php | protected static function byteSplit($x, $bytes)
{
if (is_int($x)) {
if ($x < 0) {
$x = sprintf("%u", $x);
}
}
$res = array();
while ($bytes > 0) {
$b = bcmod($x, '256');
$res[] = (int)$b;
$x = bcdiv($x, '256', 0);
$bytes--;
}
$res = array_reverse($res);
// if ($x != 0) {
// throw new \Exception('Value too big!');
// }
return $res;
} | [
"protected",
"static",
"function",
"byteSplit",
"(",
"$",
"x",
",",
"$",
"bytes",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"x",
")",
")",
"{",
"if",
"(",
"$",
"x",
"<",
"0",
")",
"{",
"$",
"x",
"=",
"sprintf",
"(",
"\"%u\"",
",",
"$",
"x",
")",
";",
"}",
"}",
"$",
"res",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"bytes",
">",
"0",
")",
"{",
"$",
"b",
"=",
"bcmod",
"(",
"$",
"x",
",",
"'256'",
")",
";",
"$",
"res",
"[",
"]",
"=",
"(",
"int",
")",
"$",
"b",
";",
"$",
"x",
"=",
"bcdiv",
"(",
"$",
"x",
",",
"'256'",
",",
"0",
")",
";",
"$",
"bytes",
"--",
";",
"}",
"$",
"res",
"=",
"array_reverse",
"(",
"$",
"res",
")",
";",
"// if ($x != 0) {",
"// throw new \\Exception('Value too big!');",
"// }",
"return",
"$",
"res",
";",
"}"
]
| Splits number (could be either int or string) into array of byte
values (represented as integers) in big-endian byte order.
@static
@param $x
@param $bytes
@return array
@throws \Exception | [
"Splits",
"number",
"(",
"could",
"be",
"either",
"int",
"or",
"string",
")",
"into",
"array",
"of",
"byte",
"values",
"(",
"represented",
"as",
"integers",
")",
"in",
"big",
"-",
"endian",
"byte",
"order",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L50-L74 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeOctet | public function writeOctet($n)
{
if ($n < 0 || $n > 255) {
throw new \InvalidArgumentException('Octet out of range 0..255');
}
$this->flushBits();
$this->out .= chr($n);
return $this;
} | php | public function writeOctet($n)
{
if ($n < 0 || $n > 255) {
throw new \InvalidArgumentException('Octet out of range 0..255');
}
$this->flushBits();
$this->out .= chr($n);
return $this;
} | [
"public",
"function",
"writeOctet",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"<",
"0",
"||",
"$",
"n",
">",
"255",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Octet out of range 0..255'",
")",
";",
"}",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"chr",
"(",
"$",
"n",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 8-bit value.
@param $n
@return Writer
@throws \InvalidArgumentException | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"8",
"-",
"bit",
"value",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L138-L147 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeShort | public function writeShort($n)
{
if ($n < 0 || $n > 65535) {
throw new \InvalidArgumentException('Octet out of range 0..65535');
}
$this->flushBits();
$this->out .= pack('n', $n);
return $this;
} | php | public function writeShort($n)
{
if ($n < 0 || $n > 65535) {
throw new \InvalidArgumentException('Octet out of range 0..65535');
}
$this->flushBits();
$this->out .= pack('n', $n);
return $this;
} | [
"public",
"function",
"writeShort",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"<",
"0",
"||",
"$",
"n",
">",
"65535",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Octet out of range 0..65535'",
")",
";",
"}",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"pack",
"(",
"'n'",
",",
"$",
"n",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 16-bit value.
@param $n
@return Writer
@throws \InvalidArgumentException | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"16",
"-",
"bit",
"value",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L157-L166 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeLong | public function writeLong($n)
{
$this->flushBits();
$this->out .= implode('', Writer::chrByteSplit($n, 4));
return $this;
} | php | public function writeLong($n)
{
$this->flushBits();
$this->out .= implode('', Writer::chrByteSplit($n, 4));
return $this;
} | [
"public",
"function",
"writeLong",
"(",
"$",
"n",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"implode",
"(",
"''",
",",
"Writer",
"::",
"chrByteSplit",
"(",
"$",
"n",
",",
"4",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 32-bit value.
@param $n
@return Writer | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"32",
"-",
"bit",
"value",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L175-L180 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeLongLong | public function writeLongLong($n)
{
$this->flushBits();
$this->out .= implode('', Writer::chrByteSplit($n, 8));
return $this;
} | php | public function writeLongLong($n)
{
$this->flushBits();
$this->out .= implode('', Writer::chrByteSplit($n, 8));
return $this;
} | [
"public",
"function",
"writeLongLong",
"(",
"$",
"n",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"implode",
"(",
"''",
",",
"Writer",
"::",
"chrByteSplit",
"(",
"$",
"n",
",",
"8",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 64-bit value.
@param $n
@return Writer | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"64",
"-",
"bit",
"value",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L201-L206 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeShortStr | public function writeShortStr($s)
{
$this->flushBits();
if (strlen($s) > 255) {
throw new \InvalidArgumentException('String too long');
}
$this->writeOctet(strlen($s));
$this->out .= $s;
return $this;
} | php | public function writeShortStr($s)
{
$this->flushBits();
if (strlen($s) > 255) {
throw new \InvalidArgumentException('String too long');
}
$this->writeOctet(strlen($s));
$this->out .= $s;
return $this;
} | [
"public",
"function",
"writeShortStr",
"(",
"$",
"s",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"s",
")",
">",
"255",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'String too long'",
")",
";",
"}",
"$",
"this",
"->",
"writeOctet",
"(",
"strlen",
"(",
"$",
"s",
")",
")",
";",
"$",
"this",
"->",
"out",
".=",
"$",
"s",
";",
"return",
"$",
"this",
";",
"}"
]
| Write a string up to 255 bytes long after encoding.
Assume UTF-8 encoding.
@param $s
@return Writer
@throws \InvalidArgumentException | [
"Write",
"a",
"string",
"up",
"to",
"255",
"bytes",
"long",
"after",
"encoding",
".",
"Assume",
"UTF",
"-",
"8",
"encoding",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L217-L227 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeLongStr | public function writeLongStr($s)
{
$this->flushBits();
$this->writeLong(strlen($s));
$this->out .= $s;
return $this;
} | php | public function writeLongStr($s)
{
$this->flushBits();
$this->writeLong(strlen($s));
$this->out .= $s;
return $this;
} | [
"public",
"function",
"writeLongStr",
"(",
"$",
"s",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"writeLong",
"(",
"strlen",
"(",
"$",
"s",
")",
")",
";",
"$",
"this",
"->",
"out",
".=",
"$",
"s",
";",
"return",
"$",
"this",
";",
"}"
]
| Write a string up to 2**32 bytes long. Assume UTF-8 encoding.
@param $s
@return Writer | [
"Write",
"a",
"string",
"up",
"to",
"2",
"**",
"32",
"bytes",
"long",
".",
"Assume",
"UTF",
"-",
"8",
"encoding",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L236-L242 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeArray | public function writeArray($a)
{
$this->flushBits();
$data = new Writer();
foreach ($a as $v) {
if (is_string($v)) {
$data->write('S');
$data->writeLongStr($v);
} else if (is_int($v)) {
$data->write('I');
$data->_writeSignedLong($v);
} else if ($v instanceof Decimal) {
$data->write('D');
$data->writeOctet($v->e);
$data->_writeSignedLong($v->n);
} else if (is_array($v)) {
$data->write('A');
$data->writeArray($v);
}
}
$data = $data->getvalue();
$this->writeLong(strlen($data));
$this->write($data);
return $this;
} | php | public function writeArray($a)
{
$this->flushBits();
$data = new Writer();
foreach ($a as $v) {
if (is_string($v)) {
$data->write('S');
$data->writeLongStr($v);
} else if (is_int($v)) {
$data->write('I');
$data->_writeSignedLong($v);
} else if ($v instanceof Decimal) {
$data->write('D');
$data->writeOctet($v->e);
$data->_writeSignedLong($v->n);
} else if (is_array($v)) {
$data->write('A');
$data->writeArray($v);
}
}
$data = $data->getvalue();
$this->writeLong(strlen($data));
$this->write($data);
return $this;
} | [
"public",
"function",
"writeArray",
"(",
"$",
"a",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"data",
"=",
"new",
"Writer",
"(",
")",
";",
"foreach",
"(",
"$",
"a",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"v",
")",
")",
"{",
"$",
"data",
"->",
"write",
"(",
"'S'",
")",
";",
"$",
"data",
"->",
"writeLongStr",
"(",
"$",
"v",
")",
";",
"}",
"else",
"if",
"(",
"is_int",
"(",
"$",
"v",
")",
")",
"{",
"$",
"data",
"->",
"write",
"(",
"'I'",
")",
";",
"$",
"data",
"->",
"_writeSignedLong",
"(",
"$",
"v",
")",
";",
"}",
"else",
"if",
"(",
"$",
"v",
"instanceof",
"Decimal",
")",
"{",
"$",
"data",
"->",
"write",
"(",
"'D'",
")",
";",
"$",
"data",
"->",
"writeOctet",
"(",
"$",
"v",
"->",
"e",
")",
";",
"$",
"data",
"->",
"_writeSignedLong",
"(",
"$",
"v",
"->",
"n",
")",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"data",
"->",
"write",
"(",
"'A'",
")",
";",
"$",
"data",
"->",
"writeArray",
"(",
"$",
"v",
")",
";",
"}",
"}",
"$",
"data",
"=",
"$",
"data",
"->",
"getvalue",
"(",
")",
";",
"$",
"this",
"->",
"writeLong",
"(",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Supports the writing of Array types, so that you can implement
array methods, like Rabbitmq's HA parameters
@param array $a
@return self | [
"Supports",
"the",
"writing",
"of",
"Array",
"types",
"so",
"that",
"you",
"can",
"implement",
"array",
"methods",
"like",
"Rabbitmq",
"s",
"HA",
"parameters"
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L252-L278 |
zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeTable | public function writeTable($d)
{
$this->flushBits();
$table_data = new Writer();
foreach ($d as $k => $va) {
list($ftype, $v) = $va;
$table_data->writeShortStr($k);
if ($ftype == 'S') {
$table_data->write('S');
$table_data->writeLongStr($v);
} else if ($ftype == 'I') {
$table_data->write('I');
$table_data->_writeSignedLong($v);
} else if ($ftype == 'D') {
// 'D' type values are passed Decimal instances.
$table_data->write('D');
$table_data->writeOctet($v->e);
$table_data->_writeSignedLong($v->n);
} else if ($ftype == 'T') {
$table_data->write('T');
$table_data->writeTimestamp($v);
} else if ($ftype == 'F') {
$table_data->write('F');
$table_data->writeTable($v);
} else if ($ftype = 'A') {
$table_data->write('A');
$table_data->writeArray($v);
}
}
$table_data = $table_data->getvalue();
$this->writeLong(strlen($table_data));
$this->write($table_data);
return $this;
} | php | public function writeTable($d)
{
$this->flushBits();
$table_data = new Writer();
foreach ($d as $k => $va) {
list($ftype, $v) = $va;
$table_data->writeShortStr($k);
if ($ftype == 'S') {
$table_data->write('S');
$table_data->writeLongStr($v);
} else if ($ftype == 'I') {
$table_data->write('I');
$table_data->_writeSignedLong($v);
} else if ($ftype == 'D') {
// 'D' type values are passed Decimal instances.
$table_data->write('D');
$table_data->writeOctet($v->e);
$table_data->_writeSignedLong($v->n);
} else if ($ftype == 'T') {
$table_data->write('T');
$table_data->writeTimestamp($v);
} else if ($ftype == 'F') {
$table_data->write('F');
$table_data->writeTable($v);
} else if ($ftype = 'A') {
$table_data->write('A');
$table_data->writeArray($v);
}
}
$table_data = $table_data->getvalue();
$this->writeLong(strlen($table_data));
$this->write($table_data);
return $this;
} | [
"public",
"function",
"writeTable",
"(",
"$",
"d",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"table_data",
"=",
"new",
"Writer",
"(",
")",
";",
"foreach",
"(",
"$",
"d",
"as",
"$",
"k",
"=>",
"$",
"va",
")",
"{",
"list",
"(",
"$",
"ftype",
",",
"$",
"v",
")",
"=",
"$",
"va",
";",
"$",
"table_data",
"->",
"writeShortStr",
"(",
"$",
"k",
")",
";",
"if",
"(",
"$",
"ftype",
"==",
"'S'",
")",
"{",
"$",
"table_data",
"->",
"write",
"(",
"'S'",
")",
";",
"$",
"table_data",
"->",
"writeLongStr",
"(",
"$",
"v",
")",
";",
"}",
"else",
"if",
"(",
"$",
"ftype",
"==",
"'I'",
")",
"{",
"$",
"table_data",
"->",
"write",
"(",
"'I'",
")",
";",
"$",
"table_data",
"->",
"_writeSignedLong",
"(",
"$",
"v",
")",
";",
"}",
"else",
"if",
"(",
"$",
"ftype",
"==",
"'D'",
")",
"{",
"// 'D' type values are passed Decimal instances.",
"$",
"table_data",
"->",
"write",
"(",
"'D'",
")",
";",
"$",
"table_data",
"->",
"writeOctet",
"(",
"$",
"v",
"->",
"e",
")",
";",
"$",
"table_data",
"->",
"_writeSignedLong",
"(",
"$",
"v",
"->",
"n",
")",
";",
"}",
"else",
"if",
"(",
"$",
"ftype",
"==",
"'T'",
")",
"{",
"$",
"table_data",
"->",
"write",
"(",
"'T'",
")",
";",
"$",
"table_data",
"->",
"writeTimestamp",
"(",
"$",
"v",
")",
";",
"}",
"else",
"if",
"(",
"$",
"ftype",
"==",
"'F'",
")",
"{",
"$",
"table_data",
"->",
"write",
"(",
"'F'",
")",
";",
"$",
"table_data",
"->",
"writeTable",
"(",
"$",
"v",
")",
";",
"}",
"else",
"if",
"(",
"$",
"ftype",
"=",
"'A'",
")",
"{",
"$",
"table_data",
"->",
"write",
"(",
"'A'",
")",
";",
"$",
"table_data",
"->",
"writeArray",
"(",
"$",
"v",
")",
";",
"}",
"}",
"$",
"table_data",
"=",
"$",
"table_data",
"->",
"getvalue",
"(",
")",
";",
"$",
"this",
"->",
"writeLong",
"(",
"strlen",
"(",
"$",
"table_data",
")",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"table_data",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write PHP array, as table. Input array format: keys are strings,
values are (type,value) tuples.
@param $d
@return Writer | [
"Write",
"PHP",
"array",
"as",
"table",
".",
"Input",
"array",
"format",
":",
"keys",
"are",
"strings",
"values",
"are",
"(",
"type",
"value",
")",
"tuples",
"."
]
| train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L301-L335 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/IOFactory.php | PHPWord_IOFactory.createWriter | public static function createWriter(PHPWord $PHPWord, $writerType = '') {
$searchType = 'IWriter';
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
$instance = new $className($PHPWord);
if(!is_null($instance)) {
return $instance;
}
}
}
throw new Exception("No $searchType found for type $writerType");
} | php | public static function createWriter(PHPWord $PHPWord, $writerType = '') {
$searchType = 'IWriter';
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
$instance = new $className($PHPWord);
if(!is_null($instance)) {
return $instance;
}
}
}
throw new Exception("No $searchType found for type $writerType");
} | [
"public",
"static",
"function",
"createWriter",
"(",
"PHPWord",
"$",
"PHPWord",
",",
"$",
"writerType",
"=",
"''",
")",
"{",
"$",
"searchType",
"=",
"'IWriter'",
";",
"foreach",
"(",
"self",
"::",
"$",
"_searchLocations",
"as",
"$",
"searchLocation",
")",
"{",
"if",
"(",
"$",
"searchLocation",
"[",
"'type'",
"]",
"==",
"$",
"searchType",
")",
"{",
"$",
"className",
"=",
"str_replace",
"(",
"'{0}'",
",",
"$",
"writerType",
",",
"$",
"searchLocation",
"[",
"'class'",
"]",
")",
";",
"$",
"classFile",
"=",
"str_replace",
"(",
"'{0}'",
",",
"$",
"writerType",
",",
"$",
"searchLocation",
"[",
"'path'",
"]",
")",
";",
"$",
"instance",
"=",
"new",
"$",
"className",
"(",
"$",
"PHPWord",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"instance",
")",
")",
"{",
"return",
"$",
"instance",
";",
"}",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"\"No $searchType found for type $writerType\"",
")",
";",
"}"
]
| Create PHPWord_Writer_IWriter
@param PHPWord $PHPWord
@param string $writerType Example: Word2007
@return PHPWord_Writer_IWriter | [
"Create",
"PHPWord_Writer_IWriter"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/IOFactory.php#L102-L118 |
webforge-labs/psc-cms | lib/Psc/Form/I18nWrapperValidatorRule.php | I18nWrapperValidatorRule.validate | public function validate($data) {
if ($data === NULL) throw $this->emptyException();
if (!is_array($data)) throw $this->invalidArgument(1, $data, 'Array', __FUNCTION__);
foreach ($this->languages as $lang) {
if (!array_key_exists($lang, $data)) {
throw $this->emptyException();
}
try {
$data[$lang] = $this->wrappedRule->validate($data[$lang]);
} catch (EmptyDataException $e) {
throw $this->emptyException($e);
}
}
return $data;
} | php | public function validate($data) {
if ($data === NULL) throw $this->emptyException();
if (!is_array($data)) throw $this->invalidArgument(1, $data, 'Array', __FUNCTION__);
foreach ($this->languages as $lang) {
if (!array_key_exists($lang, $data)) {
throw $this->emptyException();
}
try {
$data[$lang] = $this->wrappedRule->validate($data[$lang]);
} catch (EmptyDataException $e) {
throw $this->emptyException($e);
}
}
return $data;
} | [
"public",
"function",
"validate",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"NULL",
")",
"throw",
"$",
"this",
"->",
"emptyException",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"throw",
"$",
"this",
"->",
"invalidArgument",
"(",
"1",
",",
"$",
"data",
",",
"'Array'",
",",
"__FUNCTION__",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"languages",
"as",
"$",
"lang",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"lang",
",",
"$",
"data",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"emptyException",
"(",
")",
";",
"}",
"try",
"{",
"$",
"data",
"[",
"$",
"lang",
"]",
"=",
"$",
"this",
"->",
"wrappedRule",
"->",
"validate",
"(",
"$",
"data",
"[",
"$",
"lang",
"]",
")",
";",
"}",
"catch",
"(",
"EmptyDataException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"emptyException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
]
| Validiert alle für alle sprachen der Data die Daten der Inneren Componente
@return $data | [
"Validiert",
"alle",
"für",
"alle",
"sprachen",
"der",
"Data",
"die",
"Daten",
"der",
"Inneren",
"Componente"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Form/I18nWrapperValidatorRule.php#L30-L47 |
GrahamDeprecated/CMS-Core | src/CMSCoreServiceProvider.php | CMSCoreServiceProvider.setupViewer | protected function setupViewer()
{
$this->app->bindShared('viewer', function ($app) {
$view = $app['view'];
$credentials = $app['credentials'];
$navigation = $app['navigation'];
$pageprovider = $app['pageprovider'];
$name = $app['config']['platform.name'];
$inverse = $app['config']['theme.inverse'];
return new Classes\Viewer($view, $credentials, $navigation, $pageprovider, $name, $inverse);
});
} | php | protected function setupViewer()
{
$this->app->bindShared('viewer', function ($app) {
$view = $app['view'];
$credentials = $app['credentials'];
$navigation = $app['navigation'];
$pageprovider = $app['pageprovider'];
$name = $app['config']['platform.name'];
$inverse = $app['config']['theme.inverse'];
return new Classes\Viewer($view, $credentials, $navigation, $pageprovider, $name, $inverse);
});
} | [
"protected",
"function",
"setupViewer",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'viewer'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"view",
"=",
"$",
"app",
"[",
"'view'",
"]",
";",
"$",
"credentials",
"=",
"$",
"app",
"[",
"'credentials'",
"]",
";",
"$",
"navigation",
"=",
"$",
"app",
"[",
"'navigation'",
"]",
";",
"$",
"pageprovider",
"=",
"$",
"app",
"[",
"'pageprovider'",
"]",
";",
"$",
"name",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'platform.name'",
"]",
";",
"$",
"inverse",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'theme.inverse'",
"]",
";",
"return",
"new",
"Classes",
"\\",
"Viewer",
"(",
"$",
"view",
",",
"$",
"credentials",
",",
"$",
"navigation",
",",
"$",
"pageprovider",
",",
"$",
"name",
",",
"$",
"inverse",
")",
";",
"}",
")",
";",
"}"
]
| Setup the viewer class.
@return void | [
"Setup",
"the",
"viewer",
"class",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/CMSCoreServiceProvider.php#L56-L68 |
GrahamDeprecated/CMS-Core | src/CMSCoreServiceProvider.php | CMSCoreServiceProvider.registerCommentProvider | protected function registerCommentProvider()
{
$this->app->bindShared('commentprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::comment'];
$comment = new $model();
return new Providers\CommentProvider($comment);
});
} | php | protected function registerCommentProvider()
{
$this->app->bindShared('commentprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::comment'];
$comment = new $model();
return new Providers\CommentProvider($comment);
});
} | [
"protected",
"function",
"registerCommentProvider",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'commentprovider'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"model",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'graham-campbell/cms-core::comment'",
"]",
";",
"$",
"comment",
"=",
"new",
"$",
"model",
"(",
")",
";",
"return",
"new",
"Providers",
"\\",
"CommentProvider",
"(",
"$",
"comment",
")",
";",
"}",
")",
";",
"}"
]
| Register the comment provider class.
@return void | [
"Register",
"the",
"comment",
"provider",
"class",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/CMSCoreServiceProvider.php#L88-L96 |
GrahamDeprecated/CMS-Core | src/CMSCoreServiceProvider.php | CMSCoreServiceProvider.registerEventProvider | protected function registerEventProvider()
{
$this->app->bindShared('eventprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::event'];
$event = new $model();
return new Providers\EventProvider($event);
});
} | php | protected function registerEventProvider()
{
$this->app->bindShared('eventprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::event'];
$event = new $model();
return new Providers\EventProvider($event);
});
} | [
"protected",
"function",
"registerEventProvider",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'eventprovider'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"model",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'graham-campbell/cms-core::event'",
"]",
";",
"$",
"event",
"=",
"new",
"$",
"model",
"(",
")",
";",
"return",
"new",
"Providers",
"\\",
"EventProvider",
"(",
"$",
"event",
")",
";",
"}",
")",
";",
"}"
]
| Register the event provider class.
@return void | [
"Register",
"the",
"event",
"provider",
"class",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/CMSCoreServiceProvider.php#L103-L111 |
GrahamDeprecated/CMS-Core | src/CMSCoreServiceProvider.php | CMSCoreServiceProvider.registerPageProvider | protected function registerPageProvider()
{
$this->app->bindShared('pageprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::page'];
$page = new $model();
return new Providers\PageProvider($page);
});
} | php | protected function registerPageProvider()
{
$this->app->bindShared('pageprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::page'];
$page = new $model();
return new Providers\PageProvider($page);
});
} | [
"protected",
"function",
"registerPageProvider",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'pageprovider'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"model",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'graham-campbell/cms-core::page'",
"]",
";",
"$",
"page",
"=",
"new",
"$",
"model",
"(",
")",
";",
"return",
"new",
"Providers",
"\\",
"PageProvider",
"(",
"$",
"page",
")",
";",
"}",
")",
";",
"}"
]
| Register the page provider class.
@return void | [
"Register",
"the",
"page",
"provider",
"class",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/CMSCoreServiceProvider.php#L118-L126 |
GrahamDeprecated/CMS-Core | src/CMSCoreServiceProvider.php | CMSCoreServiceProvider.registerPostProvider | protected function registerPostProvider()
{
$this->app->bindShared('postprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::post'];
$post = new $model();
return new Providers\PostProvider($post);
});
} | php | protected function registerPostProvider()
{
$this->app->bindShared('postprovider', function ($app) {
$model = $app['config']['graham-campbell/cms-core::post'];
$post = new $model();
return new Providers\PostProvider($post);
});
} | [
"protected",
"function",
"registerPostProvider",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'postprovider'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"model",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'graham-campbell/cms-core::post'",
"]",
";",
"$",
"post",
"=",
"new",
"$",
"model",
"(",
")",
";",
"return",
"new",
"Providers",
"\\",
"PostProvider",
"(",
"$",
"post",
")",
";",
"}",
")",
";",
"}"
]
| Register the post provider class.
@return void | [
"Register",
"the",
"post",
"provider",
"class",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/CMSCoreServiceProvider.php#L133-L141 |
phore/phore-filesystem | src/FileStream.php | FileStream.getMetadata | public function getMetadata($key = null)
{
if ($key !== null)
return stream_get_meta_data($this->res)[$key];
return stream_get_meta_data($this->res);
} | php | public function getMetadata($key = null)
{
if ($key !== null)
return stream_get_meta_data($this->res)[$key];
return stream_get_meta_data($this->res);
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"return",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"res",
")",
"[",
"$",
"key",
"]",
";",
"return",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"res",
")",
";",
"}"
]
| Get stream metadata as an associative array or retrieve a specific key.
The keys returned are identical to the keys returned from PHP's
stream_get_meta_data() function.
@link http://php.net/manual/en/function.stream-get-meta-data.php
@param string $key Specific metadata to retrieve.
@return array|mixed|null Returns an associative array if no key is
provided. Returns a specific key value if a key is provided and the
value is found, or null if the key is not found. | [
"Get",
"stream",
"metadata",
"as",
"an",
"associative",
"array",
"or",
"retrieve",
"a",
"specific",
"key",
"."
]
| train | https://github.com/phore/phore-filesystem/blob/be7d4d3f6d21fd08fdb4eb24120a45050d9422e2/src/FileStream.php#L298-L303 |
forkiss/pharest | src/Pharest/Model.php | Model.firstOrFail | public static function firstOrFail($parameters, $message = '')
{
$query = parent::findFirst($parameters);
if (!$query) {
if (!$message) {
$message = 'data can not be found';
}
throw new \Pharest\Exception\ModelException($message, 100091);
}
return $query;
} | php | public static function firstOrFail($parameters, $message = '')
{
$query = parent::findFirst($parameters);
if (!$query) {
if (!$message) {
$message = 'data can not be found';
}
throw new \Pharest\Exception\ModelException($message, 100091);
}
return $query;
} | [
"public",
"static",
"function",
"firstOrFail",
"(",
"$",
"parameters",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"query",
"=",
"parent",
"::",
"findFirst",
"(",
"$",
"parameters",
")",
";",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"$",
"message",
")",
"{",
"$",
"message",
"=",
"'data can not be found'",
";",
"}",
"throw",
"new",
"\\",
"Pharest",
"\\",
"Exception",
"\\",
"ModelException",
"(",
"$",
"message",
",",
"100091",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
]
| Allows to query the first record that match the specified conditions
@param mixed $parameters
@param string $message
@return static | [
"Allows",
"to",
"query",
"the",
"first",
"record",
"that",
"match",
"the",
"specified",
"conditions"
]
| train | https://github.com/forkiss/pharest/blob/f8b444f9bba446bf7994d98f27585529aefed565/src/Pharest/Model.php#L60-L74 |
Lansoweb/LosBase | src/LosBase/DBAL/Types/UtcDateTimeType.php | UtcDateTimeType.convertToDatabaseValue | public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return;
}
$formatString = $platform->getDateTimeFormatString();
$formatted = $value->setTimezone(new \DateTimeZone('UTC'))->format($formatString);
return $formatted;
} | php | public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return;
}
$formatString = $platform->getDateTimeFormatString();
$formatted = $value->setTimezone(new \DateTimeZone('UTC'))->format($formatString);
return $formatted;
} | [
"public",
"function",
"convertToDatabaseValue",
"(",
"$",
"value",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"formatString",
"=",
"$",
"platform",
"->",
"getDateTimeFormatString",
"(",
")",
";",
"$",
"formatted",
"=",
"$",
"value",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
"->",
"format",
"(",
"$",
"formatString",
")",
";",
"return",
"$",
"formatted",
";",
"}"
]
| @param DateTime $value
@param Doctrine\DBAL\Platforms\AbstractPlatform $platform
@return string | [
"@param",
"DateTime",
"$value",
"@param",
"Doctrine",
"\\",
"DBAL",
"\\",
"Platforms",
"\\",
"AbstractPlatform",
"$platform"
]
| train | https://github.com/Lansoweb/LosBase/blob/90e18a53d29c1bd841c149dca43aa365eecc656d/src/LosBase/DBAL/Types/UtcDateTimeType.php#L17-L27 |
Lansoweb/LosBase | src/LosBase/DBAL/Types/UtcDateTimeType.php | UtcDateTimeType.convertToPHPValue | public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return;
}
$val = \DateTime::createFromFormat(
$platform->getDateTimeFormatString(),
$value,
new \DateTimeZone('UTC')
);
if (!$val) {
throw ConversionException::conversionFailed($value, $this->getName());
}
return $val;
} | php | public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return;
}
$val = \DateTime::createFromFormat(
$platform->getDateTimeFormatString(),
$value,
new \DateTimeZone('UTC')
);
if (!$val) {
throw ConversionException::conversionFailed($value, $this->getName());
}
return $val;
} | [
"public",
"function",
"convertToPHPValue",
"(",
"$",
"value",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"val",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"platform",
"->",
"getDateTimeFormatString",
"(",
")",
",",
"$",
"value",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"if",
"(",
"!",
"$",
"val",
")",
"{",
"throw",
"ConversionException",
"::",
"conversionFailed",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
"val",
";",
"}"
]
| @param string $value
@param DoctrineDBALPlatformsAbstractPlatform $platform
@return DateTime|mixed|null
@throws DoctrineDBALTypesConversionException | [
"@param",
"string",
"$value",
"@param",
"DoctrineDBALPlatformsAbstractPlatform",
"$platform"
]
| train | https://github.com/Lansoweb/LosBase/blob/90e18a53d29c1bd841c149dca43aa365eecc656d/src/LosBase/DBAL/Types/UtcDateTimeType.php#L37-L53 |
forxer/tao | src/Tao/Templating/Helpers/TitleTag.php | TitleTag.add | public function add($sTitle, $bPrepend = false)
{
if ($bPrepend)
{
$this->aTitles = array_reverse($this->aTitles, true);
$this->aTitles[$sTitle] = $sTitle;
$this->aTitles = array_reverse($this->aTitles, true);
}
else {
$this->aTitles[$sTitle] = $sTitle;
}
} | php | public function add($sTitle, $bPrepend = false)
{
if ($bPrepend)
{
$this->aTitles = array_reverse($this->aTitles, true);
$this->aTitles[$sTitle] = $sTitle;
$this->aTitles = array_reverse($this->aTitles, true);
}
else {
$this->aTitles[$sTitle] = $sTitle;
}
} | [
"public",
"function",
"add",
"(",
"$",
"sTitle",
",",
"$",
"bPrepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"bPrepend",
")",
"{",
"$",
"this",
"->",
"aTitles",
"=",
"array_reverse",
"(",
"$",
"this",
"->",
"aTitles",
",",
"true",
")",
";",
"$",
"this",
"->",
"aTitles",
"[",
"$",
"sTitle",
"]",
"=",
"$",
"sTitle",
";",
"$",
"this",
"->",
"aTitles",
"=",
"array_reverse",
"(",
"$",
"this",
"->",
"aTitles",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aTitles",
"[",
"$",
"sTitle",
"]",
"=",
"$",
"sTitle",
";",
"}",
"}"
]
| Add a title tag to the titles tag stack.
@param string $sTitle
@param boolean $bPrepend | [
"Add",
"a",
"title",
"tag",
"to",
"the",
"titles",
"tag",
"stack",
"."
]
| train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/TitleTag.php#L16-L27 |
forxer/tao | src/Tao/Templating/Helpers/TitleTag.php | TitleTag.has | public function has($sTitle = null)
{
if (null === $sTitle) {
return !empty($this->aTitles);
}
return isset($this->aTitles[$sTitle]);
} | php | public function has($sTitle = null)
{
if (null === $sTitle) {
return !empty($this->aTitles);
}
return isset($this->aTitles[$sTitle]);
} | [
"public",
"function",
"has",
"(",
"$",
"sTitle",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"sTitle",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"aTitles",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"aTitles",
"[",
"$",
"sTitle",
"]",
")",
";",
"}"
]
| Indicate if a given title tag exists or if there are items in the titles tag stack.
@param string $sTitle
@return boolean | [
"Indicate",
"if",
"a",
"given",
"title",
"tag",
"exists",
"or",
"if",
"there",
"are",
"items",
"in",
"the",
"titles",
"tag",
"stack",
"."
]
| train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/TitleTag.php#L47-L54 |
VincentChalnot/SidusEAVFilterBundle | Filter/Type/AbstractEAVFilterType.php | AbstractEAVFilterType.getFormOptions | public function getFormOptions(QueryHandlerInterface $queryHandler, FilterInterface $filter): array
{
if (!$queryHandler instanceof EAVQueryHandlerInterface) {
throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class);
}
return array_merge(
$this->getDefaultFormOptions($queryHandler, $filter),
$filter->getFormOptions()
);
} | php | public function getFormOptions(QueryHandlerInterface $queryHandler, FilterInterface $filter): array
{
if (!$queryHandler instanceof EAVQueryHandlerInterface) {
throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class);
}
return array_merge(
$this->getDefaultFormOptions($queryHandler, $filter),
$filter->getFormOptions()
);
} | [
"public",
"function",
"getFormOptions",
"(",
"QueryHandlerInterface",
"$",
"queryHandler",
",",
"FilterInterface",
"$",
"filter",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"queryHandler",
"instanceof",
"EAVQueryHandlerInterface",
")",
"{",
"throw",
"new",
"BadQueryHandlerException",
"(",
"$",
"queryHandler",
",",
"EAVQueryHandlerInterface",
"::",
"class",
")",
";",
"}",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"getDefaultFormOptions",
"(",
"$",
"queryHandler",
",",
"$",
"filter",
")",
",",
"$",
"filter",
"->",
"getFormOptions",
"(",
")",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/AbstractEAVFilterType.php#L40-L50 |
VincentChalnot/SidusEAVFilterBundle | Filter/Type/AbstractEAVFilterType.php | AbstractEAVFilterType.getDefaultFormOptions | protected function getDefaultFormOptions(EAVQueryHandlerInterface $queryHandler, FilterInterface $filter): array
{
$formOptions = $this->formOptions;
try {
$attributes = $queryHandler->getEAVAttributes($filter);
} catch (MissingAttributeException $e) {
return $formOptions;
}
if (1 === \count($attributes)) {
$attribute = reset($attributes);
$attributeFormOptions = $attribute->getFormOptions();
$formOptions['label'] = (string) $attribute;
$formOptions['translate_label'] = false;
if (array_key_exists('translation_domain', $attributeFormOptions)) {
$formOptions['translation_domain'] = $attributeFormOptions['translation_domain'];
}
}
return $formOptions;
} | php | protected function getDefaultFormOptions(EAVQueryHandlerInterface $queryHandler, FilterInterface $filter): array
{
$formOptions = $this->formOptions;
try {
$attributes = $queryHandler->getEAVAttributes($filter);
} catch (MissingAttributeException $e) {
return $formOptions;
}
if (1 === \count($attributes)) {
$attribute = reset($attributes);
$attributeFormOptions = $attribute->getFormOptions();
$formOptions['label'] = (string) $attribute;
$formOptions['translate_label'] = false;
if (array_key_exists('translation_domain', $attributeFormOptions)) {
$formOptions['translation_domain'] = $attributeFormOptions['translation_domain'];
}
}
return $formOptions;
} | [
"protected",
"function",
"getDefaultFormOptions",
"(",
"EAVQueryHandlerInterface",
"$",
"queryHandler",
",",
"FilterInterface",
"$",
"filter",
")",
":",
"array",
"{",
"$",
"formOptions",
"=",
"$",
"this",
"->",
"formOptions",
";",
"try",
"{",
"$",
"attributes",
"=",
"$",
"queryHandler",
"->",
"getEAVAttributes",
"(",
"$",
"filter",
")",
";",
"}",
"catch",
"(",
"MissingAttributeException",
"$",
"e",
")",
"{",
"return",
"$",
"formOptions",
";",
"}",
"if",
"(",
"1",
"===",
"\\",
"count",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"attribute",
"=",
"reset",
"(",
"$",
"attributes",
")",
";",
"$",
"attributeFormOptions",
"=",
"$",
"attribute",
"->",
"getFormOptions",
"(",
")",
";",
"$",
"formOptions",
"[",
"'label'",
"]",
"=",
"(",
"string",
")",
"$",
"attribute",
";",
"$",
"formOptions",
"[",
"'translate_label'",
"]",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"'translation_domain'",
",",
"$",
"attributeFormOptions",
")",
")",
"{",
"$",
"formOptions",
"[",
"'translation_domain'",
"]",
"=",
"$",
"attributeFormOptions",
"[",
"'translation_domain'",
"]",
";",
"}",
"}",
"return",
"$",
"formOptions",
";",
"}"
]
| @param EAVQueryHandlerInterface $queryHandler
@param FilterInterface $filter
@return array | [
"@param",
"EAVQueryHandlerInterface",
"$queryHandler",
"@param",
"FilterInterface",
"$filter"
]
| train | https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/AbstractEAVFilterType.php#L58-L77 |
joomla-framework/crypt | src/Cipher/OpenSSL.php | OpenSSL.decrypt | public function decrypt($data, Key $key)
{
// Validate key.
if ($key->getType() !== 'openssl')
{
throw new InvalidKeyTypeException('openssl', $key->getType());
}
$cleartext = openssl_decrypt($data, $this->method, $key->getPrivate(), true, $this->iv);
if ($cleartext === false)
{
throw new \RuntimeException('Failed to decrypt data');
}
return $cleartext;
} | php | public function decrypt($data, Key $key)
{
// Validate key.
if ($key->getType() !== 'openssl')
{
throw new InvalidKeyTypeException('openssl', $key->getType());
}
$cleartext = openssl_decrypt($data, $this->method, $key->getPrivate(), true, $this->iv);
if ($cleartext === false)
{
throw new \RuntimeException('Failed to decrypt data');
}
return $cleartext;
} | [
"public",
"function",
"decrypt",
"(",
"$",
"data",
",",
"Key",
"$",
"key",
")",
"{",
"// Validate key.",
"if",
"(",
"$",
"key",
"->",
"getType",
"(",
")",
"!==",
"'openssl'",
")",
"{",
"throw",
"new",
"InvalidKeyTypeException",
"(",
"'openssl'",
",",
"$",
"key",
"->",
"getType",
"(",
")",
")",
";",
"}",
"$",
"cleartext",
"=",
"openssl_decrypt",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"method",
",",
"$",
"key",
"->",
"getPrivate",
"(",
")",
",",
"true",
",",
"$",
"this",
"->",
"iv",
")",
";",
"if",
"(",
"$",
"cleartext",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Failed to decrypt data'",
")",
";",
"}",
"return",
"$",
"cleartext",
";",
"}"
]
| Method to decrypt a data string.
@param string $data The encrypted string to decrypt.
@param Key $key The key object to use for decryption.
@return string The decrypted data string.
@since __DEPLOY_VERSION__
@throws \InvalidArgumentException
@throws \RuntimeException | [
"Method",
"to",
"decrypt",
"a",
"data",
"string",
"."
]
| train | https://github.com/joomla-framework/crypt/blob/5b24370bd5f07d2b305f66e62294c6d10a3f619d/src/Cipher/OpenSSL.php#L64-L80 |
joomla-framework/crypt | src/Cipher/OpenSSL.php | OpenSSL.encrypt | public function encrypt($data, Key $key)
{
// Validate key.
if ($key->getType() !== 'openssl')
{
throw new InvalidKeyTypeException('openssl', $key->getType());
}
$encrypted = openssl_encrypt($data, $this->method, $key->getPrivate(), true, $this->iv);
if ($encrypted === false)
{
throw new \RuntimeException('Unable to encrypt data');
}
return $encrypted;
} | php | public function encrypt($data, Key $key)
{
// Validate key.
if ($key->getType() !== 'openssl')
{
throw new InvalidKeyTypeException('openssl', $key->getType());
}
$encrypted = openssl_encrypt($data, $this->method, $key->getPrivate(), true, $this->iv);
if ($encrypted === false)
{
throw new \RuntimeException('Unable to encrypt data');
}
return $encrypted;
} | [
"public",
"function",
"encrypt",
"(",
"$",
"data",
",",
"Key",
"$",
"key",
")",
"{",
"// Validate key.",
"if",
"(",
"$",
"key",
"->",
"getType",
"(",
")",
"!==",
"'openssl'",
")",
"{",
"throw",
"new",
"InvalidKeyTypeException",
"(",
"'openssl'",
",",
"$",
"key",
"->",
"getType",
"(",
")",
")",
";",
"}",
"$",
"encrypted",
"=",
"openssl_encrypt",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"method",
",",
"$",
"key",
"->",
"getPrivate",
"(",
")",
",",
"true",
",",
"$",
"this",
"->",
"iv",
")",
";",
"if",
"(",
"$",
"encrypted",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to encrypt data'",
")",
";",
"}",
"return",
"$",
"encrypted",
";",
"}"
]
| Method to encrypt a data string.
@param string $data The data string to encrypt.
@param Key $key The key object to use for encryption.
@return string The encrypted data string.
@since __DEPLOY_VERSION__
@throws \InvalidArgumentException
@throws \RuntimeException | [
"Method",
"to",
"encrypt",
"a",
"data",
"string",
"."
]
| train | https://github.com/joomla-framework/crypt/blob/5b24370bd5f07d2b305f66e62294c6d10a3f619d/src/Cipher/OpenSSL.php#L94-L110 |
joomla-framework/crypt | src/Cipher/OpenSSL.php | OpenSSL.generateKey | public function generateKey(array $options = [])
{
$passphrase = $options['passphrase'] ?? false;
if ($passphrase === false)
{
throw new \RuntimeException('Missing passphrase file');
}
return new Key('openssl', $passphrase, 'unused');
} | php | public function generateKey(array $options = [])
{
$passphrase = $options['passphrase'] ?? false;
if ($passphrase === false)
{
throw new \RuntimeException('Missing passphrase file');
}
return new Key('openssl', $passphrase, 'unused');
} | [
"public",
"function",
"generateKey",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"passphrase",
"=",
"$",
"options",
"[",
"'passphrase'",
"]",
"??",
"false",
";",
"if",
"(",
"$",
"passphrase",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Missing passphrase file'",
")",
";",
"}",
"return",
"new",
"Key",
"(",
"'openssl'",
",",
"$",
"passphrase",
",",
"'unused'",
")",
";",
"}"
]
| Method to generate a new encryption key object.
@param array $options Key generation options.
@return Key
@since __DEPLOY_VERSION__
@throws \RuntimeException | [
"Method",
"to",
"generate",
"a",
"new",
"encryption",
"key",
"object",
"."
]
| train | https://github.com/joomla-framework/crypt/blob/5b24370bd5f07d2b305f66e62294c6d10a3f619d/src/Cipher/OpenSSL.php#L122-L132 |
christianvizarra/laravel-service-provider | src/Publisher/MigrationPublisher.php | MigrationPublisher.getSource | protected function getSource($packagePath)
{
$sources = [
"{$packagePath}/resources/database/migrations",
"{$packagePath}/resources/migrations",
"{$packagePath}/migrations",
];
// iterate through all possible locations
foreach ($sources as $source) {
if ($this->files->isDirectory($source)) {
$paths = [];
// get all files of the current directory
$files = $this->getSourceFiles($source);
// iterate through all files
foreach ($files as $file) {
// if the destination doesn't exist we can add the file to the queue
if (!class_exists($this->getClassFromFile($file))) {
$paths[$file] = $this->getDestinationPath('migrations', [
date('Y_m_d_His', time()), $this->getFileName($file),
]);
}
}
return $paths;
}
}
throw new InvalidArgumentException('Migrations not found.');
} | php | protected function getSource($packagePath)
{
$sources = [
"{$packagePath}/resources/database/migrations",
"{$packagePath}/resources/migrations",
"{$packagePath}/migrations",
];
// iterate through all possible locations
foreach ($sources as $source) {
if ($this->files->isDirectory($source)) {
$paths = [];
// get all files of the current directory
$files = $this->getSourceFiles($source);
// iterate through all files
foreach ($files as $file) {
// if the destination doesn't exist we can add the file to the queue
if (!class_exists($this->getClassFromFile($file))) {
$paths[$file] = $this->getDestinationPath('migrations', [
date('Y_m_d_His', time()), $this->getFileName($file),
]);
}
}
return $paths;
}
}
throw new InvalidArgumentException('Migrations not found.');
} | [
"protected",
"function",
"getSource",
"(",
"$",
"packagePath",
")",
"{",
"$",
"sources",
"=",
"[",
"\"{$packagePath}/resources/database/migrations\"",
",",
"\"{$packagePath}/resources/migrations\"",
",",
"\"{$packagePath}/migrations\"",
",",
"]",
";",
"// iterate through all possible locations",
"foreach",
"(",
"$",
"sources",
"as",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"source",
")",
")",
"{",
"$",
"paths",
"=",
"[",
"]",
";",
"// get all files of the current directory",
"$",
"files",
"=",
"$",
"this",
"->",
"getSourceFiles",
"(",
"$",
"source",
")",
";",
"// iterate through all files",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"// if the destination doesn't exist we can add the file to the queue",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"getClassFromFile",
"(",
"$",
"file",
")",
")",
")",
"{",
"$",
"paths",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"getDestinationPath",
"(",
"'migrations'",
",",
"[",
"date",
"(",
"'Y_m_d_His'",
",",
"time",
"(",
")",
")",
",",
"$",
"this",
"->",
"getFileName",
"(",
"$",
"file",
")",
",",
"]",
")",
";",
"}",
"}",
"return",
"$",
"paths",
";",
"}",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Migrations not found.'",
")",
";",
"}"
]
| Get the source assets directory to publish.
@param string $packagePath
@return string
@throws \InvalidArgumentException | [
"Get",
"the",
"source",
"assets",
"directory",
"to",
"publish",
"."
]
| train | https://github.com/christianvizarra/laravel-service-provider/blob/73e6b664c34ce228d4a3a48ed3b96cf2546ccfee/src/Publisher/MigrationPublisher.php#L27-L58 |
zephia/pilot-api-client | src/Model/LeadData.php | LeadData.toArray | public function toArray()
{
$this->validate();
return [
'pilot_firstname' => $this->getFirstname(),
'pilot_lastname' => $this->getLastname(),
'pilot_phone' => $this->getPhone(),
'pilot_cellphone' => $this->getCellphone(),
'pilot_email' => $this->getEmail(),
'pilot_contact_type_id' => $this->getContactTypeId(),
'pilot_business_type_id' => $this->getBusinessTypeId(),
'pilot_notes' => $this->getNotes(),
'pilot_origin_id' => $this->getOriginId(),
'pilot_suborigin_id' => $this->getSuboriginId(),
'pilot_assigned_user' => $this->getAssignedUser(),
'pilot_car_brand' => $this->getCarBrand(),
'pilot_car_modelo' => $this->getCarModelo(),
'pilot_city' => $this->getCity(),
'pilot_province' => $this->getProvince(),
'pilot_country' => $this->getCountry(),
'pilot_vendor_name' => $this->getVendorName(),
'pilot_vendor_email' => $this->getVendorEmail(),
'pilot_vendor_phone' => $this->getVendorPhone(),
'pilot_provider_service' => $this->getProviderService(),
'pilot_provider_url' => $this->getProviderUrl()
];
} | php | public function toArray()
{
$this->validate();
return [
'pilot_firstname' => $this->getFirstname(),
'pilot_lastname' => $this->getLastname(),
'pilot_phone' => $this->getPhone(),
'pilot_cellphone' => $this->getCellphone(),
'pilot_email' => $this->getEmail(),
'pilot_contact_type_id' => $this->getContactTypeId(),
'pilot_business_type_id' => $this->getBusinessTypeId(),
'pilot_notes' => $this->getNotes(),
'pilot_origin_id' => $this->getOriginId(),
'pilot_suborigin_id' => $this->getSuboriginId(),
'pilot_assigned_user' => $this->getAssignedUser(),
'pilot_car_brand' => $this->getCarBrand(),
'pilot_car_modelo' => $this->getCarModelo(),
'pilot_city' => $this->getCity(),
'pilot_province' => $this->getProvince(),
'pilot_country' => $this->getCountry(),
'pilot_vendor_name' => $this->getVendorName(),
'pilot_vendor_email' => $this->getVendorEmail(),
'pilot_vendor_phone' => $this->getVendorPhone(),
'pilot_provider_service' => $this->getProviderService(),
'pilot_provider_url' => $this->getProviderUrl()
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"return",
"[",
"'pilot_firstname'",
"=>",
"$",
"this",
"->",
"getFirstname",
"(",
")",
",",
"'pilot_lastname'",
"=>",
"$",
"this",
"->",
"getLastname",
"(",
")",
",",
"'pilot_phone'",
"=>",
"$",
"this",
"->",
"getPhone",
"(",
")",
",",
"'pilot_cellphone'",
"=>",
"$",
"this",
"->",
"getCellphone",
"(",
")",
",",
"'pilot_email'",
"=>",
"$",
"this",
"->",
"getEmail",
"(",
")",
",",
"'pilot_contact_type_id'",
"=>",
"$",
"this",
"->",
"getContactTypeId",
"(",
")",
",",
"'pilot_business_type_id'",
"=>",
"$",
"this",
"->",
"getBusinessTypeId",
"(",
")",
",",
"'pilot_notes'",
"=>",
"$",
"this",
"->",
"getNotes",
"(",
")",
",",
"'pilot_origin_id'",
"=>",
"$",
"this",
"->",
"getOriginId",
"(",
")",
",",
"'pilot_suborigin_id'",
"=>",
"$",
"this",
"->",
"getSuboriginId",
"(",
")",
",",
"'pilot_assigned_user'",
"=>",
"$",
"this",
"->",
"getAssignedUser",
"(",
")",
",",
"'pilot_car_brand'",
"=>",
"$",
"this",
"->",
"getCarBrand",
"(",
")",
",",
"'pilot_car_modelo'",
"=>",
"$",
"this",
"->",
"getCarModelo",
"(",
")",
",",
"'pilot_city'",
"=>",
"$",
"this",
"->",
"getCity",
"(",
")",
",",
"'pilot_province'",
"=>",
"$",
"this",
"->",
"getProvince",
"(",
")",
",",
"'pilot_country'",
"=>",
"$",
"this",
"->",
"getCountry",
"(",
")",
",",
"'pilot_vendor_name'",
"=>",
"$",
"this",
"->",
"getVendorName",
"(",
")",
",",
"'pilot_vendor_email'",
"=>",
"$",
"this",
"->",
"getVendorEmail",
"(",
")",
",",
"'pilot_vendor_phone'",
"=>",
"$",
"this",
"->",
"getVendorPhone",
"(",
")",
",",
"'pilot_provider_service'",
"=>",
"$",
"this",
"->",
"getProviderService",
"(",
")",
",",
"'pilot_provider_url'",
"=>",
"$",
"this",
"->",
"getProviderUrl",
"(",
")",
"]",
";",
"}"
]
| Object to array
@return array | [
"Object",
"to",
"array"
]
| train | https://github.com/zephia/pilot-api-client/blob/218fbf2fc5892e2ffc554ddd01fa95d63d6e3c0f/src/Model/LeadData.php#L51-L77 |
zephia/pilot-api-client | src/Model/LeadData.php | LeadData.validate | private function validate()
{
$required = '';
$validations = [
'FirstnameOrLastname',
'PhoneCellphoneOrEmail',
'ContactTypeId',
'BusinessTypeId',
'SuboriginId',
];
for ($i = 0; $i < count($validations) && empty($required); $i++) {
$required = $this->{"validate" . $validations[$i]}();
}
if (!empty($required)) {
throw new InvalidArgumentException(
sprintf('Missing required value: %s.', $required)
);
}
} | php | private function validate()
{
$required = '';
$validations = [
'FirstnameOrLastname',
'PhoneCellphoneOrEmail',
'ContactTypeId',
'BusinessTypeId',
'SuboriginId',
];
for ($i = 0; $i < count($validations) && empty($required); $i++) {
$required = $this->{"validate" . $validations[$i]}();
}
if (!empty($required)) {
throw new InvalidArgumentException(
sprintf('Missing required value: %s.', $required)
);
}
} | [
"private",
"function",
"validate",
"(",
")",
"{",
"$",
"required",
"=",
"''",
";",
"$",
"validations",
"=",
"[",
"'FirstnameOrLastname'",
",",
"'PhoneCellphoneOrEmail'",
",",
"'ContactTypeId'",
",",
"'BusinessTypeId'",
",",
"'SuboriginId'",
",",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"validations",
")",
"&&",
"empty",
"(",
"$",
"required",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"required",
"=",
"$",
"this",
"->",
"{",
"\"validate\"",
".",
"$",
"validations",
"[",
"$",
"i",
"]",
"}",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"required",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Missing required value: %s.'",
",",
"$",
"required",
")",
")",
";",
"}",
"}"
]
| Validate
@throws InvalidArgumentException | [
"Validate"
]
| train | https://github.com/zephia/pilot-api-client/blob/218fbf2fc5892e2ffc554ddd01fa95d63d6e3c0f/src/Model/LeadData.php#L84-L105 |
zephia/pilot-api-client | src/Model/LeadData.php | LeadData.set | private function set($key, $value = "")
{
if (property_exists($this, $key)) {
$key = implode('', array_map('ucfirst', explode('_', $key)));
$this->{'set' . $key}($value);
}
} | php | private function set($key, $value = "")
{
if (property_exists($this, $key)) {
$key = implode('', array_map('ucfirst', explode('_', $key)));
$this->{'set' . $key}($value);
}
} | [
"private",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"\"\"",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"key",
")",
")",
"{",
"$",
"key",
"=",
"implode",
"(",
"''",
",",
"array_map",
"(",
"'ucfirst'",
",",
"explode",
"(",
"'_'",
",",
"$",
"key",
")",
")",
")",
";",
"$",
"this",
"->",
"{",
"'set'",
".",
"$",
"key",
"}",
"(",
"$",
"value",
")",
";",
"}",
"}"
]
| Set
@param $key
@param string $value | [
"Set"
]
| train | https://github.com/zephia/pilot-api-client/blob/218fbf2fc5892e2ffc554ddd01fa95d63d6e3c0f/src/Model/LeadData.php#L157-L163 |
turanct/showpad-api | src/Showpad/Client.php | Client.assetsList | public function assetsList($limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/assets.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | php | public function assetsList($limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/assets.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | [
"public",
"function",
"assetsList",
"(",
"$",
"limit",
"=",
"25",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"'/assets.json'",
",",
"array",
"(",
"'query'",
"=>",
"array",
"(",
"'limit'",
"=>",
"(",
"int",
")",
"$",
"limit",
",",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"offset",
")",
")",
")",
";",
"}"
]
| Get a list of existing assets
GET /assets.json
@param int $limit The max number of items we want to retrieve
@param int $offset The number of items to skip from the top of the list
@return array | [
"Get",
"a",
"list",
"of",
"existing",
"assets"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L44-L51 |
turanct/showpad-api | src/Showpad/Client.php | Client.assetsAdd | public function assetsAdd($file)
{
$resource = '/assets.json';
$parameters = array(
'file' => '@' . $file,
);
// Create request
$data = $this->auth->request(
'POST',
$resource,
$parameters
);
return $data;
} | php | public function assetsAdd($file)
{
$resource = '/assets.json';
$parameters = array(
'file' => '@' . $file,
);
// Create request
$data = $this->auth->request(
'POST',
$resource,
$parameters
);
return $data;
} | [
"public",
"function",
"assetsAdd",
"(",
"$",
"file",
")",
"{",
"$",
"resource",
"=",
"'/assets.json'",
";",
"$",
"parameters",
"=",
"array",
"(",
"'file'",
"=>",
"'@'",
".",
"$",
"file",
",",
")",
";",
"// Create request",
"$",
"data",
"=",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'POST'",
",",
"$",
"resource",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Add an asset
POST /assets.json
@param string $file The path to the file
@return array | [
"Add",
"an",
"asset"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L62-L78 |
turanct/showpad-api | src/Showpad/Client.php | Client.assetsGet | public function assetsGet($id)
{
$resource = '/assets/' . $id . '.json';
// Create request
$data = $this->auth->request('GET', $resource);
return $data;
} | php | public function assetsGet($id)
{
$resource = '/assets/' . $id . '.json';
// Create request
$data = $this->auth->request('GET', $resource);
return $data;
} | [
"public",
"function",
"assetsGet",
"(",
"$",
"id",
")",
"{",
"$",
"resource",
"=",
"'/assets/'",
".",
"$",
"id",
".",
"'.json'",
";",
"// Create request",
"$",
"data",
"=",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"$",
"resource",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Get an asset by id
GET /assets/{id}.json
@param string $id The asset id
@return array | [
"Get",
"an",
"asset",
"by",
"id"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L89-L97 |
turanct/showpad-api | src/Showpad/Client.php | Client.assetsDelete | public function assetsDelete($id)
{
$resource = '/assets/' . $id . '.json';
// Create request
$data = $this->auth->request('DELETE', $resource);
return $data;
} | php | public function assetsDelete($id)
{
$resource = '/assets/' . $id . '.json';
// Create request
$data = $this->auth->request('DELETE', $resource);
return $data;
} | [
"public",
"function",
"assetsDelete",
"(",
"$",
"id",
")",
"{",
"$",
"resource",
"=",
"'/assets/'",
".",
"$",
"id",
".",
"'.json'",
";",
"// Create request",
"$",
"data",
"=",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"resource",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Delete asset by id
DELETE /assets/{id}.json
@param string $id The asset id
@return array | [
"Delete",
"asset",
"by",
"id"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L108-L116 |
turanct/showpad-api | src/Showpad/Client.php | Client.assetsTagsAddById | public function assetsTagsAddById($id, $tag)
{
$resource = '/assets/' . $id . '/tags/' . $tag . '.json';
$parameters = array(
'query' => array('method' => 'link'),
);
// Create request
$data = $this->auth->request(
'GET',
$resource,
$parameters
);
return $data;
} | php | public function assetsTagsAddById($id, $tag)
{
$resource = '/assets/' . $id . '/tags/' . $tag . '.json';
$parameters = array(
'query' => array('method' => 'link'),
);
// Create request
$data = $this->auth->request(
'GET',
$resource,
$parameters
);
return $data;
} | [
"public",
"function",
"assetsTagsAddById",
"(",
"$",
"id",
",",
"$",
"tag",
")",
"{",
"$",
"resource",
"=",
"'/assets/'",
".",
"$",
"id",
".",
"'/tags/'",
".",
"$",
"tag",
".",
"'.json'",
";",
"$",
"parameters",
"=",
"array",
"(",
"'query'",
"=>",
"array",
"(",
"'method'",
"=>",
"'link'",
")",
",",
")",
";",
"// Create request",
"$",
"data",
"=",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"$",
"resource",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Add a tag to an asset by tag id
POST /assets/{id}/tags.json
@param string $id The asset id
@param string $tag The tag id
@return array | [
"Add",
"a",
"tag",
"to",
"an",
"asset",
"by",
"tag",
"id"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L156-L172 |
turanct/showpad-api | src/Showpad/Client.php | Client.assetsTagsList | public function assetsTagsList($assetId, $limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/assets/' . $assetId . '/tags.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | php | public function assetsTagsList($assetId, $limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/assets/' . $assetId . '/tags.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | [
"public",
"function",
"assetsTagsList",
"(",
"$",
"assetId",
",",
"$",
"limit",
"=",
"25",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"'/assets/'",
".",
"$",
"assetId",
".",
"'/tags.json'",
",",
"array",
"(",
"'query'",
"=>",
"array",
"(",
"'limit'",
"=>",
"(",
"int",
")",
"$",
"limit",
",",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"offset",
")",
")",
")",
";",
"}"
]
| Get a list of existing assets
GET /assets/{id}/tags.json
@param int $assetId The id of the asset
@param int $limit The max number of items we want to retrieve
@param int $offset The number of items to skip from the top of the list
@return array | [
"Get",
"a",
"list",
"of",
"existing",
"assets"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L206-L213 |
turanct/showpad-api | src/Showpad/Client.php | Client.tagsList | public function tagsList($limit = 25, $offset = 0)
{
$resource = '/tags.json';
// Create request
$data = $this->auth->request(
'GET',
$resource,
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
return $data;
} | php | public function tagsList($limit = 25, $offset = 0)
{
$resource = '/tags.json';
// Create request
$data = $this->auth->request(
'GET',
$resource,
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
return $data;
} | [
"public",
"function",
"tagsList",
"(",
"$",
"limit",
"=",
"25",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"resource",
"=",
"'/tags.json'",
";",
"// Create request",
"$",
"data",
"=",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"$",
"resource",
",",
"array",
"(",
"'query'",
"=>",
"array",
"(",
"'limit'",
"=>",
"(",
"int",
")",
"$",
"limit",
",",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"offset",
")",
")",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Get a list of existing tags
GET /tags.json
@param int $limit The max number of items we want to retrieve
@param int $offset The number of items to skip from the top of the list
@return array | [
"Get",
"a",
"list",
"of",
"existing",
"tags"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L225-L237 |
turanct/showpad-api | src/Showpad/Client.php | Client.ticketsGet | public function ticketsGet($id)
{
$resource = '/tickets/' . $id . '.json';
// Create request
$data = $this->auth->request('GET', $resource);
return $data;
} | php | public function ticketsGet($id)
{
$resource = '/tickets/' . $id . '.json';
// Create request
$data = $this->auth->request('GET', $resource);
return $data;
} | [
"public",
"function",
"ticketsGet",
"(",
"$",
"id",
")",
"{",
"$",
"resource",
"=",
"'/tickets/'",
".",
"$",
"id",
".",
"'.json'",
";",
"// Create request",
"$",
"data",
"=",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"$",
"resource",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Get a ticket by id
GET /tickets/{id}.json
@param string $id The ticket id
@return array | [
"Get",
"a",
"ticket",
"by",
"id"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L266-L274 |
turanct/showpad-api | src/Showpad/Client.php | Client.tagAssetsList | public function tagAssetsList($tagId, $limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/tags/' . $tagId . '/assets.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | php | public function tagAssetsList($tagId, $limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/tags/' . $tagId . '/assets.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | [
"public",
"function",
"tagAssetsList",
"(",
"$",
"tagId",
",",
"$",
"limit",
"=",
"25",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"'/tags/'",
".",
"$",
"tagId",
".",
"'/assets.json'",
",",
"array",
"(",
"'query'",
"=>",
"array",
"(",
"'limit'",
"=>",
"(",
"int",
")",
"$",
"limit",
",",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"offset",
")",
")",
")",
";",
"}"
]
| Get a list of assets coupled to a certain tag
GET /tags/{id}/assets.json
@param int $limit The max number of items we want to retrieve
@param int $offset The number of items to skip from the top of the list
@return array | [
"Get",
"a",
"list",
"of",
"assets",
"coupled",
"to",
"a",
"certain",
"tag"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L286-L293 |
turanct/showpad-api | src/Showpad/Client.php | Client.channelsList | public function channelsList($limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/channels.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | php | public function channelsList($limit = 25, $offset = 0)
{
return $this->auth->request(
'GET',
'/channels.json',
array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
);
} | [
"public",
"function",
"channelsList",
"(",
"$",
"limit",
"=",
"25",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"auth",
"->",
"request",
"(",
"'GET'",
",",
"'/channels.json'",
",",
"array",
"(",
"'query'",
"=>",
"array",
"(",
"'limit'",
"=>",
"(",
"int",
")",
"$",
"limit",
",",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"offset",
")",
")",
")",
";",
"}"
]
| Get a list of existing channels
@note: this works only with API v3
GET /channels.json
@param int $limit The max number of items we want to retrieve
@param int $offset The number of items to skip from the top of the list
@return array | [
"Get",
"a",
"list",
"of",
"existing",
"channels"
]
| train | https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Client.php#L307-L314 |
GrahamDeprecated/CMS-Core | src/Models/User.php | User.beforeDelete | public function beforeDelete()
{
$this->invites()->sync(array());
$this->deletePages();
$this->deletePosts();
$this->deleteEvents();
$this->deleteComments();
} | php | public function beforeDelete()
{
$this->invites()->sync(array());
$this->deletePages();
$this->deletePosts();
$this->deleteEvents();
$this->deleteComments();
} | [
"public",
"function",
"beforeDelete",
"(",
")",
"{",
"$",
"this",
"->",
"invites",
"(",
")",
"->",
"sync",
"(",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"deletePages",
"(",
")",
";",
"$",
"this",
"->",
"deletePosts",
"(",
")",
";",
"$",
"this",
"->",
"deleteEvents",
"(",
")",
";",
"$",
"this",
"->",
"deleteComments",
"(",
")",
";",
"}"
]
| Before deleting an existing model.
@return mixed | [
"Before",
"deleting",
"an",
"existing",
"model",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Models/User.php#L49-L56 |
2amigos/yiifoundation | helpers/Alert.php | Alert.success | public static function success($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', Enum::COLOR_SUCCESS, $htmlOptions);
return static::alert($content, $htmlOptions, $close);
} | php | public static function success($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', Enum::COLOR_SUCCESS, $htmlOptions);
return static::alert($content, $htmlOptions, $close);
} | [
"public",
"static",
"function",
"success",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"close",
"=",
"'×'",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"Enum",
"::",
"COLOR_SUCCESS",
",",
"$",
"htmlOptions",
")",
";",
"return",
"static",
"::",
"alert",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
",",
"$",
"close",
")",
";",
"}"
]
| Generates a success alert
@param string $content the text within the alert box
@param array $htmlOptions the HTML attributes of the alert box
@param string $close the label for the close button. Set to false if you don't wish to display it.
@return string the alert box | [
"Generates",
"a",
"success",
"alert"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Alert.php#L28-L32 |
2amigos/yiifoundation | helpers/Alert.php | Alert.important | public static function important($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', Enum::COLOR_ALERT, $htmlOptions);
return static::alert($content, $htmlOptions, $close);
} | php | public static function important($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', Enum::COLOR_ALERT, $htmlOptions);
return static::alert($content, $htmlOptions, $close);
} | [
"public",
"static",
"function",
"important",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"close",
"=",
"'×'",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"Enum",
"::",
"COLOR_ALERT",
",",
"$",
"htmlOptions",
")",
";",
"return",
"static",
"::",
"alert",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
",",
"$",
"close",
")",
";",
"}"
]
| Generates an red coloured alert box
@param string $content the text within the alert box
@param array $htmlOptions the HTML attributes of the alert box
@param string $close the label for the close button. Set to false if you don't wish to display it.
@return string the alert box | [
"Generates",
"an",
"red",
"coloured",
"alert",
"box"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Alert.php#L42-L46 |
2amigos/yiifoundation | helpers/Alert.php | Alert.secondary | public static function secondary($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', Enum::COLOR_SECONDARY, $htmlOptions);
return static::alert($content, $htmlOptions, $close);
} | php | public static function secondary($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', Enum::COLOR_SECONDARY, $htmlOptions);
return static::alert($content, $htmlOptions, $close);
} | [
"public",
"static",
"function",
"secondary",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"close",
"=",
"'×'",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"Enum",
"::",
"COLOR_SECONDARY",
",",
"$",
"htmlOptions",
")",
";",
"return",
"static",
"::",
"alert",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
",",
"$",
"close",
")",
";",
"}"
]
| Generates a secondary alert box
@param string $content the text within the alert box
@param array $htmlOptions the HTML attributes of the alert box
@param string $close the label for the close button. Set to false if you don't wish to display it.
@return string the alert box | [
"Generates",
"a",
"secondary",
"alert",
"box"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Alert.php#L56-L60 |
2amigos/yiifoundation | helpers/Alert.php | Alert.alert | public static function alert($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', 'alert-box', $htmlOptions);
ob_start();
echo '<div data-alert ' . \CHtml::renderAttributes($htmlOptions) . '>';
echo $content;
if ($close !== false)
echo static::closeLink($close);
echo '</div>';
return ob_get_clean();
} | php | public static function alert($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', 'alert-box', $htmlOptions);
ob_start();
echo '<div data-alert ' . \CHtml::renderAttributes($htmlOptions) . '>';
echo $content;
if ($close !== false)
echo static::closeLink($close);
echo '</div>';
return ob_get_clean();
} | [
"public",
"static",
"function",
"alert",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"close",
"=",
"'×'",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"'alert-box'",
",",
"$",
"htmlOptions",
")",
";",
"ob_start",
"(",
")",
";",
"echo",
"'<div data-alert '",
".",
"\\",
"CHtml",
"::",
"renderAttributes",
"(",
"$",
"htmlOptions",
")",
".",
"'>'",
";",
"echo",
"$",
"content",
";",
"if",
"(",
"$",
"close",
"!==",
"false",
")",
"echo",
"static",
"::",
"closeLink",
"(",
"$",
"close",
")",
";",
"echo",
"'</div>'",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
]
| Returns an alert box
@param string $content the text within the alert box
@param array $htmlOptions the HTML attributes of the alert box
@param string $close the label for the close button. Set to false if you don't wish to display it.
@return string the alert box
@see http://foundation.zurb.com/docs/components/alert-boxes.html | [
"Returns",
"an",
"alert",
"box"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Alert.php#L71-L82 |
2amigos/yiifoundation | helpers/Alert.php | Alert.closeLink | public static function closeLink($label = '×', $htmlOptions = array())
{
$htmlOptions = ArrayHelper::defaultValue('href', '#', $htmlOptions);
ArrayHelper::addValue('class', 'close', $htmlOptions);
return \CHtml::openTag('a', $htmlOptions) . $label . \CHtml::closeTag('a');
} | php | public static function closeLink($label = '×', $htmlOptions = array())
{
$htmlOptions = ArrayHelper::defaultValue('href', '#', $htmlOptions);
ArrayHelper::addValue('class', 'close', $htmlOptions);
return \CHtml::openTag('a', $htmlOptions) . $label . \CHtml::closeTag('a');
} | [
"public",
"static",
"function",
"closeLink",
"(",
"$",
"label",
"=",
"'×'",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"htmlOptions",
"=",
"ArrayHelper",
"::",
"defaultValue",
"(",
"'href'",
",",
"'#'",
",",
"$",
"htmlOptions",
")",
";",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"'close'",
",",
"$",
"htmlOptions",
")",
";",
"return",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'a'",
",",
"$",
"htmlOptions",
")",
".",
"$",
"label",
".",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'a'",
")",
";",
"}"
]
| Generates a close link.
@param string $label the link label text.
@param array $htmlOptions additional HTML attributes.
@return string the generated link. | [
"Generates",
"a",
"close",
"link",
"."
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Alert.php#L90-L95 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php | ContentTypeGroupSubManager.loadContentTypeGroupsByIdentifiers | public function loadContentTypeGroupsByIdentifiers(array $identifiers)
{
$contentTypeGroups = array_map(
function ($identifier) {
try {
return $this->contentTypeService->loadContentTypeGroupByIdentifier($identifier);
} catch (NotFoundException $notFoundException) {
return $this->createContentTypeGroupByIdentifier($identifier);
}
},
$identifiers
);
return $contentTypeGroups;
} | php | public function loadContentTypeGroupsByIdentifiers(array $identifiers)
{
$contentTypeGroups = array_map(
function ($identifier) {
try {
return $this->contentTypeService->loadContentTypeGroupByIdentifier($identifier);
} catch (NotFoundException $notFoundException) {
return $this->createContentTypeGroupByIdentifier($identifier);
}
},
$identifiers
);
return $contentTypeGroups;
} | [
"public",
"function",
"loadContentTypeGroupsByIdentifiers",
"(",
"array",
"$",
"identifiers",
")",
"{",
"$",
"contentTypeGroups",
"=",
"array_map",
"(",
"function",
"(",
"$",
"identifier",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"contentTypeService",
"->",
"loadContentTypeGroupByIdentifier",
"(",
"$",
"identifier",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"notFoundException",
")",
"{",
"return",
"$",
"this",
"->",
"createContentTypeGroupByIdentifier",
"(",
"$",
"identifier",
")",
";",
"}",
"}",
",",
"$",
"identifiers",
")",
";",
"return",
"$",
"contentTypeGroups",
";",
"}"
]
| /*
@param array $identifiers
@return ContentTypeGroup[] | [
"/",
"*",
"@param",
"array",
"$identifiers"
]
| train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php#L62-L76 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php | ContentTypeGroupSubManager.createContentTypeGroupByIdentifier | private function createContentTypeGroupByIdentifier($contentTypeGroupIdentifier)
{
$contentTypeGroupCreateStruct = new ContentTypeGroupCreateStruct();
$contentTypeGroupCreateStruct->identifier = $contentTypeGroupIdentifier;
return $this->contentTypeService->createContentTypeGroup($contentTypeGroupCreateStruct);
} | php | private function createContentTypeGroupByIdentifier($contentTypeGroupIdentifier)
{
$contentTypeGroupCreateStruct = new ContentTypeGroupCreateStruct();
$contentTypeGroupCreateStruct->identifier = $contentTypeGroupIdentifier;
return $this->contentTypeService->createContentTypeGroup($contentTypeGroupCreateStruct);
} | [
"private",
"function",
"createContentTypeGroupByIdentifier",
"(",
"$",
"contentTypeGroupIdentifier",
")",
"{",
"$",
"contentTypeGroupCreateStruct",
"=",
"new",
"ContentTypeGroupCreateStruct",
"(",
")",
";",
"$",
"contentTypeGroupCreateStruct",
"->",
"identifier",
"=",
"$",
"contentTypeGroupIdentifier",
";",
"return",
"$",
"this",
"->",
"contentTypeService",
"->",
"createContentTypeGroup",
"(",
"$",
"contentTypeGroupCreateStruct",
")",
";",
"}"
]
| @param string $contentTypeGroupIdentifier
@return ContentTypeGroup | [
"@param",
"string",
"$contentTypeGroupIdentifier"
]
| train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php#L83-L89 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php | ContentTypeGroupSubManager.updateContentTypeGroupsAssignment | public function updateContentTypeGroupsAssignment(ContentTypeObject $object)
{
// Load contenttype
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($object->data['identifier']);
// Get identifiers of current contenttypegroups
$currentContentTypeGroupIdentifiers = array_map(
function (ContentTypeGroup $contentTypeGroup) {
return $contentTypeGroup->identifier;
},
$contentType->getContentTypeGroups()
);
// Get new contenttypegroup identifiers
$newContentTypeGroupIdentifiers = $object->data['contenttype_groups'];
// Compare identifiers to identify which once to add/remove/keep
$remove = array_diff($currentContentTypeGroupIdentifiers, $newContentTypeGroupIdentifiers);
$add = array_diff($newContentTypeGroupIdentifiers, $currentContentTypeGroupIdentifiers);
$this->attachContentTypeGroupsByIdentifiers($contentType, $add);
$this->detachContentTypeGroupsByIdentifiers($contentType, $remove);
return true;
} | php | public function updateContentTypeGroupsAssignment(ContentTypeObject $object)
{
// Load contenttype
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($object->data['identifier']);
// Get identifiers of current contenttypegroups
$currentContentTypeGroupIdentifiers = array_map(
function (ContentTypeGroup $contentTypeGroup) {
return $contentTypeGroup->identifier;
},
$contentType->getContentTypeGroups()
);
// Get new contenttypegroup identifiers
$newContentTypeGroupIdentifiers = $object->data['contenttype_groups'];
// Compare identifiers to identify which once to add/remove/keep
$remove = array_diff($currentContentTypeGroupIdentifiers, $newContentTypeGroupIdentifiers);
$add = array_diff($newContentTypeGroupIdentifiers, $currentContentTypeGroupIdentifiers);
$this->attachContentTypeGroupsByIdentifiers($contentType, $add);
$this->detachContentTypeGroupsByIdentifiers($contentType, $remove);
return true;
} | [
"public",
"function",
"updateContentTypeGroupsAssignment",
"(",
"ContentTypeObject",
"$",
"object",
")",
"{",
"// Load contenttype",
"$",
"contentType",
"=",
"$",
"this",
"->",
"contentTypeService",
"->",
"loadContentTypeByIdentifier",
"(",
"$",
"object",
"->",
"data",
"[",
"'identifier'",
"]",
")",
";",
"// Get identifiers of current contenttypegroups",
"$",
"currentContentTypeGroupIdentifiers",
"=",
"array_map",
"(",
"function",
"(",
"ContentTypeGroup",
"$",
"contentTypeGroup",
")",
"{",
"return",
"$",
"contentTypeGroup",
"->",
"identifier",
";",
"}",
",",
"$",
"contentType",
"->",
"getContentTypeGroups",
"(",
")",
")",
";",
"// Get new contenttypegroup identifiers",
"$",
"newContentTypeGroupIdentifiers",
"=",
"$",
"object",
"->",
"data",
"[",
"'contenttype_groups'",
"]",
";",
"// Compare identifiers to identify which once to add/remove/keep",
"$",
"remove",
"=",
"array_diff",
"(",
"$",
"currentContentTypeGroupIdentifiers",
",",
"$",
"newContentTypeGroupIdentifiers",
")",
";",
"$",
"add",
"=",
"array_diff",
"(",
"$",
"newContentTypeGroupIdentifiers",
",",
"$",
"currentContentTypeGroupIdentifiers",
")",
";",
"$",
"this",
"->",
"attachContentTypeGroupsByIdentifiers",
"(",
"$",
"contentType",
",",
"$",
"add",
")",
";",
"$",
"this",
"->",
"detachContentTypeGroupsByIdentifiers",
"(",
"$",
"contentType",
",",
"$",
"remove",
")",
";",
"return",
"true",
";",
"}"
]
| @param ContentTypeObject $object
@return bool
@throws NotFoundException
@throws \Exception | [
"@param",
"ContentTypeObject",
"$object"
]
| train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php#L99-L123 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php | ContentTypeGroupSubManager.attachContentTypeGroupsByIdentifiers | private function attachContentTypeGroupsByIdentifiers(ContentType $contentType, array $contentTypeGroupsIdentifiers)
{
$contentTypeGroups = $this->loadContentTypeGroupsByIdentifiers($contentTypeGroupsIdentifiers);
foreach ($contentTypeGroups as $contentTypeGroup) {
$this->contentTypeService->assignContentTypeGroup($contentType, $contentTypeGroup);
}
} | php | private function attachContentTypeGroupsByIdentifiers(ContentType $contentType, array $contentTypeGroupsIdentifiers)
{
$contentTypeGroups = $this->loadContentTypeGroupsByIdentifiers($contentTypeGroupsIdentifiers);
foreach ($contentTypeGroups as $contentTypeGroup) {
$this->contentTypeService->assignContentTypeGroup($contentType, $contentTypeGroup);
}
} | [
"private",
"function",
"attachContentTypeGroupsByIdentifiers",
"(",
"ContentType",
"$",
"contentType",
",",
"array",
"$",
"contentTypeGroupsIdentifiers",
")",
"{",
"$",
"contentTypeGroups",
"=",
"$",
"this",
"->",
"loadContentTypeGroupsByIdentifiers",
"(",
"$",
"contentTypeGroupsIdentifiers",
")",
";",
"foreach",
"(",
"$",
"contentTypeGroups",
"as",
"$",
"contentTypeGroup",
")",
"{",
"$",
"this",
"->",
"contentTypeService",
"->",
"assignContentTypeGroup",
"(",
"$",
"contentType",
",",
"$",
"contentTypeGroup",
")",
";",
"}",
"}"
]
| Load (and create if not exists) new contenttype groups, and assign them to a contenttype.
@param ContentType $contentType
@param array $contentTypeGroupsIdentifiers
@throws NotFoundException | [
"Load",
"(",
"and",
"create",
"if",
"not",
"exists",
")",
"new",
"contenttype",
"groups",
"and",
"assign",
"them",
"to",
"a",
"contenttype",
"."
]
| train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php#L133-L139 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php | ContentTypeGroupSubManager.detachContentTypeGroupsByIdentifiers | private function detachContentTypeGroupsByIdentifiers(ContentType $contentType, array $contentTypeGroupsIdentifiers)
{
$contentTypeGroups = $this->loadContentTypeGroupsByIdentifiers($contentTypeGroupsIdentifiers);
foreach ($contentTypeGroups as $contentTypeGroup) {
$this->contentTypeService->unassignContentTypeGroup($contentType, $contentTypeGroup);
}
} | php | private function detachContentTypeGroupsByIdentifiers(ContentType $contentType, array $contentTypeGroupsIdentifiers)
{
$contentTypeGroups = $this->loadContentTypeGroupsByIdentifiers($contentTypeGroupsIdentifiers);
foreach ($contentTypeGroups as $contentTypeGroup) {
$this->contentTypeService->unassignContentTypeGroup($contentType, $contentTypeGroup);
}
} | [
"private",
"function",
"detachContentTypeGroupsByIdentifiers",
"(",
"ContentType",
"$",
"contentType",
",",
"array",
"$",
"contentTypeGroupsIdentifiers",
")",
"{",
"$",
"contentTypeGroups",
"=",
"$",
"this",
"->",
"loadContentTypeGroupsByIdentifiers",
"(",
"$",
"contentTypeGroupsIdentifiers",
")",
";",
"foreach",
"(",
"$",
"contentTypeGroups",
"as",
"$",
"contentTypeGroup",
")",
"{",
"$",
"this",
"->",
"contentTypeService",
"->",
"unassignContentTypeGroup",
"(",
"$",
"contentType",
",",
"$",
"contentTypeGroup",
")",
";",
"}",
"}"
]
| Load contenttype groups, and unassign them from a contenttype.
@param ContentType $contentType
@param array $contentTypeGroupsIdentifiers
@throws NotFoundException | [
"Load",
"contenttype",
"groups",
"and",
"unassign",
"them",
"from",
"a",
"contenttype",
"."
]
| train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Sub/ContentTypeGroupSubManager.php#L149-L155 |
php-rise/rise | src/Router/UrlGenerator.php | UrlGenerator.generate | public function generate($name, $params = []) {
$url = '';
$path = $this->generatePath($name, $params);
if ($path) {
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'
) {
$scheme = 'https';
} else {
$scheme = 'http';
}
$url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $path;
}
return $url;
} | php | public function generate($name, $params = []) {
$url = '';
$path = $this->generatePath($name, $params);
if ($path) {
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'
) {
$scheme = 'https';
} else {
$scheme = 'http';
}
$url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $path;
}
return $url;
} | [
"public",
"function",
"generate",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"''",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"generatePath",
"(",
"$",
"name",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_PROTO'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_PROTO'",
"]",
"===",
"'https'",
")",
"{",
"$",
"scheme",
"=",
"'https'",
";",
"}",
"else",
"{",
"$",
"scheme",
"=",
"'http'",
";",
"}",
"$",
"url",
"=",
"$",
"scheme",
".",
"'://'",
".",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
".",
"$",
"path",
";",
"}",
"return",
"$",
"url",
";",
"}"
]
| Generate URL.
@param string $name
@param array $params
@return string | [
"Generate",
"URL",
"."
]
| train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/UrlGenerator.php#L46-L62 |
php-rise/rise | src/Router/UrlGenerator.php | UrlGenerator.compile | protected function compile($name) {
if (!isset($this->raw[$name])) {
return;
}
$count = preg_match_all(
self::ROUTE_PARAM_PATTERN,
$this->raw[$name],
$matches,
PREG_OFFSET_CAPTURE
);
if ($count === 0) {
$this->compiled[$name] = $this->raw[$name];
} else if ($count > 0) {
$routePath = $this->raw[$name];
$params = [];
$chunks = [];
$pos = 0;
for ($i = 0; $i < $count; $i++) {
$chunks[] = substr($routePath, $pos, $matches[1][$i][1] - $pos);
$size = array_push($chunks, ''); // Empty string is just a placeholder, it can be anything
$params[$matches[2][$i][0]] = $size - 1; // Set index
$pos = $matches[1][$i][1] + strlen($matches[1][$i][0]);
}
$chunks[] = substr($routePath, $pos);
$this->compiled[$name] = [
'params' => $params,
'chunks' => $chunks,
];
}
} | php | protected function compile($name) {
if (!isset($this->raw[$name])) {
return;
}
$count = preg_match_all(
self::ROUTE_PARAM_PATTERN,
$this->raw[$name],
$matches,
PREG_OFFSET_CAPTURE
);
if ($count === 0) {
$this->compiled[$name] = $this->raw[$name];
} else if ($count > 0) {
$routePath = $this->raw[$name];
$params = [];
$chunks = [];
$pos = 0;
for ($i = 0; $i < $count; $i++) {
$chunks[] = substr($routePath, $pos, $matches[1][$i][1] - $pos);
$size = array_push($chunks, ''); // Empty string is just a placeholder, it can be anything
$params[$matches[2][$i][0]] = $size - 1; // Set index
$pos = $matches[1][$i][1] + strlen($matches[1][$i][0]);
}
$chunks[] = substr($routePath, $pos);
$this->compiled[$name] = [
'params' => $params,
'chunks' => $chunks,
];
}
} | [
"protected",
"function",
"compile",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"raw",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"count",
"=",
"preg_match_all",
"(",
"self",
"::",
"ROUTE_PARAM_PATTERN",
",",
"$",
"this",
"->",
"raw",
"[",
"$",
"name",
"]",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"$",
"count",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"compiled",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"raw",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"routePath",
"=",
"$",
"this",
"->",
"raw",
"[",
"$",
"name",
"]",
";",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"chunks",
"=",
"[",
"]",
";",
"$",
"pos",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"chunks",
"[",
"]",
"=",
"substr",
"(",
"$",
"routePath",
",",
"$",
"pos",
",",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"-",
"$",
"pos",
")",
";",
"$",
"size",
"=",
"array_push",
"(",
"$",
"chunks",
",",
"''",
")",
";",
"// Empty string is just a placeholder, it can be anything",
"$",
"params",
"[",
"$",
"matches",
"[",
"2",
"]",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"]",
"=",
"$",
"size",
"-",
"1",
";",
"// Set index",
"$",
"pos",
"=",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
")",
";",
"}",
"$",
"chunks",
"[",
"]",
"=",
"substr",
"(",
"$",
"routePath",
",",
"$",
"pos",
")",
";",
"$",
"this",
"->",
"compiled",
"[",
"$",
"name",
"]",
"=",
"[",
"'params'",
"=>",
"$",
"params",
",",
"'chunks'",
"=>",
"$",
"chunks",
",",
"]",
";",
"}",
"}"
]
| Compile raw route to a format for generation.
@param string $name | [
"Compile",
"raw",
"route",
"to",
"a",
"format",
"for",
"generation",
"."
]
| train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/UrlGenerator.php#L69-L100 |
php-rise/rise | src/Router/UrlGenerator.php | UrlGenerator.getCompiledRoute | protected function getCompiledRoute($name) {
if (!isset($this->compiled[$name])) {
$this->compile($name);
}
return isset($this->compiled[$name]) ? $this->compiled[$name] : null;
} | php | protected function getCompiledRoute($name) {
if (!isset($this->compiled[$name])) {
$this->compile($name);
}
return isset($this->compiled[$name]) ? $this->compiled[$name] : null;
} | [
"protected",
"function",
"getCompiledRoute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"compiled",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"compile",
"(",
"$",
"name",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"compiled",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"compiled",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
]
| Get a compiled route.
@param string $name
@return string|array|null | [
"Get",
"a",
"compiled",
"route",
"."
]
| train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/UrlGenerator.php#L108-L114 |
php-rise/rise | src/Router/UrlGenerator.php | UrlGenerator.generatePath | protected function generatePath($name, $params = []) {
$result = '';
$compiledRoute = $this->getCompiledRoute($name);
if (is_string($compiledRoute)) {
$result = $compiledRoute;
} else if (is_array($compiledRoute)) {
$chunks = $compiledRoute['chunks'];
foreach ($params as $paramName => $value) {
if (isset($compiledRoute['params'][$paramName])) {
$index = $compiledRoute['params'][$paramName];
$chunks[$index] = $value;
}
}
$result = implode($chunks);
}
return $result;
} | php | protected function generatePath($name, $params = []) {
$result = '';
$compiledRoute = $this->getCompiledRoute($name);
if (is_string($compiledRoute)) {
$result = $compiledRoute;
} else if (is_array($compiledRoute)) {
$chunks = $compiledRoute['chunks'];
foreach ($params as $paramName => $value) {
if (isset($compiledRoute['params'][$paramName])) {
$index = $compiledRoute['params'][$paramName];
$chunks[$index] = $value;
}
}
$result = implode($chunks);
}
return $result;
} | [
"protected",
"function",
"generatePath",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"compiledRoute",
"=",
"$",
"this",
"->",
"getCompiledRoute",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"compiledRoute",
")",
")",
"{",
"$",
"result",
"=",
"$",
"compiledRoute",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"compiledRoute",
")",
")",
"{",
"$",
"chunks",
"=",
"$",
"compiledRoute",
"[",
"'chunks'",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"paramName",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"compiledRoute",
"[",
"'params'",
"]",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"$",
"index",
"=",
"$",
"compiledRoute",
"[",
"'params'",
"]",
"[",
"$",
"paramName",
"]",
";",
"$",
"chunks",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"result",
"=",
"implode",
"(",
"$",
"chunks",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Generate path from compiled route.
@param string $name
@param array $params
@return string | [
"Generate",
"path",
"from",
"compiled",
"route",
"."
]
| train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/UrlGenerator.php#L123-L141 |
webforge-labs/psc-cms | lib/Psc/Form/HTML.php | HTML.select | public static function select($name, $options, $selected = NULL, Array $attributes = NULL) {
$name = self::getName($name);
if (is_string($options)) {
// nothing, wir haben hier vermutlich schon was zusammengebaut, was so hinkommt
} else {
$options = self::selectOptions($options, $selected);
}
$select = static::tag('select',$options, $attributes)
->setAttribute('name',$name)
->setGlueContent("%s \n");
return $select;
} | php | public static function select($name, $options, $selected = NULL, Array $attributes = NULL) {
$name = self::getName($name);
if (is_string($options)) {
// nothing, wir haben hier vermutlich schon was zusammengebaut, was so hinkommt
} else {
$options = self::selectOptions($options, $selected);
}
$select = static::tag('select',$options, $attributes)
->setAttribute('name',$name)
->setGlueContent("%s \n");
return $select;
} | [
"public",
"static",
"function",
"select",
"(",
"$",
"name",
",",
"$",
"options",
",",
"$",
"selected",
"=",
"NULL",
",",
"Array",
"$",
"attributes",
"=",
"NULL",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"getName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
")",
"{",
"// nothing, wir haben hier vermutlich schon was zusammengebaut, was so hinkommt",
"}",
"else",
"{",
"$",
"options",
"=",
"self",
"::",
"selectOptions",
"(",
"$",
"options",
",",
"$",
"selected",
")",
";",
"}",
"$",
"select",
"=",
"static",
"::",
"tag",
"(",
"'select'",
",",
"$",
"options",
",",
"$",
"attributes",
")",
"->",
"setAttribute",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"setGlueContent",
"(",
"\"%s \\n\"",
")",
";",
"return",
"$",
"select",
";",
"}"
]
| Erstellt ein Select Element
@param string $name
@param HTMLTag[] $options
@param mixed $selected das Ausgewählte elemt (muss die value einer option sein)
@param Array $attributes
@return HTMLTag | [
"Erstellt",
"ein",
"Select",
"Element"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Form/HTML.php#L90-L104 |
webforge-labs/psc-cms | lib/Psc/Form/HTML.php | HTML.selectOptions | public static function selectOptions($optionsArray, $selected = NULL) {
$ret = array();
foreach ($optionsArray as $value => $label) {
if ($label instanceof HTMLTag) {
$tag = $label;
if ($tag->getAttribute('value') === $selected)
$tag->setAttribute('selected','selected');
} else {
/* Interface Form Item */
if($label instanceof \Psc\Form\Item) {
$item = $label;
$label = $item->getFormLabel();
$value = $item->getFormValue();
}
$tag = static::tag('option',self::esc((string) $label),array('value'=>$value));
if ($value === $selected)
$tag->setAttribute('selected','selected');
}
$ret[] = $tag;
}
return $ret;
} | php | public static function selectOptions($optionsArray, $selected = NULL) {
$ret = array();
foreach ($optionsArray as $value => $label) {
if ($label instanceof HTMLTag) {
$tag = $label;
if ($tag->getAttribute('value') === $selected)
$tag->setAttribute('selected','selected');
} else {
/* Interface Form Item */
if($label instanceof \Psc\Form\Item) {
$item = $label;
$label = $item->getFormLabel();
$value = $item->getFormValue();
}
$tag = static::tag('option',self::esc((string) $label),array('value'=>$value));
if ($value === $selected)
$tag->setAttribute('selected','selected');
}
$ret[] = $tag;
}
return $ret;
} | [
"public",
"static",
"function",
"selectOptions",
"(",
"$",
"optionsArray",
",",
"$",
"selected",
"=",
"NULL",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"optionsArray",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"label",
"instanceof",
"HTMLTag",
")",
"{",
"$",
"tag",
"=",
"$",
"label",
";",
"if",
"(",
"$",
"tag",
"->",
"getAttribute",
"(",
"'value'",
")",
"===",
"$",
"selected",
")",
"$",
"tag",
"->",
"setAttribute",
"(",
"'selected'",
",",
"'selected'",
")",
";",
"}",
"else",
"{",
"/* Interface Form Item */",
"if",
"(",
"$",
"label",
"instanceof",
"\\",
"Psc",
"\\",
"Form",
"\\",
"Item",
")",
"{",
"$",
"item",
"=",
"$",
"label",
";",
"$",
"label",
"=",
"$",
"item",
"->",
"getFormLabel",
"(",
")",
";",
"$",
"value",
"=",
"$",
"item",
"->",
"getFormValue",
"(",
")",
";",
"}",
"$",
"tag",
"=",
"static",
"::",
"tag",
"(",
"'option'",
",",
"self",
"::",
"esc",
"(",
"(",
"string",
")",
"$",
"label",
")",
",",
"array",
"(",
"'value'",
"=>",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"value",
"===",
"$",
"selected",
")",
"$",
"tag",
"->",
"setAttribute",
"(",
"'selected'",
",",
"'selected'",
")",
";",
"}",
"$",
"ret",
"[",
"]",
"=",
"$",
"tag",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Erstellt einen Array von <option> Elementen für select
@param array $optionsArray $value => $label , $label wird escaped
@param mixed $selected die Value von dem Element welches selected="selected" als attribut haben soll
@return HTMLTag[] | [
"Erstellt",
"einen",
"Array",
"von",
"<option",
">",
"Elementen",
"für",
"select"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Form/HTML.php#L158-L183 |
webforge-labs/psc-cms | lib/Psc/Form/HTML.php | HTML.tag | public static function tag($name, $content = NULL, Array $attributes = NULL) {
$tag = new HTMLTag($name, $content, $attributes);
return $tag;
} | php | public static function tag($name, $content = NULL, Array $attributes = NULL) {
$tag = new HTMLTag($name, $content, $attributes);
return $tag;
} | [
"public",
"static",
"function",
"tag",
"(",
"$",
"name",
",",
"$",
"content",
"=",
"NULL",
",",
"Array",
"$",
"attributes",
"=",
"NULL",
")",
"{",
"$",
"tag",
"=",
"new",
"HTMLTag",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"tag",
";",
"}"
]
| Erzeugt ein neues Tag
@param string $name
@param mixed $content
@param Array $attributes
@return HTMLTag | [
"Erzeugt",
"ein",
"neues",
"Tag"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Form/HTML.php#L201-L204 |
crypto-markets/common | src/Common/GatewayFactory.php | GatewayFactory.create | public function create($abstract, array $options = [])
{
$concrete = $this->getConcrete($abstract);
if (class_exists($concrete)) {
return new $concrete($options);
}
throw new InvalidArgumentException("The gateway of [$abstract] not supported.");
} | php | public function create($abstract, array $options = [])
{
$concrete = $this->getConcrete($abstract);
if (class_exists($concrete)) {
return new $concrete($options);
}
throw new InvalidArgumentException("The gateway of [$abstract] not supported.");
} | [
"public",
"function",
"create",
"(",
"$",
"abstract",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"concrete",
"=",
"$",
"this",
"->",
"getConcrete",
"(",
"$",
"abstract",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"concrete",
")",
")",
"{",
"return",
"new",
"$",
"concrete",
"(",
"$",
"options",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The gateway of [$abstract] not supported.\"",
")",
";",
"}"
]
| Create an instance of the specified market driver.
@param string $abstract
@param array $options
@return \CryptoMarkets\Common\Gateway
@throws \InvalidArgumentException | [
"Create",
"an",
"instance",
"of",
"the",
"specified",
"market",
"driver",
"."
]
| train | https://github.com/crypto-markets/common/blob/206b1d9b88502d3fb73cef1323cd086156d3e633/src/Common/GatewayFactory.php#L18-L27 |
nyeholt/silverstripe-external-content | thirdparty/Zend/Uri.php | Zend_Uri.setConfig | static public function setConfig(array $config)
{
foreach ($config as $k => $v) {
self::$_config[$k] = $v;
}
} | php | static public function setConfig(array $config)
{
foreach ($config as $k => $v) {
self::$_config[$k] = $v;
}
} | [
"static",
"public",
"function",
"setConfig",
"(",
"array",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"self",
"::",
"$",
"_config",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}"
]
| Set global configuration options
@param array $config | [
"Set",
"global",
"configuration",
"options"
]
| train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Uri.php#L156-L161 |
boekkooi/tactician-amqp | src/Publisher/MessageCapturer.php | MessageCapturer.fetchMessages | public function fetchMessages($clear = true)
{
$messages = $this->messages;
if ($clear) {
$this->clear();
}
return $messages;
} | php | public function fetchMessages($clear = true)
{
$messages = $this->messages;
if ($clear) {
$this->clear();
}
return $messages;
} | [
"public",
"function",
"fetchMessages",
"(",
"$",
"clear",
"=",
"true",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"messages",
";",
"if",
"(",
"$",
"clear",
")",
"{",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"}",
"return",
"$",
"messages",
";",
"}"
]
| Fetch the captured messages.
@param bool $clear Clear the stored messages
@return Message[] | [
"Fetch",
"the",
"captured",
"messages",
"."
]
| train | https://github.com/boekkooi/tactician-amqp/blob/55cbb8b9e20aab7891e6a6090b248377c599360e/src/Publisher/MessageCapturer.php#L33-L41 |
inc2734/wp-share-buttons | src/App/Model/Count_Cache.php | Count_Cache.get | public function get() {
$cache = get_post_meta( $this->post_id, '_inc2734_count_cache_' . $this->service_name, true );
if ( '' !== $cache && time() <= $cache['expiration'] ) {
return $cache['count'];
}
} | php | public function get() {
$cache = get_post_meta( $this->post_id, '_inc2734_count_cache_' . $this->service_name, true );
if ( '' !== $cache && time() <= $cache['expiration'] ) {
return $cache['count'];
}
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"cache",
"=",
"get_post_meta",
"(",
"$",
"this",
"->",
"post_id",
",",
"'_inc2734_count_cache_'",
".",
"$",
"this",
"->",
"service_name",
",",
"true",
")",
";",
"if",
"(",
"''",
"!==",
"$",
"cache",
"&&",
"time",
"(",
")",
"<=",
"$",
"cache",
"[",
"'expiration'",
"]",
")",
"{",
"return",
"$",
"cache",
"[",
"'count'",
"]",
";",
"}",
"}"
]
| Return count cache
@return null|int | [
"Return",
"count",
"cache"
]
| train | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Model/Count_Cache.php#L39-L44 |
inc2734/wp-share-buttons | src/App/Model/Count_Cache.php | Count_Cache.get_cache_expiration | public function get_cache_expiration() {
$cache = get_post_meta( $this->post_id, '_inc2734_count_cache_' . $this->service_name, true );
if ( ! empty( $cache['expiration'] ) ) {
return date_i18n( 'm-d-Y H:i:s', $cache['expiration'] );
}
} | php | public function get_cache_expiration() {
$cache = get_post_meta( $this->post_id, '_inc2734_count_cache_' . $this->service_name, true );
if ( ! empty( $cache['expiration'] ) ) {
return date_i18n( 'm-d-Y H:i:s', $cache['expiration'] );
}
} | [
"public",
"function",
"get_cache_expiration",
"(",
")",
"{",
"$",
"cache",
"=",
"get_post_meta",
"(",
"$",
"this",
"->",
"post_id",
",",
"'_inc2734_count_cache_'",
".",
"$",
"this",
"->",
"service_name",
",",
"true",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cache",
"[",
"'expiration'",
"]",
")",
")",
"{",
"return",
"date_i18n",
"(",
"'m-d-Y H:i:s'",
",",
"$",
"cache",
"[",
"'expiration'",
"]",
")",
";",
"}",
"}"
]
| Return count cache
@return null|int | [
"Return",
"count",
"cache"
]
| train | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Model/Count_Cache.php#L51-L56 |
inc2734/wp-share-buttons | src/App/Model/Count_Cache.php | Count_Cache.update | public function update( $count ) {
update_post_meta(
$this->post_id,
'_inc2734_count_cache_' . $this->service_name,
[
'count' => $count,
'expiration' => time() + (int) apply_filters( 'inc2734_wp_share_buttons_count_cache_seconds', 60 * 5 ),
]
);
} | php | public function update( $count ) {
update_post_meta(
$this->post_id,
'_inc2734_count_cache_' . $this->service_name,
[
'count' => $count,
'expiration' => time() + (int) apply_filters( 'inc2734_wp_share_buttons_count_cache_seconds', 60 * 5 ),
]
);
} | [
"public",
"function",
"update",
"(",
"$",
"count",
")",
"{",
"update_post_meta",
"(",
"$",
"this",
"->",
"post_id",
",",
"'_inc2734_count_cache_'",
".",
"$",
"this",
"->",
"service_name",
",",
"[",
"'count'",
"=>",
"$",
"count",
",",
"'expiration'",
"=>",
"time",
"(",
")",
"+",
"(",
"int",
")",
"apply_filters",
"(",
"'inc2734_wp_share_buttons_count_cache_seconds'",
",",
"60",
"*",
"5",
")",
",",
"]",
")",
";",
"}"
]
| Update count cache
@return bool | [
"Update",
"count",
"cache"
]
| train | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Model/Count_Cache.php#L73-L82 |
austinkregel/Warden | src/Warden/WardenServiceProvider.php | WardenServiceProvider.register | public function register()
{
// Register the FormModel Provider.
$this->app->register(\Kregel\FormModel\FormModelServiceProvider::class);
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
// Register the alias.
$loader->alias('FormModel', \Kregel\FormModel\FormModel::class);
} | php | public function register()
{
// Register the FormModel Provider.
$this->app->register(\Kregel\FormModel\FormModelServiceProvider::class);
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
// Register the alias.
$loader->alias('FormModel', \Kregel\FormModel\FormModel::class);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"// Register the FormModel Provider.",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"\\",
"Kregel",
"\\",
"FormModel",
"\\",
"FormModelServiceProvider",
"::",
"class",
")",
";",
"$",
"loader",
"=",
"\\",
"Illuminate",
"\\",
"Foundation",
"\\",
"AliasLoader",
"::",
"getInstance",
"(",
")",
";",
"// Register the alias.",
"$",
"loader",
"->",
"alias",
"(",
"'FormModel'",
",",
"\\",
"Kregel",
"\\",
"FormModel",
"\\",
"FormModel",
"::",
"class",
")",
";",
"}"
]
| Register the service provider. | [
"Register",
"the",
"service",
"provider",
"."
]
| train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/WardenServiceProvider.php#L27-L34 |
austinkregel/Warden | src/Warden/WardenServiceProvider.php | WardenServiceProvider.boot | public function boot(Router $router)
{
$this->defineRoutes($router);
$this->loadViewsFrom(__DIR__.'/../resources/views', 'warden');
$this->publishes([
__DIR__.'/../resources/views' => base_path('resources/views/vendor/warden'),
], 'views');
$this->publishes([
__DIR__.'/../config/config.php' => config_path('kregel/warden.php'),
], 'config');
} | php | public function boot(Router $router)
{
$this->defineRoutes($router);
$this->loadViewsFrom(__DIR__.'/../resources/views', 'warden');
$this->publishes([
__DIR__.'/../resources/views' => base_path('resources/views/vendor/warden'),
], 'views');
$this->publishes([
__DIR__.'/../config/config.php' => config_path('kregel/warden.php'),
], 'config');
} | [
"public",
"function",
"boot",
"(",
"Router",
"$",
"router",
")",
"{",
"$",
"this",
"->",
"defineRoutes",
"(",
"$",
"router",
")",
";",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"__DIR__",
".",
"'/../resources/views'",
",",
"'warden'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../resources/views'",
"=>",
"base_path",
"(",
"'resources/views/vendor/warden'",
")",
",",
"]",
",",
"'views'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../config/config.php'",
"=>",
"config_path",
"(",
"'kregel/warden.php'",
")",
",",
"]",
",",
"'config'",
")",
";",
"}"
]
| Bootstrap any application services. | [
"Bootstrap",
"any",
"application",
"services",
"."
]
| train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/WardenServiceProvider.php#L39-L50 |
dms-org/package.blog | src/Domain/Services/Loader/BlogArticleLoader.php | BlogArticleLoader.getAmountOfArticles | public function getAmountOfArticles(Criteria $criteria = null) : int
{
return $this->blogArticleRepo->countMatching($criteria ?? $this->criteria());
} | php | public function getAmountOfArticles(Criteria $criteria = null) : int
{
return $this->blogArticleRepo->countMatching($criteria ?? $this->criteria());
} | [
"public",
"function",
"getAmountOfArticles",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"blogArticleRepo",
"->",
"countMatching",
"(",
"$",
"criteria",
"??",
"$",
"this",
"->",
"criteria",
"(",
")",
")",
";",
"}"
]
| @param Criteria $criteria
@return int | [
"@param",
"Criteria",
"$criteria"
]
| train | https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Domain/Services/Loader/BlogArticleLoader.php#L63-L66 |
dms-org/package.blog | src/Domain/Services/Loader/BlogArticleLoader.php | BlogArticleLoader.loadFromSlug | public function loadFromSlug(string $slug) : BlogArticle
{
$categories = $this->blogArticleRepo->matching(
$this->blogArticleRepo->criteria()
->where(BlogArticle::SLUG, '=', $slug)
->where(BlogArticle::PUBLISHED, '=', true)
);
if (!$categories) {
throw new EntityNotFoundException(BlogArticle::class, $slug, BlogArticle::SLUG);
}
return reset($categories);
} | php | public function loadFromSlug(string $slug) : BlogArticle
{
$categories = $this->blogArticleRepo->matching(
$this->blogArticleRepo->criteria()
->where(BlogArticle::SLUG, '=', $slug)
->where(BlogArticle::PUBLISHED, '=', true)
);
if (!$categories) {
throw new EntityNotFoundException(BlogArticle::class, $slug, BlogArticle::SLUG);
}
return reset($categories);
} | [
"public",
"function",
"loadFromSlug",
"(",
"string",
"$",
"slug",
")",
":",
"BlogArticle",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"blogArticleRepo",
"->",
"matching",
"(",
"$",
"this",
"->",
"blogArticleRepo",
"->",
"criteria",
"(",
")",
"->",
"where",
"(",
"BlogArticle",
"::",
"SLUG",
",",
"'='",
",",
"$",
"slug",
")",
"->",
"where",
"(",
"BlogArticle",
"::",
"PUBLISHED",
",",
"'='",
",",
"true",
")",
")",
";",
"if",
"(",
"!",
"$",
"categories",
")",
"{",
"throw",
"new",
"EntityNotFoundException",
"(",
"BlogArticle",
"::",
"class",
",",
"$",
"slug",
",",
"BlogArticle",
"::",
"SLUG",
")",
";",
"}",
"return",
"reset",
"(",
"$",
"categories",
")",
";",
"}"
]
| @param string $slug
@return BlogArticle
@throws EntityNotFoundException | [
"@param",
"string",
"$slug"
]
| train | https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Domain/Services/Loader/BlogArticleLoader.php#L86-L99 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.