id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
15,800 | codeburnerframework/router | src/Group.php | Group.setDefault | public function setDefault($key, $value)
{
foreach ($this->routes as $route)
$route->setDefault($key, $value);
return $this;
} | php | public function setDefault($key, $value)
{
foreach ($this->routes as $route)
$route->setDefault($key, $value);
return $this;
} | [
"public",
"function",
"setDefault",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"route",
")",
"$",
"route",
"->",
"setDefault",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set a default parameter to all grouped routes.
@param string $key
@param mixed $value
@return $this | [
"Set",
"a",
"default",
"parameter",
"to",
"all",
"grouped",
"routes",
"."
]
| 2b0e8030303dd08d3fadfc4c57aa37b184a408cd | https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L210-L215 |
15,801 | codeburnerframework/router | src/Group.php | Group.setStrategy | public function setStrategy($strategy)
{
foreach ($this->routes as $route)
$route->setStrategy($strategy);
return $this;
} | php | public function setStrategy($strategy)
{
foreach ($this->routes as $route)
$route->setStrategy($strategy);
return $this;
} | [
"public",
"function",
"setStrategy",
"(",
"$",
"strategy",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"route",
")",
"$",
"route",
"->",
"setStrategy",
"(",
"$",
"strategy",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set one dispatch strategy to all grouped routes.
@param string|Strategies\StrategyInterface $strategy
@return self | [
"Set",
"one",
"dispatch",
"strategy",
"to",
"all",
"grouped",
"routes",
"."
]
| 2b0e8030303dd08d3fadfc4c57aa37b184a408cd | https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L224-L229 |
15,802 | codeburnerframework/router | src/Group.php | Group.setName | public function setName($name)
{
if (count($this->routes) > 1) {
throw new \LogicException("You cannot set the same name to several routes.");
}
$this->routes[0]->setName($name);
return $this;
} | php | public function setName($name)
{
if (count($this->routes) > 1) {
throw new \LogicException("You cannot set the same name to several routes.");
}
$this->routes[0]->setName($name);
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"routes",
")",
">",
"1",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"You cannot set the same name to several routes.\"",
")",
";",
"}",
"$",
"this",
"->",
"routes",
"[",
"0",
"]",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set a name to a Route.
@param string $name
@return self | [
"Set",
"a",
"name",
"to",
"a",
"Route",
"."
]
| 2b0e8030303dd08d3fadfc4c57aa37b184a408cd | https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L254-L262 |
15,803 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceSimple.php | StubReplaceSimple.determineIfModelIsSluggable | protected function determineIfModelIsSluggable()
{
$this->context->modelIsSluggable = false;
$this->context->modelIsParentOfSluggableTranslation = false;
// if the model is sluggable and not translated, or this is the actual translation
if ($this->data['sluggable']) {
if ( ! isset($this->data->sluggable_setup['translated'])
|| ! $this->data->sluggable_setup['translated']
|| $this->data->is_translation
) {
$this->context->modelIsSluggable = true;
} else {
// this is the parent of a translated sluggable model
$this->context->modelIsParentOfSluggableTranslation = true;
}
}
} | php | protected function determineIfModelIsSluggable()
{
$this->context->modelIsSluggable = false;
$this->context->modelIsParentOfSluggableTranslation = false;
// if the model is sluggable and not translated, or this is the actual translation
if ($this->data['sluggable']) {
if ( ! isset($this->data->sluggable_setup['translated'])
|| ! $this->data->sluggable_setup['translated']
|| $this->data->is_translation
) {
$this->context->modelIsSluggable = true;
} else {
// this is the parent of a translated sluggable model
$this->context->modelIsParentOfSluggableTranslation = true;
}
}
} | [
"protected",
"function",
"determineIfModelIsSluggable",
"(",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"modelIsSluggable",
"=",
"false",
";",
"$",
"this",
"->",
"context",
"->",
"modelIsParentOfSluggableTranslation",
"=",
"false",
";",
"// if the model is sluggable and not translated, or this is the actual translation",
"if",
"(",
"$",
"this",
"->",
"data",
"[",
"'sluggable'",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"->",
"sluggable_setup",
"[",
"'translated'",
"]",
")",
"||",
"!",
"$",
"this",
"->",
"data",
"->",
"sluggable_setup",
"[",
"'translated'",
"]",
"||",
"$",
"this",
"->",
"data",
"->",
"is_translation",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"modelIsSluggable",
"=",
"true",
";",
"}",
"else",
"{",
"// this is the parent of a translated sluggable model",
"$",
"this",
"->",
"context",
"->",
"modelIsParentOfSluggableTranslation",
"=",
"true",
";",
"}",
"}",
"}"
]
| Determines and stores whether model itself is sluggable
If so, it will have both the trait and implement the interface | [
"Determines",
"and",
"stores",
"whether",
"model",
"itself",
"is",
"sluggable",
"If",
"so",
"it",
"will",
"have",
"both",
"the",
"trait",
"and",
"implement",
"the",
"interface"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceSimple.php#L74-L95 |
15,804 | verschoof/bunq-api | src/Certificate/CertificateType.php | CertificateType.protect | private function protect()
{
if (!in_array($this->certificateType, self::allAsString(), true)) {
throw new \InvalidArgumentException(sprintf('Invalid certificate type %s', $this->certificateType));
}
} | php | private function protect()
{
if (!in_array($this->certificateType, self::allAsString(), true)) {
throw new \InvalidArgumentException(sprintf('Invalid certificate type %s', $this->certificateType));
}
} | [
"private",
"function",
"protect",
"(",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"certificateType",
",",
"self",
"::",
"allAsString",
"(",
")",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid certificate type %s'",
",",
"$",
"this",
"->",
"certificateType",
")",
")",
";",
"}",
"}"
]
| Check if the certificateType exists in our list | [
"Check",
"if",
"the",
"certificateType",
"exists",
"in",
"our",
"list"
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Certificate/CertificateType.php#L113-L118 |
15,805 | elkuku/crowdin-api | src/Package.php | Package.getBasePath | protected function getBasePath(string $action) : string
{
return sprintf(
'project/%s/%s?key=%s',
$this->getProjectId(),
$action,
$this->getApiKey()
);
} | php | protected function getBasePath(string $action) : string
{
return sprintf(
'project/%s/%s?key=%s',
$this->getProjectId(),
$action,
$this->getApiKey()
);
} | [
"protected",
"function",
"getBasePath",
"(",
"string",
"$",
"action",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"'project/%s/%s?key=%s'",
",",
"$",
"this",
"->",
"getProjectId",
"(",
")",
",",
"$",
"action",
",",
"$",
"this",
"->",
"getApiKey",
"(",
")",
")",
";",
"}"
]
| Get the base path for the command including an action.
@param string $action The action to perform.
@return string | [
"Get",
"the",
"base",
"path",
"for",
"the",
"command",
"including",
"an",
"action",
"."
]
| 690f00eed8f91a875b3f288d319750d6d8ae0453 | https://github.com/elkuku/crowdin-api/blob/690f00eed8f91a875b3f288d319750d6d8ae0453/src/Package.php#L89-L97 |
15,806 | drunomics/service-utils | src/Core/State/StateTrait.php | StateTrait.getState | public function getState() {
if (empty($this->state)) {
$this->state = \Drupal::service('state');
}
return $this->state;
} | php | public function getState() {
if (empty($this->state)) {
$this->state = \Drupal::service('state');
}
return $this->state;
} | [
"public",
"function",
"getState",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"state",
")",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"\\",
"Drupal",
"::",
"service",
"(",
"'state'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"state",
";",
"}"
]
| Gets the state storage.
@return \Drupal\Core\State\StateInterface
The state storage. | [
"Gets",
"the",
"state",
"storage",
"."
]
| 56761750043132365ef4ae5d9e0cf4263459328f | https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/State/StateTrait.php#L38-L43 |
15,807 | comodojo/dispatcher.framework | src/Comodojo/Dispatcher/Traits/HeadersTrait.php | HeadersTrait.merge | public function merge($headers) {
foreach ($headers as $key => $value) {
$this->set($key, $value);
}
return $this;
} | php | public function merge($headers) {
foreach ($headers as $key => $value) {
$this->set($key, $value);
}
return $this;
} | [
"public",
"function",
"merge",
"(",
"$",
"headers",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Merge actual headers with an array of headers
@param string $header
@return self | [
"Merge",
"actual",
"headers",
"with",
"an",
"array",
"of",
"headers"
]
| 5093297dcb7441a8d8f79cbb2429c93232e16d1c | https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Traits/HeadersTrait.php#L159-L167 |
15,808 | jan-dolata/crude-crud | src/Engine/Traits/FromModelTraitPart/CollectionTrait.php | CollectionTrait.getFiltered | public function getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters = [])
{
$query = $this->prepareQuery();
$query = $this->richFiltersOnQuery($query, $richFilters);
if ($sortAttr && $sortOrder && $this->inScope($sortAttr)) {
$scope = $this->getScope($sortAttr);
$query = $query->orderBy($scope, $sortOrder);
}
if ($searchAttr && $searchValue && $this->inScope($searchAttr)) {
$scope = $this->getScope($searchAttr);
$query = $query->where($scope, 'like', '%' . $searchValue . '%');
}
$collection = $query->get();
$collection = $this->addPermissions($collection);
$collection = $this->formatCollection($collection);
$collection = $collection->each(function ($model) {
$model = $this->formatModel($model);
});
if ($sortAttr && $sortOrder && ! $this->inScope($sortAttr)) {
$collection = $sortOrder == 'asc'
? $collection->sortBy($sortAttr)
: $collection->sortByDesc($sortAttr);
}
$collection = $this->richFiltersOnCollection($collection, $richFilters);
if ($searchAttr && $searchValue && ! $this->inScope($searchAttr)) {
$collection = $collection->filter(function ($model) use ($searchAttr, $searchValue) {
$value = (string) $model->$searchAttr;
$value = strtolower($value);
$search = strtolower($searchValue);
return strpos($value, $search) !== false;
});
}
if ($page && $numRows) {
$toSkip = ($page - 1) * $numRows;
$count = $collection->count();
$collection = $collection->take(- ($count - $toSkip))->take($numRows);
} else if ($numRows)
$collection = $collection->take($numRows);
return collect(array_values($collection->toArray()));
} | php | public function getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters = [])
{
$query = $this->prepareQuery();
$query = $this->richFiltersOnQuery($query, $richFilters);
if ($sortAttr && $sortOrder && $this->inScope($sortAttr)) {
$scope = $this->getScope($sortAttr);
$query = $query->orderBy($scope, $sortOrder);
}
if ($searchAttr && $searchValue && $this->inScope($searchAttr)) {
$scope = $this->getScope($searchAttr);
$query = $query->where($scope, 'like', '%' . $searchValue . '%');
}
$collection = $query->get();
$collection = $this->addPermissions($collection);
$collection = $this->formatCollection($collection);
$collection = $collection->each(function ($model) {
$model = $this->formatModel($model);
});
if ($sortAttr && $sortOrder && ! $this->inScope($sortAttr)) {
$collection = $sortOrder == 'asc'
? $collection->sortBy($sortAttr)
: $collection->sortByDesc($sortAttr);
}
$collection = $this->richFiltersOnCollection($collection, $richFilters);
if ($searchAttr && $searchValue && ! $this->inScope($searchAttr)) {
$collection = $collection->filter(function ($model) use ($searchAttr, $searchValue) {
$value = (string) $model->$searchAttr;
$value = strtolower($value);
$search = strtolower($searchValue);
return strpos($value, $search) !== false;
});
}
if ($page && $numRows) {
$toSkip = ($page - 1) * $numRows;
$count = $collection->count();
$collection = $collection->take(- ($count - $toSkip))->take($numRows);
} else if ($numRows)
$collection = $collection->take($numRows);
return collect(array_values($collection->toArray()));
} | [
"public",
"function",
"getFiltered",
"(",
"$",
"page",
",",
"$",
"numRows",
",",
"$",
"sortAttr",
",",
"$",
"sortOrder",
",",
"$",
"searchAttr",
",",
"$",
"searchValue",
",",
"$",
"richFilters",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"prepareQuery",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"richFiltersOnQuery",
"(",
"$",
"query",
",",
"$",
"richFilters",
")",
";",
"if",
"(",
"$",
"sortAttr",
"&&",
"$",
"sortOrder",
"&&",
"$",
"this",
"->",
"inScope",
"(",
"$",
"sortAttr",
")",
")",
"{",
"$",
"scope",
"=",
"$",
"this",
"->",
"getScope",
"(",
"$",
"sortAttr",
")",
";",
"$",
"query",
"=",
"$",
"query",
"->",
"orderBy",
"(",
"$",
"scope",
",",
"$",
"sortOrder",
")",
";",
"}",
"if",
"(",
"$",
"searchAttr",
"&&",
"$",
"searchValue",
"&&",
"$",
"this",
"->",
"inScope",
"(",
"$",
"searchAttr",
")",
")",
"{",
"$",
"scope",
"=",
"$",
"this",
"->",
"getScope",
"(",
"$",
"searchAttr",
")",
";",
"$",
"query",
"=",
"$",
"query",
"->",
"where",
"(",
"$",
"scope",
",",
"'like'",
",",
"'%'",
".",
"$",
"searchValue",
".",
"'%'",
")",
";",
"}",
"$",
"collection",
"=",
"$",
"query",
"->",
"get",
"(",
")",
";",
"$",
"collection",
"=",
"$",
"this",
"->",
"addPermissions",
"(",
"$",
"collection",
")",
";",
"$",
"collection",
"=",
"$",
"this",
"->",
"formatCollection",
"(",
"$",
"collection",
")",
";",
"$",
"collection",
"=",
"$",
"collection",
"->",
"each",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"formatModel",
"(",
"$",
"model",
")",
";",
"}",
")",
";",
"if",
"(",
"$",
"sortAttr",
"&&",
"$",
"sortOrder",
"&&",
"!",
"$",
"this",
"->",
"inScope",
"(",
"$",
"sortAttr",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"sortOrder",
"==",
"'asc'",
"?",
"$",
"collection",
"->",
"sortBy",
"(",
"$",
"sortAttr",
")",
":",
"$",
"collection",
"->",
"sortByDesc",
"(",
"$",
"sortAttr",
")",
";",
"}",
"$",
"collection",
"=",
"$",
"this",
"->",
"richFiltersOnCollection",
"(",
"$",
"collection",
",",
"$",
"richFilters",
")",
";",
"if",
"(",
"$",
"searchAttr",
"&&",
"$",
"searchValue",
"&&",
"!",
"$",
"this",
"->",
"inScope",
"(",
"$",
"searchAttr",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"filter",
"(",
"function",
"(",
"$",
"model",
")",
"use",
"(",
"$",
"searchAttr",
",",
"$",
"searchValue",
")",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"model",
"->",
"$",
"searchAttr",
";",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"$",
"search",
"=",
"strtolower",
"(",
"$",
"searchValue",
")",
";",
"return",
"strpos",
"(",
"$",
"value",
",",
"$",
"search",
")",
"!==",
"false",
";",
"}",
")",
";",
"}",
"if",
"(",
"$",
"page",
"&&",
"$",
"numRows",
")",
"{",
"$",
"toSkip",
"=",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"numRows",
";",
"$",
"count",
"=",
"$",
"collection",
"->",
"count",
"(",
")",
";",
"$",
"collection",
"=",
"$",
"collection",
"->",
"take",
"(",
"-",
"(",
"$",
"count",
"-",
"$",
"toSkip",
")",
")",
"->",
"take",
"(",
"$",
"numRows",
")",
";",
"}",
"else",
"if",
"(",
"$",
"numRows",
")",
"$",
"collection",
"=",
"$",
"collection",
"->",
"take",
"(",
"$",
"numRows",
")",
";",
"return",
"collect",
"(",
"array_values",
"(",
"$",
"collection",
"->",
"toArray",
"(",
")",
")",
")",
";",
"}"
]
| Get filtered collection
@param integer $page
@param integer $numRows
@param string $sortAttr
@param string $sortOrder
@param string $searchAttr
@param string $searchValue
@return Collection | [
"Get",
"filtered",
"collection"
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Traits/FromModelTraitPart/CollectionTrait.php#L71-L122 |
15,809 | jan-dolata/crude-crud | src/Engine/Traits/FromModelTraitPart/CollectionTrait.php | CollectionTrait.countFiltered | public function countFiltered($searchAttr, $searchValue, $richFilters)
{
$collection = $this->getFiltered(null, null, null, null, $searchAttr, $searchValue, $richFilters);
return count($collection);
} | php | public function countFiltered($searchAttr, $searchValue, $richFilters)
{
$collection = $this->getFiltered(null, null, null, null, $searchAttr, $searchValue, $richFilters);
return count($collection);
} | [
"public",
"function",
"countFiltered",
"(",
"$",
"searchAttr",
",",
"$",
"searchValue",
",",
"$",
"richFilters",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getFiltered",
"(",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"$",
"searchAttr",
",",
"$",
"searchValue",
",",
"$",
"richFilters",
")",
";",
"return",
"count",
"(",
"$",
"collection",
")",
";",
"}"
]
| Count all rows with condition
@param string $searchAttr
@param string $searchValue
@return integer | [
"Count",
"all",
"rows",
"with",
"condition"
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Traits/FromModelTraitPart/CollectionTrait.php#L130-L134 |
15,810 | jan-dolata/crude-crud | src/Engine/Traits/FromModelTraitPart/CollectionTrait.php | CollectionTrait.addPermissions | public function addPermissions($collection)
{
$newCollection = collect([]);
$customActions = $this->crudeSetup->getCustomActions();
$collection->each(function ($model) use ($newCollection, $customActions) {
if ($this->permissionView($model)) {
$model = $this->addPermissionsForModel($model, $customActions);
$newCollection->push($model);
}
});
return $newCollection;
} | php | public function addPermissions($collection)
{
$newCollection = collect([]);
$customActions = $this->crudeSetup->getCustomActions();
$collection->each(function ($model) use ($newCollection, $customActions) {
if ($this->permissionView($model)) {
$model = $this->addPermissionsForModel($model, $customActions);
$newCollection->push($model);
}
});
return $newCollection;
} | [
"public",
"function",
"addPermissions",
"(",
"$",
"collection",
")",
"{",
"$",
"newCollection",
"=",
"collect",
"(",
"[",
"]",
")",
";",
"$",
"customActions",
"=",
"$",
"this",
"->",
"crudeSetup",
"->",
"getCustomActions",
"(",
")",
";",
"$",
"collection",
"->",
"each",
"(",
"function",
"(",
"$",
"model",
")",
"use",
"(",
"$",
"newCollection",
",",
"$",
"customActions",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"permissionView",
"(",
"$",
"model",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"addPermissionsForModel",
"(",
"$",
"model",
",",
"$",
"customActions",
")",
";",
"$",
"newCollection",
"->",
"push",
"(",
"$",
"model",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"newCollection",
";",
"}"
]
| Filter collection by permissions and add attributes canBeEdited and canBeRemoved
@param Collection $collection
@return Collection | [
"Filter",
"collection",
"by",
"permissions",
"and",
"add",
"attributes",
"canBeEdited",
"and",
"canBeRemoved"
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Traits/FromModelTraitPart/CollectionTrait.php#L141-L155 |
15,811 | weavephp/weave | src/Dispatch/Dispatch.php | Dispatch.dispatch | public function dispatch($dispatchable, $resolutionType, $dispatchSource, Request $request, ...$rest)
{
return $dispatchable($request, ...$rest);
} | php | public function dispatch($dispatchable, $resolutionType, $dispatchSource, Request $request, ...$rest)
{
return $dispatchable($request, ...$rest);
} | [
"public",
"function",
"dispatch",
"(",
"$",
"dispatchable",
",",
"$",
"resolutionType",
",",
"$",
"dispatchSource",
",",
"Request",
"$",
"request",
",",
"...",
"$",
"rest",
")",
"{",
"return",
"$",
"dispatchable",
"(",
"$",
"request",
",",
"...",
"$",
"rest",
")",
";",
"}"
]
| Call the callable, providing parameters and returning the returned value.
Override this method in subclasses to easily wrap the actual dispatch callable
and provide pre- and post-dispatch custom functionality.
$resolutionType and $dispatchSource can help in identifying when to conditionally
wrap the dispatch to handle translation, templating etc.
@param callable $dispatchable The callable to be called.
@param string $resolutionType Are we dispatching to a static, invokable etc.
@param string $dispatchSource Where the dispatch request came from.
@param Request $request The request.
@param mixed ...$rest Any remaining parameters passed to the callable.
@return mixed Some form of PSR-7 style response. | [
"Call",
"the",
"callable",
"providing",
"parameters",
"and",
"returning",
"the",
"returned",
"value",
"."
]
| 44183a5bcb9e3ed3754cc76aa9e0724d718caeec | https://github.com/weavephp/weave/blob/44183a5bcb9e3ed3754cc76aa9e0724d718caeec/src/Dispatch/Dispatch.php#L31-L34 |
15,812 | arrilot/collectors | src/Collector.php | Collector.scanCollection | public function scanCollection($collection, $fields)
{
$fields = (array) $fields;
foreach ($collection as $item) {
$this->collectIdsFromItem($item, $fields);
}
return $this;
} | php | public function scanCollection($collection, $fields)
{
$fields = (array) $fields;
foreach ($collection as $item) {
$this->collectIdsFromItem($item, $fields);
}
return $this;
} | [
"public",
"function",
"scanCollection",
"(",
"$",
"collection",
",",
"$",
"fields",
")",
"{",
"$",
"fields",
"=",
"(",
"array",
")",
"$",
"fields",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"collectIdsFromItem",
"(",
"$",
"item",
",",
"$",
"fields",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a collection source.
@param $collection
@param mixed $fields
@return $this | [
"Add",
"a",
"collection",
"source",
"."
]
| b2084462070d098f088eccea37bf800097e97807 | https://github.com/arrilot/collectors/blob/b2084462070d098f088eccea37bf800097e97807/src/Collector.php#L52-L60 |
15,813 | arrilot/collectors | src/Collector.php | Collector.scanItem | public function scanItem($item, $fields)
{
$fields = (array) $fields;
$this->collectIdsFromItem($item, $fields);
return $this;
} | php | public function scanItem($item, $fields)
{
$fields = (array) $fields;
$this->collectIdsFromItem($item, $fields);
return $this;
} | [
"public",
"function",
"scanItem",
"(",
"$",
"item",
",",
"$",
"fields",
")",
"{",
"$",
"fields",
"=",
"(",
"array",
")",
"$",
"fields",
";",
"$",
"this",
"->",
"collectIdsFromItem",
"(",
"$",
"item",
",",
"$",
"fields",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add an item source.
@param $item
@param mixed $fields
@return $this | [
"Add",
"an",
"item",
"source",
"."
]
| b2084462070d098f088eccea37bf800097e97807 | https://github.com/arrilot/collectors/blob/b2084462070d098f088eccea37bf800097e97807/src/Collector.php#L69-L75 |
15,814 | arrilot/collectors | src/Collector.php | Collector.addIds | public function addIds($ids)
{
foreach ($ids as $id) {
if ((int) $id) {
$this->ids[] = (int) $id;
}
}
return $this;
} | php | public function addIds($ids)
{
foreach ($ids as $id) {
if ((int) $id) {
$this->ids[] = (int) $id;
}
}
return $this;
} | [
"public",
"function",
"addIds",
"(",
"$",
"ids",
")",
"{",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"ids",
"[",
"]",
"=",
"(",
"int",
")",
"$",
"id",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add existeing ids array source.
@param array $ids
@return $this | [
"Add",
"existeing",
"ids",
"array",
"source",
"."
]
| b2084462070d098f088eccea37bf800097e97807 | https://github.com/arrilot/collectors/blob/b2084462070d098f088eccea37bf800097e97807/src/Collector.php#L83-L92 |
15,815 | arrilot/collectors | src/Collector.php | Collector.collectIdsFromField | protected function collectIdsFromField($item, $field)
{
$ids = Arr::get($item, $field, []);
return is_object($ids) && method_exists($ids, 'toArray') ? $ids->toArray() : (array) $ids;
} | php | protected function collectIdsFromField($item, $field)
{
$ids = Arr::get($item, $field, []);
return is_object($ids) && method_exists($ids, 'toArray') ? $ids->toArray() : (array) $ids;
} | [
"protected",
"function",
"collectIdsFromField",
"(",
"$",
"item",
",",
"$",
"field",
")",
"{",
"$",
"ids",
"=",
"Arr",
"::",
"get",
"(",
"$",
"item",
",",
"$",
"field",
",",
"[",
"]",
")",
";",
"return",
"is_object",
"(",
"$",
"ids",
")",
"&&",
"method_exists",
"(",
"$",
"ids",
",",
"'toArray'",
")",
"?",
"$",
"ids",
"->",
"toArray",
"(",
")",
":",
"(",
"array",
")",
"$",
"ids",
";",
"}"
]
| Collect ids from field of item
@param $item
@param string $field
@return array | [
"Collect",
"ids",
"from",
"field",
"of",
"item"
]
| b2084462070d098f088eccea37bf800097e97807 | https://github.com/arrilot/collectors/blob/b2084462070d098f088eccea37bf800097e97807/src/Collector.php#L158-L163 |
15,816 | ridvanbaluyos/mmda | src/Ridvanbaluyos/Mmda/MMDA.php | MMDA.segments | public function segments($highway = NULL)
{
if ($highway && isset($this->trafficData[$highway]['segments'])) {
return array_keys($this->trafficData[$highway]['segments']);
}
return null;
} | php | public function segments($highway = NULL)
{
if ($highway && isset($this->trafficData[$highway]['segments'])) {
return array_keys($this->trafficData[$highway]['segments']);
}
return null;
} | [
"public",
"function",
"segments",
"(",
"$",
"highway",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"highway",
"&&",
"isset",
"(",
"$",
"this",
"->",
"trafficData",
"[",
"$",
"highway",
"]",
"[",
"'segments'",
"]",
")",
")",
"{",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"trafficData",
"[",
"$",
"highway",
"]",
"[",
"'segments'",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| This function returns the list of segments in a given highway.
@param $highway
@return array|null | [
"This",
"function",
"returns",
"the",
"list",
"of",
"segments",
"in",
"a",
"given",
"highway",
"."
]
| 7aebc360b122fc4fe8d21d482341f5ebe091e7e2 | https://github.com/ridvanbaluyos/mmda/blob/7aebc360b122fc4fe8d21d482341f5ebe091e7e2/src/Ridvanbaluyos/Mmda/MMDA.php#L66-L73 |
15,817 | ridvanbaluyos/mmda | src/Ridvanbaluyos/Mmda/MMDA.php | MMDA.getTrafficData | final private function getTrafficData($feedUrl)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $feedUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
return $this->sanitizeTrafficData($this->parseTrafficData($xml));
} | php | final private function getTrafficData($feedUrl)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $feedUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
return $this->sanitizeTrafficData($this->parseTrafficData($xml));
} | [
"final",
"private",
"function",
"getTrafficData",
"(",
"$",
"feedUrl",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"feedUrl",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"response",
")",
";",
"return",
"$",
"this",
"->",
"sanitizeTrafficData",
"(",
"$",
"this",
"->",
"parseTrafficData",
"(",
"$",
"xml",
")",
")",
";",
"}"
]
| This function retrieves the traffic data from the MMDA Traffic API.
@return array | [
"This",
"function",
"retrieves",
"the",
"traffic",
"data",
"from",
"the",
"MMDA",
"Traffic",
"API",
"."
]
| 7aebc360b122fc4fe8d21d482341f5ebe091e7e2 | https://github.com/ridvanbaluyos/mmda/blob/7aebc360b122fc4fe8d21d482341f5ebe091e7e2/src/Ridvanbaluyos/Mmda/MMDA.php#L80-L91 |
15,818 | ridvanbaluyos/mmda | src/Ridvanbaluyos/Mmda/MMDA.php | MMDA.parseTrafficData | final private function parseTrafficData($xml)
{
$traffic = [];
foreach ($xml->channel->item as $item) {
$item = get_object_vars($item);
$title = $item['title'];
$description = $item['description'];
$pubDate = $item['pubDate'];
$highway = explode('-', $title, 2)[0];
$segment = substr(explode('-', $title, 2)[1], 0, -3);
$direction = substr(explode('-', $title, 2)[1], -2);
if (empty($traffic[$highway])) $traffic[$highway] = [];
if (empty($traffic[$highway][$segment])) $traffic[$highway][$segment] = [];
$traffic[$highway][$segment][$direction] = $description;
$traffic[$highway][$segment]['pubDate'] = $pubDate;
}
return $traffic;
} | php | final private function parseTrafficData($xml)
{
$traffic = [];
foreach ($xml->channel->item as $item) {
$item = get_object_vars($item);
$title = $item['title'];
$description = $item['description'];
$pubDate = $item['pubDate'];
$highway = explode('-', $title, 2)[0];
$segment = substr(explode('-', $title, 2)[1], 0, -3);
$direction = substr(explode('-', $title, 2)[1], -2);
if (empty($traffic[$highway])) $traffic[$highway] = [];
if (empty($traffic[$highway][$segment])) $traffic[$highway][$segment] = [];
$traffic[$highway][$segment][$direction] = $description;
$traffic[$highway][$segment]['pubDate'] = $pubDate;
}
return $traffic;
} | [
"final",
"private",
"function",
"parseTrafficData",
"(",
"$",
"xml",
")",
"{",
"$",
"traffic",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"xml",
"->",
"channel",
"->",
"item",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"=",
"get_object_vars",
"(",
"$",
"item",
")",
";",
"$",
"title",
"=",
"$",
"item",
"[",
"'title'",
"]",
";",
"$",
"description",
"=",
"$",
"item",
"[",
"'description'",
"]",
";",
"$",
"pubDate",
"=",
"$",
"item",
"[",
"'pubDate'",
"]",
";",
"$",
"highway",
"=",
"explode",
"(",
"'-'",
",",
"$",
"title",
",",
"2",
")",
"[",
"0",
"]",
";",
"$",
"segment",
"=",
"substr",
"(",
"explode",
"(",
"'-'",
",",
"$",
"title",
",",
"2",
")",
"[",
"1",
"]",
",",
"0",
",",
"-",
"3",
")",
";",
"$",
"direction",
"=",
"substr",
"(",
"explode",
"(",
"'-'",
",",
"$",
"title",
",",
"2",
")",
"[",
"1",
"]",
",",
"-",
"2",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"traffic",
"[",
"$",
"highway",
"]",
")",
")",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"[",
"$",
"segment",
"]",
")",
")",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"[",
"$",
"segment",
"]",
"=",
"[",
"]",
";",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"[",
"$",
"segment",
"]",
"[",
"$",
"direction",
"]",
"=",
"$",
"description",
";",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"[",
"$",
"segment",
"]",
"[",
"'pubDate'",
"]",
"=",
"$",
"pubDate",
";",
"}",
"return",
"$",
"traffic",
";",
"}"
]
| This function parses the XML response from the MMDA Traffic API into JSON.
@param $xml
@return array | [
"This",
"function",
"parses",
"the",
"XML",
"response",
"from",
"the",
"MMDA",
"Traffic",
"API",
"into",
"JSON",
"."
]
| 7aebc360b122fc4fe8d21d482341f5ebe091e7e2 | https://github.com/ridvanbaluyos/mmda/blob/7aebc360b122fc4fe8d21d482341f5ebe091e7e2/src/Ridvanbaluyos/Mmda/MMDA.php#L99-L121 |
15,819 | ridvanbaluyos/mmda | src/Ridvanbaluyos/Mmda/MMDA.php | MMDA.sanitizeTrafficData | final private function sanitizeTrafficData(Array $trafficData)
{
$traffic = [];
foreach ($trafficData as $highway=>$segments) {
$traffic[$highway] = [
'name' => $highway,
'label' => $this->convertToTitle($highway),
];
$traffic[$highway]['segments'] = [];
$dataSegments = [];
foreach ($segments as $segment=>$status) {
$dataSegments[$segment] = [
'name' => $segment,
'label' => $this->convertToTitle($segment),
'status' => $this->convertToStatus($status),
];
$traffic[$highway]['segments'] = $dataSegments;
}
}
return $traffic;
} | php | final private function sanitizeTrafficData(Array $trafficData)
{
$traffic = [];
foreach ($trafficData as $highway=>$segments) {
$traffic[$highway] = [
'name' => $highway,
'label' => $this->convertToTitle($highway),
];
$traffic[$highway]['segments'] = [];
$dataSegments = [];
foreach ($segments as $segment=>$status) {
$dataSegments[$segment] = [
'name' => $segment,
'label' => $this->convertToTitle($segment),
'status' => $this->convertToStatus($status),
];
$traffic[$highway]['segments'] = $dataSegments;
}
}
return $traffic;
} | [
"final",
"private",
"function",
"sanitizeTrafficData",
"(",
"Array",
"$",
"trafficData",
")",
"{",
"$",
"traffic",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"trafficData",
"as",
"$",
"highway",
"=>",
"$",
"segments",
")",
"{",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"highway",
",",
"'label'",
"=>",
"$",
"this",
"->",
"convertToTitle",
"(",
"$",
"highway",
")",
",",
"]",
";",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"[",
"'segments'",
"]",
"=",
"[",
"]",
";",
"$",
"dataSegments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"segment",
"=>",
"$",
"status",
")",
"{",
"$",
"dataSegments",
"[",
"$",
"segment",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"segment",
",",
"'label'",
"=>",
"$",
"this",
"->",
"convertToTitle",
"(",
"$",
"segment",
")",
",",
"'status'",
"=>",
"$",
"this",
"->",
"convertToStatus",
"(",
"$",
"status",
")",
",",
"]",
";",
"$",
"traffic",
"[",
"$",
"highway",
"]",
"[",
"'segments'",
"]",
"=",
"$",
"dataSegments",
";",
"}",
"}",
"return",
"$",
"traffic",
";",
"}"
]
| This function sanitizes the traffic data and organizes them into an envelope
@param array $trafficData
@return array | [
"This",
"function",
"sanitizes",
"the",
"traffic",
"data",
"and",
"organizes",
"them",
"into",
"an",
"envelope"
]
| 7aebc360b122fc4fe8d21d482341f5ebe091e7e2 | https://github.com/ridvanbaluyos/mmda/blob/7aebc360b122fc4fe8d21d482341f5ebe091e7e2/src/Ridvanbaluyos/Mmda/MMDA.php#L129-L152 |
15,820 | ridvanbaluyos/mmda | src/Ridvanbaluyos/Mmda/MMDA.php | MMDA.convertToStatus | final private function convertToStatus(Array $data)
{
$statusMatrix = [
'L' => 'Light',
'ML' => 'Light to Moderate',
'M' => 'Moderate',
'MH' => 'Moderate to Heavy',
'H' => 'Heavy'
];
$status = [
'NB' => [
'name' => $data['NB'],
'label' => $statusMatrix[$data['NB']] . ' Traffic',
'last_updated' => $data['pubDate']
],
'SB' => [
'name' => $data['SB'],
'label' => $statusMatrix[$data['SB']] . ' Traffic',
'last_updated' => $data['pubDate']
]
];
return $status;
} | php | final private function convertToStatus(Array $data)
{
$statusMatrix = [
'L' => 'Light',
'ML' => 'Light to Moderate',
'M' => 'Moderate',
'MH' => 'Moderate to Heavy',
'H' => 'Heavy'
];
$status = [
'NB' => [
'name' => $data['NB'],
'label' => $statusMatrix[$data['NB']] . ' Traffic',
'last_updated' => $data['pubDate']
],
'SB' => [
'name' => $data['SB'],
'label' => $statusMatrix[$data['SB']] . ' Traffic',
'last_updated' => $data['pubDate']
]
];
return $status;
} | [
"final",
"private",
"function",
"convertToStatus",
"(",
"Array",
"$",
"data",
")",
"{",
"$",
"statusMatrix",
"=",
"[",
"'L'",
"=>",
"'Light'",
",",
"'ML'",
"=>",
"'Light to Moderate'",
",",
"'M'",
"=>",
"'Moderate'",
",",
"'MH'",
"=>",
"'Moderate to Heavy'",
",",
"'H'",
"=>",
"'Heavy'",
"]",
";",
"$",
"status",
"=",
"[",
"'NB'",
"=>",
"[",
"'name'",
"=>",
"$",
"data",
"[",
"'NB'",
"]",
",",
"'label'",
"=>",
"$",
"statusMatrix",
"[",
"$",
"data",
"[",
"'NB'",
"]",
"]",
".",
"' Traffic'",
",",
"'last_updated'",
"=>",
"$",
"data",
"[",
"'pubDate'",
"]",
"]",
",",
"'SB'",
"=>",
"[",
"'name'",
"=>",
"$",
"data",
"[",
"'SB'",
"]",
",",
"'label'",
"=>",
"$",
"statusMatrix",
"[",
"$",
"data",
"[",
"'SB'",
"]",
"]",
".",
"' Traffic'",
",",
"'last_updated'",
"=>",
"$",
"data",
"[",
"'pubDate'",
"]",
"]",
"]",
";",
"return",
"$",
"status",
";",
"}"
]
| This function converts traffic data status to readable format.
@param array $data
@return array | [
"This",
"function",
"converts",
"traffic",
"data",
"status",
"to",
"readable",
"format",
"."
]
| 7aebc360b122fc4fe8d21d482341f5ebe091e7e2 | https://github.com/ridvanbaluyos/mmda/blob/7aebc360b122fc4fe8d21d482341f5ebe091e7e2/src/Ridvanbaluyos/Mmda/MMDA.php#L160-L184 |
15,821 | ridvanbaluyos/mmda | src/Ridvanbaluyos/Mmda/MMDA.php | MMDA.convertToTitle | final private function convertToTitle($string)
{
$string2 = [];
$string = str_replace(['_', 'AVE.', 'BLVD.'], [' ', 'AVENUE', 'BOULEVARD'], $string);
$words = explode(' ', $string);
foreach ($words as $word) {
if (!in_array($word, ['EDSA', 'U.N.'])) {
$word = ucwords(mb_strtolower($word));
}
array_push($string2, $word);
}
return implode(' ', $string2);
} | php | final private function convertToTitle($string)
{
$string2 = [];
$string = str_replace(['_', 'AVE.', 'BLVD.'], [' ', 'AVENUE', 'BOULEVARD'], $string);
$words = explode(' ', $string);
foreach ($words as $word) {
if (!in_array($word, ['EDSA', 'U.N.'])) {
$word = ucwords(mb_strtolower($word));
}
array_push($string2, $word);
}
return implode(' ', $string2);
} | [
"final",
"private",
"function",
"convertToTitle",
"(",
"$",
"string",
")",
"{",
"$",
"string2",
"=",
"[",
"]",
";",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"'_'",
",",
"'AVE.'",
",",
"'BLVD.'",
"]",
",",
"[",
"' '",
",",
"'AVENUE'",
",",
"'BOULEVARD'",
"]",
",",
"$",
"string",
")",
";",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"string",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"word",
",",
"[",
"'EDSA'",
",",
"'U.N.'",
"]",
")",
")",
"{",
"$",
"word",
"=",
"ucwords",
"(",
"mb_strtolower",
"(",
"$",
"word",
")",
")",
";",
"}",
"array_push",
"(",
"$",
"string2",
",",
"$",
"word",
")",
";",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"string2",
")",
";",
"}"
]
| This function sanitizes certain abbreviations into readable format.
@param $string
@return string | [
"This",
"function",
"sanitizes",
"certain",
"abbreviations",
"into",
"readable",
"format",
"."
]
| 7aebc360b122fc4fe8d21d482341f5ebe091e7e2 | https://github.com/ridvanbaluyos/mmda/blob/7aebc360b122fc4fe8d21d482341f5ebe091e7e2/src/Ridvanbaluyos/Mmda/MMDA.php#L192-L206 |
15,822 | chris-schmitz/L5SimpleFM | src/L5SimpleFM.php | L5SimpleFM.findByRecId | public function findByRecId($recId)
{
if (empty($recId)) {
throw new \Exception('No record ID specified');
}
$this->primeCommandArray();
$this->addToCommandArray(['-recid' => $recId]);
$this->addToCommandArray(['-find' => null]);
return $this;
} | php | public function findByRecId($recId)
{
if (empty($recId)) {
throw new \Exception('No record ID specified');
}
$this->primeCommandArray();
$this->addToCommandArray(['-recid' => $recId]);
$this->addToCommandArray(['-find' => null]);
return $this;
} | [
"public",
"function",
"findByRecId",
"(",
"$",
"recId",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"recId",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No record ID specified'",
")",
";",
"}",
"$",
"this",
"->",
"primeCommandArray",
"(",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-recid'",
"=>",
"$",
"recId",
"]",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-find'",
"=>",
"null",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Find a record based on it's internal FileMaker record ID
@param integer The internal FileMaker Record ID
@return object This object | [
"Find",
"a",
"record",
"based",
"on",
"it",
"s",
"internal",
"FileMaker",
"record",
"ID"
]
| 9c3250e0918184d537a46c15140f15527e833a4c | https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFM.php#L72-L81 |
15,823 | chris-schmitz/L5SimpleFM | src/L5SimpleFM.php | L5SimpleFM.createRecord | public function createRecord($data)
{
$this->primeCommandArray();
$this->addToCommandArray($data);
$this->addToCommandArray(['-new' => null]);
return $this;
} | php | public function createRecord($data)
{
$this->primeCommandArray();
$this->addToCommandArray($data);
$this->addToCommandArray(['-new' => null]);
return $this;
} | [
"public",
"function",
"createRecord",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"primeCommandArray",
"(",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-new'",
"=>",
"null",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Create a new record and populate it with data.
@param array An associative array of FileName => Values to populate the record with
@return object This object | [
"Create",
"a",
"new",
"record",
"and",
"populate",
"it",
"with",
"data",
"."
]
| 9c3250e0918184d537a46c15140f15527e833a4c | https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFM.php#L88-L94 |
15,824 | chris-schmitz/L5SimpleFM | src/L5SimpleFM.php | L5SimpleFM.updateRecord | public function updateRecord($recId, $data)
{
if (empty($recId)) {
throw new \Exception('No record ID specified');
}
$this->primeCommandArray();
$this->addToCommandArray($data);
$this->addToCommandArray(['-recid' => $recId]);
$this->addToCommandArray(['-edit' => null]);
return $this;
} | php | public function updateRecord($recId, $data)
{
if (empty($recId)) {
throw new \Exception('No record ID specified');
}
$this->primeCommandArray();
$this->addToCommandArray($data);
$this->addToCommandArray(['-recid' => $recId]);
$this->addToCommandArray(['-edit' => null]);
return $this;
} | [
"public",
"function",
"updateRecord",
"(",
"$",
"recId",
",",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"recId",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No record ID specified'",
")",
";",
"}",
"$",
"this",
"->",
"primeCommandArray",
"(",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-recid'",
"=>",
"$",
"recId",
"]",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-edit'",
"=>",
"null",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Update data in an existing record per it's internal FileMaker record ID.
@param integer The internal FileMaker record ID.
@param array An associative array of FileName => Values to overwrite the record with
Data in fields not included will not be overwritten.
@return object This object | [
"Update",
"data",
"in",
"an",
"existing",
"record",
"per",
"it",
"s",
"internal",
"FileMaker",
"record",
"ID",
"."
]
| 9c3250e0918184d537a46c15140f15527e833a4c | https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFM.php#L103-L113 |
15,825 | chris-schmitz/L5SimpleFM | src/L5SimpleFM.php | L5SimpleFM.deleteRecord | public function deleteRecord($recId)
{
if (empty($recId)) {
throw new \Exception('No record ID specified');
}
$this->primeCommandArray();
$this->addToCommandArray(['-recid' => $recId]);
$this->addToCommandArray(['-delete' => null]);
return $this;
} | php | public function deleteRecord($recId)
{
if (empty($recId)) {
throw new \Exception('No record ID specified');
}
$this->primeCommandArray();
$this->addToCommandArray(['-recid' => $recId]);
$this->addToCommandArray(['-delete' => null]);
return $this;
} | [
"public",
"function",
"deleteRecord",
"(",
"$",
"recId",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"recId",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No record ID specified'",
")",
";",
"}",
"$",
"this",
"->",
"primeCommandArray",
"(",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-recid'",
"=>",
"$",
"recId",
"]",
")",
";",
"$",
"this",
"->",
"addToCommandArray",
"(",
"[",
"'-delete'",
"=>",
"null",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Delete a record per it's internal FileMaker record ID.
@param integer The internal FileMaker record ID.
@return object This object | [
"Delete",
"a",
"record",
"per",
"it",
"s",
"internal",
"FileMaker",
"record",
"ID",
"."
]
| 9c3250e0918184d537a46c15140f15527e833a4c | https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFM.php#L120-L129 |
15,826 | 100hz/hive | src/Hive/Hive.php | Hive.createDocumentManager | protected function createDocumentManager()
{
AnnotationDriver::registerAnnotationClasses();
$configuration = new Configuration();
$configuration->setProxyDir($this->configuration['doctrine']['proxyDir']);
$configuration->setProxyNamespace($this->configuration['doctrine']['proxyNamespace']);
$configuration->setHydratorDir($this->configuration['doctrine']['hydratorDir']);
$configuration->setHydratorNamespace($this->configuration['doctrine']['hydratorNamespace']);
$configuration->setMetadataDriverImpl(AnnotationDriver::create());
return DocumentManager::create(new Connection($this->configuration['doctrine']['connection']['server']), $configuration);
} | php | protected function createDocumentManager()
{
AnnotationDriver::registerAnnotationClasses();
$configuration = new Configuration();
$configuration->setProxyDir($this->configuration['doctrine']['proxyDir']);
$configuration->setProxyNamespace($this->configuration['doctrine']['proxyNamespace']);
$configuration->setHydratorDir($this->configuration['doctrine']['hydratorDir']);
$configuration->setHydratorNamespace($this->configuration['doctrine']['hydratorNamespace']);
$configuration->setMetadataDriverImpl(AnnotationDriver::create());
return DocumentManager::create(new Connection($this->configuration['doctrine']['connection']['server']), $configuration);
} | [
"protected",
"function",
"createDocumentManager",
"(",
")",
"{",
"AnnotationDriver",
"::",
"registerAnnotationClasses",
"(",
")",
";",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"configuration",
"->",
"setProxyDir",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'doctrine'",
"]",
"[",
"'proxyDir'",
"]",
")",
";",
"$",
"configuration",
"->",
"setProxyNamespace",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'doctrine'",
"]",
"[",
"'proxyNamespace'",
"]",
")",
";",
"$",
"configuration",
"->",
"setHydratorDir",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'doctrine'",
"]",
"[",
"'hydratorDir'",
"]",
")",
";",
"$",
"configuration",
"->",
"setHydratorNamespace",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'doctrine'",
"]",
"[",
"'hydratorNamespace'",
"]",
")",
";",
"$",
"configuration",
"->",
"setMetadataDriverImpl",
"(",
"AnnotationDriver",
"::",
"create",
"(",
")",
")",
";",
"return",
"DocumentManager",
"::",
"create",
"(",
"new",
"Connection",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'doctrine'",
"]",
"[",
"'connection'",
"]",
"[",
"'server'",
"]",
")",
",",
"$",
"configuration",
")",
";",
"}"
]
| Creates the doctrine document mananger for working on the database
@return DocumentManager | [
"Creates",
"the",
"doctrine",
"document",
"mananger",
"for",
"working",
"on",
"the",
"database"
]
| b336b092255ce885b1ff9bf78d49693c4daf1c72 | https://github.com/100hz/hive/blob/b336b092255ce885b1ff9bf78d49693c4daf1c72/src/Hive/Hive.php#L154-L166 |
15,827 | 100hz/hive | src/Hive/Hive.php | Hive.initPromises | protected function initPromises($promisesTrait)
{
return $promisesTrait->findOne($this->createFindOneClosure())
->findMany($this->createFindManyClosure())
->renderResult($this->createRenderResultClosure())
->allowRequest($this->createAllowRequestClosure());
} | php | protected function initPromises($promisesTrait)
{
return $promisesTrait->findOne($this->createFindOneClosure())
->findMany($this->createFindManyClosure())
->renderResult($this->createRenderResultClosure())
->allowRequest($this->createAllowRequestClosure());
} | [
"protected",
"function",
"initPromises",
"(",
"$",
"promisesTrait",
")",
"{",
"return",
"$",
"promisesTrait",
"->",
"findOne",
"(",
"$",
"this",
"->",
"createFindOneClosure",
"(",
")",
")",
"->",
"findMany",
"(",
"$",
"this",
"->",
"createFindManyClosure",
"(",
")",
")",
"->",
"renderResult",
"(",
"$",
"this",
"->",
"createRenderResultClosure",
"(",
")",
")",
"->",
"allowRequest",
"(",
"$",
"this",
"->",
"createAllowRequestClosure",
"(",
")",
")",
";",
"}"
]
| Method for initializing a PromisesTrait object with the Closures
@param PromisesTrait|Hive|Resource $promisesTrait
@return PromisesTrait|Hive|Resource | [
"Method",
"for",
"initializing",
"a",
"PromisesTrait",
"object",
"with",
"the",
"Closures"
]
| b336b092255ce885b1ff9bf78d49693c4daf1c72 | https://github.com/100hz/hive/blob/b336b092255ce885b1ff9bf78d49693c4daf1c72/src/Hive/Hive.php#L174-L180 |
15,828 | 100hz/hive | src/Hive/Hive.php | Hive.createHttpException | protected function createHttpException($code, $message = null)
{
if ($code == 404) {
$message = 'Entity not found';
}
$exception = new HttpException($message, $code);
return $exception;
} | php | protected function createHttpException($code, $message = null)
{
if ($code == 404) {
$message = 'Entity not found';
}
$exception = new HttpException($message, $code);
return $exception;
} | [
"protected",
"function",
"createHttpException",
"(",
"$",
"code",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"==",
"404",
")",
"{",
"$",
"message",
"=",
"'Entity not found'",
";",
"}",
"$",
"exception",
"=",
"new",
"HttpException",
"(",
"$",
"message",
",",
"$",
"code",
")",
";",
"return",
"$",
"exception",
";",
"}"
]
| Helper method for creating HTTP exceptions
@param int $code
@param string $message
@return HttpException | [
"Helper",
"method",
"for",
"creating",
"HTTP",
"exceptions"
]
| b336b092255ce885b1ff9bf78d49693c4daf1c72 | https://github.com/100hz/hive/blob/b336b092255ce885b1ff9bf78d49693c4daf1c72/src/Hive/Hive.php#L769-L777 |
15,829 | 100hz/hive | src/Hive/Hive.php | Hive.resource | public function resource($className, $settings = [])
{
/** @var \Hive\Resource $resource */
$resource = $this->initPromises(Resource::create($className, $settings, $this));
foreach ($resource->settings['actions'] as $action => $actionSettings) {
$methodName = "setup$action";
if (method_exists($this, $methodName)) {
$this->{$methodName}($resource);
}
}
return $resource;
} | php | public function resource($className, $settings = [])
{
/** @var \Hive\Resource $resource */
$resource = $this->initPromises(Resource::create($className, $settings, $this));
foreach ($resource->settings['actions'] as $action => $actionSettings) {
$methodName = "setup$action";
if (method_exists($this, $methodName)) {
$this->{$methodName}($resource);
}
}
return $resource;
} | [
"public",
"function",
"resource",
"(",
"$",
"className",
",",
"$",
"settings",
"=",
"[",
"]",
")",
"{",
"/** @var \\Hive\\Resource $resource */",
"$",
"resource",
"=",
"$",
"this",
"->",
"initPromises",
"(",
"Resource",
"::",
"create",
"(",
"$",
"className",
",",
"$",
"settings",
",",
"$",
"this",
")",
")",
";",
"foreach",
"(",
"$",
"resource",
"->",
"settings",
"[",
"'actions'",
"]",
"as",
"$",
"action",
"=>",
"$",
"actionSettings",
")",
"{",
"$",
"methodName",
"=",
"\"setup$action\"",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"methodName",
"}",
"(",
"$",
"resource",
")",
";",
"}",
"}",
"return",
"$",
"resource",
";",
"}"
]
| The second most important method.
Will create RESTful routes for MongoDB model.
@param string $className
@param array $settings
@return PromisesTrait|Resource | [
"The",
"second",
"most",
"important",
"method",
".",
"Will",
"create",
"RESTful",
"routes",
"for",
"MongoDB",
"model",
"."
]
| b336b092255ce885b1ff9bf78d49693c4daf1c72 | https://github.com/100hz/hive/blob/b336b092255ce885b1ff9bf78d49693c4daf1c72/src/Hive/Hive.php#L800-L813 |
15,830 | 100hz/hive | src/Hive/Hive.php | Hive.api | public function api($request = null, $response = null, $sendResponse = true)
{
$this->klein->respond('POST', '/authenticate', $this->authenticate);
$this->klein->onHttpError($this->handleError);
// see https://github.com/klein/klein.php/wiki/Sub-Directory-Installation
if ($request === null)
$request = Request::createFromGlobals();
// Grab the server-passed "REQUEST_URI"
$uri = $request->server()->get('REQUEST_URI');
// Set the request URI to a modified one (without the "subdirectory") in it
$request->server()->set('REQUEST_URI', '/' . substr($uri, strlen($this->configuration['basePath'])));
// Pass our request to our dispatch method
$this->klein->dispatch($request, $response, $sendResponse);
} | php | public function api($request = null, $response = null, $sendResponse = true)
{
$this->klein->respond('POST', '/authenticate', $this->authenticate);
$this->klein->onHttpError($this->handleError);
// see https://github.com/klein/klein.php/wiki/Sub-Directory-Installation
if ($request === null)
$request = Request::createFromGlobals();
// Grab the server-passed "REQUEST_URI"
$uri = $request->server()->get('REQUEST_URI');
// Set the request URI to a modified one (without the "subdirectory") in it
$request->server()->set('REQUEST_URI', '/' . substr($uri, strlen($this->configuration['basePath'])));
// Pass our request to our dispatch method
$this->klein->dispatch($request, $response, $sendResponse);
} | [
"public",
"function",
"api",
"(",
"$",
"request",
"=",
"null",
",",
"$",
"response",
"=",
"null",
",",
"$",
"sendResponse",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"klein",
"->",
"respond",
"(",
"'POST'",
",",
"'/authenticate'",
",",
"$",
"this",
"->",
"authenticate",
")",
";",
"$",
"this",
"->",
"klein",
"->",
"onHttpError",
"(",
"$",
"this",
"->",
"handleError",
")",
";",
"// see https://github.com/klein/klein.php/wiki/Sub-Directory-Installation",
"if",
"(",
"$",
"request",
"===",
"null",
")",
"$",
"request",
"=",
"Request",
"::",
"createFromGlobals",
"(",
")",
";",
"// Grab the server-passed \"REQUEST_URI\"",
"$",
"uri",
"=",
"$",
"request",
"->",
"server",
"(",
")",
"->",
"get",
"(",
"'REQUEST_URI'",
")",
";",
"// Set the request URI to a modified one (without the \"subdirectory\") in it",
"$",
"request",
"->",
"server",
"(",
")",
"->",
"set",
"(",
"'REQUEST_URI'",
",",
"'/'",
".",
"substr",
"(",
"$",
"uri",
",",
"strlen",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'basePath'",
"]",
")",
")",
")",
";",
"// Pass our request to our dispatch method",
"$",
"this",
"->",
"klein",
"->",
"dispatch",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"sendResponse",
")",
";",
"}"
]
| The most important method.
Will start the hive engine and listening for requests.
@param Request $request
@param AbstractResponse $response
@param boolean $sendResponse
@return void | [
"The",
"most",
"important",
"method",
".",
"Will",
"start",
"the",
"hive",
"engine",
"and",
"listening",
"for",
"requests",
"."
]
| b336b092255ce885b1ff9bf78d49693c4daf1c72 | https://github.com/100hz/hive/blob/b336b092255ce885b1ff9bf78d49693c4daf1c72/src/Hive/Hive.php#L825-L842 |
15,831 | fproject/yii2-flex | fproject/widgets/FlexWidget.php | FlexWidget.getFlexLocale | private function getFlexLocale($language) {
if(!empty($language))
{
$split = explode("-", $language, 2);
if(count($split) == 2 && $split[1] != "") {
$split[1] = strtoupper($split[1]);
} else {
$split = null;
}
}
if(empty($split))
$split = ['en', 'US'];
return $split[0] . self::LANGUAGUE_SEPARATOR . $split[1];
} | php | private function getFlexLocale($language) {
if(!empty($language))
{
$split = explode("-", $language, 2);
if(count($split) == 2 && $split[1] != "") {
$split[1] = strtoupper($split[1]);
} else {
$split = null;
}
}
if(empty($split))
$split = ['en', 'US'];
return $split[0] . self::LANGUAGUE_SEPARATOR . $split[1];
} | [
"private",
"function",
"getFlexLocale",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"language",
")",
")",
"{",
"$",
"split",
"=",
"explode",
"(",
"\"-\"",
",",
"$",
"language",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"split",
")",
"==",
"2",
"&&",
"$",
"split",
"[",
"1",
"]",
"!=",
"\"\"",
")",
"{",
"$",
"split",
"[",
"1",
"]",
"=",
"strtoupper",
"(",
"$",
"split",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"split",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"split",
")",
")",
"$",
"split",
"=",
"[",
"'en'",
",",
"'US'",
"]",
";",
"return",
"$",
"split",
"[",
"0",
"]",
".",
"self",
"::",
"LANGUAGUE_SEPARATOR",
".",
"$",
"split",
"[",
"1",
"]",
";",
"}"
]
| Returns locale with format for flex application
@param string $language the app language
@return string | [
"Returns",
"locale",
"with",
"format",
"for",
"flex",
"application"
]
| 661c8532484ce90592af9111df3cccf4091b10a7 | https://github.com/fproject/yii2-flex/blob/661c8532484ce90592af9111df3cccf4091b10a7/fproject/widgets/FlexWidget.php#L248-L264 |
15,832 | prooph/link-app-core | src/Command/ConfigureJavascriptTicker.php | ConfigureJavascriptTicker.assertPayload | protected function assertPayload($aPayload = null)
{
if (! array_key_exists('enabled', $aPayload) || ! array_key_exists('interval', $aPayload)) {
throw new \InvalidArgumentException('Payload does not contain a enabled or interval key');
}
if (! is_bool($aPayload['enabled'])) throw new \InvalidArgumentException('Enabled flag must be a boolean value');
if (! is_int($aPayload['interval'])) throw new \InvalidArgumentException('Ticker interval must be an integer');
} | php | protected function assertPayload($aPayload = null)
{
if (! array_key_exists('enabled', $aPayload) || ! array_key_exists('interval', $aPayload)) {
throw new \InvalidArgumentException('Payload does not contain a enabled or interval key');
}
if (! is_bool($aPayload['enabled'])) throw new \InvalidArgumentException('Enabled flag must be a boolean value');
if (! is_int($aPayload['interval'])) throw new \InvalidArgumentException('Ticker interval must be an integer');
} | [
"protected",
"function",
"assertPayload",
"(",
"$",
"aPayload",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'enabled'",
",",
"$",
"aPayload",
")",
"||",
"!",
"array_key_exists",
"(",
"'interval'",
",",
"$",
"aPayload",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Payload does not contain a enabled or interval key'",
")",
";",
"}",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"aPayload",
"[",
"'enabled'",
"]",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Enabled flag must be a boolean value'",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"aPayload",
"[",
"'interval'",
"]",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Ticker interval must be an integer'",
")",
";",
"}"
]
| Assert that payload contains all required information for this command
@param null|array $aPayload
@throws \InvalidArgumentException | [
"Assert",
"that",
"payload",
"contains",
"all",
"required",
"information",
"for",
"this",
"command"
]
| 835a5945dfa7be7b2cebfa6e84e757ecfd783357 | https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Command/ConfigureJavascriptTicker.php#L60-L68 |
15,833 | ua1-labs/firebug | Fire/Bug/Panel.php | Panel.renderLabel | public function renderLabel($content, $class = '', $style = '')
{
$styleAttr = ($style) ? ' style="' . $style . '"' : '';
$classes = ($class) ? ' ' . $class : '';
$renderLabel = '';
$renderLabel .= '<span class="fs-label' . $classes . '"' . $style . '>';
$renderLabel .= $content;
$renderLabel .= '</span>';
return $renderLabel;
} | php | public function renderLabel($content, $class = '', $style = '')
{
$styleAttr = ($style) ? ' style="' . $style . '"' : '';
$classes = ($class) ? ' ' . $class : '';
$renderLabel = '';
$renderLabel .= '<span class="fs-label' . $classes . '"' . $style . '>';
$renderLabel .= $content;
$renderLabel .= '</span>';
return $renderLabel;
} | [
"public",
"function",
"renderLabel",
"(",
"$",
"content",
",",
"$",
"class",
"=",
"''",
",",
"$",
"style",
"=",
"''",
")",
"{",
"$",
"styleAttr",
"=",
"(",
"$",
"style",
")",
"?",
"' style=\"'",
".",
"$",
"style",
".",
"'\"'",
":",
"''",
";",
"$",
"classes",
"=",
"(",
"$",
"class",
")",
"?",
"' '",
".",
"$",
"class",
":",
"''",
";",
"$",
"renderLabel",
"=",
"''",
";",
"$",
"renderLabel",
".=",
"'<span class=\"fs-label'",
".",
"$",
"classes",
".",
"'\"'",
".",
"$",
"style",
".",
"'>'",
";",
"$",
"renderLabel",
".=",
"$",
"content",
";",
"$",
"renderLabel",
".=",
"'</span>'",
";",
"return",
"$",
"renderLabel",
";",
"}"
]
| Returns a label.
@param string $content The content of the label
@param string $class CSV list of classes you want to add
@param string $style Custom styles you want added
@return string HTML code for the separator | [
"Returns",
"a",
"label",
"."
]
| 70a45b2c0bbf64978641eb07e5f3cddfc1951162 | https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug/Panel.php#L90-L99 |
15,834 | ua1-labs/firebug | Fire/Bug/Panel.php | Panel.renderSeparator | public function renderSeparator($bold = true, $class = '', $style = '')
{
$styleAttr = ($style) ? ' style="' . $style . '"' : '';
$classes = ($class) ? ' ' . $class : '';
if ($bold) {
return '<hr class="fs-hr' . $classes . '"' . $styleAttr . '>';
} else {
return '<hr class="fs-hr-dotted' . $classes . '"' . $styleAttr . '>';
}
} | php | public function renderSeparator($bold = true, $class = '', $style = '')
{
$styleAttr = ($style) ? ' style="' . $style . '"' : '';
$classes = ($class) ? ' ' . $class : '';
if ($bold) {
return '<hr class="fs-hr' . $classes . '"' . $styleAttr . '>';
} else {
return '<hr class="fs-hr-dotted' . $classes . '"' . $styleAttr . '>';
}
} | [
"public",
"function",
"renderSeparator",
"(",
"$",
"bold",
"=",
"true",
",",
"$",
"class",
"=",
"''",
",",
"$",
"style",
"=",
"''",
")",
"{",
"$",
"styleAttr",
"=",
"(",
"$",
"style",
")",
"?",
"' style=\"'",
".",
"$",
"style",
".",
"'\"'",
":",
"''",
";",
"$",
"classes",
"=",
"(",
"$",
"class",
")",
"?",
"' '",
".",
"$",
"class",
":",
"''",
";",
"if",
"(",
"$",
"bold",
")",
"{",
"return",
"'<hr class=\"fs-hr'",
".",
"$",
"classes",
".",
"'\"'",
".",
"$",
"styleAttr",
".",
"'>'",
";",
"}",
"else",
"{",
"return",
"'<hr class=\"fs-hr-dotted'",
".",
"$",
"classes",
".",
"'\"'",
".",
"$",
"styleAttr",
".",
"'>'",
";",
"}",
"}"
]
| Returns a separator.
@param boolean $bold Do you want a bold separator
@param string $class CSV list of classes you want to add
@param string $style Custom styles you want added
@return string HTML code for the separator. | [
"Returns",
"a",
"separator",
"."
]
| 70a45b2c0bbf64978641eb07e5f3cddfc1951162 | https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug/Panel.php#L108-L117 |
15,835 | ua1-labs/firebug | Fire/Bug/Panel.php | Panel.renderTrace | public function renderTrace($debug_backtrace)
{
$renderTrace = '';
$renderTrace .= '<span class="fs-label">';
foreach ($debug_backtrace as $index => $trace) {
$renderTrace .= '#' . $index . ' ';
if (!empty($trace['file'])) {
$renderTrace .= $trace['file'];
}
if (!empty($trace['line'])) {
$renderTrace .= '(' . $trace['line'] . ') ';
}
if (!empty($trace['class'])) {
$renderTrace .= $trace['class'] . '::';
}
$renderTrace .= $trace['function'] . '()'
. '<br>';
}
$renderTrace .= '</span>';
return $renderTrace;
} | php | public function renderTrace($debug_backtrace)
{
$renderTrace = '';
$renderTrace .= '<span class="fs-label">';
foreach ($debug_backtrace as $index => $trace) {
$renderTrace .= '#' . $index . ' ';
if (!empty($trace['file'])) {
$renderTrace .= $trace['file'];
}
if (!empty($trace['line'])) {
$renderTrace .= '(' . $trace['line'] . ') ';
}
if (!empty($trace['class'])) {
$renderTrace .= $trace['class'] . '::';
}
$renderTrace .= $trace['function'] . '()'
. '<br>';
}
$renderTrace .= '</span>';
return $renderTrace;
} | [
"public",
"function",
"renderTrace",
"(",
"$",
"debug_backtrace",
")",
"{",
"$",
"renderTrace",
"=",
"''",
";",
"$",
"renderTrace",
".=",
"'<span class=\"fs-label\">'",
";",
"foreach",
"(",
"$",
"debug_backtrace",
"as",
"$",
"index",
"=>",
"$",
"trace",
")",
"{",
"$",
"renderTrace",
".=",
"'#'",
".",
"$",
"index",
".",
"' '",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"trace",
"[",
"'file'",
"]",
")",
")",
"{",
"$",
"renderTrace",
".=",
"$",
"trace",
"[",
"'file'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"trace",
"[",
"'line'",
"]",
")",
")",
"{",
"$",
"renderTrace",
".=",
"'('",
".",
"$",
"trace",
"[",
"'line'",
"]",
".",
"') '",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"trace",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"renderTrace",
".=",
"$",
"trace",
"[",
"'class'",
"]",
".",
"'::'",
";",
"}",
"$",
"renderTrace",
".=",
"$",
"trace",
"[",
"'function'",
"]",
".",
"'()'",
".",
"'<br>'",
";",
"}",
"$",
"renderTrace",
".=",
"'</span>'",
";",
"return",
"$",
"renderTrace",
";",
"}"
]
| Returns a rendered debug_backtrace.
@param array $debug_backtrace
@return string | [
"Returns",
"a",
"rendered",
"debug_backtrace",
"."
]
| 70a45b2c0bbf64978641eb07e5f3cddfc1951162 | https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug/Panel.php#L164-L184 |
15,836 | popovserhii/db | src/Db.php | Db.fetch | public function fetch($query)
{
$result = $this->query($query);
return $result->fetch(\PDO::FETCH_ASSOC);
} | php | public function fetch($query)
{
$result = $this->query($query);
return $result->fetch(\PDO::FETCH_ASSOC);
} | [
"public",
"function",
"fetch",
"(",
"$",
"query",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"query",
")",
";",
"return",
"$",
"result",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}"
]
| Return associate array with all data of one row in table
@param $query
@return mixed | [
"Return",
"associate",
"array",
"with",
"all",
"data",
"of",
"one",
"row",
"in",
"table"
]
| 86a1651784eb5763ef5b974233e6356b38b66aaa | https://github.com/popovserhii/db/blob/86a1651784eb5763ef5b974233e6356b38b66aaa/src/Db.php#L173-L178 |
15,837 | popovserhii/db | src/Db.php | Db.addFields | protected function addFields($fields)
{
$fields_array = [];
foreach ($fields as $field => $value) {
$fields_array[] = $field;
}
return '`' . implode('`, `', $fields_array) . '`';
} | php | protected function addFields($fields)
{
$fields_array = [];
foreach ($fields as $field => $value) {
$fields_array[] = $field;
}
return '`' . implode('`, `', $fields_array) . '`';
} | [
"protected",
"function",
"addFields",
"(",
"$",
"fields",
")",
"{",
"$",
"fields_array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"fields_array",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"return",
"'`'",
".",
"implode",
"(",
"'`, `'",
",",
"$",
"fields_array",
")",
".",
"'`'",
";",
"}"
]
| Generates a set of fields that need to be updated or inserted.
For the terms "INSERT INTO".
@param $fields
@return string | [
"Generates",
"a",
"set",
"of",
"fields",
"that",
"need",
"to",
"be",
"updated",
"or",
"inserted",
".",
"For",
"the",
"terms",
"INSERT",
"INTO",
"."
]
| 86a1651784eb5763ef5b974233e6356b38b66aaa | https://github.com/popovserhii/db/blob/86a1651784eb5763ef5b974233e6356b38b66aaa/src/Db.php#L487-L495 |
15,838 | popovserhii/db | src/Db.php | Db._addValue | protected function _addValue($values)
{
$method = $this->getSaveMode();
$value_array = [];
foreach ($values as $key => $value) {
$value_array[] = $this->$method($key, $value);
}
return implode(',', $value_array);
} | php | protected function _addValue($values)
{
$method = $this->getSaveMode();
$value_array = [];
foreach ($values as $key => $value) {
$value_array[] = $this->$method($key, $value);
}
return implode(',', $value_array);
} | [
"protected",
"function",
"_addValue",
"(",
"$",
"values",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"getSaveMode",
"(",
")",
";",
"$",
"value_array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"value_array",
"[",
"]",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"implode",
"(",
"','",
",",
"$",
"value_array",
")",
";",
"}"
]
| Handles one-dimensional array of data and generates a set for one group.
@param array $values
@return string | [
"Handles",
"one",
"-",
"dimensional",
"array",
"of",
"data",
"and",
"generates",
"a",
"set",
"for",
"one",
"group",
"."
]
| 86a1651784eb5763ef5b974233e6356b38b66aaa | https://github.com/popovserhii/db/blob/86a1651784eb5763ef5b974233e6356b38b66aaa/src/Db.php#L519-L528 |
15,839 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceSluggableData.php | StubReplaceSluggableData.getSluggableConfigReplace | protected function getSluggableConfigReplace()
{
$setup = $this->data->sluggable_setup;
if ( ! $this->context->modelIsSluggable || ! $this->data->sluggable || empty($setup)) return '';
$replace = $this->tab() . "protected \$sluggable = [\n";
$rows = [];
if (array_get($setup, 'source')) {
$rows['build_from'] = "'" . $setup['source'] . "'";
}
if (array_get($setup, 'target')) {
$rows['save_to'] = "'" . $setup['target'] . "'";
}
if (config('pxlcms.generator.models.slugs.resluggify_on_update')) {
$rows['on_update'] = 'true';
}
// for now we don't support the locale key, all translated
// tables will have a language_id column in the old CMS.
if (array_get($setup, 'translated') === true) {
$rows['language_key'] = "'" . config('pxlcms.slugs.keys.language', 'language_id') . "'";
$rows['locale_key'] = 'null';
}
$longestPropertyLength = $this->getLongestKey($rows);
foreach ($rows as $property => $value) {
$replace .= $this->tab(2) . "'"
. str_pad($property . "'", $longestPropertyLength + 1)
. " => {$value},\n";
}
$replace .= $this->tab() . "];\n\n";
return $replace;
} | php | protected function getSluggableConfigReplace()
{
$setup = $this->data->sluggable_setup;
if ( ! $this->context->modelIsSluggable || ! $this->data->sluggable || empty($setup)) return '';
$replace = $this->tab() . "protected \$sluggable = [\n";
$rows = [];
if (array_get($setup, 'source')) {
$rows['build_from'] = "'" . $setup['source'] . "'";
}
if (array_get($setup, 'target')) {
$rows['save_to'] = "'" . $setup['target'] . "'";
}
if (config('pxlcms.generator.models.slugs.resluggify_on_update')) {
$rows['on_update'] = 'true';
}
// for now we don't support the locale key, all translated
// tables will have a language_id column in the old CMS.
if (array_get($setup, 'translated') === true) {
$rows['language_key'] = "'" . config('pxlcms.slugs.keys.language', 'language_id') . "'";
$rows['locale_key'] = 'null';
}
$longestPropertyLength = $this->getLongestKey($rows);
foreach ($rows as $property => $value) {
$replace .= $this->tab(2) . "'"
. str_pad($property . "'", $longestPropertyLength + 1)
. " => {$value},\n";
}
$replace .= $this->tab() . "];\n\n";
return $replace;
} | [
"protected",
"function",
"getSluggableConfigReplace",
"(",
")",
"{",
"$",
"setup",
"=",
"$",
"this",
"->",
"data",
"->",
"sluggable_setup",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"context",
"->",
"modelIsSluggable",
"||",
"!",
"$",
"this",
"->",
"data",
"->",
"sluggable",
"||",
"empty",
"(",
"$",
"setup",
")",
")",
"return",
"''",
";",
"$",
"replace",
"=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"protected \\$sluggable = [\\n\"",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"if",
"(",
"array_get",
"(",
"$",
"setup",
",",
"'source'",
")",
")",
"{",
"$",
"rows",
"[",
"'build_from'",
"]",
"=",
"\"'\"",
".",
"$",
"setup",
"[",
"'source'",
"]",
".",
"\"'\"",
";",
"}",
"if",
"(",
"array_get",
"(",
"$",
"setup",
",",
"'target'",
")",
")",
"{",
"$",
"rows",
"[",
"'save_to'",
"]",
"=",
"\"'\"",
".",
"$",
"setup",
"[",
"'target'",
"]",
".",
"\"'\"",
";",
"}",
"if",
"(",
"config",
"(",
"'pxlcms.generator.models.slugs.resluggify_on_update'",
")",
")",
"{",
"$",
"rows",
"[",
"'on_update'",
"]",
"=",
"'true'",
";",
"}",
"// for now we don't support the locale key, all translated",
"// tables will have a language_id column in the old CMS.",
"if",
"(",
"array_get",
"(",
"$",
"setup",
",",
"'translated'",
")",
"===",
"true",
")",
"{",
"$",
"rows",
"[",
"'language_key'",
"]",
"=",
"\"'\"",
".",
"config",
"(",
"'pxlcms.slugs.keys.language'",
",",
"'language_id'",
")",
".",
"\"'\"",
";",
"$",
"rows",
"[",
"'locale_key'",
"]",
"=",
"'null'",
";",
"}",
"$",
"longestPropertyLength",
"=",
"$",
"this",
"->",
"getLongestKey",
"(",
"$",
"rows",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
"2",
")",
".",
"\"'\"",
".",
"str_pad",
"(",
"$",
"property",
".",
"\"'\"",
",",
"$",
"longestPropertyLength",
"+",
"1",
")",
".",
"\" => {$value},\\n\"",
";",
"}",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"];\\n\\n\"",
";",
"return",
"$",
"replace",
";",
"}"
]
| Returns the replacement for the sluggable config placeholder
@return string | [
"Returns",
"the",
"replacement",
"for",
"the",
"sluggable",
"config",
"placeholder"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceSluggableData.php#L18-L60 |
15,840 | jkribeiro/composer-hydration | src/Composer/ComposerHydration.php | ComposerHydration.meatOnBones | public static function meatOnBones(Event $event)
{
$basePath = realpath(".");
$handler = new ComposerHydrationHandler($event, $basePath);
$handler->hydrate();
} | php | public static function meatOnBones(Event $event)
{
$basePath = realpath(".");
$handler = new ComposerHydrationHandler($event, $basePath);
$handler->hydrate();
} | [
"public",
"static",
"function",
"meatOnBones",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"basePath",
"=",
"realpath",
"(",
"\".\"",
")",
";",
"$",
"handler",
"=",
"new",
"ComposerHydrationHandler",
"(",
"$",
"event",
",",
"$",
"basePath",
")",
";",
"$",
"handler",
"->",
"hydrate",
"(",
")",
";",
"}"
]
| Composer callback method for Hydration process.
@param object $event
Composer Event object. | [
"Composer",
"callback",
"method",
"for",
"Hydration",
"process",
"."
]
| b0dd7e9c4a966f664c2df08b3067c1b6f263e226 | https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydration.php#L24-L30 |
15,841 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/Style/StyleRuleSet.php | StyleRuleSet.setSelectors | public function setSelectors($selectors)
{
$this->selectors = [];
if (!is_array($selectors)) {
$selectors = [$selectors];
}
foreach ($selectors as $selector) {
$this->addSelector($selector);
}
return $this;
} | php | public function setSelectors($selectors)
{
$this->selectors = [];
if (!is_array($selectors)) {
$selectors = [$selectors];
}
foreach ($selectors as $selector) {
$this->addSelector($selector);
}
return $this;
} | [
"public",
"function",
"setSelectors",
"(",
"$",
"selectors",
")",
"{",
"$",
"this",
"->",
"selectors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"selectors",
")",
")",
"{",
"$",
"selectors",
"=",
"[",
"$",
"selectors",
"]",
";",
"}",
"foreach",
"(",
"$",
"selectors",
"as",
"$",
"selector",
")",
"{",
"$",
"this",
"->",
"addSelector",
"(",
"$",
"selector",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets the selectors for the style rule.
@param StyleSelector[]|StyleSelector $selectors
@return $this | [
"Sets",
"the",
"selectors",
"for",
"the",
"style",
"rule",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/Style/StyleRuleSet.php#L43-L54 |
15,842 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/Style/StyleRuleSet.php | StyleRuleSet.parseRuleString | protected function parseRuleString($ruleString)
{
foreach ($this->getSelectorStrings($ruleString) as $selectorString)
{
// Check for invalid selector (e.g. if starting with a comma, like in this example from
// the spec ",all { body { background:lime } }")
if ($selectorString === "") {
$this->setIsValid(false);
$this->addValidationError("Invalid selector at '$ruleString'.");
break;
}
$this->addSelector(new StyleSelector($selectorString, $this->getStyleSheet()));
}
} | php | protected function parseRuleString($ruleString)
{
foreach ($this->getSelectorStrings($ruleString) as $selectorString)
{
// Check for invalid selector (e.g. if starting with a comma, like in this example from
// the spec ",all { body { background:lime } }")
if ($selectorString === "") {
$this->setIsValid(false);
$this->addValidationError("Invalid selector at '$ruleString'.");
break;
}
$this->addSelector(new StyleSelector($selectorString, $this->getStyleSheet()));
}
} | [
"protected",
"function",
"parseRuleString",
"(",
"$",
"ruleString",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSelectorStrings",
"(",
"$",
"ruleString",
")",
"as",
"$",
"selectorString",
")",
"{",
"// Check for invalid selector (e.g. if starting with a comma, like in this example from",
"// the spec \",all { body { background:lime } }\")",
"if",
"(",
"$",
"selectorString",
"===",
"\"\"",
")",
"{",
"$",
"this",
"->",
"setIsValid",
"(",
"false",
")",
";",
"$",
"this",
"->",
"addValidationError",
"(",
"\"Invalid selector at '$ruleString'.\"",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"addSelector",
"(",
"new",
"StyleSelector",
"(",
"$",
"selectorString",
",",
"$",
"this",
"->",
"getStyleSheet",
"(",
")",
")",
")",
";",
"}",
"}"
]
| Parses the selector rule.
@param string $ruleString | [
"Parses",
"the",
"selector",
"rule",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/Style/StyleRuleSet.php#L103-L117 |
15,843 | nick-jones/globby | lib/Globby/Builder/Regex.php | Regex.createFromTokens | public function createFromTokens(array $tokens)
{
$buffer = $this->delimiter . '^';
foreach ($tokens as $token) {
$buffer .= $this->translateToken($token);
}
$buffer .= '$' . $this->delimiter . $this->modifiers;
return $buffer;
} | php | public function createFromTokens(array $tokens)
{
$buffer = $this->delimiter . '^';
foreach ($tokens as $token) {
$buffer .= $this->translateToken($token);
}
$buffer .= '$' . $this->delimiter . $this->modifiers;
return $buffer;
} | [
"public",
"function",
"createFromTokens",
"(",
"array",
"$",
"tokens",
")",
"{",
"$",
"buffer",
"=",
"$",
"this",
"->",
"delimiter",
".",
"'^'",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"token",
")",
"{",
"$",
"buffer",
".=",
"$",
"this",
"->",
"translateToken",
"(",
"$",
"token",
")",
";",
"}",
"$",
"buffer",
".=",
"'$'",
".",
"$",
"this",
"->",
"delimiter",
".",
"$",
"this",
"->",
"modifiers",
";",
"return",
"$",
"buffer",
";",
"}"
]
| Creates a regular expression based on the supplied tokens. This return expression will be wrapped by the
value of the 'delimiter' property, and the modifiers contained within the 'modifiers' property will be appended
to the end.
@param array $tokens
@return string | [
"Creates",
"a",
"regular",
"expression",
"based",
"on",
"the",
"supplied",
"tokens",
".",
"This",
"return",
"expression",
"will",
"be",
"wrapped",
"by",
"the",
"value",
"of",
"the",
"delimiter",
"property",
"and",
"the",
"modifiers",
"contained",
"within",
"the",
"modifiers",
"property",
"will",
"be",
"appended",
"to",
"the",
"end",
"."
]
| 5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4 | https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Builder/Regex.php#L79-L90 |
15,844 | nick-jones/globby | lib/Globby/Builder/Regex.php | Regex.translateToken | protected function translateToken(array $token)
{
$identifier = is_string($token[0]) ? null : $token[0];
$value = $token[2];
$result = $this->translateTokenFromIdentifier($identifier, $value);
if ($result === null) {
throw new BuildException(sprintf('No available translation for "%s"', $value));
}
return $result;
} | php | protected function translateToken(array $token)
{
$identifier = is_string($token[0]) ? null : $token[0];
$value = $token[2];
$result = $this->translateTokenFromIdentifier($identifier, $value);
if ($result === null) {
throw new BuildException(sprintf('No available translation for "%s"', $value));
}
return $result;
} | [
"protected",
"function",
"translateToken",
"(",
"array",
"$",
"token",
")",
"{",
"$",
"identifier",
"=",
"is_string",
"(",
"$",
"token",
"[",
"0",
"]",
")",
"?",
"null",
":",
"$",
"token",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"token",
"[",
"2",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"translateTokenFromIdentifier",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"result",
"===",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"sprintf",
"(",
"'No available translation for \"%s\"'",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Translates a token into an appropriate regular expression construct. Various map directly to the same values;
others require some massaging and escaping to make them valid within the constructed in the regular expression.
@param array $token
@return string
@throws BuildException | [
"Translates",
"a",
"token",
"into",
"an",
"appropriate",
"regular",
"expression",
"construct",
".",
"Various",
"map",
"directly",
"to",
"the",
"same",
"values",
";",
"others",
"require",
"some",
"massaging",
"and",
"escaping",
"to",
"make",
"them",
"valid",
"within",
"the",
"constructed",
"in",
"the",
"regular",
"expression",
"."
]
| 5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4 | https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Builder/Regex.php#L100-L112 |
15,845 | nick-jones/globby | lib/Globby/Builder/Regex.php | Regex.translateTokenFromIdentifier | protected function translateTokenFromIdentifier($identifier, $value)
{
$result = null;
if (array_key_exists($identifier, self::$tokenValueMap)) {
$result = $this->translateTokenUsingMap($identifier);
} elseif (array_key_exists($identifier, self::$tokenCallbackMap)) {
$result = $this->translateTokenUsingCallback($identifier, $value);
}
return $result;
} | php | protected function translateTokenFromIdentifier($identifier, $value)
{
$result = null;
if (array_key_exists($identifier, self::$tokenValueMap)) {
$result = $this->translateTokenUsingMap($identifier);
} elseif (array_key_exists($identifier, self::$tokenCallbackMap)) {
$result = $this->translateTokenUsingCallback($identifier, $value);
}
return $result;
} | [
"protected",
"function",
"translateTokenFromIdentifier",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"identifier",
",",
"self",
"::",
"$",
"tokenValueMap",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"translateTokenUsingMap",
"(",
"$",
"identifier",
")",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"identifier",
",",
"self",
"::",
"$",
"tokenCallbackMap",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"translateTokenUsingCallback",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Translates a token based on the identifier flavour.
@param int $identifier
@param string $value
@return string|null | [
"Translates",
"a",
"token",
"based",
"on",
"the",
"identifier",
"flavour",
"."
]
| 5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4 | https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Builder/Regex.php#L121-L132 |
15,846 | nick-jones/globby | lib/Globby/Builder/Regex.php | Regex.translateTokenUsingCallback | protected function translateTokenUsingCallback($identifier, $value)
{
$method = self::$tokenCallbackMap[$identifier];
return call_user_func(
[$this, $method],
$value
);
} | php | protected function translateTokenUsingCallback($identifier, $value)
{
$method = self::$tokenCallbackMap[$identifier];
return call_user_func(
[$this, $method],
$value
);
} | [
"protected",
"function",
"translateTokenUsingCallback",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"self",
"::",
"$",
"tokenCallbackMap",
"[",
"$",
"identifier",
"]",
";",
"return",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"$",
"value",
")",
";",
"}"
]
| Calls an internal method to retrieve an appropriate value for use within the regex.
@param int $identifier
@param string $value
@return string | [
"Calls",
"an",
"internal",
"method",
"to",
"retrieve",
"an",
"appropriate",
"value",
"for",
"use",
"within",
"the",
"regex",
"."
]
| 5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4 | https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Builder/Regex.php#L152-L160 |
15,847 | alexpts/psr15-middlewares | src/ErrorToJsonResponse.php | ErrorToJsonResponse.closeOutputBuffers | protected function closeOutputBuffers(int $targetLevel = 0, bool $flush = false): void
{
$status = ob_get_status(true);
$level = \count($status);
while ($level-- > $targetLevel) {
$flush ? ob_end_flush() : ob_end_clean();
}
} | php | protected function closeOutputBuffers(int $targetLevel = 0, bool $flush = false): void
{
$status = ob_get_status(true);
$level = \count($status);
while ($level-- > $targetLevel) {
$flush ? ob_end_flush() : ob_end_clean();
}
} | [
"protected",
"function",
"closeOutputBuffers",
"(",
"int",
"$",
"targetLevel",
"=",
"0",
",",
"bool",
"$",
"flush",
"=",
"false",
")",
":",
"void",
"{",
"$",
"status",
"=",
"ob_get_status",
"(",
"true",
")",
";",
"$",
"level",
"=",
"\\",
"count",
"(",
"$",
"status",
")",
";",
"while",
"(",
"$",
"level",
"--",
">",
"$",
"targetLevel",
")",
"{",
"$",
"flush",
"?",
"ob_end_flush",
"(",
")",
":",
"ob_end_clean",
"(",
")",
";",
"}",
"}"
]
| Cleans or flushes output buffers up to target level.
Resulting level can be greater than target level if a non-removable buffer has been encountered.
@param int $targetLevel
@param bool $flush
@see original Symfony Response::closeOutputBuffers | [
"Cleans",
"or",
"flushes",
"output",
"buffers",
"up",
"to",
"target",
"level",
".",
"Resulting",
"level",
"can",
"be",
"greater",
"than",
"target",
"level",
"if",
"a",
"non",
"-",
"removable",
"buffer",
"has",
"been",
"encountered",
"."
]
| bff2887d5af01c54d9288fd19c20f0f593b69358 | https://github.com/alexpts/psr15-middlewares/blob/bff2887d5af01c54d9288fd19c20f0f593b69358/src/ErrorToJsonResponse.php#L85-L93 |
15,848 | drunomics/service-utils | src/Core/Render/RendererTrait.php | RendererTrait.getrenderer | public function getrenderer() {
if (empty($this->renderer)) {
$this->renderer = \Drupal::service('renderer');
}
return $this->renderer;
} | php | public function getrenderer() {
if (empty($this->renderer)) {
$this->renderer = \Drupal::service('renderer');
}
return $this->renderer;
} | [
"public",
"function",
"getrenderer",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"renderer",
")",
")",
"{",
"$",
"this",
"->",
"renderer",
"=",
"\\",
"Drupal",
"::",
"service",
"(",
"'renderer'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"renderer",
";",
"}"
]
| Gets the renderer.
@return \Drupal\Core\Render\RendererInterface
The renderer. | [
"Gets",
"the",
"renderer",
"."
]
| 56761750043132365ef4ae5d9e0cf4263459328f | https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/Render/RendererTrait.php#L38-L43 |
15,849 | model3/model3 | src/Model3/Db/Table.php | Table.describe | protected function describe()
{
if(is_null($this->_tableName) == false)
{
$this->_query = 'DESCRIBE '.$this->_tableName;
if($this->_db->execute($this->_query) !== false)
{
$res = $this->_db->getAllRows();
unset($this->_fields);
unset($this->_primaryKey);
$this->_fields = array();
foreach($res as $r)
{
$this->_fields[] = $r['Field'];
if($r['Key'] == 'PRI')
$this->_primaryKey = $r['Field'];
}
return true;
}
}
return false;
} | php | protected function describe()
{
if(is_null($this->_tableName) == false)
{
$this->_query = 'DESCRIBE '.$this->_tableName;
if($this->_db->execute($this->_query) !== false)
{
$res = $this->_db->getAllRows();
unset($this->_fields);
unset($this->_primaryKey);
$this->_fields = array();
foreach($res as $r)
{
$this->_fields[] = $r['Field'];
if($r['Key'] == 'PRI')
$this->_primaryKey = $r['Field'];
}
return true;
}
}
return false;
} | [
"protected",
"function",
"describe",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_tableName",
")",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"_query",
"=",
"'DESCRIBE '",
".",
"$",
"this",
"->",
"_tableName",
";",
"if",
"(",
"$",
"this",
"->",
"_db",
"->",
"execute",
"(",
"$",
"this",
"->",
"_query",
")",
"!==",
"false",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"_db",
"->",
"getAllRows",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_fields",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_primaryKey",
")",
";",
"$",
"this",
"->",
"_fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"res",
"as",
"$",
"r",
")",
"{",
"$",
"this",
"->",
"_fields",
"[",
"]",
"=",
"$",
"r",
"[",
"'Field'",
"]",
";",
"if",
"(",
"$",
"r",
"[",
"'Key'",
"]",
"==",
"'PRI'",
")",
"$",
"this",
"->",
"_primaryKey",
"=",
"$",
"r",
"[",
"'Field'",
"]",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| for now, this method is intended just for tables with one primary key | [
"for",
"now",
"this",
"method",
"is",
"intended",
"just",
"for",
"tables",
"with",
"one",
"primary",
"key"
]
| c62858013fce9bac597d47a2475c69aebe7d6209 | https://github.com/model3/model3/blob/c62858013fce9bac597d47a2475c69aebe7d6209/src/Model3/Db/Table.php#L98-L119 |
15,850 | model3/model3 | src/Model3/Db/Table.php | Table.insert | public function insert($data)
{
//var_dump($data);
unset($this->_error);
if(is_array($data))
{
$fields = '';
$values = '';
reset($data);
for($counter = 0, $maxIndex = count($data), $valid = true; $counter < $maxIndex && $valid == true; $counter ++)
{
$elementKey = key($data);
$elementKey = $this->_db->escape($elementKey);
$valid = in_array($elementKey, $this->_fields);
if($valid == true)
{
$element = $data[$elementKey];
$element = $this->_db->escape($element);
if(is_object($element) == true)
{
$valid = false;
$this->_error = 'field: '.$elementKey.'is an object (this method just accept strings)';
}
else
{
if(is_numeric($element) == false)
$values .= '\''.$element.'\'';
else
$values .= $element;
$fields .= $elementKey;
if(($counter + 1) < $maxIndex)
{
$fields .= ',';
$values .= ',';
}
next($data);
}
}
else
{
$this->_error = 'field: '.$elementKey.' is not defined in '.$this->_tableName;
}
}
if($valid == true)
{
$this->_query = 'INSERT INTO '.$this->_tableName.'('.$fields.') VALUES('.$values.')';
if($this->_db->execute($this->_query) !== false)
{
return $this->_db->insertId();
}
else
{
$this->_error = $this->_db->errorStr();
}
}
}
return false;
} | php | public function insert($data)
{
//var_dump($data);
unset($this->_error);
if(is_array($data))
{
$fields = '';
$values = '';
reset($data);
for($counter = 0, $maxIndex = count($data), $valid = true; $counter < $maxIndex && $valid == true; $counter ++)
{
$elementKey = key($data);
$elementKey = $this->_db->escape($elementKey);
$valid = in_array($elementKey, $this->_fields);
if($valid == true)
{
$element = $data[$elementKey];
$element = $this->_db->escape($element);
if(is_object($element) == true)
{
$valid = false;
$this->_error = 'field: '.$elementKey.'is an object (this method just accept strings)';
}
else
{
if(is_numeric($element) == false)
$values .= '\''.$element.'\'';
else
$values .= $element;
$fields .= $elementKey;
if(($counter + 1) < $maxIndex)
{
$fields .= ',';
$values .= ',';
}
next($data);
}
}
else
{
$this->_error = 'field: '.$elementKey.' is not defined in '.$this->_tableName;
}
}
if($valid == true)
{
$this->_query = 'INSERT INTO '.$this->_tableName.'('.$fields.') VALUES('.$values.')';
if($this->_db->execute($this->_query) !== false)
{
return $this->_db->insertId();
}
else
{
$this->_error = $this->_db->errorStr();
}
}
}
return false;
} | [
"public",
"function",
"insert",
"(",
"$",
"data",
")",
"{",
"//var_dump($data);",
"unset",
"(",
"$",
"this",
"->",
"_error",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"fields",
"=",
"''",
";",
"$",
"values",
"=",
"''",
";",
"reset",
"(",
"$",
"data",
")",
";",
"for",
"(",
"$",
"counter",
"=",
"0",
",",
"$",
"maxIndex",
"=",
"count",
"(",
"$",
"data",
")",
",",
"$",
"valid",
"=",
"true",
";",
"$",
"counter",
"<",
"$",
"maxIndex",
"&&",
"$",
"valid",
"==",
"true",
";",
"$",
"counter",
"++",
")",
"{",
"$",
"elementKey",
"=",
"key",
"(",
"$",
"data",
")",
";",
"$",
"elementKey",
"=",
"$",
"this",
"->",
"_db",
"->",
"escape",
"(",
"$",
"elementKey",
")",
";",
"$",
"valid",
"=",
"in_array",
"(",
"$",
"elementKey",
",",
"$",
"this",
"->",
"_fields",
")",
";",
"if",
"(",
"$",
"valid",
"==",
"true",
")",
"{",
"$",
"element",
"=",
"$",
"data",
"[",
"$",
"elementKey",
"]",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"_db",
"->",
"escape",
"(",
"$",
"element",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"element",
")",
"==",
"true",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"$",
"this",
"->",
"_error",
"=",
"'field: '",
".",
"$",
"elementKey",
".",
"'is an object (this method just accept strings)'",
";",
"}",
"else",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"element",
")",
"==",
"false",
")",
"$",
"values",
".=",
"'\\''",
".",
"$",
"element",
".",
"'\\''",
";",
"else",
"$",
"values",
".=",
"$",
"element",
";",
"$",
"fields",
".=",
"$",
"elementKey",
";",
"if",
"(",
"(",
"$",
"counter",
"+",
"1",
")",
"<",
"$",
"maxIndex",
")",
"{",
"$",
"fields",
".=",
"','",
";",
"$",
"values",
".=",
"','",
";",
"}",
"next",
"(",
"$",
"data",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_error",
"=",
"'field: '",
".",
"$",
"elementKey",
".",
"' is not defined in '",
".",
"$",
"this",
"->",
"_tableName",
";",
"}",
"}",
"if",
"(",
"$",
"valid",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"_query",
"=",
"'INSERT INTO '",
".",
"$",
"this",
"->",
"_tableName",
".",
"'('",
".",
"$",
"fields",
".",
"') VALUES('",
".",
"$",
"values",
".",
"')'",
";",
"if",
"(",
"$",
"this",
"->",
"_db",
"->",
"execute",
"(",
"$",
"this",
"->",
"_query",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"_db",
"->",
"insertId",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_error",
"=",
"$",
"this",
"->",
"_db",
"->",
"errorStr",
"(",
")",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| data is an associative array containing the name of the field and its value | [
"data",
"is",
"an",
"associative",
"array",
"containing",
"the",
"name",
"of",
"the",
"field",
"and",
"its",
"value"
]
| c62858013fce9bac597d47a2475c69aebe7d6209 | https://github.com/model3/model3/blob/c62858013fce9bac597d47a2475c69aebe7d6209/src/Model3/Db/Table.php#L122-L179 |
15,851 | ejsmont-artur/phpProxyBuilder | src/PhpProxyBuilder/Adapter/Intrumentor/SimpleArrayIntrumentor.php | SimpleArrayIntrumentor.incrementTimer | public function incrementTimer($name, $time) {
if (!isset($this->timers[$name])) {
$this->timers[$name] = 0;
}
$this->timers[$name] += $this->getTime() - $time;
} | php | public function incrementTimer($name, $time) {
if (!isset($this->timers[$name])) {
$this->timers[$name] = 0;
}
$this->timers[$name] += $this->getTime() - $time;
} | [
"public",
"function",
"incrementTimer",
"(",
"$",
"name",
",",
"$",
"time",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"timers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"timers",
"[",
"$",
"name",
"]",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"timers",
"[",
"$",
"name",
"]",
"+=",
"$",
"this",
"->",
"getTime",
"(",
")",
"-",
"$",
"time",
";",
"}"
]
| Increments named timer.
@param string $name name of the timer
@param mixed $time time value acquired from getTime() method
@return InstrumentorInterface returns $this for chaining | [
"Increments",
"named",
"timer",
"."
]
| ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480 | https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Adapter/Intrumentor/SimpleArrayIntrumentor.php#L67-L72 |
15,852 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/TraitVendorPrefix.php | TraitVendorPrefix.setVendorPrefix | public function setVendorPrefix($vendorPrefix)
{
if (is_string($vendorPrefix)) {
$this->vendorPrefix = $vendorPrefix;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($vendorPrefix). "' for argument 'vendorPrefix' given."
);
}
} | php | public function setVendorPrefix($vendorPrefix)
{
if (is_string($vendorPrefix)) {
$this->vendorPrefix = $vendorPrefix;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($vendorPrefix). "' for argument 'vendorPrefix' given."
);
}
} | [
"public",
"function",
"setVendorPrefix",
"(",
"$",
"vendorPrefix",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"vendorPrefix",
")",
")",
"{",
"$",
"this",
"->",
"vendorPrefix",
"=",
"$",
"vendorPrefix",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"vendorPrefix",
")",
".",
"\"' for argument 'vendorPrefix' given.\"",
")",
";",
"}",
"}"
]
| Sets the vendor prefix.
@param $vendorPrefix | [
"Sets",
"the",
"vendor",
"prefix",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitVendorPrefix.php#L13-L22 |
15,853 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/TraitVendorPrefix.php | TraitVendorPrefix.getVendorPrefixRegExp | public static function getVendorPrefixRegExp($delimiter = null)
{
$vendorPrefixValues = self::getVendorPrefixValues();
foreach ($vendorPrefixValues as $vendorPrefixKey => $vendorPrefixValue) {
$vendorPrefixValues[$vendorPrefixKey] = preg_quote($vendorPrefixValue, $delimiter);
}
return implode('|', $vendorPrefixValues);
} | php | public static function getVendorPrefixRegExp($delimiter = null)
{
$vendorPrefixValues = self::getVendorPrefixValues();
foreach ($vendorPrefixValues as $vendorPrefixKey => $vendorPrefixValue) {
$vendorPrefixValues[$vendorPrefixKey] = preg_quote($vendorPrefixValue, $delimiter);
}
return implode('|', $vendorPrefixValues);
} | [
"public",
"static",
"function",
"getVendorPrefixRegExp",
"(",
"$",
"delimiter",
"=",
"null",
")",
"{",
"$",
"vendorPrefixValues",
"=",
"self",
"::",
"getVendorPrefixValues",
"(",
")",
";",
"foreach",
"(",
"$",
"vendorPrefixValues",
"as",
"$",
"vendorPrefixKey",
"=>",
"$",
"vendorPrefixValue",
")",
"{",
"$",
"vendorPrefixValues",
"[",
"$",
"vendorPrefixKey",
"]",
"=",
"preg_quote",
"(",
"$",
"vendorPrefixValue",
",",
"$",
"delimiter",
")",
";",
"}",
"return",
"implode",
"(",
"'|'",
",",
"$",
"vendorPrefixValues",
")",
";",
"}"
]
| Returns a partial regular expression of known vendor prefixes.
@param string|null $delimiter
@return string | [
"Returns",
"a",
"partial",
"regular",
"expression",
"of",
"known",
"vendor",
"prefixes",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitVendorPrefix.php#L67-L74 |
15,854 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.count | public function count($filters = [], $options = [])
{
return $this->collection->count($this->castQuery($filters), $options);
} | php | public function count($filters = [], $options = [])
{
return $this->collection->count($this->castQuery($filters), $options);
} | [
"public",
"function",
"count",
"(",
"$",
"filters",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"collection",
"->",
"count",
"(",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"filters",
")",
",",
"$",
"options",
")",
";",
"}"
]
| Count corresponding documents for filters
@param array $filters Object
@param array $options Options for the query
@return int Number of corresponding documents | [
"Count",
"corresponding",
"documents",
"for",
"filters"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L131-L134 |
15,855 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.distinct | public function distinct($fieldName, $filters = [], $options = [])
{
$field = $fieldName;
$propInfos = $this->classMetadata->getPropertyInfoForField($fieldName);
if (!$propInfos) {
$propInfos = $this->classMetadata->getPropertyInfo($fieldName);
}
if (isset($propInfos)) {
$field = $propInfos->getField();
if ($propInfos->getMetadata()) {
$field = "metadata." . $field;
}
}
$filters = $this->castQuery($filters);
$result = $this->collection->distinct($field, $filters, $options);
return $result;
} | php | public function distinct($fieldName, $filters = [], $options = [])
{
$field = $fieldName;
$propInfos = $this->classMetadata->getPropertyInfoForField($fieldName);
if (!$propInfos) {
$propInfos = $this->classMetadata->getPropertyInfo($fieldName);
}
if (isset($propInfos)) {
$field = $propInfos->getField();
if ($propInfos->getMetadata()) {
$field = "metadata." . $field;
}
}
$filters = $this->castQuery($filters);
$result = $this->collection->distinct($field, $filters, $options);
return $result;
} | [
"public",
"function",
"distinct",
"(",
"$",
"fieldName",
",",
"$",
"filters",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"field",
"=",
"$",
"fieldName",
";",
"$",
"propInfos",
"=",
"$",
"this",
"->",
"classMetadata",
"->",
"getPropertyInfoForField",
"(",
"$",
"fieldName",
")",
";",
"if",
"(",
"!",
"$",
"propInfos",
")",
"{",
"$",
"propInfos",
"=",
"$",
"this",
"->",
"classMetadata",
"->",
"getPropertyInfo",
"(",
"$",
"fieldName",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"propInfos",
")",
")",
"{",
"$",
"field",
"=",
"$",
"propInfos",
"->",
"getField",
"(",
")",
";",
"if",
"(",
"$",
"propInfos",
"->",
"getMetadata",
"(",
")",
")",
"{",
"$",
"field",
"=",
"\"metadata.\"",
".",
"$",
"field",
";",
"}",
"}",
"$",
"filters",
"=",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"filters",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"collection",
"->",
"distinct",
"(",
"$",
"field",
",",
"$",
"filters",
",",
"$",
"options",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get distinct value for a field
@param string $fieldName Name of the field
@param array $filters Filters of query
@param array $options Options of query
@return array List of distinct values | [
"Get",
"distinct",
"value",
"for",
"a",
"field"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L144-L165 |
15,856 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.findAll | public function findAll($projections = [], $sorts = [], $options = [])
{
$options = $this->createOption($projections, $sorts, $options);
$result = $this->collection->find([], $options);
if (!isset($options['iterator']) || $options['iterator'] === false) {
$objects = [];
foreach ($result as $datas) {
if (null != ($object = $this->createObject($datas, $options))) {
$objects[] = $object;
}
}
return $objects;
} else {
$iteratorClass = $options['iterator'];
$iterator = $iteratorClass === true ? new DocumentIterator($result, $this->modelName, $this) : new $iteratorClass($result, $this->modelName, $this);
if (isset($options['readOnly']) && $options['readOnly'] == true) {
$iterator->readOnly();
}
return $iterator;
}
} | php | public function findAll($projections = [], $sorts = [], $options = [])
{
$options = $this->createOption($projections, $sorts, $options);
$result = $this->collection->find([], $options);
if (!isset($options['iterator']) || $options['iterator'] === false) {
$objects = [];
foreach ($result as $datas) {
if (null != ($object = $this->createObject($datas, $options))) {
$objects[] = $object;
}
}
return $objects;
} else {
$iteratorClass = $options['iterator'];
$iterator = $iteratorClass === true ? new DocumentIterator($result, $this->modelName, $this) : new $iteratorClass($result, $this->modelName, $this);
if (isset($options['readOnly']) && $options['readOnly'] == true) {
$iterator->readOnly();
}
return $iterator;
}
} | [
"public",
"function",
"findAll",
"(",
"$",
"projections",
"=",
"[",
"]",
",",
"$",
"sorts",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"createOption",
"(",
"$",
"projections",
",",
"$",
"sorts",
",",
"$",
"options",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"collection",
"->",
"find",
"(",
"[",
"]",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'iterator'",
"]",
")",
"||",
"$",
"options",
"[",
"'iterator'",
"]",
"===",
"false",
")",
"{",
"$",
"objects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"datas",
")",
"{",
"if",
"(",
"null",
"!=",
"(",
"$",
"object",
"=",
"$",
"this",
"->",
"createObject",
"(",
"$",
"datas",
",",
"$",
"options",
")",
")",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"$",
"object",
";",
"}",
"}",
"return",
"$",
"objects",
";",
"}",
"else",
"{",
"$",
"iteratorClass",
"=",
"$",
"options",
"[",
"'iterator'",
"]",
";",
"$",
"iterator",
"=",
"$",
"iteratorClass",
"===",
"true",
"?",
"new",
"DocumentIterator",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"modelName",
",",
"$",
"this",
")",
":",
"new",
"$",
"iteratorClass",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"modelName",
",",
"$",
"this",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'readOnly'",
"]",
")",
"&&",
"$",
"options",
"[",
"'readOnly'",
"]",
"==",
"true",
")",
"{",
"$",
"iterator",
"->",
"readOnly",
"(",
")",
";",
"}",
"return",
"$",
"iterator",
";",
"}",
"}"
]
| Find all document of the collection
Options :
* readOnly : boolean - When false, flush will not update object
* iterator : boolean|string - Return DocumentIterator if true (or specified class if is string)
@see MongoDB\Operation\Find::__construct for more option
@param array $projections Projection of the query
@param array $sorts Sort options
@param array $options Options for the query
@return array Array containing all the document of the collection | [
"Find",
"all",
"document",
"of",
"the",
"collection"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L201-L223 |
15,857 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.findAndModifyOneBy | public function findAndModifyOneBy($filters = [], $update = [], $projections = [], $sorts = [], $options = [])
{
$options = $this->createOption($projections, $sorts, $options);
$filters = $this->castQuery($filters);
$update = $this->castQuery($update);
$result = (array) $this->collection->findOneAndUpdate($filters, $update, $options);
return $this->createObject($result, $options);
} | php | public function findAndModifyOneBy($filters = [], $update = [], $projections = [], $sorts = [], $options = [])
{
$options = $this->createOption($projections, $sorts, $options);
$filters = $this->castQuery($filters);
$update = $this->castQuery($update);
$result = (array) $this->collection->findOneAndUpdate($filters, $update, $options);
return $this->createObject($result, $options);
} | [
"public",
"function",
"findAndModifyOneBy",
"(",
"$",
"filters",
"=",
"[",
"]",
",",
"$",
"update",
"=",
"[",
"]",
",",
"$",
"projections",
"=",
"[",
"]",
",",
"$",
"sorts",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"createOption",
"(",
"$",
"projections",
",",
"$",
"sorts",
",",
"$",
"options",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"filters",
")",
";",
"$",
"update",
"=",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"update",
")",
";",
"$",
"result",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"collection",
"->",
"findOneAndUpdate",
"(",
"$",
"filters",
",",
"$",
"update",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"createObject",
"(",
"$",
"result",
",",
"$",
"options",
")",
";",
"}"
]
| Find a document and make specified update on it
Options :
* readOnly : boolean - When false, flush will not update object
@see MongoDB\Operation\FindAndModify::__construct for more option
@param array $filters Filters
@param array $update Update to perform
@param array $projections Projection of the query
@param array $sorts Sorts specification
@param array $options Options for the query
@param array $options
@return void | [
"Find",
"a",
"document",
"and",
"make",
"specified",
"update",
"on",
"it"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L305-L316 |
15,858 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.getTailableCursor | public function getTailableCursor($filters = [], $options = [])
{
$options['cursorType'] = \MongoDB\Operation\Find::TAILABLE_AWAIT;
return $this->collection->find($this->castQuery($filters), $options);
} | php | public function getTailableCursor($filters = [], $options = [])
{
$options['cursorType'] = \MongoDB\Operation\Find::TAILABLE_AWAIT;
return $this->collection->find($this->castQuery($filters), $options);
} | [
"public",
"function",
"getTailableCursor",
"(",
"$",
"filters",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"[",
"'cursorType'",
"]",
"=",
"\\",
"MongoDB",
"\\",
"Operation",
"\\",
"Find",
"::",
"TAILABLE_AWAIT",
";",
"return",
"$",
"this",
"->",
"collection",
"->",
"find",
"(",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"filters",
")",
",",
"$",
"options",
")",
";",
"}"
]
| Get tailable cursor for query
@param array $filters Filters of query
@param array $options Option (Tailable setted as default)
@return \MongoDB\Driver\TailableCursor A tailable cursor | [
"Get",
"tailable",
"cursor",
"for",
"query"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L325-L330 |
15,859 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.insertOne | public function insertOne($document, $options = [])
{
$query = new InsertOne($this->documentManager, $this, $document, $options);
if (isset($options['getQuery']) && $options['getQuery']) {
return $query;
} else {
return $query->execute();
}
} | php | public function insertOne($document, $options = [])
{
$query = new InsertOne($this->documentManager, $this, $document, $options);
if (isset($options['getQuery']) && $options['getQuery']) {
return $query;
} else {
return $query->execute();
}
} | [
"public",
"function",
"insertOne",
"(",
"$",
"document",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"new",
"InsertOne",
"(",
"$",
"this",
"->",
"documentManager",
",",
"$",
"this",
",",
"$",
"document",
",",
"$",
"options",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'getQuery'",
"]",
")",
"&&",
"$",
"options",
"[",
"'getQuery'",
"]",
")",
"{",
"return",
"$",
"query",
";",
"}",
"else",
"{",
"return",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"}",
"}"
]
| Insert a document in collection
@param mixed $document Document to insert
@param array $options Options
@return void | [
"Insert",
"a",
"document",
"in",
"collection"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L339-L347 |
15,860 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.insertMany | public function insertMany($documents, $options = [])
{
$insertQuery = [];
foreach ($documents as $document) {
$this->classMetadata->getEventManager()->execute(EventManager::EVENT_PRE_INSERT, $document);
$query = $this->hydrator->unhydrate($document);
$idGen = $this->classMetadata->getIdGenerator();
if ($idGen !== null) {
if (!class_exists($idGen) || !is_subclass_of($idGen, AbstractIdGenerator::class)) {
throw new \Exception('Bad ID generator : class \'' . $idGen . '\' not exists or not extends JPC\MongoDB\ODM\Id\AbstractIdGenerator');
}
$generator = new $idGen();
$query['_id'] = $generator->generate($this->documentManager, $document);
}
$insertQuery[] = $query;
}
$result = $this->collection->insertMany($insertQuery, $options);
if ($result->isAcknowledged()) {
foreach ($result->getInsertedIds() as $key => $id) {
if ($id instanceof \stdClass) {
$id = (array) $id;
}
$insertQuery[$key]["_id"] = $id;
$this->hydrator->hydrate($documents[$key], $insertQuery[$key]);
$this->classMetadata->getEventManager()->execute(EventManager::EVENT_POST_INSERT, $documents[$key]);
$this->cacheObject($documents[$key]);
}
return true;
} else {
foreach ($documents as $document) {
$this->cacheObject($document);
// $this->documentManager->removeObject();
}
return false;
}
} | php | public function insertMany($documents, $options = [])
{
$insertQuery = [];
foreach ($documents as $document) {
$this->classMetadata->getEventManager()->execute(EventManager::EVENT_PRE_INSERT, $document);
$query = $this->hydrator->unhydrate($document);
$idGen = $this->classMetadata->getIdGenerator();
if ($idGen !== null) {
if (!class_exists($idGen) || !is_subclass_of($idGen, AbstractIdGenerator::class)) {
throw new \Exception('Bad ID generator : class \'' . $idGen . '\' not exists or not extends JPC\MongoDB\ODM\Id\AbstractIdGenerator');
}
$generator = new $idGen();
$query['_id'] = $generator->generate($this->documentManager, $document);
}
$insertQuery[] = $query;
}
$result = $this->collection->insertMany($insertQuery, $options);
if ($result->isAcknowledged()) {
foreach ($result->getInsertedIds() as $key => $id) {
if ($id instanceof \stdClass) {
$id = (array) $id;
}
$insertQuery[$key]["_id"] = $id;
$this->hydrator->hydrate($documents[$key], $insertQuery[$key]);
$this->classMetadata->getEventManager()->execute(EventManager::EVENT_POST_INSERT, $documents[$key]);
$this->cacheObject($documents[$key]);
}
return true;
} else {
foreach ($documents as $document) {
$this->cacheObject($document);
// $this->documentManager->removeObject();
}
return false;
}
} | [
"public",
"function",
"insertMany",
"(",
"$",
"documents",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"insertQuery",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"documents",
"as",
"$",
"document",
")",
"{",
"$",
"this",
"->",
"classMetadata",
"->",
"getEventManager",
"(",
")",
"->",
"execute",
"(",
"EventManager",
"::",
"EVENT_PRE_INSERT",
",",
"$",
"document",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"hydrator",
"->",
"unhydrate",
"(",
"$",
"document",
")",
";",
"$",
"idGen",
"=",
"$",
"this",
"->",
"classMetadata",
"->",
"getIdGenerator",
"(",
")",
";",
"if",
"(",
"$",
"idGen",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"idGen",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"idGen",
",",
"AbstractIdGenerator",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Bad ID generator : class \\''",
".",
"$",
"idGen",
".",
"'\\' not exists or not extends JPC\\MongoDB\\ODM\\Id\\AbstractIdGenerator'",
")",
";",
"}",
"$",
"generator",
"=",
"new",
"$",
"idGen",
"(",
")",
";",
"$",
"query",
"[",
"'_id'",
"]",
"=",
"$",
"generator",
"->",
"generate",
"(",
"$",
"this",
"->",
"documentManager",
",",
"$",
"document",
")",
";",
"}",
"$",
"insertQuery",
"[",
"]",
"=",
"$",
"query",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"collection",
"->",
"insertMany",
"(",
"$",
"insertQuery",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isAcknowledged",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"result",
"->",
"getInsertedIds",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"\\",
"stdClass",
")",
"{",
"$",
"id",
"=",
"(",
"array",
")",
"$",
"id",
";",
"}",
"$",
"insertQuery",
"[",
"$",
"key",
"]",
"[",
"\"_id\"",
"]",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"documents",
"[",
"$",
"key",
"]",
",",
"$",
"insertQuery",
"[",
"$",
"key",
"]",
")",
";",
"$",
"this",
"->",
"classMetadata",
"->",
"getEventManager",
"(",
")",
"->",
"execute",
"(",
"EventManager",
"::",
"EVENT_POST_INSERT",
",",
"$",
"documents",
"[",
"$",
"key",
"]",
")",
";",
"$",
"this",
"->",
"cacheObject",
"(",
"$",
"documents",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"documents",
"as",
"$",
"document",
")",
"{",
"$",
"this",
"->",
"cacheObject",
"(",
"$",
"document",
")",
";",
"// $this->documentManager->removeObject();",
"}",
"return",
"false",
";",
"}",
"}"
]
| Insert multiple documents in collection
@param mixed $documents Documents to insert
@param array $options Options
@return void | [
"Insert",
"multiple",
"documents",
"in",
"collection"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L356-L398 |
15,861 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.updateMany | public function updateMany($filters, $update, $options = [])
{
$result = $this->collection->updateMany($this->castQuery($filters), $update, $options);
if ($result->isAcknowledged()) {
return true;
} else {
return false;
}
} | php | public function updateMany($filters, $update, $options = [])
{
$result = $this->collection->updateMany($this->castQuery($filters), $update, $options);
if ($result->isAcknowledged()) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"updateMany",
"(",
"$",
"filters",
",",
"$",
"update",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"collection",
"->",
"updateMany",
"(",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"filters",
")",
",",
"$",
"update",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isAcknowledged",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
]
| Update many document
@param array $filters Filters
@param array $update Update to perform
@param array $options Options
@return void | [
"Update",
"many",
"document"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L426-L435 |
15,862 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.deleteMany | public function deleteMany($filter, $options = [])
{
$filter = $this->castQuery($filter);
$result = $this->collection->deleteMany($filter, $options);
if ($result->isAcknowledged()) {
return true;
} else {
return false;
}
} | php | public function deleteMany($filter, $options = [])
{
$filter = $this->castQuery($filter);
$result = $this->collection->deleteMany($filter, $options);
if ($result->isAcknowledged()) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"deleteMany",
"(",
"$",
"filter",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"filter",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"collection",
"->",
"deleteMany",
"(",
"$",
"filter",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isAcknowledged",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
]
| Delete many document
@param array $filter Filter wich match to objects to delete
@param array $options Options
@return void | [
"Delete",
"many",
"document"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L479-L489 |
15,863 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.createObject | protected function createObject($data, $options = [])
{
$object = null;
if ($data != null) {
$id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : null;
$model = $this->getModelName();
$softHydrate = false;
if (null !== $this->documentManager->getObject($id)) {
$softHydrate = true;
$object = $this->documentManager->getObject($id);
} else {
$object = new $this->modelName();
}
$this->hydrator->hydrate($object, $data, $softHydrate);
$this->classMetadata->getEventManager()->execute(EventManager::EVENT_POST_LOAD, $object);
if (!isset($options['readOnly']) || $options['readOnly'] != true) {
$oid = spl_object_hash($object);
$data = $this->hydrator->unhydrate($object);
$id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : $oid;
$projection = isset($options['projection']) ? $options['projection'] : [];
$this->lastProjectionCache->save($id, $projection);
$this->cacheObject($object);
$this->documentManager->addObject($object, DocumentManager::OBJ_MANAGED, $this);
}
return $object;
}
return $object;
} | php | protected function createObject($data, $options = [])
{
$object = null;
if ($data != null) {
$id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : null;
$model = $this->getModelName();
$softHydrate = false;
if (null !== $this->documentManager->getObject($id)) {
$softHydrate = true;
$object = $this->documentManager->getObject($id);
} else {
$object = new $this->modelName();
}
$this->hydrator->hydrate($object, $data, $softHydrate);
$this->classMetadata->getEventManager()->execute(EventManager::EVENT_POST_LOAD, $object);
if (!isset($options['readOnly']) || $options['readOnly'] != true) {
$oid = spl_object_hash($object);
$data = $this->hydrator->unhydrate($object);
$id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : $oid;
$projection = isset($options['projection']) ? $options['projection'] : [];
$this->lastProjectionCache->save($id, $projection);
$this->cacheObject($object);
$this->documentManager->addObject($object, DocumentManager::OBJ_MANAGED, $this);
}
return $object;
}
return $object;
} | [
"protected",
"function",
"createObject",
"(",
"$",
"data",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"object",
"=",
"null",
";",
"if",
"(",
"$",
"data",
"!=",
"null",
")",
"{",
"$",
"id",
"=",
"isset",
"(",
"$",
"data",
"[",
"'_id'",
"]",
")",
"?",
"serialize",
"(",
"$",
"data",
"[",
"'_id'",
"]",
")",
".",
"$",
"this",
"->",
"getCollection",
"(",
")",
":",
"null",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"$",
"softHydrate",
"=",
"false",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"documentManager",
"->",
"getObject",
"(",
"$",
"id",
")",
")",
"{",
"$",
"softHydrate",
"=",
"true",
";",
"$",
"object",
"=",
"$",
"this",
"->",
"documentManager",
"->",
"getObject",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"object",
"=",
"new",
"$",
"this",
"->",
"modelName",
"(",
")",
";",
"}",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"object",
",",
"$",
"data",
",",
"$",
"softHydrate",
")",
";",
"$",
"this",
"->",
"classMetadata",
"->",
"getEventManager",
"(",
")",
"->",
"execute",
"(",
"EventManager",
"::",
"EVENT_POST_LOAD",
",",
"$",
"object",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'readOnly'",
"]",
")",
"||",
"$",
"options",
"[",
"'readOnly'",
"]",
"!=",
"true",
")",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"object",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"hydrator",
"->",
"unhydrate",
"(",
"$",
"object",
")",
";",
"$",
"id",
"=",
"isset",
"(",
"$",
"data",
"[",
"'_id'",
"]",
")",
"?",
"serialize",
"(",
"$",
"data",
"[",
"'_id'",
"]",
")",
".",
"$",
"this",
"->",
"getCollection",
"(",
")",
":",
"$",
"oid",
";",
"$",
"projection",
"=",
"isset",
"(",
"$",
"options",
"[",
"'projection'",
"]",
")",
"?",
"$",
"options",
"[",
"'projection'",
"]",
":",
"[",
"]",
";",
"$",
"this",
"->",
"lastProjectionCache",
"->",
"save",
"(",
"$",
"id",
",",
"$",
"projection",
")",
";",
"$",
"this",
"->",
"cacheObject",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"documentManager",
"->",
"addObject",
"(",
"$",
"object",
",",
"DocumentManager",
"::",
"OBJ_MANAGED",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"object",
";",
"}",
"return",
"$",
"object",
";",
"}"
]
| Create object based on provided data
@param array $data Array of data which will hydrate object
@param array $options Options
@return void | [
"Create",
"object",
"based",
"on",
"provided",
"data"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L503-L533 |
15,864 | JoffreyPoreeCoding/MongoDB-ODM | src/Repository.php | Repository.createOption | protected function createOption($projections, $sort, $otherOptions = [])
{
$options = [];
isset($projections) ? $options["projection"] = $this->castQuery($projections) : null;
isset($sort) ? $options["sort"] = $this->castQuery($sort) : null;
$options = array_merge($this->documentManager->getDefaultOptions(), $otherOptions, $options);
return $options;
} | php | protected function createOption($projections, $sort, $otherOptions = [])
{
$options = [];
isset($projections) ? $options["projection"] = $this->castQuery($projections) : null;
isset($sort) ? $options["sort"] = $this->castQuery($sort) : null;
$options = array_merge($this->documentManager->getDefaultOptions(), $otherOptions, $options);
return $options;
} | [
"protected",
"function",
"createOption",
"(",
"$",
"projections",
",",
"$",
"sort",
",",
"$",
"otherOptions",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"isset",
"(",
"$",
"projections",
")",
"?",
"$",
"options",
"[",
"\"projection\"",
"]",
"=",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"projections",
")",
":",
"null",
";",
"isset",
"(",
"$",
"sort",
")",
"?",
"$",
"options",
"[",
"\"sort\"",
"]",
"=",
"$",
"this",
"->",
"castQuery",
"(",
"$",
"sort",
")",
":",
"null",
";",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"documentManager",
"->",
"getDefaultOptions",
"(",
")",
",",
"$",
"otherOptions",
",",
"$",
"options",
")",
";",
"return",
"$",
"options",
";",
"}"
]
| Create options based on parameters
@param array $projections Projection specification
@param array $sort Sort specification
@param array $otherOptions Other options
@return void | [
"Create",
"options",
"based",
"on",
"parameters"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Repository.php#L543-L551 |
15,865 | pdefreitas/Laravel-VanillaSSO | src/Pdefreitas/VanillaSSO/VanillaSSO.php | VanillaSSO.WriteJsConnect | public static function WriteJsConnect($User, $Request, $Secure = TRUE)
{
$User = array_change_key_case($User);
$ClientID = Config::get("vanillasso.client_id");
$Secret = Config::get("vanillasso.secret");
// Error checking.
if ($Secure) {
// Check the client.
if (!isset($Request['client_id']))
$Error = array('error' => 'invalid_request', 'message' => 'The client_id parameter is missing.');
elseif ($Request['client_id'] != $ClientID)
$Error = array('error' => 'invalid_client', 'message' => "Unknown client {$Request['client_id']}.");
elseif (!isset($Request['timestamp']) && !isset($Request['signature'])) {
if (is_array($User) && count($User) > 0) {
// This isn't really an error, but we are just going to return public information when no signature is sent.
$Error = array('name' => $User['name'], 'photourl' => @$User['photourl']);
} else {
$Error = array('name' => '', 'photourl' => '');
}
} elseif (!isset($Request['timestamp']) || !is_numeric($Request['timestamp']))
$Error = array('error' => 'invalid_request', 'message' => 'The timestamp parameter is missing or invalid.');
elseif (!isset($Request['signature']))
$Error = array('error' => 'invalid_request', 'message' => 'Missing signature parameter.');
elseif (($Diff = abs($Request['timestamp'] - self::JsTimestamp())) > JS_TIMEOUT)
$Error = array('error' => 'invalid_request', 'message' => 'The timestamp is invalid.');
else {
// Make sure the timestamp hasn't timed out.
$Signature = self::JsHash($Request['timestamp'] . $Secret, $Secure);
if ($Signature != $Request['signature'])
$Error = array('error' => 'access_denied', 'message' => 'Signature invalid.');
}
}
if (isset($Error))
$Result = $Error;
elseif (is_array($User) && count($User) > 0) {
if ($Secure === NULL) {
$Result = $User;
} else {
$Result = self::SignJsConnect($User, $ClientID, $Secret, $Secure, TRUE);
}
} else
$Result = array('name' => '', 'photourl' => '');
$Json = json_encode($Result);
if (isset($Request['callback']))
return "{$Request['callback']}($Json)";
else
return $Json;
} | php | public static function WriteJsConnect($User, $Request, $Secure = TRUE)
{
$User = array_change_key_case($User);
$ClientID = Config::get("vanillasso.client_id");
$Secret = Config::get("vanillasso.secret");
// Error checking.
if ($Secure) {
// Check the client.
if (!isset($Request['client_id']))
$Error = array('error' => 'invalid_request', 'message' => 'The client_id parameter is missing.');
elseif ($Request['client_id'] != $ClientID)
$Error = array('error' => 'invalid_client', 'message' => "Unknown client {$Request['client_id']}.");
elseif (!isset($Request['timestamp']) && !isset($Request['signature'])) {
if (is_array($User) && count($User) > 0) {
// This isn't really an error, but we are just going to return public information when no signature is sent.
$Error = array('name' => $User['name'], 'photourl' => @$User['photourl']);
} else {
$Error = array('name' => '', 'photourl' => '');
}
} elseif (!isset($Request['timestamp']) || !is_numeric($Request['timestamp']))
$Error = array('error' => 'invalid_request', 'message' => 'The timestamp parameter is missing or invalid.');
elseif (!isset($Request['signature']))
$Error = array('error' => 'invalid_request', 'message' => 'Missing signature parameter.');
elseif (($Diff = abs($Request['timestamp'] - self::JsTimestamp())) > JS_TIMEOUT)
$Error = array('error' => 'invalid_request', 'message' => 'The timestamp is invalid.');
else {
// Make sure the timestamp hasn't timed out.
$Signature = self::JsHash($Request['timestamp'] . $Secret, $Secure);
if ($Signature != $Request['signature'])
$Error = array('error' => 'access_denied', 'message' => 'Signature invalid.');
}
}
if (isset($Error))
$Result = $Error;
elseif (is_array($User) && count($User) > 0) {
if ($Secure === NULL) {
$Result = $User;
} else {
$Result = self::SignJsConnect($User, $ClientID, $Secret, $Secure, TRUE);
}
} else
$Result = array('name' => '', 'photourl' => '');
$Json = json_encode($Result);
if (isset($Request['callback']))
return "{$Request['callback']}($Json)";
else
return $Json;
} | [
"public",
"static",
"function",
"WriteJsConnect",
"(",
"$",
"User",
",",
"$",
"Request",
",",
"$",
"Secure",
"=",
"TRUE",
")",
"{",
"$",
"User",
"=",
"array_change_key_case",
"(",
"$",
"User",
")",
";",
"$",
"ClientID",
"=",
"Config",
"::",
"get",
"(",
"\"vanillasso.client_id\"",
")",
";",
"$",
"Secret",
"=",
"Config",
"::",
"get",
"(",
"\"vanillasso.secret\"",
")",
";",
"// Error checking.",
"if",
"(",
"$",
"Secure",
")",
"{",
"// Check the client.",
"if",
"(",
"!",
"isset",
"(",
"$",
"Request",
"[",
"'client_id'",
"]",
")",
")",
"$",
"Error",
"=",
"array",
"(",
"'error'",
"=>",
"'invalid_request'",
",",
"'message'",
"=>",
"'The client_id parameter is missing.'",
")",
";",
"elseif",
"(",
"$",
"Request",
"[",
"'client_id'",
"]",
"!=",
"$",
"ClientID",
")",
"$",
"Error",
"=",
"array",
"(",
"'error'",
"=>",
"'invalid_client'",
",",
"'message'",
"=>",
"\"Unknown client {$Request['client_id']}.\"",
")",
";",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"Request",
"[",
"'timestamp'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"Request",
"[",
"'signature'",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"User",
")",
"&&",
"count",
"(",
"$",
"User",
")",
">",
"0",
")",
"{",
"// This isn't really an error, but we are just going to return public information when no signature is sent.",
"$",
"Error",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"User",
"[",
"'name'",
"]",
",",
"'photourl'",
"=>",
"@",
"$",
"User",
"[",
"'photourl'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"Error",
"=",
"array",
"(",
"'name'",
"=>",
"''",
",",
"'photourl'",
"=>",
"''",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"Request",
"[",
"'timestamp'",
"]",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"Request",
"[",
"'timestamp'",
"]",
")",
")",
"$",
"Error",
"=",
"array",
"(",
"'error'",
"=>",
"'invalid_request'",
",",
"'message'",
"=>",
"'The timestamp parameter is missing or invalid.'",
")",
";",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"Request",
"[",
"'signature'",
"]",
")",
")",
"$",
"Error",
"=",
"array",
"(",
"'error'",
"=>",
"'invalid_request'",
",",
"'message'",
"=>",
"'Missing signature parameter.'",
")",
";",
"elseif",
"(",
"(",
"$",
"Diff",
"=",
"abs",
"(",
"$",
"Request",
"[",
"'timestamp'",
"]",
"-",
"self",
"::",
"JsTimestamp",
"(",
")",
")",
")",
">",
"JS_TIMEOUT",
")",
"$",
"Error",
"=",
"array",
"(",
"'error'",
"=>",
"'invalid_request'",
",",
"'message'",
"=>",
"'The timestamp is invalid.'",
")",
";",
"else",
"{",
"// Make sure the timestamp hasn't timed out.",
"$",
"Signature",
"=",
"self",
"::",
"JsHash",
"(",
"$",
"Request",
"[",
"'timestamp'",
"]",
".",
"$",
"Secret",
",",
"$",
"Secure",
")",
";",
"if",
"(",
"$",
"Signature",
"!=",
"$",
"Request",
"[",
"'signature'",
"]",
")",
"$",
"Error",
"=",
"array",
"(",
"'error'",
"=>",
"'access_denied'",
",",
"'message'",
"=>",
"'Signature invalid.'",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"Error",
")",
")",
"$",
"Result",
"=",
"$",
"Error",
";",
"elseif",
"(",
"is_array",
"(",
"$",
"User",
")",
"&&",
"count",
"(",
"$",
"User",
")",
">",
"0",
")",
"{",
"if",
"(",
"$",
"Secure",
"===",
"NULL",
")",
"{",
"$",
"Result",
"=",
"$",
"User",
";",
"}",
"else",
"{",
"$",
"Result",
"=",
"self",
"::",
"SignJsConnect",
"(",
"$",
"User",
",",
"$",
"ClientID",
",",
"$",
"Secret",
",",
"$",
"Secure",
",",
"TRUE",
")",
";",
"}",
"}",
"else",
"$",
"Result",
"=",
"array",
"(",
"'name'",
"=>",
"''",
",",
"'photourl'",
"=>",
"''",
")",
";",
"$",
"Json",
"=",
"json_encode",
"(",
"$",
"Result",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"Request",
"[",
"'callback'",
"]",
")",
")",
"return",
"\"{$Request['callback']}($Json)\"",
";",
"else",
"return",
"$",
"Json",
";",
"}"
]
| Write the jsConnect string for single sign on.
@param array $User An array containing information about the currently signed on user. If no user is signed in then this should be an empty array.
@param array $Request An array of the $_GET request.
@param string|bool $Secure Whether or not to check for security. This is one of these values.
- true: Check for security and sign the response with an md5 hash.
- false: Don't check for security, but sign the response with an md5 hash.
- string: Check for security and sign the response with the given hash algorithm. See hash_algos() for what your server can support.
- null: Don't check for security and don't sign the response.
@since 1.1b Added the ability to provide a hash algorithm to $Secure.
@return string JSON response formatted. | [
"Write",
"the",
"jsConnect",
"string",
"for",
"single",
"sign",
"on",
"."
]
| f47a7c33eaf392fb6564a909f622b36ffd373759 | https://github.com/pdefreitas/Laravel-VanillaSSO/blob/f47a7c33eaf392fb6564a909f622b36ffd373759/src/Pdefreitas/VanillaSSO/VanillaSSO.php#L38-L89 |
15,866 | pdefreitas/Laravel-VanillaSSO | src/Pdefreitas/VanillaSSO/VanillaSSO.php | VanillaSSO.JsHash | protected static function JsHash($String, $Secure = TRUE)
{
if ($Secure === TRUE)
$Secure = 'md5';
switch ($Secure) {
case 'sha1':
return sha1($String);
break;
case 'md5':
case FALSE:
return md5($String);
default:
return hash($Secure, $String);
}
} | php | protected static function JsHash($String, $Secure = TRUE)
{
if ($Secure === TRUE)
$Secure = 'md5';
switch ($Secure) {
case 'sha1':
return sha1($String);
break;
case 'md5':
case FALSE:
return md5($String);
default:
return hash($Secure, $String);
}
} | [
"protected",
"static",
"function",
"JsHash",
"(",
"$",
"String",
",",
"$",
"Secure",
"=",
"TRUE",
")",
"{",
"if",
"(",
"$",
"Secure",
"===",
"TRUE",
")",
"$",
"Secure",
"=",
"'md5'",
";",
"switch",
"(",
"$",
"Secure",
")",
"{",
"case",
"'sha1'",
":",
"return",
"sha1",
"(",
"$",
"String",
")",
";",
"break",
";",
"case",
"'md5'",
":",
"case",
"FALSE",
":",
"return",
"md5",
"(",
"$",
"String",
")",
";",
"default",
":",
"return",
"hash",
"(",
"$",
"Secure",
",",
"$",
"String",
")",
";",
"}",
"}"
]
| Return the hash of a string.
@param string $String The string to hash.
@param string|bool $Secure The hash algorithm to use. TRUE means md5.
@return string
@since 1.1b | [
"Return",
"the",
"hash",
"of",
"a",
"string",
"."
]
| f47a7c33eaf392fb6564a909f622b36ffd373759 | https://github.com/pdefreitas/Laravel-VanillaSSO/blob/f47a7c33eaf392fb6564a909f622b36ffd373759/src/Pdefreitas/VanillaSSO/VanillaSSO.php#L121-L136 |
15,867 | pdefreitas/Laravel-VanillaSSO | src/Pdefreitas/VanillaSSO/VanillaSSO.php | VanillaSSO.JsSSOString | protected static function JsSSOString($User, $ClientID, $Secret)
{
if (!isset($User['client_id']))
$User['client_id'] = $ClientID;
$String = base64_encode(json_encode($User));
$Timestamp = time();
$Hash = hash_hmac('sha1', "$String $Timestamp", $Secret);
$Result = "$String $Hash $Timestamp hmacsha1";
return $Result;
} | php | protected static function JsSSOString($User, $ClientID, $Secret)
{
if (!isset($User['client_id']))
$User['client_id'] = $ClientID;
$String = base64_encode(json_encode($User));
$Timestamp = time();
$Hash = hash_hmac('sha1', "$String $Timestamp", $Secret);
$Result = "$String $Hash $Timestamp hmacsha1";
return $Result;
} | [
"protected",
"static",
"function",
"JsSSOString",
"(",
"$",
"User",
",",
"$",
"ClientID",
",",
"$",
"Secret",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"User",
"[",
"'client_id'",
"]",
")",
")",
"$",
"User",
"[",
"'client_id'",
"]",
"=",
"$",
"ClientID",
";",
"$",
"String",
"=",
"base64_encode",
"(",
"json_encode",
"(",
"$",
"User",
")",
")",
";",
"$",
"Timestamp",
"=",
"time",
"(",
")",
";",
"$",
"Hash",
"=",
"hash_hmac",
"(",
"'sha1'",
",",
"\"$String $Timestamp\"",
",",
"$",
"Secret",
")",
";",
"$",
"Result",
"=",
"\"$String $Hash $Timestamp hmacsha1\"",
";",
"return",
"$",
"Result",
";",
"}"
]
| Generate an SSO string suitible for passing in the url for embedded SSO.
@param array $User The user to sso.
@param string $ClientID Your client ID.
@param string $Secret Your secret.
@return string | [
"Generate",
"an",
"SSO",
"string",
"suitible",
"for",
"passing",
"in",
"the",
"url",
"for",
"embedded",
"SSO",
"."
]
| f47a7c33eaf392fb6564a909f622b36ffd373759 | https://github.com/pdefreitas/Laravel-VanillaSSO/blob/f47a7c33eaf392fb6564a909f622b36ffd373759/src/Pdefreitas/VanillaSSO/VanillaSSO.php#L151-L162 |
15,868 | fuelphp/display | src/DataContainer.php | DataContainer.getData | public function getData()
{
$data = $this->data;
foreach ($data as $key => $value)
{
if (is_object($value) and $this->isWhitelisted($value))
{
continue;
}
if ($this->shouldBeFiltered($key))
{
if ($value instanceof Sanitize)
{
$data[$key] = $value->sanitize();
}
else
{
$data[$key] = $this->filter($value);
}
}
}
return $data;
} | php | public function getData()
{
$data = $this->data;
foreach ($data as $key => $value)
{
if (is_object($value) and $this->isWhitelisted($value))
{
continue;
}
if ($this->shouldBeFiltered($key))
{
if ($value instanceof Sanitize)
{
$data[$key] = $value->sanitize();
}
else
{
$data[$key] = $this->filter($value);
}
}
}
return $data;
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"and",
"$",
"this",
"->",
"isWhitelisted",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"shouldBeFiltered",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Sanitize",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"->",
"sanitize",
"(",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"filter",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"return",
"$",
"data",
";",
"}"
]
| Retrieves all the view data
@return array | [
"Retrieves",
"all",
"the",
"view",
"data"
]
| d9a3eddbf80f0fd81beb40d9f4507600ac6611a4 | https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/DataContainer.php#L62-L87 |
15,869 | fuelphp/display | src/DataContainer.php | DataContainer.shouldBeFiltered | protected function shouldBeFiltered($key)
{
if (isset($this->filterIndex[$key]))
{
return $this->filterIndex[$key];
}
return $this->autoFilter;
} | php | protected function shouldBeFiltered($key)
{
if (isset($this->filterIndex[$key]))
{
return $this->filterIndex[$key];
}
return $this->autoFilter;
} | [
"protected",
"function",
"shouldBeFiltered",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filterIndex",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"filterIndex",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"autoFilter",
";",
"}"
]
| Checks if a key should be filtered or not
Uses filterIndex and autoFilter
@param string $key
@return boolean | [
"Checks",
"if",
"a",
"key",
"should",
"be",
"filtered",
"or",
"not"
]
| d9a3eddbf80f0fd81beb40d9f4507600ac6611a4 | https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/DataContainer.php#L98-L106 |
15,870 | fuelphp/display | src/DataContainer.php | DataContainer.isWhitelisted | protected function isWhitelisted($object)
{
foreach ($this->whitelist as $whitelisted)
{
if ($object instanceof $whitelisted)
{
return true;
}
}
return false;
} | php | protected function isWhitelisted($object)
{
foreach ($this->whitelist as $whitelisted)
{
if ($object instanceof $whitelisted)
{
return true;
}
}
return false;
} | [
"protected",
"function",
"isWhitelisted",
"(",
"$",
"object",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"whitelist",
"as",
"$",
"whitelisted",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"$",
"whitelisted",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Checks if an object is whitelisted
@param object $object
@return boolean | [
"Checks",
"if",
"an",
"object",
"is",
"whitelisted"
]
| d9a3eddbf80f0fd81beb40d9f4507600ac6611a4 | https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/DataContainer.php#L115-L126 |
15,871 | fuelphp/display | src/DataContainer.php | DataContainer.filter | public function filter($value)
{
if (is_array($value) or (is_object($value) and $value instanceof \ArrayAccess))
{
return array_map([$this, 'filter'], $value);
}
return htmlentities($value, ENT_QUOTES | ENT_HTML5);
} | php | public function filter($value)
{
if (is_array($value) or (is_object($value) and $value instanceof \ArrayAccess))
{
return array_map([$this, 'filter'], $value);
}
return htmlentities($value, ENT_QUOTES | ENT_HTML5);
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"or",
"(",
"is_object",
"(",
"$",
"value",
")",
"and",
"$",
"value",
"instanceof",
"\\",
"ArrayAccess",
")",
")",
"{",
"return",
"array_map",
"(",
"[",
"$",
"this",
",",
"'filter'",
"]",
",",
"$",
"value",
")",
";",
"}",
"return",
"htmlentities",
"(",
"$",
"value",
",",
"ENT_QUOTES",
"|",
"ENT_HTML5",
")",
";",
"}"
]
| Filters the output
@param mixed $value
@return string | [
"Filters",
"the",
"output"
]
| d9a3eddbf80f0fd81beb40d9f4507600ac6611a4 | https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/DataContainer.php#L135-L143 |
15,872 | fuelphp/display | src/DataContainer.php | DataContainer.set | public function set($key, $value = null, $filter = null)
{
parent::set($key, $value);
if (is_array($key))
{
if (is_bool($value))
{
$filter = $value;
}
foreach ($key as $_key => $_value)
{
$this->filterIndex[$_key] = $filter;
}
}
else
{
$this->filterIndex[$key] = $filter;
}
return $this;
} | php | public function set($key, $value = null, $filter = null)
{
parent::set($key, $value);
if (is_array($key))
{
if (is_bool($value))
{
$filter = $value;
}
foreach ($key as $_key => $_value)
{
$this->filterIndex[$_key] = $filter;
}
}
else
{
$this->filterIndex[$key] = $filter;
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"parent",
"::",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"value",
";",
"}",
"foreach",
"(",
"$",
"key",
"as",
"$",
"_key",
"=>",
"$",
"_value",
")",
"{",
"$",
"this",
"->",
"filterIndex",
"[",
"$",
"_key",
"]",
"=",
"$",
"filter",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"filterIndex",
"[",
"$",
"key",
"]",
"=",
"$",
"filter",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets view data
@param string|array $key
@param mixed $value
@param boolean $filter
@return $this | [
"Sets",
"view",
"data"
]
| d9a3eddbf80f0fd81beb40d9f4507600ac6611a4 | https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/DataContainer.php#L154-L176 |
15,873 | fuelphp/display | src/DataContainer.php | DataContainer.replaceData | public function replaceData(array $data, $filter = null)
{
$this->clearData();
return $this->set($data, $filter);
} | php | public function replaceData(array $data, $filter = null)
{
$this->clearData();
return $this->set($data, $filter);
} | [
"public",
"function",
"replaceData",
"(",
"array",
"$",
"data",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearData",
"(",
")",
";",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"data",
",",
"$",
"filter",
")",
";",
"}"
]
| Overwrites all the view data
@param array $data
@param boolean $filter
@return $this | [
"Overwrites",
"all",
"the",
"view",
"data"
]
| d9a3eddbf80f0fd81beb40d9f4507600ac6611a4 | https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/DataContainer.php#L223-L228 |
15,874 | FrenchFrogs/framework | src/Table/Column/Column.php | Column.order | public function order($direction = null)
{
if (is_null($direction)) {
$direction = $this->getOrderDirection();
} else {
$this->setOrderDirection($direction);
}
// if a direction is set
if (!empty($direction)) {
if (!is_string($this->order) && is_callable($this->order)) {
call_user_func_array($this->order, $this);
} else {
$table = $this->getTable();
// verify that source is a query
if (!$table->isSourceQueryBuilder()) {
throw new \Exception('Table source is not an instance of query builder');
}
$table->getSource()->orderBy($this->order, $direction);
}
}
return $this;
} | php | public function order($direction = null)
{
if (is_null($direction)) {
$direction = $this->getOrderDirection();
} else {
$this->setOrderDirection($direction);
}
// if a direction is set
if (!empty($direction)) {
if (!is_string($this->order) && is_callable($this->order)) {
call_user_func_array($this->order, $this);
} else {
$table = $this->getTable();
// verify that source is a query
if (!$table->isSourceQueryBuilder()) {
throw new \Exception('Table source is not an instance of query builder');
}
$table->getSource()->orderBy($this->order, $direction);
}
}
return $this;
} | [
"public",
"function",
"order",
"(",
"$",
"direction",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"direction",
")",
")",
"{",
"$",
"direction",
"=",
"$",
"this",
"->",
"getOrderDirection",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setOrderDirection",
"(",
"$",
"direction",
")",
";",
"}",
"// if a direction is set",
"if",
"(",
"!",
"empty",
"(",
"$",
"direction",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"order",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"order",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"order",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"// verify that source is a query",
"if",
"(",
"!",
"$",
"table",
"->",
"isSourceQueryBuilder",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Table source is not an instance of query builder'",
")",
";",
"}",
"$",
"table",
"->",
"getSource",
"(",
")",
"->",
"orderBy",
"(",
"$",
"this",
"->",
"order",
",",
"$",
"direction",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Order process for the column
@param $direction (asc or desc)
@return $this
@throws \Exception | [
"Order",
"process",
"for",
"the",
"column"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Column.php#L346-L372 |
15,875 | FrenchFrogs/framework | src/Table/Column/Column.php | Column.isVisible | public function isVisible($row = null)
{
$callable = !is_bool($this->visible) && !is_string($this->visible) && is_callable($this->visible);
return (bool) ($callable ? call_user_func($this->visible, $this, $row) : $this->visible);
} | php | public function isVisible($row = null)
{
$callable = !is_bool($this->visible) && !is_string($this->visible) && is_callable($this->visible);
return (bool) ($callable ? call_user_func($this->visible, $this, $row) : $this->visible);
} | [
"public",
"function",
"isVisible",
"(",
"$",
"row",
"=",
"null",
")",
"{",
"$",
"callable",
"=",
"!",
"is_bool",
"(",
"$",
"this",
"->",
"visible",
")",
"&&",
"!",
"is_string",
"(",
"$",
"this",
"->",
"visible",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"visible",
")",
";",
"return",
"(",
"bool",
")",
"(",
"$",
"callable",
"?",
"call_user_func",
"(",
"$",
"this",
"->",
"visible",
",",
"$",
"this",
",",
"$",
"row",
")",
":",
"$",
"this",
"->",
"visible",
")",
";",
"}"
]
| Return if the columns is visible
@param $row
@return bool | [
"Return",
"if",
"the",
"columns",
"is",
"visible"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Column.php#L466-L470 |
15,876 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/CheckTables.php | CheckTables.checkRequiredTables | protected function checkRequiredTables()
{
// check if relevant tables are present in the list
foreach ([
config('pxlcms.tables.meta.modules'),
config('pxlcms.tables.meta.fields'),
config('pxlcms.tables.meta.field_options_choices'),
//config('pxlcms.tables.meta.groups'),
//config('pxlcms.tables.meta.sections'),
//config('pxlcms.tables.meta.field_types'),
//config('pxlcms.tables.meta.tabs'),
//config('pxlcms.tables.meta.users'),
//config('pxlcms.tables.meta.field_options_resizes'),
config('pxlcms.tables.languages'),
config('pxlcms.tables.categories'),
config('pxlcms.tables.files'),
config('pxlcms.tables.images'),
config('pxlcms.tables.references'),
config('pxlcms.tables.checkboxes'),
//config('pxlcms.tables.slugs'),
] as $checkTable
) {
if ( ! in_array($checkTable, $this->tables)) {
throw new Exception("Could not find expected CMS table in database: '{$checkTable}'");
}
}
} | php | protected function checkRequiredTables()
{
// check if relevant tables are present in the list
foreach ([
config('pxlcms.tables.meta.modules'),
config('pxlcms.tables.meta.fields'),
config('pxlcms.tables.meta.field_options_choices'),
//config('pxlcms.tables.meta.groups'),
//config('pxlcms.tables.meta.sections'),
//config('pxlcms.tables.meta.field_types'),
//config('pxlcms.tables.meta.tabs'),
//config('pxlcms.tables.meta.users'),
//config('pxlcms.tables.meta.field_options_resizes'),
config('pxlcms.tables.languages'),
config('pxlcms.tables.categories'),
config('pxlcms.tables.files'),
config('pxlcms.tables.images'),
config('pxlcms.tables.references'),
config('pxlcms.tables.checkboxes'),
//config('pxlcms.tables.slugs'),
] as $checkTable
) {
if ( ! in_array($checkTable, $this->tables)) {
throw new Exception("Could not find expected CMS table in database: '{$checkTable}'");
}
}
} | [
"protected",
"function",
"checkRequiredTables",
"(",
")",
"{",
"// check if relevant tables are present in the list",
"foreach",
"(",
"[",
"config",
"(",
"'pxlcms.tables.meta.modules'",
")",
",",
"config",
"(",
"'pxlcms.tables.meta.fields'",
")",
",",
"config",
"(",
"'pxlcms.tables.meta.field_options_choices'",
")",
",",
"//config('pxlcms.tables.meta.groups'),",
"//config('pxlcms.tables.meta.sections'),",
"//config('pxlcms.tables.meta.field_types'),",
"//config('pxlcms.tables.meta.tabs'),",
"//config('pxlcms.tables.meta.users'),",
"//config('pxlcms.tables.meta.field_options_resizes'),",
"config",
"(",
"'pxlcms.tables.languages'",
")",
",",
"config",
"(",
"'pxlcms.tables.categories'",
")",
",",
"config",
"(",
"'pxlcms.tables.files'",
")",
",",
"config",
"(",
"'pxlcms.tables.images'",
")",
",",
"config",
"(",
"'pxlcms.tables.references'",
")",
",",
"config",
"(",
"'pxlcms.tables.checkboxes'",
")",
",",
"//config('pxlcms.tables.slugs'),",
"]",
"as",
"$",
"checkTable",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"checkTable",
",",
"$",
"this",
"->",
"tables",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Could not find expected CMS table in database: '{$checkTable}'\"",
")",
";",
"}",
"}",
"}"
]
| Checks if all required tables are present
@throws Exception if a table is not found | [
"Checks",
"if",
"all",
"required",
"tables",
"are",
"present"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/CheckTables.php#L35-L65 |
15,877 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/CheckTables.php | CheckTables.detectSlugStructure | protected function detectSlugStructure()
{
$this->context->slugStructurePresent = false;
$slugsTable = config('pxlcms.slugs.table');
if ( ! in_array($slugsTable, $this->tables)) {
$this->context->log("No slugs table detected.");
return;
}
// the table exists.. does it have the content we need / expect?
// Note: cannot escape/PDO this, so be careful with your config
$columns = $this->loadColumnListForTable($slugsTable);
foreach ([
config('pxlcms.slugs.keys.module'),
config('pxlcms.slugs.keys.entry'),
config('pxlcms.slugs.keys.language'),
] as $requiredColumn
) {
if (in_array($requiredColumn, $columns)) continue;
// column does not exist!
$this->context->log(
"Slugs table detected but not usable for Sluggable handling!"
. " Missing required column '{$requiredColumn}'.",
Generator::LOG_LEVEL_WARNING
);
return;
}
$this->context->slugStructurePresent = true;
$this->context->log("Slugs table detected and considered usable for Sluggable handling.");
} | php | protected function detectSlugStructure()
{
$this->context->slugStructurePresent = false;
$slugsTable = config('pxlcms.slugs.table');
if ( ! in_array($slugsTable, $this->tables)) {
$this->context->log("No slugs table detected.");
return;
}
// the table exists.. does it have the content we need / expect?
// Note: cannot escape/PDO this, so be careful with your config
$columns = $this->loadColumnListForTable($slugsTable);
foreach ([
config('pxlcms.slugs.keys.module'),
config('pxlcms.slugs.keys.entry'),
config('pxlcms.slugs.keys.language'),
] as $requiredColumn
) {
if (in_array($requiredColumn, $columns)) continue;
// column does not exist!
$this->context->log(
"Slugs table detected but not usable for Sluggable handling!"
. " Missing required column '{$requiredColumn}'.",
Generator::LOG_LEVEL_WARNING
);
return;
}
$this->context->slugStructurePresent = true;
$this->context->log("Slugs table detected and considered usable for Sluggable handling.");
} | [
"protected",
"function",
"detectSlugStructure",
"(",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"slugStructurePresent",
"=",
"false",
";",
"$",
"slugsTable",
"=",
"config",
"(",
"'pxlcms.slugs.table'",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"slugsTable",
",",
"$",
"this",
"->",
"tables",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"No slugs table detected.\"",
")",
";",
"return",
";",
"}",
"// the table exists.. does it have the content we need / expect?",
"// Note: cannot escape/PDO this, so be careful with your config",
"$",
"columns",
"=",
"$",
"this",
"->",
"loadColumnListForTable",
"(",
"$",
"slugsTable",
")",
";",
"foreach",
"(",
"[",
"config",
"(",
"'pxlcms.slugs.keys.module'",
")",
",",
"config",
"(",
"'pxlcms.slugs.keys.entry'",
")",
",",
"config",
"(",
"'pxlcms.slugs.keys.language'",
")",
",",
"]",
"as",
"$",
"requiredColumn",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"requiredColumn",
",",
"$",
"columns",
")",
")",
"continue",
";",
"// column does not exist!",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Slugs table detected but not usable for Sluggable handling!\"",
".",
"\" Missing required column '{$requiredColumn}'.\"",
",",
"Generator",
"::",
"LOG_LEVEL_WARNING",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"context",
"->",
"slugStructurePresent",
"=",
"true",
";",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Slugs table detected and considered usable for Sluggable handling.\"",
")",
";",
"}"
]
| Detects whether this CMS has the 'typical' slug table setup | [
"Detects",
"whether",
"this",
"CMS",
"has",
"the",
"typical",
"slug",
"table",
"setup"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/CheckTables.php#L70-L105 |
15,878 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/CheckTables.php | CheckTables.loadTableList | protected function loadTableList()
{
if ($this->getDatabaseDriver() === 'sqlite') {
$statement = "SELECT name FROM sqlite_master WHERE type='table';";
} else {
$statement = 'SHOW TABLES';
}
$tables = DB::select($statement);
$this->tables = [];
foreach ($tables as $tableObject) {
$this->tables[] = array_get(array_values((array) $tableObject), '0');
}
} | php | protected function loadTableList()
{
if ($this->getDatabaseDriver() === 'sqlite') {
$statement = "SELECT name FROM sqlite_master WHERE type='table';";
} else {
$statement = 'SHOW TABLES';
}
$tables = DB::select($statement);
$this->tables = [];
foreach ($tables as $tableObject) {
$this->tables[] = array_get(array_values((array) $tableObject), '0');
}
} | [
"protected",
"function",
"loadTableList",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDatabaseDriver",
"(",
")",
"===",
"'sqlite'",
")",
"{",
"$",
"statement",
"=",
"\"SELECT name FROM sqlite_master WHERE type='table';\"",
";",
"}",
"else",
"{",
"$",
"statement",
"=",
"'SHOW TABLES'",
";",
"}",
"$",
"tables",
"=",
"DB",
"::",
"select",
"(",
"$",
"statement",
")",
";",
"$",
"this",
"->",
"tables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableObject",
")",
"{",
"$",
"this",
"->",
"tables",
"[",
"]",
"=",
"array_get",
"(",
"array_values",
"(",
"(",
"array",
")",
"$",
"tableObject",
")",
",",
"'0'",
")",
";",
"}",
"}"
]
| Caches the list of tables in the database | [
"Caches",
"the",
"list",
"of",
"tables",
"in",
"the",
"database"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/CheckTables.php#L149-L165 |
15,879 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/CheckTables.php | CheckTables.loadColumnListForTable | protected function loadColumnListForTable($table)
{
if ($this->getDatabaseDriver() === 'sqlite') {
$statement = "PRAGMA table_info(`{$table}`)";
} else {
$statement = "SHOW columns FROM `{$table}`";
}
$columnResults = DB::select($statement);
$columns = [];
foreach ($columnResults as $columnObject) {
$columns[] = array_get(array_values((array) $columnObject), '0');
}
return $columns;
} | php | protected function loadColumnListForTable($table)
{
if ($this->getDatabaseDriver() === 'sqlite') {
$statement = "PRAGMA table_info(`{$table}`)";
} else {
$statement = "SHOW columns FROM `{$table}`";
}
$columnResults = DB::select($statement);
$columns = [];
foreach ($columnResults as $columnObject) {
$columns[] = array_get(array_values((array) $columnObject), '0');
}
return $columns;
} | [
"protected",
"function",
"loadColumnListForTable",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDatabaseDriver",
"(",
")",
"===",
"'sqlite'",
")",
"{",
"$",
"statement",
"=",
"\"PRAGMA table_info(`{$table}`)\"",
";",
"}",
"else",
"{",
"$",
"statement",
"=",
"\"SHOW columns FROM `{$table}`\"",
";",
"}",
"$",
"columnResults",
"=",
"DB",
"::",
"select",
"(",
"$",
"statement",
")",
";",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columnResults",
"as",
"$",
"columnObject",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"array_get",
"(",
"array_values",
"(",
"(",
"array",
")",
"$",
"columnObject",
")",
",",
"'0'",
")",
";",
"}",
"return",
"$",
"columns",
";",
"}"
]
| Returns the column names for a table
@param string $table
@return array | [
"Returns",
"the",
"column",
"names",
"for",
"a",
"table"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/CheckTables.php#L173-L190 |
15,880 | iter8-au/builder | src/Builder/Builder.php | Builder.prepareBuilder | private function prepareBuilder(): void
{
if (!file_exists($this->getReportCacheDir())) {
@mkdir($this->getReportCacheDir(), 0777, true);
}
$this->builder
->setCacheDir($this->getReportCacheDir())
->initialise();
return;
} | php | private function prepareBuilder(): void
{
if (!file_exists($this->getReportCacheDir())) {
@mkdir($this->getReportCacheDir(), 0777, true);
}
$this->builder
->setCacheDir($this->getReportCacheDir())
->initialise();
return;
} | [
"private",
"function",
"prepareBuilder",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"getReportCacheDir",
"(",
")",
")",
")",
"{",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"getReportCacheDir",
"(",
")",
",",
"0777",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"builder",
"->",
"setCacheDir",
"(",
"$",
"this",
"->",
"getReportCacheDir",
"(",
")",
")",
"->",
"initialise",
"(",
")",
";",
"return",
";",
"}"
]
| Prepares the builders and creates the cache directory if it doesn't exist.
@return void | [
"Prepares",
"the",
"builders",
"and",
"creates",
"the",
"cache",
"directory",
"if",
"it",
"doesn",
"t",
"exist",
"."
]
| 95105636c2490c5c7a88da466702c523a9d0901c | https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builder.php#L112-L123 |
15,881 | iter8-au/builder | src/Builder/Builder.php | Builder.generate | public function generate($unlinkFlag = true) {
// Determine which format we are using and call the appropriate method.
if ($this->getReportType() === self::REPORT_EXCEL) {
$this->generateExcel();
// Output headers
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment;filename=' . $this->getFilename() . '.xlsx');
header('Content-Transfer-Encoding: binary ');
readfile($this->builder->getTempName());
unlink($this->builder->getTempName());
exit;
}
throw new UnexpectedValueException('Attempted to generate a report in an unsupported format.');
} | php | public function generate($unlinkFlag = true) {
// Determine which format we are using and call the appropriate method.
if ($this->getReportType() === self::REPORT_EXCEL) {
$this->generateExcel();
// Output headers
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment;filename=' . $this->getFilename() . '.xlsx');
header('Content-Transfer-Encoding: binary ');
readfile($this->builder->getTempName());
unlink($this->builder->getTempName());
exit;
}
throw new UnexpectedValueException('Attempted to generate a report in an unsupported format.');
} | [
"public",
"function",
"generate",
"(",
"$",
"unlinkFlag",
"=",
"true",
")",
"{",
"// Determine which format we are using and call the appropriate method.",
"if",
"(",
"$",
"this",
"->",
"getReportType",
"(",
")",
"===",
"self",
"::",
"REPORT_EXCEL",
")",
"{",
"$",
"this",
"->",
"generateExcel",
"(",
")",
";",
"// Output headers",
"header",
"(",
"'Pragma: public'",
")",
";",
"header",
"(",
"'Expires: 0'",
")",
";",
"header",
"(",
"'Cache-Control: must-revalidate, post-check=0, pre-check=0'",
")",
";",
"header",
"(",
"'Content-Type: application/force-download'",
")",
";",
"header",
"(",
"'Content-Type: application/octet-stream'",
")",
";",
"header",
"(",
"'Content-Type: application/download'",
")",
";",
"header",
"(",
"'Content-Disposition: attachment;filename='",
".",
"$",
"this",
"->",
"getFilename",
"(",
")",
".",
"'.xlsx'",
")",
";",
"header",
"(",
"'Content-Transfer-Encoding: binary '",
")",
";",
"readfile",
"(",
"$",
"this",
"->",
"builder",
"->",
"getTempName",
"(",
")",
")",
";",
"unlink",
"(",
"$",
"this",
"->",
"builder",
"->",
"getTempName",
"(",
")",
")",
";",
"exit",
";",
"}",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Attempted to generate a report in an unsupported format.'",
")",
";",
"}"
]
| Generate the final report using whatever the set format is.
@param bool $unlinkFlag
@return void | [
"Generate",
"the",
"final",
"report",
"using",
"whatever",
"the",
"set",
"format",
"is",
"."
]
| 95105636c2490c5c7a88da466702c523a9d0901c | https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builder.php#L142-L164 |
15,882 | iter8-au/builder | src/Builder/Builder.php | Builder.generateExcel | public function generateExcel(): void
{
// Set Document Properties from Service values.
$this->builder
->setCreator($this->getCreator())
->setLastModifiedBy($this->getCreator())
->setTitle($this->getTitle())
->setSubject($this->getTitle())
->setDescription($this->getDescription());
if ($this->hasSheets()) {
// Multiple sheets.
$this->createSheets();
} else {
// Single sheet - these will be an array and a string.
$headers = $this->getHeaders();
$reportArray = $this->getData();
$sheetTitle = $this->getSheetTitles();
$this->builder->setActiveSheetIndex(0);
$this->createSheet(
$headers,
$reportArray,
$sheetTitle
);
}
// Close the builder and write the file.
$this->builder->closeAndWrite();
return;
} | php | public function generateExcel(): void
{
// Set Document Properties from Service values.
$this->builder
->setCreator($this->getCreator())
->setLastModifiedBy($this->getCreator())
->setTitle($this->getTitle())
->setSubject($this->getTitle())
->setDescription($this->getDescription());
if ($this->hasSheets()) {
// Multiple sheets.
$this->createSheets();
} else {
// Single sheet - these will be an array and a string.
$headers = $this->getHeaders();
$reportArray = $this->getData();
$sheetTitle = $this->getSheetTitles();
$this->builder->setActiveSheetIndex(0);
$this->createSheet(
$headers,
$reportArray,
$sheetTitle
);
}
// Close the builder and write the file.
$this->builder->closeAndWrite();
return;
} | [
"public",
"function",
"generateExcel",
"(",
")",
":",
"void",
"{",
"// Set Document Properties from Service values.",
"$",
"this",
"->",
"builder",
"->",
"setCreator",
"(",
"$",
"this",
"->",
"getCreator",
"(",
")",
")",
"->",
"setLastModifiedBy",
"(",
"$",
"this",
"->",
"getCreator",
"(",
")",
")",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"getTitle",
"(",
")",
")",
"->",
"setSubject",
"(",
"$",
"this",
"->",
"getTitle",
"(",
")",
")",
"->",
"setDescription",
"(",
"$",
"this",
"->",
"getDescription",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasSheets",
"(",
")",
")",
"{",
"// Multiple sheets.",
"$",
"this",
"->",
"createSheets",
"(",
")",
";",
"}",
"else",
"{",
"// Single sheet - these will be an array and a string.",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHeaders",
"(",
")",
";",
"$",
"reportArray",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"$",
"sheetTitle",
"=",
"$",
"this",
"->",
"getSheetTitles",
"(",
")",
";",
"$",
"this",
"->",
"builder",
"->",
"setActiveSheetIndex",
"(",
"0",
")",
";",
"$",
"this",
"->",
"createSheet",
"(",
"$",
"headers",
",",
"$",
"reportArray",
",",
"$",
"sheetTitle",
")",
";",
"}",
"// Close the builder and write the file.",
"$",
"this",
"->",
"builder",
"->",
"closeAndWrite",
"(",
")",
";",
"return",
";",
"}"
]
| Generates an Excel document.
@return void | [
"Generates",
"an",
"Excel",
"document",
"."
]
| 95105636c2490c5c7a88da466702c523a9d0901c | https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builder.php#L171-L203 |
15,883 | datasift/datasift-php | lib/DataSift/User.php | DataSift_User.setApiClient | public function setApiClient($api_client)
{
if (! class_exists($api_client) || ! method_exists($api_client, 'call')) {
throw new DataSift_Exception_InvalidData('Class "' . $api_client . '" does not exist');
}
$this->_api_client = $api_client;
} | php | public function setApiClient($api_client)
{
if (! class_exists($api_client) || ! method_exists($api_client, 'call')) {
throw new DataSift_Exception_InvalidData('Class "' . $api_client . '" does not exist');
}
$this->_api_client = $api_client;
} | [
"public",
"function",
"setApiClient",
"(",
"$",
"api_client",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"api_client",
")",
"||",
"!",
"method_exists",
"(",
"$",
"api_client",
",",
"'call'",
")",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Class \"'",
".",
"$",
"api_client",
".",
"'\" does not exist'",
")",
";",
"}",
"$",
"this",
"->",
"_api_client",
"=",
"$",
"api_client",
";",
"}"
]
| Set the class to use when calling the API
@param string $api_client The class to use.
@return void
@throws DataSift_Exception_InvalidData | [
"Set",
"the",
"class",
"to",
"use",
"when",
"calling",
"the",
"API"
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/User.php#L173-L180 |
15,884 | datasift/datasift-php | lib/DataSift/User.php | DataSift_User.createHistoric | public function createHistoric($hash, $start, $end, $sources, $name, $sample = DataSift_Historic::DEFAULT_SAMPLE)
{
return new DataSift_Historic($this, $hash, $start, $end, $sources, $name, $sample);
} | php | public function createHistoric($hash, $start, $end, $sources, $name, $sample = DataSift_Historic::DEFAULT_SAMPLE)
{
return new DataSift_Historic($this, $hash, $start, $end, $sources, $name, $sample);
} | [
"public",
"function",
"createHistoric",
"(",
"$",
"hash",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"sources",
",",
"$",
"name",
",",
"$",
"sample",
"=",
"DataSift_Historic",
"::",
"DEFAULT_SAMPLE",
")",
"{",
"return",
"new",
"DataSift_Historic",
"(",
"$",
"this",
",",
"$",
"hash",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"sources",
",",
"$",
"name",
",",
"$",
"sample",
")",
";",
"}"
]
| Create a historic query based on a stream hash.
@param string $hash The stream hash.
@param int $start The timestamp from which to start the query.
@param int $end The timestamp at which to end the query.
@param array $sources An array of sources required.
@param string $name A friendly name for this query.
@param float $sample An optional sample rate for this query.
@return DataSift_Historic
@throws DataSift_Exception_InvalidData | [
"Create",
"a",
"historic",
"query",
"based",
"on",
"a",
"stream",
"hash",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/User.php#L286-L289 |
15,885 | datasift/datasift-php | lib/DataSift/User.php | DataSift_User.getConsumer | public function getConsumer($type, $hash, $eventHandler)
{
return DataSift_StreamConsumer::factory(
$this,
$type,
new DataSift_Definition($this, false, $hash),
$eventHandler
);
} | php | public function getConsumer($type, $hash, $eventHandler)
{
return DataSift_StreamConsumer::factory(
$this,
$type,
new DataSift_Definition($this, false, $hash),
$eventHandler
);
} | [
"public",
"function",
"getConsumer",
"(",
"$",
"type",
",",
"$",
"hash",
",",
"$",
"eventHandler",
")",
"{",
"return",
"DataSift_StreamConsumer",
"::",
"factory",
"(",
"$",
"this",
",",
"$",
"type",
",",
"new",
"DataSift_Definition",
"(",
"$",
"this",
",",
"false",
",",
"$",
"hash",
")",
",",
"$",
"eventHandler",
")",
";",
"}"
]
| Returns a DataSift_StreamConsumer-derived object for the given hash,
for the given type.
@param string $type The consumer type for which to construct a consumer.
@param string $hash The hash to be consumed.
@param DataSift_IStreamConsumerEventHandler $eventHandler The object that will receive events.
@return DataSift_StreamConsumer The consumer object.
@throws DataSift_Exception_InvalidData
@see DataSift_StreamConsumer | [
"Returns",
"a",
"DataSift_StreamConsumer",
"-",
"derived",
"object",
"for",
"the",
"given",
"hash",
"for",
"the",
"given",
"type",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/User.php#L344-L352 |
15,886 | datasift/datasift-php | lib/DataSift/User.php | DataSift_User.getMultiConsumer | public function getMultiConsumer($type, $hashes, $eventHandler)
{
return DataSift_StreamConsumer::factory($this, $type, $hashes, $eventHandler);
} | php | public function getMultiConsumer($type, $hashes, $eventHandler)
{
return DataSift_StreamConsumer::factory($this, $type, $hashes, $eventHandler);
} | [
"public",
"function",
"getMultiConsumer",
"(",
"$",
"type",
",",
"$",
"hashes",
",",
"$",
"eventHandler",
")",
"{",
"return",
"DataSift_StreamConsumer",
"::",
"factory",
"(",
"$",
"this",
",",
"$",
"type",
",",
"$",
"hashes",
",",
"$",
"eventHandler",
")",
";",
"}"
]
| Returns a DataSift_StreamConsumer-derived object for the given hashes,
for the given type.
@param string $type The consumer type for which to construct a consumer.
@param string $hashes An array containing hashes and/or Definition
objects to be consumed.
@param DataSift_IStreamConsumerEventHandler $eventHandler The object that will receive events.
@return DataSift_StreamConsumer The consumer object.
@throws DataSift_Exception_InvalidData
@see DataSift_StreamConsumer | [
"Returns",
"a",
"DataSift_StreamConsumer",
"-",
"derived",
"object",
"for",
"the",
"given",
"hashes",
"for",
"the",
"given",
"type",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/User.php#L367-L370 |
15,887 | datasift/datasift-php | lib/DataSift/User.php | DataSift_User.listPushSubscriptions | public function listPushSubscriptions(
$page = 1,
$per_page = 100,
$order_by = DataSift_Push_Subscription::ORDERBY_CREATED_AT,
$order_dir = DataSift_Push_Subscription::ORDERDIR_ASC,
$include_finished = false
) {
return DataSift_Push_Subscription::listSubscriptions(
$this,
$page,
$per_page,
$order_by,
$order_dir,
$include_finished
);
} | php | public function listPushSubscriptions(
$page = 1,
$per_page = 100,
$order_by = DataSift_Push_Subscription::ORDERBY_CREATED_AT,
$order_dir = DataSift_Push_Subscription::ORDERDIR_ASC,
$include_finished = false
) {
return DataSift_Push_Subscription::listSubscriptions(
$this,
$page,
$per_page,
$order_by,
$order_dir,
$include_finished
);
} | [
"public",
"function",
"listPushSubscriptions",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"per_page",
"=",
"100",
",",
"$",
"order_by",
"=",
"DataSift_Push_Subscription",
"::",
"ORDERBY_CREATED_AT",
",",
"$",
"order_dir",
"=",
"DataSift_Push_Subscription",
"::",
"ORDERDIR_ASC",
",",
"$",
"include_finished",
"=",
"false",
")",
"{",
"return",
"DataSift_Push_Subscription",
"::",
"listSubscriptions",
"(",
"$",
"this",
",",
"$",
"page",
",",
"$",
"per_page",
",",
"$",
"order_by",
",",
"$",
"order_dir",
",",
"$",
"include_finished",
")",
";",
"}"
]
| Get a list of push subscriptions in your account.
@param int $page The page number to get.
@param int $per_page The number of items per page.
@param String order_by Which field to sort by.
@param String order_dir In asc[ending] or desc[ending] order.
@param bool $include_finished Set to true when you want to include finished subscription in the results.
@return array Of DataSift_Push_Subscription objects.
@throws DataSift_Exception_InvalidData
@throws DataSift_Exception_APIError
@throws DataSift_Exception_AccessDenied | [
"Get",
"a",
"list",
"of",
"push",
"subscriptions",
"in",
"your",
"account",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/User.php#L401-L416 |
15,888 | datasift/datasift-php | lib/DataSift/User.php | DataSift_User.get | public function get($endpoint, $params = array(), $headers = array())
{
$res = call_user_func(
array($this->_api_client, 'call'),
$this,
$endpoint,
'get',
array(),
$headers,
$this->getUserAgent(),
$params
);
$this->_rate_limit = $res['rate_limit'];
$this->_rate_limit_remaining = $res['rate_limit_remaining'];
return $this->handleResponse($res);
} | php | public function get($endpoint, $params = array(), $headers = array())
{
$res = call_user_func(
array($this->_api_client, 'call'),
$this,
$endpoint,
'get',
array(),
$headers,
$this->getUserAgent(),
$params
);
$this->_rate_limit = $res['rate_limit'];
$this->_rate_limit_remaining = $res['rate_limit_remaining'];
return $this->handleResponse($res);
} | [
"public",
"function",
"get",
"(",
"$",
"endpoint",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"res",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"_api_client",
",",
"'call'",
")",
",",
"$",
"this",
",",
"$",
"endpoint",
",",
"'get'",
",",
"array",
"(",
")",
",",
"$",
"headers",
",",
"$",
"this",
"->",
"getUserAgent",
"(",
")",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"_rate_limit",
"=",
"$",
"res",
"[",
"'rate_limit'",
"]",
";",
"$",
"this",
"->",
"_rate_limit_remaining",
"=",
"$",
"res",
"[",
"'rate_limit_remaining'",
"]",
";",
"return",
"$",
"this",
"->",
"handleResponse",
"(",
"$",
"res",
")",
";",
"}"
]
| Make a GET call to a DataSift API endpoint.
@param string $endpoint The endpoint of the API call.
@param array $params The parameters to be passed along with the request.
@return array The response from the server.
@throws DataSift_Exception_APIError
@throws DataSift_Exception_RateLimitExceeded | [
"Make",
"a",
"GET",
"call",
"to",
"a",
"DataSift",
"API",
"endpoint",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/User.php#L611-L628 |
15,889 | EcomDev/phpspec-magento-di-adapter | src/GeneratorWrapper.php | GeneratorWrapper.supports | public function supports($className)
{
return (strpos($className, ucfirst($this->classSuffix)) === strlen($className) - strlen($this->classSuffix));
} | php | public function supports($className)
{
return (strpos($className, ucfirst($this->classSuffix)) === strlen($className) - strlen($this->classSuffix));
} | [
"public",
"function",
"supports",
"(",
"$",
"className",
")",
"{",
"return",
"(",
"strpos",
"(",
"$",
"className",
",",
"ucfirst",
"(",
"$",
"this",
"->",
"classSuffix",
")",
")",
"===",
"strlen",
"(",
"$",
"className",
")",
"-",
"strlen",
"(",
"$",
"this",
"->",
"classSuffix",
")",
")",
";",
"}"
]
| Returns true if class has been generated
@param string $className
@return bool | [
"Returns",
"true",
"if",
"class",
"has",
"been",
"generated"
]
| b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37 | https://github.com/EcomDev/phpspec-magento-di-adapter/blob/b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37/src/GeneratorWrapper.php#L45-L48 |
15,890 | EcomDev/phpspec-magento-di-adapter | src/GeneratorWrapper.php | GeneratorWrapper.createGenerator | public function createGenerator($className)
{
$factory = $this->generatorFactory;
$sourceClass = rtrim(substr($className, 0, strpos($className, ucfirst($this->classSuffix))), '\\');
$entityGenerator = $factory($sourceClass, $className);
return $entityGenerator;
} | php | public function createGenerator($className)
{
$factory = $this->generatorFactory;
$sourceClass = rtrim(substr($className, 0, strpos($className, ucfirst($this->classSuffix))), '\\');
$entityGenerator = $factory($sourceClass, $className);
return $entityGenerator;
} | [
"public",
"function",
"createGenerator",
"(",
"$",
"className",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"generatorFactory",
";",
"$",
"sourceClass",
"=",
"rtrim",
"(",
"substr",
"(",
"$",
"className",
",",
"0",
",",
"strpos",
"(",
"$",
"className",
",",
"ucfirst",
"(",
"$",
"this",
"->",
"classSuffix",
")",
")",
")",
",",
"'\\\\'",
")",
";",
"$",
"entityGenerator",
"=",
"$",
"factory",
"(",
"$",
"sourceClass",
",",
"$",
"className",
")",
";",
"return",
"$",
"entityGenerator",
";",
"}"
]
| Creates a generator
@param string $className
@return EntityAbstract | [
"Creates",
"a",
"generator"
]
| b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37 | https://github.com/EcomDev/phpspec-magento-di-adapter/blob/b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37/src/GeneratorWrapper.php#L69-L75 |
15,891 | verschoof/bunq-api | src/Resource/MonetaryAccountResource.php | MonetaryAccountResource.listMonetaryAccounts | public function listMonetaryAccounts($userId)
{
$monetaryAccounts = $this->client->get($this->getResourceEndpoint($userId));
return $monetaryAccounts;
} | php | public function listMonetaryAccounts($userId)
{
$monetaryAccounts = $this->client->get($this->getResourceEndpoint($userId));
return $monetaryAccounts;
} | [
"public",
"function",
"listMonetaryAccounts",
"(",
"$",
"userId",
")",
"{",
"$",
"monetaryAccounts",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"getResourceEndpoint",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"monetaryAccounts",
";",
"}"
]
| Lists all the Monetary accounts for the current user.
@param integer $userId
@return array | [
"Lists",
"all",
"the",
"Monetary",
"accounts",
"for",
"the",
"current",
"user",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Resource/MonetaryAccountResource.php#L29-L34 |
15,892 | verschoof/bunq-api | src/Resource/MonetaryAccountResource.php | MonetaryAccountResource.getMonetaryAccount | public function getMonetaryAccount($userId, $id)
{
$monetaryAccount = $this->client->get($this->getResourceEndpoint($userId) . '/' . (int)$id);
return $monetaryAccount['Response'][0]['MonetaryAccountBank'];
} | php | public function getMonetaryAccount($userId, $id)
{
$monetaryAccount = $this->client->get($this->getResourceEndpoint($userId) . '/' . (int)$id);
return $monetaryAccount['Response'][0]['MonetaryAccountBank'];
} | [
"public",
"function",
"getMonetaryAccount",
"(",
"$",
"userId",
",",
"$",
"id",
")",
"{",
"$",
"monetaryAccount",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"getResourceEndpoint",
"(",
"$",
"userId",
")",
".",
"'/'",
".",
"(",
"int",
")",
"$",
"id",
")",
";",
"return",
"$",
"monetaryAccount",
"[",
"'Response'",
"]",
"[",
"0",
"]",
"[",
"'MonetaryAccountBank'",
"]",
";",
"}"
]
| Gets a Monetary Account by its identifier.
@param integer $userId
@param integer $id
@return array | [
"Gets",
"a",
"Monetary",
"Account",
"by",
"its",
"identifier",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Resource/MonetaryAccountResource.php#L44-L49 |
15,893 | weavephp/weave | src/Router/Router.php | Router.run | protected function run(Request $request)
{
if (!$this->routesConfigured) {
$this->adaptor->configureRoutes($this->routeProvider);
$this->routesConfigured = true;
}
$handler = $this->adaptor->route($request);
if ($handler === false) {
return $this->chain($request);
}
// Setup any remaining chained parts of the dispatch for future dispatch
$request = $request->withAttribute('dispatch.handler', $this->resolver->shift($handler));
// Resolve the handler into something callable
$dispatchable = $this->resolver->resolve($handler, $resolutionType);
$parameters = [
$dispatchable,
$resolutionType,
DispatchAdaptorInterface::SOURCE_ROUTER,
$request
];
$response = $this->getResponseObject();
if ($response !== null) {
$parameters[] = $response;
}
return $this->dispatcher->dispatch(...$parameters) ?: $this->chain($request);
} | php | protected function run(Request $request)
{
if (!$this->routesConfigured) {
$this->adaptor->configureRoutes($this->routeProvider);
$this->routesConfigured = true;
}
$handler = $this->adaptor->route($request);
if ($handler === false) {
return $this->chain($request);
}
// Setup any remaining chained parts of the dispatch for future dispatch
$request = $request->withAttribute('dispatch.handler', $this->resolver->shift($handler));
// Resolve the handler into something callable
$dispatchable = $this->resolver->resolve($handler, $resolutionType);
$parameters = [
$dispatchable,
$resolutionType,
DispatchAdaptorInterface::SOURCE_ROUTER,
$request
];
$response = $this->getResponseObject();
if ($response !== null) {
$parameters[] = $response;
}
return $this->dispatcher->dispatch(...$parameters) ?: $this->chain($request);
} | [
"protected",
"function",
"run",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"routesConfigured",
")",
"{",
"$",
"this",
"->",
"adaptor",
"->",
"configureRoutes",
"(",
"$",
"this",
"->",
"routeProvider",
")",
";",
"$",
"this",
"->",
"routesConfigured",
"=",
"true",
";",
"}",
"$",
"handler",
"=",
"$",
"this",
"->",
"adaptor",
"->",
"route",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"handler",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"chain",
"(",
"$",
"request",
")",
";",
"}",
"// Setup any remaining chained parts of the dispatch for future dispatch",
"$",
"request",
"=",
"$",
"request",
"->",
"withAttribute",
"(",
"'dispatch.handler'",
",",
"$",
"this",
"->",
"resolver",
"->",
"shift",
"(",
"$",
"handler",
")",
")",
";",
"// Resolve the handler into something callable",
"$",
"dispatchable",
"=",
"$",
"this",
"->",
"resolver",
"->",
"resolve",
"(",
"$",
"handler",
",",
"$",
"resolutionType",
")",
";",
"$",
"parameters",
"=",
"[",
"$",
"dispatchable",
",",
"$",
"resolutionType",
",",
"DispatchAdaptorInterface",
"::",
"SOURCE_ROUTER",
",",
"$",
"request",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponseObject",
"(",
")",
";",
"if",
"(",
"$",
"response",
"!==",
"null",
")",
"{",
"$",
"parameters",
"[",
"]",
"=",
"$",
"response",
";",
"}",
"return",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"...",
"$",
"parameters",
")",
"?",
":",
"$",
"this",
"->",
"chain",
"(",
"$",
"request",
")",
";",
"}"
]
| Configure and then attempt to route and dispatch for the supplied Request.
@param Request $request The request to route.
@return Response | [
"Configure",
"and",
"then",
"attempt",
"to",
"route",
"and",
"dispatch",
"for",
"the",
"supplied",
"Request",
"."
]
| 44183a5bcb9e3ed3754cc76aa9e0724d718caeec | https://github.com/weavephp/weave/blob/44183a5bcb9e3ed3754cc76aa9e0724d718caeec/src/Router/Router.php#L82-L112 |
15,894 | acasademont/wurfl | WURFL/Storage/Base.php | WURFL_Storage_Base.setCacheStorage | public function setCacheStorage(WURFL_Storage_Base $cache)
{
if (!$this->supportsSecondaryCaching()) {
throw new WURFL_Storage_Exception("The storage provider ".get_class($cache)." cannot be used as a cache for ".get_class($this));
}
$this->cache = $cache;
} | php | public function setCacheStorage(WURFL_Storage_Base $cache)
{
if (!$this->supportsSecondaryCaching()) {
throw new WURFL_Storage_Exception("The storage provider ".get_class($cache)." cannot be used as a cache for ".get_class($this));
}
$this->cache = $cache;
} | [
"public",
"function",
"setCacheStorage",
"(",
"WURFL_Storage_Base",
"$",
"cache",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supportsSecondaryCaching",
"(",
")",
")",
"{",
"throw",
"new",
"WURFL_Storage_Exception",
"(",
"\"The storage provider \"",
".",
"get_class",
"(",
"$",
"cache",
")",
".",
"\" cannot be used as a cache for \"",
".",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"=",
"$",
"cache",
";",
"}"
]
| Sets the cache provider for the persistence provider; this is used to
cache data in a volatile storage system like APC in front of a slow
persistence provider like the filesystem.
@param WURFL_Storage_Base $cache | [
"Sets",
"the",
"cache",
"provider",
"for",
"the",
"persistence",
"provider",
";",
"this",
"is",
"used",
"to",
"cache",
"data",
"in",
"a",
"volatile",
"storage",
"system",
"like",
"APC",
"in",
"front",
"of",
"a",
"slow",
"persistence",
"provider",
"like",
"the",
"filesystem",
"."
]
| 0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2 | https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Storage/Base.php#L129-L135 |
15,895 | acasademont/wurfl | WURFL/Storage/Base.php | WURFL_Storage_Base.setWURFLLoaded | public function setWURFLLoaded($loaded = true)
{
$this->save(self::WURFL_LOADED, $loaded);
$this->cacheSave(self::WURFL_LOADED, new StorageObject($loaded, 0));
} | php | public function setWURFLLoaded($loaded = true)
{
$this->save(self::WURFL_LOADED, $loaded);
$this->cacheSave(self::WURFL_LOADED, new StorageObject($loaded, 0));
} | [
"public",
"function",
"setWURFLLoaded",
"(",
"$",
"loaded",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"save",
"(",
"self",
"::",
"WURFL_LOADED",
",",
"$",
"loaded",
")",
";",
"$",
"this",
"->",
"cacheSave",
"(",
"self",
"::",
"WURFL_LOADED",
",",
"new",
"StorageObject",
"(",
"$",
"loaded",
",",
"0",
")",
")",
";",
"}"
]
| Sets the WURFL Loaded flag
@param bool $loaded | [
"Sets",
"the",
"WURFL",
"Loaded",
"flag"
]
| 0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2 | https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Storage/Base.php#L182-L186 |
15,896 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.findAll | public function findAll($projections = array(), $sorts = array(), $options = array())
{
$options = $this->createOption($projections, $sorts, $options);
if (!isset($options['iterator']) || $options['iterator'] === false) {
$objects = parent::findAll($projections, $sorts, $options);
foreach ($objects as $object) {
if ($this->getStreamProjection($projections)) {
$data["stream"] = $this->bucket->openDownloadStream($object->getId());
}
$this->hydrator->hydrate($object, $data, true);
}
return $objects;
} else {
if (!is_string($options['iterator'])) {
$options['iterator'] = GridFSDocumentIterator::class;
}
return parent::findAll($projections, $sorts, $options);
}
} | php | public function findAll($projections = array(), $sorts = array(), $options = array())
{
$options = $this->createOption($projections, $sorts, $options);
if (!isset($options['iterator']) || $options['iterator'] === false) {
$objects = parent::findAll($projections, $sorts, $options);
foreach ($objects as $object) {
if ($this->getStreamProjection($projections)) {
$data["stream"] = $this->bucket->openDownloadStream($object->getId());
}
$this->hydrator->hydrate($object, $data, true);
}
return $objects;
} else {
if (!is_string($options['iterator'])) {
$options['iterator'] = GridFSDocumentIterator::class;
}
return parent::findAll($projections, $sorts, $options);
}
} | [
"public",
"function",
"findAll",
"(",
"$",
"projections",
"=",
"array",
"(",
")",
",",
"$",
"sorts",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"createOption",
"(",
"$",
"projections",
",",
"$",
"sorts",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'iterator'",
"]",
")",
"||",
"$",
"options",
"[",
"'iterator'",
"]",
"===",
"false",
")",
"{",
"$",
"objects",
"=",
"parent",
"::",
"findAll",
"(",
"$",
"projections",
",",
"$",
"sorts",
",",
"$",
"options",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStreamProjection",
"(",
"$",
"projections",
")",
")",
"{",
"$",
"data",
"[",
"\"stream\"",
"]",
"=",
"$",
"this",
"->",
"bucket",
"->",
"openDownloadStream",
"(",
"$",
"object",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"object",
",",
"$",
"data",
",",
"true",
")",
";",
"}",
"return",
"$",
"objects",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"options",
"[",
"'iterator'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'iterator'",
"]",
"=",
"GridFSDocumentIterator",
"::",
"class",
";",
"}",
"return",
"parent",
"::",
"findAll",
"(",
"$",
"projections",
",",
"$",
"sorts",
",",
"$",
"options",
")",
";",
"}",
"}"
]
| Get all documents of collection
Options :
* readOnly : boolean - When false, flush will not update object
* iterator : boolean|string - Return DocumentIterator if true (or specified class if is string)
@see MongoDB\Operation\Find::__construct for more option
@param array $projections Projection of the query
@param array $sorts Sorts specification
@param array $options Options for the query
@param array $options
@return void | [
"Get",
"all",
"documents",
"of",
"collection"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L113-L131 |
15,897 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.cacheObject | public function cacheObject($object)
{
if (is_object($object)) {
$unhyd = $this->hydrator->unhydrate($object);
unset($unhyd["stream"]);
$this->objectCache->save(spl_object_hash($object), $unhyd);
}
} | php | public function cacheObject($object)
{
if (is_object($object)) {
$unhyd = $this->hydrator->unhydrate($object);
unset($unhyd["stream"]);
$this->objectCache->save(spl_object_hash($object), $unhyd);
}
} | [
"public",
"function",
"cacheObject",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"$",
"unhyd",
"=",
"$",
"this",
"->",
"hydrator",
"->",
"unhydrate",
"(",
"$",
"object",
")",
";",
"unset",
"(",
"$",
"unhyd",
"[",
"\"stream\"",
"]",
")",
";",
"$",
"this",
"->",
"objectCache",
"->",
"save",
"(",
"spl_object_hash",
"(",
"$",
"object",
")",
",",
"$",
"unhyd",
")",
";",
"}",
"}"
]
| Store object in cache to see changes
@param object $object Object to cache
@return void | [
"Store",
"object",
"in",
"cache",
"to",
"see",
"changes"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L242-L249 |
15,898 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.insertOne | public function insertOne($document, $options = [])
{
$objectDatas = $this->hydrator->unhydrate($document);
$stream = $objectDatas["stream"];
unset($objectDatas["stream"]);
if (!isset($objectDatas["filename"])) {
$filename = stream_get_meta_data($stream)["uri"];
} else {
$filename = $objectDatas["filename"];
}
unset($objectDatas["filename"]);
$id = $this->bucket->uploadFromStream($filename, $stream, $objectDatas);
$data['_id'] = $id;
$data["stream"] = $this->bucket->openDownloadStream($data['_id']);
$this->hydrator->hydrate($document, $data, true);
$this->documentManager->setObjectState($document, ObjectManager::OBJ_MANAGED);
$this->cacheObject($document);
return true;
} | php | public function insertOne($document, $options = [])
{
$objectDatas = $this->hydrator->unhydrate($document);
$stream = $objectDatas["stream"];
unset($objectDatas["stream"]);
if (!isset($objectDatas["filename"])) {
$filename = stream_get_meta_data($stream)["uri"];
} else {
$filename = $objectDatas["filename"];
}
unset($objectDatas["filename"]);
$id = $this->bucket->uploadFromStream($filename, $stream, $objectDatas);
$data['_id'] = $id;
$data["stream"] = $this->bucket->openDownloadStream($data['_id']);
$this->hydrator->hydrate($document, $data, true);
$this->documentManager->setObjectState($document, ObjectManager::OBJ_MANAGED);
$this->cacheObject($document);
return true;
} | [
"public",
"function",
"insertOne",
"(",
"$",
"document",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"objectDatas",
"=",
"$",
"this",
"->",
"hydrator",
"->",
"unhydrate",
"(",
"$",
"document",
")",
";",
"$",
"stream",
"=",
"$",
"objectDatas",
"[",
"\"stream\"",
"]",
";",
"unset",
"(",
"$",
"objectDatas",
"[",
"\"stream\"",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"objectDatas",
"[",
"\"filename\"",
"]",
")",
")",
"{",
"$",
"filename",
"=",
"stream_get_meta_data",
"(",
"$",
"stream",
")",
"[",
"\"uri\"",
"]",
";",
"}",
"else",
"{",
"$",
"filename",
"=",
"$",
"objectDatas",
"[",
"\"filename\"",
"]",
";",
"}",
"unset",
"(",
"$",
"objectDatas",
"[",
"\"filename\"",
"]",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"bucket",
"->",
"uploadFromStream",
"(",
"$",
"filename",
",",
"$",
"stream",
",",
"$",
"objectDatas",
")",
";",
"$",
"data",
"[",
"'_id'",
"]",
"=",
"$",
"id",
";",
"$",
"data",
"[",
"\"stream\"",
"]",
"=",
"$",
"this",
"->",
"bucket",
"->",
"openDownloadStream",
"(",
"$",
"data",
"[",
"'_id'",
"]",
")",
";",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"document",
",",
"$",
"data",
",",
"true",
")",
";",
"$",
"this",
"->",
"documentManager",
"->",
"setObjectState",
"(",
"$",
"document",
",",
"ObjectManager",
"::",
"OBJ_MANAGED",
")",
";",
"$",
"this",
"->",
"cacheObject",
"(",
"$",
"document",
")",
";",
"return",
"true",
";",
"}"
]
| Insert a GridFS document
@param object $document Document to insert
@param array $options Useless, just for Repository compatibility
@return boolean | [
"Insert",
"a",
"GridFS",
"document"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L269-L294 |
15,899 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.insertMany | public function insertMany($documents, $options = [])
{
foreach ($documents as $document) {
if (!$this->insertOne($document)) {
return false;
}
}
return true;
} | php | public function insertMany($documents, $options = [])
{
foreach ($documents as $document) {
if (!$this->insertOne($document)) {
return false;
}
}
return true;
} | [
"public",
"function",
"insertMany",
"(",
"$",
"documents",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"documents",
"as",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"insertOne",
"(",
"$",
"document",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| Insert multiple GridFS documents
@param array $documents Documents to insert
@param array $options Useless, just for Repository compatibility
@return boolean | [
"Insert",
"multiple",
"GridFS",
"documents"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L303-L312 |
Subsets and Splits