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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
221,200
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.findOrCreate
|
public function findOrCreate($attributes)
{
$attributes = $this->castRequest($attributes);
if (!is_null($instance = $this->findWhere($attributes)->first())) {
return $instance;
}
return $this->create($attributes);
}
|
php
|
public function findOrCreate($attributes)
{
$attributes = $this->castRequest($attributes);
if (!is_null($instance = $this->findWhere($attributes)->first())) {
return $instance;
}
return $this->create($attributes);
}
|
[
"public",
"function",
"findOrCreate",
"(",
"$",
"attributes",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"castRequest",
"(",
"$",
"attributes",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"instance",
"=",
"$",
"this",
"->",
"findWhere",
"(",
"$",
"attributes",
")",
"->",
"first",
"(",
")",
")",
")",
"{",
"return",
"$",
"instance",
";",
"}",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"attributes",
")",
";",
"}"
] |
Find an entity matching the given attributes or create it.
@param array $attributes
|
[
"Find",
"an",
"entity",
"matching",
"the",
"given",
"attributes",
"or",
"create",
"it",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L174-L183
|
221,201
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.pluck
|
public function pluck($column, $key = null)
{
$cacheKey = $this->generateKey([$column, $key]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($column, $key) {
return $this->model->pluck($column, $key);
});
}
|
php
|
public function pluck($column, $key = null)
{
$cacheKey = $this->generateKey([$column, $key]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($column, $key) {
return $this->model->pluck($column, $key);
});
}
|
[
"public",
"function",
"pluck",
"(",
"$",
"column",
",",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"generateKey",
"(",
"[",
"$",
"column",
",",
"$",
"key",
"]",
")",
";",
"return",
"$",
"this",
"->",
"cacheResults",
"(",
"get_called_class",
"(",
")",
",",
"__FUNCTION__",
",",
"$",
"cacheKey",
",",
"function",
"(",
")",
"use",
"(",
"$",
"column",
",",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"pluck",
"(",
"$",
"column",
",",
"$",
"key",
")",
";",
"}",
")",
";",
"}"
] |
Get an array with the values of the given column from entities.
@param string $column
@param string|null $key
|
[
"Get",
"an",
"array",
"with",
"the",
"values",
"of",
"the",
"given",
"column",
"from",
"entities",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L191-L198
|
221,202
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.paginate
|
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$cacheKey = $this->generateKey([$perPage, $columns, $pageName, $page]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($perPage, $columns, $pageName, $page) {
return $this->model->paginate($perPage, $columns, $pageName, $page);
});
}
|
php
|
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$cacheKey = $this->generateKey([$perPage, $columns, $pageName, $page]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($perPage, $columns, $pageName, $page) {
return $this->model->paginate($perPage, $columns, $pageName, $page);
});
}
|
[
"public",
"function",
"paginate",
"(",
"$",
"perPage",
"=",
"null",
",",
"$",
"columns",
"=",
"[",
"'*'",
"]",
",",
"$",
"pageName",
"=",
"'page'",
",",
"$",
"page",
"=",
"null",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"generateKey",
"(",
"[",
"$",
"perPage",
",",
"$",
"columns",
",",
"$",
"pageName",
",",
"$",
"page",
"]",
")",
";",
"return",
"$",
"this",
"->",
"cacheResults",
"(",
"get_called_class",
"(",
")",
",",
"__FUNCTION__",
",",
"$",
"cacheKey",
",",
"function",
"(",
")",
"use",
"(",
"$",
"perPage",
",",
"$",
"columns",
",",
"$",
"pageName",
",",
"$",
"page",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"paginate",
"(",
"$",
"perPage",
",",
"$",
"columns",
",",
"$",
"pageName",
",",
"$",
"page",
")",
";",
"}",
")",
";",
"}"
] |
Paginate the given query for retrieving entities.
@param int|null $perPage
@param array $columns
@param string $pageName
@param int|null $page
|
[
"Paginate",
"the",
"given",
"query",
"for",
"retrieving",
"entities",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L208-L215
|
221,203
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.delete
|
public function delete($id)
{
$deleted = false;
$instance = $id instanceof Model ? $id : $this->find($id);
if ($instance) {
event(implode('-', $this->tag).'.entity.deleting', [$this, $instance]);
$deleted = $instance->delete();
event(implode('-', $this->tag).'.entity.deleted', [$this, $instance]);
}
return [
$deleted,
$instance,
];
}
|
php
|
public function delete($id)
{
$deleted = false;
$instance = $id instanceof Model ? $id : $this->find($id);
if ($instance) {
event(implode('-', $this->tag).'.entity.deleting', [$this, $instance]);
$deleted = $instance->delete();
event(implode('-', $this->tag).'.entity.deleted', [$this, $instance]);
}
return [
$deleted,
$instance,
];
}
|
[
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"deleted",
"=",
"false",
";",
"$",
"instance",
"=",
"$",
"id",
"instanceof",
"Model",
"?",
"$",
"id",
":",
"$",
"this",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"instance",
")",
"{",
"event",
"(",
"implode",
"(",
"'-'",
",",
"$",
"this",
"->",
"tag",
")",
".",
"'.entity.deleting'",
",",
"[",
"$",
"this",
",",
"$",
"instance",
"]",
")",
";",
"$",
"deleted",
"=",
"$",
"instance",
"->",
"delete",
"(",
")",
";",
"event",
"(",
"implode",
"(",
"'-'",
",",
"$",
"this",
"->",
"tag",
")",
".",
"'.entity.deleted'",
",",
"[",
"$",
"this",
",",
"$",
"instance",
"]",
")",
";",
"}",
"return",
"[",
"$",
"deleted",
",",
"$",
"instance",
",",
"]",
";",
"}"
] |
Delete an entity with the given ID.
@param mixed $id
@return array
|
[
"Delete",
"an",
"entity",
"with",
"the",
"given",
"ID",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L272-L289
|
221,204
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/VideoConverter.php
|
VideoConverter.videoToHtml
|
public function videoToHtml()
{
if (in_array($this->provider, $this->providers)) {
$caption = '';
if (!empty($this->caption)) {
$caption = $this->parser->toHtml($this->caption);
}
// View
return $this->view(
'video.'.$this->provider,
[
'remote' => $this->remoteId,
'caption' => $caption,
],
$this->provider
);
}
return '';
}
|
php
|
public function videoToHtml()
{
if (in_array($this->provider, $this->providers)) {
$caption = '';
if (!empty($this->caption)) {
$caption = $this->parser->toHtml($this->caption);
}
// View
return $this->view(
'video.'.$this->provider,
[
'remote' => $this->remoteId,
'caption' => $caption,
],
$this->provider
);
}
return '';
}
|
[
"public",
"function",
"videoToHtml",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"provider",
",",
"$",
"this",
"->",
"providers",
")",
")",
"{",
"$",
"caption",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"caption",
")",
")",
"{",
"$",
"caption",
"=",
"$",
"this",
"->",
"parser",
"->",
"toHtml",
"(",
"$",
"this",
"->",
"caption",
")",
";",
"}",
"// View",
"return",
"$",
"this",
"->",
"view",
"(",
"'video.'",
".",
"$",
"this",
"->",
"provider",
",",
"[",
"'remote'",
"=>",
"$",
"this",
"->",
"remoteId",
",",
"'caption'",
"=>",
"$",
"caption",
",",
"]",
",",
"$",
"this",
"->",
"provider",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Render of video tag.
@return string
|
[
"Render",
"of",
"video",
"tag",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/VideoConverter.php#L142-L162
|
221,205
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/JoinBuilder.php
|
JoinBuilder.orOn
|
public function orOn($key, $operator, $value): self
{
return $this->on($key, $operator, $value, 'OR');
}
|
php
|
public function orOn($key, $operator, $value): self
{
return $this->on($key, $operator, $value, 'OR');
}
|
[
"public",
"function",
"orOn",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"on",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
",",
"'OR'",
")",
";",
"}"
] |
Add OR ON join
@param string|Raw|\Closure $key
@param string|Raw|\Closure $operator
@param string|Raw|\Closure $value
@return static
|
[
"Add",
"OR",
"ON",
"join"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/JoinBuilder.php#L60-L63
|
221,206
|
caffeinated/repository
|
src/Repositories/Repository.php
|
Repository.cacheResults
|
protected function cacheResults($class, $method, $key, $closure)
{
$key = $class.'@'.$method.'.'.$key;
if (method_exists(app()->make('cache')->getStore(), 'tags')) {
return app()->make('cache')->tags($this->tag)->remember($key, 60, $closure);
}
return call_user_func($closure);
}
|
php
|
protected function cacheResults($class, $method, $key, $closure)
{
$key = $class.'@'.$method.'.'.$key;
if (method_exists(app()->make('cache')->getStore(), 'tags')) {
return app()->make('cache')->tags($this->tag)->remember($key, 60, $closure);
}
return call_user_func($closure);
}
|
[
"protected",
"function",
"cacheResults",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"key",
",",
"$",
"closure",
")",
"{",
"$",
"key",
"=",
"$",
"class",
".",
"'@'",
".",
"$",
"method",
".",
"'.'",
".",
"$",
"key",
";",
"if",
"(",
"method_exists",
"(",
"app",
"(",
")",
"->",
"make",
"(",
"'cache'",
")",
"->",
"getStore",
"(",
")",
",",
"'tags'",
")",
")",
"{",
"return",
"app",
"(",
")",
"->",
"make",
"(",
"'cache'",
")",
"->",
"tags",
"(",
"$",
"this",
"->",
"tag",
")",
"->",
"remember",
"(",
"$",
"key",
",",
"60",
",",
"$",
"closure",
")",
";",
"}",
"return",
"call_user_func",
"(",
"$",
"closure",
")",
";",
"}"
] |
Execute the provided callback and cache the results.
@param string $class
@param string $method
@param string $key
@param Closure $closure
@return mixed
|
[
"Execute",
"the",
"provided",
"callback",
"and",
"cache",
"the",
"results",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/Repository.php#L99-L108
|
221,207
|
caffeinated/repository
|
src/Repositories/Repository.php
|
Repository.flushCache
|
public function flushCache()
{
if (method_exists(app()->make('cache')->getStore(), 'tags')) {
app()->make('cache')->tags($this->tag)->flush();
event(implode('-', $this->tag).'.entity.cache.flushed', [$this]);
}
return $this;
}
|
php
|
public function flushCache()
{
if (method_exists(app()->make('cache')->getStore(), 'tags')) {
app()->make('cache')->tags($this->tag)->flush();
event(implode('-', $this->tag).'.entity.cache.flushed', [$this]);
}
return $this;
}
|
[
"public",
"function",
"flushCache",
"(",
")",
"{",
"if",
"(",
"method_exists",
"(",
"app",
"(",
")",
"->",
"make",
"(",
"'cache'",
")",
"->",
"getStore",
"(",
")",
",",
"'tags'",
")",
")",
"{",
"app",
"(",
")",
"->",
"make",
"(",
"'cache'",
")",
"->",
"tags",
"(",
"$",
"this",
"->",
"tag",
")",
"->",
"flush",
"(",
")",
";",
"event",
"(",
"implode",
"(",
"'-'",
",",
"$",
"this",
"->",
"tag",
")",
".",
"'.entity.cache.flushed'",
",",
"[",
"$",
"this",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Flush the repository cache results.
@return $this
|
[
"Flush",
"the",
"repository",
"cache",
"results",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/Repository.php#L115-L124
|
221,208
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/Connection.php
|
Connection.connect
|
public function connect(): self
{
if ($this->pdoInstance !== null) {
return $this;
}
// Build a database connection if we don't have one connected
$this->setPdoInstance($this->getAdapter()->connect($this->getAdapterConfig()));
return $this;
}
|
php
|
public function connect(): self
{
if ($this->pdoInstance !== null) {
return $this;
}
// Build a database connection if we don't have one connected
$this->setPdoInstance($this->getAdapter()->connect($this->getAdapterConfig()));
return $this;
}
|
[
"public",
"function",
"connect",
"(",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"pdoInstance",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// Build a database connection if we don't have one connected",
"$",
"this",
"->",
"setPdoInstance",
"(",
"$",
"this",
"->",
"getAdapter",
"(",
")",
"->",
"connect",
"(",
"$",
"this",
"->",
"getAdapterConfig",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Create the connection adapter and connect to database
@return static
|
[
"Create",
"the",
"connection",
"adapter",
"and",
"connect",
"to",
"database"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/Connection.php#L84-L94
|
221,209
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/TextConverter.php
|
TextConverter.blockquoteToHtml
|
public function blockquoteToHtml()
{
// remove the indent thats added by Sir Trevor
return $this->view('text.blockquote', [
'cite' => $this->data['cite'] ?? '',
'text' => $this->parser->toHtml(ltrim($this->data['text'], '>')),
]);
}
|
php
|
public function blockquoteToHtml()
{
// remove the indent thats added by Sir Trevor
return $this->view('text.blockquote', [
'cite' => $this->data['cite'] ?? '',
'text' => $this->parser->toHtml(ltrim($this->data['text'], '>')),
]);
}
|
[
"public",
"function",
"blockquoteToHtml",
"(",
")",
"{",
"// remove the indent thats added by Sir Trevor",
"return",
"$",
"this",
"->",
"view",
"(",
"'text.blockquote'",
",",
"[",
"'cite'",
"=>",
"$",
"this",
"->",
"data",
"[",
"'cite'",
"]",
"??",
"''",
",",
"'text'",
"=>",
"$",
"this",
"->",
"parser",
"->",
"toHtml",
"(",
"ltrim",
"(",
"$",
"this",
"->",
"data",
"[",
"'text'",
"]",
",",
"'>'",
")",
")",
",",
"]",
")",
";",
"}"
] |
Converts block quotes to html.
@return string
|
[
"Converts",
"block",
"quotes",
"to",
"html",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/TextConverter.php#L81-L88
|
221,210
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
|
BaseAdapter.arrayStr
|
protected function arrayStr(array $pieces, string $glue = ',', bool $wrapSanitizer = true): string
{
$str = '';
foreach ($pieces as $key => $piece) {
if ($wrapSanitizer === true) {
$piece = $this->wrapSanitizer($piece);
}
if (\is_int($key) === false) {
$piece = ($wrapSanitizer ? $this->wrapSanitizer($key) : $key) . ' AS ' . $piece;
}
$str .= $piece . $glue;
}
return trim($str, $glue);
}
|
php
|
protected function arrayStr(array $pieces, string $glue = ',', bool $wrapSanitizer = true): string
{
$str = '';
foreach ($pieces as $key => $piece) {
if ($wrapSanitizer === true) {
$piece = $this->wrapSanitizer($piece);
}
if (\is_int($key) === false) {
$piece = ($wrapSanitizer ? $this->wrapSanitizer($key) : $key) . ' AS ' . $piece;
}
$str .= $piece . $glue;
}
return trim($str, $glue);
}
|
[
"protected",
"function",
"arrayStr",
"(",
"array",
"$",
"pieces",
",",
"string",
"$",
"glue",
"=",
"','",
",",
"bool",
"$",
"wrapSanitizer",
"=",
"true",
")",
":",
"string",
"{",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"pieces",
"as",
"$",
"key",
"=>",
"$",
"piece",
")",
"{",
"if",
"(",
"$",
"wrapSanitizer",
"===",
"true",
")",
"{",
"$",
"piece",
"=",
"$",
"this",
"->",
"wrapSanitizer",
"(",
"$",
"piece",
")",
";",
"}",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"key",
")",
"===",
"false",
")",
"{",
"$",
"piece",
"=",
"(",
"$",
"wrapSanitizer",
"?",
"$",
"this",
"->",
"wrapSanitizer",
"(",
"$",
"key",
")",
":",
"$",
"key",
")",
".",
"' AS '",
".",
"$",
"piece",
";",
"}",
"$",
"str",
".=",
"$",
"piece",
".",
"$",
"glue",
";",
"}",
"return",
"trim",
"(",
"$",
"str",
",",
"$",
"glue",
")",
";",
"}"
] |
Array concatenating method, like implode.
But it does wrap sanitizer and trims last glue
@param array $pieces
@param string $glue
@param bool $wrapSanitizer
@return string
|
[
"Array",
"concatenating",
"method",
"like",
"implode",
".",
"But",
"it",
"does",
"wrap",
"sanitizer",
"and",
"trims",
"last",
"glue"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php#L73-L89
|
221,211
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
|
BaseAdapter.concatenateQuery
|
protected function concatenateQuery(array $pieces): string
{
$str = '';
foreach ($pieces as $piece) {
$str = trim($str) . ' ' . trim($piece);
}
return trim($str);
}
|
php
|
protected function concatenateQuery(array $pieces): string
{
$str = '';
foreach ($pieces as $piece) {
$str = trim($str) . ' ' . trim($piece);
}
return trim($str);
}
|
[
"protected",
"function",
"concatenateQuery",
"(",
"array",
"$",
"pieces",
")",
":",
"string",
"{",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"pieces",
"as",
"$",
"piece",
")",
"{",
"$",
"str",
"=",
"trim",
"(",
"$",
"str",
")",
".",
"' '",
".",
"trim",
"(",
"$",
"piece",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"str",
")",
";",
"}"
] |
Join different part of queries with a space.
@param array $pieces
@return string
|
[
"Join",
"different",
"part",
"of",
"queries",
"with",
"a",
"space",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php#L290-L298
|
221,212
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
|
BaseAdapter.criteriaOnly
|
public function criteriaOnly(array $statements, $bindValues = true): array
{
$sql = $bindings = [];
if (isset($statements['criteria']) === false) {
return compact('sql', 'bindings');
}
[$sql, $bindings] = $this->buildCriteria($statements['criteria'], $bindValues);
return compact('sql', 'bindings');
}
|
php
|
public function criteriaOnly(array $statements, $bindValues = true): array
{
$sql = $bindings = [];
if (isset($statements['criteria']) === false) {
return compact('sql', 'bindings');
}
[$sql, $bindings] = $this->buildCriteria($statements['criteria'], $bindValues);
return compact('sql', 'bindings');
}
|
[
"public",
"function",
"criteriaOnly",
"(",
"array",
"$",
"statements",
",",
"$",
"bindValues",
"=",
"true",
")",
":",
"array",
"{",
"$",
"sql",
"=",
"$",
"bindings",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"statements",
"[",
"'criteria'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"compact",
"(",
"'sql'",
",",
"'bindings'",
")",
";",
"}",
"[",
"$",
"sql",
",",
"$",
"bindings",
"]",
"=",
"$",
"this",
"->",
"buildCriteria",
"(",
"$",
"statements",
"[",
"'criteria'",
"]",
",",
"$",
"bindValues",
")",
";",
"return",
"compact",
"(",
"'sql'",
",",
"'bindings'",
")",
";",
"}"
] |
Build just criteria part of the query
@param array $statements
@param bool $bindValues
@return array
@throws Exception
|
[
"Build",
"just",
"criteria",
"part",
"of",
"the",
"query"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php#L309-L319
|
221,213
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
|
BaseAdapter.buildQueryPart
|
protected function buildQueryPart(string $section, array $statements): string
{
switch ($section) {
case static::QUERY_PART_JOIN:
return $this->buildJoin($statements);
case static::QUERY_PART_LIMIT:
return isset($statements['limit']) ? 'LIMIT ' . $statements['limit'] : '';
case static::QUERY_PART_OFFSET:
return isset($statements['offset']) ? 'OFFSET ' . $statements['offset'] : '';
case static::QUERY_PART_ORDERBY:
$orderBys = '';
if (isset($statements['orderBys']) === true && \is_array($statements['orderBys']) === true) {
foreach ($statements['orderBys'] as $orderBy) {
$orderBys .= $this->wrapSanitizer($orderBy['field']) . ' ' . $orderBy['type'] . ', ';
}
if ($orderBys = trim($orderBys, ', ')) {
$orderBys = 'ORDER BY ' . $orderBys;
}
}
return $orderBys;
case static::QUERY_PART_GROUPBY:
$groupBys = $this->arrayStr($statements['groupBys'], ', ');
if ($groupBys !== '' && isset($statements['groupBys']) === true) {
$groupBys = 'GROUP BY ' . $groupBys;
}
return $groupBys;
}
return '';
}
|
php
|
protected function buildQueryPart(string $section, array $statements): string
{
switch ($section) {
case static::QUERY_PART_JOIN:
return $this->buildJoin($statements);
case static::QUERY_PART_LIMIT:
return isset($statements['limit']) ? 'LIMIT ' . $statements['limit'] : '';
case static::QUERY_PART_OFFSET:
return isset($statements['offset']) ? 'OFFSET ' . $statements['offset'] : '';
case static::QUERY_PART_ORDERBY:
$orderBys = '';
if (isset($statements['orderBys']) === true && \is_array($statements['orderBys']) === true) {
foreach ($statements['orderBys'] as $orderBy) {
$orderBys .= $this->wrapSanitizer($orderBy['field']) . ' ' . $orderBy['type'] . ', ';
}
if ($orderBys = trim($orderBys, ', ')) {
$orderBys = 'ORDER BY ' . $orderBys;
}
}
return $orderBys;
case static::QUERY_PART_GROUPBY:
$groupBys = $this->arrayStr($statements['groupBys'], ', ');
if ($groupBys !== '' && isset($statements['groupBys']) === true) {
$groupBys = 'GROUP BY ' . $groupBys;
}
return $groupBys;
}
return '';
}
|
[
"protected",
"function",
"buildQueryPart",
"(",
"string",
"$",
"section",
",",
"array",
"$",
"statements",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"section",
")",
"{",
"case",
"static",
"::",
"QUERY_PART_JOIN",
":",
"return",
"$",
"this",
"->",
"buildJoin",
"(",
"$",
"statements",
")",
";",
"case",
"static",
"::",
"QUERY_PART_LIMIT",
":",
"return",
"isset",
"(",
"$",
"statements",
"[",
"'limit'",
"]",
")",
"?",
"'LIMIT '",
".",
"$",
"statements",
"[",
"'limit'",
"]",
":",
"''",
";",
"case",
"static",
"::",
"QUERY_PART_OFFSET",
":",
"return",
"isset",
"(",
"$",
"statements",
"[",
"'offset'",
"]",
")",
"?",
"'OFFSET '",
".",
"$",
"statements",
"[",
"'offset'",
"]",
":",
"''",
";",
"case",
"static",
"::",
"QUERY_PART_ORDERBY",
":",
"$",
"orderBys",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"statements",
"[",
"'orderBys'",
"]",
")",
"===",
"true",
"&&",
"\\",
"is_array",
"(",
"$",
"statements",
"[",
"'orderBys'",
"]",
")",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"statements",
"[",
"'orderBys'",
"]",
"as",
"$",
"orderBy",
")",
"{",
"$",
"orderBys",
".=",
"$",
"this",
"->",
"wrapSanitizer",
"(",
"$",
"orderBy",
"[",
"'field'",
"]",
")",
".",
"' '",
".",
"$",
"orderBy",
"[",
"'type'",
"]",
".",
"', '",
";",
"}",
"if",
"(",
"$",
"orderBys",
"=",
"trim",
"(",
"$",
"orderBys",
",",
"', '",
")",
")",
"{",
"$",
"orderBys",
"=",
"'ORDER BY '",
".",
"$",
"orderBys",
";",
"}",
"}",
"return",
"$",
"orderBys",
";",
"case",
"static",
"::",
"QUERY_PART_GROUPBY",
":",
"$",
"groupBys",
"=",
"$",
"this",
"->",
"arrayStr",
"(",
"$",
"statements",
"[",
"'groupBys'",
"]",
",",
"', '",
")",
";",
"if",
"(",
"$",
"groupBys",
"!==",
"''",
"&&",
"isset",
"(",
"$",
"statements",
"[",
"'groupBys'",
"]",
")",
"===",
"true",
")",
"{",
"$",
"groupBys",
"=",
"'GROUP BY '",
".",
"$",
"groupBys",
";",
"}",
"return",
"$",
"groupBys",
";",
"}",
"return",
"''",
";",
"}"
] |
Returns specific part of a query like JOIN, LIMIT, OFFSET etc.
@param string $section
@param array $statements
@return string
@throws Exception
|
[
"Returns",
"specific",
"part",
"of",
"a",
"query",
"like",
"JOIN",
"LIMIT",
"OFFSET",
"etc",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php#L576-L608
|
221,214
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
|
BaseAdapter.buildUnion
|
protected function buildUnion(array $statements, string $sql): string
{
if (isset($statements['unions']) === false || \count($statements['unions']) === 0) {
return $sql;
}
foreach ((array)$statements['unions'] as $i => $union) {
/* @var $queryBuilder QueryBuilderHandler */
$queryBuilder = $union['query'];
if ($i === 0) {
$sql .= ')';
}
$type = ($union['type'] !== QueryBuilderHandler::UNION_TYPE_NONE) ? $union['type'] . ' ' : '';
$sql .= sprintf(' UNION %s(%s)', $type, $queryBuilder->getQuery('select')->getRawSql());
}
return sprintf('(%s', $sql);
}
|
php
|
protected function buildUnion(array $statements, string $sql): string
{
if (isset($statements['unions']) === false || \count($statements['unions']) === 0) {
return $sql;
}
foreach ((array)$statements['unions'] as $i => $union) {
/* @var $queryBuilder QueryBuilderHandler */
$queryBuilder = $union['query'];
if ($i === 0) {
$sql .= ')';
}
$type = ($union['type'] !== QueryBuilderHandler::UNION_TYPE_NONE) ? $union['type'] . ' ' : '';
$sql .= sprintf(' UNION %s(%s)', $type, $queryBuilder->getQuery('select')->getRawSql());
}
return sprintf('(%s', $sql);
}
|
[
"protected",
"function",
"buildUnion",
"(",
"array",
"$",
"statements",
",",
"string",
"$",
"sql",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"statements",
"[",
"'unions'",
"]",
")",
"===",
"false",
"||",
"\\",
"count",
"(",
"$",
"statements",
"[",
"'unions'",
"]",
")",
"===",
"0",
")",
"{",
"return",
"$",
"sql",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"statements",
"[",
"'unions'",
"]",
"as",
"$",
"i",
"=>",
"$",
"union",
")",
"{",
"/* @var $queryBuilder QueryBuilderHandler */",
"$",
"queryBuilder",
"=",
"$",
"union",
"[",
"'query'",
"]",
";",
"if",
"(",
"$",
"i",
"===",
"0",
")",
"{",
"$",
"sql",
".=",
"')'",
";",
"}",
"$",
"type",
"=",
"(",
"$",
"union",
"[",
"'type'",
"]",
"!==",
"QueryBuilderHandler",
"::",
"UNION_TYPE_NONE",
")",
"?",
"$",
"union",
"[",
"'type'",
"]",
".",
"' '",
":",
"''",
";",
"$",
"sql",
".=",
"sprintf",
"(",
"' UNION %s(%s)'",
",",
"$",
"type",
",",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
"'select'",
")",
"->",
"getRawSql",
"(",
")",
")",
";",
"}",
"return",
"sprintf",
"(",
"'(%s'",
",",
"$",
"sql",
")",
";",
"}"
] |
Adds union query to sql statement
@param array $statements
@param string $sql
@return string
@throws Exception
|
[
"Adds",
"union",
"query",
"to",
"sql",
"statement"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php#L618-L637
|
221,215
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
|
BaseAdapter.wrapSanitizer
|
public function wrapSanitizer($value)
{
// Its a raw query, just cast as string, object has __toString()
if ($value instanceof Raw) {
return (string)$value;
}
if ($value instanceof \Closure) {
return $value;
}
// Separate our table and fields which are joined with a ".", like my_table.id
$valueArr = explode('.', $value, 2);
foreach ($valueArr as $key => $subValue) {
// Don't wrap if we have *, which is not a usual field
$valueArr[$key] = trim($subValue) === '*' ? $subValue : static::SANITIZER . $subValue . static::SANITIZER;
}
// Join these back with "." and return
return implode('.', $valueArr);
}
|
php
|
public function wrapSanitizer($value)
{
// Its a raw query, just cast as string, object has __toString()
if ($value instanceof Raw) {
return (string)$value;
}
if ($value instanceof \Closure) {
return $value;
}
// Separate our table and fields which are joined with a ".", like my_table.id
$valueArr = explode('.', $value, 2);
foreach ($valueArr as $key => $subValue) {
// Don't wrap if we have *, which is not a usual field
$valueArr[$key] = trim($subValue) === '*' ? $subValue : static::SANITIZER . $subValue . static::SANITIZER;
}
// Join these back with "." and return
return implode('.', $valueArr);
}
|
[
"public",
"function",
"wrapSanitizer",
"(",
"$",
"value",
")",
"{",
"// Its a raw query, just cast as string, object has __toString()",
"if",
"(",
"$",
"value",
"instanceof",
"Raw",
")",
"{",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Closure",
")",
"{",
"return",
"$",
"value",
";",
"}",
"// Separate our table and fields which are joined with a \".\", like my_table.id",
"$",
"valueArr",
"=",
"explode",
"(",
"'.'",
",",
"$",
"value",
",",
"2",
")",
";",
"foreach",
"(",
"$",
"valueArr",
"as",
"$",
"key",
"=>",
"$",
"subValue",
")",
"{",
"// Don't wrap if we have *, which is not a usual field",
"$",
"valueArr",
"[",
"$",
"key",
"]",
"=",
"trim",
"(",
"$",
"subValue",
")",
"===",
"'*'",
"?",
"$",
"subValue",
":",
"static",
"::",
"SANITIZER",
".",
"$",
"subValue",
".",
"static",
"::",
"SANITIZER",
";",
"}",
"// Join these back with \".\" and return",
"return",
"implode",
"(",
"'.'",
",",
"$",
"valueArr",
")",
";",
"}"
] |
Wrap values with adapter's sanitizer like, '`'
@param string|Raw|\Closure $value
@return string|\Closure
|
[
"Wrap",
"values",
"with",
"adapter",
"s",
"sanitizer",
"like"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php#L688-L709
|
221,216
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/ValueObject/Api.php
|
Api.build
|
public static function build($name, $version, $description)
{
$api = new static();
$api->name = $name;
$api->apiVersion = $version;
$api->description = $description;
return $api;
}
|
php
|
public static function build($name, $version, $description)
{
$api = new static();
$api->name = $name;
$api->apiVersion = $version;
$api->description = $description;
return $api;
}
|
[
"public",
"static",
"function",
"build",
"(",
"$",
"name",
",",
"$",
"version",
",",
"$",
"description",
")",
"{",
"$",
"api",
"=",
"new",
"static",
"(",
")",
";",
"$",
"api",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"api",
"->",
"apiVersion",
"=",
"$",
"version",
";",
"$",
"api",
"->",
"description",
"=",
"$",
"description",
";",
"return",
"$",
"api",
";",
"}"
] |
Build a new API Object.
@param string $name
@param string $version
@param string $description
@return static
|
[
"Build",
"a",
"new",
"API",
"Object",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/ValueObject/Api.php#L36-L44
|
221,217
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/ValueObject/Api.php
|
Api.addOperation
|
public function addOperation(Operation $operation)
{
$this->operations[$operation->name] = $operation;
ksort($this->operations);
}
|
php
|
public function addOperation(Operation $operation)
{
$this->operations[$operation->name] = $operation;
ksort($this->operations);
}
|
[
"public",
"function",
"addOperation",
"(",
"Operation",
"$",
"operation",
")",
"{",
"$",
"this",
"->",
"operations",
"[",
"$",
"operation",
"->",
"name",
"]",
"=",
"$",
"operation",
";",
"ksort",
"(",
"$",
"this",
"->",
"operations",
")",
";",
"}"
] |
Adds a new operation.
@param Operation $operation
|
[
"Adds",
"a",
"new",
"operation",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/ValueObject/Api.php#L51-L55
|
221,218
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Controller/TraitSirTrevorJsController.php
|
TraitSirTrevorJsController.upload
|
public function upload(Request $request)
{
if ($request->hasFile('attachment')) {
// config
$config = config('sir-trevor-js');
// file
$file = $request->file('attachment');
// Problem on some configurations
$file = (!method_exists($file, 'getClientOriginalName')) ? $file['file'] : $file;
// filename
$filename = $file->getClientOriginalName();
// suffixe if file exists
$suffixe = '01';
// verif if file exists
while (file_exists(public_path($config['directory_upload']).'/'.$filename)) {
$filename = $suffixe.'_'.$filename;
++$suffixe;
if ($suffixe < 10) {
$suffixe = '0'.$suffixe;
}
}
if ($file->move(public_path($config['directory_upload']), $filename)) {
$return = [
'file' => [
'url' => '/'.$config['directory_upload'].'/'.$filename,
],
];
echo json_encode($return);
}
}
}
|
php
|
public function upload(Request $request)
{
if ($request->hasFile('attachment')) {
// config
$config = config('sir-trevor-js');
// file
$file = $request->file('attachment');
// Problem on some configurations
$file = (!method_exists($file, 'getClientOriginalName')) ? $file['file'] : $file;
// filename
$filename = $file->getClientOriginalName();
// suffixe if file exists
$suffixe = '01';
// verif if file exists
while (file_exists(public_path($config['directory_upload']).'/'.$filename)) {
$filename = $suffixe.'_'.$filename;
++$suffixe;
if ($suffixe < 10) {
$suffixe = '0'.$suffixe;
}
}
if ($file->move(public_path($config['directory_upload']), $filename)) {
$return = [
'file' => [
'url' => '/'.$config['directory_upload'].'/'.$filename,
],
];
echo json_encode($return);
}
}
}
|
[
"public",
"function",
"upload",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"hasFile",
"(",
"'attachment'",
")",
")",
"{",
"// config",
"$",
"config",
"=",
"config",
"(",
"'sir-trevor-js'",
")",
";",
"// file",
"$",
"file",
"=",
"$",
"request",
"->",
"file",
"(",
"'attachment'",
")",
";",
"// Problem on some configurations",
"$",
"file",
"=",
"(",
"!",
"method_exists",
"(",
"$",
"file",
",",
"'getClientOriginalName'",
")",
")",
"?",
"$",
"file",
"[",
"'file'",
"]",
":",
"$",
"file",
";",
"// filename",
"$",
"filename",
"=",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
";",
"// suffixe if file exists",
"$",
"suffixe",
"=",
"'01'",
";",
"// verif if file exists",
"while",
"(",
"file_exists",
"(",
"public_path",
"(",
"$",
"config",
"[",
"'directory_upload'",
"]",
")",
".",
"'/'",
".",
"$",
"filename",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"suffixe",
".",
"'_'",
".",
"$",
"filename",
";",
"++",
"$",
"suffixe",
";",
"if",
"(",
"$",
"suffixe",
"<",
"10",
")",
"{",
"$",
"suffixe",
"=",
"'0'",
".",
"$",
"suffixe",
";",
"}",
"}",
"if",
"(",
"$",
"file",
"->",
"move",
"(",
"public_path",
"(",
"$",
"config",
"[",
"'directory_upload'",
"]",
")",
",",
"$",
"filename",
")",
")",
"{",
"$",
"return",
"=",
"[",
"'file'",
"=>",
"[",
"'url'",
"=>",
"'/'",
".",
"$",
"config",
"[",
"'directory_upload'",
"]",
".",
"'/'",
".",
"$",
"filename",
",",
"]",
",",
"]",
";",
"echo",
"json_encode",
"(",
"$",
"return",
")",
";",
"}",
"}",
"}"
] |
Upload image.
@internal you can define `directory_upload` in config file
@param Request $request
|
[
"Upload",
"image",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Controller/TraitSirTrevorJsController.php#L28-L67
|
221,219
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/Command/DocsToJsonCommand.php
|
DocsToJsonCommand.parseDocuments
|
protected function parseDocuments()
{
$this->apis = array(
3 => Api::build('Meetup', 3, 'Meetup API v3 methods'),
2 => Api::build('Meetup', 2, 'Meetup API v2 methods'),
1 => Api::build('Meetup', 1, 'Meetup API v1 methods'),
'stream' => Api::build('Meetup', 'stream', 'Meetup API Stream methods'),
);
$this->output->writeln('Downloading data from API docs ...');
$data = $this->getApiData();
/** @var TableHelper $nameConversionTable */
$nameConversionTable = $this->getHelper('table');
$nameConversionTable->setHeaders(array('v', 'Docs Name', 'Method', 'Path', 'Final Method Name'));
$this->output->writeln('Parsing data from API docs ...');
foreach ($data['docs'] as $definition) {
$operation = Operation::createFromApiJsonDocs($definition);
if ($operation === null) {
continue;
}
$nameConversionTable->addRow(array(
$operation->version,
arr::get('name', $definition),
arr::get('http_method', $definition),
arr::get('path', $definition),
$operation->name,
));
$this->apis[$operation->version]->addOperation($operation);
}
DuplicateResolver::processApis($this->apis);
if ($this->input->getOption('debug-names')) {
$nameConversionTable->render($this->output);
}
}
|
php
|
protected function parseDocuments()
{
$this->apis = array(
3 => Api::build('Meetup', 3, 'Meetup API v3 methods'),
2 => Api::build('Meetup', 2, 'Meetup API v2 methods'),
1 => Api::build('Meetup', 1, 'Meetup API v1 methods'),
'stream' => Api::build('Meetup', 'stream', 'Meetup API Stream methods'),
);
$this->output->writeln('Downloading data from API docs ...');
$data = $this->getApiData();
/** @var TableHelper $nameConversionTable */
$nameConversionTable = $this->getHelper('table');
$nameConversionTable->setHeaders(array('v', 'Docs Name', 'Method', 'Path', 'Final Method Name'));
$this->output->writeln('Parsing data from API docs ...');
foreach ($data['docs'] as $definition) {
$operation = Operation::createFromApiJsonDocs($definition);
if ($operation === null) {
continue;
}
$nameConversionTable->addRow(array(
$operation->version,
arr::get('name', $definition),
arr::get('http_method', $definition),
arr::get('path', $definition),
$operation->name,
));
$this->apis[$operation->version]->addOperation($operation);
}
DuplicateResolver::processApis($this->apis);
if ($this->input->getOption('debug-names')) {
$nameConversionTable->render($this->output);
}
}
|
[
"protected",
"function",
"parseDocuments",
"(",
")",
"{",
"$",
"this",
"->",
"apis",
"=",
"array",
"(",
"3",
"=>",
"Api",
"::",
"build",
"(",
"'Meetup'",
",",
"3",
",",
"'Meetup API v3 methods'",
")",
",",
"2",
"=>",
"Api",
"::",
"build",
"(",
"'Meetup'",
",",
"2",
",",
"'Meetup API v2 methods'",
")",
",",
"1",
"=>",
"Api",
"::",
"build",
"(",
"'Meetup'",
",",
"1",
",",
"'Meetup API v1 methods'",
")",
",",
"'stream'",
"=>",
"Api",
"::",
"build",
"(",
"'Meetup'",
",",
"'stream'",
",",
"'Meetup API Stream methods'",
")",
",",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'Downloading data from API docs ...'",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getApiData",
"(",
")",
";",
"/** @var TableHelper $nameConversionTable */",
"$",
"nameConversionTable",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'table'",
")",
";",
"$",
"nameConversionTable",
"->",
"setHeaders",
"(",
"array",
"(",
"'v'",
",",
"'Docs Name'",
",",
"'Method'",
",",
"'Path'",
",",
"'Final Method Name'",
")",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'Parsing data from API docs ...'",
")",
";",
"foreach",
"(",
"$",
"data",
"[",
"'docs'",
"]",
"as",
"$",
"definition",
")",
"{",
"$",
"operation",
"=",
"Operation",
"::",
"createFromApiJsonDocs",
"(",
"$",
"definition",
")",
";",
"if",
"(",
"$",
"operation",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"nameConversionTable",
"->",
"addRow",
"(",
"array",
"(",
"$",
"operation",
"->",
"version",
",",
"arr",
"::",
"get",
"(",
"'name'",
",",
"$",
"definition",
")",
",",
"arr",
"::",
"get",
"(",
"'http_method'",
",",
"$",
"definition",
")",
",",
"arr",
"::",
"get",
"(",
"'path'",
",",
"$",
"definition",
")",
",",
"$",
"operation",
"->",
"name",
",",
")",
")",
";",
"$",
"this",
"->",
"apis",
"[",
"$",
"operation",
"->",
"version",
"]",
"->",
"addOperation",
"(",
"$",
"operation",
")",
";",
"}",
"DuplicateResolver",
"::",
"processApis",
"(",
"$",
"this",
"->",
"apis",
")",
";",
"if",
"(",
"$",
"this",
"->",
"input",
"->",
"getOption",
"(",
"'debug-names'",
")",
")",
"{",
"$",
"nameConversionTable",
"->",
"render",
"(",
"$",
"this",
"->",
"output",
")",
";",
"}",
"}"
] |
Parse API Docs.
|
[
"Parse",
"API",
"Docs",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/Command/DocsToJsonCommand.php#L89-L129
|
221,220
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/Command/DocsToJsonCommand.php
|
DocsToJsonCommand.getApiData
|
public function getApiData()
{
$client = new Client(self::API_DOCS);
$response = $client->get()->send();
return $response->json();
}
|
php
|
public function getApiData()
{
$client = new Client(self::API_DOCS);
$response = $client->get()->send();
return $response->json();
}
|
[
"public",
"function",
"getApiData",
"(",
")",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
"self",
"::",
"API_DOCS",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"get",
"(",
")",
"->",
"send",
"(",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] |
Read API json.
@return array|bool|float|int|string
|
[
"Read",
"API",
"json",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/Command/DocsToJsonCommand.php#L136-L142
|
221,221
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/SoundConverter.php
|
SoundConverter.soundcloudToHtml
|
public function soundcloudToHtml()
{
$theme = $this->config['soundcloud'] ?? '';
if ('full' !== $theme) {
$theme = 'small';
}
return $this->view('sound.soundcloud.'.$theme, [
'remote' => $this->data['remote_id'],
]);
}
|
php
|
public function soundcloudToHtml()
{
$theme = $this->config['soundcloud'] ?? '';
if ('full' !== $theme) {
$theme = 'small';
}
return $this->view('sound.soundcloud.'.$theme, [
'remote' => $this->data['remote_id'],
]);
}
|
[
"public",
"function",
"soundcloudToHtml",
"(",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"config",
"[",
"'soundcloud'",
"]",
"??",
"''",
";",
"if",
"(",
"'full'",
"!==",
"$",
"theme",
")",
"{",
"$",
"theme",
"=",
"'small'",
";",
"}",
"return",
"$",
"this",
"->",
"view",
"(",
"'sound.soundcloud.'",
".",
"$",
"theme",
",",
"[",
"'remote'",
"=>",
"$",
"this",
"->",
"data",
"[",
"'remote_id'",
"]",
",",
"]",
")",
";",
"}"
] |
Soundcloud block.
@return string
|
[
"Soundcloud",
"block",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/SoundConverter.php#L43-L54
|
221,222
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php
|
SirTrevorJsConverter.toHtml
|
public function toHtml(string $json)
{
if (empty($this->view)) {
$this->view = 'sirtrevorjs::html';
}
$this->output = 'html';
return $this->convert($json);
}
|
php
|
public function toHtml(string $json)
{
if (empty($this->view)) {
$this->view = 'sirtrevorjs::html';
}
$this->output = 'html';
return $this->convert($json);
}
|
[
"public",
"function",
"toHtml",
"(",
"string",
"$",
"json",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'sirtrevorjs::html'",
";",
"}",
"$",
"this",
"->",
"output",
"=",
"'html'",
";",
"return",
"$",
"this",
"->",
"convert",
"(",
"$",
"json",
")",
";",
"}"
] |
Converts the outputted json from Sir Trevor to Html.
@param string $json
@return string
|
[
"Converts",
"the",
"outputted",
"json",
"from",
"Sir",
"Trevor",
"to",
"Html",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php#L121-L130
|
221,223
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php
|
SirTrevorJsConverter.toAmp
|
public function toAmp(string $json)
{
if (empty($this->view)) {
$this->view = 'sirtrevorjs::amp';
}
$this->output = 'amp';
return $this->convert($json, false);
}
|
php
|
public function toAmp(string $json)
{
if (empty($this->view)) {
$this->view = 'sirtrevorjs::amp';
}
$this->output = 'amp';
return $this->convert($json, false);
}
|
[
"public",
"function",
"toAmp",
"(",
"string",
"$",
"json",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'sirtrevorjs::amp'",
";",
"}",
"$",
"this",
"->",
"output",
"=",
"'amp'",
";",
"return",
"$",
"this",
"->",
"convert",
"(",
"$",
"json",
",",
"false",
")",
";",
"}"
] |
Converts the outputted json from Sir Trevor to Amp.
@param string $json
@return string
|
[
"Converts",
"the",
"outputted",
"json",
"from",
"Sir",
"Trevor",
"to",
"Amp",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php#L139-L148
|
221,224
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php
|
SirTrevorJsConverter.toFb
|
public function toFb(string $json)
{
if (empty($this->view)) {
$this->view = 'sirtrevorjs::fb';
}
$this->output = 'fb';
return $this->convert($json);
}
|
php
|
public function toFb(string $json)
{
if (empty($this->view)) {
$this->view = 'sirtrevorjs::fb';
}
$this->output = 'fb';
return $this->convert($json);
}
|
[
"public",
"function",
"toFb",
"(",
"string",
"$",
"json",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'sirtrevorjs::fb'",
";",
"}",
"$",
"this",
"->",
"output",
"=",
"'fb'",
";",
"return",
"$",
"this",
"->",
"convert",
"(",
"$",
"json",
")",
";",
"}"
] |
Converts the outputted json from Sir Trevor to Facebook Articles.
@param string $json
@return string
|
[
"Converts",
"the",
"outputted",
"json",
"from",
"Sir",
"Trevor",
"to",
"Facebook",
"Articles",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php#L157-L166
|
221,225
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php
|
SirTrevorJsConverter.convert
|
public function convert(string $json, bool $externalJs = true)
{
// convert the json to an associative array
$input = json_decode($json, true);
$text = '';
$codejs = [];
if (empty($this->view)) {
$this->view = 'sirtrevorjs::html';
}
if (is_array($input)) {
// blocks
$blocks = $this->getBlocks();
// loop trough the data blocks
foreach ($input['data'] as $block) {
// no data, problem
if (!isset($block['data']) || !array_key_exists($block['type'], $blocks)) {
break;
}
$class = $blocks[$block['type']];
$converter = new $class($this->parser, $this->config, $block, $this->output);
$converter->setView($this->view);
$text .= $converter->render();
$codejsClass = $converter->getCodeJs();
if (is_array($codejsClass)) {
$codejs = array_merge($codejs, $codejsClass);
}
}
// code js
if ($externalJs && is_array($codejs)) {
$text .= implode($codejs);
}
$this->codeJs = implode($codejs);
}
return $text;
}
|
php
|
public function convert(string $json, bool $externalJs = true)
{
// convert the json to an associative array
$input = json_decode($json, true);
$text = '';
$codejs = [];
if (empty($this->view)) {
$this->view = 'sirtrevorjs::html';
}
if (is_array($input)) {
// blocks
$blocks = $this->getBlocks();
// loop trough the data blocks
foreach ($input['data'] as $block) {
// no data, problem
if (!isset($block['data']) || !array_key_exists($block['type'], $blocks)) {
break;
}
$class = $blocks[$block['type']];
$converter = new $class($this->parser, $this->config, $block, $this->output);
$converter->setView($this->view);
$text .= $converter->render();
$codejsClass = $converter->getCodeJs();
if (is_array($codejsClass)) {
$codejs = array_merge($codejs, $codejsClass);
}
}
// code js
if ($externalJs && is_array($codejs)) {
$text .= implode($codejs);
}
$this->codeJs = implode($codejs);
}
return $text;
}
|
[
"public",
"function",
"convert",
"(",
"string",
"$",
"json",
",",
"bool",
"$",
"externalJs",
"=",
"true",
")",
"{",
"// convert the json to an associative array",
"$",
"input",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"$",
"text",
"=",
"''",
";",
"$",
"codejs",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'sirtrevorjs::html'",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"// blocks",
"$",
"blocks",
"=",
"$",
"this",
"->",
"getBlocks",
"(",
")",
";",
"// loop trough the data blocks",
"foreach",
"(",
"$",
"input",
"[",
"'data'",
"]",
"as",
"$",
"block",
")",
"{",
"// no data, problem",
"if",
"(",
"!",
"isset",
"(",
"$",
"block",
"[",
"'data'",
"]",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"block",
"[",
"'type'",
"]",
",",
"$",
"blocks",
")",
")",
"{",
"break",
";",
"}",
"$",
"class",
"=",
"$",
"blocks",
"[",
"$",
"block",
"[",
"'type'",
"]",
"]",
";",
"$",
"converter",
"=",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"parser",
",",
"$",
"this",
"->",
"config",
",",
"$",
"block",
",",
"$",
"this",
"->",
"output",
")",
";",
"$",
"converter",
"->",
"setView",
"(",
"$",
"this",
"->",
"view",
")",
";",
"$",
"text",
".=",
"$",
"converter",
"->",
"render",
"(",
")",
";",
"$",
"codejsClass",
"=",
"$",
"converter",
"->",
"getCodeJs",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"codejsClass",
")",
")",
"{",
"$",
"codejs",
"=",
"array_merge",
"(",
"$",
"codejs",
",",
"$",
"codejsClass",
")",
";",
"}",
"}",
"// code js",
"if",
"(",
"$",
"externalJs",
"&&",
"is_array",
"(",
"$",
"codejs",
")",
")",
"{",
"$",
"text",
".=",
"implode",
"(",
"$",
"codejs",
")",
";",
"}",
"$",
"this",
"->",
"codeJs",
"=",
"implode",
"(",
"$",
"codejs",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] |
Convert the outputted json from Sir Trevor.
@param string $json
@param bool $externalJs
@return string
|
[
"Convert",
"the",
"outputted",
"json",
"from",
"Sir",
"Trevor",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php#L176-L218
|
221,226
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php
|
SirTrevorJsConverter.getBlocks
|
protected function getBlocks()
{
$blocks = [];
foreach ($this->blocks as $key => $value) {
$blocks[$key] = 'Caouecs\\Sirtrevorjs\\Converter\\'.$value.'Converter';
}
if (!empty($this->customBlocks)) {
$blocks = array_merge($blocks, $this->customBlocks);
}
if (isset($this->config['customBlocks']) && !empty($this->config['customBlocks'])) {
$blocks = array_merge($blocks, $this->config['customBlocks']);
}
return $blocks;
}
|
php
|
protected function getBlocks()
{
$blocks = [];
foreach ($this->blocks as $key => $value) {
$blocks[$key] = 'Caouecs\\Sirtrevorjs\\Converter\\'.$value.'Converter';
}
if (!empty($this->customBlocks)) {
$blocks = array_merge($blocks, $this->customBlocks);
}
if (isset($this->config['customBlocks']) && !empty($this->config['customBlocks'])) {
$blocks = array_merge($blocks, $this->config['customBlocks']);
}
return $blocks;
}
|
[
"protected",
"function",
"getBlocks",
"(",
")",
"{",
"$",
"blocks",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"blocks",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"blocks",
"[",
"$",
"key",
"]",
"=",
"'Caouecs\\\\Sirtrevorjs\\\\Converter\\\\'",
".",
"$",
"value",
".",
"'Converter'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"customBlocks",
")",
")",
"{",
"$",
"blocks",
"=",
"array_merge",
"(",
"$",
"blocks",
",",
"$",
"this",
"->",
"customBlocks",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'customBlocks'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'customBlocks'",
"]",
")",
")",
"{",
"$",
"blocks",
"=",
"array_merge",
"(",
"$",
"blocks",
",",
"$",
"this",
"->",
"config",
"[",
"'customBlocks'",
"]",
")",
";",
"}",
"return",
"$",
"blocks",
";",
"}"
] |
Return base blocks and custom blocks with good classes.
@return array
|
[
"Return",
"base",
"blocks",
"and",
"custom",
"blocks",
"with",
"good",
"classes",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJsConverter.php#L225-L242
|
221,227
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.transformText
|
public static function transformText(string $text)
{
$text = json_decode($text, true);
$return = [];
if (is_array($text) && isset($text['data'])) {
foreach ($text['data'] as $data) {
/*
* The bug is with new image, the data is in an array where each character is an element of this array
*
* This code transforms this array into a string (JSON format)
* and after it transforms it into an another array for Sir Trevor
*/
if ('image' === $data['type'] && !isset($data['data']['file'])) {
$return[] = [
'type' => 'image',
'data' => json_decode(implode($data['data']), true),
];
} else {
$return[] = $data;
}
}
return json_encode(['data' => $return], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
return '';
}
|
php
|
public static function transformText(string $text)
{
$text = json_decode($text, true);
$return = [];
if (is_array($text) && isset($text['data'])) {
foreach ($text['data'] as $data) {
/*
* The bug is with new image, the data is in an array where each character is an element of this array
*
* This code transforms this array into a string (JSON format)
* and after it transforms it into an another array for Sir Trevor
*/
if ('image' === $data['type'] && !isset($data['data']['file'])) {
$return[] = [
'type' => 'image',
'data' => json_decode(implode($data['data']), true),
];
} else {
$return[] = $data;
}
}
return json_encode(['data' => $return], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
return '';
}
|
[
"public",
"static",
"function",
"transformText",
"(",
"string",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"json_decode",
"(",
"$",
"text",
",",
"true",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"text",
")",
"&&",
"isset",
"(",
"$",
"text",
"[",
"'data'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"text",
"[",
"'data'",
"]",
"as",
"$",
"data",
")",
"{",
"/*\n * The bug is with new image, the data is in an array where each character is an element of this array\n *\n * This code transforms this array into a string (JSON format)\n * and after it transforms it into an another array for Sir Trevor\n */",
"if",
"(",
"'image'",
"===",
"$",
"data",
"[",
"'type'",
"]",
"&&",
"!",
"isset",
"(",
"$",
"data",
"[",
"'data'",
"]",
"[",
"'file'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"'image'",
",",
"'data'",
"=>",
"json_decode",
"(",
"implode",
"(",
"$",
"data",
"[",
"'data'",
"]",
")",
",",
"true",
")",
",",
"]",
";",
"}",
"else",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"return",
"json_encode",
"(",
"[",
"'data'",
"=>",
"$",
"return",
"]",
",",
"JSON_UNESCAPED_UNICODE",
"|",
"JSON_UNESCAPED_SLASHES",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Transform text with image bug.
@param string $text Text to fix
@return string
@static
|
[
"Transform",
"text",
"with",
"image",
"bug",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L75-L103
|
221,228
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.stylesheets
|
public static function stylesheets()
{
// params in config file
$config = config('sir-trevor-js');
/*
* Files of Sir Trevor JS
*/
$return = HTML::style($config['path'].'sir-trevor-icons.css')
.HTML::style($config['path'].'sir-trevor.css');
/*
* Others files if you need it
*/
if (isset($config['stylesheet']) && is_array($config['stylesheet'])) {
foreach ($config['stylesheet'] as $arr) {
if (file_exists(public_path($arr))) {
$return .= HTML::style($arr);
}
}
}
return $return;
}
|
php
|
public static function stylesheets()
{
// params in config file
$config = config('sir-trevor-js');
/*
* Files of Sir Trevor JS
*/
$return = HTML::style($config['path'].'sir-trevor-icons.css')
.HTML::style($config['path'].'sir-trevor.css');
/*
* Others files if you need it
*/
if (isset($config['stylesheet']) && is_array($config['stylesheet'])) {
foreach ($config['stylesheet'] as $arr) {
if (file_exists(public_path($arr))) {
$return .= HTML::style($arr);
}
}
}
return $return;
}
|
[
"public",
"static",
"function",
"stylesheets",
"(",
")",
"{",
"// params in config file",
"$",
"config",
"=",
"config",
"(",
"'sir-trevor-js'",
")",
";",
"/*\n * Files of Sir Trevor JS\n */",
"$",
"return",
"=",
"HTML",
"::",
"style",
"(",
"$",
"config",
"[",
"'path'",
"]",
".",
"'sir-trevor-icons.css'",
")",
".",
"HTML",
"::",
"style",
"(",
"$",
"config",
"[",
"'path'",
"]",
".",
"'sir-trevor.css'",
")",
";",
"/*\n * Others files if you need it\n */",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'stylesheet'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'stylesheet'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'stylesheet'",
"]",
"as",
"$",
"arr",
")",
"{",
"if",
"(",
"file_exists",
"(",
"public_path",
"(",
"$",
"arr",
")",
")",
")",
"{",
"$",
"return",
".=",
"HTML",
"::",
"style",
"(",
"$",
"arr",
")",
";",
"}",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Stylesheet files
see config file.
@return string
@static
|
[
"Stylesheet",
"files",
"see",
"config",
"file",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L112-L135
|
221,229
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.scripts
|
public static function scripts(array $params = [])
{
// params
$config = self::config($params);
$return = '';
/*
* Others files
*/
if (isset($config['script']) && is_array($config['script'])) {
foreach ($config['script'] as $arr) {
if (file_exists(public_path($arr))) {
$return .= HTML::script($arr);
}
}
}
/*
* File of Sir Trevor JS
*/
$return .= HTML::script($config['path'].'sir-trevor.min.js');
/*
* Language
*/
if ('en' != $config['language']) {
$return .= HTML::script($config['path'].'locales/'.$config['language'].'.js');
}
return $return.view('sirtrevorjs::js', ['config' => $config]);
}
|
php
|
public static function scripts(array $params = [])
{
// params
$config = self::config($params);
$return = '';
/*
* Others files
*/
if (isset($config['script']) && is_array($config['script'])) {
foreach ($config['script'] as $arr) {
if (file_exists(public_path($arr))) {
$return .= HTML::script($arr);
}
}
}
/*
* File of Sir Trevor JS
*/
$return .= HTML::script($config['path'].'sir-trevor.min.js');
/*
* Language
*/
if ('en' != $config['language']) {
$return .= HTML::script($config['path'].'locales/'.$config['language'].'.js');
}
return $return.view('sirtrevorjs::js', ['config' => $config]);
}
|
[
"public",
"static",
"function",
"scripts",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"// params",
"$",
"config",
"=",
"self",
"::",
"config",
"(",
"$",
"params",
")",
";",
"$",
"return",
"=",
"''",
";",
"/*\n * Others files\n */",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'script'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'script'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'script'",
"]",
"as",
"$",
"arr",
")",
"{",
"if",
"(",
"file_exists",
"(",
"public_path",
"(",
"$",
"arr",
")",
")",
")",
"{",
"$",
"return",
".=",
"HTML",
"::",
"script",
"(",
"$",
"arr",
")",
";",
"}",
"}",
"}",
"/*\n * File of Sir Trevor JS\n */",
"$",
"return",
".=",
"HTML",
"::",
"script",
"(",
"$",
"config",
"[",
"'path'",
"]",
".",
"'sir-trevor.min.js'",
")",
";",
"/*\n * Language\n */",
"if",
"(",
"'en'",
"!=",
"$",
"config",
"[",
"'language'",
"]",
")",
"{",
"$",
"return",
".=",
"HTML",
"::",
"script",
"(",
"$",
"config",
"[",
"'path'",
"]",
".",
"'locales/'",
".",
"$",
"config",
"[",
"'language'",
"]",
".",
"'.js'",
")",
";",
"}",
"return",
"$",
"return",
".",
"view",
"(",
"'sirtrevorjs::js'",
",",
"[",
"'config'",
"=>",
"$",
"config",
"]",
")",
";",
"}"
] |
Javascript files.
@param array $params
@return string
@static
Params :
- class
- blocktypes
- language
- uploadUrl
- tweetUrl
|
[
"Javascript",
"files",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L152-L182
|
221,230
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.config
|
public static function config(array $params = [])
{
// params in config file
$config = config('sir-trevor-js');
/*
* Block types
*/
// params
if (isset($params['blocktypes']) && !empty($params['blocktypes']) && is_array($params['blocktypes'])) {
$blocktypes = $params['blocktypes'];
// config
} elseif (isset($config['blocktypes']) && !empty($config['blocktypes']) && is_array($config['blocktypes'])) {
$blocktypes = $config['blocktypes'];
// default
} else {
$blocktypes = self::$blocktypes;
}
return [
'blocktypes' => '\''.implode('\', \'', $blocktypes).'\'',
'class' => self::defineParam('class', $params),
'language' => self::defineParam('language', $params, $config),
'path' => $config['path'],
'script' => $config['script'],
'tweetUrl' => self::defineParam('tweetUrl', $params, $config),
'uploadUrl' => self::defineParam('uploadUrl', $params, $config),
'version' => $config['version'],
];
}
|
php
|
public static function config(array $params = [])
{
// params in config file
$config = config('sir-trevor-js');
/*
* Block types
*/
// params
if (isset($params['blocktypes']) && !empty($params['blocktypes']) && is_array($params['blocktypes'])) {
$blocktypes = $params['blocktypes'];
// config
} elseif (isset($config['blocktypes']) && !empty($config['blocktypes']) && is_array($config['blocktypes'])) {
$blocktypes = $config['blocktypes'];
// default
} else {
$blocktypes = self::$blocktypes;
}
return [
'blocktypes' => '\''.implode('\', \'', $blocktypes).'\'',
'class' => self::defineParam('class', $params),
'language' => self::defineParam('language', $params, $config),
'path' => $config['path'],
'script' => $config['script'],
'tweetUrl' => self::defineParam('tweetUrl', $params, $config),
'uploadUrl' => self::defineParam('uploadUrl', $params, $config),
'version' => $config['version'],
];
}
|
[
"public",
"static",
"function",
"config",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"// params in config file",
"$",
"config",
"=",
"config",
"(",
"'sir-trevor-js'",
")",
";",
"/*\n * Block types\n */",
"// params",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'blocktypes'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"params",
"[",
"'blocktypes'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"'blocktypes'",
"]",
")",
")",
"{",
"$",
"blocktypes",
"=",
"$",
"params",
"[",
"'blocktypes'",
"]",
";",
"// config",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"config",
"[",
"'blocktypes'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"'blocktypes'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'blocktypes'",
"]",
")",
")",
"{",
"$",
"blocktypes",
"=",
"$",
"config",
"[",
"'blocktypes'",
"]",
";",
"// default",
"}",
"else",
"{",
"$",
"blocktypes",
"=",
"self",
"::",
"$",
"blocktypes",
";",
"}",
"return",
"[",
"'blocktypes'",
"=>",
"'\\''",
".",
"implode",
"(",
"'\\', \\''",
",",
"$",
"blocktypes",
")",
".",
"'\\''",
",",
"'class'",
"=>",
"self",
"::",
"defineParam",
"(",
"'class'",
",",
"$",
"params",
")",
",",
"'language'",
"=>",
"self",
"::",
"defineParam",
"(",
"'language'",
",",
"$",
"params",
",",
"$",
"config",
")",
",",
"'path'",
"=>",
"$",
"config",
"[",
"'path'",
"]",
",",
"'script'",
"=>",
"$",
"config",
"[",
"'script'",
"]",
",",
"'tweetUrl'",
"=>",
"self",
"::",
"defineParam",
"(",
"'tweetUrl'",
",",
"$",
"params",
",",
"$",
"config",
")",
",",
"'uploadUrl'",
"=>",
"self",
"::",
"defineParam",
"(",
"'uploadUrl'",
",",
"$",
"params",
",",
"$",
"config",
")",
",",
"'version'",
"=>",
"$",
"config",
"[",
"'version'",
"]",
",",
"]",
";",
"}"
] |
Configuration of Sir Trevor JS.
1 - $params
2 - config file
3 - default
@param array $params Personnalized params
@return array
@static
|
[
"Configuration",
"of",
"Sir",
"Trevor",
"JS",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L196-L225
|
221,231
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.defineParam
|
private static function defineParam(string $type, array $params, array $config = [])
{
// params
if (isset($params[$type]) && !empty($params[$type])) {
return $params[$type];
// config
} elseif (isset($config[$type]) && !empty($config[$type])) {
return $config[$type];
}
// default
return self::$$type;
}
|
php
|
private static function defineParam(string $type, array $params, array $config = [])
{
// params
if (isset($params[$type]) && !empty($params[$type])) {
return $params[$type];
// config
} elseif (isset($config[$type]) && !empty($config[$type])) {
return $config[$type];
}
// default
return self::$$type;
}
|
[
"private",
"static",
"function",
"defineParam",
"(",
"string",
"$",
"type",
",",
"array",
"$",
"params",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"// params",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"$",
"type",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"params",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"params",
"[",
"$",
"type",
"]",
";",
"// config",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"config",
"[",
"$",
"type",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"config",
"[",
"$",
"type",
"]",
";",
"}",
"// default",
"return",
"self",
"::",
"$",
"$",
"type",
";",
"}"
] |
Define param.
@param string $type
@param array $params
@param array $config
@return string
|
[
"Define",
"param",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L236-L248
|
221,232
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.findImage
|
public static function findImage(string $text)
{
$array = json_decode($text, true);
if (!empty($array['data'])) {
foreach ($array['data'] as $arr) {
if ('image' === $arr['type'] && isset($arr['data']['file']['url'])) {
return $arr['data']['file']['url'];
}
}
}
return '';
}
|
php
|
public static function findImage(string $text)
{
$array = json_decode($text, true);
if (!empty($array['data'])) {
foreach ($array['data'] as $arr) {
if ('image' === $arr['type'] && isset($arr['data']['file']['url'])) {
return $arr['data']['file']['url'];
}
}
}
return '';
}
|
[
"public",
"static",
"function",
"findImage",
"(",
"string",
"$",
"text",
")",
"{",
"$",
"array",
"=",
"json_decode",
"(",
"$",
"text",
",",
"true",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
"[",
"'data'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"array",
"[",
"'data'",
"]",
"as",
"$",
"arr",
")",
"{",
"if",
"(",
"'image'",
"===",
"$",
"arr",
"[",
"'type'",
"]",
"&&",
"isset",
"(",
"$",
"arr",
"[",
"'data'",
"]",
"[",
"'file'",
"]",
"[",
"'url'",
"]",
")",
")",
"{",
"return",
"$",
"arr",
"[",
"'data'",
"]",
"[",
"'file'",
"]",
"[",
"'url'",
"]",
";",
"}",
"}",
"}",
"return",
"''",
";",
"}"
] |
Find first image in text from Sir Trevor JS.
@param string $text
@return string Url of image
@static
|
[
"Find",
"first",
"image",
"in",
"text",
"from",
"Sir",
"Trevor",
"JS",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L271-L284
|
221,233
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.find
|
public static function find(string $text, string $blocktype, string $output = 'json', int $nbr = 0)
{
$array = json_decode($text, true);
if (!isset($array['data'])) {
return false;
}
$return = [];
$_nbr = 1;
foreach ($array['data'] as $arr) {
if ($arr['type'] == $blocktype) {
$return[] = $arr['data'];
if ($_nbr == $nbr) {
break;
}
++$_nbr;
}
}
if (empty($return) || 'array' === $output) {
return $return;
}
return json_encode($return, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
|
php
|
public static function find(string $text, string $blocktype, string $output = 'json', int $nbr = 0)
{
$array = json_decode($text, true);
if (!isset($array['data'])) {
return false;
}
$return = [];
$_nbr = 1;
foreach ($array['data'] as $arr) {
if ($arr['type'] == $blocktype) {
$return[] = $arr['data'];
if ($_nbr == $nbr) {
break;
}
++$_nbr;
}
}
if (empty($return) || 'array' === $output) {
return $return;
}
return json_encode($return, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
|
[
"public",
"static",
"function",
"find",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"blocktype",
",",
"string",
"$",
"output",
"=",
"'json'",
",",
"int",
"$",
"nbr",
"=",
"0",
")",
"{",
"$",
"array",
"=",
"json_decode",
"(",
"$",
"text",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"'data'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"return",
"=",
"[",
"]",
";",
"$",
"_nbr",
"=",
"1",
";",
"foreach",
"(",
"$",
"array",
"[",
"'data'",
"]",
"as",
"$",
"arr",
")",
"{",
"if",
"(",
"$",
"arr",
"[",
"'type'",
"]",
"==",
"$",
"blocktype",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"arr",
"[",
"'data'",
"]",
";",
"if",
"(",
"$",
"_nbr",
"==",
"$",
"nbr",
")",
"{",
"break",
";",
"}",
"++",
"$",
"_nbr",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"return",
")",
"||",
"'array'",
"===",
"$",
"output",
")",
"{",
"return",
"$",
"return",
";",
"}",
"return",
"json_encode",
"(",
"$",
"return",
",",
"JSON_UNESCAPED_UNICODE",
"|",
"JSON_UNESCAPED_SLASHES",
")",
";",
"}"
] |
Find occurences of a type of block in a text.
@param string $text
@param string $blocktype
@param string $output json or array
@param int $nbr Number of occurences ( 0 = all )
@return array|string|bool Returns list of blocks in an array or a json, if exists. Else, returns false
@static
|
[
"Find",
"occurences",
"of",
"a",
"type",
"of",
"block",
"in",
"a",
"text",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L297-L325
|
221,234
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/SirTrevorJs.php
|
SirTrevorJs.first
|
public static function first(string $text, string $blocktype, string $output = 'json')
{
return self::find($text, $blocktype, $output, 1);
}
|
php
|
public static function first(string $text, string $blocktype, string $output = 'json')
{
return self::find($text, $blocktype, $output, 1);
}
|
[
"public",
"static",
"function",
"first",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"blocktype",
",",
"string",
"$",
"output",
"=",
"'json'",
")",
"{",
"return",
"self",
"::",
"find",
"(",
"$",
"text",
",",
"$",
"blocktype",
",",
"$",
"output",
",",
"1",
")",
";",
"}"
] |
Find first occurence of a type of block in a text.
@param string $text
@param string $blocktype
@param string $output json or array
@return array|bool Returns list of blocks in an array if exists. Else, returns false
@static
|
[
"Find",
"first",
"occurence",
"of",
"a",
"type",
"of",
"block",
"in",
"a",
"text",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/SirTrevorJs.php#L337-L340
|
221,235
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Plugin/KeyAuthPlugin.php
|
KeyAuthPlugin.signRequest
|
protected function signRequest($request)
{
$url = $request->getUrl(true);
$url->getQuery()->add('key', $this->key);
$request->setUrl($url);
}
|
php
|
protected function signRequest($request)
{
$url = $request->getUrl(true);
$url->getQuery()->add('key', $this->key);
$request->setUrl($url);
}
|
[
"protected",
"function",
"signRequest",
"(",
"$",
"request",
")",
"{",
"$",
"url",
"=",
"$",
"request",
"->",
"getUrl",
"(",
"true",
")",
";",
"$",
"url",
"->",
"getQuery",
"(",
")",
"->",
"add",
"(",
"'key'",
",",
"$",
"this",
"->",
"key",
")",
";",
"$",
"request",
"->",
"setUrl",
"(",
"$",
"url",
")",
";",
"}"
] |
Adds "key" parameters as a Query Parameter.
@param Request $request
|
[
"Adds",
"key",
"parameters",
"as",
"a",
"Query",
"Parameter",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Plugin/KeyAuthPlugin.php#L75-L81
|
221,236
|
sheadawson/silverstripe-shortcodable
|
src/Controller/ShortcodableController.php
|
ShortcodableController.init
|
public function init()
{
parent::init();
if ($data = $this->getShortcodeData()) {
$this->isnew = false;
$this->shortcodableclass = $data['name'];
} elseif ($type = $this->request->requestVar('ShortcodeType')) {
$this->shortcodableclass = $type;
} else {
$this->shortcodableclass = $this->request->param('ShortcodeType');
}
}
|
php
|
public function init()
{
parent::init();
if ($data = $this->getShortcodeData()) {
$this->isnew = false;
$this->shortcodableclass = $data['name'];
} elseif ($type = $this->request->requestVar('ShortcodeType')) {
$this->shortcodableclass = $type;
} else {
$this->shortcodableclass = $this->request->param('ShortcodeType');
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"$",
"data",
"=",
"$",
"this",
"->",
"getShortcodeData",
"(",
")",
")",
"{",
"$",
"this",
"->",
"isnew",
"=",
"false",
";",
"$",
"this",
"->",
"shortcodableclass",
"=",
"$",
"data",
"[",
"'name'",
"]",
";",
"}",
"elseif",
"(",
"$",
"type",
"=",
"$",
"this",
"->",
"request",
"->",
"requestVar",
"(",
"'ShortcodeType'",
")",
")",
"{",
"$",
"this",
"->",
"shortcodableclass",
"=",
"$",
"type",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"shortcodableclass",
"=",
"$",
"this",
"->",
"request",
"->",
"param",
"(",
"'ShortcodeType'",
")",
";",
"}",
"}"
] |
Get the shortcodable class by whatever means possible.
Determine if this is a new shortcode, or editing an existing one.
|
[
"Get",
"the",
"shortcodable",
"class",
"by",
"whatever",
"means",
"possible",
".",
"Determine",
"if",
"this",
"is",
"a",
"new",
"shortcode",
"or",
"editing",
"an",
"existing",
"one",
"."
] |
f418ba7bc9d2632a22be455846bfa3ed2d27f695
|
https://github.com/sheadawson/silverstripe-shortcodable/blob/f418ba7bc9d2632a22be455846bfa3ed2d27f695/src/Controller/ShortcodableController.php#L63-L74
|
221,237
|
sheadawson/silverstripe-shortcodable
|
src/Controller/ShortcodableController.php
|
ShortcodableController.Link
|
public function Link($action = null)
{
if ($this->shortcodableclass) {
return Controller::join_links(
$this->config()->url_base,
$this->config()->sc_url_segment,
'edit',
$this->shortcodableclass
);
}
return Controller::join_links($this->config()->url_base, $this->config()->sc_url_segment, $action);
}
|
php
|
public function Link($action = null)
{
if ($this->shortcodableclass) {
return Controller::join_links(
$this->config()->url_base,
$this->config()->sc_url_segment,
'edit',
$this->shortcodableclass
);
}
return Controller::join_links($this->config()->url_base, $this->config()->sc_url_segment, $action);
}
|
[
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shortcodableclass",
")",
"{",
"return",
"Controller",
"::",
"join_links",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"url_base",
",",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"sc_url_segment",
",",
"'edit'",
",",
"$",
"this",
"->",
"shortcodableclass",
")",
";",
"}",
"return",
"Controller",
"::",
"join_links",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"url_base",
",",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"sc_url_segment",
",",
"$",
"action",
")",
";",
"}"
] |
Point to edit link, if shortcodable class exists.
|
[
"Point",
"to",
"edit",
"link",
"if",
"shortcodable",
"class",
"exists",
"."
] |
f418ba7bc9d2632a22be455846bfa3ed2d27f695
|
https://github.com/sheadawson/silverstripe-shortcodable/blob/f418ba7bc9d2632a22be455846bfa3ed2d27f695/src/Controller/ShortcodableController.php#L79-L90
|
221,238
|
sheadawson/silverstripe-shortcodable
|
src/Controller/ShortcodableController.php
|
ShortcodableController.getShortcodeData
|
protected function getShortcodeData()
{
if($this->shortcodedata){
return $this->shortcodedata;
}
$data = false;
if($shortcode = $this->request->requestVar('Shortcode')){
//remove BOM inside string on cursor position...
$shortcode = str_replace("\xEF\xBB\xBF", '', $shortcode);
$data = singleton('\Silverstripe\Shortcodable\ShortcodableParser')->the_shortcodes(array(), $shortcode);
if(isset($data[0])){
$this->shortcodedata = $data[0];
return $this->shortcodedata;
}
}
}
|
php
|
protected function getShortcodeData()
{
if($this->shortcodedata){
return $this->shortcodedata;
}
$data = false;
if($shortcode = $this->request->requestVar('Shortcode')){
//remove BOM inside string on cursor position...
$shortcode = str_replace("\xEF\xBB\xBF", '', $shortcode);
$data = singleton('\Silverstripe\Shortcodable\ShortcodableParser')->the_shortcodes(array(), $shortcode);
if(isset($data[0])){
$this->shortcodedata = $data[0];
return $this->shortcodedata;
}
}
}
|
[
"protected",
"function",
"getShortcodeData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shortcodedata",
")",
"{",
"return",
"$",
"this",
"->",
"shortcodedata",
";",
"}",
"$",
"data",
"=",
"false",
";",
"if",
"(",
"$",
"shortcode",
"=",
"$",
"this",
"->",
"request",
"->",
"requestVar",
"(",
"'Shortcode'",
")",
")",
"{",
"//remove BOM inside string on cursor position...",
"$",
"shortcode",
"=",
"str_replace",
"(",
"\"\\xEF\\xBB\\xBF\"",
",",
"''",
",",
"$",
"shortcode",
")",
";",
"$",
"data",
"=",
"singleton",
"(",
"'\\Silverstripe\\Shortcodable\\ShortcodableParser'",
")",
"->",
"the_shortcodes",
"(",
"array",
"(",
")",
",",
"$",
"shortcode",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"shortcodedata",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"return",
"$",
"this",
"->",
"shortcodedata",
";",
"}",
"}",
"}"
] |
Get the shortcode data from the request.
@return array shortcodedata
|
[
"Get",
"the",
"shortcode",
"data",
"from",
"the",
"request",
"."
] |
f418ba7bc9d2632a22be455846bfa3ed2d27f695
|
https://github.com/sheadawson/silverstripe-shortcodable/blob/f418ba7bc9d2632a22be455846bfa3ed2d27f695/src/Controller/ShortcodableController.php#L105-L120
|
221,239
|
sheadawson/silverstripe-shortcodable
|
src/Controller/ShortcodableController.php
|
ShortcodableController.shortcodePlaceHolder
|
public function shortcodePlaceHolder($request)
{
if (!Permission::check('CMS_ACCESS_CMSMain')) {
return;
}
$classname = $request->param('ID');
$id = $request->param('OtherID');
if (!class_exists($classname)) {
return;
}
if ($id) {
$object = $classname::get()->byID($id);
} else {
$object = singleton($classname);
}
if ($object->hasMethod('getShortcodePlaceHolder')) {
$attributes = null;
if ($shortcode = $request->requestVar('Shortcode')) {
$shortcode = str_replace("\xEF\xBB\xBF", '', $shortcode); //remove BOM inside string on cursor position...
$shortcodeData = singleton('\Silverstripe\Shortcodable\ShortcodableParser')->the_shortcodes(array(), $shortcode);
if (isset($shortcodeData[0])) {
$attributes = $shortcodeData[0]['atts'];
}
}
$link = $object->getShortcodePlaceholder($attributes);
return $this->redirect($link);
}
}
|
php
|
public function shortcodePlaceHolder($request)
{
if (!Permission::check('CMS_ACCESS_CMSMain')) {
return;
}
$classname = $request->param('ID');
$id = $request->param('OtherID');
if (!class_exists($classname)) {
return;
}
if ($id) {
$object = $classname::get()->byID($id);
} else {
$object = singleton($classname);
}
if ($object->hasMethod('getShortcodePlaceHolder')) {
$attributes = null;
if ($shortcode = $request->requestVar('Shortcode')) {
$shortcode = str_replace("\xEF\xBB\xBF", '', $shortcode); //remove BOM inside string on cursor position...
$shortcodeData = singleton('\Silverstripe\Shortcodable\ShortcodableParser')->the_shortcodes(array(), $shortcode);
if (isset($shortcodeData[0])) {
$attributes = $shortcodeData[0]['atts'];
}
}
$link = $object->getShortcodePlaceholder($attributes);
return $this->redirect($link);
}
}
|
[
"public",
"function",
"shortcodePlaceHolder",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"Permission",
"::",
"check",
"(",
"'CMS_ACCESS_CMSMain'",
")",
")",
"{",
"return",
";",
"}",
"$",
"classname",
"=",
"$",
"request",
"->",
"param",
"(",
"'ID'",
")",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"param",
"(",
"'OtherID'",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"object",
"=",
"$",
"classname",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"object",
"=",
"singleton",
"(",
"$",
"classname",
")",
";",
"}",
"if",
"(",
"$",
"object",
"->",
"hasMethod",
"(",
"'getShortcodePlaceHolder'",
")",
")",
"{",
"$",
"attributes",
"=",
"null",
";",
"if",
"(",
"$",
"shortcode",
"=",
"$",
"request",
"->",
"requestVar",
"(",
"'Shortcode'",
")",
")",
"{",
"$",
"shortcode",
"=",
"str_replace",
"(",
"\"\\xEF\\xBB\\xBF\"",
",",
"''",
",",
"$",
"shortcode",
")",
";",
"//remove BOM inside string on cursor position...",
"$",
"shortcodeData",
"=",
"singleton",
"(",
"'\\Silverstripe\\Shortcodable\\ShortcodableParser'",
")",
"->",
"the_shortcodes",
"(",
"array",
"(",
")",
",",
"$",
"shortcode",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"shortcodeData",
"[",
"0",
"]",
")",
")",
"{",
"$",
"attributes",
"=",
"$",
"shortcodeData",
"[",
"0",
"]",
"[",
"'atts'",
"]",
";",
"}",
"}",
"$",
"link",
"=",
"$",
"object",
"->",
"getShortcodePlaceholder",
"(",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"link",
")",
";",
"}",
"}"
] |
Generates shortcode placeholder to display inside TinyMCE instead of the shortcode.
@return void
|
[
"Generates",
"shortcode",
"placeholder",
"to",
"display",
"inside",
"TinyMCE",
"instead",
"of",
"the",
"shortcode",
"."
] |
f418ba7bc9d2632a22be455846bfa3ed2d27f695
|
https://github.com/sheadawson/silverstripe-shortcodable/blob/f418ba7bc9d2632a22be455846bfa3ed2d27f695/src/Controller/ShortcodableController.php#L217-L249
|
221,240
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/Helper/OperationNameConverter.php
|
OperationNameConverter.parseOperationName
|
public static function parseOperationName(Operation $operation)
{
$verb = self::deriveAction($operation->httpMethod, $operation->uri);
$wordifiedPath = self::wordifyPath($operation->uri);
if ($operation->version == 'stream') {
$wordifiedPath = $wordifiedPath.'Stream';
}
if (preg_match("/^\/{urlname}.*/", $operation->uri) == 1) {
$wordifiedPath = 'Group'.$wordifiedPath;
}
return ucfirst($verb.$wordifiedPath);
}
|
php
|
public static function parseOperationName(Operation $operation)
{
$verb = self::deriveAction($operation->httpMethod, $operation->uri);
$wordifiedPath = self::wordifyPath($operation->uri);
if ($operation->version == 'stream') {
$wordifiedPath = $wordifiedPath.'Stream';
}
if (preg_match("/^\/{urlname}.*/", $operation->uri) == 1) {
$wordifiedPath = 'Group'.$wordifiedPath;
}
return ucfirst($verb.$wordifiedPath);
}
|
[
"public",
"static",
"function",
"parseOperationName",
"(",
"Operation",
"$",
"operation",
")",
"{",
"$",
"verb",
"=",
"self",
"::",
"deriveAction",
"(",
"$",
"operation",
"->",
"httpMethod",
",",
"$",
"operation",
"->",
"uri",
")",
";",
"$",
"wordifiedPath",
"=",
"self",
"::",
"wordifyPath",
"(",
"$",
"operation",
"->",
"uri",
")",
";",
"if",
"(",
"$",
"operation",
"->",
"version",
"==",
"'stream'",
")",
"{",
"$",
"wordifiedPath",
"=",
"$",
"wordifiedPath",
".",
"'Stream'",
";",
"}",
"if",
"(",
"preg_match",
"(",
"\"/^\\/{urlname}.*/\"",
",",
"$",
"operation",
"->",
"uri",
")",
"==",
"1",
")",
"{",
"$",
"wordifiedPath",
"=",
"'Group'",
".",
"$",
"wordifiedPath",
";",
"}",
"return",
"ucfirst",
"(",
"$",
"verb",
".",
"$",
"wordifiedPath",
")",
";",
"}"
] |
Parse Operation name.
@param Operation $operation
@return string
|
[
"Parse",
"Operation",
"name",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/Helper/OperationNameConverter.php#L19-L34
|
221,241
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/Helper/OperationNameConverter.php
|
OperationNameConverter.wordifyPath
|
public static function wordifyPath($path)
{
// drop parameters
$path = preg_replace('/{[a-z_]*}/', '', $path);
$path = preg_replace('/[0-9]*/', '', $path);
$path = str_replace('_', '/', $path);
// split
$parts = array_filter(explode('/', $path));
//UpperCase Words
$parts = array_map('ucfirst', $parts);
return implode('', $parts);
}
|
php
|
public static function wordifyPath($path)
{
// drop parameters
$path = preg_replace('/{[a-z_]*}/', '', $path);
$path = preg_replace('/[0-9]*/', '', $path);
$path = str_replace('_', '/', $path);
// split
$parts = array_filter(explode('/', $path));
//UpperCase Words
$parts = array_map('ucfirst', $parts);
return implode('', $parts);
}
|
[
"public",
"static",
"function",
"wordifyPath",
"(",
"$",
"path",
")",
"{",
"// drop parameters",
"$",
"path",
"=",
"preg_replace",
"(",
"'/{[a-z_]*}/'",
",",
"''",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'/[0-9]*/'",
",",
"''",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"'_'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"// split",
"$",
"parts",
"=",
"array_filter",
"(",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
")",
";",
"//UpperCase Words",
"$",
"parts",
"=",
"array_map",
"(",
"'ucfirst'",
",",
"$",
"parts",
")",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"parts",
")",
";",
"}"
] |
Converts the url parts into words.
@param string $path
@return string
|
[
"Converts",
"the",
"url",
"parts",
"into",
"words",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/Helper/OperationNameConverter.php#L43-L57
|
221,242
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/Helper/OperationNameConverter.php
|
OperationNameConverter.deriveAction
|
public static function deriveAction($method, $path)
{
$method = strtolower($method);
if ($method == 'get') {
return $method;
}
if ($method == 'delete') {
return $method;
}
if ($method == 'post' && $path == '/{urlname}') {
return 'edit';
}
if ($method == 'post' && (strpos($path, '{id}') !== false || strpos($path, '{mid}') !== false)) {
return 'edit';
}
if ($method == 'post') {
return 'create';
}
if ($method == 'ws') {
return 'webSocket';
}
if ($method == 'patch') {
return 'edit';
}
return '';
}
|
php
|
public static function deriveAction($method, $path)
{
$method = strtolower($method);
if ($method == 'get') {
return $method;
}
if ($method == 'delete') {
return $method;
}
if ($method == 'post' && $path == '/{urlname}') {
return 'edit';
}
if ($method == 'post' && (strpos($path, '{id}') !== false || strpos($path, '{mid}') !== false)) {
return 'edit';
}
if ($method == 'post') {
return 'create';
}
if ($method == 'ws') {
return 'webSocket';
}
if ($method == 'patch') {
return 'edit';
}
return '';
}
|
[
"public",
"static",
"function",
"deriveAction",
"(",
"$",
"method",
",",
"$",
"path",
")",
"{",
"$",
"method",
"=",
"strtolower",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"method",
"==",
"'get'",
")",
"{",
"return",
"$",
"method",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'delete'",
")",
"{",
"return",
"$",
"method",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'post'",
"&&",
"$",
"path",
"==",
"'/{urlname}'",
")",
"{",
"return",
"'edit'",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'post'",
"&&",
"(",
"strpos",
"(",
"$",
"path",
",",
"'{id}'",
")",
"!==",
"false",
"||",
"strpos",
"(",
"$",
"path",
",",
"'{mid}'",
")",
"!==",
"false",
")",
")",
"{",
"return",
"'edit'",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'post'",
")",
"{",
"return",
"'create'",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'ws'",
")",
"{",
"return",
"'webSocket'",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'patch'",
")",
"{",
"return",
"'edit'",
";",
"}",
"return",
"''",
";",
"}"
] |
Derives a Verb for the endpoint.
@param string $method
@param string $path
@return string
|
[
"Derives",
"a",
"Verb",
"for",
"the",
"endpoint",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/Helper/OperationNameConverter.php#L67-L100
|
221,243
|
pepijnolivier/Eloquent-Model-Generator
|
src/Console/SchemaGenerator.php
|
SchemaGenerator.getPrimaryKeys
|
function getPrimaryKeys($tableName) {
$primary_key_index = $this->schema->listTableDetails($tableName)->getPrimaryKey();
return $primary_key_index ? $primary_key_index->getColumns() : [];
}
|
php
|
function getPrimaryKeys($tableName) {
$primary_key_index = $this->schema->listTableDetails($tableName)->getPrimaryKey();
return $primary_key_index ? $primary_key_index->getColumns() : [];
}
|
[
"function",
"getPrimaryKeys",
"(",
"$",
"tableName",
")",
"{",
"$",
"primary_key_index",
"=",
"$",
"this",
"->",
"schema",
"->",
"listTableDetails",
"(",
"$",
"tableName",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"return",
"$",
"primary_key_index",
"?",
"$",
"primary_key_index",
"->",
"getColumns",
"(",
")",
":",
"[",
"]",
";",
"}"
] |
Returns array of fields matched as primary keys in table
|
[
"Returns",
"array",
"of",
"fields",
"matched",
"as",
"primary",
"keys",
"in",
"table"
] |
a9930e07d7e74d47096d3615f868e66f6e1cd78f
|
https://github.com/pepijnolivier/Eloquent-Model-Generator/blob/a9930e07d7e74d47096d3615f868e66f6e1cd78f/src/Console/SchemaGenerator.php#L12-L15
|
221,244
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/ImageConverter.php
|
ImageConverter.imageToHtml
|
public function imageToHtml()
{
if (empty($this->data['file.url'])) {
return '';
}
$text = $this->data['text'] ?? '';
if (!empty($text)) {
$text = $this->parser->toHtml($text);
}
$url = $this->data['file.url'] ?? '';
try {
$size = getimagesize($url);
} catch (Exception $e) {
$size = [
$this->config['image.width'] ?? 520,
$this->config['image.height'] ?? 200,
];
}
return $this->view('image.image', [
'url' => $url,
'text' => $text,
'width' => $size[0],
'height' => $size[1],
]);
}
|
php
|
public function imageToHtml()
{
if (empty($this->data['file.url'])) {
return '';
}
$text = $this->data['text'] ?? '';
if (!empty($text)) {
$text = $this->parser->toHtml($text);
}
$url = $this->data['file.url'] ?? '';
try {
$size = getimagesize($url);
} catch (Exception $e) {
$size = [
$this->config['image.width'] ?? 520,
$this->config['image.height'] ?? 200,
];
}
return $this->view('image.image', [
'url' => $url,
'text' => $text,
'width' => $size[0],
'height' => $size[1],
]);
}
|
[
"public",
"function",
"imageToHtml",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'file.url'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"text",
"=",
"$",
"this",
"->",
"data",
"[",
"'text'",
"]",
"??",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"text",
")",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"parser",
"->",
"toHtml",
"(",
"$",
"text",
")",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"data",
"[",
"'file.url'",
"]",
"??",
"''",
";",
"try",
"{",
"$",
"size",
"=",
"getimagesize",
"(",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"size",
"=",
"[",
"$",
"this",
"->",
"config",
"[",
"'image.width'",
"]",
"??",
"520",
",",
"$",
"this",
"->",
"config",
"[",
"'image.height'",
"]",
"??",
"200",
",",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"view",
"(",
"'image.image'",
",",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'text'",
"=>",
"$",
"text",
",",
"'width'",
"=>",
"$",
"size",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"size",
"[",
"1",
"]",
",",
"]",
")",
";",
"}"
] |
Converts the image to html.
@return string
|
[
"Converts",
"the",
"image",
"to",
"html",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/ImageConverter.php#L54-L83
|
221,245
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/ImageConverter.php
|
ImageConverter.gettyimagesToHtml
|
public function gettyimagesToHtml()
{
return $this->view('image.gettyimages', [
'remote_id' => $this->data['remote_id'],
'width' => $this->config['gettyimages.width'] ?? 594,
'height' => $this->config['gettyimages.height'] ?? 465,
'placeholder' => $this->config['gettyimages.placeholder'] ?? '/',
]);
}
|
php
|
public function gettyimagesToHtml()
{
return $this->view('image.gettyimages', [
'remote_id' => $this->data['remote_id'],
'width' => $this->config['gettyimages.width'] ?? 594,
'height' => $this->config['gettyimages.height'] ?? 465,
'placeholder' => $this->config['gettyimages.placeholder'] ?? '/',
]);
}
|
[
"public",
"function",
"gettyimagesToHtml",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"view",
"(",
"'image.gettyimages'",
",",
"[",
"'remote_id'",
"=>",
"$",
"this",
"->",
"data",
"[",
"'remote_id'",
"]",
",",
"'width'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'gettyimages.width'",
"]",
"??",
"594",
",",
"'height'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'gettyimages.height'",
"]",
"??",
"465",
",",
"'placeholder'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'gettyimages.placeholder'",
"]",
"??",
"'/'",
",",
"]",
")",
";",
"}"
] |
Converts GettyImage to html.
@return string
|
[
"Converts",
"GettyImage",
"to",
"html",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/ImageConverter.php#L90-L98
|
221,246
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/AbstractMeetupClient.php
|
AbstractMeetupClient.buildConfig
|
public static function buildConfig($config = array())
{
$default = static::getDefaultParameters();
$required = static::getRequiredParameters();
$config = Collection::fromConfig($config, $default, $required);
$standardHeaders = array(
'Accept-Charset' => 'utf-8',
'Accept' => 'application/json',
);
$requestOptions = array(
'headers' => $standardHeaders,
);
$config->add('request.options', $requestOptions);
return $config;
}
|
php
|
public static function buildConfig($config = array())
{
$default = static::getDefaultParameters();
$required = static::getRequiredParameters();
$config = Collection::fromConfig($config, $default, $required);
$standardHeaders = array(
'Accept-Charset' => 'utf-8',
'Accept' => 'application/json',
);
$requestOptions = array(
'headers' => $standardHeaders,
);
$config->add('request.options', $requestOptions);
return $config;
}
|
[
"public",
"static",
"function",
"buildConfig",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"default",
"=",
"static",
"::",
"getDefaultParameters",
"(",
")",
";",
"$",
"required",
"=",
"static",
"::",
"getRequiredParameters",
"(",
")",
";",
"$",
"config",
"=",
"Collection",
"::",
"fromConfig",
"(",
"$",
"config",
",",
"$",
"default",
",",
"$",
"required",
")",
";",
"$",
"standardHeaders",
"=",
"array",
"(",
"'Accept-Charset'",
"=>",
"'utf-8'",
",",
"'Accept'",
"=>",
"'application/json'",
",",
")",
";",
"$",
"requestOptions",
"=",
"array",
"(",
"'headers'",
"=>",
"$",
"standardHeaders",
",",
")",
";",
"$",
"config",
"->",
"add",
"(",
"'request.options'",
",",
"$",
"requestOptions",
")",
";",
"return",
"$",
"config",
";",
"}"
] |
Builds array of configurations into final config.
@param array $config
@return Collection
|
[
"Builds",
"array",
"of",
"configurations",
"into",
"final",
"config",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/AbstractMeetupClient.php#L192-L210
|
221,247
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/AbstractMeetupClient.php
|
AbstractMeetupClient.loadDefinitions
|
public static function loadDefinitions(Client $client)
{
$serviceDescriptions = ServiceDescription::factory(__DIR__.'/Resources/config/meetup.json');
foreach ($serviceDescriptions->getOperations() as $operation) {
/* @var $operation Operation */
$operation->setClass('DMS\Service\Meetup\Command\MeetupCommand');
}
$client->setDescription($serviceDescriptions);
}
|
php
|
public static function loadDefinitions(Client $client)
{
$serviceDescriptions = ServiceDescription::factory(__DIR__.'/Resources/config/meetup.json');
foreach ($serviceDescriptions->getOperations() as $operation) {
/* @var $operation Operation */
$operation->setClass('DMS\Service\Meetup\Command\MeetupCommand');
}
$client->setDescription($serviceDescriptions);
}
|
[
"public",
"static",
"function",
"loadDefinitions",
"(",
"Client",
"$",
"client",
")",
"{",
"$",
"serviceDescriptions",
"=",
"ServiceDescription",
"::",
"factory",
"(",
"__DIR__",
".",
"'/Resources/config/meetup.json'",
")",
";",
"foreach",
"(",
"$",
"serviceDescriptions",
"->",
"getOperations",
"(",
")",
"as",
"$",
"operation",
")",
"{",
"/* @var $operation Operation */",
"$",
"operation",
"->",
"setClass",
"(",
"'DMS\\Service\\Meetup\\Command\\MeetupCommand'",
")",
";",
"}",
"$",
"client",
"->",
"setDescription",
"(",
"$",
"serviceDescriptions",
")",
";",
"}"
] |
Loads API method definitions.
@param \Guzzle\Service\Client $client
|
[
"Loads",
"API",
"method",
"definitions",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/AbstractMeetupClient.php#L217-L227
|
221,248
|
sroehrl/neoan3-db
|
Db.php
|
Db.init
|
private static function init() {
if(!self::$_env) {
self::$_env = new DbEnvironment();
}
if(!self::$_ops) {
self::$_ops = new DbOps(self::$_env);
}
}
|
php
|
private static function init() {
if(!self::$_env) {
self::$_env = new DbEnvironment();
}
if(!self::$_ops) {
self::$_ops = new DbOps(self::$_env);
}
}
|
[
"private",
"static",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_env",
")",
"{",
"self",
"::",
"$",
"_env",
"=",
"new",
"DbEnvironment",
"(",
")",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"_ops",
")",
"{",
"self",
"::",
"$",
"_ops",
"=",
"new",
"DbOps",
"(",
"self",
"::",
"$",
"_env",
")",
";",
"}",
"}"
] |
Db initiator.
|
[
"Db",
"initiator",
"."
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/Db.php#L44-L51
|
221,249
|
sroehrl/neoan3-db
|
Db.php
|
Db.deprecationWarning
|
private static function deprecationWarning() {
$caller = next(debug_backtrace());
$msg = 'Deprecated Db-function in function ' . $caller['function'] . ' called from ' . $caller['file'];
$msg .= ' on line ' . $caller['line'];
trigger_error($msg, E_USER_NOTICE);
}
|
php
|
private static function deprecationWarning() {
$caller = next(debug_backtrace());
$msg = 'Deprecated Db-function in function ' . $caller['function'] . ' called from ' . $caller['file'];
$msg .= ' on line ' . $caller['line'];
trigger_error($msg, E_USER_NOTICE);
}
|
[
"private",
"static",
"function",
"deprecationWarning",
"(",
")",
"{",
"$",
"caller",
"=",
"next",
"(",
"debug_backtrace",
"(",
")",
")",
";",
"$",
"msg",
"=",
"'Deprecated Db-function in function '",
".",
"$",
"caller",
"[",
"'function'",
"]",
".",
"' called from '",
".",
"$",
"caller",
"[",
"'file'",
"]",
";",
"$",
"msg",
".=",
"' on line '",
".",
"$",
"caller",
"[",
"'line'",
"]",
";",
"trigger_error",
"(",
"$",
"msg",
",",
"E_USER_NOTICE",
")",
";",
"}"
] |
Creates a NOTICE
|
[
"Creates",
"a",
"NOTICE"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/Db.php#L576-L581
|
221,250
|
davelip/laravel-database-queue
|
src/DatabaseServiceProvider.php
|
DatabaseServiceProvider.registerDatabaseCommand
|
protected function registerDatabaseCommand()
{
$app = $this->app;
$app['command.queue.database'] = $app->share(function ($app) {
return new DatabaseCommand();
});
$this->commands('command.queue.database');
}
|
php
|
protected function registerDatabaseCommand()
{
$app = $this->app;
$app['command.queue.database'] = $app->share(function ($app) {
return new DatabaseCommand();
});
$this->commands('command.queue.database');
}
|
[
"protected",
"function",
"registerDatabaseCommand",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"app",
"[",
"'command.queue.database'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"DatabaseCommand",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"'command.queue.database'",
")",
";",
"}"
] |
Register the queue listener console command.
@return void
|
[
"Register",
"the",
"queue",
"listener",
"console",
"command",
"."
] |
505b09ddd548fbf7608b63f79463f2d041e04c7a
|
https://github.com/davelip/laravel-database-queue/blob/505b09ddd548fbf7608b63f79463f2d041e04c7a/src/DatabaseServiceProvider.php#L41-L50
|
221,251
|
PHPixie/Framework
|
src/PHPixie/Framework.php
|
Framework.registerDebugHandlers
|
public function registerDebugHandlers($shutdownLog = false, $exception = true, $error = true)
{
$debug = $this->builder->components()->debug();
$debug->registerHandlers($shutdownLog, $exception, $error);
}
|
php
|
public function registerDebugHandlers($shutdownLog = false, $exception = true, $error = true)
{
$debug = $this->builder->components()->debug();
$debug->registerHandlers($shutdownLog, $exception, $error);
}
|
[
"public",
"function",
"registerDebugHandlers",
"(",
"$",
"shutdownLog",
"=",
"false",
",",
"$",
"exception",
"=",
"true",
",",
"$",
"error",
"=",
"true",
")",
"{",
"$",
"debug",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
"->",
"debug",
"(",
")",
";",
"$",
"debug",
"->",
"registerHandlers",
"(",
"$",
"shutdownLog",
",",
"$",
"exception",
",",
"$",
"error",
")",
";",
"}"
] |
Register error and exception handlers
@param bool $shutdownLog Whether to output log contents at shutdown
@param bool $exception Whether to catch and dump exceptions
@param bool $error Whether to convert errors to exceptions
@return void
|
[
"Register",
"error",
"and",
"exception",
"handlers"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework.php#L71-L75
|
221,252
|
middlewares/trailing-slash
|
src/TrailingSlash.php
|
TrailingSlash.normalize
|
private function normalize(string $path): string
{
if ($path === '') {
return '/';
}
if (strlen($path) > 1) {
if ($this->trailingSlash) {
if (substr($path, -1) !== '/' && !pathinfo($path, PATHINFO_EXTENSION)) {
return $path.'/';
}
} else {
return rtrim($path, '/');
}
}
return $path;
}
|
php
|
private function normalize(string $path): string
{
if ($path === '') {
return '/';
}
if (strlen($path) > 1) {
if ($this->trailingSlash) {
if (substr($path, -1) !== '/' && !pathinfo($path, PATHINFO_EXTENSION)) {
return $path.'/';
}
} else {
return rtrim($path, '/');
}
}
return $path;
}
|
[
"private",
"function",
"normalize",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"if",
"(",
"$",
"path",
"===",
"''",
")",
"{",
"return",
"'/'",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
">",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"trailingSlash",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
")",
"!==",
"'/'",
"&&",
"!",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_EXTENSION",
")",
")",
"{",
"return",
"$",
"path",
".",
"'/'",
";",
"}",
"}",
"else",
"{",
"return",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"}",
"}",
"return",
"$",
"path",
";",
"}"
] |
Normalize the trailing slash.
|
[
"Normalize",
"the",
"trailing",
"slash",
"."
] |
2080091ac1c01353a04ace3926b056a2cf0aa46a
|
https://github.com/middlewares/trailing-slash/blob/2080091ac1c01353a04ace3926b056a2cf0aa46a/src/TrailingSlash.php#L66-L83
|
221,253
|
PHPixie/Framework
|
src/PHPixie/Framework/Processors/HTTP/Response/Normalize.php
|
Normalize.process
|
public function process($value)
{
if($value instanceof \PHPixie\HTTP\Responses\Response) {
return $value;
}
if($value instanceof \Psr\Http\Message\ResponseInterface) {
return $value;
}
if($value instanceof \PHPixie\Template\Container) {
$value = $value->render();
}
if(is_string($value)) {
return $this->http->responses()->string($value);
}
if(is_object($value) || is_array($value)) {
return $this->http->responses()->json($value);
}
$type = gettype($value);
throw new \PHPixie\HTTPProcessors\Exception("Cannot convert type '$type' into a response");
}
|
php
|
public function process($value)
{
if($value instanceof \PHPixie\HTTP\Responses\Response) {
return $value;
}
if($value instanceof \Psr\Http\Message\ResponseInterface) {
return $value;
}
if($value instanceof \PHPixie\Template\Container) {
$value = $value->render();
}
if(is_string($value)) {
return $this->http->responses()->string($value);
}
if(is_object($value) || is_array($value)) {
return $this->http->responses()->json($value);
}
$type = gettype($value);
throw new \PHPixie\HTTPProcessors\Exception("Cannot convert type '$type' into a response");
}
|
[
"public",
"function",
"process",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"PHPixie",
"\\",
"HTTP",
"\\",
"Responses",
"\\",
"Response",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Psr",
"\\",
"Http",
"\\",
"Message",
"\\",
"ResponseInterface",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"PHPixie",
"\\",
"Template",
"\\",
"Container",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"render",
"(",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"http",
"->",
"responses",
"(",
")",
"->",
"string",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"http",
"->",
"responses",
"(",
")",
"->",
"json",
"(",
"$",
"value",
")",
";",
"}",
"$",
"type",
"=",
"gettype",
"(",
"$",
"value",
")",
";",
"throw",
"new",
"\\",
"PHPixie",
"\\",
"HTTPProcessors",
"\\",
"Exception",
"(",
"\"Cannot convert type '$type' into a response\"",
")",
";",
"}"
] |
Convert data to a HTTP response
@param mixed $value
@return \PHPixie\HTTP\Responses\Response
@throws \PHPixie\HTTPProcessors\Exception If data type is not supported
|
[
"Convert",
"data",
"to",
"a",
"HTTP",
"response"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Processors/HTTP/Response/Normalize.php#L30-L54
|
221,254
|
colinmollenhour/mongodb-php-odm
|
classes/json.php
|
JSON.decode
|
public static function decode($json, $assoc = FALSE)
{
$json = utf8_encode($json);
$json = str_replace(array("\n","\r"),"",$json);
$json = preg_replace('/([{,])(\s*)([^"]+?)\s*:/','$1"$3":',$json);
return json_decode($json,$assoc);
}
|
php
|
public static function decode($json, $assoc = FALSE)
{
$json = utf8_encode($json);
$json = str_replace(array("\n","\r"),"",$json);
$json = preg_replace('/([{,])(\s*)([^"]+?)\s*:/','$1"$3":',$json);
return json_decode($json,$assoc);
}
|
[
"public",
"static",
"function",
"decode",
"(",
"$",
"json",
",",
"$",
"assoc",
"=",
"FALSE",
")",
"{",
"$",
"json",
"=",
"utf8_encode",
"(",
"$",
"json",
")",
";",
"$",
"json",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\n\"",
",",
"\"\\r\"",
")",
",",
"\"\"",
",",
"$",
"json",
")",
";",
"$",
"json",
"=",
"preg_replace",
"(",
"'/([{,])(\\s*)([^\"]+?)\\s*:/'",
",",
"'$1\"$3\":'",
",",
"$",
"json",
")",
";",
"return",
"json_decode",
"(",
"$",
"json",
",",
"$",
"assoc",
")",
";",
"}"
] |
Decode a JSON string that is not strictly formed.
@param string $json
@param boolean $assoc
@return array|object
|
[
"Decode",
"a",
"JSON",
"string",
"that",
"is",
"not",
"strictly",
"formed",
"."
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/json.php#L18-L24
|
221,255
|
PHPixie/Framework
|
src/PHPixie/Framework/Extensions.php
|
Extensions.templateExtensions
|
public function templateExtensions()
{
return array(
new Extensions\Template\Extension\Debug(
$this->components()->debug()
),
new Extensions\Template\Extension\RouteTranslator(
'http',
$this->builder->http()->routeTranslator()
)
);
}
|
php
|
public function templateExtensions()
{
return array(
new Extensions\Template\Extension\Debug(
$this->components()->debug()
),
new Extensions\Template\Extension\RouteTranslator(
'http',
$this->builder->http()->routeTranslator()
)
);
}
|
[
"public",
"function",
"templateExtensions",
"(",
")",
"{",
"return",
"array",
"(",
"new",
"Extensions",
"\\",
"Template",
"\\",
"Extension",
"\\",
"Debug",
"(",
"$",
"this",
"->",
"components",
"(",
")",
"->",
"debug",
"(",
")",
")",
",",
"new",
"Extensions",
"\\",
"Template",
"\\",
"Extension",
"\\",
"RouteTranslator",
"(",
"'http'",
",",
"$",
"this",
"->",
"builder",
"->",
"http",
"(",
")",
"->",
"routeTranslator",
"(",
")",
")",
")",
";",
"}"
] |
Extensions for the Template component
@return array
|
[
"Extensions",
"for",
"the",
"Template",
"component"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Extensions.php#L28-L39
|
221,256
|
PHPixie/Framework
|
src/PHPixie/Framework/Extensions.php
|
Extensions.authProviderBuilders
|
public function authProviderBuilders()
{
return array(
$this->buildAuthLogin()->providers(),
$this->buildAuthHttp()->providers(),
$this->buildAuthSocial()->providers()
);
}
|
php
|
public function authProviderBuilders()
{
return array(
$this->buildAuthLogin()->providers(),
$this->buildAuthHttp()->providers(),
$this->buildAuthSocial()->providers()
);
}
|
[
"public",
"function",
"authProviderBuilders",
"(",
")",
"{",
"return",
"array",
"(",
"$",
"this",
"->",
"buildAuthLogin",
"(",
")",
"->",
"providers",
"(",
")",
",",
"$",
"this",
"->",
"buildAuthHttp",
"(",
")",
"->",
"providers",
"(",
")",
",",
"$",
"this",
"->",
"buildAuthSocial",
"(",
")",
"->",
"providers",
"(",
")",
")",
";",
"}"
] |
Provider builders for the Auth component
@return array
|
[
"Provider",
"builders",
"for",
"the",
"Auth",
"component"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Extensions.php#L54-L61
|
221,257
|
sroehrl/neoan3-db
|
DbOps.php
|
DbOps.operandi
|
protected function operandi($string, $set = false, $prepared = false) {
if(empty($string) && $string !== "0") {
return ($set ? ' = NULL' : ' IS NULL');
}
$firstLetter = strtolower(substr($string, 0, 1));
switch($firstLetter) {
case '>':
case '<':
$return = ' ' . $firstLetter . ' "' . intval(substr($string, 1)) . '"';
break;
case '.':
$return = ' = NOW()';
break;
case '$':
$rest = substr($string, 1);
if($prepared){
$return = ' = UNHEX(?)';
$this->addExclusion($rest, 's');
} else {
$return = ' = UNHEX("'.$rest.'")';
}
break;
case '!':
if(strtolower($string) == '!null' || strlen($string) == 1){
if($set){
$this->formatError(
[$string], 'Cannot set "NOT NULL" as value for "' . substr($string, 1) . '"'
);
}
$return = ' IS NOT NULL ';
} else {
if($set){
$this->formatError([$string], 'Cannot use "!= ' . substr($string, 1) . '" to set a value');
}
$return = ' != "' . substr($string, 1) . '"';
}
break;
case '{':
$return = ' ' . substr($string, 1, -1);
break;
case '^':
$return = ($set ? ' = NULL' : ' IS NULL');
break;
default:
if(strtolower($string) == 'null'){
$return = ($set ? ' = NULL' : ' IS NULL');
} elseif($prepared){
$return = ' = ? ';
$this->addExclusion($string);
} else {
$return = ' = "' . $string . '"';
}
break;
}
return $return;
}
|
php
|
protected function operandi($string, $set = false, $prepared = false) {
if(empty($string) && $string !== "0") {
return ($set ? ' = NULL' : ' IS NULL');
}
$firstLetter = strtolower(substr($string, 0, 1));
switch($firstLetter) {
case '>':
case '<':
$return = ' ' . $firstLetter . ' "' . intval(substr($string, 1)) . '"';
break;
case '.':
$return = ' = NOW()';
break;
case '$':
$rest = substr($string, 1);
if($prepared){
$return = ' = UNHEX(?)';
$this->addExclusion($rest, 's');
} else {
$return = ' = UNHEX("'.$rest.'")';
}
break;
case '!':
if(strtolower($string) == '!null' || strlen($string) == 1){
if($set){
$this->formatError(
[$string], 'Cannot set "NOT NULL" as value for "' . substr($string, 1) . '"'
);
}
$return = ' IS NOT NULL ';
} else {
if($set){
$this->formatError([$string], 'Cannot use "!= ' . substr($string, 1) . '" to set a value');
}
$return = ' != "' . substr($string, 1) . '"';
}
break;
case '{':
$return = ' ' . substr($string, 1, -1);
break;
case '^':
$return = ($set ? ' = NULL' : ' IS NULL');
break;
default:
if(strtolower($string) == 'null'){
$return = ($set ? ' = NULL' : ' IS NULL');
} elseif($prepared){
$return = ' = ? ';
$this->addExclusion($string);
} else {
$return = ' = "' . $string . '"';
}
break;
}
return $return;
}
|
[
"protected",
"function",
"operandi",
"(",
"$",
"string",
",",
"$",
"set",
"=",
"false",
",",
"$",
"prepared",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"string",
")",
"&&",
"$",
"string",
"!==",
"\"0\"",
")",
"{",
"return",
"(",
"$",
"set",
"?",
"' = NULL'",
":",
"' IS NULL'",
")",
";",
"}",
"$",
"firstLetter",
"=",
"strtolower",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"1",
")",
")",
";",
"switch",
"(",
"$",
"firstLetter",
")",
"{",
"case",
"'>'",
":",
"case",
"'<'",
":",
"$",
"return",
"=",
"' '",
".",
"$",
"firstLetter",
".",
"' \"'",
".",
"intval",
"(",
"substr",
"(",
"$",
"string",
",",
"1",
")",
")",
".",
"'\"'",
";",
"break",
";",
"case",
"'.'",
":",
"$",
"return",
"=",
"' = NOW()'",
";",
"break",
";",
"case",
"'$'",
":",
"$",
"rest",
"=",
"substr",
"(",
"$",
"string",
",",
"1",
")",
";",
"if",
"(",
"$",
"prepared",
")",
"{",
"$",
"return",
"=",
"' = UNHEX(?)'",
";",
"$",
"this",
"->",
"addExclusion",
"(",
"$",
"rest",
",",
"'s'",
")",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"' = UNHEX(\"'",
".",
"$",
"rest",
".",
"'\")'",
";",
"}",
"break",
";",
"case",
"'!'",
":",
"if",
"(",
"strtolower",
"(",
"$",
"string",
")",
"==",
"'!null'",
"||",
"strlen",
"(",
"$",
"string",
")",
"==",
"1",
")",
"{",
"if",
"(",
"$",
"set",
")",
"{",
"$",
"this",
"->",
"formatError",
"(",
"[",
"$",
"string",
"]",
",",
"'Cannot set \"NOT NULL\" as value for \"'",
".",
"substr",
"(",
"$",
"string",
",",
"1",
")",
".",
"'\"'",
")",
";",
"}",
"$",
"return",
"=",
"' IS NOT NULL '",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"set",
")",
"{",
"$",
"this",
"->",
"formatError",
"(",
"[",
"$",
"string",
"]",
",",
"'Cannot use \"!= '",
".",
"substr",
"(",
"$",
"string",
",",
"1",
")",
".",
"'\" to set a value'",
")",
";",
"}",
"$",
"return",
"=",
"' != \"'",
".",
"substr",
"(",
"$",
"string",
",",
"1",
")",
".",
"'\"'",
";",
"}",
"break",
";",
"case",
"'{'",
":",
"$",
"return",
"=",
"' '",
".",
"substr",
"(",
"$",
"string",
",",
"1",
",",
"-",
"1",
")",
";",
"break",
";",
"case",
"'^'",
":",
"$",
"return",
"=",
"(",
"$",
"set",
"?",
"' = NULL'",
":",
"' IS NULL'",
")",
";",
"break",
";",
"default",
":",
"if",
"(",
"strtolower",
"(",
"$",
"string",
")",
"==",
"'null'",
")",
"{",
"$",
"return",
"=",
"(",
"$",
"set",
"?",
"' = NULL'",
":",
"' IS NULL'",
")",
";",
"}",
"elseif",
"(",
"$",
"prepared",
")",
"{",
"$",
"return",
"=",
"' = ? '",
";",
"$",
"this",
"->",
"addExclusion",
"(",
"$",
"string",
")",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"' = \"'",
".",
"$",
"string",
".",
"'\"'",
";",
"}",
"break",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
EASY markup interpretation to influence conditions-behavior
@param $string
@param bool $set
@param bool $prepared
@return array|bool|string
@throws DbException
|
[
"EASY",
"markup",
"interpretation",
"to",
"influence",
"conditions",
"-",
"behavior"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/DbOps.php#L78-L134
|
221,258
|
sroehrl/neoan3-db
|
DbOps.php
|
DbOps.selectandi
|
protected function selectandi($string) {
$firstLetter = strtolower(substr($string, 0, 1));
$rest = substr($string, 1);
switch($firstLetter) {
case '#':
$return = 'UNIX_TIMESTAMP(' . $this->_sanitizeAndAddBackticks($this->cleanAs($rest)) . ')*1000';
break;
case '$':
$return = 'HEX(' . $this->_sanitizeAndAddBackticks($this->cleanAs($rest)) . ')';
break;
default:
$return = $this->addBackticks($string);
}
return $return . $this->checkAs($string);
}
|
php
|
protected function selectandi($string) {
$firstLetter = strtolower(substr($string, 0, 1));
$rest = substr($string, 1);
switch($firstLetter) {
case '#':
$return = 'UNIX_TIMESTAMP(' . $this->_sanitizeAndAddBackticks($this->cleanAs($rest)) . ')*1000';
break;
case '$':
$return = 'HEX(' . $this->_sanitizeAndAddBackticks($this->cleanAs($rest)) . ')';
break;
default:
$return = $this->addBackticks($string);
}
return $return . $this->checkAs($string);
}
|
[
"protected",
"function",
"selectandi",
"(",
"$",
"string",
")",
"{",
"$",
"firstLetter",
"=",
"strtolower",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"1",
")",
")",
";",
"$",
"rest",
"=",
"substr",
"(",
"$",
"string",
",",
"1",
")",
";",
"switch",
"(",
"$",
"firstLetter",
")",
"{",
"case",
"'#'",
":",
"$",
"return",
"=",
"'UNIX_TIMESTAMP('",
".",
"$",
"this",
"->",
"_sanitizeAndAddBackticks",
"(",
"$",
"this",
"->",
"cleanAs",
"(",
"$",
"rest",
")",
")",
".",
"')*1000'",
";",
"break",
";",
"case",
"'$'",
":",
"$",
"return",
"=",
"'HEX('",
".",
"$",
"this",
"->",
"_sanitizeAndAddBackticks",
"(",
"$",
"this",
"->",
"cleanAs",
"(",
"$",
"rest",
")",
")",
".",
"')'",
";",
"break",
";",
"default",
":",
"$",
"return",
"=",
"$",
"this",
"->",
"addBackticks",
"(",
"$",
"string",
")",
";",
"}",
"return",
"$",
"return",
".",
"$",
"this",
"->",
"checkAs",
"(",
"$",
"string",
")",
";",
"}"
] |
EASY markup interpretation to influence select-behavior
@param $string
@return string
|
[
"EASY",
"markup",
"interpretation",
"to",
"influence",
"select",
"-",
"behavior"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/DbOps.php#L143-L157
|
221,259
|
sroehrl/neoan3-db
|
DbOps.php
|
DbOps.addBackticks
|
protected function addBackticks($string) {
$parts = explode('.', $string);
$result = '';
foreach($parts as $i => $part) {
$result .= ($i > 0 ? '.' : '');
if($part !== '*') {
$result .= '`' . $part . '`';
} else {
$result .= $part;
}
}
return $result;
}
|
php
|
protected function addBackticks($string) {
$parts = explode('.', $string);
$result = '';
foreach($parts as $i => $part) {
$result .= ($i > 0 ? '.' : '');
if($part !== '*') {
$result .= '`' . $part . '`';
} else {
$result .= $part;
}
}
return $result;
}
|
[
"protected",
"function",
"addBackticks",
"(",
"$",
"string",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"string",
")",
";",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"i",
"=>",
"$",
"part",
")",
"{",
"$",
"result",
".=",
"(",
"$",
"i",
">",
"0",
"?",
"'.'",
":",
"''",
")",
";",
"if",
"(",
"$",
"part",
"!==",
"'*'",
")",
"{",
"$",
"result",
".=",
"'`'",
".",
"$",
"part",
".",
"'`'",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"$",
"part",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Adds backticks to keys, tables & columns
@param $string
@return string
|
[
"Adds",
"backticks",
"to",
"keys",
"tables",
"&",
"columns"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/DbOps.php#L177-L189
|
221,260
|
PHPixie/Framework
|
src/PHPixie/Framework/Processors.php
|
Processors.httpExceptionResponse
|
public function httpExceptionResponse($configData)
{
$components = $this->builder->components();
return new Processors\HTTP\Response\Exception(
$components->debug(),
$components->http(),
$components->template(),
$configData
);
}
|
php
|
public function httpExceptionResponse($configData)
{
$components = $this->builder->components();
return new Processors\HTTP\Response\Exception(
$components->debug(),
$components->http(),
$components->template(),
$configData
);
}
|
[
"public",
"function",
"httpExceptionResponse",
"(",
"$",
"configData",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
";",
"return",
"new",
"Processors",
"\\",
"HTTP",
"\\",
"Response",
"\\",
"Exception",
"(",
"$",
"components",
"->",
"debug",
"(",
")",
",",
"$",
"components",
"->",
"http",
"(",
")",
",",
"$",
"components",
"->",
"template",
"(",
")",
",",
"$",
"configData",
")",
";",
"}"
] |
Processor that renders the exception response
@param Data $configData
@return Processors\HTTP\Response\Exception
|
[
"Processor",
"that",
"renders",
"the",
"exception",
"response"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Processors.php#L44-L54
|
221,261
|
PHPixie/Framework
|
src/PHPixie/Framework/Processors.php
|
Processors.httpNotFoundResponse
|
public function httpNotFoundResponse($configData)
{
$components = $this->builder->components();
return new Processors\HTTP\Response\NotFound(
$components->http(),
$components->template(),
$configData
);
}
|
php
|
public function httpNotFoundResponse($configData)
{
$components = $this->builder->components();
return new Processors\HTTP\Response\NotFound(
$components->http(),
$components->template(),
$configData
);
}
|
[
"public",
"function",
"httpNotFoundResponse",
"(",
"$",
"configData",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
";",
"return",
"new",
"Processors",
"\\",
"HTTP",
"\\",
"Response",
"\\",
"NotFound",
"(",
"$",
"components",
"->",
"http",
"(",
")",
",",
"$",
"components",
"->",
"template",
"(",
")",
",",
"$",
"configData",
")",
";",
"}"
] |
Processor for the "not found" page
@param Data $configData
@return Processors\HTTP\Response\NotFound
|
[
"Processor",
"for",
"the",
"not",
"found",
"page"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Processors.php#L61-L70
|
221,262
|
PHPixie/Framework
|
src/PHPixie/Framework/Processors.php
|
Processors.httpNormalizeResponse
|
public function httpNormalizeResponse()
{
$components = $this->builder->components();
return new Processors\HTTP\Response\Normalize(
$components->http()
);
}
|
php
|
public function httpNormalizeResponse()
{
$components = $this->builder->components();
return new Processors\HTTP\Response\Normalize(
$components->http()
);
}
|
[
"public",
"function",
"httpNormalizeResponse",
"(",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
";",
"return",
"new",
"Processors",
"\\",
"HTTP",
"\\",
"Response",
"\\",
"Normalize",
"(",
"$",
"components",
"->",
"http",
"(",
")",
")",
";",
"}"
] |
Processor that turns return values into HTTP Responses.
E.g. objects are turned into JSON responses
and template containers are rendered automatically
@return Processors\HTTP\Response\Normalize
|
[
"Processor",
"that",
"turns",
"return",
"values",
"into",
"HTTP",
"Responses",
"."
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Processors.php#L79-L86
|
221,263
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/subdocument.php
|
Mongo_Subdocument.iterate
|
public static function iterate(Mongo_Document $document, $name, $model = false)
{
if (is_bool($model)) $model = get_called_class();
else if (is_object($model)) $model = get_class($model);
$value = $document->get($name);
if (!is_array($value) && !($value instanceof Iterator)) throw new MongoException();
$result = array();
foreach ($value as $key => $v)
{
$sub = new $model($document, $name . '.' . $key);
$result[$key] = $sub;
}
return $result;
}
|
php
|
public static function iterate(Mongo_Document $document, $name, $model = false)
{
if (is_bool($model)) $model = get_called_class();
else if (is_object($model)) $model = get_class($model);
$value = $document->get($name);
if (!is_array($value) && !($value instanceof Iterator)) throw new MongoException();
$result = array();
foreach ($value as $key => $v)
{
$sub = new $model($document, $name . '.' . $key);
$result[$key] = $sub;
}
return $result;
}
|
[
"public",
"static",
"function",
"iterate",
"(",
"Mongo_Document",
"$",
"document",
",",
"$",
"name",
",",
"$",
"model",
"=",
"false",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"model",
")",
")",
"$",
"model",
"=",
"get_called_class",
"(",
")",
";",
"else",
"if",
"(",
"is_object",
"(",
"$",
"model",
")",
")",
"$",
"model",
"=",
"get_class",
"(",
"$",
"model",
")",
";",
"$",
"value",
"=",
"$",
"document",
"->",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"Iterator",
")",
")",
"throw",
"new",
"MongoException",
"(",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"v",
")",
"{",
"$",
"sub",
"=",
"new",
"$",
"model",
"(",
"$",
"document",
",",
"$",
"name",
".",
"'.'",
".",
"$",
"key",
")",
";",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"sub",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns a subdocument for every value in the array.
|
[
"Returns",
"a",
"subdocument",
"for",
"every",
"value",
"in",
"the",
"array",
"."
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/subdocument.php#L72-L87
|
221,264
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.userShow
|
public function userShow($user_id)
{
$response = $this->getGuzzleClient()
->get('/users/' . $user_id, $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
User::class,
'json'
);
}
|
php
|
public function userShow($user_id)
{
$response = $this->getGuzzleClient()
->get('/users/' . $user_id, $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
User::class,
'json'
);
}
|
[
"public",
"function",
"userShow",
"(",
"$",
"user_id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"get",
"(",
"'/users/'",
".",
"$",
"user_id",
",",
"$",
"this",
"->",
"setQuery",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"User",
"::",
"class",
",",
"'json'",
")",
";",
"}"
] |
User show resource
@param $user_id
@return array|\JMS\Serializer\scalar|object
|
[
"User",
"show",
"resource"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L126-L136
|
221,265
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.userPackages
|
public function userPackages($user_id, $filters = [])
{
// TODO: Tests
$response = $this->getGuzzleClient()
->get(
'/users/' . $user_id . '/classifieds_promotion_packs',
$this->setQuery($filters)
);
return $this->serializer->deserialize(
$response->getBody()->getContents(),
"array<" . Package::class . ">",
'json'
);
}
|
php
|
public function userPackages($user_id, $filters = [])
{
// TODO: Tests
$response = $this->getGuzzleClient()
->get(
'/users/' . $user_id . '/classifieds_promotion_packs',
$this->setQuery($filters)
);
return $this->serializer->deserialize(
$response->getBody()->getContents(),
"array<" . Package::class . ">",
'json'
);
}
|
[
"public",
"function",
"userPackages",
"(",
"$",
"user_id",
",",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"// TODO: Tests",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"get",
"(",
"'/users/'",
".",
"$",
"user_id",
".",
"'/classifieds_promotion_packs'",
",",
"$",
"this",
"->",
"setQuery",
"(",
"$",
"filters",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"\"array<\"",
".",
"Package",
"::",
"class",
".",
"\">\"",
",",
"'json'",
")",
";",
"}"
] |
Hired packages by user
@param $user_id
@param $filters
@return array|\JMS\Serializer\scalar|object
|
[
"Hired",
"packages",
"by",
"user"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L146-L160
|
221,266
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.categoryList
|
public function categoryList($site_id)
{
$response = $this->getGuzzleClient()
->get('/sites/' . $site_id . '/categories', $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
"array<" . Category::class . ">",
'json'
);
}
|
php
|
public function categoryList($site_id)
{
$response = $this->getGuzzleClient()
->get('/sites/' . $site_id . '/categories', $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
"array<" . Category::class . ">",
'json'
);
}
|
[
"public",
"function",
"categoryList",
"(",
"$",
"site_id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"get",
"(",
"'/sites/'",
".",
"$",
"site_id",
".",
"'/categories'",
",",
"$",
"this",
"->",
"setQuery",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"\"array<\"",
".",
"Category",
"::",
"class",
".",
"\">\"",
",",
"'json'",
")",
";",
"}"
] |
Category list resource
@param $site_id string
@return array|\JMS\Serializer\scalar|object
|
[
"Category",
"list",
"resource"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L179-L189
|
221,267
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.categoryPredict
|
public function categoryPredict($site_id, $title)
{
$response = $this->getGuzzleClient()
->get(
'/sites/' . $site_id . '/category_predictor/predict',
$this->setQuery(['title' => $title])
);
return $this->serializer->deserialize(
$response->getBody()->getContents(),
CategoryPrediction::class,
'json'
);
}
|
php
|
public function categoryPredict($site_id, $title)
{
$response = $this->getGuzzleClient()
->get(
'/sites/' . $site_id . '/category_predictor/predict',
$this->setQuery(['title' => $title])
);
return $this->serializer->deserialize(
$response->getBody()->getContents(),
CategoryPrediction::class,
'json'
);
}
|
[
"public",
"function",
"categoryPredict",
"(",
"$",
"site_id",
",",
"$",
"title",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"get",
"(",
"'/sites/'",
".",
"$",
"site_id",
".",
"'/category_predictor/predict'",
",",
"$",
"this",
"->",
"setQuery",
"(",
"[",
"'title'",
"=>",
"$",
"title",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"CategoryPrediction",
"::",
"class",
",",
"'json'",
")",
";",
"}"
] |
Category Predict resource
@param $site_id string
@param $title string
@return array|\JMS\Serializer\scalar|object
|
[
"Category",
"Predict",
"resource"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L199-L211
|
221,268
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.itemList
|
public function itemList($user_id)
{
$response = $this->getGuzzleClient()
->get('/users/' . $user_id . '/items/search', $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
ItemList::class,
'json'
);
}
|
php
|
public function itemList($user_id)
{
$response = $this->getGuzzleClient()
->get('/users/' . $user_id . '/items/search', $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
ItemList::class,
'json'
);
}
|
[
"public",
"function",
"itemList",
"(",
"$",
"user_id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"get",
"(",
"'/users/'",
".",
"$",
"user_id",
".",
"'/items/search'",
",",
"$",
"this",
"->",
"setQuery",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"ItemList",
"::",
"class",
",",
"'json'",
")",
";",
"}"
] |
Item List resource
@param $user_id string
@return array|\JMS\Serializer\scalar|object
|
[
"Item",
"List",
"resource"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L220-L230
|
221,269
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.itemShow
|
public function itemShow($item_id)
{
$response = $this->getGuzzleClient()
->get('/items/' . $item_id, $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
Item::class,
'json'
);
}
|
php
|
public function itemShow($item_id)
{
$response = $this->getGuzzleClient()
->get('/items/' . $item_id, $this->setQuery());
return $this->serializer->deserialize(
$response->getBody()->getContents(),
Item::class,
'json'
);
}
|
[
"public",
"function",
"itemShow",
"(",
"$",
"item_id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"get",
"(",
"'/items/'",
".",
"$",
"item_id",
",",
"$",
"this",
"->",
"setQuery",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"Item",
"::",
"class",
",",
"'json'",
")",
";",
"}"
] |
Item Show resource
@param $item_id
@return array|\JMS\Serializer\scalar|object
|
[
"Item",
"Show",
"resource"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L239-L249
|
221,270
|
zephia/mercadolibre
|
src/Client/MercadoLibreClient.php
|
MercadoLibreClient.itemUpdateListingType
|
public function itemUpdateListingType($item_id, $listing_type)
{
// TODO: Tests
$response = $this->getGuzzleClient()
->post(
'/items/' . $item_id . '/listing_type',
array_merge(
$this->setQuery(),
$this->setBodyArray(['id' => $listing_type])
)
);
return $this->serializer->deserialize(
$response->getBody()->getContents(),
Item::class,
'json'
);
}
|
php
|
public function itemUpdateListingType($item_id, $listing_type)
{
// TODO: Tests
$response = $this->getGuzzleClient()
->post(
'/items/' . $item_id . '/listing_type',
array_merge(
$this->setQuery(),
$this->setBodyArray(['id' => $listing_type])
)
);
return $this->serializer->deserialize(
$response->getBody()->getContents(),
Item::class,
'json'
);
}
|
[
"public",
"function",
"itemUpdateListingType",
"(",
"$",
"item_id",
",",
"$",
"listing_type",
")",
"{",
"// TODO: Tests",
"$",
"response",
"=",
"$",
"this",
"->",
"getGuzzleClient",
"(",
")",
"->",
"post",
"(",
"'/items/'",
".",
"$",
"item_id",
".",
"'/listing_type'",
",",
"array_merge",
"(",
"$",
"this",
"->",
"setQuery",
"(",
")",
",",
"$",
"this",
"->",
"setBodyArray",
"(",
"[",
"'id'",
"=>",
"$",
"listing_type",
"]",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"Item",
"::",
"class",
",",
"'json'",
")",
";",
"}"
] |
Item update listing type
@param string $item_id
@param string $listing_type
@return array|\JMS\Serializer\scalar|object
|
[
"Item",
"update",
"listing",
"type"
] |
7914110c0eda8619f706552fc5d87b594cc89b73
|
https://github.com/zephia/mercadolibre/blob/7914110c0eda8619f706552fc5d87b594cc89b73/src/Client/MercadoLibreClient.php#L355-L372
|
221,271
|
davelip/laravel-database-queue
|
src/DatabaseQueue.php
|
DatabaseQueue.storeJob
|
public function storeJob($job, $data, $queue, $timestamp = 0)
{
$payload = $this->createPayload($job, $data);
$job = new Job();
$job->setConnection($this->database->getName());
$job->queue = ($queue ? $queue : $this->default);
$job->status = Job::STATUS_OPEN;
$job->timestamp = date('Y-m-d H:i:s', ($timestamp != 0 ? $timestamp : time()));
$job->payload = $payload;
$job->save();
return $job->id;
}
|
php
|
public function storeJob($job, $data, $queue, $timestamp = 0)
{
$payload = $this->createPayload($job, $data);
$job = new Job();
$job->setConnection($this->database->getName());
$job->queue = ($queue ? $queue : $this->default);
$job->status = Job::STATUS_OPEN;
$job->timestamp = date('Y-m-d H:i:s', ($timestamp != 0 ? $timestamp : time()));
$job->payload = $payload;
$job->save();
return $job->id;
}
|
[
"public",
"function",
"storeJob",
"(",
"$",
"job",
",",
"$",
"data",
",",
"$",
"queue",
",",
"$",
"timestamp",
"=",
"0",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"createPayload",
"(",
"$",
"job",
",",
"$",
"data",
")",
";",
"$",
"job",
"=",
"new",
"Job",
"(",
")",
";",
"$",
"job",
"->",
"setConnection",
"(",
"$",
"this",
"->",
"database",
"->",
"getName",
"(",
")",
")",
";",
"$",
"job",
"->",
"queue",
"=",
"(",
"$",
"queue",
"?",
"$",
"queue",
":",
"$",
"this",
"->",
"default",
")",
";",
"$",
"job",
"->",
"status",
"=",
"Job",
"::",
"STATUS_OPEN",
";",
"$",
"job",
"->",
"timestamp",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"(",
"$",
"timestamp",
"!=",
"0",
"?",
"$",
"timestamp",
":",
"time",
"(",
")",
")",
")",
";",
"$",
"job",
"->",
"payload",
"=",
"$",
"payload",
";",
"$",
"job",
"->",
"save",
"(",
")",
";",
"return",
"$",
"job",
"->",
"id",
";",
"}"
] |
Store the job in the database
@param string $job job
@param mixed $data payload of job
@param string $queue queue name
@param integer $timestamp=0 timestamp
@return integer The id of the job
|
[
"Store",
"the",
"job",
"in",
"the",
"database"
] |
505b09ddd548fbf7608b63f79463f2d041e04c7a
|
https://github.com/davelip/laravel-database-queue/blob/505b09ddd548fbf7608b63f79463f2d041e04c7a/src/DatabaseQueue.php#L110-L123
|
221,272
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.processSapiRequest
|
public function processSapiRequest()
{
$http = $this->builder->components()->http();
$serverRequest = $http->sapiServerRequest();
$response = $this->processor()->process($serverRequest);
$http->output(
$response,
$this->builder->context()->httpContext()
);
}
|
php
|
public function processSapiRequest()
{
$http = $this->builder->components()->http();
$serverRequest = $http->sapiServerRequest();
$response = $this->processor()->process($serverRequest);
$http->output(
$response,
$this->builder->context()->httpContext()
);
}
|
[
"public",
"function",
"processSapiRequest",
"(",
")",
"{",
"$",
"http",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
"->",
"http",
"(",
")",
";",
"$",
"serverRequest",
"=",
"$",
"http",
"->",
"sapiServerRequest",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"processor",
"(",
")",
"->",
"process",
"(",
"$",
"serverRequest",
")",
";",
"$",
"http",
"->",
"output",
"(",
"$",
"response",
",",
"$",
"this",
"->",
"builder",
"->",
"context",
"(",
")",
"->",
"httpContext",
"(",
")",
")",
";",
"}"
] |
Process a PHP request from globals
and output the response
@return void
|
[
"Process",
"a",
"PHP",
"request",
"from",
"globals",
"and",
"output",
"the",
"response"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L97-L108
|
221,273
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.processServerRequest
|
public function processServerRequest($serverRequest)
{
$response = $this->processor()->process($serverRequest);
return $response->asResponseMessage(
$this->builder->context()->httpContext()
);
}
|
php
|
public function processServerRequest($serverRequest)
{
$response = $this->processor()->process($serverRequest);
return $response->asResponseMessage(
$this->builder->context()->httpContext()
);
}
|
[
"public",
"function",
"processServerRequest",
"(",
"$",
"serverRequest",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"processor",
"(",
")",
"->",
"process",
"(",
"$",
"serverRequest",
")",
";",
"return",
"$",
"response",
"->",
"asResponseMessage",
"(",
"$",
"this",
"->",
"builder",
"->",
"context",
"(",
")",
"->",
"httpContext",
"(",
")",
")",
";",
"}"
] |
Process a PSR7 ServerRequest into a PSR7 Response
@param ServerRequestInterface $serverRequest
@return ResponseInterface
|
[
"Process",
"a",
"PSR7",
"ServerRequest",
"into",
"a",
"PSR7",
"Response"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L115-L122
|
221,274
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.buildProcessor
|
protected function buildProcessor()
{
$processors = $this->builder->components()->processors();
return $processors->catchException(
$processors->chain(array(
$this->requestProcessor(),
$this->contextProcessor(),
$processors->checkIsProcessable(
$this->builder->configuration()->httpProcessor(),
$this->dispatchProcessor(),
$this->notFoundProcessor()
)
)),
$this->exceptionProcessor()
);
}
|
php
|
protected function buildProcessor()
{
$processors = $this->builder->components()->processors();
return $processors->catchException(
$processors->chain(array(
$this->requestProcessor(),
$this->contextProcessor(),
$processors->checkIsProcessable(
$this->builder->configuration()->httpProcessor(),
$this->dispatchProcessor(),
$this->notFoundProcessor()
)
)),
$this->exceptionProcessor()
);
}
|
[
"protected",
"function",
"buildProcessor",
"(",
")",
"{",
"$",
"processors",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
"->",
"processors",
"(",
")",
";",
"return",
"$",
"processors",
"->",
"catchException",
"(",
"$",
"processors",
"->",
"chain",
"(",
"array",
"(",
"$",
"this",
"->",
"requestProcessor",
"(",
")",
",",
"$",
"this",
"->",
"contextProcessor",
"(",
")",
",",
"$",
"processors",
"->",
"checkIsProcessable",
"(",
"$",
"this",
"->",
"builder",
"->",
"configuration",
"(",
")",
"->",
"httpProcessor",
"(",
")",
",",
"$",
"this",
"->",
"dispatchProcessor",
"(",
")",
",",
"$",
"this",
"->",
"notFoundProcessor",
"(",
")",
")",
")",
")",
",",
"$",
"this",
"->",
"exceptionProcessor",
"(",
")",
")",
";",
"}"
] |
Builds the HTTP request processor
@return Processor
|
[
"Builds",
"the",
"HTTP",
"request",
"processor"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L128-L144
|
221,275
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.requestProcessor
|
protected function requestProcessor()
{
$components = $this->builder->components();
$processors = $components->processors();
$httpProcessors = $components->httpProcessors();
return $processors->chain(array(
$httpProcessors->parseBody(),
$this->parseRouteProcessor(),
$httpProcessors->buildRequest()
));
}
|
php
|
protected function requestProcessor()
{
$components = $this->builder->components();
$processors = $components->processors();
$httpProcessors = $components->httpProcessors();
return $processors->chain(array(
$httpProcessors->parseBody(),
$this->parseRouteProcessor(),
$httpProcessors->buildRequest()
));
}
|
[
"protected",
"function",
"requestProcessor",
"(",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
";",
"$",
"processors",
"=",
"$",
"components",
"->",
"processors",
"(",
")",
";",
"$",
"httpProcessors",
"=",
"$",
"components",
"->",
"httpProcessors",
"(",
")",
";",
"return",
"$",
"processors",
"->",
"chain",
"(",
"array",
"(",
"$",
"httpProcessors",
"->",
"parseBody",
"(",
")",
",",
"$",
"this",
"->",
"parseRouteProcessor",
"(",
")",
",",
"$",
"httpProcessors",
"->",
"buildRequest",
"(",
")",
")",
")",
";",
"}"
] |
Builds the processor that takes care
of generating the PHPixie HTTP Request
@return Processor
|
[
"Builds",
"the",
"processor",
"that",
"takes",
"care",
"of",
"generating",
"the",
"PHPixie",
"HTTP",
"Request"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L151-L163
|
221,276
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.parseRouteProcessor
|
protected function parseRouteProcessor()
{
$frameworkProcessors = $this->builder->processors();
$translator = $this->routeTranslator();
return $frameworkProcessors->httpParseRoute($translator);
}
|
php
|
protected function parseRouteProcessor()
{
$frameworkProcessors = $this->builder->processors();
$translator = $this->routeTranslator();
return $frameworkProcessors->httpParseRoute($translator);
}
|
[
"protected",
"function",
"parseRouteProcessor",
"(",
")",
"{",
"$",
"frameworkProcessors",
"=",
"$",
"this",
"->",
"builder",
"->",
"processors",
"(",
")",
";",
"$",
"translator",
"=",
"$",
"this",
"->",
"routeTranslator",
"(",
")",
";",
"return",
"$",
"frameworkProcessors",
"->",
"httpParseRoute",
"(",
"$",
"translator",
")",
";",
"}"
] |
Builds the processor that takes care
of parsing the Request and populating route data
@return Processor
|
[
"Builds",
"the",
"processor",
"that",
"takes",
"care",
"of",
"parsing",
"the",
"Request",
"and",
"populating",
"route",
"data"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L191-L197
|
221,277
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.dispatchProcessor
|
protected function dispatchProcessor()
{
$processors = $this->builder->components()->processors();
$frameworkProcessors = $this->builder->processors();
return $processors->chain(array(
$this->builder->configuration()->httpProcessor(),
$frameworkProcessors->httpNormalizeResponse(),
));
}
|
php
|
protected function dispatchProcessor()
{
$processors = $this->builder->components()->processors();
$frameworkProcessors = $this->builder->processors();
return $processors->chain(array(
$this->builder->configuration()->httpProcessor(),
$frameworkProcessors->httpNormalizeResponse(),
));
}
|
[
"protected",
"function",
"dispatchProcessor",
"(",
")",
"{",
"$",
"processors",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
"->",
"processors",
"(",
")",
";",
"$",
"frameworkProcessors",
"=",
"$",
"this",
"->",
"builder",
"->",
"processors",
"(",
")",
";",
"return",
"$",
"processors",
"->",
"chain",
"(",
"array",
"(",
"$",
"this",
"->",
"builder",
"->",
"configuration",
"(",
")",
"->",
"httpProcessor",
"(",
")",
",",
"$",
"frameworkProcessors",
"->",
"httpNormalizeResponse",
"(",
")",
",",
")",
")",
";",
"}"
] |
Builds the processor that takes care
of dispatching the request.
If you want to process the request before
it reaches your code, you can do that
by overriding this method and adding your own
processor to the chain.
@return Processor
|
[
"Builds",
"the",
"processor",
"that",
"takes",
"care",
"of",
"dispatching",
"the",
"request",
"."
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L209-L218
|
221,278
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.exceptionProcessor
|
protected function exceptionProcessor()
{
$frameworkProcessors = $this->builder->processors();
$httpConfig = $this->builder->configuration()->httpConfig();
return $frameworkProcessors->httpExceptionResponse(
$httpConfig->slice('exceptionResponse')
);
}
|
php
|
protected function exceptionProcessor()
{
$frameworkProcessors = $this->builder->processors();
$httpConfig = $this->builder->configuration()->httpConfig();
return $frameworkProcessors->httpExceptionResponse(
$httpConfig->slice('exceptionResponse')
);
}
|
[
"protected",
"function",
"exceptionProcessor",
"(",
")",
"{",
"$",
"frameworkProcessors",
"=",
"$",
"this",
"->",
"builder",
"->",
"processors",
"(",
")",
";",
"$",
"httpConfig",
"=",
"$",
"this",
"->",
"builder",
"->",
"configuration",
"(",
")",
"->",
"httpConfig",
"(",
")",
";",
"return",
"$",
"frameworkProcessors",
"->",
"httpExceptionResponse",
"(",
"$",
"httpConfig",
"->",
"slice",
"(",
"'exceptionResponse'",
")",
")",
";",
"}"
] |
Builds the processor that handles uncaught exception
@return Processor
|
[
"Builds",
"the",
"processor",
"that",
"handles",
"uncaught",
"exception"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L224-L232
|
221,279
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.notFoundProcessor
|
protected function notFoundProcessor()
{
$frameworkProcessors = $this->builder->processors();
$httpConfig = $this->builder->configuration()->httpConfig();
return $frameworkProcessors->httpNotFoundResponse(
$httpConfig->slice('notFoundResponse')
);
}
|
php
|
protected function notFoundProcessor()
{
$frameworkProcessors = $this->builder->processors();
$httpConfig = $this->builder->configuration()->httpConfig();
return $frameworkProcessors->httpNotFoundResponse(
$httpConfig->slice('notFoundResponse')
);
}
|
[
"protected",
"function",
"notFoundProcessor",
"(",
")",
"{",
"$",
"frameworkProcessors",
"=",
"$",
"this",
"->",
"builder",
"->",
"processors",
"(",
")",
";",
"$",
"httpConfig",
"=",
"$",
"this",
"->",
"builder",
"->",
"configuration",
"(",
")",
"->",
"httpConfig",
"(",
")",
";",
"return",
"$",
"frameworkProcessors",
"->",
"httpNotFoundResponse",
"(",
"$",
"httpConfig",
"->",
"slice",
"(",
"'notFoundResponse'",
")",
")",
";",
"}"
] |
Builds the processor that handles non-existing urls
@return Processor
|
[
"Builds",
"the",
"processor",
"that",
"handles",
"non",
"-",
"existing",
"urls"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L238-L246
|
221,280
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.generateUri
|
public function generateUri(
$resolverPath = null,
$attributes = array(),
$withHost = false
)
{
return $this->routeTranslator()->generateUri(
$resolverPath,
$attributes,
$withHost
);
}
|
php
|
public function generateUri(
$resolverPath = null,
$attributes = array(),
$withHost = false
)
{
return $this->routeTranslator()->generateUri(
$resolverPath,
$attributes,
$withHost
);
}
|
[
"public",
"function",
"generateUri",
"(",
"$",
"resolverPath",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"withHost",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"routeTranslator",
"(",
")",
"->",
"generateUri",
"(",
"$",
"resolverPath",
",",
"$",
"attributes",
",",
"$",
"withHost",
")",
";",
"}"
] |
Generate a PSR-7 URI from route path and attributes
@param string $resolverPath
@param array $attributes
@param boolean $withHost Whether to include host in the URI
@return \PHPixie\HTTP\Messages\URI\Implementation
|
[
"Generate",
"a",
"PSR",
"-",
"7",
"URI",
"from",
"route",
"path",
"and",
"attributes"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L279-L290
|
221,281
|
PHPixie/Framework
|
src/PHPixie/Framework/HTTP.php
|
HTTP.redirectResponse
|
public function redirectResponse($resolverPath = null, $attributes = array())
{
$path = $this->generatePath(
$resolverPath,
$attributes
);
$http = $this->builder->components()->http();
return $http->responses()->redirect($path);
}
|
php
|
public function redirectResponse($resolverPath = null, $attributes = array())
{
$path = $this->generatePath(
$resolverPath,
$attributes
);
$http = $this->builder->components()->http();
return $http->responses()->redirect($path);
}
|
[
"public",
"function",
"redirectResponse",
"(",
"$",
"resolverPath",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"generatePath",
"(",
"$",
"resolverPath",
",",
"$",
"attributes",
")",
";",
"$",
"http",
"=",
"$",
"this",
"->",
"builder",
"->",
"components",
"(",
")",
"->",
"http",
"(",
")",
";",
"return",
"$",
"http",
"->",
"responses",
"(",
")",
"->",
"redirect",
"(",
"$",
"path",
")",
";",
"}"
] |
Generate a redirect response from route path and attributes
@param string $resolverPath
@param array $attributes
@return \PHPixie\HTTP\Responses\Response
|
[
"Generate",
"a",
"redirect",
"response",
"from",
"route",
"path",
"and",
"attributes"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/HTTP.php#L298-L307
|
221,282
|
sroehrl/neoan3-db
|
UuidHandler.php
|
UuidHandler.newUuid
|
public function newUuid(){
$q = Db::query('SELECT REPLACE(UUID(),"-","") as id');
while($row = $q['result']->fetch_assoc()){
$this->uuid = strtoupper($row['id']);
}
return $this;
}
|
php
|
public function newUuid(){
$q = Db::query('SELECT REPLACE(UUID(),"-","") as id');
while($row = $q['result']->fetch_assoc()){
$this->uuid = strtoupper($row['id']);
}
return $this;
}
|
[
"public",
"function",
"newUuid",
"(",
")",
"{",
"$",
"q",
"=",
"Db",
"::",
"query",
"(",
"'SELECT REPLACE(UUID(),\"-\",\"\") as id'",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"q",
"[",
"'result'",
"]",
"->",
"fetch_assoc",
"(",
")",
")",
"{",
"$",
"this",
"->",
"uuid",
"=",
"strtoupper",
"(",
"$",
"row",
"[",
"'id'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Generates new UUID
@return $this
@throws DbException
|
[
"Generates",
"new",
"UUID"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/UuidHandler.php#L54-L61
|
221,283
|
sroehrl/neoan3-db
|
UuidHandler.php
|
UuidHandler.convertBinaryResults
|
public function convertBinaryResults($resultArray){
foreach ($resultArray as $i => $item){
if(is_numeric($i)){
$resultArray[$i] = $this->convertBinaryResults($item);
} elseif(is_string($item)) {
if(DbOps::isBinary($item)){
$resultArray[$i] = strtoupper(bin2hex($item));
}
}
}
return $resultArray;
}
|
php
|
public function convertBinaryResults($resultArray){
foreach ($resultArray as $i => $item){
if(is_numeric($i)){
$resultArray[$i] = $this->convertBinaryResults($item);
} elseif(is_string($item)) {
if(DbOps::isBinary($item)){
$resultArray[$i] = strtoupper(bin2hex($item));
}
}
}
return $resultArray;
}
|
[
"public",
"function",
"convertBinaryResults",
"(",
"$",
"resultArray",
")",
"{",
"foreach",
"(",
"$",
"resultArray",
"as",
"$",
"i",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"i",
")",
")",
"{",
"$",
"resultArray",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"convertBinaryResults",
"(",
"$",
"item",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"if",
"(",
"DbOps",
"::",
"isBinary",
"(",
"$",
"item",
")",
")",
"{",
"$",
"resultArray",
"[",
"$",
"i",
"]",
"=",
"strtoupper",
"(",
"bin2hex",
"(",
"$",
"item",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"resultArray",
";",
"}"
] |
handles binary to hex conversion
@param $resultArray
@return mixed
|
[
"handles",
"binary",
"to",
"hex",
"conversion"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/UuidHandler.php#L70-L81
|
221,284
|
sroehrl/neoan3-db
|
UuidHandler.php
|
UuidHandler.convertToCompliantUuid
|
public function convertToCompliantUuid($uuid=false){
$id = ($uuid?$uuid:$this->uuid);
$arr = [8, 13, 18, 23];
foreach ($arr as $part){
$id = substr_replace($id, '-', $part, 0);
}
return $id;
}
|
php
|
public function convertToCompliantUuid($uuid=false){
$id = ($uuid?$uuid:$this->uuid);
$arr = [8, 13, 18, 23];
foreach ($arr as $part){
$id = substr_replace($id, '-', $part, 0);
}
return $id;
}
|
[
"public",
"function",
"convertToCompliantUuid",
"(",
"$",
"uuid",
"=",
"false",
")",
"{",
"$",
"id",
"=",
"(",
"$",
"uuid",
"?",
"$",
"uuid",
":",
"$",
"this",
"->",
"uuid",
")",
";",
"$",
"arr",
"=",
"[",
"8",
",",
"13",
",",
"18",
",",
"23",
"]",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"part",
")",
"{",
"$",
"id",
"=",
"substr_replace",
"(",
"$",
"id",
",",
"'-'",
",",
"$",
"part",
",",
"0",
")",
";",
"}",
"return",
"$",
"id",
";",
"}"
] |
Converts short UUIDs to RFC 4122 conform format
@param bool $uuid
@return bool|mixed
|
[
"Converts",
"short",
"UUIDs",
"to",
"RFC",
"4122",
"conform",
"format"
] |
e66a7ec3bf958ffc0d59d32415f3d14a296c15cd
|
https://github.com/sroehrl/neoan3-db/blob/e66a7ec3bf958ffc0d59d32415f3d14a296c15cd/UuidHandler.php#L90-L97
|
221,285
|
PHPixie/Framework
|
src/PHPixie/Framework/Processors/HTTP/Response/NotFound.php
|
NotFound.process
|
public function process($request)
{
$templateName = $this->configData->getRequired('template');
$body = $this->template->render(
$templateName,
array(
'request' => $request
)
);
return $this->http->responses()->response($body, array(), 404);
}
|
php
|
public function process($request)
{
$templateName = $this->configData->getRequired('template');
$body = $this->template->render(
$templateName,
array(
'request' => $request
)
);
return $this->http->responses()->response($body, array(), 404);
}
|
[
"public",
"function",
"process",
"(",
"$",
"request",
")",
"{",
"$",
"templateName",
"=",
"$",
"this",
"->",
"configData",
"->",
"getRequired",
"(",
"'template'",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"template",
"->",
"render",
"(",
"$",
"templateName",
",",
"array",
"(",
"'request'",
"=>",
"$",
"request",
")",
")",
";",
"return",
"$",
"this",
"->",
"http",
"->",
"responses",
"(",
")",
"->",
"response",
"(",
"$",
"body",
",",
"array",
"(",
")",
",",
"404",
")",
";",
"}"
] |
Build a response for when a uri does not exist
@param \PHPixie\HTTP\Request $request
@return \PHPixie\HTTP\Responses\Response
|
[
"Build",
"a",
"response",
"for",
"when",
"a",
"uri",
"does",
"not",
"exist"
] |
f9bce1beffb09fe386e5d62d124aea042346001f
|
https://github.com/PHPixie/Framework/blob/f9bce1beffb09fe386e5d62d124aea042346001f/src/PHPixie/Framework/Processors/HTTP/Response/NotFound.php#L44-L56
|
221,286
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document._cast
|
protected function _cast($field, $value)
{
switch($field)
{
case '_id':
// Cast _id strings to MongoIds if they convert back and forth without changing
if ($value instanceof MongoId)
return $value;
if ((is_string($value) || ctype_xdigit($value) || (is_object($value) && method_exists($value, '__toString'))) && strlen($value) == 24)
{
$id = new MongoId($value);
if( (string) $id == $value)
return $id;
}
}
return $value;
}
|
php
|
protected function _cast($field, $value)
{
switch($field)
{
case '_id':
// Cast _id strings to MongoIds if they convert back and forth without changing
if ($value instanceof MongoId)
return $value;
if ((is_string($value) || ctype_xdigit($value) || (is_object($value) && method_exists($value, '__toString'))) && strlen($value) == 24)
{
$id = new MongoId($value);
if( (string) $id == $value)
return $id;
}
}
return $value;
}
|
[
"protected",
"function",
"_cast",
"(",
"$",
"field",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"field",
")",
"{",
"case",
"'_id'",
":",
"// Cast _id strings to MongoIds if they convert back and forth without changing",
"if",
"(",
"$",
"value",
"instanceof",
"MongoId",
")",
"return",
"$",
"value",
";",
"if",
"(",
"(",
"is_string",
"(",
"$",
"value",
")",
"||",
"ctype_xdigit",
"(",
"$",
"value",
")",
"||",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"method_exists",
"(",
"$",
"value",
",",
"'__toString'",
")",
")",
")",
"&&",
"strlen",
"(",
"$",
"value",
")",
"==",
"24",
")",
"{",
"$",
"id",
"=",
"new",
"MongoId",
"(",
"$",
"value",
")",
";",
"if",
"(",
"(",
"string",
")",
"$",
"id",
"==",
"$",
"value",
")",
"return",
"$",
"id",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] |
Override to cast values when they are set with untrusted data
@param mixed $field The field name being set
@param mixed $value The value being set
@return mixed|\MongoId|string
|
[
"Override",
"to",
"cast",
"values",
"when",
"they",
"are",
"set",
"with",
"untrusted",
"data"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L348-L364
|
221,287
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.__isset
|
public function __isset($name)
{
$name = $this->get_field_name($name, FALSE);
if (isset($this->_object[$name])) return TRUE;
// check for dirties...
if ($this->get($name)) return TRUE;
return isset($this->_object[$name]);
}
|
php
|
public function __isset($name)
{
$name = $this->get_field_name($name, FALSE);
if (isset($this->_object[$name])) return TRUE;
// check for dirties...
if ($this->get($name)) return TRUE;
return isset($this->_object[$name]);
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
",",
"FALSE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_object",
"[",
"$",
"name",
"]",
")",
")",
"return",
"TRUE",
";",
"// check for dirties...",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
")",
"return",
"TRUE",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"_object",
"[",
"$",
"name",
"]",
")",
";",
"}"
] |
Checks if a field is set
@param string $name Field name
@return boolean field is set
|
[
"Checks",
"if",
"a",
"field",
"is",
"set"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L408-L415
|
221,288
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.clear
|
public function clear()
{
$this->_object = $this->_changed = $this->_operations = $this->_dirty = $this->_related_objects = array();
$this->_loaded = NULL;
return $this;
}
|
php
|
public function clear()
{
$this->_object = $this->_changed = $this->_operations = $this->_dirty = $this->_related_objects = array();
$this->_loaded = NULL;
return $this;
}
|
[
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"_object",
"=",
"$",
"this",
"->",
"_changed",
"=",
"$",
"this",
"->",
"_operations",
"=",
"$",
"this",
"->",
"_dirty",
"=",
"$",
"this",
"->",
"_related_objects",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_loaded",
"=",
"NULL",
";",
"return",
"$",
"this",
";",
"}"
] |
Clear the document data
@return Mongo_Document
|
[
"Clear",
"the",
"document",
"data"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L433-L438
|
221,289
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.is_changed
|
public function is_changed($name = NULL)
{
if($name === NULL)
{
return ($this->_changed || $this->_operations);
}
else
{
$name = $this->get_field_name($name);
return isset($this->_changed[$name]) || isset($this->_dirty[$name]);
}
}
|
php
|
public function is_changed($name = NULL)
{
if($name === NULL)
{
return ($this->_changed || $this->_operations);
}
else
{
$name = $this->get_field_name($name);
return isset($this->_changed[$name]) || isset($this->_dirty[$name]);
}
}
|
[
"public",
"function",
"is_changed",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"NULL",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"_changed",
"||",
"$",
"this",
"->",
"_operations",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"_changed",
"[",
"$",
"name",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"_dirty",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}"
] |
Return TRUE if field has been changed
@param string $name field name (no parameter returns TRUE if there are *any* changes)
@return boolean field has been changed
|
[
"Return",
"TRUE",
"if",
"field",
"has",
"been",
"changed"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L446-L457
|
221,290
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.collection
|
public function collection($fresh = FALSE)
{
if($fresh === TRUE)
{
if($this->name)
{
if ($this->db === NULL)
{
$this->db = Mongo_Database::$default;
}
return new Mongo_Collection($this->name, $this->db, $this->gridFS, get_class($this));
}
else
{
$class_name = $this->get_collection_class_name();
return new $class_name(NULL, NULL, NULL, get_class($this));
}
}
if($this->name)
{
$name = "$this->db.$this->name.$this->gridFS";
if( ! isset(self::$collections[$name]))
{
if ($this->db === NULL)
{
$this->db = Mongo_Database::$default;
}
self::$collections[$name] = new Mongo_Collection($this->name, $this->db, $this->gridFS, get_class($this));
}
return self::$collections[$name];
}
else
{
$name = $this->get_collection_class_name();
if( ! isset(self::$collections[$name]))
{
self::$collections[$name] = new $name(NULL, NULL, NULL, get_class($this));
}
return self::$collections[$name];
}
}
|
php
|
public function collection($fresh = FALSE)
{
if($fresh === TRUE)
{
if($this->name)
{
if ($this->db === NULL)
{
$this->db = Mongo_Database::$default;
}
return new Mongo_Collection($this->name, $this->db, $this->gridFS, get_class($this));
}
else
{
$class_name = $this->get_collection_class_name();
return new $class_name(NULL, NULL, NULL, get_class($this));
}
}
if($this->name)
{
$name = "$this->db.$this->name.$this->gridFS";
if( ! isset(self::$collections[$name]))
{
if ($this->db === NULL)
{
$this->db = Mongo_Database::$default;
}
self::$collections[$name] = new Mongo_Collection($this->name, $this->db, $this->gridFS, get_class($this));
}
return self::$collections[$name];
}
else
{
$name = $this->get_collection_class_name();
if( ! isset(self::$collections[$name]))
{
self::$collections[$name] = new $name(NULL, NULL, NULL, get_class($this));
}
return self::$collections[$name];
}
}
|
[
"public",
"function",
"collection",
"(",
"$",
"fresh",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"fresh",
"===",
"TRUE",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"db",
"=",
"Mongo_Database",
"::",
"$",
"default",
";",
"}",
"return",
"new",
"Mongo_Collection",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"db",
",",
"$",
"this",
"->",
"gridFS",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"else",
"{",
"$",
"class_name",
"=",
"$",
"this",
"->",
"get_collection_class_name",
"(",
")",
";",
"return",
"new",
"$",
"class_name",
"(",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"name",
")",
"{",
"$",
"name",
"=",
"\"$this->db.$this->name.$this->gridFS\"",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"collections",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"db",
"=",
"Mongo_Database",
"::",
"$",
"default",
";",
"}",
"self",
"::",
"$",
"collections",
"[",
"$",
"name",
"]",
"=",
"new",
"Mongo_Collection",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"db",
",",
"$",
"this",
"->",
"gridFS",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"collections",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_collection_class_name",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"collections",
"[",
"$",
"name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"collections",
"[",
"$",
"name",
"]",
"=",
"new",
"$",
"name",
"(",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"collections",
"[",
"$",
"name",
"]",
";",
"}",
"}"
] |
Get a corresponding collection singleton
@param boolean $fresh Pass TRUE if you don't want to get the singleton instance
@return Mongo_Collection
|
[
"Get",
"a",
"corresponding",
"collection",
"singleton"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L493-L534
|
221,291
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.load_if_needed
|
protected function load_if_needed($name)
{
// Reload when retrieving dirty data
if ($this->_loaded && empty($this->_operations) && !empty($this->_dirty[$name]))
{
return $this->load();
}
// Lazy loading!
else if ($this->_loaded === NULL && isset($this->_object['_id']) && !isset($this->_changed['_id']) && $name != '_id')
{
return $this->load();
}
return FALSE;
}
|
php
|
protected function load_if_needed($name)
{
// Reload when retrieving dirty data
if ($this->_loaded && empty($this->_operations) && !empty($this->_dirty[$name]))
{
return $this->load();
}
// Lazy loading!
else if ($this->_loaded === NULL && isset($this->_object['_id']) && !isset($this->_changed['_id']) && $name != '_id')
{
return $this->load();
}
return FALSE;
}
|
[
"protected",
"function",
"load_if_needed",
"(",
"$",
"name",
")",
"{",
"// Reload when retrieving dirty data",
"if",
"(",
"$",
"this",
"->",
"_loaded",
"&&",
"empty",
"(",
"$",
"this",
"->",
"_operations",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"_dirty",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"// Lazy loading!",
"else",
"if",
"(",
"$",
"this",
"->",
"_loaded",
"===",
"NULL",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_object",
"[",
"'_id'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"_changed",
"[",
"'_id'",
"]",
")",
"&&",
"$",
"name",
"!=",
"'_id'",
")",
"{",
"return",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Reload document only if there is need for it
@param string $name Name of the field to check for (no dot notation)
@return bool
|
[
"Reload",
"document",
"only",
"if",
"there",
"is",
"need",
"for",
"it"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L654-L668
|
221,292
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.set
|
public function set($name, $value, $emulate = null)
{
if (!strpos($name, '.'))
{
$this->__set($name, $value);
return $this;
}
$name = $this->get_field_name($name);
$this->_operations['$set'][$name] = $value;
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE);
$ref = $value;
return $this;
}
}
|
php
|
public function set($name, $value, $emulate = null)
{
if (!strpos($name, '.'))
{
$this->__set($name, $value);
return $this;
}
$name = $this->get_field_name($name);
$this->_operations['$set'][$name] = $value;
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE);
$ref = $value;
return $this;
}
}
|
[
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"strpos",
"(",
"$",
"name",
",",
"'.'",
")",
")",
"{",
"$",
"this",
"->",
"__set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"_operations",
"[",
"'$set'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"&",
"$",
"this",
"->",
"get_field_reference",
"(",
"$",
"name",
",",
"TRUE",
")",
";",
"$",
"ref",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}",
"}"
] |
Set the value for a key. This function must be used when updating nested documents.
@param string $name The key of the data to update (use dot notation for embedded objects)
@param mixed $value The data to be saved
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload. @see $_emulate
@return Mongo_Document
|
[
"Set",
"the",
"value",
"for",
"a",
"key",
".",
"This",
"function",
"must",
"be",
"used",
"when",
"updating",
"nested",
"documents",
"."
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L767-L786
|
221,293
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document._unset
|
public function _unset($name, $emulate = null)
{
$name = $this->get_field_name($name);
$this->_operations['$unset'][$name] = 1;
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
self::unset_named_reference($this->_object, $name);
return $this;
}
}
|
php
|
public function _unset($name, $emulate = null)
{
$name = $this->get_field_name($name);
$this->_operations['$unset'][$name] = 1;
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
self::unset_named_reference($this->_object, $name);
return $this;
}
}
|
[
"public",
"function",
"_unset",
"(",
"$",
"name",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"_operations",
"[",
"'$unset'",
"]",
"[",
"$",
"name",
"]",
"=",
"1",
";",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"self",
"::",
"unset_named_reference",
"(",
"$",
"this",
"->",
"_object",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}",
"}"
] |
Unset a key
Note: unset() method call for _unset() is defined in __call() method since 'unset' method name
is reserved in PHP. ( Requires PHP > 5.2.3. - http://php.net/manual/en/reserved.keywords.php )
@param string $name The key of the data to update (use dot notation for embedded objects)
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload.
@see $_emulate
@return Mongo_Document
|
[
"Unset",
"a",
"key"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L799-L812
|
221,294
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.inc
|
public function inc($name, $value = 1, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$inc'][$name]))
{
$this->_operations['$inc'][$name] += $value;
}
else
{
$this->_operations['$inc'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, 0);
$ref += $value;
return $this;
}
}
|
php
|
public function inc($name, $value = 1, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$inc'][$name]))
{
$this->_operations['$inc'][$name] += $value;
}
else
{
$this->_operations['$inc'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, 0);
$ref += $value;
return $this;
}
}
|
[
"public",
"function",
"inc",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"1",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$inc'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$inc'",
"]",
"[",
"$",
"name",
"]",
"+=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$inc'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"&",
"$",
"this",
"->",
"get_field_reference",
"(",
"$",
"name",
",",
"TRUE",
",",
"0",
")",
";",
"$",
"ref",
"+=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}",
"}"
] |
Increment a value atomically
@param string $name The key of the data to update (use dot notation for embedded objects)
@param mixed $value The amount to increment by (default is 1)
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload. @see $_emulate
@return Mongo_Document
|
[
"Increment",
"a",
"value",
"atomically"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L822-L843
|
221,295
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.push
|
public function push($name, $value, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$pushAll'][$name]))
{
$this->_operations['$pushAll'][$name][] = $value;
}
else if(isset($this->_operations['$push'][$name]))
{
$this->_operations['$pushAll'][$name] = array($this->_operations['$push'][$name],$value);
unset($this->_operations['$push'][$name]);
if( ! count($this->_operations['$push']))
unset($this->_operations['$push']);
}
else
{
$this->_operations['$push'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, array());
if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
array_push($ref, $value);
return $this;
}
}
|
php
|
public function push($name, $value, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$pushAll'][$name]))
{
$this->_operations['$pushAll'][$name][] = $value;
}
else if(isset($this->_operations['$push'][$name]))
{
$this->_operations['$pushAll'][$name] = array($this->_operations['$push'][$name],$value);
unset($this->_operations['$push'][$name]);
if( ! count($this->_operations['$push']))
unset($this->_operations['$push']);
}
else
{
$this->_operations['$push'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, array());
if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
array_push($ref, $value);
return $this;
}
}
|
[
"public",
"function",
"push",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$pushAll'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$pushAll'",
"]",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$push'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$pushAll'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$push'",
"]",
"[",
"$",
"name",
"]",
",",
"$",
"value",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$push'",
"]",
"[",
"$",
"name",
"]",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$push'",
"]",
")",
")",
"unset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$push'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$push'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"&",
"$",
"this",
"->",
"get_field_reference",
"(",
"$",
"name",
",",
"TRUE",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ref",
")",
")",
"throw",
"new",
"MongoException",
"(",
"\"Value '$name' cannot be used as an array\"",
")",
";",
"array_push",
"(",
"$",
"ref",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}",
"}"
] |
Push a vlaue to an array atomically. Can be called multiple times.
@param string $name The key of the data to update (use dot notation for embedded objects)
@param mixed $value The value to push
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload. @see $_emulate
@return Mongo_Document
|
[
"Push",
"a",
"vlaue",
"to",
"an",
"array",
"atomically",
".",
"Can",
"be",
"called",
"multiple",
"times",
"."
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L853-L882
|
221,296
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.pushAll
|
public function pushAll($name, $value, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$pushAll'][$name]))
{
$this->_operations['$pushAll'][$name] += $value;
}
else
{
$this->_operations['$pushAll'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, array());
if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
foreach ($value as $v) array_push($ref, $v);
return $this;
}
}
|
php
|
public function pushAll($name, $value, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$pushAll'][$name]))
{
$this->_operations['$pushAll'][$name] += $value;
}
else
{
$this->_operations['$pushAll'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, array());
if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
foreach ($value as $v) array_push($ref, $v);
return $this;
}
}
|
[
"public",
"function",
"pushAll",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$pushAll'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$pushAll'",
"]",
"[",
"$",
"name",
"]",
"+=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$pushAll'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"&",
"$",
"this",
"->",
"get_field_reference",
"(",
"$",
"name",
",",
"TRUE",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ref",
")",
")",
"throw",
"new",
"MongoException",
"(",
"\"Value '$name' cannot be used as an array\"",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"array_push",
"(",
"$",
"ref",
",",
"$",
"v",
")",
";",
"return",
"$",
"this",
";",
"}",
"}"
] |
Push an array of values to an array in the document
@param string $name The key of the data to update (use dot notation for embedded objects)
@param array $value An array of values to push
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload. @see $_emulate
@return Mongo_Document
|
[
"Push",
"an",
"array",
"of",
"values",
"to",
"an",
"array",
"in",
"the",
"document"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L892-L914
|
221,297
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.pop
|
public function pop($name, $last = TRUE, $emulate = null)
{
$name = $this->get_field_name($name);
$this->_operations['$pop'][$name] = $last ? 1 : -1;
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, null);
if ($ref === null) return $this;
if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
if ($last) array_pop($ref);
else array_shift($ref);
return $this;
}
}
|
php
|
public function pop($name, $last = TRUE, $emulate = null)
{
$name = $this->get_field_name($name);
$this->_operations['$pop'][$name] = $last ? 1 : -1;
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE, null);
if ($ref === null) return $this;
if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
if ($last) array_pop($ref);
else array_shift($ref);
return $this;
}
}
|
[
"public",
"function",
"pop",
"(",
"$",
"name",
",",
"$",
"last",
"=",
"TRUE",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"_operations",
"[",
"'$pop'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"last",
"?",
"1",
":",
"-",
"1",
";",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"&",
"$",
"this",
"->",
"get_field_reference",
"(",
"$",
"name",
",",
"TRUE",
",",
"null",
")",
";",
"if",
"(",
"$",
"ref",
"===",
"null",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ref",
")",
")",
"throw",
"new",
"MongoException",
"(",
"\"Value '$name' cannot be used as an array\"",
")",
";",
"if",
"(",
"$",
"last",
")",
"array_pop",
"(",
"$",
"ref",
")",
";",
"else",
"array_shift",
"(",
"$",
"ref",
")",
";",
"return",
"$",
"this",
";",
"}",
"}"
] |
Pop a value from the end of an array
@param string $name The key of the data to update (use dot notation for embedded objects)
@param boolean $last Pass TRUE to pop last element
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload. @see $_emulate
@return Mongo_Document
|
[
"Pop",
"a",
"value",
"from",
"the",
"end",
"of",
"an",
"array"
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L924-L941
|
221,298
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.addToSet
|
public function addToSet($name, $value, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$addToSet'][$name]))
{
if( ! isset($this->_operations['$addToSet'][$name]['$each']))
{
$this->_operations['$addToSet'][$name] = array('$each' => array($this->_operations['$addToSet'][$name]));
}
if(isset($value['$each']))
{
foreach($value['$each'] as $val)
{
$this->_operations['$addToSet'][$name]['$each'][] = $val;
}
}
else
{
$this->_operations['$addToSet'][$name]['$each'][] = $value;
}
}
else
{
$this->_operations['$addToSet'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE);
if ($ref === null)
{
$ref = array($value);
}
else
{
if (!is_array($ref)) throw new Exception("Value '$name' cannot be set as an array"); // $ref = array($ref);
if (!in_array($value, $ref, TRUE))
{
array_push($ref, $value);
}
}
return $this;
}
}
|
php
|
public function addToSet($name, $value, $emulate = null)
{
$name = $this->get_field_name($name);
if(isset($this->_operations['$addToSet'][$name]))
{
if( ! isset($this->_operations['$addToSet'][$name]['$each']))
{
$this->_operations['$addToSet'][$name] = array('$each' => array($this->_operations['$addToSet'][$name]));
}
if(isset($value['$each']))
{
foreach($value['$each'] as $val)
{
$this->_operations['$addToSet'][$name]['$each'][] = $val;
}
}
else
{
$this->_operations['$addToSet'][$name]['$each'][] = $value;
}
}
else
{
$this->_operations['$addToSet'][$name] = $value;
}
if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
{
return $this->_set_dirty($name);
}
else
{
$ref = & $this->get_field_reference($name, TRUE);
if ($ref === null)
{
$ref = array($value);
}
else
{
if (!is_array($ref)) throw new Exception("Value '$name' cannot be set as an array"); // $ref = array($ref);
if (!in_array($value, $ref, TRUE))
{
array_push($ref, $value);
}
}
return $this;
}
}
|
[
"public",
"function",
"addToSet",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"emulate",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
"[",
"'$each'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'$each'",
"=>",
"array",
"(",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"'$each'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"[",
"'$each'",
"]",
"as",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
"[",
"'$each'",
"]",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
"[",
"'$each'",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_operations",
"[",
"'$addToSet'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"emulate",
"===",
"FALSE",
"||",
"(",
"$",
"emulate",
"===",
"null",
"&&",
"$",
"this",
"->",
"_emulate",
"===",
"FALSE",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_set_dirty",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"&",
"$",
"this",
"->",
"get_field_reference",
"(",
"$",
"name",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"ref",
"===",
"null",
")",
"{",
"$",
"ref",
"=",
"array",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ref",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Value '$name' cannot be set as an array\"",
")",
";",
"// $ref = array($ref);",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"ref",
",",
"TRUE",
")",
")",
"{",
"array_push",
"(",
"$",
"ref",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}",
"}"
] |
Adds value to the array only if its not in the array already.
@param string $name The key of the data to update (use dot notation for embedded objects)
@param mixed $value The value to add to the set
@param boolean $emulate TRUE will emulate the database function for eventual consistency, FALSE will not change the object until save & reload. @see $_emulate
@return Mongo_Document
|
[
"Adds",
"value",
"to",
"the",
"array",
"only",
"if",
"its",
"not",
"in",
"the",
"array",
"already",
"."
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L1055-L1101
|
221,299
|
colinmollenhour/mongodb-php-odm
|
classes/mongo/document.php
|
Mongo_Document.load_values
|
public function load_values(array $values, $clean = FALSE)
{
if($clean === TRUE)
{
$this->before_load();
$this->_object = $values;
$this->_loaded = ! empty($this->_object);
$this->after_load();
}
else
{
foreach ($values as $field => $value)
{
$this->__set($field, $value);
}
}
return $this;
}
|
php
|
public function load_values(array $values, $clean = FALSE)
{
if($clean === TRUE)
{
$this->before_load();
$this->_object = $values;
$this->_loaded = ! empty($this->_object);
$this->after_load();
}
else
{
foreach ($values as $field => $value)
{
$this->__set($field, $value);
}
}
return $this;
}
|
[
"public",
"function",
"load_values",
"(",
"array",
"$",
"values",
",",
"$",
"clean",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"clean",
"===",
"TRUE",
")",
"{",
"$",
"this",
"->",
"before_load",
"(",
")",
";",
"$",
"this",
"->",
"_object",
"=",
"$",
"values",
";",
"$",
"this",
"->",
"_loaded",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"_object",
")",
";",
"$",
"this",
"->",
"after_load",
"(",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"__set",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Load all of the values in an associative array. Ignores all fields
not in the model.
@param array $values field => value pairs
@param boolean $clean values are clean (from database)?
@return Mongo_Document
|
[
"Load",
"all",
"of",
"the",
"values",
"in",
"an",
"associative",
"array",
".",
"Ignores",
"all",
"fields",
"not",
"in",
"the",
"model",
"."
] |
640ce82c0ab00765168addec1bf0b996bdb4e4d1
|
https://github.com/colinmollenhour/mongodb-php-odm/blob/640ce82c0ab00765168addec1bf0b996bdb4e4d1/classes/mongo/document.php#L1111-L1131
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.