repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleHttpException | protected function handleHttpException(Exception $e)
{
$statusCode = $e->getStatusCode();
// if there is no exception message just get the standard HTTP text.
if (empty($e->getMessage())) {
$message = Response::$statusTexts[$statusCode];
} else {
$message = $e->getMessage();
}
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | php | protected function handleHttpException(Exception $e)
{
$statusCode = $e->getStatusCode();
// if there is no exception message just get the standard HTTP text.
if (empty($e->getMessage())) {
$message = Response::$statusTexts[$statusCode];
} else {
$message = $e->getMessage();
}
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | [
"protected",
"function",
"handleHttpException",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"statusCode",
"=",
"$",
"e",
"->",
"getStatusCode",
"(",
")",
";",
"// if there is no exception message just get the standard HTTP text.",
"if",
"(",
"empty",
"(",
"$",
"e",
... | Handle a HTTP exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"HTTP",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L79-L91 | train |
LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleModelNotFoundException | protected function handleModelNotFoundException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 404;
$reflection = new \ReflectionClass($e->getModel());
$message = $reflection->getShortName() . ' not found';
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | php | protected function handleModelNotFoundException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 404;
$reflection = new \ReflectionClass($e->getModel());
$message = $reflection->getShortName() . ' not found';
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | [
"protected",
"function",
"handleModelNotFoundException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Get the status code and build the message.",
"$",
"statusCode",
"=",
"404",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"e",
"->",
"getModel... | Handle a model not found exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"model",
"not",
"found",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L99-L107 | train |
LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleValidationException | protected function handleValidationException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 422;
$message = $e->getMessage();
$errorData = $e->getResponse()->getData();
return $this->generateResponse('errors', $errorData, $statusCode, Status::FAIL, $message);
} | php | protected function handleValidationException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 422;
$message = $e->getMessage();
$errorData = $e->getResponse()->getData();
return $this->generateResponse('errors', $errorData, $statusCode, Status::FAIL, $message);
} | [
"protected",
"function",
"handleValidationException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Get the status code and build the message.",
"$",
"statusCode",
"=",
"422",
";",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"errorData",
"... | Handle a validation exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"validation",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L115-L123 | train |
LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleGenericException | protected function handleGenericException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 500;
$message = $e->getMessage();
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | php | protected function handleGenericException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 500;
$message = $e->getMessage();
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | [
"protected",
"function",
"handleGenericException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Get the status code and build the message.",
"$",
"statusCode",
"=",
"500",
";",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"$",
"this",... | Handle a generic exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"generic",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L131-L138 | train |
LUSHDigital/microservice-core | src/Http/Controllers/MicroServiceController.php | MicroServiceController.info | public function info()
{
// Build the response object.
$serviceInfo = (object) MicroServiceHelper::getServiceInfo();
$serviceInfo->endpoints = [];
// Add the endpoints.
foreach (app()->getRoutes() as $appRoute) {
$endpoint = new \stdClass();
$endpoint->uri = $appRoute['uri'];
$endpoint->method = $appRoute['method'];
$serviceInfo->endpoints[] = $endpoint;
}
return response()->json($serviceInfo);
} | php | public function info()
{
// Build the response object.
$serviceInfo = (object) MicroServiceHelper::getServiceInfo();
$serviceInfo->endpoints = [];
// Add the endpoints.
foreach (app()->getRoutes() as $appRoute) {
$endpoint = new \stdClass();
$endpoint->uri = $appRoute['uri'];
$endpoint->method = $appRoute['method'];
$serviceInfo->endpoints[] = $endpoint;
}
return response()->json($serviceInfo);
} | [
"public",
"function",
"info",
"(",
")",
"{",
"// Build the response object.",
"$",
"serviceInfo",
"=",
"(",
"object",
")",
"MicroServiceHelper",
"::",
"getServiceInfo",
"(",
")",
";",
"$",
"serviceInfo",
"->",
"endpoints",
"=",
"[",
"]",
";",
"// Add the endpoin... | Retrieve information about this microservice.
Required by the service registry.
@return Response | [
"Retrieve",
"information",
"about",
"this",
"microservice",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Http/Controllers/MicroServiceController.php#L35-L51 | train |
LUSHDigital/microservice-core | src/Http/Controllers/MicroServiceController.php | MicroServiceController.health | public function health()
{
try {
// Logic for validating health (e.g. connections to external
// services) should go here.
// If a cache driver is defined, check it is working.
if (!empty(env('CACHE_DRIVER', null))) {
Cache::put('health_check', 'test', 1);
Cache::get('health_check');
}
// If a DB connection is defined, check it is working.
if (!empty(env('DB_HOST', null))) {
DB::connection()->getPdo();
}
// All of our service dependencies are working so build a valid
// response object.
return $this->generateResponse('health', null);
} catch (\Exception $e) {
return $this->generateResponse('', null, 500, Status::FAIL, $e->getMessage());
}
} | php | public function health()
{
try {
// Logic for validating health (e.g. connections to external
// services) should go here.
// If a cache driver is defined, check it is working.
if (!empty(env('CACHE_DRIVER', null))) {
Cache::put('health_check', 'test', 1);
Cache::get('health_check');
}
// If a DB connection is defined, check it is working.
if (!empty(env('DB_HOST', null))) {
DB::connection()->getPdo();
}
// All of our service dependencies are working so build a valid
// response object.
return $this->generateResponse('health', null);
} catch (\Exception $e) {
return $this->generateResponse('', null, 500, Status::FAIL, $e->getMessage());
}
} | [
"public",
"function",
"health",
"(",
")",
"{",
"try",
"{",
"// Logic for validating health (e.g. connections to external",
"// services) should go here.",
"// If a cache driver is defined, check it is working.",
"if",
"(",
"!",
"empty",
"(",
"env",
"(",
"'CACHE_DRIVER'",
",",
... | Retrieve a health check for this microservice.
Required by the service gateway and load balancer.
@return Response | [
"Retrieve",
"a",
"health",
"check",
"for",
"this",
"microservice",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Http/Controllers/MicroServiceController.php#L60-L83 | train |
LUSHDigital/microservice-core | src/Pagination/Paginator.php | Paginator.preparePaginationResponse | public function preparePaginationResponse()
{
return new Response($this->total, $this->perPage, $this->page, $this->lastPage);
} | php | public function preparePaginationResponse()
{
return new Response($this->total, $this->perPage, $this->page, $this->lastPage);
} | [
"public",
"function",
"preparePaginationResponse",
"(",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"total",
",",
"$",
"this",
"->",
"perPage",
",",
"$",
"this",
"->",
"page",
",",
"$",
"this",
"->",
"lastPage",
")",
";",
"}"
] | Prepare the pagination response.
@return Response | [
"Prepare",
"the",
"pagination",
"response",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Paginator.php#L178-L181 | train |
LUSHDigital/microservice-core | src/Pagination/Paginator.php | Paginator.calculateOffset | protected function calculateOffset()
{
if (empty($this->page) || empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate offset. Insufficient data');
}
$this->offset = ($this->page - 1) * $this->perPage;
} | php | protected function calculateOffset()
{
if (empty($this->page) || empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate offset. Insufficient data');
}
$this->offset = ($this->page - 1) * $this->perPage;
} | [
"protected",
"function",
"calculateOffset",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"page",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"perPage",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot calculate offset. I... | Calculate the offset based on the current values. | [
"Calculate",
"the",
"offset",
"based",
"on",
"the",
"current",
"values",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Paginator.php#L186-L193 | train |
LUSHDigital/microservice-core | src/Pagination/Paginator.php | Paginator.calculateLastPage | protected function calculateLastPage()
{
if (empty($this->total)) {
$this->lastPage = 0;
return;
}
if (empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate last page. Insufficient data');
}
$this->lastPage = (int) ceil($this->total / $this->perPage);
} | php | protected function calculateLastPage()
{
if (empty($this->total)) {
$this->lastPage = 0;
return;
}
if (empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate last page. Insufficient data');
}
$this->lastPage = (int) ceil($this->total / $this->perPage);
} | [
"protected",
"function",
"calculateLastPage",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"total",
")",
")",
"{",
"$",
"this",
"->",
"lastPage",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"perPage"... | Calculate the last page based on the current values. | [
"Calculate",
"the",
"last",
"page",
"based",
"on",
"the",
"current",
"values",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Paginator.php#L198-L210 | train |
view-components/grids | src/Component/Column.php | Column.formatValue | public function formatValue($value)
{
$formatter = $this->getValueFormatter();
return (string)($formatter ? call_user_func($formatter, $value, $this->getGrid()->getCurrentRow()) : $value);
} | php | public function formatValue($value)
{
$formatter = $this->getValueFormatter();
return (string)($formatter ? call_user_func($formatter, $value, $this->getGrid()->getCurrentRow()) : $value);
} | [
"public",
"function",
"formatValue",
"(",
"$",
"value",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getValueFormatter",
"(",
")",
";",
"return",
"(",
"string",
")",
"(",
"$",
"formatter",
"?",
"call_user_func",
"(",
"$",
"formatter",
",",
"$",
... | Formats value extracted from data row.
@param $value
@return string | [
"Formats",
"value",
"extracted",
"from",
"data",
"row",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/Column.php#L93-L97 | train |
view-components/grids | src/Component/Column.php | Column.getCurrentValue | public function getCurrentValue()
{
$func = $this->getValueCalculator();
$currentDataRow = $this->getGrid()->getCurrentRow();
if ($func !== null) {
return call_user_func($func, $currentDataRow);
} else {
return mp\getValue($currentDataRow, $this->getDataFieldName());
}
} | php | public function getCurrentValue()
{
$func = $this->getValueCalculator();
$currentDataRow = $this->getGrid()->getCurrentRow();
if ($func !== null) {
return call_user_func($func, $currentDataRow);
} else {
return mp\getValue($currentDataRow, $this->getDataFieldName());
}
} | [
"public",
"function",
"getCurrentValue",
"(",
")",
"{",
"$",
"func",
"=",
"$",
"this",
"->",
"getValueCalculator",
"(",
")",
";",
"$",
"currentDataRow",
"=",
"$",
"this",
"->",
"getGrid",
"(",
")",
"->",
"getCurrentRow",
"(",
")",
";",
"if",
"(",
"$",
... | Returns current data cell value.
@return mixed | [
"Returns",
"current",
"data",
"cell",
"value",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/Column.php#L104-L113 | train |
view-components/grids | src/Component/Column.php | Column.getLabel | public function getLabel()
{
if ($this->label === null) {
$this->label = ucwords(str_replace(array('-', '_', '.'), ' ', $this->id));
}
return $this->label;
} | php | public function getLabel()
{
if ($this->label === null) {
$this->label = ucwords(str_replace(array('-', '_', '.'), ' ', $this->id));
}
return $this->label;
} | [
"public",
"function",
"getLabel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"label",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"label",
"=",
"ucwords",
"(",
"str_replace",
"(",
"array",
"(",
"'-'",
",",
"'_'",
",",
"'.'",
")",
",",
"' '",
",... | Returns text label that will be rendered in table header.
@return string | [
"Returns",
"text",
"label",
"that",
"will",
"be",
"rendered",
"in",
"table",
"header",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/Column.php#L270-L276 | train |
view-components/grids | src/Component/ColumnSortingControl.php | ColumnSortingControl.getDirection | protected function getDirection()
{
if (!$this->inputOption->hasValue()) {
return null;
}
list($columnName, $direction) = explode(static::DELIMITER, $this->inputOption->getValue());
if ($columnName !== $this->columnId) {
return null;
}
return $direction;
} | php | protected function getDirection()
{
if (!$this->inputOption->hasValue()) {
return null;
}
list($columnName, $direction) = explode(static::DELIMITER, $this->inputOption->getValue());
if ($columnName !== $this->columnId) {
return null;
}
return $direction;
} | [
"protected",
"function",
"getDirection",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"inputOption",
"->",
"hasValue",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"list",
"(",
"$",
"columnName",
",",
"$",
"direction",
")",
"=",
"explode",
"(... | Returns sorting direction for attached column if specified in input.
@return string|null 'asc', 'desc' or null | [
"Returns",
"sorting",
"direction",
"for",
"attached",
"column",
"if",
"specified",
"in",
"input",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/ColumnSortingControl.php#L40-L50 | train |
view-components/grids | src/Component/ColumnSortingControl.php | ColumnSortingControl.getOperation | public function getOperation()
{
$direction = $this->getDirection();
if ($direction === null) {
return new DummyOperation();
}
if ($this->root !== null) {
/** @var Grid $root */
$root = $this->root;
$fieldName = $root->getColumn($this->columnId)->getDataFieldName();
} else {
$fieldName = $this->columnId;
}
return new SortOperation($fieldName, $direction);
} | php | public function getOperation()
{
$direction = $this->getDirection();
if ($direction === null) {
return new DummyOperation();
}
if ($this->root !== null) {
/** @var Grid $root */
$root = $this->root;
$fieldName = $root->getColumn($this->columnId)->getDataFieldName();
} else {
$fieldName = $this->columnId;
}
return new SortOperation($fieldName, $direction);
} | [
"public",
"function",
"getOperation",
"(",
")",
"{",
"$",
"direction",
"=",
"$",
"this",
"->",
"getDirection",
"(",
")",
";",
"if",
"(",
"$",
"direction",
"===",
"null",
")",
"{",
"return",
"new",
"DummyOperation",
"(",
")",
";",
"}",
"if",
"(",
"$",... | Creates operation for data provider.
@return DummyOperation|SortOperation | [
"Creates",
"operation",
"for",
"data",
"provider",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/ColumnSortingControl.php#L69-L83 | train |
view-components/grids | src/GridPartsAccessTrait.php | GridPartsAccessTrait.setTable | public function setTable(ContainerComponentInterface $component)
{
return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
} | php | public function setTable(ContainerComponentInterface $component)
{
return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
} | [
"public",
"function",
"setTable",
"(",
"ContainerComponentInterface",
"$",
"component",
")",
"{",
"return",
"$",
"this",
"->",
"setComponent",
"(",
"$",
"component",
",",
"Grid",
"::",
"TABLE_ID",
",",
"Grid",
"::",
"FORM_ID",
")",
";",
"}"
] | Sets component for rendering 'table' tag.
@param ContainerComponentInterface $component
@return $this | [
"Sets",
"component",
"for",
"rendering",
"table",
"tag",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/GridPartsAccessTrait.php#L49-L52 | train |
view-components/grids | src/Component/PageTotalsRow.php | PageTotalsRow.render | public function render()
{
/** @var Grid $grid */
$grid = $this->root;
$this->isTotalsCalculationFinished = true;
$tr = $grid->getRecordView();
// set total_row as current grid row
$lastRow = $grid->getCurrentRow();
$grid->setCurrentRow($this->totalData);
// modify columns, prepare it for rendering totals row
$valueCalculators = [];
$valueFormatters = [];
foreach ($grid->getColumns() as $column) {
$valueCalculators[$column->getId()] = $column->getValueCalculator();
$valueFormatters[$column->getId()] = $prevFormatter = $column->getValueFormatter();
$column->setValueCalculator(null);
$column->setValueFormatter(function ($value) use ($prevFormatter, $column) {
$operation = $this->getOperation($column->getId());
if ($prevFormatter && !($operation === static::OPERATION_IGNORE || $operation instanceof Closure)) {
$value = call_user_func($prevFormatter, $value);
}
// Add value prefix if specified for operation
if ($value !== null && is_string($operation) && array_key_exists($operation, $this->valuePrefixes)) {
$value = $this->valuePrefixes[$operation] . ' ' . $value;
}
return $value;
});
}
$output = $tr->render();
// restore column value calculators & formatters
foreach ($grid->getColumns() as $column) {
$column->setValueCalculator($valueCalculators[$column->getId()]);
$column->setValueFormatter($valueFormatters[$column->getId()]);
}
// restore last data row
$grid->setCurrentRow($lastRow);
return $output;
} | php | public function render()
{
/** @var Grid $grid */
$grid = $this->root;
$this->isTotalsCalculationFinished = true;
$tr = $grid->getRecordView();
// set total_row as current grid row
$lastRow = $grid->getCurrentRow();
$grid->setCurrentRow($this->totalData);
// modify columns, prepare it for rendering totals row
$valueCalculators = [];
$valueFormatters = [];
foreach ($grid->getColumns() as $column) {
$valueCalculators[$column->getId()] = $column->getValueCalculator();
$valueFormatters[$column->getId()] = $prevFormatter = $column->getValueFormatter();
$column->setValueCalculator(null);
$column->setValueFormatter(function ($value) use ($prevFormatter, $column) {
$operation = $this->getOperation($column->getId());
if ($prevFormatter && !($operation === static::OPERATION_IGNORE || $operation instanceof Closure)) {
$value = call_user_func($prevFormatter, $value);
}
// Add value prefix if specified for operation
if ($value !== null && is_string($operation) && array_key_exists($operation, $this->valuePrefixes)) {
$value = $this->valuePrefixes[$operation] . ' ' . $value;
}
return $value;
});
}
$output = $tr->render();
// restore column value calculators & formatters
foreach ($grid->getColumns() as $column) {
$column->setValueCalculator($valueCalculators[$column->getId()]);
$column->setValueFormatter($valueFormatters[$column->getId()]);
}
// restore last data row
$grid->setCurrentRow($lastRow);
return $output;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"/** @var Grid $grid */",
"$",
"grid",
"=",
"$",
"this",
"->",
"root",
";",
"$",
"this",
"->",
"isTotalsCalculationFinished",
"=",
"true",
";",
"$",
"tr",
"=",
"$",
"grid",
"->",
"getRecordView",
"(",
")",
"... | Renders tag and returns output.
@return string | [
"Renders",
"tag",
"and",
"returns",
"output",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/PageTotalsRow.php#L126-L166 | train |
view-components/grids | src/Grid.php | Grid.getColumn | public function getColumn($id)
{
$column = $this->getComponent($id);
if (!$column) {
throw new RuntimeException("Column '$id' is not defined.");
}
if (!$column instanceof Column) {
throw new RuntimeException("'$id' is not a column.");
}
return $column;
} | php | public function getColumn($id)
{
$column = $this->getComponent($id);
if (!$column) {
throw new RuntimeException("Column '$id' is not defined.");
}
if (!$column instanceof Column) {
throw new RuntimeException("'$id' is not a column.");
}
return $column;
} | [
"public",
"function",
"getColumn",
"(",
"$",
"id",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getComponent",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"column",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Column '$id' is not defined... | Returns column with specified id,
throws exception if grid does not have specified column.
@param string $id
@return Column | [
"Returns",
"column",
"with",
"specified",
"id",
"throws",
"exception",
"if",
"grid",
"does",
"not",
"have",
"specified",
"column",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Grid.php#L49-L59 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy.execute | public function execute()
{
$this->_checkPermissions();
$this->_gatherRequestInfo();
$this->_makeRequest();
$this->_parseResponse();
$this->_buildAndExecuteProxyResponse();
} | php | public function execute()
{
$this->_checkPermissions();
$this->_gatherRequestInfo();
$this->_makeRequest();
$this->_parseResponse();
$this->_buildAndExecuteProxyResponse();
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"this",
"->",
"_checkPermissions",
"(",
")",
";",
"$",
"this",
"->",
"_gatherRequestInfo",
"(",
")",
";",
"$",
"this",
"->",
"_makeRequest",
"(",
")",
";",
"$",
"this",
"->",
"_parseResponse",
"(",
"... | Execute the proxy request. This method sets HTTP headers and write to the
output stream. Make sure that no whitespace or headers have already been
sent. | [
"Execute",
"the",
"proxy",
"request",
".",
"This",
"method",
"sets",
"HTTP",
"headers",
"and",
"write",
"to",
"the",
"output",
"stream",
".",
"Make",
"sure",
"that",
"no",
"whitespace",
"or",
"headers",
"have",
"already",
"been",
"sent",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L182-L189 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._gatherRequestInfo | protected function _gatherRequestInfo()
{
$this->_loadRequestMethod();
$this->_loadRequestCookies();
$this->_loadRequestUserAgent();
$this->_loadRequestAuthorizationHeader();
$this->_loadRequestAcceptHeader();
$this->_loadRawHeaders();
$this->_loadContentType();
$this->_loadUrl();
if($this->_requestMethod === 'POST'
|| $this->_requestMethod === 'PUT')
{
$this->_loadRequestBody();
}
} | php | protected function _gatherRequestInfo()
{
$this->_loadRequestMethod();
$this->_loadRequestCookies();
$this->_loadRequestUserAgent();
$this->_loadRequestAuthorizationHeader();
$this->_loadRequestAcceptHeader();
$this->_loadRawHeaders();
$this->_loadContentType();
$this->_loadUrl();
if($this->_requestMethod === 'POST'
|| $this->_requestMethod === 'PUT')
{
$this->_loadRequestBody();
}
} | [
"protected",
"function",
"_gatherRequestInfo",
"(",
")",
"{",
"$",
"this",
"->",
"_loadRequestMethod",
"(",
")",
";",
"$",
"this",
"->",
"_loadRequestCookies",
"(",
")",
";",
"$",
"this",
"->",
"_loadRequestUserAgent",
"(",
")",
";",
"$",
"this",
"->",
"_l... | Gather any information we need about the request and
store them in the class properties | [
"Gather",
"any",
"information",
"we",
"need",
"about",
"the",
"request",
"and",
"store",
"them",
"in",
"the",
"class",
"properties"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L195-L211 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadUrl | protected function _loadUrl()
{
if(!key_exists('url', $_GET))
throw new Exception("You must supply a 'url' parameter in the request");
$this->_url = ($this->_forwardHost)
? $this->_forwardHost . $_GET['url']
: $_GET['url'];
} | php | protected function _loadUrl()
{
if(!key_exists('url', $_GET))
throw new Exception("You must supply a 'url' parameter in the request");
$this->_url = ($this->_forwardHost)
? $this->_forwardHost . $_GET['url']
: $_GET['url'];
} | [
"protected",
"function",
"_loadUrl",
"(",
")",
"{",
"if",
"(",
"!",
"key_exists",
"(",
"'url'",
",",
"$",
"_GET",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"You must supply a 'url' parameter in the request\"",
")",
";",
"$",
"this",
"->",
"_url",
"=",
"(... | Get the url to where the request will be made.
@throws Exception When there is no 'url' parameter | [
"Get",
"the",
"url",
"to",
"where",
"the",
"request",
"will",
"be",
"made",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L218-L226 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestMethod | protected function _loadRequestMethod()
{
if($this->_requestMethod !== NULL) return;
if(!key_exists('REQUEST_METHOD', $_SERVER)) {
throw new Exception("Request method unknown");
}
$method = strtoupper($_SERVER['REQUEST_METHOD']);
if (in_array($method, array('GET', 'POST', 'PUT', 'DELETE', 'PATCH'))) {
$this->_requestMethod = $method;
} else {
throw new Exception("Request method ($method) invalid");
}
} | php | protected function _loadRequestMethod()
{
if($this->_requestMethod !== NULL) return;
if(!key_exists('REQUEST_METHOD', $_SERVER)) {
throw new Exception("Request method unknown");
}
$method = strtoupper($_SERVER['REQUEST_METHOD']);
if (in_array($method, array('GET', 'POST', 'PUT', 'DELETE', 'PATCH'))) {
$this->_requestMethod = $method;
} else {
throw new Exception("Request method ($method) invalid");
}
} | [
"protected",
"function",
"_loadRequestMethod",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestMethod",
"!==",
"NULL",
")",
"return",
";",
"if",
"(",
"!",
"key_exists",
"(",
"'REQUEST_METHOD'",
",",
"$",
"_SERVER",
")",
")",
"{",
"throw",
"new",
"E... | Examine the request and load the HTTP request method
into the _requestMethod property
@throws Exception When there is no request method | [
"Examine",
"the",
"request",
"and",
"load",
"the",
"HTTP",
"request",
"method",
"into",
"the",
"_requestMethod",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L248-L263 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestUserAgent | protected function _loadRequestUserAgent()
{
if($this->_requestUserAgent !== NULL) return;
if(! key_exists('HTTP_USER_AGENT', $_SERVER))
throw new Exception("No HTTP User Agent was found");
$this->_requestUserAgent = $_SERVER['HTTP_USER_AGENT'];
} | php | protected function _loadRequestUserAgent()
{
if($this->_requestUserAgent !== NULL) return;
if(! key_exists('HTTP_USER_AGENT', $_SERVER))
throw new Exception("No HTTP User Agent was found");
$this->_requestUserAgent = $_SERVER['HTTP_USER_AGENT'];
} | [
"protected",
"function",
"_loadRequestUserAgent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestUserAgent",
"!==",
"NULL",
")",
"return",
";",
"if",
"(",
"!",
"key_exists",
"(",
"'HTTP_USER_AGENT'",
",",
"$",
"_SERVER",
")",
")",
"throw",
"new",
"E... | Loads the user-agent string into the _requestUserAgent property
@throws Exception When the user agent is not sent by the client | [
"Loads",
"the",
"user",
"-",
"agent",
"string",
"into",
"the",
"_requestUserAgent",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L269-L277 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestAuthorizationHeader | protected function _loadRequestAuthorizationHeader()
{
if($this->_requestAuthorization !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Authorization', $this->_rawHeaders)) {
$this->_requestAuthorization = $this->_rawHeaders['Authorization'];
}
} | php | protected function _loadRequestAuthorizationHeader()
{
if($this->_requestAuthorization !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Authorization', $this->_rawHeaders)) {
$this->_requestAuthorization = $this->_rawHeaders['Authorization'];
}
} | [
"protected",
"function",
"_loadRequestAuthorizationHeader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestAuthorization",
"!==",
"NULL",
")",
"return",
";",
"$",
"this",
"->",
"_loadRawHeaders",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'Authorizat... | Store the Authorization header in _requestAuthorization
property | [
"Store",
"the",
"Authorization",
"header",
"in",
"_requestAuthorization",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L294-L303 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestAcceptHeader | protected function _loadRequestAcceptHeader()
{
if($this->_requestAccept !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Accept', $this->_rawHeaders)) {
$this->_requestAccept = $this->_rawHeaders['Accept'];
}
} | php | protected function _loadRequestAcceptHeader()
{
if($this->_requestAccept !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Accept', $this->_rawHeaders)) {
$this->_requestAccept = $this->_rawHeaders['Accept'];
}
} | [
"protected",
"function",
"_loadRequestAcceptHeader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestAccept",
"!==",
"NULL",
")",
"return",
";",
"$",
"this",
"->",
"_loadRawHeaders",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'Accept'",
",",
"$",
... | Store the Accept header in _requestAccept property | [
"Store",
"the",
"Accept",
"header",
"in",
"_requestAccept",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L308-L317 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadContentType | protected function _loadContentType()
{
$this->_loadRawHeaders();
if(key_exists('Content-Type', $this->_rawHeaders))
$this->_requestContentType = $this->_rawHeaders['Content-Type'];
} | php | protected function _loadContentType()
{
$this->_loadRawHeaders();
if(key_exists('Content-Type', $this->_rawHeaders))
$this->_requestContentType = $this->_rawHeaders['Content-Type'];
} | [
"protected",
"function",
"_loadContentType",
"(",
")",
"{",
"$",
"this",
"->",
"_loadRawHeaders",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'Content-Type'",
",",
"$",
"this",
"->",
"_rawHeaders",
")",
")",
"$",
"this",
"->",
"_requestContentType",
"=",
... | Load the content type into the _requestContentType property | [
"Load",
"the",
"content",
"type",
"into",
"the",
"_requestContentType",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L322-L328 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRawHeaders | protected function _loadRawHeaders()
{
if($this->_rawHeaders !== NULL) return;
$this->_rawHeaders = apache_request_headers();
if($this->_rawHeaders === FALSE)
throw new Exception("Could not get request headers");
} | php | protected function _loadRawHeaders()
{
if($this->_rawHeaders !== NULL) return;
$this->_rawHeaders = apache_request_headers();
if($this->_rawHeaders === FALSE)
throw new Exception("Could not get request headers");
} | [
"protected",
"function",
"_loadRawHeaders",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_rawHeaders",
"!==",
"NULL",
")",
"return",
";",
"$",
"this",
"->",
"_rawHeaders",
"=",
"apache_request_headers",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_raw... | Load raw headers into the _rawHeaders property.
This method REQUIRES APACHE
@throws Exception When we can't load request headers (perhaps when Apache
isn't being used) | [
"Load",
"raw",
"headers",
"into",
"the",
"_rawHeaders",
"property",
".",
"This",
"method",
"REQUIRES",
"APACHE"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L336-L344 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._checkPermissions | protected function _checkPermissions()
{
if($this->_allowedHostnames === NULL)
return;
if(key_exists('REMOTE_HOST', $_SERVER))
$host = $_SERVER['REMOTE_HOST'];
else
$host = $_SERVER['REMOTE_ADDR'];
if(!in_array($host, $this->_allowedHostnames))
throw new Exception("Requests from hostname ($host) are not allowed");
} | php | protected function _checkPermissions()
{
if($this->_allowedHostnames === NULL)
return;
if(key_exists('REMOTE_HOST', $_SERVER))
$host = $_SERVER['REMOTE_HOST'];
else
$host = $_SERVER['REMOTE_ADDR'];
if(!in_array($host, $this->_allowedHostnames))
throw new Exception("Requests from hostname ($host) are not allowed");
} | [
"protected",
"function",
"_checkPermissions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_allowedHostnames",
"===",
"NULL",
")",
"return",
";",
"if",
"(",
"key_exists",
"(",
"'REMOTE_HOST'",
",",
"$",
"_SERVER",
")",
")",
"$",
"host",
"=",
"$",
"_SERV... | Check that the proxy request is coming from the appropriate host
that was set in the second argument of the constructor
@return void
@throws Exception when a client hostname is not permitted on a request | [
"Check",
"that",
"the",
"proxy",
"request",
"is",
"coming",
"from",
"the",
"appropriate",
"host",
"that",
"was",
"set",
"in",
"the",
"second",
"argument",
"of",
"the",
"constructor"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L352-L364 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._makeRequest | protected function _makeRequest()
{
# Check for cURL. If it isn't loaded, fall back to fopen()
if(function_exists('curl_init'))
$this->_rawResponse = $this->_makeCurlRequest($this->_url);
else
$this->_rawResponse = $this->_makeFOpenRequest($this->_url);
} | php | protected function _makeRequest()
{
# Check for cURL. If it isn't loaded, fall back to fopen()
if(function_exists('curl_init'))
$this->_rawResponse = $this->_makeCurlRequest($this->_url);
else
$this->_rawResponse = $this->_makeFOpenRequest($this->_url);
} | [
"protected",
"function",
"_makeRequest",
"(",
")",
"{",
"# Check for cURL. If it isn't loaded, fall back to fopen()\r",
"if",
"(",
"function_exists",
"(",
"'curl_init'",
")",
")",
"$",
"this",
"->",
"_rawResponse",
"=",
"$",
"this",
"->",
"_makeCurlRequest",
"(",
"$",... | Make the proxy request using the supplied route and the base host we got
in the constructor. Store the response in _rawResponse | [
"Make",
"the",
"proxy",
"request",
"using",
"the",
"supplied",
"route",
"and",
"the",
"base",
"host",
"we",
"got",
"in",
"the",
"constructor",
".",
"Store",
"the",
"response",
"in",
"_rawResponse"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L370-L377 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._makeCurlRequest | protected function _makeCurlRequest($url)
{
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->_requestMethod);
if($this->_requestBody)
{
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->_requestBody);
}
curl_setopt($curl_handle, CURLOPT_HEADER, true);
curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->_requestUserAgent);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_COOKIE, $this->_buildProxyRequestCookieString());
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $this->_generateProxyRequestHeaders());
$response = curl_exec($curl_handle);
if (false === $response) {
var_dump(curl_error($curl_handle));
} else {
return $response;
}
} | php | protected function _makeCurlRequest($url)
{
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->_requestMethod);
if($this->_requestBody)
{
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->_requestBody);
}
curl_setopt($curl_handle, CURLOPT_HEADER, true);
curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->_requestUserAgent);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_COOKIE, $this->_buildProxyRequestCookieString());
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $this->_generateProxyRequestHeaders());
$response = curl_exec($curl_handle);
if (false === $response) {
var_dump(curl_error($curl_handle));
} else {
return $response;
}
} | [
"protected",
"function",
"_makeCurlRequest",
"(",
"$",
"url",
")",
"{",
"$",
"curl_handle",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"this",
"->",
"_requestMethod",
")",
";",... | Given the object's current settings, make a request to the given url
using the cURL library
@param string $url The url to make the request to
@return string The full HTTP response | [
"Given",
"the",
"object",
"s",
"current",
"settings",
"make",
"a",
"request",
"to",
"the",
"given",
"url",
"using",
"the",
"cURL",
"library"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L385-L408 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._makeFOpenRequest | protected function _makeFOpenRequest($url)
{
$context = $this->_buildFOpenStreamContext();
$file_pointer = @fopen($url, 'r', null, $context);
if(!$file_pointer)
throw new Exception("There was an error making the request. Make sure that the url is valid, and either fopen or cURL are available.");
$meta = stream_get_meta_data($file_pointer);
$headers = $this->_buildResponseHeaderFromMeta($meta);
$content = stream_get_contents($file_pointer);
fclose($file_pointer);
return "$headers\r\n\r\n$content";
} | php | protected function _makeFOpenRequest($url)
{
$context = $this->_buildFOpenStreamContext();
$file_pointer = @fopen($url, 'r', null, $context);
if(!$file_pointer)
throw new Exception("There was an error making the request. Make sure that the url is valid, and either fopen or cURL are available.");
$meta = stream_get_meta_data($file_pointer);
$headers = $this->_buildResponseHeaderFromMeta($meta);
$content = stream_get_contents($file_pointer);
fclose($file_pointer);
return "$headers\r\n\r\n$content";
} | [
"protected",
"function",
"_makeFOpenRequest",
"(",
"$",
"url",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"_buildFOpenStreamContext",
"(",
")",
";",
"$",
"file_pointer",
"=",
"@",
"fopen",
"(",
"$",
"url",
",",
"'r'",
",",
"null",
",",
"$",
"con... | Given the object's current settings, make a request to the supplied url
using PHP's native, less speedy, fopen functions
@param string $url The url to make the request to
@return string The full HTTP response | [
"Given",
"the",
"object",
"s",
"current",
"settings",
"make",
"a",
"request",
"to",
"the",
"supplied",
"url",
"using",
"PHP",
"s",
"native",
"less",
"speedy",
"fopen",
"functions"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L416-L431 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._buildResponseHeaderFromMeta | protected function _buildResponseHeaderFromMeta($meta)
{
if(! array_key_exists('wrapper_data', $meta))
throw new Exception("Did not receive a valid response from the server");
$headers = $meta['wrapper_data'];
/**
* When using stream_context_create, if the socket is redirected via a
* 302, PHP just adds the 302 headers onto the wrapper_data array
* in addition to the headers from the redirected page. We only
* want the redirected page's headers.
*/
$last_status = 0;
for($i = 0; $i < count($headers); $i++)
{
if(strpos($headers[$i], 'HTTP/') === 0)
{
$last_status = $i;
}
}
# Get the applicable portion of the headers
$headers = array_slice($headers, $last_status);
return implode("\n", $headers);
} | php | protected function _buildResponseHeaderFromMeta($meta)
{
if(! array_key_exists('wrapper_data', $meta))
throw new Exception("Did not receive a valid response from the server");
$headers = $meta['wrapper_data'];
/**
* When using stream_context_create, if the socket is redirected via a
* 302, PHP just adds the 302 headers onto the wrapper_data array
* in addition to the headers from the redirected page. We only
* want the redirected page's headers.
*/
$last_status = 0;
for($i = 0; $i < count($headers); $i++)
{
if(strpos($headers[$i], 'HTTP/') === 0)
{
$last_status = $i;
}
}
# Get the applicable portion of the headers
$headers = array_slice($headers, $last_status);
return implode("\n", $headers);
} | [
"protected",
"function",
"_buildResponseHeaderFromMeta",
"(",
"$",
"meta",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'wrapper_data'",
",",
"$",
"meta",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Did not receive a valid response from the server\"",
")",
... | Given an associative array returned by PHP's methods to get stream meta,
extract the HTTP response header from it
@param array $meta The associative array contianing stream information
@return array | [
"Given",
"an",
"associative",
"array",
"returned",
"by",
"PHP",
"s",
"methods",
"to",
"get",
"stream",
"meta",
"extract",
"the",
"HTTP",
"response",
"header",
"from",
"it"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L439-L465 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._parseResponse | protected function _parseResponse()
{
/**
* According to the HTTP spec, we have to respect \n\n too
* @todo: Respect \n\n
*/
$break_1 = strpos($this->_rawResponse, "\r\n\r\n");
$break_2 = strpos($this->_rawResponse, "\n\n");
$break = 0;
if ($break_1 && $break_2 === FALSE) $break = $break_1;
elseif($break_2 && $break_1 === FALSE) $break = $break_2;
elseif($break_1 < $break_2) $break = $break_1;
else $break = $break_2;
# Let's check to see if we recieved a header but no body
if($break === FALSE)
{
if(strpos($this->_rawResponse, 'HTTP/') !== FALSE)
{
$break = strlen($this->_rawResponse);
}
else
{
throw new Exception("A valid response was not received from the host");
}
}
$header = substr($this->_rawResponse, 0, $break);
$this->_responseHeaders = $this->_parseResponseHeaders($header);
$this->_responseBody = substr($this->_rawResponse, $break + 3);
} | php | protected function _parseResponse()
{
/**
* According to the HTTP spec, we have to respect \n\n too
* @todo: Respect \n\n
*/
$break_1 = strpos($this->_rawResponse, "\r\n\r\n");
$break_2 = strpos($this->_rawResponse, "\n\n");
$break = 0;
if ($break_1 && $break_2 === FALSE) $break = $break_1;
elseif($break_2 && $break_1 === FALSE) $break = $break_2;
elseif($break_1 < $break_2) $break = $break_1;
else $break = $break_2;
# Let's check to see if we recieved a header but no body
if($break === FALSE)
{
if(strpos($this->_rawResponse, 'HTTP/') !== FALSE)
{
$break = strlen($this->_rawResponse);
}
else
{
throw new Exception("A valid response was not received from the host");
}
}
$header = substr($this->_rawResponse, 0, $break);
$this->_responseHeaders = $this->_parseResponseHeaders($header);
$this->_responseBody = substr($this->_rawResponse, $break + 3);
} | [
"protected",
"function",
"_parseResponse",
"(",
")",
"{",
"/**\r\n * According to the HTTP spec, we have to respect \\n\\n too\r\n * @todo: Respect \\n\\n\r\n */",
"$",
"break_1",
"=",
"strpos",
"(",
"$",
"this",
"->",
"_rawResponse",
",",
"\"\\r\\n\\r\\n\"... | Parse the headers and the body out of the raw response sent back by the
server. Store them in _responseHeaders and _responseBody.
@throws Exception When the server does not give us a valid response | [
"Parse",
"the",
"headers",
"and",
"the",
"body",
"out",
"of",
"the",
"raw",
"response",
"sent",
"back",
"by",
"the",
"server",
".",
"Store",
"them",
"in",
"_responseHeaders",
"and",
"_responseBody",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L501-L532 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._parseResponseHeaders | protected function _parseResponseHeaders($headers)
{
$headers = str_replace("\r", "", $headers);
$headers = explode("\n", $headers);
$parsed = array();
foreach($headers as $header)
{
$field_end = strpos($header, ':');
if($field_end === FALSE)
{
/* Cover the case where we're at the first header, the HTTP
* status header
*/
$field = 'status';
$value = $header;
}
else
{
$field = substr($header, 0, $field_end);
$value = substr($header, $field_end + 1);
}
$parsed[$field] = $value;
}
return $parsed;
} | php | protected function _parseResponseHeaders($headers)
{
$headers = str_replace("\r", "", $headers);
$headers = explode("\n", $headers);
$parsed = array();
foreach($headers as $header)
{
$field_end = strpos($header, ':');
if($field_end === FALSE)
{
/* Cover the case where we're at the first header, the HTTP
* status header
*/
$field = 'status';
$value = $header;
}
else
{
$field = substr($header, 0, $field_end);
$value = substr($header, $field_end + 1);
}
$parsed[$field] = $value;
}
return $parsed;
} | [
"protected",
"function",
"_parseResponseHeaders",
"(",
"$",
"headers",
")",
"{",
"$",
"headers",
"=",
"str_replace",
"(",
"\"\\r\"",
",",
"\"\"",
",",
"$",
"headers",
")",
";",
"$",
"headers",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"headers",
")",
";"... | Parse out the headers from the response and store them in a key-value
array and return it
@param string $headers A big chunk of text representing the HTTP headers
@return array A key-value array containing heder names and values | [
"Parse",
"out",
"the",
"headers",
"from",
"the",
"response",
"and",
"store",
"them",
"in",
"a",
"key",
"-",
"value",
"array",
"and",
"return",
"it"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L540-L568 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._generateProxyRequestHeaders | protected function _generateProxyRequestHeaders($as_string = FALSE)
{
$headers = array();
$headers[] = 'Content-Type: ' . $this->_requestContentType;
if ($this->_requestAuthorization) {
$headers[] = 'Authorization: ' . $this->_requestAuthorization;
}
if ($this->_requestAccept) {
$headers[] = 'Accept: ' . $this->_requestAccept;
}
if($as_string)
{
$data = "";
foreach($headers as $value)
if($value)
$data .= "$value\n";
$headers = $data;
}
return $headers;
} | php | protected function _generateProxyRequestHeaders($as_string = FALSE)
{
$headers = array();
$headers[] = 'Content-Type: ' . $this->_requestContentType;
if ($this->_requestAuthorization) {
$headers[] = 'Authorization: ' . $this->_requestAuthorization;
}
if ($this->_requestAccept) {
$headers[] = 'Accept: ' . $this->_requestAccept;
}
if($as_string)
{
$data = "";
foreach($headers as $value)
if($value)
$data .= "$value\n";
$headers = $data;
}
return $headers;
} | [
"protected",
"function",
"_generateProxyRequestHeaders",
"(",
"$",
"as_string",
"=",
"FALSE",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"headers",
"[",
"]",
"=",
"'Content-Type: '",
".",
"$",
"this",
"->",
"_requestContentType",
";",
"if",
... | Generate and return any headers needed to make the proxy request
@param bool $as_string Whether to return the headers as a string instead
of an associative array
@return array|string | [
"Generate",
"and",
"return",
"any",
"headers",
"needed",
"to",
"make",
"the",
"proxy",
"request"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L576-L600 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy._buildAndExecuteProxyResponse | protected function _buildAndExecuteProxyResponse()
{
if($this->_responseModifier)
{
$data = call_user_func_array($this->_responseModifier, array(&$this->_responseBody, &$this->_responseHeaders));
}
$this->_generateProxyResponseHeaders();
$this->_output($this->_responseBody);
} | php | protected function _buildAndExecuteProxyResponse()
{
if($this->_responseModifier)
{
$data = call_user_func_array($this->_responseModifier, array(&$this->_responseBody, &$this->_responseHeaders));
}
$this->_generateProxyResponseHeaders();
$this->_output($this->_responseBody);
} | [
"protected",
"function",
"_buildAndExecuteProxyResponse",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_responseModifier",
")",
"{",
"$",
"data",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"_responseModifier",
",",
"array",
"(",
"&",
"$",
"this",
... | Generate the headers and send the final response to the output stream | [
"Generate",
"the",
"headers",
"and",
"send",
"the",
"final",
"response",
"to",
"the",
"output",
"stream"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L639-L649 | train |
lanthaler/HydraConsole | proxylib.php | AjaxProxy.handleException | public function handleException(Exception $exception)
{
$this->_sendFatalError("Fatal proxy Exception: '"
. $exception->getMessage()
. "' in "
. $exception->getFile()
. ":"
. $exception->getLine());
} | php | public function handleException(Exception $exception)
{
$this->_sendFatalError("Fatal proxy Exception: '"
. $exception->getMessage()
. "' in "
. $exception->getFile()
. ":"
. $exception->getLine());
} | [
"public",
"function",
"handleException",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"_sendFatalError",
"(",
"\"Fatal proxy Exception: '\"",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
".",
"\"' in \"",
".",
"$",
"exception",
"->",
... | A callback method for PHP's set_exception_handler function. Used to
handle application-wide exceptions.
@param Exception $exception The exception being thrown | [
"A",
"callback",
"method",
"for",
"PHP",
"s",
"set_exception_handler",
"function",
".",
"Used",
"to",
"handle",
"application",
"-",
"wide",
"exceptions",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L690-L698 | train |
bobthecow/Faker | src/Faker/DateTime.php | DateTime.dateTimeFormat | public static function dateTimeFormat()
{
return self::pickOne(array(
DATE_ATOM,
DATE_COOKIE,
DATE_ISO8601,
DATE_RFC822,
DATE_RFC850,
DATE_RFC1036,
DATE_RFC1123,
DATE_RFC2822,
DATE_RSS,
DATE_W3C,
));
} | php | public static function dateTimeFormat()
{
return self::pickOne(array(
DATE_ATOM,
DATE_COOKIE,
DATE_ISO8601,
DATE_RFC822,
DATE_RFC850,
DATE_RFC1036,
DATE_RFC1123,
DATE_RFC2822,
DATE_RSS,
DATE_W3C,
));
} | [
"public",
"static",
"function",
"dateTimeFormat",
"(",
")",
"{",
"return",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"DATE_ATOM",
",",
"DATE_COOKIE",
",",
"DATE_ISO8601",
",",
"DATE_RFC822",
",",
"DATE_RFC850",
",",
"DATE_RFC1036",
",",
"DATE_RFC1123",
",",
... | Return a random date and time format.
@access public
@static
@return string Date and time format | [
"Return",
"a",
"random",
"date",
"and",
"time",
"format",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/DateTime.php#L129-L143 | train |
bobthecow/Faker | src/Faker/Address.php | Address.streetAddress | public static function streetAddress($includeSecondary = false)
{
$chunks = array(
self::pickOne(array('#####', '####', '###')),
self::streetName(),
);
if ($includeSecondary) {
$chunks[] = self::secondaryAddress();
}
return self::numerify(implode(' ', $chunks));
} | php | public static function streetAddress($includeSecondary = false)
{
$chunks = array(
self::pickOne(array('#####', '####', '###')),
self::streetName(),
);
if ($includeSecondary) {
$chunks[] = self::secondaryAddress();
}
return self::numerify(implode(' ', $chunks));
} | [
"public",
"static",
"function",
"streetAddress",
"(",
"$",
"includeSecondary",
"=",
"false",
")",
"{",
"$",
"chunks",
"=",
"array",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'#####'",
",",
"'####'",
",",
"'###'",
")",
")",
",",
"self",
"::",
"s... | Generate a random street address.
@access public
@static
@param bool $includeSecondary Include a secondary address, e.g. "Apt. 100"? (default: false)
@return string Street address | [
"Generate",
"a",
"random",
"street",
"address",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Address.php#L54-L66 | train |
bobthecow/Faker | src/Faker/Address.php | Address.city | public static function city()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s%4$s',
'%1$s %2$s',
'%2$s%4$s',
'%3$s%4$s',
)),
self::cityPrefix(),
Name::firstName(),
Name::lastName(),
self::citySuffix()
);
} | php | public static function city()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s%4$s',
'%1$s %2$s',
'%2$s%4$s',
'%3$s%4$s',
)),
self::cityPrefix(),
Name::firstName(),
Name::lastName(),
self::citySuffix()
);
} | [
"public",
"static",
"function",
"city",
"(",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'%1$s %2$s%4$s'",
",",
"'%1$s %2$s'",
",",
"'%2$s%4$s'",
",",
"'%3$s%4$s'",
",",
")",
")",
",",
"self",
"::",
"cityPrefix",
"(",
... | Generate a random city name.
@access public
@static
@return string City name | [
"Generate",
"a",
"random",
"city",
"name",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Address.php#L114-L128 | train |
bobthecow/Faker | src/Faker/Geo.php | Geo.point | public static function point(array $bounds = null)
{
if ($bounds === null) {
$bounds = static::bounds();
}
return array(
self::LAT => self::randFloat(self::latRange($bounds)),
self::LNG => self::randFloat(self::lngRange($bounds)),
);
} | php | public static function point(array $bounds = null)
{
if ($bounds === null) {
$bounds = static::bounds();
}
return array(
self::LAT => self::randFloat(self::latRange($bounds)),
self::LNG => self::randFloat(self::lngRange($bounds)),
);
} | [
"public",
"static",
"function",
"point",
"(",
"array",
"$",
"bounds",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"bounds",
"===",
"null",
")",
"{",
"$",
"bounds",
"=",
"static",
"::",
"bounds",
"(",
")",
";",
"}",
"return",
"array",
"(",
"self",
"::",
... | Generate random coordinates, as an array.
@access public
@static
@param array $bounds
@return array [$lat, $lng] | [
"Generate",
"random",
"coordinates",
"as",
"an",
"array",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Geo.php#L57-L67 | train |
bobthecow/Faker | src/Faker/Geo.php | Geo.pointDMS | public static function pointDMS(array $bounds = null)
{
list($lat, $lng) = static::point($bounds);
return sprintf('%s %s', self::floatToDMS($lat), self::floatToDMS($lng));
} | php | public static function pointDMS(array $bounds = null)
{
list($lat, $lng) = static::point($bounds);
return sprintf('%s %s', self::floatToDMS($lat), self::floatToDMS($lng));
} | [
"public",
"static",
"function",
"pointDMS",
"(",
"array",
"$",
"bounds",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"lat",
",",
"$",
"lng",
")",
"=",
"static",
"::",
"point",
"(",
"$",
"bounds",
")",
";",
"return",
"sprintf",
"(",
"'%s %s'",
",",
"se... | Generate random coordinates, formatted as degrees, minutes and seconds.
45°30'15" -90°30'15"
@access public
@static
@param array $bounds
@return string Formatted coordinates | [
"Generate",
"random",
"coordinates",
"formatted",
"as",
"degrees",
"minutes",
"and",
"seconds",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Geo.php#L79-L84 | train |
bobthecow/Faker | src/Faker/Internet.php | Internet.userName | public static function userName($name = null)
{
if ($name !== null) {
$email = preg_split('/\W+/', $name);
shuffle($email);
$email = implode(self::separator(), $email);
} else {
$email = sprintf(
self::pickOne(array(
'%s',
'%s%s%s'
)),
Name::firstName(),
self::separator(),
Name::lastName()
);
}
return strtolower(preg_replace('/\W/', '', $email));
} | php | public static function userName($name = null)
{
if ($name !== null) {
$email = preg_split('/\W+/', $name);
shuffle($email);
$email = implode(self::separator(), $email);
} else {
$email = sprintf(
self::pickOne(array(
'%s',
'%s%s%s'
)),
Name::firstName(),
self::separator(),
Name::lastName()
);
}
return strtolower(preg_replace('/\W/', '', $email));
} | [
"public",
"static",
"function",
"userName",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"$",
"email",
"=",
"preg_split",
"(",
"'/\\W+/'",
",",
"$",
"name",
")",
";",
"shuffle",
"(",
"$",
"email",
")",
... | Generate a random username.
Optionally, supply a user's name, from which the username will be generated.
@access public
@static
@param string $name (default: null)
@return string Username | [
"Generate",
"a",
"random",
"username",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Internet.php#L87-L106 | train |
bobthecow/Faker | src/Faker/Lorem.php | Lorem.sentences | public static function sentences($sentenceCount = 3)
{
$ret = array();
for ($i = 0; $i < $sentenceCount; $i++) {
$ret[] = self::sentence();
}
return $ret;
} | php | public static function sentences($sentenceCount = 3)
{
$ret = array();
for ($i = 0; $i < $sentenceCount; $i++) {
$ret[] = self::sentence();
}
return $ret;
} | [
"public",
"static",
"function",
"sentences",
"(",
"$",
"sentenceCount",
"=",
"3",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"sentenceCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
... | Generate random sentences.
@access public
@static
@param int $sentenceCount Number of sentences (default: 3)
@return array Sentences | [
"Generate",
"random",
"sentences",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Lorem.php#L99-L106 | train |
bobthecow/Faker | src/Faker/Lorem.php | Lorem.paragraphs | public static function paragraphs($paragraphCount = 3)
{
$ret = array();
for ($i = 0; $i < $paragraphCount; $i++) {
$ret[] = self::paragraph();
}
return $ret;
} | php | public static function paragraphs($paragraphCount = 3)
{
$ret = array();
for ($i = 0; $i < $paragraphCount; $i++) {
$ret[] = self::paragraph();
}
return $ret;
} | [
"public",
"static",
"function",
"paragraphs",
"(",
"$",
"paragraphCount",
"=",
"3",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"paragraphCount",
";",
"$",
"i",
"++",
")",
"{",
"$"... | Generate random paragraphs.
@access public
@static
@param int $paragraphCount Number of paragraphs (default: 3)
@return array Paragraphs | [
"Generate",
"random",
"paragraphs",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Lorem.php#L132-L139 | train |
bobthecow/Faker | src/Faker/Name.php | Name.name | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s %3$s',
'%2$s %3$s %4$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
)),
self::prefix(),
self::firstName(),
self::lastName(),
self::suffix()
);
} | php | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s %3$s',
'%2$s %3$s %4$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
)),
self::prefix(),
self::firstName(),
self::lastName(),
self::suffix()
);
} | [
"public",
"static",
"function",
"name",
"(",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'%1$s %2$s %3$s'",
",",
"'%2$s %3$s %4$s'",
",",
"'%2$s %3$s'",
",",
"'%2$s %3$s'",
",",
"'%2$s %3$s'",
",",
"'%2$s %3$s'",
",",
")",
... | Generate a random full name.
@access public
@static
@return string Full name | [
"Generate",
"a",
"random",
"full",
"name",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Name.php#L29-L45 | train |
bobthecow/Faker | src/Faker/Company.php | Company.name | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %4$s',
'%1$s-%2$s',
'%1$s, %2$s and %3$s'
)),
Name::lastName(),
Name::lastName(),
Name::lastName(),
self::suffix()
);
} | php | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %4$s',
'%1$s-%2$s',
'%1$s, %2$s and %3$s'
)),
Name::lastName(),
Name::lastName(),
Name::lastName(),
self::suffix()
);
} | [
"public",
"static",
"function",
"name",
"(",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'%1$s %4$s'",
",",
"'%1$s-%2$s'",
",",
"'%1$s, %2$s and %3$s'",
")",
")",
",",
"Name",
"::",
"lastName",
"(",
")",
",",
"Name",
... | Generate a fake company name.
@access public
@static
@return string Company name | [
"Generate",
"a",
"fake",
"company",
"name",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Company.php#L29-L42 | train |
ostark/craft-async-queue | src/ProcessPool.php | ProcessPool.canIUse | public function canIUse($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
return ($poolUsage < $this->maxItems) ? true : false;
} | php | public function canIUse($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
return ($poolUsage < $this->maxItems) ? true : false;
} | [
"public",
"function",
"canIUse",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"poolUsage",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"CACHE_KEY",
")",
"?",
":",
"0",
";",
"$",
"this",
"->",
"logPoolUsage",
"(",
"$",
"pool... | Check if there is room
@param mixed $context
@return bool | [
"Check",
"if",
"there",
"is",
"room"
] | ba6ef528473ab352e1fb5be23c1550f56570efc0 | https://github.com/ostark/craft-async-queue/blob/ba6ef528473ab352e1fb5be23c1550f56570efc0/src/ProcessPool.php#L55-L61 | train |
ostark/craft-async-queue | src/ProcessPool.php | ProcessPool.increment | public function increment($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
$this->cache->set(self::CACHE_KEY, $poolUsage + 1, $this->lifetime);
} | php | public function increment($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
$this->cache->set(self::CACHE_KEY, $poolUsage + 1, $this->lifetime);
} | [
"public",
"function",
"increment",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"poolUsage",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"CACHE_KEY",
")",
"?",
":",
"0",
";",
"$",
"this",
"->",
"logPoolUsage",
"(",
"$",
"po... | Add one item to pool
@param mixed $context | [
"Add",
"one",
"item",
"to",
"pool"
] | ba6ef528473ab352e1fb5be23c1550f56570efc0 | https://github.com/ostark/craft-async-queue/blob/ba6ef528473ab352e1fb5be23c1550f56570efc0/src/ProcessPool.php#L69-L74 | train |
ostark/craft-async-queue | src/ProcessPool.php | ProcessPool.decrement | public function decrement($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
if ($poolUsage > 1) {
$this->cache->set(self::CACHE_KEY, $poolUsage - 1, $this->lifetime);
} else {
$this->cache->delete(self::CACHE_KEY);
}
} | php | public function decrement($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
if ($poolUsage > 1) {
$this->cache->set(self::CACHE_KEY, $poolUsage - 1, $this->lifetime);
} else {
$this->cache->delete(self::CACHE_KEY);
}
} | [
"public",
"function",
"decrement",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"poolUsage",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"CACHE_KEY",
")",
"?",
":",
"0",
";",
"$",
"this",
"->",
"logPoolUsage",
"(",
"$",
"po... | Remove one item from pool
@param mixed $context | [
"Remove",
"one",
"item",
"from",
"pool"
] | ba6ef528473ab352e1fb5be23c1550f56570efc0 | https://github.com/ostark/craft-async-queue/blob/ba6ef528473ab352e1fb5be23c1550f56570efc0/src/ProcessPool.php#L81-L90 | train |
approached/laravel-image-optimizer | src/ImageOptimizer.php | ImageOptimizer.optimizeImage | public function optimizeImage($filepath)
{
$fileExtension = $this->extensions[mime_content_type($filepath)];
$transformHandler = config('imageoptimizer.transform_handler');
if (!isset($transformHandler[$fileExtension])) {
throw new \Exception('TransformHandler for file extension: "' . $fileExtension . '" was not found');
}
$this->get($transformHandler[$fileExtension])->optimize($filepath);
} | php | public function optimizeImage($filepath)
{
$fileExtension = $this->extensions[mime_content_type($filepath)];
$transformHandler = config('imageoptimizer.transform_handler');
if (!isset($transformHandler[$fileExtension])) {
throw new \Exception('TransformHandler for file extension: "' . $fileExtension . '" was not found');
}
$this->get($transformHandler[$fileExtension])->optimize($filepath);
} | [
"public",
"function",
"optimizeImage",
"(",
"$",
"filepath",
")",
"{",
"$",
"fileExtension",
"=",
"$",
"this",
"->",
"extensions",
"[",
"mime_content_type",
"(",
"$",
"filepath",
")",
"]",
";",
"$",
"transformHandler",
"=",
"config",
"(",
"'imageoptimizer.tran... | Opitimize a image.
@param $filepath
@throws \Exception | [
"Opitimize",
"a",
"image",
"."
] | 5e822ebe1c366c43a3cec484d45b37c8c56fb383 | https://github.com/approached/laravel-image-optimizer/blob/5e822ebe1c366c43a3cec484d45b37c8c56fb383/src/ImageOptimizer.php#L24-L35 | train |
approached/laravel-image-optimizer | src/ImageOptimizer.php | ImageOptimizer.getFileExtensionFromFilepath | private function getFileExtensionFromFilepath($filepath)
{
$fileExtension = pathinfo($filepath, PATHINFO_EXTENSION);
if (empty($fileExtension)) {
throw new \Exception('File extension not found');
}
return $fileExtension;
} | php | private function getFileExtensionFromFilepath($filepath)
{
$fileExtension = pathinfo($filepath, PATHINFO_EXTENSION);
if (empty($fileExtension)) {
throw new \Exception('File extension not found');
}
return $fileExtension;
} | [
"private",
"function",
"getFileExtensionFromFilepath",
"(",
"$",
"filepath",
")",
"{",
"$",
"fileExtension",
"=",
"pathinfo",
"(",
"$",
"filepath",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fileExtension",
")",
")",
"{",
"throw",
"n... | Get extension from a file.
@param $filepath
@throws \Exception
@return string | [
"Get",
"extension",
"from",
"a",
"file",
"."
] | 5e822ebe1c366c43a3cec484d45b37c8c56fb383 | https://github.com/approached/laravel-image-optimizer/blob/5e822ebe1c366c43a3cec484d45b37c8c56fb383/src/ImageOptimizer.php#L58-L67 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setCredentials | function setCredentials($xmlrpcEndPoint, $username, $password)
{
// prepend http protocol to the end point if needed
$scheme = parse_url($xmlrpcEndPoint, PHP_URL_SCHEME);
if (!$scheme) {
$xmlrpcEndPoint = "http://{$xmlrpcEndPoint}";
}
// swith to https when working with wordpress.com blogs
$host = parse_url($xmlrpcEndPoint, PHP_URL_HOST);
if (substr($host, -14) == '.wordpress.com') {
$xmlrpcEndPoint = preg_replace('|http://|', 'https://', $xmlrpcEndPoint, 1);
}
// save information
$this->endPoint = $xmlrpcEndPoint;
$this->username = $username;
$this->password = $password;
} | php | function setCredentials($xmlrpcEndPoint, $username, $password)
{
// prepend http protocol to the end point if needed
$scheme = parse_url($xmlrpcEndPoint, PHP_URL_SCHEME);
if (!$scheme) {
$xmlrpcEndPoint = "http://{$xmlrpcEndPoint}";
}
// swith to https when working with wordpress.com blogs
$host = parse_url($xmlrpcEndPoint, PHP_URL_HOST);
if (substr($host, -14) == '.wordpress.com') {
$xmlrpcEndPoint = preg_replace('|http://|', 'https://', $xmlrpcEndPoint, 1);
}
// save information
$this->endPoint = $xmlrpcEndPoint;
$this->username = $username;
$this->password = $password;
} | [
"function",
"setCredentials",
"(",
"$",
"xmlrpcEndPoint",
",",
"$",
"username",
",",
"$",
"password",
")",
"{",
"// prepend http protocol to the end point if needed",
"$",
"scheme",
"=",
"parse_url",
"(",
"$",
"xmlrpcEndPoint",
",",
"PHP_URL_SCHEME",
")",
";",
"if",... | Set the endpoint, username and password for next requests
@param string $xmlrpcEndPoint The wordpress XML-RPC endpoint
@param string $username The client's username
@param string $password The client's password
@since 2.4.0 | [
"Set",
"the",
"endpoint",
"username",
"and",
"password",
"for",
"next",
"requests"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L79-L97 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setUserAgent | function setUserAgent($userAgent)
{
if ($userAgent) {
$this->userAgent = $userAgent;
} else {
$this->userAgent = $this->getDefaultUserAgent();
}
} | php | function setUserAgent($userAgent)
{
if ($userAgent) {
$this->userAgent = $userAgent;
} else {
$this->userAgent = $this->getDefaultUserAgent();
}
} | [
"function",
"setUserAgent",
"(",
"$",
"userAgent",
")",
"{",
"if",
"(",
"$",
"userAgent",
")",
"{",
"$",
"this",
"->",
"userAgent",
"=",
"$",
"userAgent",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"userAgent",
"=",
"$",
"this",
"->",
"getDefaultUserAge... | Set the user agent for next requests
@param string $userAgent custom user agent, give a falsy value to use library user agent
@since 2.4.0 | [
"Set",
"the",
"user",
"agent",
"for",
"next",
"requests"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L145-L152 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setAuth | function setAuth($authConfig)
{
if ($authConfig === false || is_array($authConfig)) {
$this->authConfig = $authConfig;
} else {
throw new \InvalidArgumentException(__METHOD__ . " only accept boolean 'false' or an array as parameter.");
}
} | php | function setAuth($authConfig)
{
if ($authConfig === false || is_array($authConfig)) {
$this->authConfig = $authConfig;
} else {
throw new \InvalidArgumentException(__METHOD__ . " only accept boolean 'false' or an array as parameter.");
}
} | [
"function",
"setAuth",
"(",
"$",
"authConfig",
")",
"{",
"if",
"(",
"$",
"authConfig",
"===",
"false",
"||",
"is_array",
"(",
"$",
"authConfig",
")",
")",
"{",
"$",
"this",
"->",
"authConfig",
"=",
"$",
"authConfig",
";",
"}",
"else",
"{",
"throw",
"... | Set authentication info
@param boolean|array $authConfig the configuation array
<ul>
<li><code>auth_user</code>: the username for server authentication</li>
<li><code>auth_pass</code>: the password for server authentication</li>
<li><code>auth_mode</code>: value for CURLOPT_HTTPAUTH option (default to
CURLAUTH_BASIC)</li>
</ul>
@throws \InvalidArgumentException
@see curl_setopt
@since 2.2 | [
"Set",
"authentication",
"info"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L218-L225 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getPost | function getPost($postId, array $fields = array())
{
if (empty($fields)) {
$params = array(1, $this->username, $this->password, $postId);
} else {
$params = array(1, $this->username, $this->password, $postId, $fields);
}
return $this->sendRequest('wp.getPost', $params);
} | php | function getPost($postId, array $fields = array())
{
if (empty($fields)) {
$params = array(1, $this->username, $this->password, $postId);
} else {
$params = array(1, $this->username, $this->password, $postId, $fields);
}
return $this->sendRequest('wp.getPost', $params);
} | [
"function",
"getPost",
"(",
"$",
"postId",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$"... | Retrieve a post of any registered post type.
@param integer $postId the id of selected post
@param array $fields (optional) list of field or meta-field names to include in response.
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPosts | [
"Retrieve",
"a",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L247-L256 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.newPost | function newPost($title, $body, array $content = array())
{
$default = array(
'post_type' => 'post',
'post_status' => 'publish',
);
$content = array_merge($default, $content);
$content['post_title'] = $title;
$content['post_content'] = $body;
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.newPost', $params);
} | php | function newPost($title, $body, array $content = array())
{
$default = array(
'post_type' => 'post',
'post_status' => 'publish',
);
$content = array_merge($default, $content);
$content['post_title'] = $title;
$content['post_content'] = $body;
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.newPost', $params);
} | [
"function",
"newPost",
"(",
"$",
"title",
",",
"$",
"body",
",",
"array",
"$",
"content",
"=",
"array",
"(",
")",
")",
"{",
"$",
"default",
"=",
"array",
"(",
"'post_type'",
"=>",
"'post'",
",",
"'post_status'",
"=>",
"'publish'",
",",
")",
";",
"$",... | Create a new post of any registered post type.
@param string $title the post title
@param string $body the post body
@param array $categorieIds the list of category ids
@param integer $thumbnailId the thumbnail id
@param array $content the content array, see more at wordpress documentation
@return integer the new post id
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost | [
"Create",
"a",
"new",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L290-L303 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editPost | function editPost($postId, array $content)
{
$params = array(1, $this->username, $this->password, $postId, $content);
return $this->sendRequest('wp.editPost', $params);
} | php | function editPost($postId, array $content)
{
$params = array(1, $this->username, $this->password, $postId, $content);
return $this->sendRequest('wp.editPost', $params);
} | [
"function",
"editPost",
"(",
"$",
"postId",
",",
"array",
"$",
"content",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postId",
",",
"$",
"content",
")",
";",
... | Edit an existing post of any registered post type.
@param integer $postId the id of selected post
@param string $title the new title
@param string $body the new body
@param array $categorieIds the new list of category ids
@param integer $thumbnailId the new thumbnail id
@param array $content the advanced array
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.editPost | [
"Edit",
"an",
"existing",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L319-L324 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.deletePost | function deletePost($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.deletePost', $params);
} | php | function deletePost($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.deletePost', $params);
} | [
"function",
"deletePost",
"(",
"$",
"postId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'... | Delete an existing post of any registered post type.
@param integer $postId the id of selected post
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.deletePost | [
"Delete",
"an",
"existing",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L335-L340 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getPostType | function getPostType($postTypeName, array $fields = array())
{
$params = array(1, $this->username, $this->password, $postTypeName, $fields);
return $this->sendRequest('wp.getPostType', $params);
} | php | function getPostType($postTypeName, array $fields = array())
{
$params = array(1, $this->username, $this->password, $postTypeName, $fields);
return $this->sendRequest('wp.getPostType', $params);
} | [
"function",
"getPostType",
"(",
"$",
"postTypeName",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postTypeName... | Retrieve a registered post type.
@param string $postTypeName the post type name
@param array $fields (optional) list of field or meta-field names to include in response.
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostType | [
"Retrieve",
"a",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L352-L357 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getPostTypes | function getPostTypes(array $filter = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filter, $fields);
return $this->sendRequest('wp.getPostTypes', $params);
} | php | function getPostTypes(array $filter = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filter, $fields);
return $this->sendRequest('wp.getPostTypes', $params);
} | [
"function",
"getPostTypes",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"pa... | Retrieve list of registered post types.
@param array $filter
@param array $fields
@return array list of struct
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostTypes | [
"Retrieve",
"list",
"of",
"registered",
"post",
"types",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L369-L374 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getTaxonomy | function getTaxonomy($taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy);
return $this->sendRequest('wp.getTaxonomy', $params);
} | php | function getTaxonomy($taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy);
return $this->sendRequest('wp.getTaxonomy', $params);
} | [
"function",
"getTaxonomy",
"(",
"$",
"taxonomy",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",... | Retrieve information about a taxonomy.
@param string $taxonomy the name of the selected taxonomy
@return array taxonomy information
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTaxonomy | [
"Retrieve",
"information",
"about",
"a",
"taxonomy",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L413-L418 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getTerm | function getTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.getTerm', $params);
} | php | function getTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.getTerm', $params);
} | [
"function",
"getTerm",
"(",
"$",
"termId",
",",
"$",
"taxonomy",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
",",
"$",
"termId",
")",
";",
"return",
... | Retrieve a taxonomy term.
@param integer $termId
@param string $taxonomy
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerm | [
"Retrieve",
"a",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L444-L449 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getTerms | function getTerms($taxonomy, array $filter = array())
{
$params = array(1, $this->username, $this->password, $taxonomy, $filter);
return $this->sendRequest('wp.getTerms', $params);
} | php | function getTerms($taxonomy, array $filter = array())
{
$params = array(1, $this->username, $this->password, $taxonomy, $filter);
return $this->sendRequest('wp.getTerms', $params);
} | [
"function",
"getTerms",
"(",
"$",
"taxonomy",
",",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
",",
... | Retrieve list of terms in a taxonomy.
@param string $taxonomy
@param array $filter
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerms | [
"Retrieve",
"list",
"of",
"terms",
"in",
"a",
"taxonomy",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L461-L466 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.newTerm | function newTerm($name, $taxomony, $slug = null, $description = null, $parentId = null)
{
$content = array(
'name' => $name,
'taxonomy' => $taxomony,
);
if ($slug) {
$content['slug'] = $slug;
}
if ($description) {
$content['description'] = $description;
}
if ($parentId) {
$content['parent'] = $parentId;
}
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.newTerm', $params);
} | php | function newTerm($name, $taxomony, $slug = null, $description = null, $parentId = null)
{
$content = array(
'name' => $name,
'taxonomy' => $taxomony,
);
if ($slug) {
$content['slug'] = $slug;
}
if ($description) {
$content['description'] = $description;
}
if ($parentId) {
$content['parent'] = $parentId;
}
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.newTerm', $params);
} | [
"function",
"newTerm",
"(",
"$",
"name",
",",
"$",
"taxomony",
",",
"$",
"slug",
"=",
"null",
",",
"$",
"description",
"=",
"null",
",",
"$",
"parentId",
"=",
"null",
")",
"{",
"$",
"content",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
... | Create a new taxonomy term.
@param string $name
@param string $taxomony
@param string $slug
@param string $description
@param integer $parentId
@return integer new term id
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.newTerm | [
"Create",
"a",
"new",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L481-L499 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editTerm | function editTerm($termId, $taxonomy, array $content = array())
{
$content['taxonomy'] = $taxonomy;
$params = array(1, $this->username, $this->password, $termId, $content);
return $this->sendRequest('wp.editTerm', $params);
} | php | function editTerm($termId, $taxonomy, array $content = array())
{
$content['taxonomy'] = $taxonomy;
$params = array(1, $this->username, $this->password, $termId, $content);
return $this->sendRequest('wp.editTerm', $params);
} | [
"function",
"editTerm",
"(",
"$",
"termId",
",",
"$",
"taxonomy",
",",
"array",
"$",
"content",
"=",
"array",
"(",
")",
")",
"{",
"$",
"content",
"[",
"'taxonomy'",
"]",
"=",
"$",
"taxonomy",
";",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
... | Edit an existing taxonomy term.
@param integer $termId
@param string $taxonomy
@param array $content
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.editTerm | [
"Edit",
"an",
"existing",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L512-L518 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.deleteTerm | function deleteTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.deleteTerm', $params);
} | php | function deleteTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.deleteTerm', $params);
} | [
"function",
"deleteTerm",
"(",
"$",
"termId",
",",
"$",
"taxonomy",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
",",
"$",
"termId",
")",
";",
"return... | Delete an existing taxonomy term.
@param integer $termId
@param string $taxonomy
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.deleteTerm | [
"Delete",
"an",
"existing",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L530-L535 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getMediaLibrary | function getMediaLibrary(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getMediaLibrary', $params);
} | php | function getMediaLibrary(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getMediaLibrary', $params);
} | [
"function",
"getMediaLibrary",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"filter",
")",
";",
"return",
"$"... | Retrieve list of media items.
@param array $filter
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.getMediaLibrary | [
"Retrieve",
"list",
"of",
"media",
"items",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L562-L567 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getCommentCount | function getCommentCount($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.getCommentCount', $params);
} | php | function getCommentCount($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.getCommentCount', $params);
} | [
"function",
"getCommentCount",
"(",
"$",
"postId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",... | Retrieve comment count for a specific post.
@param integer $postId
@return integer
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getCommentCount | [
"Retrieve",
"comment",
"count",
"for",
"a",
"specific",
"post",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L610-L615 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getComment | function getComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.getComment', $params);
} | php | function getComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.getComment', $params);
} | [
"function",
"getComment",
"(",
"$",
"commentId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"commentId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"("... | Retrieve a comment.
@param integer $commentId
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComment | [
"Retrieve",
"a",
"comment",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L626-L631 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getComments | function getComments(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getComments', $params);
} | php | function getComments(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getComments', $params);
} | [
"function",
"getComments",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"filter",
")",
";",
"return",
"$",
... | Retrieve list of comments.
@param array $filter
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComments | [
"Retrieve",
"list",
"of",
"comments",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L642-L647 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editComment | function editComment($commentId, array $comment)
{
$params = array(1, $this->username, $this->password, $commentId, $comment);
return $this->sendRequest('wp.editComment', $params);
} | php | function editComment($commentId, array $comment)
{
$params = array(1, $this->username, $this->password, $commentId, $comment);
return $this->sendRequest('wp.editComment', $params);
} | [
"function",
"editComment",
"(",
"$",
"commentId",
",",
"array",
"$",
"comment",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"commentId",
",",
"$",
"comment",
")",
... | Edit an existing comment.
@param integer $commentId
@param array $comment
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.editComment | [
"Edit",
"an",
"existing",
"comment",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L676-L681 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.deleteComment | function deleteComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.deleteComment', $params);
} | php | function deleteComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.deleteComment', $params);
} | [
"function",
"deleteComment",
"(",
"$",
"commentId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"commentId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
... | Remove an existing comment.
@param integer $commentId
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.deleteComment | [
"Remove",
"an",
"existing",
"comment",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L692-L697 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getOptions | function getOptions(array $options = array())
{
if (empty($options)) {
$params = array(1, $this->username, $this->password);
} else {
$params = array(1, $this->username, $this->password, $options);
}
return $this->sendRequest('wp.getOptions', $params);
} | php | function getOptions(array $options = array())
{
if (empty($options)) {
$params = array(1, $this->username, $this->password);
} else {
$params = array(1, $this->username, $this->password, $options);
}
return $this->sendRequest('wp.getOptions', $params);
} | [
"function",
"getOptions",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
... | Retrieve blog options.
@param array $options
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.getOptions | [
"Retrieve",
"blog",
"options",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L722-L731 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setOptions | function setOptions(array $options)
{
$params = array(1, $this->username, $this->password, $options);
return $this->sendRequest('wp.setOptions', $params);
} | php | function setOptions(array $options)
{
$params = array(1, $this->username, $this->password, $options);
return $this->sendRequest('wp.setOptions', $params);
} | [
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest"... | Edit blog options.
@param array $options
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.setOptions | [
"Edit",
"blog",
"options",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L742-L747 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getUser | function getUser($userId, array $fields = array())
{
$params = array(1, $this->username, $this->password, $userId);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUser', $params);
} | php | function getUser($userId, array $fields = array())
{
$params = array(1, $this->username, $this->password, $userId);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUser', $params);
} | [
"function",
"getUser",
"(",
"$",
"userId",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"userId",
")",
";",... | Retrieve a user.
@param integer $userId
@param array $fields Optional. List of field or meta-field names to include in response.
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUser | [
"Retrieve",
"a",
"user",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L773-L781 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getUsers | function getUsers(array $filters = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filters);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUsers', $params);
} | php | function getUsers(array $filters = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filters);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUsers', $params);
} | [
"function",
"getUsers",
"(",
"array",
"$",
"filters",
"=",
"array",
"(",
")",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"passw... | Retrieve list of users.
@param array $filters
@param array $fields
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUsers | [
"Retrieve",
"list",
"of",
"users",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L793-L801 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getProfile | function getProfile(array $fields = array())
{
$params = array(1, $this->username, $this->password);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getProfile', $params);
} | php | function getProfile(array $fields = array())
{
$params = array(1, $this->username, $this->password);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getProfile', $params);
} | [
"function",
"getProfile",
"(",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
... | Retrieve profile of the requesting user.
@param array $fields
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getProfile | [
"Retrieve",
"profile",
"of",
"the",
"requesting",
"user",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L812-L820 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editProfile | function editProfile(array $content)
{
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.editProfile', $params);
} | php | function editProfile(array $content)
{
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.editProfile', $params);
} | [
"function",
"editProfile",
"(",
"array",
"$",
"content",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"content",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest... | Edit profile of the requesting user.
@param array $content
@return boolean
http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.editProfile | [
"Edit",
"profile",
"of",
"the",
"requesting",
"user",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L831-L836 | train |
letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setXmlrpcType | private function setXmlrpcType(&$array)
{
foreach ($array as $key => $element) {
if (is_a($element, '\DateTime')) {
$array[$key] = $element->format("Ymd\TH:i:sO");
xmlrpc_set_type($array[$key], 'datetime');
} elseif (is_array($element)) {
$this->setXmlrpcType($array[$key]);
}
}
} | php | private function setXmlrpcType(&$array)
{
foreach ($array as $key => $element) {
if (is_a($element, '\DateTime')) {
$array[$key] = $element->format("Ymd\TH:i:sO");
xmlrpc_set_type($array[$key], 'datetime');
} elseif (is_array($element)) {
$this->setXmlrpcType($array[$key]);
}
}
} | [
"private",
"function",
"setXmlrpcType",
"(",
"&",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"element",
",",
"'\\DateTime'",
")",
")",
"{",
"$",
"array",
"[",... | Set the correct type for each element in an array
@param array $array
@since 2.2 | [
"Set",
"the",
"correct",
"type",
"for",
"each",
"element",
"in",
"an",
"array"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L938-L948 | train |
TopShelfCraft/SuperSort | src/SuperSort.php | SuperSort.init | public function init()
{
parent::init();
self::$plugin = $this;
Craft::$app->getView()->registerTwigExtension(new SuperSortTwigExtension());
} | php | public function init()
{
parent::init();
self::$plugin = $this;
Craft::$app->getView()->registerTwigExtension(new SuperSortTwigExtension());
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"self",
"::",
"$",
"plugin",
"=",
"$",
"this",
";",
"Craft",
"::",
"$",
"app",
"->",
"getView",
"(",
")",
"->",
"registerTwigExtension",
"(",
"new",
"SuperSortTwigExten... | Initializes the plugin, sets its static self-reference, and registers the Twig extension. | [
"Initializes",
"the",
"plugin",
"sets",
"its",
"static",
"self",
"-",
"reference",
"and",
"registers",
"the",
"Twig",
"extension",
"."
] | 8e3e23e30b49a9fbb285e6b2dd0b458de74e340d | https://github.com/TopShelfCraft/SuperSort/blob/8e3e23e30b49a9fbb285e6b2dd0b458de74e340d/src/SuperSort.php#L46-L54 | train |
hail-framework/framework | src/Util/Utf8String.php | Utf8String.pad | public function pad(int $length, string $piece = ' ', int $side = STR_PAD_RIGHT)
{
if ($side === STR_PAD_BOTH) {
$length -= $this->count();
if ($length <= 0) {
return $this;
}
$left = (int) ($length / 2);
$right = $length - $left;
$this->_string = Strings::padRight(
Strings::padLeft($this->_string, $left, $piece),
$right, $piece
);
} elseif (STR_PAD_LEFT === $side) {
$this->_string = Strings::padLeft($this->_string, $length, $piece);
} else {
$this->_string = Strings::padRight($this->_string, $length, $piece);
}
return $this;
} | php | public function pad(int $length, string $piece = ' ', int $side = STR_PAD_RIGHT)
{
if ($side === STR_PAD_BOTH) {
$length -= $this->count();
if ($length <= 0) {
return $this;
}
$left = (int) ($length / 2);
$right = $length - $left;
$this->_string = Strings::padRight(
Strings::padLeft($this->_string, $left, $piece),
$right, $piece
);
} elseif (STR_PAD_LEFT === $side) {
$this->_string = Strings::padLeft($this->_string, $length, $piece);
} else {
$this->_string = Strings::padRight($this->_string, $length, $piece);
}
return $this;
} | [
"public",
"function",
"pad",
"(",
"int",
"$",
"length",
",",
"string",
"$",
"piece",
"=",
"' '",
",",
"int",
"$",
"side",
"=",
"STR_PAD_RIGHT",
")",
"{",
"if",
"(",
"$",
"side",
"===",
"STR_PAD_BOTH",
")",
"{",
"$",
"length",
"-=",
"$",
"this",
"->... | Pad the current string to a certain length with another piece, aka piece.
@param int $length Length.
@param string $piece Piece.
@param int $side Whether we append at the end or the beginning
of the current string.
@return self | [
"Pad",
"the",
"current",
"string",
"to",
"a",
"certain",
"length",
"with",
"another",
"piece",
"aka",
"piece",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L223-L246 | train |
hail-framework/framework | src/Util/Utf8String.php | Utf8String.toAscii | public function toAscii()
{
if (0 === \preg_match('#[\x80-\xff]#', $this->_string)) {
return $this;
}
$this->_string = Strings::toAscii($this->_string);
return $this;
} | php | public function toAscii()
{
if (0 === \preg_match('#[\x80-\xff]#', $this->_string)) {
return $this;
}
$this->_string = Strings::toAscii($this->_string);
return $this;
} | [
"public",
"function",
"toAscii",
"(",
")",
"{",
"if",
"(",
"0",
"===",
"\\",
"preg_match",
"(",
"'#[\\x80-\\xff]#'",
",",
"$",
"this",
"->",
"_string",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"_string",
"=",
"Strings",
"::"... | Transform a UTF-8 string into an ASCII one.
@return self
@throws \Exception | [
"Transform",
"a",
"UTF",
"-",
"8",
"string",
"into",
"an",
"ASCII",
"one",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L425-L434 | train |
hail-framework/framework | src/Util/Utf8String.php | Utf8String.offsetSet | public function offsetSet($offset, $value)
{
$head = null;
$offset = $this->computeOffset($offset);
if (0 < $offset) {
$head = \mb_substr($this->_string, 0, $offset);
}
$tail = \mb_substr($this->_string, $offset + 1);
$this->_string = $head . $value . $tail;
$this->_direction = null;
return $this;
} | php | public function offsetSet($offset, $value)
{
$head = null;
$offset = $this->computeOffset($offset);
if (0 < $offset) {
$head = \mb_substr($this->_string, 0, $offset);
}
$tail = \mb_substr($this->_string, $offset + 1);
$this->_string = $head . $value . $tail;
$this->_direction = null;
return $this;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"$",
"head",
"=",
"null",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"computeOffset",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"0",
"<",
"$",
"offset",
")",
"{",... | Set a specific character of the current string.
@param int $offset Offset (can be negative and unbound).
@param string $value Value.
@return self | [
"Set",
"a",
"specific",
"character",
"of",
"the",
"current",
"string",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L534-L548 | train |
hail-framework/framework | src/Util/Utf8String.php | Utf8String.offsetExists | public function offsetExists($offset)
{
if (!\is_int($offset)) {
return false;
}
$len = $this->count();
return $offset >= -$len && $offset < $len;
} | php | public function offsetExists($offset)
{
if (!\is_int($offset)) {
return false;
}
$len = $this->count();
return $offset >= -$len && $offset < $len;
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"\\",
"is_int",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"len",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"return",
"$",
"offset... | Check if a specific offset exists.
@return bool | [
"Check",
"if",
"a",
"specific",
"offset",
"exists",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L567-L576 | train |
hail-framework/framework | src/Util/Utf8String.php | Utf8String.reduce | public function reduce($start, $length = null)
{
$this->_string = \mb_substr($this->_string, $start, $length);
return $this;
} | php | public function reduce($start, $length = null)
{
$this->_string = \mb_substr($this->_string, $start, $length);
return $this;
} | [
"public",
"function",
"reduce",
"(",
"$",
"start",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_string",
"=",
"\\",
"mb_substr",
"(",
"$",
"this",
"->",
"_string",
",",
"$",
"start",
",",
"$",
"length",
")",
";",
"return",
"$",
... | Reduce the strings.
@param int $start Position of first character.
@param int $length Maximum number of characters.
@return self | [
"Reduce",
"the",
"strings",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L586-L591 | train |
hail-framework/framework | src/Template/Processor/Processor.php | Processor.before | protected static function before(Element $element, string $phpExpression): void
{
$element->insertBeforeSelf(
static::toPhp($phpExpression)
);
} | php | protected static function before(Element $element, string $phpExpression): void
{
$element->insertBeforeSelf(
static::toPhp($phpExpression)
);
} | [
"protected",
"static",
"function",
"before",
"(",
"Element",
"$",
"element",
",",
"string",
"$",
"phpExpression",
")",
":",
"void",
"{",
"$",
"element",
"->",
"insertBeforeSelf",
"(",
"static",
"::",
"toPhp",
"(",
"$",
"phpExpression",
")",
")",
";",
"}"
] | insert a php code before an element.
@param Element $element
@param string $phpExpression | [
"insert",
"a",
"php",
"code",
"before",
"an",
"element",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Template/Processor/Processor.php#L30-L35 | train |
hail-framework/framework | src/Template/Processor/Processor.php | Processor.after | protected static function after(Element $element, string $phpExpression): void
{
$element->insertAfterSelf(
static::toPhp($phpExpression)
);
} | php | protected static function after(Element $element, string $phpExpression): void
{
$element->insertAfterSelf(
static::toPhp($phpExpression)
);
} | [
"protected",
"static",
"function",
"after",
"(",
"Element",
"$",
"element",
",",
"string",
"$",
"phpExpression",
")",
":",
"void",
"{",
"$",
"element",
"->",
"insertAfterSelf",
"(",
"static",
"::",
"toPhp",
"(",
"$",
"phpExpression",
")",
")",
";",
"}"
] | insert a php code after an element.
@param Element $element
@param string $phpExpression | [
"insert",
"a",
"php",
"code",
"after",
"an",
"element",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Template/Processor/Processor.php#L43-L48 | train |
hail-framework/framework | src/Template/Processor/Processor.php | Processor.text | protected static function text(Element $element, string $phpExpression): void
{
$element->removeChildren();
if ($phpExpression) {
$element->appendChild(
static::toPhp($phpExpression)
);
}
} | php | protected static function text(Element $element, string $phpExpression): void
{
$element->removeChildren();
if ($phpExpression) {
$element->appendChild(
static::toPhp($phpExpression)
);
}
} | [
"protected",
"static",
"function",
"text",
"(",
"Element",
"$",
"element",
",",
"string",
"$",
"phpExpression",
")",
":",
"void",
"{",
"$",
"element",
"->",
"removeChildren",
"(",
")",
";",
"if",
"(",
"$",
"phpExpression",
")",
"{",
"$",
"element",
"->",... | set inner text of the an element.
@param Element $element
@param string $phpExpression | [
"set",
"inner",
"text",
"of",
"the",
"an",
"element",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Template/Processor/Processor.php#L56-L65 | train |
htmlburger/wpemerge-cli | src/CarbonFields/Carbon_Rich_Text_Widget.php | Carbon_Rich_Text_Widget.front_end | public function front_end( $args, $instance ) {
if ( $instance['title'] ) {
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
echo $args['before_title'] . $title . $args['after_title'];
}
echo apply_filters( 'the_content', $instance['content'] );
} | php | public function front_end( $args, $instance ) {
if ( $instance['title'] ) {
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
echo $args['before_title'] . $title . $args['after_title'];
}
echo apply_filters( 'the_content', $instance['content'] );
} | [
"public",
"function",
"front_end",
"(",
"$",
"args",
",",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"instance",
"[",
"'title'",
"]",
")",
"{",
"$",
"title",
"=",
"apply_filters",
"(",
"'widget_title'",
",",
"$",
"instance",
"[",
"'title'",
"]",
",",
... | Renders the widget front-end.
@param array $args Widgets arguments.
@param array $instance Instance values.
@return void | [
"Renders",
"the",
"widget",
"front",
"-",
"end",
"."
] | 075f1982b7dd87039a4e7bbc05caf676a10fe862 | https://github.com/htmlburger/wpemerge-cli/blob/075f1982b7dd87039a4e7bbc05caf676a10fe862/src/CarbonFields/Carbon_Rich_Text_Widget.php#L34-L42 | train |
hail-framework/framework | src/Util/Yaml/Dumper.php | Dumper.requiresSingleQuoting | private static function requiresSingleQuoting(string $value): bool
{
// Determines if a PHP value is entirely composed of a value that would
// require single quoting in YAML.
if (\in_array(\strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'], true)) {
return true;
}
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return \preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
} | php | private static function requiresSingleQuoting(string $value): bool
{
// Determines if a PHP value is entirely composed of a value that would
// require single quoting in YAML.
if (\in_array(\strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'], true)) {
return true;
}
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return \preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
} | [
"private",
"static",
"function",
"requiresSingleQuoting",
"(",
"string",
"$",
"value",
")",
":",
"bool",
"{",
"// Determines if a PHP value is entirely composed of a value that would",
"// require single quoting in YAML.",
"if",
"(",
"\\",
"in_array",
"(",
"\\",
"strtolower",... | Determines if a PHP value would require single quoting in YAML.
@param string $value A PHP value
@return bool True if the value would require single quotes | [
"Determines",
"if",
"a",
"PHP",
"value",
"would",
"require",
"single",
"quoting",
"in",
"YAML",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Yaml/Dumper.php#L267-L278 | train |
Becklyn/RadBundle | src/Path/PathHelper.php | PathHelper.join | public static function join (...$paths) : string
{
$normalized = [];
foreach ($paths as $index => $path)
{
if (0 !== $index)
{
$path = \ltrim($path, "/");
}
if ($index !== \count($paths) - 1)
{
$path = \rtrim($path, "/");
}
$normalized[] = $path;
}
return \implode("/", $normalized);
} | php | public static function join (...$paths) : string
{
$normalized = [];
foreach ($paths as $index => $path)
{
if (0 !== $index)
{
$path = \ltrim($path, "/");
}
if ($index !== \count($paths) - 1)
{
$path = \rtrim($path, "/");
}
$normalized[] = $path;
}
return \implode("/", $normalized);
} | [
"public",
"static",
"function",
"join",
"(",
"...",
"$",
"paths",
")",
":",
"string",
"{",
"$",
"normalized",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"index",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"0",
"!==",
"$",
"index",
... | Joins path segments to one full path.
@param string[] ...$paths
@return string | [
"Joins",
"path",
"segments",
"to",
"one",
"full",
"path",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Path/PathHelper.php#L17-L37 | train |
Kuestenschmiede/TrackingBundle | Resources/contao/dca/tl_c4g_tracking_pois.php | tl_c4g_tracking_pois.getTypes | public function getTypes()
{
$groups = array();
foreach ($GLOBALS['FE_MOD'] as $k=>$v)
{
foreach (array_keys($v) as $kk)
{
$groups[$k][] = $kk;
}
}
return $groups;
} | php | public function getTypes()
{
$groups = array();
foreach ($GLOBALS['FE_MOD'] as $k=>$v)
{
foreach (array_keys($v) as $kk)
{
$groups[$k][] = $kk;
}
}
return $groups;
} | [
"public",
"function",
"getTypes",
"(",
")",
"{",
"$",
"groups",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'FE_MOD'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"v",
")",
"as",
... | Return all front end modules as array
@return array | [
"Return",
"all",
"front",
"end",
"modules",
"as",
"array"
] | 7ad1b8ef3103854dfce8309d2eed7060febaa4ee | https://github.com/Kuestenschmiede/TrackingBundle/blob/7ad1b8ef3103854dfce8309d2eed7060febaa4ee/Resources/contao/dca/tl_c4g_tracking_pois.php#L260-L273 | train |
TheBnl/silverstripe-pageslices | src/controller/PageSliceController.php | PageSliceController.getCacheKey | public function getCacheKey()
{
$cacheKey = implode('_', array(
$this->ID,
strtotime($this->LastEdited),
strtotime($this->Parent()->LastEdited),
Versioned::get_reading_mode()
));
$this->extend('updateCacheKey', $cacheKey);
return $cacheKey;
} | php | public function getCacheKey()
{
$cacheKey = implode('_', array(
$this->ID,
strtotime($this->LastEdited),
strtotime($this->Parent()->LastEdited),
Versioned::get_reading_mode()
));
$this->extend('updateCacheKey', $cacheKey);
return $cacheKey;
} | [
"public",
"function",
"getCacheKey",
"(",
")",
"{",
"$",
"cacheKey",
"=",
"implode",
"(",
"'_'",
",",
"array",
"(",
"$",
"this",
"->",
"ID",
",",
"strtotime",
"(",
"$",
"this",
"->",
"LastEdited",
")",
",",
"strtotime",
"(",
"$",
"this",
"->",
"Paren... | The Cache key with basis properties
Extend this on your subclass for more specific properties
@return string | [
"The",
"Cache",
"key",
"with",
"basis",
"properties",
"Extend",
"this",
"on",
"your",
"subclass",
"for",
"more",
"specific",
"properties"
] | 5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b | https://github.com/TheBnl/silverstripe-pageslices/blob/5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b/src/controller/PageSliceController.php#L118-L128 | train |
TheBnl/silverstripe-pageslices | src/controller/PageSliceController.php | PageSliceController.getTemplate | public function getTemplate()
{
if (!$this->useCaching()) {
$result = $this->renderTemplate();
} else {
$cache = Injector::inst()->get(CacheInterface::class . '.PageSlices');
if (!$cache->has($this->getCacheKey())) {
$result = $this->renderTemplate();
$cache->set($this->getCacheKey(), $result);
} else {
$result = $cache->get($this->getCacheKey());
}
}
return $result;
} | php | public function getTemplate()
{
if (!$this->useCaching()) {
$result = $this->renderTemplate();
} else {
$cache = Injector::inst()->get(CacheInterface::class . '.PageSlices');
if (!$cache->has($this->getCacheKey())) {
$result = $this->renderTemplate();
$cache->set($this->getCacheKey(), $result);
} else {
$result = $cache->get($this->getCacheKey());
}
}
return $result;
} | [
"public",
"function",
"getTemplate",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"useCaching",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"renderTemplate",
"(",
")",
";",
"}",
"else",
"{",
"$",
"cache",
"=",
"Injector",
"::",
... | Return the rendered template
@return \HTMLText | [
"Return",
"the",
"rendered",
"template"
] | 5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b | https://github.com/TheBnl/silverstripe-pageslices/blob/5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b/src/controller/PageSliceController.php#L135-L150 | train |
hiqdev/hipanel-module-server | src/models/traits/AssignSwitchTrait.php | AssignSwitchTrait.generateUniqueValidators | protected function generateUniqueValidators(): array
{
if (empty($this->switchVariants)) {
throw new InvalidConfigException('Please specify `switchVariants` array to use AssignSwitchTrait::generateUniqueValidators()');
}
$rules = [];
foreach ($this->switchVariants as $variant) {
$rules[] = [
[$variant . '_port'],
function ($attribute, $params, $validator) use ($variant) {
if ($this->{$attribute} && $this->{$variant . '_id'}) {
$query = Binding::find();
$query->andWhere(['port' => $this->{$attribute}]);
$query->andWhere(['switch_id' => $this->{$variant . '_id'}]);
$query->andWhere(['ne', 'base_device_id', $this->id]);
/** @var Binding[] $bindings */
$bindings = $query->all();
if (!empty($bindings)) {
$binding = reset($bindings);
$this->addError($attribute, Yii::t('hipanel:server', '{switch}::{port} already taken by {device}', [
'switch' => $binding->switch_name,
'port' => $binding->port,
'device' => $binding->device_name,
]));
}
}
},
];
}
return $rules;
} | php | protected function generateUniqueValidators(): array
{
if (empty($this->switchVariants)) {
throw new InvalidConfigException('Please specify `switchVariants` array to use AssignSwitchTrait::generateUniqueValidators()');
}
$rules = [];
foreach ($this->switchVariants as $variant) {
$rules[] = [
[$variant . '_port'],
function ($attribute, $params, $validator) use ($variant) {
if ($this->{$attribute} && $this->{$variant . '_id'}) {
$query = Binding::find();
$query->andWhere(['port' => $this->{$attribute}]);
$query->andWhere(['switch_id' => $this->{$variant . '_id'}]);
$query->andWhere(['ne', 'base_device_id', $this->id]);
/** @var Binding[] $bindings */
$bindings = $query->all();
if (!empty($bindings)) {
$binding = reset($bindings);
$this->addError($attribute, Yii::t('hipanel:server', '{switch}::{port} already taken by {device}', [
'switch' => $binding->switch_name,
'port' => $binding->port,
'device' => $binding->device_name,
]));
}
}
},
];
}
return $rules;
} | [
"protected",
"function",
"generateUniqueValidators",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"switchVariants",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Please specify `switchVariants` array to use AssignSwitchTrait... | Added to model's rules list of switch pairs.
@throws InvalidConfigException
@return array | [
"Added",
"to",
"model",
"s",
"rules",
"list",
"of",
"switch",
"pairs",
"."
] | e40c3601952cf1fd420ebb97093ee17a33ff3207 | https://github.com/hiqdev/hipanel-module-server/blob/e40c3601952cf1fd420ebb97093ee17a33ff3207/src/models/traits/AssignSwitchTrait.php#L90-L122 | train |
DoSomething/gateway | src/Resources/NorthstarUser.php | NorthstarUser.displayName | public function displayName()
{
if (! empty($this->first_name) && ! empty($this->last_name)) {
return $this->first_name.' '.$this->last_name;
}
if (! empty($this->first_name) && ! empty($this->last_initial)) {
return $this->first_name.' '.$this->last_initial.'.';
}
return $this->id;
} | php | public function displayName()
{
if (! empty($this->first_name) && ! empty($this->last_name)) {
return $this->first_name.' '.$this->last_name;
}
if (! empty($this->first_name) && ! empty($this->last_initial)) {
return $this->first_name.' '.$this->last_initial.'.';
}
return $this->id;
} | [
"public",
"function",
"displayName",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"first_name",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"last_name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"first_name",
".",
"' '",
"... | Get the user's display name.
@return mixed|string | [
"Get",
"the",
"user",
"s",
"display",
"name",
"."
] | 89c1c59c6af038dff790df6d5aaa9fc703246568 | https://github.com/DoSomething/gateway/blob/89c1c59c6af038dff790df6d5aaa9fc703246568/src/Resources/NorthstarUser.php#L25-L36 | train |
DoSomething/gateway | src/Resources/NorthstarUser.php | NorthstarUser.prettyMobile | public function prettyMobile($fallback = '')
{
if (! isset($this->mobile)) {
return $fallback;
}
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$formattedNumber = $phoneUtil->parse($this->mobile, 'US');
return $phoneUtil->format($formattedNumber, PhoneNumberFormat::INTERNATIONAL);
} catch (\libphonenumber\NumberParseException $e) {
return $this->number;
}
} | php | public function prettyMobile($fallback = '')
{
if (! isset($this->mobile)) {
return $fallback;
}
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$formattedNumber = $phoneUtil->parse($this->mobile, 'US');
return $phoneUtil->format($formattedNumber, PhoneNumberFormat::INTERNATIONAL);
} catch (\libphonenumber\NumberParseException $e) {
return $this->number;
}
} | [
"public",
"function",
"prettyMobile",
"(",
"$",
"fallback",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mobile",
")",
")",
"{",
"return",
"$",
"fallback",
";",
"}",
"$",
"phoneUtil",
"=",
"PhoneNumberUtil",
"::",
"getInstance... | Get the user's formatted mobile number.
@param string $fallback - Text to display if no mobile is set
@return mixed|string | [
"Get",
"the",
"user",
"s",
"formatted",
"mobile",
"number",
"."
] | 89c1c59c6af038dff790df6d5aaa9fc703246568 | https://github.com/DoSomething/gateway/blob/89c1c59c6af038dff790df6d5aaa9fc703246568/src/Resources/NorthstarUser.php#L44-L58 | train |
mirko-pagliai/php-tools | src/ReflectionTrait.php | ReflectionTrait.getMethodInstance | protected function getMethodInstance(&$object, $methodName)
{
$method = new ReflectionMethod(get_class($object), $methodName);
$method->setAccessible(true);
return $method;
} | php | protected function getMethodInstance(&$object, $methodName)
{
$method = new ReflectionMethod(get_class($object), $methodName);
$method->setAccessible(true);
return $method;
} | [
"protected",
"function",
"getMethodInstance",
"(",
"&",
"$",
"object",
",",
"$",
"methodName",
")",
"{",
"$",
"method",
"=",
"new",
"ReflectionMethod",
"(",
"get_class",
"(",
"$",
"object",
")",
",",
"$",
"methodName",
")",
";",
"$",
"method",
"->",
"set... | Internal method to get the `ReflectionMethod` instance
@param object $object Instantiated object that we will run method on
@param string $methodName Method name
@return ReflectionMethod | [
"Internal",
"method",
"to",
"get",
"the",
"ReflectionMethod",
"instance"
] | 46003b05490de4b570b46c6377f1e09139ffe43b | https://github.com/mirko-pagliai/php-tools/blob/46003b05490de4b570b46c6377f1e09139ffe43b/src/ReflectionTrait.php#L31-L37 | train |
mirko-pagliai/php-tools | src/ReflectionTrait.php | ReflectionTrait.getProperties | protected function getProperties(&$object, $filter = 256 | 512 | 1024)
{
$properties = (new ReflectionClass($object))->getProperties($filter);
//Removes properties added by PHPUnit, if the object is a mock
$properties = $object instanceof MockObject ? array_filter($properties, function ($property) {
return !string_starts_with($property->getName(), '__phpunit');
}) : $properties;
$values = array_map(function ($property) use ($object) {
$property->setAccessible(true);
return $property->getValue($object);
}, $properties);
return array_combine(objects_map($properties, 'getName'), $values);
} | php | protected function getProperties(&$object, $filter = 256 | 512 | 1024)
{
$properties = (new ReflectionClass($object))->getProperties($filter);
//Removes properties added by PHPUnit, if the object is a mock
$properties = $object instanceof MockObject ? array_filter($properties, function ($property) {
return !string_starts_with($property->getName(), '__phpunit');
}) : $properties;
$values = array_map(function ($property) use ($object) {
$property->setAccessible(true);
return $property->getValue($object);
}, $properties);
return array_combine(objects_map($properties, 'getName'), $values);
} | [
"protected",
"function",
"getProperties",
"(",
"&",
"$",
"object",
",",
"$",
"filter",
"=",
"256",
"|",
"512",
"|",
"1024",
")",
"{",
"$",
"properties",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"object",
")",
")",
"->",
"getProperties",
"(",
"$",
... | Gets all properties as array with property names as keys.
If the object is a mock, it removes the properties added by PHPUnit.
@param object $object Object from which to get properties
@param int $filter The optional filter, for filtering desired property
types. It's configured using `ReflectionProperty` constants, and
default is public, protected and private properties
@return array Property names as keys and property values as values
@link http://php.net/manual/en/class.reflectionproperty.php#reflectionproperty.constants.modifiers
@since 1.1.4 | [
"Gets",
"all",
"properties",
"as",
"array",
"with",
"property",
"names",
"as",
"keys",
"."
] | 46003b05490de4b570b46c6377f1e09139ffe43b | https://github.com/mirko-pagliai/php-tools/blob/46003b05490de4b570b46c6377f1e09139ffe43b/src/ReflectionTrait.php#L51-L67 | train |
mirko-pagliai/php-tools | src/ReflectionTrait.php | ReflectionTrait.getPropertyInstance | protected function getPropertyInstance(&$object, $name)
{
$property = new ReflectionProperty(get_class($object), $name);
$property->setAccessible(true);
return $property;
} | php | protected function getPropertyInstance(&$object, $name)
{
$property = new ReflectionProperty(get_class($object), $name);
$property->setAccessible(true);
return $property;
} | [
"protected",
"function",
"getPropertyInstance",
"(",
"&",
"$",
"object",
",",
"$",
"name",
")",
"{",
"$",
"property",
"=",
"new",
"ReflectionProperty",
"(",
"get_class",
"(",
"$",
"object",
")",
",",
"$",
"name",
")",
";",
"$",
"property",
"->",
"setAcce... | Internal method to get the `ReflectionProperty` instance
@param object $object Instantiated object that has the property
@param string $name Property name
@return ReflectionProperty | [
"Internal",
"method",
"to",
"get",
"the",
"ReflectionProperty",
"instance"
] | 46003b05490de4b570b46c6377f1e09139ffe43b | https://github.com/mirko-pagliai/php-tools/blob/46003b05490de4b570b46c6377f1e09139ffe43b/src/ReflectionTrait.php#L75-L81 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.