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
|
---|---|---|---|---|---|---|---|---|---|---|---|
21,500 |
nabab/bbn
|
src/bbn/util/timer.php
|
timer.has_started
|
public function has_started($key)
{
if ( isset($this->measures[$key]) ){
return $this->measures[$key]['start'] > 0;
}
return false;
}
|
php
|
public function has_started($key)
{
if ( isset($this->measures[$key]) ){
return $this->measures[$key]['start'] > 0;
}
return false;
}
|
[
"public",
"function",
"has_started",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
">",
"0",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns true is the timer has started for the given key
@return bool
|
[
"Returns",
"true",
"is",
"the",
"timer",
"has",
"started",
"for",
"the",
"given",
"key"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/timer.php#L53-L59
|
21,501 |
nabab/bbn
|
src/bbn/util/timer.php
|
timer.stop
|
public function stop($key='default')
{
if ( isset($this->measures[$key], $this->measures[$key]['start']) ){
$this->measures[$key]['num']++;
$time = $this->measure($key);
$this->measures[$key]['sum'] += $time;
unset($this->measures[$key]['start']);
return $time;
}
else{
die("Missing a start declaration for timer $key");
}
}
|
php
|
public function stop($key='default')
{
if ( isset($this->measures[$key], $this->measures[$key]['start']) ){
$this->measures[$key]['num']++;
$time = $this->measure($key);
$this->measures[$key]['sum'] += $time;
unset($this->measures[$key]['start']);
return $time;
}
else{
die("Missing a start declaration for timer $key");
}
}
|
[
"public",
"function",
"stop",
"(",
"$",
"key",
"=",
"'default'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
",",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'num'",
"]",
"++",
";",
"$",
"time",
"=",
"$",
"this",
"->",
"measure",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'sum'",
"]",
"+=",
"$",
"time",
";",
"unset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
")",
";",
"return",
"$",
"time",
";",
"}",
"else",
"{",
"die",
"(",
"\"Missing a start declaration for timer $key\"",
")",
";",
"}",
"}"
] |
Stops a timer for a given key
@return int
|
[
"Stops",
"a",
"timer",
"for",
"a",
"given",
"key"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/timer.php#L67-L79
|
21,502 |
interactivesolutions/honeycomb-core
|
src/models/traits/CustomAppends.php
|
CustomAppends.getArrayAbleAppends
|
protected function getArrayAbleAppends()
{
if (property_exists($this, 'customAppends')) {
// you can set custom appends array
if (is_array(self::$customAppends) && count(self::$customAppends))
return self::$customAppends;
// or if you want to disable custom appends just write false i.e. Model::$customAppends = false;
elseif (is_bool(self::$customAppends) && !self::$customAppends)
return [];
}
return parent::getArrayAbleAppends();
}
|
php
|
protected function getArrayAbleAppends()
{
if (property_exists($this, 'customAppends')) {
// you can set custom appends array
if (is_array(self::$customAppends) && count(self::$customAppends))
return self::$customAppends;
// or if you want to disable custom appends just write false i.e. Model::$customAppends = false;
elseif (is_bool(self::$customAppends) && !self::$customAppends)
return [];
}
return parent::getArrayAbleAppends();
}
|
[
"protected",
"function",
"getArrayAbleAppends",
"(",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'customAppends'",
")",
")",
"{",
"// you can set custom appends array",
"if",
"(",
"is_array",
"(",
"self",
"::",
"$",
"customAppends",
")",
"&&",
"count",
"(",
"self",
"::",
"$",
"customAppends",
")",
")",
"return",
"self",
"::",
"$",
"customAppends",
";",
"// or if you want to disable custom appends just write false i.e. Model::$customAppends = false;",
"elseif",
"(",
"is_bool",
"(",
"self",
"::",
"$",
"customAppends",
")",
"&&",
"!",
"self",
"::",
"$",
"customAppends",
")",
"return",
"[",
"]",
";",
"}",
"return",
"parent",
"::",
"getArrayAbleAppends",
"(",
")",
";",
"}"
] |
Append attribute ignore
@return array
|
[
"Append",
"attribute",
"ignore"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/traits/CustomAppends.php#L19-L33
|
21,503 |
nabab/bbn
|
src/bbn/appui/masks.php
|
masks.get
|
public function get(string $id): ?array
{
$mask = $this->db->rselect('bbn_notes_masks', [], ['id_note' => $id]);
if ( $data = $this->notes->get($mask['id_note']) ){
$data['default'] = $mask['def'];
$data['id_type'] = $mask['id_type'];
$data['type'] = $this->o->text($mask['id_type']);
$data['name'] = $mask['name'];
return $data;
}
return null;
}
|
php
|
public function get(string $id): ?array
{
$mask = $this->db->rselect('bbn_notes_masks', [], ['id_note' => $id]);
if ( $data = $this->notes->get($mask['id_note']) ){
$data['default'] = $mask['def'];
$data['id_type'] = $mask['id_type'];
$data['type'] = $this->o->text($mask['id_type']);
$data['name'] = $mask['name'];
return $data;
}
return null;
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"id",
")",
":",
"?",
"array",
"{",
"$",
"mask",
"=",
"$",
"this",
"->",
"db",
"->",
"rselect",
"(",
"'bbn_notes_masks'",
",",
"[",
"]",
",",
"[",
"'id_note'",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"$",
"data",
"=",
"$",
"this",
"->",
"notes",
"->",
"get",
"(",
"$",
"mask",
"[",
"'id_note'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'default'",
"]",
"=",
"$",
"mask",
"[",
"'def'",
"]",
";",
"$",
"data",
"[",
"'id_type'",
"]",
"=",
"$",
"mask",
"[",
"'id_type'",
"]",
";",
"$",
"data",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"o",
"->",
"text",
"(",
"$",
"mask",
"[",
"'id_type'",
"]",
")",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"mask",
"[",
"'name'",
"]",
";",
"return",
"$",
"data",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the content of a mask based on the provided ID
@param string $id
@return array|null
|
[
"Gets",
"the",
"content",
"of",
"a",
"mask",
"based",
"on",
"the",
"provided",
"ID"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/masks.php#L42-L53
|
21,504 |
Laralum/Events
|
src/Controllers/EventController.php
|
EventController.getDatetime
|
private function getDatetime($datein, $timein)
{
$date = explode('-', $datein);
$time = explode(':', $timein);
$datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $datetime;
}
|
php
|
private function getDatetime($datein, $timein)
{
$date = explode('-', $datein);
$time = explode(':', $timein);
$datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $datetime;
}
|
[
"private",
"function",
"getDatetime",
"(",
"$",
"datein",
",",
"$",
"timein",
")",
"{",
"$",
"date",
"=",
"explode",
"(",
"'-'",
",",
"$",
"datein",
")",
";",
"$",
"time",
"=",
"explode",
"(",
"':'",
",",
"$",
"timein",
")",
";",
"$",
"datetime",
"=",
"Carbon",
"::",
"create",
"(",
"$",
"date",
"[",
"0",
"]",
",",
"$",
"date",
"[",
"1",
"]",
",",
"$",
"date",
"[",
"2",
"]",
",",
"$",
"time",
"[",
"0",
"]",
",",
"$",
"time",
"[",
"1",
"]",
")",
";",
"return",
"$",
"datetime",
";",
"}"
] |
Get Carbon start datetime and end datemime.
@param mixed $object
@return array
|
[
"Get",
"Carbon",
"start",
"datetime",
"and",
"end",
"datemime",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L48-L55
|
21,505 |
Laralum/Events
|
src/Controllers/EventController.php
|
EventController.confirmDestroy
|
public function confirmDestroy(Request $request, Event $event)
{
$this->authorize('delete', $event);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'message' => __('laralum_events::general.sure_del_event', ['event' => $event->title]),
'action' => route('laralum::events.destroy', ['event' => $event->id]),
]);
}
|
php
|
public function confirmDestroy(Request $request, Event $event)
{
$this->authorize('delete', $event);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'message' => __('laralum_events::general.sure_del_event', ['event' => $event->title]),
'action' => route('laralum::events.destroy', ['event' => $event->id]),
]);
}
|
[
"public",
"function",
"confirmDestroy",
"(",
"Request",
"$",
"request",
",",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"event",
")",
";",
"return",
"view",
"(",
"'laralum::pages.confirmation'",
",",
"[",
"'method'",
"=>",
"'DELETE'",
",",
"'message'",
"=>",
"__",
"(",
"'laralum_events::general.sure_del_event'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"title",
"]",
")",
",",
"'action'",
"=>",
"route",
"(",
"'laralum::events.destroy'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
",",
"]",
")",
";",
"}"
] |
confirm destroy of the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response
|
[
"confirm",
"destroy",
"of",
"the",
"specified",
"resource",
"from",
"storage",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L221-L230
|
21,506 |
Laralum/Events
|
src/Controllers/EventController.php
|
EventController.join
|
public function join(Event $event)
{
$this->authorize('join', Event::class);
$event->addUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.joined_event', ['id' => $event->id]));
}
|
php
|
public function join(Event $event)
{
$this->authorize('join', Event::class);
$event->addUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.joined_event', ['id' => $event->id]));
}
|
[
"public",
"function",
"join",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'join'",
",",
"Event",
"::",
"class",
")",
";",
"$",
"event",
"->",
"addUser",
"(",
"User",
"::",
"findOrfail",
"(",
"Auth",
"::",
"id",
"(",
")",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.joined_event'",
",",
"[",
"'id'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
")",
";",
"}"
] |
Join to the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response
|
[
"Join",
"to",
"the",
"specified",
"resource",
"from",
"storage",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L256-L263
|
21,507 |
Laralum/Events
|
src/Controllers/EventController.php
|
EventController.leave
|
public function leave(Event $event)
{
$this->authorize('join', Event::class);
$event->deleteUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.left_event', ['id' => $event->id]));
}
|
php
|
public function leave(Event $event)
{
$this->authorize('join', Event::class);
$event->deleteUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.left_event', ['id' => $event->id]));
}
|
[
"public",
"function",
"leave",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'join'",
",",
"Event",
"::",
"class",
")",
";",
"$",
"event",
"->",
"deleteUser",
"(",
"User",
"::",
"findOrfail",
"(",
"Auth",
"::",
"id",
"(",
")",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.left_event'",
",",
"[",
"'id'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
")",
";",
"}"
] |
Leave from the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response
|
[
"Leave",
"from",
"the",
"specified",
"resource",
"from",
"storage",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L272-L279
|
21,508 |
Laralum/Events
|
src/Controllers/EventController.php
|
EventController.makeResponsible
|
public function makeResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->addResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_added', ['event_id' => $event->id, 'user_id' => $user->id]));
}
|
php
|
public function makeResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->addResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_added', ['event_id' => $event->id, 'user_id' => $user->id]));
}
|
[
"public",
"function",
"makeResponsible",
"(",
"Event",
"$",
"event",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"event",
")",
";",
"$",
"event",
"->",
"addResponsible",
"(",
"$",
"user",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.show'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.responsible_added'",
",",
"[",
"'event_id'",
"=>",
"$",
"event",
"->",
"id",
",",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
")",
";",
"}"
] |
Make author of to the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@param \Laralum\Users\Models\User $user
@return \Illuminate\Http\Response
|
[
"Make",
"author",
"of",
"to",
"the",
"specified",
"resource",
"from",
"storage",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L289-L296
|
21,509 |
Laralum/Events
|
src/Controllers/EventController.php
|
EventController.undoResponsible
|
public function undoResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->deleteResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_deleted', ['event_id' => $event->id, 'user_id' => $user->id]));
}
|
php
|
public function undoResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->deleteResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_deleted', ['event_id' => $event->id, 'user_id' => $user->id]));
}
|
[
"public",
"function",
"undoResponsible",
"(",
"Event",
"$",
"event",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"event",
")",
";",
"$",
"event",
"->",
"deleteResponsible",
"(",
"$",
"user",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.show'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.responsible_deleted'",
",",
"[",
"'event_id'",
"=>",
"$",
"event",
"->",
"id",
",",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
")",
";",
"}"
] |
Undo author from the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@param \Laralum\Users\Models\User $user
@return \Illuminate\Http\Response
|
[
"Undo",
"author",
"from",
"the",
"specified",
"resource",
"from",
"storage",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L306-L313
|
21,510 |
jasny/codeception-module
|
src/RequestConvertor.php
|
RequestConvertor.createStream
|
protected function createStream(BrowserKitRequest $request)
{
$stream = fopen('php://temp', 'a+');
fwrite($stream, $request->getContent());
return new Stream($stream);
}
|
php
|
protected function createStream(BrowserKitRequest $request)
{
$stream = fopen('php://temp', 'a+');
fwrite($stream, $request->getContent());
return new Stream($stream);
}
|
[
"protected",
"function",
"createStream",
"(",
"BrowserKitRequest",
"$",
"request",
")",
"{",
"$",
"stream",
"=",
"fopen",
"(",
"'php://temp'",
",",
"'a+'",
")",
";",
"fwrite",
"(",
"$",
"stream",
",",
"$",
"request",
"->",
"getContent",
"(",
")",
")",
";",
"return",
"new",
"Stream",
"(",
"$",
"stream",
")",
";",
"}"
] |
Create the output stream handle
@param BrowserKitRequest $request
@return Stream
|
[
"Create",
"the",
"output",
"stream",
"handle"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/RequestConvertor.php#L25-L31
|
21,511 |
jasny/codeception-module
|
src/RequestConvertor.php
|
RequestConvertor.buildFullUri
|
protected function buildFullUri(BrowserKitRequest $request)
{
$uri = new Uri($request->getUri());
$queryParams = [];
parse_str($uri->getQuery(), $queryParams);
if ($request->getMethod() === 'GET') {
$queryParams = array_merge($queryParams, $request->getParameters());
$uri = $uri->withQuery(http_build_query($queryParams));
}
return [$uri, $queryParams];
}
|
php
|
protected function buildFullUri(BrowserKitRequest $request)
{
$uri = new Uri($request->getUri());
$queryParams = [];
parse_str($uri->getQuery(), $queryParams);
if ($request->getMethod() === 'GET') {
$queryParams = array_merge($queryParams, $request->getParameters());
$uri = $uri->withQuery(http_build_query($queryParams));
}
return [$uri, $queryParams];
}
|
[
"protected",
"function",
"buildFullUri",
"(",
"BrowserKitRequest",
"$",
"request",
")",
"{",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"request",
"->",
"getUri",
"(",
")",
")",
";",
"$",
"queryParams",
"=",
"[",
"]",
";",
"parse_str",
"(",
"$",
"uri",
"->",
"getQuery",
"(",
")",
",",
"$",
"queryParams",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"===",
"'GET'",
")",
"{",
"$",
"queryParams",
"=",
"array_merge",
"(",
"$",
"queryParams",
",",
"$",
"request",
"->",
"getParameters",
"(",
")",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"http_build_query",
"(",
"$",
"queryParams",
")",
")",
";",
"}",
"return",
"[",
"$",
"uri",
",",
"$",
"queryParams",
"]",
";",
"}"
] |
Build a full URI from a request
@param BrowserKitRequest $request
@return array [Uri, queryParams]
|
[
"Build",
"a",
"full",
"URI",
"from",
"a",
"request"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/RequestConvertor.php#L39-L52
|
21,512 |
jasny/codeception-module
|
src/RequestConvertor.php
|
RequestConvertor.setRequestHeaders
|
protected function setRequestHeaders(ServerRequestInterface $baseRequest, array $params)
{
$headers = (new ServerRequest())->withServerParams($params)->getHeaders();
$psrRequest = $baseRequest;
foreach ($headers as $header => $values) {
$psrRequest = $psrRequest->withHeader($header, $values);
}
return $psrRequest;
}
|
php
|
protected function setRequestHeaders(ServerRequestInterface $baseRequest, array $params)
{
$headers = (new ServerRequest())->withServerParams($params)->getHeaders();
$psrRequest = $baseRequest;
foreach ($headers as $header => $values) {
$psrRequest = $psrRequest->withHeader($header, $values);
}
return $psrRequest;
}
|
[
"protected",
"function",
"setRequestHeaders",
"(",
"ServerRequestInterface",
"$",
"baseRequest",
",",
"array",
"$",
"params",
")",
"{",
"$",
"headers",
"=",
"(",
"new",
"ServerRequest",
"(",
")",
")",
"->",
"withServerParams",
"(",
"$",
"params",
")",
"->",
"getHeaders",
"(",
")",
";",
"$",
"psrRequest",
"=",
"$",
"baseRequest",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
"=>",
"$",
"values",
")",
"{",
"$",
"psrRequest",
"=",
"$",
"psrRequest",
"->",
"withHeader",
"(",
"$",
"header",
",",
"$",
"values",
")",
";",
"}",
"return",
"$",
"psrRequest",
";",
"}"
] |
Set the request headers
@param ServerRequestInterface $baseRequest
@param array $params
@retrun ServerRequestInterface
|
[
"Set",
"the",
"request",
"headers"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/RequestConvertor.php#L61-L71
|
21,513 |
jasny/codeception-module
|
src/RequestConvertor.php
|
RequestConvertor.setRequestProperties
|
protected function setRequestProperties(
ServerRequestInterface $baseRequest,
BrowserKitRequest $request,
Stream $stream,
UriInterface $uri,
array $queryParams
) {
return $baseRequest
->withProtocolVersion('1.1')
->withBody($stream)
->withMethod($request->getMethod())
->withRequestTarget((string)($uri->withScheme('')->withHost('')->withPort('')->withUserInfo('')))
->withCookieParams($request->getCookies())
->withUri($uri)
->withQueryParams($queryParams)
->withParsedBody($request->getMethod() !== 'GET' && !empty($request->getParameters())
? $request->getParameters() : null)
->withUploadedFiles($this->convertUploadedFiles($request->getFiles()));
}
|
php
|
protected function setRequestProperties(
ServerRequestInterface $baseRequest,
BrowserKitRequest $request,
Stream $stream,
UriInterface $uri,
array $queryParams
) {
return $baseRequest
->withProtocolVersion('1.1')
->withBody($stream)
->withMethod($request->getMethod())
->withRequestTarget((string)($uri->withScheme('')->withHost('')->withPort('')->withUserInfo('')))
->withCookieParams($request->getCookies())
->withUri($uri)
->withQueryParams($queryParams)
->withParsedBody($request->getMethod() !== 'GET' && !empty($request->getParameters())
? $request->getParameters() : null)
->withUploadedFiles($this->convertUploadedFiles($request->getFiles()));
}
|
[
"protected",
"function",
"setRequestProperties",
"(",
"ServerRequestInterface",
"$",
"baseRequest",
",",
"BrowserKitRequest",
"$",
"request",
",",
"Stream",
"$",
"stream",
",",
"UriInterface",
"$",
"uri",
",",
"array",
"$",
"queryParams",
")",
"{",
"return",
"$",
"baseRequest",
"->",
"withProtocolVersion",
"(",
"'1.1'",
")",
"->",
"withBody",
"(",
"$",
"stream",
")",
"->",
"withMethod",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
")",
"->",
"withRequestTarget",
"(",
"(",
"string",
")",
"(",
"$",
"uri",
"->",
"withScheme",
"(",
"''",
")",
"->",
"withHost",
"(",
"''",
")",
"->",
"withPort",
"(",
"''",
")",
"->",
"withUserInfo",
"(",
"''",
")",
")",
")",
"->",
"withCookieParams",
"(",
"$",
"request",
"->",
"getCookies",
"(",
")",
")",
"->",
"withUri",
"(",
"$",
"uri",
")",
"->",
"withQueryParams",
"(",
"$",
"queryParams",
")",
"->",
"withParsedBody",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"!==",
"'GET'",
"&&",
"!",
"empty",
"(",
"$",
"request",
"->",
"getParameters",
"(",
")",
")",
"?",
"$",
"request",
"->",
"getParameters",
"(",
")",
":",
"null",
")",
"->",
"withUploadedFiles",
"(",
"$",
"this",
"->",
"convertUploadedFiles",
"(",
"$",
"request",
"->",
"getFiles",
"(",
")",
")",
")",
";",
"}"
] |
Set the server request properties
@param ServerRequestInterface $baseRequest
@param BrowserKitRequest $request
@param Stream $stream
@param UriInterface $uri
@param array $queryParams
@return ServerRequestInterface
|
[
"Set",
"the",
"server",
"request",
"properties"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/RequestConvertor.php#L101-L119
|
21,514 |
jasny/codeception-module
|
src/RequestConvertor.php
|
RequestConvertor.convertUploadedFiles
|
protected function convertUploadedFiles(array $files)
{
$fileObjects = [];
foreach ($files as $fieldName => $file) {
if ($file instanceof UploadedFileInterface) {
$fileObjects[$fieldName] = $file;
} elseif (!isset($file['tmp_name']) && !isset($file['error'])) {
$fileObjects[$fieldName] = $this->convertUploadedFiles($file);
} else {
$fileObjects[$fieldName] = new UploadedFile($file);
}
}
return $fileObjects;
}
|
php
|
protected function convertUploadedFiles(array $files)
{
$fileObjects = [];
foreach ($files as $fieldName => $file) {
if ($file instanceof UploadedFileInterface) {
$fileObjects[$fieldName] = $file;
} elseif (!isset($file['tmp_name']) && !isset($file['error'])) {
$fileObjects[$fieldName] = $this->convertUploadedFiles($file);
} else {
$fileObjects[$fieldName] = new UploadedFile($file);
}
}
return $fileObjects;
}
|
[
"protected",
"function",
"convertUploadedFiles",
"(",
"array",
"$",
"files",
")",
"{",
"$",
"fileObjects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"fieldName",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"instanceof",
"UploadedFileInterface",
")",
"{",
"$",
"fileObjects",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"file",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"file",
"[",
"'tmp_name'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"file",
"[",
"'error'",
"]",
")",
")",
"{",
"$",
"fileObjects",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"convertUploadedFiles",
"(",
"$",
"file",
")",
";",
"}",
"else",
"{",
"$",
"fileObjects",
"[",
"$",
"fieldName",
"]",
"=",
"new",
"UploadedFile",
"(",
"$",
"file",
")",
";",
"}",
"}",
"return",
"$",
"fileObjects",
";",
"}"
] |
Convert a list of uploaded files to a Jasny PSR-7 uploaded files
@param array $files
@return UploadedFile[]|array
|
[
"Convert",
"a",
"list",
"of",
"uploaded",
"files",
"to",
"a",
"Jasny",
"PSR",
"-",
"7",
"uploaded",
"files"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/RequestConvertor.php#L127-L142
|
21,515 |
jasny/codeception-module
|
src/RequestConvertor.php
|
RequestConvertor.convert
|
public function convert(BrowserKitRequest $request, ServerRequestInterface $baseRequest)
{
$stream = $this->createStream($request);
list($uri, $queryParams) = $this->buildFullUri($request);
if ($baseRequest instanceof ServerRequest) {
$serverParams = $this->determineServerParams($request, $uri, (array)$queryParams);
$psrRequest = $baseRequest->withServerParams($request->getServer() + $serverParams);
} else {
$psrRequest = $this->setRequestHeaders($baseRequest, $request->getServer());
}
return $this->setRequestProperties($psrRequest, $request, $stream, $uri, (array)$queryParams);
}
|
php
|
public function convert(BrowserKitRequest $request, ServerRequestInterface $baseRequest)
{
$stream = $this->createStream($request);
list($uri, $queryParams) = $this->buildFullUri($request);
if ($baseRequest instanceof ServerRequest) {
$serverParams = $this->determineServerParams($request, $uri, (array)$queryParams);
$psrRequest = $baseRequest->withServerParams($request->getServer() + $serverParams);
} else {
$psrRequest = $this->setRequestHeaders($baseRequest, $request->getServer());
}
return $this->setRequestProperties($psrRequest, $request, $stream, $uri, (array)$queryParams);
}
|
[
"public",
"function",
"convert",
"(",
"BrowserKitRequest",
"$",
"request",
",",
"ServerRequestInterface",
"$",
"baseRequest",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"createStream",
"(",
"$",
"request",
")",
";",
"list",
"(",
"$",
"uri",
",",
"$",
"queryParams",
")",
"=",
"$",
"this",
"->",
"buildFullUri",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"baseRequest",
"instanceof",
"ServerRequest",
")",
"{",
"$",
"serverParams",
"=",
"$",
"this",
"->",
"determineServerParams",
"(",
"$",
"request",
",",
"$",
"uri",
",",
"(",
"array",
")",
"$",
"queryParams",
")",
";",
"$",
"psrRequest",
"=",
"$",
"baseRequest",
"->",
"withServerParams",
"(",
"$",
"request",
"->",
"getServer",
"(",
")",
"+",
"$",
"serverParams",
")",
";",
"}",
"else",
"{",
"$",
"psrRequest",
"=",
"$",
"this",
"->",
"setRequestHeaders",
"(",
"$",
"baseRequest",
",",
"$",
"request",
"->",
"getServer",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setRequestProperties",
"(",
"$",
"psrRequest",
",",
"$",
"request",
",",
"$",
"stream",
",",
"$",
"uri",
",",
"(",
"array",
")",
"$",
"queryParams",
")",
";",
"}"
] |
Convert a codeception request to a PSR-7 server request
@param BrowserKitRequest $request
@param ServerRequestInterface $baseRequest
@return ServerRequest
|
[
"Convert",
"a",
"codeception",
"request",
"to",
"a",
"PSR",
"-",
"7",
"server",
"request"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/RequestConvertor.php#L152-L165
|
21,516 |
inhere/php-librarys
|
src/Helpers/PhpException.php
|
PhpException.toArray
|
public static function toArray($e, $getTrace = true, $catcher = null)
{
$data = [
'class' => \get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile() . ':' . $e->getLine(),
];
if ($catcher) {
$data['catcher'] = $catcher;
}
if ($getTrace) {
$data['trace'] = $e->getTrace();
}
return $data;
}
|
php
|
public static function toArray($e, $getTrace = true, $catcher = null)
{
$data = [
'class' => \get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile() . ':' . $e->getLine(),
];
if ($catcher) {
$data['catcher'] = $catcher;
}
if ($getTrace) {
$data['trace'] = $e->getTrace();
}
return $data;
}
|
[
"public",
"static",
"function",
"toArray",
"(",
"$",
"e",
",",
"$",
"getTrace",
"=",
"true",
",",
"$",
"catcher",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"'class'",
"=>",
"\\",
"get_class",
"(",
"$",
"e",
")",
",",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"'file'",
"=>",
"$",
"e",
"->",
"getFile",
"(",
")",
".",
"':'",
".",
"$",
"e",
"->",
"getLine",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"catcher",
")",
"{",
"$",
"data",
"[",
"'catcher'",
"]",
"=",
"$",
"catcher",
";",
"}",
"if",
"(",
"$",
"getTrace",
")",
"{",
"$",
"data",
"[",
"'trace'",
"]",
"=",
"$",
"e",
"->",
"getTrace",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Converts an exception into a simple array.
@param \Exception|\Throwable $e the exception being converted
@param bool $getTrace
@param null|string $catcher
@return array
|
[
"Converts",
"an",
"exception",
"into",
"a",
"simple",
"array",
"."
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/PhpException.php#L61-L79
|
21,517 |
blesta/composer-installer
|
src/Installer.php
|
Installer.supportedType
|
protected function supportedType($type)
{
$supportedType = false;
$baseType = substr($type, 0, strpos($type, '-'));
if (array_key_exists($baseType, $this->supportedTypes)) {
$supportedType = $baseType;
}
return $supportedType;
}
|
php
|
protected function supportedType($type)
{
$supportedType = false;
$baseType = substr($type, 0, strpos($type, '-'));
if (array_key_exists($baseType, $this->supportedTypes)) {
$supportedType = $baseType;
}
return $supportedType;
}
|
[
"protected",
"function",
"supportedType",
"(",
"$",
"type",
")",
"{",
"$",
"supportedType",
"=",
"false",
";",
"$",
"baseType",
"=",
"substr",
"(",
"$",
"type",
",",
"0",
",",
"strpos",
"(",
"$",
"type",
",",
"'-'",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"baseType",
",",
"$",
"this",
"->",
"supportedTypes",
")",
")",
"{",
"$",
"supportedType",
"=",
"$",
"baseType",
";",
"}",
"return",
"$",
"supportedType",
";",
"}"
] |
Find the matching installer type
@param string $type
@return boolean|string
|
[
"Find",
"the",
"matching",
"installer",
"type"
] |
11672a7cbe9c74a6d5bc602ce8148ae92781ba2e
|
https://github.com/blesta/composer-installer/blob/11672a7cbe9c74a6d5bc602ce8148ae92781ba2e/src/Installer.php#L89-L100
|
21,518 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.dbConnect
|
protected function dbConnect(array $aOptions)
{
$aOptions = array_merge(SudoBible::DB_CREDS, $aOptions);
try {
$this->db = new mysqli(
$aOptions['db_host'],
$aOptions['db_user'],
$aOptions['db_pass'],
$aOptions['db_name'],
$aOptions['db_port']
);
} catch (Exception $e) {
// Clean up the error message
throw new Exception(__METHOD__ . ': DB connection failed.');
}
}
|
php
|
protected function dbConnect(array $aOptions)
{
$aOptions = array_merge(SudoBible::DB_CREDS, $aOptions);
try {
$this->db = new mysqli(
$aOptions['db_host'],
$aOptions['db_user'],
$aOptions['db_pass'],
$aOptions['db_name'],
$aOptions['db_port']
);
} catch (Exception $e) {
// Clean up the error message
throw new Exception(__METHOD__ . ': DB connection failed.');
}
}
|
[
"protected",
"function",
"dbConnect",
"(",
"array",
"$",
"aOptions",
")",
"{",
"$",
"aOptions",
"=",
"array_merge",
"(",
"SudoBible",
"::",
"DB_CREDS",
",",
"$",
"aOptions",
")",
";",
"try",
"{",
"$",
"this",
"->",
"db",
"=",
"new",
"mysqli",
"(",
"$",
"aOptions",
"[",
"'db_host'",
"]",
",",
"$",
"aOptions",
"[",
"'db_user'",
"]",
",",
"$",
"aOptions",
"[",
"'db_pass'",
"]",
",",
"$",
"aOptions",
"[",
"'db_name'",
"]",
",",
"$",
"aOptions",
"[",
"'db_port'",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Clean up the error message",
"throw",
"new",
"Exception",
"(",
"__METHOD__",
".",
"': DB connection failed.'",
")",
";",
"}",
"}"
] |
Connect to the DB.
@param array $aOptions
@throws Exception
|
[
"Connect",
"to",
"the",
"DB",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L65-L80
|
21,519 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.setTranslation
|
public function setTranslation($mTranslation)
{
$this->iTranslation = is_numeric($mTranslation)
? $mTranslation : $this->getIdFor('translation', $mTranslation);
}
|
php
|
public function setTranslation($mTranslation)
{
$this->iTranslation = is_numeric($mTranslation)
? $mTranslation : $this->getIdFor('translation', $mTranslation);
}
|
[
"public",
"function",
"setTranslation",
"(",
"$",
"mTranslation",
")",
"{",
"$",
"this",
"->",
"iTranslation",
"=",
"is_numeric",
"(",
"$",
"mTranslation",
")",
"?",
"$",
"mTranslation",
":",
"$",
"this",
"->",
"getIdFor",
"(",
"'translation'",
",",
"$",
"mTranslation",
")",
";",
"}"
] |
Set the translation preference.
@param int|string $mTranslation
|
[
"Set",
"the",
"translation",
"preference",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L87-L91
|
21,520 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.queryFiles
|
protected function queryFiles($strAction)
{
if (!in_array($strAction, ['create', 'insert', 'drop']))
throw new Exception('Invalid parameter "' . $strAction . '" sent to SudoBible::queryFiles()');
$strPath = 'queries/' . $this->dbType . '/' . $strAction;
foreach (scandir($strPath) as $strFilename) {
// Only run SQL files (eliminates ., .., and subdirs)
// Using in_array() in case DBs other than SQL are supported in the future.
if (in_array(substr($strFilename, -4), ['.sql'])) {
$mResult = $this->db->query(file_get_contents($strPath . '/' . $strFilename));
// Check success if creating or dropping
if ('insert' !== $strAction && true !== $mResult) {
throw new Exception('Unable to ' . $strAction . ' table in ' . $strFilename
. ' - please ensure your DB user has the right permissions.');
}
}
}
}
|
php
|
protected function queryFiles($strAction)
{
if (!in_array($strAction, ['create', 'insert', 'drop']))
throw new Exception('Invalid parameter "' . $strAction . '" sent to SudoBible::queryFiles()');
$strPath = 'queries/' . $this->dbType . '/' . $strAction;
foreach (scandir($strPath) as $strFilename) {
// Only run SQL files (eliminates ., .., and subdirs)
// Using in_array() in case DBs other than SQL are supported in the future.
if (in_array(substr($strFilename, -4), ['.sql'])) {
$mResult = $this->db->query(file_get_contents($strPath . '/' . $strFilename));
// Check success if creating or dropping
if ('insert' !== $strAction && true !== $mResult) {
throw new Exception('Unable to ' . $strAction . ' table in ' . $strFilename
. ' - please ensure your DB user has the right permissions.');
}
}
}
}
|
[
"protected",
"function",
"queryFiles",
"(",
"$",
"strAction",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"strAction",
",",
"[",
"'create'",
",",
"'insert'",
",",
"'drop'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Invalid parameter \"'",
".",
"$",
"strAction",
".",
"'\" sent to SudoBible::queryFiles()'",
")",
";",
"$",
"strPath",
"=",
"'queries/'",
".",
"$",
"this",
"->",
"dbType",
".",
"'/'",
".",
"$",
"strAction",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"strPath",
")",
"as",
"$",
"strFilename",
")",
"{",
"// Only run SQL files (eliminates ., .., and subdirs)",
"// Using in_array() in case DBs other than SQL are supported in the future.",
"if",
"(",
"in_array",
"(",
"substr",
"(",
"$",
"strFilename",
",",
"-",
"4",
")",
",",
"[",
"'.sql'",
"]",
")",
")",
"{",
"$",
"mResult",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"file_get_contents",
"(",
"$",
"strPath",
".",
"'/'",
".",
"$",
"strFilename",
")",
")",
";",
"// Check success if creating or dropping",
"if",
"(",
"'insert'",
"!==",
"$",
"strAction",
"&&",
"true",
"!==",
"$",
"mResult",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to '",
".",
"$",
"strAction",
".",
"' table in '",
".",
"$",
"strFilename",
".",
"' - please ensure your DB user has the right permissions.'",
")",
";",
"}",
"}",
"}",
"}"
] |
Run the query files in a given directory.
@param string $strAction create, insert, or drop
@throws Exception
|
[
"Run",
"the",
"query",
"files",
"in",
"a",
"given",
"directory",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L125-L145
|
21,521 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.topic
|
public function topic($mTopic, $bRandomOne = false)
{
// Sanitize input
if (is_string($mTopic))
$mTopic = $this->getIdFor('topic', $mTopic);
// Search
$q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`'
. ' FROM `sudo_bible_topic_verses` AS tv'
. ' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`'
. ' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`'
. ' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`'
. ' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?'
. ' ORDER BY `book_id`, `chapter`, `verse`';
$mResult = $this->runPreparedQuery($q, [$this->iTranslation, $mTopic]);
// If a random passage was requested, pick one
if ($bRandomOne) {
$mResult = new SudoBiblePassage([$mResult[array_rand($mResult)]], $this);
// Otherwise, convert all from stdClass to SudoBiblePassage
} else {
foreach ($mResult as $k => $oResult)
$mResult[$k] = new SudoBiblePassage([$oResult], $this);
}
return $mResult;
}
|
php
|
public function topic($mTopic, $bRandomOne = false)
{
// Sanitize input
if (is_string($mTopic))
$mTopic = $this->getIdFor('topic', $mTopic);
// Search
$q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`'
. ' FROM `sudo_bible_topic_verses` AS tv'
. ' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`'
. ' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`'
. ' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`'
. ' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?'
. ' ORDER BY `book_id`, `chapter`, `verse`';
$mResult = $this->runPreparedQuery($q, [$this->iTranslation, $mTopic]);
// If a random passage was requested, pick one
if ($bRandomOne) {
$mResult = new SudoBiblePassage([$mResult[array_rand($mResult)]], $this);
// Otherwise, convert all from stdClass to SudoBiblePassage
} else {
foreach ($mResult as $k => $oResult)
$mResult[$k] = new SudoBiblePassage([$oResult], $this);
}
return $mResult;
}
|
[
"public",
"function",
"topic",
"(",
"$",
"mTopic",
",",
"$",
"bRandomOne",
"=",
"false",
")",
"{",
"// Sanitize input",
"if",
"(",
"is_string",
"(",
"$",
"mTopic",
")",
")",
"$",
"mTopic",
"=",
"$",
"this",
"->",
"getIdFor",
"(",
"'topic'",
",",
"$",
"mTopic",
")",
";",
"// Search",
"$",
"q",
"=",
"'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`'",
".",
"' FROM `sudo_bible_topic_verses` AS tv'",
".",
"' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`'",
".",
"' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`'",
".",
"' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`'",
".",
"' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?'",
".",
"' ORDER BY `book_id`, `chapter`, `verse`'",
";",
"$",
"mResult",
"=",
"$",
"this",
"->",
"runPreparedQuery",
"(",
"$",
"q",
",",
"[",
"$",
"this",
"->",
"iTranslation",
",",
"$",
"mTopic",
"]",
")",
";",
"// If a random passage was requested, pick one",
"if",
"(",
"$",
"bRandomOne",
")",
"{",
"$",
"mResult",
"=",
"new",
"SudoBiblePassage",
"(",
"[",
"$",
"mResult",
"[",
"array_rand",
"(",
"$",
"mResult",
")",
"]",
"]",
",",
"$",
"this",
")",
";",
"// Otherwise, convert all from stdClass to SudoBiblePassage",
"}",
"else",
"{",
"foreach",
"(",
"$",
"mResult",
"as",
"$",
"k",
"=>",
"$",
"oResult",
")",
"$",
"mResult",
"[",
"$",
"k",
"]",
"=",
"new",
"SudoBiblePassage",
"(",
"[",
"$",
"oResult",
"]",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"mResult",
";",
"}"
] |
Return all verses on a single topic.
@param int|string $mTopic The topic ID or name.
@param bool $bRandomOne Pick a random passage?
@return array|SudoBiblePassage
|
[
"Return",
"all",
"verses",
"on",
"a",
"single",
"topic",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L291-L317
|
21,522 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.nextVerse
|
public function nextVerse($mBook, $iChapter, $iVerse)
{
$oPassage = new SudoBiblePassage([], $this);
$iBookId = is_numeric($mBook) ? $mBook : getIdFor('book', $mBook);
// Steps to try
$aSteps = [
[$iBookId, $iChapter, $iVerse + 1], // next verse in chapter
[$iBookId, $iChapter + 1, 1], // beginning of next chapter in book
[$iBookId + 1, 1, 1], // beginning of next book
];
foreach ($aSteps as $aStep) {
if ($oPassage->isEmpty())
$oPassage = call_user_func_array([$this, 'verse'], $aStep);
else
break;
}
return $oPassage;
}
|
php
|
public function nextVerse($mBook, $iChapter, $iVerse)
{
$oPassage = new SudoBiblePassage([], $this);
$iBookId = is_numeric($mBook) ? $mBook : getIdFor('book', $mBook);
// Steps to try
$aSteps = [
[$iBookId, $iChapter, $iVerse + 1], // next verse in chapter
[$iBookId, $iChapter + 1, 1], // beginning of next chapter in book
[$iBookId + 1, 1, 1], // beginning of next book
];
foreach ($aSteps as $aStep) {
if ($oPassage->isEmpty())
$oPassage = call_user_func_array([$this, 'verse'], $aStep);
else
break;
}
return $oPassage;
}
|
[
"public",
"function",
"nextVerse",
"(",
"$",
"mBook",
",",
"$",
"iChapter",
",",
"$",
"iVerse",
")",
"{",
"$",
"oPassage",
"=",
"new",
"SudoBiblePassage",
"(",
"[",
"]",
",",
"$",
"this",
")",
";",
"$",
"iBookId",
"=",
"is_numeric",
"(",
"$",
"mBook",
")",
"?",
"$",
"mBook",
":",
"getIdFor",
"(",
"'book'",
",",
"$",
"mBook",
")",
";",
"// Steps to try",
"$",
"aSteps",
"=",
"[",
"[",
"$",
"iBookId",
",",
"$",
"iChapter",
",",
"$",
"iVerse",
"+",
"1",
"]",
",",
"// next verse in chapter",
"[",
"$",
"iBookId",
",",
"$",
"iChapter",
"+",
"1",
",",
"1",
"]",
",",
"// beginning of next chapter in book",
"[",
"$",
"iBookId",
"+",
"1",
",",
"1",
",",
"1",
"]",
",",
"// beginning of next book",
"]",
";",
"foreach",
"(",
"$",
"aSteps",
"as",
"$",
"aStep",
")",
"{",
"if",
"(",
"$",
"oPassage",
"->",
"isEmpty",
"(",
")",
")",
"$",
"oPassage",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'verse'",
"]",
",",
"$",
"aStep",
")",
";",
"else",
"break",
";",
"}",
"return",
"$",
"oPassage",
";",
"}"
] |
Get the verse following the given reference.
@param int|string $mBook
@param int $iChapter
@param int $iVerse
@return SudoBiblePassage
|
[
"Get",
"the",
"verse",
"following",
"the",
"given",
"reference",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L327-L346
|
21,523 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.getIdFor
|
protected function getIdFor($strType, $strNameAbbr)
{
// Validate input
if (!in_array($strType, ['book', 'translation', 'topic']))
throw new Exception('Invalid entity type "' . $strType . '"');
// Query the db to get the ID
$strTableName = 'sudo_bible_' . $strType . 's';
$q = 'SELECT `id` FROM `' . $strTableName . '` WHERE `name` LIKE ?';
$aParams = [$strNameAbbr];
if ('topic' !== $strType) {
$q .= ' OR `abbr` LIKE ?';
$aParams[] = $strNameAbbr;
}
$aResult = $this->runPreparedQuery($q, $aParams);
$iId = $aResult[0]->id;
// Validate result
if (!is_numeric($iId))
throw new Exception('Invalid ' . $strType . ' "' . $strNameAbbr . '" given.');
return $iId;
}
|
php
|
protected function getIdFor($strType, $strNameAbbr)
{
// Validate input
if (!in_array($strType, ['book', 'translation', 'topic']))
throw new Exception('Invalid entity type "' . $strType . '"');
// Query the db to get the ID
$strTableName = 'sudo_bible_' . $strType . 's';
$q = 'SELECT `id` FROM `' . $strTableName . '` WHERE `name` LIKE ?';
$aParams = [$strNameAbbr];
if ('topic' !== $strType) {
$q .= ' OR `abbr` LIKE ?';
$aParams[] = $strNameAbbr;
}
$aResult = $this->runPreparedQuery($q, $aParams);
$iId = $aResult[0]->id;
// Validate result
if (!is_numeric($iId))
throw new Exception('Invalid ' . $strType . ' "' . $strNameAbbr . '" given.');
return $iId;
}
|
[
"protected",
"function",
"getIdFor",
"(",
"$",
"strType",
",",
"$",
"strNameAbbr",
")",
"{",
"// Validate input",
"if",
"(",
"!",
"in_array",
"(",
"$",
"strType",
",",
"[",
"'book'",
",",
"'translation'",
",",
"'topic'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Invalid entity type \"'",
".",
"$",
"strType",
".",
"'\"'",
")",
";",
"// Query the db to get the ID",
"$",
"strTableName",
"=",
"'sudo_bible_'",
".",
"$",
"strType",
".",
"'s'",
";",
"$",
"q",
"=",
"'SELECT `id` FROM `'",
".",
"$",
"strTableName",
".",
"'` WHERE `name` LIKE ?'",
";",
"$",
"aParams",
"=",
"[",
"$",
"strNameAbbr",
"]",
";",
"if",
"(",
"'topic'",
"!==",
"$",
"strType",
")",
"{",
"$",
"q",
".=",
"' OR `abbr` LIKE ?'",
";",
"$",
"aParams",
"[",
"]",
"=",
"$",
"strNameAbbr",
";",
"}",
"$",
"aResult",
"=",
"$",
"this",
"->",
"runPreparedQuery",
"(",
"$",
"q",
",",
"$",
"aParams",
")",
";",
"$",
"iId",
"=",
"$",
"aResult",
"[",
"0",
"]",
"->",
"id",
";",
"// Validate result",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"iId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Invalid '",
".",
"$",
"strType",
".",
"' \"'",
".",
"$",
"strNameAbbr",
".",
"'\" given.'",
")",
";",
"return",
"$",
"iId",
";",
"}"
] |
Get an ID, given the name.
For now, we're using this instead of a JOIN in the main query
so we can throw a useful error.
@param string $strType translation, book, or topic
@param string $strNameAbbr Name of the translation or book.
@throws Exception
@return int
|
[
"Get",
"an",
"ID",
"given",
"the",
"name",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L359-L381
|
21,524 |
Root-XS/SudoBible
|
src/SudoBible.php
|
SudoBible.runPreparedQuery
|
protected function runPreparedQuery($strSql, array $aParams = [])
{
// call_user_func_array needs references, not values
$aRefParams = [];
foreach ($aParams as $k =>$v)
$aRefParams[$k] = &$aParams[$k];
// Build data type string for bind_param
$strDataTypes = '';
foreach ($aRefParams as $mValue)
$strDataTypes .= is_int($mValue) ? 'i' : 's';
array_unshift($aRefParams, $strDataTypes);
// Prepare & execute
$stmt = $this->db->prepare($strSql);
call_user_func_array(array($stmt, 'bind_param'), $aRefParams);
$stmt->execute();
$oResult = $stmt->get_result();
// Build return array
$aReturn = [];
$i = 0;
while ($oRow = $oResult->fetch_object())
$aReturn[] = $oRow;
$stmt->close();
return $aReturn;
}
|
php
|
protected function runPreparedQuery($strSql, array $aParams = [])
{
// call_user_func_array needs references, not values
$aRefParams = [];
foreach ($aParams as $k =>$v)
$aRefParams[$k] = &$aParams[$k];
// Build data type string for bind_param
$strDataTypes = '';
foreach ($aRefParams as $mValue)
$strDataTypes .= is_int($mValue) ? 'i' : 's';
array_unshift($aRefParams, $strDataTypes);
// Prepare & execute
$stmt = $this->db->prepare($strSql);
call_user_func_array(array($stmt, 'bind_param'), $aRefParams);
$stmt->execute();
$oResult = $stmt->get_result();
// Build return array
$aReturn = [];
$i = 0;
while ($oRow = $oResult->fetch_object())
$aReturn[] = $oRow;
$stmt->close();
return $aReturn;
}
|
[
"protected",
"function",
"runPreparedQuery",
"(",
"$",
"strSql",
",",
"array",
"$",
"aParams",
"=",
"[",
"]",
")",
"{",
"// call_user_func_array needs references, not values",
"$",
"aRefParams",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aParams",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"$",
"aRefParams",
"[",
"$",
"k",
"]",
"=",
"&",
"$",
"aParams",
"[",
"$",
"k",
"]",
";",
"// Build data type string for bind_param",
"$",
"strDataTypes",
"=",
"''",
";",
"foreach",
"(",
"$",
"aRefParams",
"as",
"$",
"mValue",
")",
"$",
"strDataTypes",
".=",
"is_int",
"(",
"$",
"mValue",
")",
"?",
"'i'",
":",
"'s'",
";",
"array_unshift",
"(",
"$",
"aRefParams",
",",
"$",
"strDataTypes",
")",
";",
"// Prepare & execute",
"$",
"stmt",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"$",
"strSql",
")",
";",
"call_user_func_array",
"(",
"array",
"(",
"$",
"stmt",
",",
"'bind_param'",
")",
",",
"$",
"aRefParams",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"$",
"oResult",
"=",
"$",
"stmt",
"->",
"get_result",
"(",
")",
";",
"// Build return array",
"$",
"aReturn",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"oRow",
"=",
"$",
"oResult",
"->",
"fetch_object",
"(",
")",
")",
"$",
"aReturn",
"[",
"]",
"=",
"$",
"oRow",
";",
"$",
"stmt",
"->",
"close",
"(",
")",
";",
"return",
"$",
"aReturn",
";",
"}"
] |
Run a "mysqli" prepared query, given the query string and params.
@param string $strSql Query string with "?" placeholders.
@param array $aParams Array of values to fill in for the placeholders.
@return array Result set.
|
[
"Run",
"a",
"mysqli",
"prepared",
"query",
"given",
"the",
"query",
"string",
"and",
"params",
"."
] |
562462e92e1b2c019bdd48ed83414502ca0bdb0c
|
https://github.com/Root-XS/SudoBible/blob/562462e92e1b2c019bdd48ed83414502ca0bdb0c/src/SudoBible.php#L390-L417
|
21,525 |
NuclearCMS/Hierarchy
|
src/Support/FileKeeper.php
|
FileKeeper.tryDelete
|
protected static function tryDelete($path)
{
$success = true;
try
{
if ( ! @unlink($path))
{
$success = false;
}
} catch (ErrorException $e)
{
$success = false;
}
return $success;
}
|
php
|
protected static function tryDelete($path)
{
$success = true;
try
{
if ( ! @unlink($path))
{
$success = false;
}
} catch (ErrorException $e)
{
$success = false;
}
return $success;
}
|
[
"protected",
"static",
"function",
"tryDelete",
"(",
"$",
"path",
")",
"{",
"$",
"success",
"=",
"true",
";",
"try",
"{",
"if",
"(",
"!",
"@",
"unlink",
"(",
"$",
"path",
")",
")",
"{",
"$",
"success",
"=",
"false",
";",
"}",
"}",
"catch",
"(",
"ErrorException",
"$",
"e",
")",
"{",
"$",
"success",
"=",
"false",
";",
"}",
"return",
"$",
"success",
";",
"}"
] |
Try to delete a file
@param $path
@return bool
|
[
"Try",
"to",
"delete",
"a",
"file"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/FileKeeper.php#L89-L105
|
21,526 |
bluetree-service/event
|
src/Event/Base/EventLog.php
|
EventLog.makeLogEvent
|
public function makeLogEvent($name, $eventListener, $status)
{
if ($this->options['log_events']
&& ($this->options['log_all_events']
|| in_array($name, $this->logEvents, true)
)
) {
$this->loggerInstance->makeLog(
[
'event_name' => $name,
'listener' => $this->getListenerData($eventListener),
'status' => $status
]
);
}
return $this;
}
|
php
|
public function makeLogEvent($name, $eventListener, $status)
{
if ($this->options['log_events']
&& ($this->options['log_all_events']
|| in_array($name, $this->logEvents, true)
)
) {
$this->loggerInstance->makeLog(
[
'event_name' => $name,
'listener' => $this->getListenerData($eventListener),
'status' => $status
]
);
}
return $this;
}
|
[
"public",
"function",
"makeLogEvent",
"(",
"$",
"name",
",",
"$",
"eventListener",
",",
"$",
"status",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'log_events'",
"]",
"&&",
"(",
"$",
"this",
"->",
"options",
"[",
"'log_all_events'",
"]",
"||",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"logEvents",
",",
"true",
")",
")",
")",
"{",
"$",
"this",
"->",
"loggerInstance",
"->",
"makeLog",
"(",
"[",
"'event_name'",
"=>",
"$",
"name",
",",
"'listener'",
"=>",
"$",
"this",
"->",
"getListenerData",
"(",
"$",
"eventListener",
")",
",",
"'status'",
"=>",
"$",
"status",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
check that event data can be logged and create log message
@param string $name
@param mixed $eventListener
@param bool|string $status
@return $this
|
[
"check",
"that",
"event",
"data",
"can",
"be",
"logged",
"and",
"create",
"log",
"message"
] |
64ef4c77af6284fc22748285d5e527edbdbed69b
|
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventLog.php#L56-L73
|
21,527 |
thienhungho/yii2-product-management
|
src/modules/ProductManage/controllers/ProductTypeMetaController.php
|
ProductTypeMetaController.findModel
|
protected function findModel($id)
{
if (($model = ProductTypeMeta::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
}
|
php
|
protected function findModel($id)
{
if (($model = ProductTypeMeta::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
}
|
[
"protected",
"function",
"findModel",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"(",
"$",
"model",
"=",
"ProductTypeMeta",
"::",
"findOne",
"(",
"$",
"id",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"model",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"t",
"(",
"'app'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"}"
] |
Finds the ProductTypeMeta model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param integer $id
@return ProductTypeMeta the loaded model
@throws NotFoundHttpException if the model cannot be found
|
[
"Finds",
"the",
"ProductTypeMeta",
"model",
"based",
"on",
"its",
"primary",
"key",
"value",
".",
"If",
"the",
"model",
"is",
"not",
"found",
"a",
"404",
"HTTP",
"exception",
"will",
"be",
"thrown",
"."
] |
72e1237bba123faf671e44491bd93077b50adde9
|
https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductTypeMetaController.php#L182-L189
|
21,528 |
xiewulong/yii2-fileupload
|
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php
|
DebugUniversalClassLoader.enable
|
public static function enable()
{
if (!is_array($functions = spl_autoload_functions())) {
return;
}
foreach ($functions as $function) {
spl_autoload_unregister($function);
}
foreach ($functions as $function) {
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
$loader = new static();
$loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
$loader->registerNamespaces($function[0]->getNamespaces());
$loader->registerPrefixes($function[0]->getPrefixes());
$loader->useIncludePath($function[0]->getUseIncludePath());
$function[0] = $loader;
}
spl_autoload_register($function);
}
}
|
php
|
public static function enable()
{
if (!is_array($functions = spl_autoload_functions())) {
return;
}
foreach ($functions as $function) {
spl_autoload_unregister($function);
}
foreach ($functions as $function) {
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
$loader = new static();
$loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
$loader->registerNamespaces($function[0]->getNamespaces());
$loader->registerPrefixes($function[0]->getPrefixes());
$loader->useIncludePath($function[0]->getUseIncludePath());
$function[0] = $loader;
}
spl_autoload_register($function);
}
}
|
[
"public",
"static",
"function",
"enable",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"functions",
"=",
"spl_autoload_functions",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"function",
")",
"{",
"spl_autoload_unregister",
"(",
"$",
"function",
")",
";",
"}",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"function",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"function",
")",
"&&",
"$",
"function",
"[",
"0",
"]",
"instanceof",
"UniversalClassLoader",
")",
"{",
"$",
"loader",
"=",
"new",
"static",
"(",
")",
";",
"$",
"loader",
"->",
"registerNamespaceFallbacks",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getNamespaceFallbacks",
"(",
")",
")",
";",
"$",
"loader",
"->",
"registerPrefixFallbacks",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getPrefixFallbacks",
"(",
")",
")",
";",
"$",
"loader",
"->",
"registerNamespaces",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getNamespaces",
"(",
")",
")",
";",
"$",
"loader",
"->",
"registerPrefixes",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getPrefixes",
"(",
")",
")",
";",
"$",
"loader",
"->",
"useIncludePath",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getUseIncludePath",
"(",
")",
")",
";",
"$",
"function",
"[",
"0",
"]",
"=",
"$",
"loader",
";",
"}",
"spl_autoload_register",
"(",
"$",
"function",
")",
";",
"}",
"}"
] |
Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
|
[
"Replaces",
"all",
"regular",
"UniversalClassLoader",
"instances",
"by",
"a",
"DebugUniversalClassLoader",
"ones",
"."
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php#L24-L48
|
21,529 |
Danack/GithubArtaxService
|
lib/GithubService/Model/RepoStatsPunchCardInfo.php
|
RepoStatsPunchCardInfo.createFromData
|
static function createFromData($data) {
$instance = new static();
$instance->day = $data[0];
$instance->hour = $data[1];
$instance->numberCommits = $data[2];
return $instance;
}
|
php
|
static function createFromData($data) {
$instance = new static();
$instance->day = $data[0];
$instance->hour = $data[1];
$instance->numberCommits = $data[2];
return $instance;
}
|
[
"static",
"function",
"createFromData",
"(",
"$",
"data",
")",
"{",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"$",
"instance",
"->",
"day",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"instance",
"->",
"hour",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"$",
"instance",
"->",
"numberCommits",
"=",
"$",
"data",
"[",
"2",
"]",
";",
"return",
"$",
"instance",
";",
"}"
] |
Number of commits
|
[
"Number",
"of",
"commits"
] |
9f62b5be4f413207d4012e7fa084d0ae505680eb
|
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Model/RepoStatsPunchCardInfo.php#L22-L30
|
21,530 |
raideer/twitch-api
|
src/Wrapper.php
|
Wrapper.registerResource
|
public function registerResource(Resources\Resource $resource)
{
$this->resources[strtolower($resource->getName())] = $resource;
}
|
php
|
public function registerResource(Resources\Resource $resource)
{
$this->resources[strtolower($resource->getName())] = $resource;
}
|
[
"public",
"function",
"registerResource",
"(",
"Resources",
"\\",
"Resource",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"resources",
"[",
"strtolower",
"(",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
"]",
"=",
"$",
"resource",
";",
"}"
] |
Registers a resource.
@param ResourcesResource $resource
@return void
|
[
"Registers",
"a",
"resource",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Wrapper.php#L71-L74
|
21,531 |
raideer/twitch-api
|
src/Wrapper.php
|
Wrapper.authorize
|
public function authorize($args)
{
$numArgs = func_num_args();
if ($numArgs === 0) {
throw new \InvalidArgumentException('Wrapper->authorize expects atleast 1 argument!');
return;
}
if ($numArgs === 1) {
$arg1 = func_get_arg(0);
if ($arg1 instanceof OAuthResponse) {
$this->accessToken = $arg1->getAccessToken();
$this->registeredScopes = $arg1->getScope();
} elseif (is_string($arg1)) {
$this->accessToken = $arg1;
} else {
throw new \InvalidArgumentException("Passed argument must be an access token OR an instance of Raideer\TwitchApi\OAuthResponse");
return;
}
} elseif ($numArgs === 2) {
list($arg1, $arg2) = func_get_args();
if (is_string($arg1) && is_array($arg2)) {
$this->accessToken = $arg1;
$this->registeredScopes = $arg2;
} else {
throw new \InvalidArgumentException('First argument must be an accessToken and the second must be an array of registered scopes');
return;
}
} else {
throw new \InvalidArgumentException('Wrapper->authorize expects 1 or 2 arguments');
return;
}
$this->authorized = true;
}
|
php
|
public function authorize($args)
{
$numArgs = func_num_args();
if ($numArgs === 0) {
throw new \InvalidArgumentException('Wrapper->authorize expects atleast 1 argument!');
return;
}
if ($numArgs === 1) {
$arg1 = func_get_arg(0);
if ($arg1 instanceof OAuthResponse) {
$this->accessToken = $arg1->getAccessToken();
$this->registeredScopes = $arg1->getScope();
} elseif (is_string($arg1)) {
$this->accessToken = $arg1;
} else {
throw new \InvalidArgumentException("Passed argument must be an access token OR an instance of Raideer\TwitchApi\OAuthResponse");
return;
}
} elseif ($numArgs === 2) {
list($arg1, $arg2) = func_get_args();
if (is_string($arg1) && is_array($arg2)) {
$this->accessToken = $arg1;
$this->registeredScopes = $arg2;
} else {
throw new \InvalidArgumentException('First argument must be an accessToken and the second must be an array of registered scopes');
return;
}
} else {
throw new \InvalidArgumentException('Wrapper->authorize expects 1 or 2 arguments');
return;
}
$this->authorized = true;
}
|
[
"public",
"function",
"authorize",
"(",
"$",
"args",
")",
"{",
"$",
"numArgs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"numArgs",
"===",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Wrapper->authorize expects atleast 1 argument!'",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"numArgs",
"===",
"1",
")",
"{",
"$",
"arg1",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"if",
"(",
"$",
"arg1",
"instanceof",
"OAuthResponse",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"arg1",
"->",
"getAccessToken",
"(",
")",
";",
"$",
"this",
"->",
"registeredScopes",
"=",
"$",
"arg1",
"->",
"getScope",
"(",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"arg1",
")",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"arg1",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Passed argument must be an access token OR an instance of Raideer\\TwitchApi\\OAuthResponse\"",
")",
";",
"return",
";",
"}",
"}",
"elseif",
"(",
"$",
"numArgs",
"===",
"2",
")",
"{",
"list",
"(",
"$",
"arg1",
",",
"$",
"arg2",
")",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"arg1",
")",
"&&",
"is_array",
"(",
"$",
"arg2",
")",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"arg1",
";",
"$",
"this",
"->",
"registeredScopes",
"=",
"$",
"arg2",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'First argument must be an accessToken and the second must be an array of registered scopes'",
")",
";",
"return",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Wrapper->authorize expects 1 or 2 arguments'",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"authorized",
"=",
"true",
";",
"}"
] |
Enables the authorized requests.
@param string $args Access token
OR
@param OAuthResponse $args Object returned by OAuth->getResponse()
OR
@param string $arg1 Access Token
@param array $arg2 Array of registered scopes
@return void
|
[
"Enables",
"the",
"authorized",
"requests",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Wrapper.php#L118-L158
|
21,532 |
raideer/twitch-api
|
src/Wrapper.php
|
Wrapper.hasScope
|
public function hasScope($name, $strict = true)
{
if (!$strict) {
if (empty($this->registeredScopes)) {
return true;
}
}
return in_array($name, $this->registeredScopes);
}
|
php
|
public function hasScope($name, $strict = true)
{
if (!$strict) {
if (empty($this->registeredScopes)) {
return true;
}
}
return in_array($name, $this->registeredScopes);
}
|
[
"public",
"function",
"hasScope",
"(",
"$",
"name",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"strict",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"registeredScopes",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"registeredScopes",
")",
";",
"}"
] |
Checks if scope is registered.
@param string $name Scope name
@param bool $strict If false and registeredScopes array is empty, function will return true.
Used by Resources. If an array of registered scopes is passed in
Wrapper->authorize() function, authorized requests will check if scope is
registered without making a request to the twitch api.
@return bool
|
[
"Checks",
"if",
"scope",
"is",
"registered",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Wrapper.php#L171-L180
|
21,533 |
raideer/twitch-api
|
src/Wrapper.php
|
Wrapper.checkScope
|
public function checkScope($name, $strict = false)
{
if (!$this->hasScope($name, $strict)) {
throw new Exceptions\OutOfScopeException("Scope $name is not registered!");
}
}
|
php
|
public function checkScope($name, $strict = false)
{
if (!$this->hasScope($name, $strict)) {
throw new Exceptions\OutOfScopeException("Scope $name is not registered!");
}
}
|
[
"public",
"function",
"checkScope",
"(",
"$",
"name",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasScope",
"(",
"$",
"name",
",",
"$",
"strict",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"OutOfScopeException",
"(",
"\"Scope $name is not registered!\"",
")",
";",
"}",
"}"
] |
Checks if scope is registered
Throws an exception if scope doesn't exist.
@param string $name Scope name
@param bool $strict
@return void
|
[
"Checks",
"if",
"scope",
"is",
"registered",
"Throws",
"an",
"exception",
"if",
"scope",
"doesn",
"t",
"exist",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Wrapper.php#L191-L196
|
21,534 |
raideer/twitch-api
|
src/Wrapper.php
|
Wrapper.resource
|
public function resource($name)
{
if (!isset($this->resources[$name])) {
throw new Exceptions\ResourceException("Resource $name does not exist!");
return;
}
return $this->resources[$name];
}
|
php
|
public function resource($name)
{
if (!isset($this->resources[$name])) {
throw new Exceptions\ResourceException("Resource $name does not exist!");
return;
}
return $this->resources[$name];
}
|
[
"public",
"function",
"resource",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resources",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"ResourceException",
"(",
"\"Resource $name does not exist!\"",
")",
";",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"resources",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns an API resource.
@param string $name Name of the resource
@return Raideer\TwitchApi\Resources\Resource
|
[
"Returns",
"an",
"API",
"resource",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Wrapper.php#L223-L232
|
21,535 |
raideer/twitch-api
|
src/Wrapper.php
|
Wrapper.request
|
public function request($type, $target, $options = [], $authorized = false)
{
$headers = [
'Accept' => 'application/vnd.twitchtv.v3+json',
];
if ($authorized) {
$headers['Authorization'] = 'OAuth '.$this->accessToken;
}
$options = array_merge_recursive(['headers' => $headers], $options);
try {
if ($this->throttling) {
$this->throttle->throttle();
}
$response = $this->client->request($type, $this->apiURL.$target, $options);
} catch (RequestException $e) {
if ($e->hasResponse()) {
$response = $e->getResponse();
} else {
return;
}
}
$body = json_decode($response->getBody()->getContents());
return (json_last_error() == JSON_ERROR_NONE) ? $body : $response->getBody()->getContents();
}
|
php
|
public function request($type, $target, $options = [], $authorized = false)
{
$headers = [
'Accept' => 'application/vnd.twitchtv.v3+json',
];
if ($authorized) {
$headers['Authorization'] = 'OAuth '.$this->accessToken;
}
$options = array_merge_recursive(['headers' => $headers], $options);
try {
if ($this->throttling) {
$this->throttle->throttle();
}
$response = $this->client->request($type, $this->apiURL.$target, $options);
} catch (RequestException $e) {
if ($e->hasResponse()) {
$response = $e->getResponse();
} else {
return;
}
}
$body = json_decode($response->getBody()->getContents());
return (json_last_error() == JSON_ERROR_NONE) ? $body : $response->getBody()->getContents();
}
|
[
"public",
"function",
"request",
"(",
"$",
"type",
",",
"$",
"target",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"authorized",
"=",
"false",
")",
"{",
"$",
"headers",
"=",
"[",
"'Accept'",
"=>",
"'application/vnd.twitchtv.v3+json'",
",",
"]",
";",
"if",
"(",
"$",
"authorized",
")",
"{",
"$",
"headers",
"[",
"'Authorization'",
"]",
"=",
"'OAuth '",
".",
"$",
"this",
"->",
"accessToken",
";",
"}",
"$",
"options",
"=",
"array_merge_recursive",
"(",
"[",
"'headers'",
"=>",
"$",
"headers",
"]",
",",
"$",
"options",
")",
";",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"throttling",
")",
"{",
"$",
"this",
"->",
"throttle",
"->",
"throttle",
"(",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"apiURL",
".",
"$",
"target",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"hasResponse",
"(",
")",
")",
"{",
"$",
"response",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"$",
"body",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
")",
";",
"return",
"(",
"json_last_error",
"(",
")",
"==",
"JSON_ERROR_NONE",
")",
"?",
"$",
"body",
":",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"}"
] |
Makes a GuzzleHttp request.
@param requestType $type GET, POST, PUT, DELETE
@param string $target Target URL
@param array $options Request options
@param bool $authorized Attach Authorization headers
@return array JsonDecoded body contents
|
[
"Makes",
"a",
"GuzzleHttp",
"request",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Wrapper.php#L268-L297
|
21,536 |
krakphp/job
|
src/Queue/Doctrine/JobRepository.php
|
JobRepository.addJob
|
public function addJob(Job\WrappedJob $job, $queue) {
$qb = $this->conn->createQueryBuilder();
$qb->insert($this->table_name);
$qb->values([
'status' => ':status',
'job' => ':job',
'name' => ':name',
'queue' => ':queue',
'created_at' => ':created_at',
'available_at' => ':available_at',
]);
$qb->setParameters([
'status' => self::JOB_STATUS_CREATED,
'queue' => $queue,
'job' => (string) $job,
'name' => $job->getName(),
]);
$qb->setParameter(':created_at', new \DateTime(), Type::DATETIME);
$available_at = $job->getDelay()
? new \DateTime(sprintf('+%d seconds', $job->getDelay()))
: new \DateTime();
$qb->setParameter(':available_at', $available_at, Type::DATETIME);
$qb->execute();
return $job->withAddedPayload([
'_doctrine' => [
'id' => $this->conn->lastInsertId()
]
]);
}
|
php
|
public function addJob(Job\WrappedJob $job, $queue) {
$qb = $this->conn->createQueryBuilder();
$qb->insert($this->table_name);
$qb->values([
'status' => ':status',
'job' => ':job',
'name' => ':name',
'queue' => ':queue',
'created_at' => ':created_at',
'available_at' => ':available_at',
]);
$qb->setParameters([
'status' => self::JOB_STATUS_CREATED,
'queue' => $queue,
'job' => (string) $job,
'name' => $job->getName(),
]);
$qb->setParameter(':created_at', new \DateTime(), Type::DATETIME);
$available_at = $job->getDelay()
? new \DateTime(sprintf('+%d seconds', $job->getDelay()))
: new \DateTime();
$qb->setParameter(':available_at', $available_at, Type::DATETIME);
$qb->execute();
return $job->withAddedPayload([
'_doctrine' => [
'id' => $this->conn->lastInsertId()
]
]);
}
|
[
"public",
"function",
"addJob",
"(",
"Job",
"\\",
"WrappedJob",
"$",
"job",
",",
"$",
"queue",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"conn",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"insert",
"(",
"$",
"this",
"->",
"table_name",
")",
";",
"$",
"qb",
"->",
"values",
"(",
"[",
"'status'",
"=>",
"':status'",
",",
"'job'",
"=>",
"':job'",
",",
"'name'",
"=>",
"':name'",
",",
"'queue'",
"=>",
"':queue'",
",",
"'created_at'",
"=>",
"':created_at'",
",",
"'available_at'",
"=>",
"':available_at'",
",",
"]",
")",
";",
"$",
"qb",
"->",
"setParameters",
"(",
"[",
"'status'",
"=>",
"self",
"::",
"JOB_STATUS_CREATED",
",",
"'queue'",
"=>",
"$",
"queue",
",",
"'job'",
"=>",
"(",
"string",
")",
"$",
"job",
",",
"'name'",
"=>",
"$",
"job",
"->",
"getName",
"(",
")",
",",
"]",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"':created_at'",
",",
"new",
"\\",
"DateTime",
"(",
")",
",",
"Type",
"::",
"DATETIME",
")",
";",
"$",
"available_at",
"=",
"$",
"job",
"->",
"getDelay",
"(",
")",
"?",
"new",
"\\",
"DateTime",
"(",
"sprintf",
"(",
"'+%d seconds'",
",",
"$",
"job",
"->",
"getDelay",
"(",
")",
")",
")",
":",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"':available_at'",
",",
"$",
"available_at",
",",
"Type",
"::",
"DATETIME",
")",
";",
"$",
"qb",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"job",
"->",
"withAddedPayload",
"(",
"[",
"'_doctrine'",
"=>",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"conn",
"->",
"lastInsertId",
"(",
")",
"]",
"]",
")",
";",
"}"
] |
add a new wrapped job
|
[
"add",
"a",
"new",
"wrapped",
"job"
] |
0c16020c1baa13d91f819ecba8334861ba7c4d6c
|
https://github.com/krakphp/job/blob/0c16020c1baa13d91f819ecba8334861ba7c4d6c/src/Queue/Doctrine/JobRepository.php#L32-L61
|
21,537 |
krakphp/job
|
src/Queue/Doctrine/JobRepository.php
|
JobRepository.getAvailableJobs
|
public function getAvailableJobs($queue, $max = 10) {
$qb = $this->conn->createQueryBuilder();
$qb->select('*');
$qb->from($this->table_name);
$qb->where('status = :status AND queue = :queue AND available_at <= :now');
$qb->orderBy('status');
$qb->setParameters([
'status' => self::JOB_STATUS_CREATED,
'queue' => $queue,
]);
$qb->setParameter('now', new \DateTime(), Type::DATETIME);
$qb->setMaxResults($max);
$stmt = $qb->execute();
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}
|
php
|
public function getAvailableJobs($queue, $max = 10) {
$qb = $this->conn->createQueryBuilder();
$qb->select('*');
$qb->from($this->table_name);
$qb->where('status = :status AND queue = :queue AND available_at <= :now');
$qb->orderBy('status');
$qb->setParameters([
'status' => self::JOB_STATUS_CREATED,
'queue' => $queue,
]);
$qb->setParameter('now', new \DateTime(), Type::DATETIME);
$qb->setMaxResults($max);
$stmt = $qb->execute();
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}
|
[
"public",
"function",
"getAvailableJobs",
"(",
"$",
"queue",
",",
"$",
"max",
"=",
"10",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"conn",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'*'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"$",
"this",
"->",
"table_name",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'status = :status AND queue = :queue AND available_at <= :now'",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'status'",
")",
";",
"$",
"qb",
"->",
"setParameters",
"(",
"[",
"'status'",
"=>",
"self",
"::",
"JOB_STATUS_CREATED",
",",
"'queue'",
"=>",
"$",
"queue",
",",
"]",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'now'",
",",
"new",
"\\",
"DateTime",
"(",
")",
",",
"Type",
"::",
"DATETIME",
")",
";",
"$",
"qb",
"->",
"setMaxResults",
"(",
"$",
"max",
")",
";",
"$",
"stmt",
"=",
"$",
"qb",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"stmt",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}"
] |
get available jobs
|
[
"get",
"available",
"jobs"
] |
0c16020c1baa13d91f819ecba8334861ba7c4d6c
|
https://github.com/krakphp/job/blob/0c16020c1baa13d91f819ecba8334861ba7c4d6c/src/Queue/Doctrine/JobRepository.php#L96-L110
|
21,538 |
alevilar/ristorantino-vendor
|
Risto/Controller/Component/RistoAuthComponent.php
|
RistoAuthComponent.initialize
|
public function initialize(Controller $controller) {
parent::initialize($controller);
$loginUrl = array(
'plugin' => 'users',
'controller' => 'users',
'action' => 'login',
'admin' => false,
);
if ( !empty( $controller->request->params['tenant'] ) ) {
$loginUrl['action'] = 'tenant_login';
}
$this->loginAction = $loginUrl;
$this->logoutRedirect = $loginUrl;
}
|
php
|
public function initialize(Controller $controller) {
parent::initialize($controller);
$loginUrl = array(
'plugin' => 'users',
'controller' => 'users',
'action' => 'login',
'admin' => false,
);
if ( !empty( $controller->request->params['tenant'] ) ) {
$loginUrl['action'] = 'tenant_login';
}
$this->loginAction = $loginUrl;
$this->logoutRedirect = $loginUrl;
}
|
[
"public",
"function",
"initialize",
"(",
"Controller",
"$",
"controller",
")",
"{",
"parent",
"::",
"initialize",
"(",
"$",
"controller",
")",
";",
"$",
"loginUrl",
"=",
"array",
"(",
"'plugin'",
"=>",
"'users'",
",",
"'controller'",
"=>",
"'users'",
",",
"'action'",
"=>",
"'login'",
",",
"'admin'",
"=>",
"false",
",",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"controller",
"->",
"request",
"->",
"params",
"[",
"'tenant'",
"]",
")",
")",
"{",
"$",
"loginUrl",
"[",
"'action'",
"]",
"=",
"'tenant_login'",
";",
"}",
"$",
"this",
"->",
"loginAction",
"=",
"$",
"loginUrl",
";",
"$",
"this",
"->",
"logoutRedirect",
"=",
"$",
"loginUrl",
";",
"}"
] |
Initializes AuthComponent for use in the controller.
@param Controller $controller A reference to the instantiating controller object
@return void
|
[
"Initializes",
"AuthComponent",
"for",
"use",
"in",
"the",
"controller",
"."
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Controller/Component/RistoAuthComponent.php#L57-L72
|
21,539 |
alevilar/ristorantino-vendor
|
Risto/Controller/Component/RistoAuthComponent.php
|
RistoAuthComponent.isAuthorized
|
public function isAuthorized($user = null, CakeRequest $request = null) {
if (empty($user) && !$this->user()) {
return false;
}
if (empty($user)) {
$user = $this->user();
}
if (empty($request)) {
$request = $this->request;
}
if (empty($this->_authorizeObjects)) {
$this->constructAuthorize();
}
foreach ($this->_authorizeObjects as $authorizer) {
if ($authorizer->authorize($user, $request) === false) {
return false;
}
}
return true;
}
|
php
|
public function isAuthorized($user = null, CakeRequest $request = null) {
if (empty($user) && !$this->user()) {
return false;
}
if (empty($user)) {
$user = $this->user();
}
if (empty($request)) {
$request = $this->request;
}
if (empty($this->_authorizeObjects)) {
$this->constructAuthorize();
}
foreach ($this->_authorizeObjects as $authorizer) {
if ($authorizer->authorize($user, $request) === false) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"isAuthorized",
"(",
"$",
"user",
"=",
"null",
",",
"CakeRequest",
"$",
"request",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
"&&",
"!",
"$",
"this",
"->",
"user",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"user",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"request",
")",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_authorizeObjects",
")",
")",
"{",
"$",
"this",
"->",
"constructAuthorize",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_authorizeObjects",
"as",
"$",
"authorizer",
")",
"{",
"if",
"(",
"$",
"authorizer",
"->",
"authorize",
"(",
"$",
"user",
",",
"$",
"request",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Al contrario que el isAuthorized que viene en CakePhp
este se fija si algun Adapter retorna false, y entonces retorna false.
el orioginal de Cake hace al reves: con que venga un true. ya le da acceso
a todos
@param array|null $user The user to check the authorization of. If empty the user in the session will be used.
@param CakeRequest|null $request The request to authenticate for. If empty, the current request will be used.
@return bool True if $user is authorized, otherwise false
|
[
"Al",
"contrario",
"que",
"el",
"isAuthorized",
"que",
"viene",
"en",
"CakePhp",
"este",
"se",
"fija",
"si",
"algun",
"Adapter",
"retorna",
"false",
"y",
"entonces",
"retorna",
"false",
"."
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Controller/Component/RistoAuthComponent.php#L86-L105
|
21,540 |
raideer/twitch-api
|
src/Resources/Streams.php
|
Streams.getStreams
|
public function getStreams($params = [])
{
$defaults = [
'game' => null,
'channel' => null,
'limit' => 25,
'offset' => 0,
'client_id' => null,
'stream_type' => 'all',
];
$types = [
'stream_type' => ['all', 'playlist', 'live'],
];
return $this->wrapper->request('GET', 'streams', ['query' => $this->resolveOptions($params, $defaults, [], $types)]);
}
|
php
|
public function getStreams($params = [])
{
$defaults = [
'game' => null,
'channel' => null,
'limit' => 25,
'offset' => 0,
'client_id' => null,
'stream_type' => 'all',
];
$types = [
'stream_type' => ['all', 'playlist', 'live'],
];
return $this->wrapper->request('GET', 'streams', ['query' => $this->resolveOptions($params, $defaults, [], $types)]);
}
|
[
"public",
"function",
"getStreams",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'game'",
"=>",
"null",
",",
"'channel'",
"=>",
"null",
",",
"'limit'",
"=>",
"25",
",",
"'offset'",
"=>",
"0",
",",
"'client_id'",
"=>",
"null",
",",
"'stream_type'",
"=>",
"'all'",
",",
"]",
";",
"$",
"types",
"=",
"[",
"'stream_type'",
"=>",
"[",
"'all'",
",",
"'playlist'",
",",
"'live'",
"]",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'streams'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
",",
"[",
"]",
",",
"$",
"types",
")",
"]",
")",
";",
"}"
] |
Returns a list of stream objects that are queried by a number
of parameters sorted by number of viewers descending.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streams
@param array $params Optional params
@return array
|
[
"Returns",
"a",
"list",
"of",
"stream",
"objects",
"that",
"are",
"queried",
"by",
"a",
"number",
"of",
"parameters",
"sorted",
"by",
"number",
"of",
"viewers",
"descending",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Streams.php#L47-L63
|
21,541 |
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Versions.php
|
Versions.entity
|
public function entity($entityType, $id, $timestamp)
{
$params = array(
'type_name' => $entityType,
'id' => $id,
'timestamp' => $timestamp,
);
return $this->post('versions/entity', $params);
}
|
php
|
public function entity($entityType, $id, $timestamp)
{
$params = array(
'type_name' => $entityType,
'id' => $id,
'timestamp' => $timestamp,
);
return $this->post('versions/entity', $params);
}
|
[
"public",
"function",
"entity",
"(",
"$",
"entityType",
",",
"$",
"id",
",",
"$",
"timestamp",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'type_name'",
"=>",
"$",
"entityType",
",",
"'id'",
"=>",
"$",
"id",
",",
"'timestamp'",
"=>",
"$",
"timestamp",
",",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'versions/entity'",
",",
"$",
"params",
")",
";",
"}"
] |
Retrieve a past value of single entity by primary key and timestamp.
@param string $entityType
@param string $id
@param string $timestamp
|
[
"Retrieve",
"a",
"past",
"value",
"of",
"single",
"entity",
"by",
"primary",
"key",
"and",
"timestamp",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Versions.php#L17-L26
|
21,542 |
WScore/Validation
|
src/Utils/HelperSameWith.php
|
HelperSameWith.get_sameWith_value
|
private static function get_sameWith_value($dio, $rules)
{
$sub_name = $rules['sameWith'];
if ($rules instanceof Rules) {
$sub_filter = clone $rules;
} else {
$sub_filter = $rules;
}
$sub_filter['sameWith'] = false;
$sub_filter['required'] = false;
$value = $dio->find($sub_name, $sub_filter);
$value = $dio->verify->is($value, $sub_filter);
return $value;
}
|
php
|
private static function get_sameWith_value($dio, $rules)
{
$sub_name = $rules['sameWith'];
if ($rules instanceof Rules) {
$sub_filter = clone $rules;
} else {
$sub_filter = $rules;
}
$sub_filter['sameWith'] = false;
$sub_filter['required'] = false;
$value = $dio->find($sub_name, $sub_filter);
$value = $dio->verify->is($value, $sub_filter);
return $value;
}
|
[
"private",
"static",
"function",
"get_sameWith_value",
"(",
"$",
"dio",
",",
"$",
"rules",
")",
"{",
"$",
"sub_name",
"=",
"$",
"rules",
"[",
"'sameWith'",
"]",
";",
"if",
"(",
"$",
"rules",
"instanceof",
"Rules",
")",
"{",
"$",
"sub_filter",
"=",
"clone",
"$",
"rules",
";",
"}",
"else",
"{",
"$",
"sub_filter",
"=",
"$",
"rules",
";",
"}",
"$",
"sub_filter",
"[",
"'sameWith'",
"]",
"=",
"false",
";",
"$",
"sub_filter",
"[",
"'required'",
"]",
"=",
"false",
";",
"$",
"value",
"=",
"$",
"dio",
"->",
"find",
"(",
"$",
"sub_name",
",",
"$",
"sub_filter",
")",
";",
"$",
"value",
"=",
"$",
"dio",
"->",
"verify",
"->",
"is",
"(",
"$",
"value",
",",
"$",
"sub_filter",
")",
";",
"return",
"$",
"value",
";",
"}"
] |
find the same with value.
@param Dio $dio
@param array|Rules $rules
@return mixed
|
[
"find",
"the",
"same",
"with",
"value",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperSameWith.php#L42-L56
|
21,543 |
vhraban/Overture
|
src/ProviderFoundation/TraversableValueContainer.php
|
TraversableValueContainer.get
|
public function get($key)
{
$ret = $this->traverseTree($key);
if(!is_scalar($ret))
{
throw new UnexpectedValueException("The {$key} configuration value is not scalar");
}
return $ret;
}
|
php
|
public function get($key)
{
$ret = $this->traverseTree($key);
if(!is_scalar($ret))
{
throw new UnexpectedValueException("The {$key} configuration value is not scalar");
}
return $ret;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"traverseTree",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"ret",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"The {$key} configuration value is not scalar\"",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Get a value for a configuration key
@param string $key The configuration key
@throws MissingKeyException if the path is unreachable
@throws UnexpectedValueException if the path is key is missing
@return string
|
[
"Get",
"a",
"value",
"for",
"a",
"configuration",
"key"
] |
4749f2631c9517bc0f6449185d5adb62b85ff4f5
|
https://github.com/vhraban/Overture/blob/4749f2631c9517bc0f6449185d5adb62b85ff4f5/src/ProviderFoundation/TraversableValueContainer.php#L37-L45
|
21,544 |
vhraban/Overture
|
src/ProviderFoundation/TraversableValueContainer.php
|
TraversableValueContainer.traverseTree
|
protected function traverseTree($path)
{
// before the travel current node is the root
$currentNode = $this->tree;
$pathElements = explode(static::KEY_NODE_DELIMITER, $path);
foreach($pathElements as $node)
{
// Ensure the next child exists
if(!isset($currentNode[$node]))
{
throw new MissingKeyException("{$path} configuration value is not found");
}
//update the current path if the child existed
$currentNode = $currentNode[$node];
}
return $currentNode;
}
|
php
|
protected function traverseTree($path)
{
// before the travel current node is the root
$currentNode = $this->tree;
$pathElements = explode(static::KEY_NODE_DELIMITER, $path);
foreach($pathElements as $node)
{
// Ensure the next child exists
if(!isset($currentNode[$node]))
{
throw new MissingKeyException("{$path} configuration value is not found");
}
//update the current path if the child existed
$currentNode = $currentNode[$node];
}
return $currentNode;
}
|
[
"protected",
"function",
"traverseTree",
"(",
"$",
"path",
")",
"{",
"// before the travel current node is the root",
"$",
"currentNode",
"=",
"$",
"this",
"->",
"tree",
";",
"$",
"pathElements",
"=",
"explode",
"(",
"static",
"::",
"KEY_NODE_DELIMITER",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"pathElements",
"as",
"$",
"node",
")",
"{",
"// Ensure the next child exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"currentNode",
"[",
"$",
"node",
"]",
")",
")",
"{",
"throw",
"new",
"MissingKeyException",
"(",
"\"{$path} configuration value is not found\"",
")",
";",
"}",
"//update the current path if the child existed",
"$",
"currentNode",
"=",
"$",
"currentNode",
"[",
"$",
"node",
"]",
";",
"}",
"return",
"$",
"currentNode",
";",
"}"
] |
Traverse a tree until the end of path is reached
$path can be separated with a dot .
In an array [ "section" => ["a => "b"], ["b" => "B"]
value B can be accessed by giving section.b key
@param string $path The path
@throws MissingKeyException if the path is unreachable
@return string
|
[
"Traverse",
"a",
"tree",
"until",
"the",
"end",
"of",
"path",
"is",
"reached"
] |
4749f2631c9517bc0f6449185d5adb62b85ff4f5
|
https://github.com/vhraban/Overture/blob/4749f2631c9517bc0f6449185d5adb62b85ff4f5/src/ProviderFoundation/TraversableValueContainer.php#L62-L81
|
21,545 |
madkom/regex
|
src/Matcher.php
|
Matcher.match
|
public function match(string $subject, int $flags = 0, int $offset = 0) : array
{
preg_match($this->pattern->getPattern() . $this->modifier, $subject, $matches, $flags, $offset);
if (($errno = preg_last_error()) !== PREG_NO_ERROR) {
$message = array_flip(get_defined_constants(true)['pcre'])[$errno];
switch ($errno) {
case PREG_INTERNAL_ERROR:
throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BACKTRACK_LIMIT_ERROR:
throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_RECURSION_LIMIT_ERROR:
throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_ERROR:
throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_OFFSET_ERROR:
throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_JIT_STACKLIMIT_ERROR:
throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
}
}
return $matches;
}
|
php
|
public function match(string $subject, int $flags = 0, int $offset = 0) : array
{
preg_match($this->pattern->getPattern() . $this->modifier, $subject, $matches, $flags, $offset);
if (($errno = preg_last_error()) !== PREG_NO_ERROR) {
$message = array_flip(get_defined_constants(true)['pcre'])[$errno];
switch ($errno) {
case PREG_INTERNAL_ERROR:
throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BACKTRACK_LIMIT_ERROR:
throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_RECURSION_LIMIT_ERROR:
throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_ERROR:
throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_BAD_UTF8_OFFSET_ERROR:
throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
case PREG_JIT_STACKLIMIT_ERROR:
throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
}
}
return $matches;
}
|
[
"public",
"function",
"match",
"(",
"string",
"$",
"subject",
",",
"int",
"$",
"flags",
"=",
"0",
",",
"int",
"$",
"offset",
"=",
"0",
")",
":",
"array",
"{",
"preg_match",
"(",
"$",
"this",
"->",
"pattern",
"->",
"getPattern",
"(",
")",
".",
"$",
"this",
"->",
"modifier",
",",
"$",
"subject",
",",
"$",
"matches",
",",
"$",
"flags",
",",
"$",
"offset",
")",
";",
"if",
"(",
"(",
"$",
"errno",
"=",
"preg_last_error",
"(",
")",
")",
"!==",
"PREG_NO_ERROR",
")",
"{",
"$",
"message",
"=",
"array_flip",
"(",
"get_defined_constants",
"(",
"true",
")",
"[",
"'pcre'",
"]",
")",
"[",
"$",
"errno",
"]",
";",
"switch",
"(",
"$",
"errno",
")",
"{",
"case",
"PREG_INTERNAL_ERROR",
":",
"throw",
"new",
"InternalException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_BACKTRACK_LIMIT_ERROR",
":",
"throw",
"new",
"BacktrackLimitException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_RECURSION_LIMIT_ERROR",
":",
"throw",
"new",
"RecursionLimitException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_BAD_UTF8_ERROR",
":",
"throw",
"new",
"BadUtf8Exception",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_BAD_UTF8_OFFSET_ERROR",
":",
"throw",
"new",
"BadUtf8OffsetException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"case",
"PREG_JIT_STACKLIMIT_ERROR",
":",
"throw",
"new",
"JitStackLimitException",
"(",
"\"{$message} using pattern: {$this->pattern->getPattern()}\"",
",",
"$",
"errno",
")",
";",
"}",
"}",
"return",
"$",
"matches",
";",
"}"
] |
Retrieve match from subject with Pattern
@param string $subject
@param int $flags
@param int $offset
@return array
@throws BacktrackLimitException
@throws BadUtf8Exception
@throws BadUtf8OffsetException
@throws InternalException
@throws JitStackLimitException
@throws RecursionLimitException
|
[
"Retrieve",
"match",
"from",
"subject",
"with",
"Pattern"
] |
798c1124805b130b1110ee6e8dcc9a88d8aaffa8
|
https://github.com/madkom/regex/blob/798c1124805b130b1110ee6e8dcc9a88d8aaffa8/src/Matcher.php#L57-L80
|
21,546 |
heidelpay/PhpDoc
|
src/phpDocumentor/Command/Command.php
|
Command.setHelperSet
|
public function setHelperSet(HelperSet $helperSet)
{
parent::setHelperSet($helperSet);
$this->getHelper('phpdocumentor_logger')->addOptions($this);
}
|
php
|
public function setHelperSet(HelperSet $helperSet)
{
parent::setHelperSet($helperSet);
$this->getHelper('phpdocumentor_logger')->addOptions($this);
}
|
[
"public",
"function",
"setHelperSet",
"(",
"HelperSet",
"$",
"helperSet",
")",
"{",
"parent",
"::",
"setHelperSet",
"(",
"$",
"helperSet",
")",
";",
"$",
"this",
"->",
"getHelper",
"(",
"'phpdocumentor_logger'",
")",
"->",
"addOptions",
"(",
"$",
"this",
")",
";",
"}"
] |
Registers the current command.
@param HelperSet $helperSet
|
[
"Registers",
"the",
"current",
"command",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Command.php#L32-L37
|
21,547 |
creolab/resources
|
src/Collection.php
|
Collection.toArray
|
public function toArray()
{
$response = array();
foreach ($this->items as $key => $item)
{
$response[] = $item->toArray();
}
return $response;
}
|
php
|
public function toArray()
{
$response = array();
foreach ($this->items as $key => $item)
{
$response[] = $item->toArray();
}
return $response;
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"response",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"response",
"[",
"]",
"=",
"$",
"item",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Return collection as array
@return array
|
[
"Return",
"collection",
"as",
"array"
] |
6e1bdd266aa373f6dafd2408b230f7d2fa05a637
|
https://github.com/creolab/resources/blob/6e1bdd266aa373f6dafd2408b230f7d2fa05a637/src/Collection.php#L29-L39
|
21,548 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.lOr
|
public function lOr()
{
$args = func_get_args();
if ( count( $args ) < 1 )
{
throw new ezcQueryVariableParameterException( 'lOr', count( $args ), 1 );
}
$elements = ezcQuerySelect::arrayFlatten( $args );
if ( count( $elements ) == 1 )
{
return $elements[0];
}
else
{
return '( ' . join( ' OR ', $elements ) . ' )';
}
}
|
php
|
public function lOr()
{
$args = func_get_args();
if ( count( $args ) < 1 )
{
throw new ezcQueryVariableParameterException( 'lOr', count( $args ), 1 );
}
$elements = ezcQuerySelect::arrayFlatten( $args );
if ( count( $elements ) == 1 )
{
return $elements[0];
}
else
{
return '( ' . join( ' OR ', $elements ) . ' )';
}
}
|
[
"public",
"function",
"lOr",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"ezcQueryVariableParameterException",
"(",
"'lOr'",
",",
"count",
"(",
"$",
"args",
")",
",",
"1",
")",
";",
"}",
"$",
"elements",
"=",
"ezcQuerySelect",
"::",
"arrayFlatten",
"(",
"$",
"args",
")",
";",
"if",
"(",
"count",
"(",
"$",
"elements",
")",
"==",
"1",
")",
"{",
"return",
"$",
"elements",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"'( '",
".",
"join",
"(",
"' OR '",
",",
"$",
"elements",
")",
".",
"' )'",
";",
"}",
"}"
] |
Returns the SQL to bind logical expressions together using a logical or.
lOr() accepts an arbitrary number of parameters. Each parameter
must contain a logical expression or an array with logical expressions.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$e = $q->expr;
$q->select( '*' )->from( 'table' )
->where( $e->lOr( $e->eq( 'id', $q->bindValue( 1 ) ),
$e->eq( 'id', $q->bindValue( 2 ) ) ) );
</code>
@throws ezcDbAbstractionException if called with no parameters.
@return string a logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"bind",
"logical",
"expressions",
"together",
"using",
"a",
"logical",
"or",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L222-L239
|
21,549 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.eq
|
public function eq( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} = {$value2}";
}
|
php
|
public function eq( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} = {$value2}";
}
|
[
"public",
"function",
"eq",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$value1} = {$value2}\"",
";",
"}"
] |
Returns the SQL to check if two values are equal.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->eq( 'id', $q->bindValue( 1 ) ) );
</code>
@param string $value1 logical expression to compare
@param string $value2 logical expression to compare with
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"two",
"values",
"are",
"equal",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L442-L447
|
21,550 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.neq
|
public function neq( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} <> {$value2}";
}
|
php
|
public function neq( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} <> {$value2}";
}
|
[
"public",
"function",
"neq",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$value1} <> {$value2}\"",
";",
"}"
] |
Returns the SQL to check if two values are unequal.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->neq( 'id', $q->bindValue( 1 ) ) );
</code>
@param string $value1 logical expression to compare
@param string $value2 logical expression to compare with
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"two",
"values",
"are",
"unequal",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L463-L468
|
21,551 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.gt
|
public function gt( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} > {$value2}";
}
|
php
|
public function gt( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} > {$value2}";
}
|
[
"public",
"function",
"gt",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$value1} > {$value2}\"",
";",
"}"
] |
Returns the SQL to check if one value is greater than another value.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->gt( 'id', $q->bindValue( 1 ) ) );
</code>
@param string $value1 logical expression to compare
@param string $value2 logical expression to compare with
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"one",
"value",
"is",
"greater",
"than",
"another",
"value",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L484-L489
|
21,552 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.gte
|
public function gte( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} >= {$value2}";
}
|
php
|
public function gte( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} >= {$value2}";
}
|
[
"public",
"function",
"gte",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$value1} >= {$value2}\"",
";",
"}"
] |
Returns the SQL to check if one value is greater than or equal to
another value.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->gte( 'id', $q->bindValue( 1 ) ) );
</code>
@param string $value1 logical expression to compare
@param string $value2 logical expression to compare with
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"one",
"value",
"is",
"greater",
"than",
"or",
"equal",
"to",
"another",
"value",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L506-L511
|
21,553 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.lt
|
public function lt( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} < {$value2}";
}
|
php
|
public function lt( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} < {$value2}";
}
|
[
"public",
"function",
"lt",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$value1} < {$value2}\"",
";",
"}"
] |
Returns the SQL to check if one value is less than another value.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->lt( 'id', $q->bindValue( 1 ) ) );
</code>
@param string $value1 logical expression to compare
@param string $value2 logical expression to compare with
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"one",
"value",
"is",
"less",
"than",
"another",
"value",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L527-L532
|
21,554 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.lte
|
public function lte( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} <= {$value2}";
}
|
php
|
public function lte( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$value1} <= {$value2}";
}
|
[
"public",
"function",
"lte",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$value1} <= {$value2}\"",
";",
"}"
] |
Returns the SQL to check if one value is less than or equal to
another value.
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->lte( 'id', $q->bindValue( 1 ) ) );
</code>
@param string $value1 logical expression to compare
@param string $value2 logical expression to compare with
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"one",
"value",
"is",
"less",
"than",
"or",
"equal",
"to",
"another",
"value",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L549-L554
|
21,555 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.between
|
public function between( $expression, $value1, $value2 )
{
$expression = $this->getIdentifier( $expression );
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$expression} BETWEEN {$value1} AND {$value2}";
}
|
php
|
public function between( $expression, $value1, $value2 )
{
$expression = $this->getIdentifier( $expression );
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "{$expression} BETWEEN {$value1} AND {$value2}";
}
|
[
"public",
"function",
"between",
"(",
"$",
"expression",
",",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"expression",
")",
";",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"{$expression} BETWEEN {$value1} AND {$value2}\"",
";",
"}"
] |
Returns SQL that checks if an expression evaluates to a value between
two values.
The parameter $expression is checked if it is between $value1 and $value2.
Note: There is a slight difference in the way BETWEEN works on some databases.
http://www.w3schools.com/sql/sql_between.asp. If you want complete database
independence you should avoid using between().
Example:
<code>
$q = ezcDbInstance::get()->createSelectQuery();
$q->select( '*' )->from( 'table' )
->where( $q->expr->between( 'id', $q->bindValue( 1 ), $q->bindValue( 5 ) ) );
</code>
@param string $expression the value to compare to
@param string $value1 the lower value to compare with
@param string $value2 the higher value to compare with
@return string logical expression
|
[
"Returns",
"SQL",
"that",
"checks",
"if",
"an",
"expression",
"evaluates",
"to",
"a",
"value",
"between",
"two",
"values",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L678-L684
|
21,556 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.bitAnd
|
public function bitAnd( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "( {$value1} & {$value2} )";
}
|
php
|
public function bitAnd( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "( {$value1} & {$value2} )";
}
|
[
"public",
"function",
"bitAnd",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"( {$value1} & {$value2} )\"",
";",
"}"
] |
Returns the SQL that performs the bitwise AND on two values.
@param string $value1
@param string $value2
@return string
|
[
"Returns",
"the",
"SQL",
"that",
"performs",
"the",
"bitwise",
"AND",
"on",
"two",
"values",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L948-L953
|
21,557 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php
|
ezcQueryExpression.bitOr
|
public function bitOr( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "( {$value1} | {$value2} )";
}
|
php
|
public function bitOr( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "( {$value1} | {$value2} )";
}
|
[
"public",
"function",
"bitOr",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"( {$value1} | {$value2} )\"",
";",
"}"
] |
Returns the SQL that performs the bitwise OR on two values.
@param string $value1
@param string $value2
@return string
|
[
"Returns",
"the",
"SQL",
"that",
"performs",
"the",
"bitwise",
"OR",
"on",
"two",
"values",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/expression.php#L962-L967
|
21,558 |
SergioMadness/query-builder
|
src/adapters/SQL/ConditionBuilder.php
|
ConditionBuilder.prepareArray
|
protected function prepareArray(array $conditions)
{
switch (count($conditions)) {
case 1:
$result = $conditions[0];
break;
case 2:
if (is_array($conditions[1])) {
$result = $conditions[0].' IN ('.implode(',', $conditions[1]).')';
} elseif (is_null($conditions[1])) {
$result = $conditions[0].' IS NULL';
} elseif ($conditions[1] instanceof \pwf\components\querybuilder\interfaces\SelectBuilder) {
$result = $conditions[0].' IN ('.$conditions[1]->generate().')';
$this->setParams(array_merge($this->getParams(),
$conditions[1]->getParams()));
} else {
$result = $conditions[0].'=?';//.$conditions[0];
$this->addParam($conditions[0], $conditions[1]);
}
break;
case 3:
$left = is_array($conditions[1]) ? $this->prepareConditions($conditions[1])
: $conditions[1];
$right = is_array($conditions[2]) ? $this->prepareConditions($conditions[2])
: $conditions[2];
$result = '(('.$left.') '.$conditions[0].' ('.$right.'))';
break;
default:
throw new \Exception('Wrong condition configuration');
}
return $result;
}
|
php
|
protected function prepareArray(array $conditions)
{
switch (count($conditions)) {
case 1:
$result = $conditions[0];
break;
case 2:
if (is_array($conditions[1])) {
$result = $conditions[0].' IN ('.implode(',', $conditions[1]).')';
} elseif (is_null($conditions[1])) {
$result = $conditions[0].' IS NULL';
} elseif ($conditions[1] instanceof \pwf\components\querybuilder\interfaces\SelectBuilder) {
$result = $conditions[0].' IN ('.$conditions[1]->generate().')';
$this->setParams(array_merge($this->getParams(),
$conditions[1]->getParams()));
} else {
$result = $conditions[0].'=?';//.$conditions[0];
$this->addParam($conditions[0], $conditions[1]);
}
break;
case 3:
$left = is_array($conditions[1]) ? $this->prepareConditions($conditions[1])
: $conditions[1];
$right = is_array($conditions[2]) ? $this->prepareConditions($conditions[2])
: $conditions[2];
$result = '(('.$left.') '.$conditions[0].' ('.$right.'))';
break;
default:
throw new \Exception('Wrong condition configuration');
}
return $result;
}
|
[
"protected",
"function",
"prepareArray",
"(",
"array",
"$",
"conditions",
")",
"{",
"switch",
"(",
"count",
"(",
"$",
"conditions",
")",
")",
"{",
"case",
"1",
":",
"$",
"result",
"=",
"$",
"conditions",
"[",
"0",
"]",
";",
"break",
";",
"case",
"2",
":",
"if",
"(",
"is_array",
"(",
"$",
"conditions",
"[",
"1",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"conditions",
"[",
"0",
"]",
".",
"' IN ('",
".",
"implode",
"(",
"','",
",",
"$",
"conditions",
"[",
"1",
"]",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"conditions",
"[",
"1",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"conditions",
"[",
"0",
"]",
".",
"' IS NULL'",
";",
"}",
"elseif",
"(",
"$",
"conditions",
"[",
"1",
"]",
"instanceof",
"\\",
"pwf",
"\\",
"components",
"\\",
"querybuilder",
"\\",
"interfaces",
"\\",
"SelectBuilder",
")",
"{",
"$",
"result",
"=",
"$",
"conditions",
"[",
"0",
"]",
".",
"' IN ('",
".",
"$",
"conditions",
"[",
"1",
"]",
"->",
"generate",
"(",
")",
".",
"')'",
";",
"$",
"this",
"->",
"setParams",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getParams",
"(",
")",
",",
"$",
"conditions",
"[",
"1",
"]",
"->",
"getParams",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"conditions",
"[",
"0",
"]",
".",
"'=?'",
";",
"//.$conditions[0];",
"$",
"this",
"->",
"addParam",
"(",
"$",
"conditions",
"[",
"0",
"]",
",",
"$",
"conditions",
"[",
"1",
"]",
")",
";",
"}",
"break",
";",
"case",
"3",
":",
"$",
"left",
"=",
"is_array",
"(",
"$",
"conditions",
"[",
"1",
"]",
")",
"?",
"$",
"this",
"->",
"prepareConditions",
"(",
"$",
"conditions",
"[",
"1",
"]",
")",
":",
"$",
"conditions",
"[",
"1",
"]",
";",
"$",
"right",
"=",
"is_array",
"(",
"$",
"conditions",
"[",
"2",
"]",
")",
"?",
"$",
"this",
"->",
"prepareConditions",
"(",
"$",
"conditions",
"[",
"2",
"]",
")",
":",
"$",
"conditions",
"[",
"2",
"]",
";",
"$",
"result",
"=",
"'(('",
".",
"$",
"left",
".",
"') '",
".",
"$",
"conditions",
"[",
"0",
"]",
".",
"' ('",
".",
"$",
"right",
".",
"'))'",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"'Wrong condition configuration'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Array to string
@param array $conditions
@return string
@throws \Exception
|
[
"Array",
"to",
"string"
] |
95b7a46bba4c4d369101c6f0d37f133fecb3956d
|
https://github.com/SergioMadness/query-builder/blob/95b7a46bba4c4d369101c6f0d37f133fecb3956d/src/adapters/SQL/ConditionBuilder.php#L17-L49
|
21,559 |
SporkCode/Spork
|
src/Mvc/Listener/EmailVerificationStrategy.php
|
EmailVerificationStrategy.checkEmailVerification
|
public function checkEmailVerification(MvcEvent $event)
{
$services = $event->getApplication()->getServiceManager();
$appConfig = $services->get('config');
$config = $this->defaultConfig;
if (array_key_exists(self::CONFIG_KEY, $appConfig)) {
$config = $appConfig[self::CONFIG_KEY] + $config;
}
// if (empty($config['routeParams'])) {
// throw new \Exception(sprintf(
// "Route parameters missing. Add \"array('%s' => array('routeParams' => array(PARAMETERS)))\" to your configuration",
// self::CONFIG_KEY));
// }
$routeMatch = $event->getRouteMatch();
if (in_array($routeMatch->getMatchedRouteName(), $config['routeBlacklist'])) {
return;
}
$auth = $services->get($config['authServiceName']);
if (!$auth->hasIdentity()) {
return;
}
$identity = $services->get($config['identityServiceName']);
$isVerified = $config['identityCheckType'] == 'property' ?
$identity->$config['identityCheck'] :
call_user_func(array($identity, $config['identityCheck']));
if ($isVerified) {
return;
}
//$routeMatch = new RouteMatch($config['routeParams']);
//$event->setRouteMatch($routeMatch);
return $services->get('controllerPluginManager')->get('redirect')->toRoute($config['route'], $config['routeParams']);
}
|
php
|
public function checkEmailVerification(MvcEvent $event)
{
$services = $event->getApplication()->getServiceManager();
$appConfig = $services->get('config');
$config = $this->defaultConfig;
if (array_key_exists(self::CONFIG_KEY, $appConfig)) {
$config = $appConfig[self::CONFIG_KEY] + $config;
}
// if (empty($config['routeParams'])) {
// throw new \Exception(sprintf(
// "Route parameters missing. Add \"array('%s' => array('routeParams' => array(PARAMETERS)))\" to your configuration",
// self::CONFIG_KEY));
// }
$routeMatch = $event->getRouteMatch();
if (in_array($routeMatch->getMatchedRouteName(), $config['routeBlacklist'])) {
return;
}
$auth = $services->get($config['authServiceName']);
if (!$auth->hasIdentity()) {
return;
}
$identity = $services->get($config['identityServiceName']);
$isVerified = $config['identityCheckType'] == 'property' ?
$identity->$config['identityCheck'] :
call_user_func(array($identity, $config['identityCheck']));
if ($isVerified) {
return;
}
//$routeMatch = new RouteMatch($config['routeParams']);
//$event->setRouteMatch($routeMatch);
return $services->get('controllerPluginManager')->get('redirect')->toRoute($config['route'], $config['routeParams']);
}
|
[
"public",
"function",
"checkEmailVerification",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"$",
"services",
"=",
"$",
"event",
"->",
"getApplication",
"(",
")",
"->",
"getServiceManager",
"(",
")",
";",
"$",
"appConfig",
"=",
"$",
"services",
"->",
"get",
"(",
"'config'",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"defaultConfig",
";",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"CONFIG_KEY",
",",
"$",
"appConfig",
")",
")",
"{",
"$",
"config",
"=",
"$",
"appConfig",
"[",
"self",
"::",
"CONFIG_KEY",
"]",
"+",
"$",
"config",
";",
"}",
"// if (empty($config['routeParams'])) {",
"// throw new \\Exception(sprintf(",
"// \"Route parameters missing. Add \\\"array('%s' => array('routeParams' => array(PARAMETERS)))\\\" to your configuration\", ",
"// self::CONFIG_KEY));",
"// }",
"$",
"routeMatch",
"=",
"$",
"event",
"->",
"getRouteMatch",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"routeMatch",
"->",
"getMatchedRouteName",
"(",
")",
",",
"$",
"config",
"[",
"'routeBlacklist'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"auth",
"=",
"$",
"services",
"->",
"get",
"(",
"$",
"config",
"[",
"'authServiceName'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"auth",
"->",
"hasIdentity",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"identity",
"=",
"$",
"services",
"->",
"get",
"(",
"$",
"config",
"[",
"'identityServiceName'",
"]",
")",
";",
"$",
"isVerified",
"=",
"$",
"config",
"[",
"'identityCheckType'",
"]",
"==",
"'property'",
"?",
"$",
"identity",
"->",
"$",
"config",
"[",
"'identityCheck'",
"]",
":",
"call_user_func",
"(",
"array",
"(",
"$",
"identity",
",",
"$",
"config",
"[",
"'identityCheck'",
"]",
")",
")",
";",
"if",
"(",
"$",
"isVerified",
")",
"{",
"return",
";",
"}",
"//$routeMatch = new RouteMatch($config['routeParams']);",
"//$event->setRouteMatch($routeMatch);",
"return",
"$",
"services",
"->",
"get",
"(",
"'controllerPluginManager'",
")",
"->",
"get",
"(",
"'redirect'",
")",
"->",
"toRoute",
"(",
"$",
"config",
"[",
"'route'",
"]",
",",
"$",
"config",
"[",
"'routeParams'",
"]",
")",
";",
"}"
] |
Check if the email address is verified and if not redirects to a
specified route.
@param MvcEvent $event
|
[
"Check",
"if",
"the",
"email",
"address",
"is",
"verified",
"and",
"if",
"not",
"redirects",
"to",
"a",
"specified",
"route",
"."
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/EmailVerificationStrategy.php#L60-L98
|
21,560 |
ekuiter/feature-php
|
FeaturePhp/Specification/DirectorySpecification.php
|
DirectorySpecification.fromArrayAndSettings
|
public static function fromArrayAndSettings($cfg, $settings) {
$directorySpecification = new self($cfg, $settings->getDirectory());
$directorySpecification->set("source", $settings->getPath($directorySpecification->getSource()));
$directorySpecification->set("baseTarget", $settings->getOptional("target", null));
if (!is_dir($directorySpecification->getSource()))
throw new DirectorySpecificationException("directory \"{$directorySpecification->getSource()}\" does not exist");
return $directorySpecification;
}
|
php
|
public static function fromArrayAndSettings($cfg, $settings) {
$directorySpecification = new self($cfg, $settings->getDirectory());
$directorySpecification->set("source", $settings->getPath($directorySpecification->getSource()));
$directorySpecification->set("baseTarget", $settings->getOptional("target", null));
if (!is_dir($directorySpecification->getSource()))
throw new DirectorySpecificationException("directory \"{$directorySpecification->getSource()}\" does not exist");
return $directorySpecification;
}
|
[
"public",
"static",
"function",
"fromArrayAndSettings",
"(",
"$",
"cfg",
",",
"$",
"settings",
")",
"{",
"$",
"directorySpecification",
"=",
"new",
"self",
"(",
"$",
"cfg",
",",
"$",
"settings",
"->",
"getDirectory",
"(",
")",
")",
";",
"$",
"directorySpecification",
"->",
"set",
"(",
"\"source\"",
",",
"$",
"settings",
"->",
"getPath",
"(",
"$",
"directorySpecification",
"->",
"getSource",
"(",
")",
")",
")",
";",
"$",
"directorySpecification",
"->",
"set",
"(",
"\"baseTarget\"",
",",
"$",
"settings",
"->",
"getOptional",
"(",
"\"target\"",
",",
"null",
")",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directorySpecification",
"->",
"getSource",
"(",
")",
")",
")",
"throw",
"new",
"DirectorySpecificationException",
"(",
"\"directory \\\"{$directorySpecification->getSource()}\\\" does not exist\"",
")",
";",
"return",
"$",
"directorySpecification",
";",
"}"
] |
Creates a directory specification from a plain settings array.
The settings context is taken into consideration to generate paths
relative to the settings.
@param array $cfg a plain settings array
@param \FeaturePhp\Settings $settings the settings context
@return DirectorySpecification
|
[
"Creates",
"a",
"directory",
"specification",
"from",
"a",
"plain",
"settings",
"array",
".",
"The",
"settings",
"context",
"is",
"taken",
"into",
"consideration",
"to",
"generate",
"paths",
"relative",
"to",
"the",
"settings",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Specification/DirectorySpecification.php#L48-L57
|
21,561 |
ekuiter/feature-php
|
FeaturePhp/Specification/DirectorySpecification.php
|
DirectorySpecification.getFileSpecifications
|
public function getFileSpecifications() {
$fileSpecifications = array();
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getSource())) as $entry)
if (!fphp\Helper\Path::isDot($entry)) {
$fileSource = $entry->getPathName();
if (is_link($fileSource))
continue;
$relativeFileTarget = fphp\Helper\Path::stripBase(
realpath($fileSource), realpath($this->getSource()));
foreach ($this->getExclude() as $exclude) {
if ($relativeFileTarget === $exclude)
continue 2;
$parts = explode("/", $exclude);
if ($parts[count($parts) - 1] === "*")
try {
fphp\Helper\Path::stripBase($relativeFileTarget, implode("/", array_slice($parts, 0, count($parts) - 1)));
continue 2;
} catch (fphp\Helper\PathException $e) {}
}
$fileTarget = fphp\Helper\Path::join(
$this->get("baseTarget"), fphp\Helper\Path::join($this->getTarget(), $relativeFileTarget));
$fileSpecifications[] = new FileSpecification(
array("source" => $fileSource, "target" => $fileTarget), $this->getDirectory());
}
return $fileSpecifications;
}
|
php
|
public function getFileSpecifications() {
$fileSpecifications = array();
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getSource())) as $entry)
if (!fphp\Helper\Path::isDot($entry)) {
$fileSource = $entry->getPathName();
if (is_link($fileSource))
continue;
$relativeFileTarget = fphp\Helper\Path::stripBase(
realpath($fileSource), realpath($this->getSource()));
foreach ($this->getExclude() as $exclude) {
if ($relativeFileTarget === $exclude)
continue 2;
$parts = explode("/", $exclude);
if ($parts[count($parts) - 1] === "*")
try {
fphp\Helper\Path::stripBase($relativeFileTarget, implode("/", array_slice($parts, 0, count($parts) - 1)));
continue 2;
} catch (fphp\Helper\PathException $e) {}
}
$fileTarget = fphp\Helper\Path::join(
$this->get("baseTarget"), fphp\Helper\Path::join($this->getTarget(), $relativeFileTarget));
$fileSpecifications[] = new FileSpecification(
array("source" => $fileSource, "target" => $fileTarget), $this->getDirectory());
}
return $fileSpecifications;
}
|
[
"public",
"function",
"getFileSpecifications",
"(",
")",
"{",
"$",
"fileSpecifications",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"this",
"->",
"getSource",
"(",
")",
")",
")",
"as",
"$",
"entry",
")",
"if",
"(",
"!",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"isDot",
"(",
"$",
"entry",
")",
")",
"{",
"$",
"fileSource",
"=",
"$",
"entry",
"->",
"getPathName",
"(",
")",
";",
"if",
"(",
"is_link",
"(",
"$",
"fileSource",
")",
")",
"continue",
";",
"$",
"relativeFileTarget",
"=",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"stripBase",
"(",
"realpath",
"(",
"$",
"fileSource",
")",
",",
"realpath",
"(",
"$",
"this",
"->",
"getSource",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getExclude",
"(",
")",
"as",
"$",
"exclude",
")",
"{",
"if",
"(",
"$",
"relativeFileTarget",
"===",
"$",
"exclude",
")",
"continue",
"2",
";",
"$",
"parts",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"exclude",
")",
";",
"if",
"(",
"$",
"parts",
"[",
"count",
"(",
"$",
"parts",
")",
"-",
"1",
"]",
"===",
"\"*\"",
")",
"try",
"{",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"stripBase",
"(",
"$",
"relativeFileTarget",
",",
"implode",
"(",
"\"/\"",
",",
"array_slice",
"(",
"$",
"parts",
",",
"0",
",",
"count",
"(",
"$",
"parts",
")",
"-",
"1",
")",
")",
")",
";",
"continue",
"2",
";",
"}",
"catch",
"(",
"fphp",
"\\",
"Helper",
"\\",
"PathException",
"$",
"e",
")",
"{",
"}",
"}",
"$",
"fileTarget",
"=",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"join",
"(",
"$",
"this",
"->",
"get",
"(",
"\"baseTarget\"",
")",
",",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"join",
"(",
"$",
"this",
"->",
"getTarget",
"(",
")",
",",
"$",
"relativeFileTarget",
")",
")",
";",
"$",
"fileSpecifications",
"[",
"]",
"=",
"new",
"FileSpecification",
"(",
"array",
"(",
"\"source\"",
"=>",
"$",
"fileSource",
",",
"\"target\"",
"=>",
"$",
"fileTarget",
")",
",",
"$",
"this",
"->",
"getDirectory",
"(",
")",
")",
";",
"}",
"return",
"$",
"fileSpecifications",
";",
"}"
] |
Returns the file specifications this directory specification applies to.
The entire source directory tree is considered, except for excluded files.
@return FileSpecification[]
|
[
"Returns",
"the",
"file",
"specifications",
"this",
"directory",
"specification",
"applies",
"to",
".",
"The",
"entire",
"source",
"directory",
"tree",
"is",
"considered",
"except",
"for",
"excluded",
"files",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Specification/DirectorySpecification.php#L73-L102
|
21,562 |
bit3archive/php-remote-objects
|
src/RemoteObjects/Client.php
|
Client.getRemoteObject
|
public function getRemoteObject($key, $interface = null)
{
if ($interface) {
if (
$this->logger !== null &&
$this->logger->isHandling(\Monolog\Logger::DEBUG)
) {
$this->logger->addDebug(
'Create new virtual remote object proxy',
array(
'interface' => $interface,
'path' => $key
)
);
}
return RemoteObjectProxyGenerator::generate($this, $interface, $key);
}
else {
if (
$this->logger !== null &&
$this->logger->isHandling(\Monolog\Logger::DEBUG)
) {
$this->logger->addDebug(
'Get remote object proxy',
array(
'path' => $key
)
);
}
return new RemoteObjectProxy($this, $key);
}
}
|
php
|
public function getRemoteObject($key, $interface = null)
{
if ($interface) {
if (
$this->logger !== null &&
$this->logger->isHandling(\Monolog\Logger::DEBUG)
) {
$this->logger->addDebug(
'Create new virtual remote object proxy',
array(
'interface' => $interface,
'path' => $key
)
);
}
return RemoteObjectProxyGenerator::generate($this, $interface, $key);
}
else {
if (
$this->logger !== null &&
$this->logger->isHandling(\Monolog\Logger::DEBUG)
) {
$this->logger->addDebug(
'Get remote object proxy',
array(
'path' => $key
)
);
}
return new RemoteObjectProxy($this, $key);
}
}
|
[
"public",
"function",
"getRemoteObject",
"(",
"$",
"key",
",",
"$",
"interface",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"interface",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
"!==",
"null",
"&&",
"$",
"this",
"->",
"logger",
"->",
"isHandling",
"(",
"\\",
"Monolog",
"\\",
"Logger",
"::",
"DEBUG",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addDebug",
"(",
"'Create new virtual remote object proxy'",
",",
"array",
"(",
"'interface'",
"=>",
"$",
"interface",
",",
"'path'",
"=>",
"$",
"key",
")",
")",
";",
"}",
"return",
"RemoteObjectProxyGenerator",
"::",
"generate",
"(",
"$",
"this",
",",
"$",
"interface",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
"!==",
"null",
"&&",
"$",
"this",
"->",
"logger",
"->",
"isHandling",
"(",
"\\",
"Monolog",
"\\",
"Logger",
"::",
"DEBUG",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addDebug",
"(",
"'Get remote object proxy'",
",",
"array",
"(",
"'path'",
"=>",
"$",
"key",
")",
")",
";",
"}",
"return",
"new",
"RemoteObjectProxy",
"(",
"$",
"this",
",",
"$",
"key",
")",
";",
"}",
"}"
] |
Get a named remote object proxy.
@param string $key
@param string|null $interface
@return RemoteObject
|
[
"Get",
"a",
"named",
"remote",
"object",
"proxy",
"."
] |
0a917cdb261d83b1e89bdbdce3627584823bff5f
|
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Client.php#L128-L161
|
21,563 |
neat-php/database
|
classes/Query.php
|
Query.join
|
public function join($table, $alias = null, $on = null, $type = 'INNER JOIN')
{
$table = $this->connection->quoteIdentifier($table);
$this->joins[$alias] = "$type $table $alias ON $on";
return $this;
}
|
php
|
public function join($table, $alias = null, $on = null, $type = 'INNER JOIN')
{
$table = $this->connection->quoteIdentifier($table);
$this->joins[$alias] = "$type $table $alias ON $on";
return $this;
}
|
[
"public",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"on",
"=",
"null",
",",
"$",
"type",
"=",
"'INNER JOIN'",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"connection",
"->",
"quoteIdentifier",
"(",
"$",
"table",
")",
";",
"$",
"this",
"->",
"joins",
"[",
"$",
"alias",
"]",
"=",
"\"$type $table $alias ON $on\"",
";",
"return",
"$",
"this",
";",
"}"
] |
Join a table
@param string $table
@param string $alias
@param string $on
@param string $type
@return $this
|
[
"Join",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L235-L242
|
21,564 |
neat-php/database
|
classes/Query.php
|
Query.leftJoin
|
public function leftJoin($table, $alias = null, $on = null)
{
return $this->join($table, $alias, $on, 'LEFT JOIN');
}
|
php
|
public function leftJoin($table, $alias = null, $on = null)
{
return $this->join($table, $alias, $on, 'LEFT JOIN');
}
|
[
"public",
"function",
"leftJoin",
"(",
"$",
"table",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"on",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"alias",
",",
"$",
"on",
",",
"'LEFT JOIN'",
")",
";",
"}"
] |
LEFT OUTER Join a table
@param string $table
@param string $alias
@param string $on
@return $this
|
[
"LEFT",
"OUTER",
"Join",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L252-L255
|
21,565 |
neat-php/database
|
classes/Query.php
|
Query.rightJoin
|
public function rightJoin($table, $alias = null, $on = null)
{
return $this->join($table, $alias, $on, 'RIGHT JOIN');
}
|
php
|
public function rightJoin($table, $alias = null, $on = null)
{
return $this->join($table, $alias, $on, 'RIGHT JOIN');
}
|
[
"public",
"function",
"rightJoin",
"(",
"$",
"table",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"on",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"alias",
",",
"$",
"on",
",",
"'RIGHT JOIN'",
")",
";",
"}"
] |
RIGHT OUTER Join a table
@param string $table
@param string $alias
@param string $on
@return $this
|
[
"RIGHT",
"OUTER",
"Join",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L265-L268
|
21,566 |
neat-php/database
|
classes/Query.php
|
Query.innerJoin
|
public function innerJoin($table, $alias = null, $on = null)
{
return $this->join($table, $alias, $on, 'INNER JOIN');
}
|
php
|
public function innerJoin($table, $alias = null, $on = null)
{
return $this->join($table, $alias, $on, 'INNER JOIN');
}
|
[
"public",
"function",
"innerJoin",
"(",
"$",
"table",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"on",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"alias",
",",
"$",
"on",
",",
"'INNER JOIN'",
")",
";",
"}"
] |
INNER Join a table
@param string $table
@param string $alias
@param string $on
@return $this
|
[
"INNER",
"Join",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L278-L281
|
21,567 |
neat-php/database
|
classes/Query.php
|
Query.getLimit
|
public function getLimit()
{
if ($this->offset && $this->limit) {
return $this->offset . ',' . $this->limit;
}
return (string)$this->limit;
}
|
php
|
public function getLimit()
{
if ($this->offset && $this->limit) {
return $this->offset . ',' . $this->limit;
}
return (string)$this->limit;
}
|
[
"public",
"function",
"getLimit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offset",
"&&",
"$",
"this",
"->",
"limit",
")",
"{",
"return",
"$",
"this",
"->",
"offset",
".",
"','",
".",
"$",
"this",
"->",
"limit",
";",
"}",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"limit",
";",
"}"
] |
Get limit query part
@return string
|
[
"Get",
"limit",
"query",
"part"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L521-L528
|
21,568 |
neat-php/database
|
classes/Query.php
|
Query.getSelectQuery
|
public function getSelectQuery()
{
$sql = 'SELECT ' . $this->getSelect();
$sql .= "\nFROM " . $this->getFrom();
if ($this->where) {
$sql .= "\nWHERE " . $this->getWhere();
}
if ($this->groupBy) {
$sql .= "\nGROUP BY " . $this->getGroupBy();
}
if ($this->having) {
$sql .= "\nHAVING " . $this->getHaving();
}
if ($this->orderBy) {
$sql .= "\nORDER BY " . $this->getOrderBy();
}
if ($this->limit) {
$sql .= "\nLIMIT " . $this->getLimit();
}
return $sql;
}
|
php
|
public function getSelectQuery()
{
$sql = 'SELECT ' . $this->getSelect();
$sql .= "\nFROM " . $this->getFrom();
if ($this->where) {
$sql .= "\nWHERE " . $this->getWhere();
}
if ($this->groupBy) {
$sql .= "\nGROUP BY " . $this->getGroupBy();
}
if ($this->having) {
$sql .= "\nHAVING " . $this->getHaving();
}
if ($this->orderBy) {
$sql .= "\nORDER BY " . $this->getOrderBy();
}
if ($this->limit) {
$sql .= "\nLIMIT " . $this->getLimit();
}
return $sql;
}
|
[
"public",
"function",
"getSelectQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"'SELECT '",
".",
"$",
"this",
"->",
"getSelect",
"(",
")",
";",
"$",
"sql",
".=",
"\"\\nFROM \"",
".",
"$",
"this",
"->",
"getFrom",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"where",
")",
"{",
"$",
"sql",
".=",
"\"\\nWHERE \"",
".",
"$",
"this",
"->",
"getWhere",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"groupBy",
")",
"{",
"$",
"sql",
".=",
"\"\\nGROUP BY \"",
".",
"$",
"this",
"->",
"getGroupBy",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"having",
")",
"{",
"$",
"sql",
".=",
"\"\\nHAVING \"",
".",
"$",
"this",
"->",
"getHaving",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"orderBy",
")",
"{",
"$",
"sql",
".=",
"\"\\nORDER BY \"",
".",
"$",
"this",
"->",
"getOrderBy",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"limit",
")",
"{",
"$",
"sql",
".=",
"\"\\nLIMIT \"",
".",
"$",
"this",
"->",
"getLimit",
"(",
")",
";",
"}",
"return",
"$",
"sql",
";",
"}"
] |
Get SQL select query
@return string
|
[
"Get",
"SQL",
"select",
"query"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L535-L556
|
21,569 |
neat-php/database
|
classes/Query.php
|
Query.getInsertQuery
|
public function getInsertQuery()
{
$sql = 'INSERT INTO ' . $this->getTable();
$sql .= "\n" . $this->getColumns();
$sql .= "\nVALUES " . $this->getValues();
return $sql;
}
|
php
|
public function getInsertQuery()
{
$sql = 'INSERT INTO ' . $this->getTable();
$sql .= "\n" . $this->getColumns();
$sql .= "\nVALUES " . $this->getValues();
return $sql;
}
|
[
"public",
"function",
"getInsertQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"'INSERT INTO '",
".",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"sql",
".=",
"\"\\n\"",
".",
"$",
"this",
"->",
"getColumns",
"(",
")",
";",
"$",
"sql",
".=",
"\"\\nVALUES \"",
".",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"return",
"$",
"sql",
";",
"}"
] |
Get SQL insert query
@return string
|
[
"Get",
"SQL",
"insert",
"query"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L563-L570
|
21,570 |
neat-php/database
|
classes/Query.php
|
Query.getUpdateQuery
|
public function getUpdateQuery()
{
$sql = 'UPDATE ' . $this->getTable();
$sql .= "\nSET " . $this->getSet();
if ($this->where) {
$sql .= "\nWHERE " . $this->getWhere();
}
if ($this->orderBy) {
$sql .= "\nORDER BY " . $this->getOrderBy();
}
if ($this->limit) {
$sql .= "\nLIMIT " . $this->getLimit();
}
return $sql;
}
|
php
|
public function getUpdateQuery()
{
$sql = 'UPDATE ' . $this->getTable();
$sql .= "\nSET " . $this->getSet();
if ($this->where) {
$sql .= "\nWHERE " . $this->getWhere();
}
if ($this->orderBy) {
$sql .= "\nORDER BY " . $this->getOrderBy();
}
if ($this->limit) {
$sql .= "\nLIMIT " . $this->getLimit();
}
return $sql;
}
|
[
"public",
"function",
"getUpdateQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"'UPDATE '",
".",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"sql",
".=",
"\"\\nSET \"",
".",
"$",
"this",
"->",
"getSet",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"where",
")",
"{",
"$",
"sql",
".=",
"\"\\nWHERE \"",
".",
"$",
"this",
"->",
"getWhere",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"orderBy",
")",
"{",
"$",
"sql",
".=",
"\"\\nORDER BY \"",
".",
"$",
"this",
"->",
"getOrderBy",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"limit",
")",
"{",
"$",
"sql",
".=",
"\"\\nLIMIT \"",
".",
"$",
"this",
"->",
"getLimit",
"(",
")",
";",
"}",
"return",
"$",
"sql",
";",
"}"
] |
Get SQL update query
@return string
|
[
"Get",
"SQL",
"update",
"query"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L577-L592
|
21,571 |
neat-php/database
|
classes/Query.php
|
Query.getDeleteQuery
|
public function getDeleteQuery()
{
$sql = 'DELETE FROM ' . $this->getTable();
if ($this->where) {
$sql .= "\nWHERE " . $this->getWhere();
}
if ($this->limit) {
$sql .= "\nLIMIT " . $this->getLimit();
}
return $sql;
}
|
php
|
public function getDeleteQuery()
{
$sql = 'DELETE FROM ' . $this->getTable();
if ($this->where) {
$sql .= "\nWHERE " . $this->getWhere();
}
if ($this->limit) {
$sql .= "\nLIMIT " . $this->getLimit();
}
return $sql;
}
|
[
"public",
"function",
"getDeleteQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"'DELETE FROM '",
".",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"where",
")",
"{",
"$",
"sql",
".=",
"\"\\nWHERE \"",
".",
"$",
"this",
"->",
"getWhere",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"limit",
")",
"{",
"$",
"sql",
".=",
"\"\\nLIMIT \"",
".",
"$",
"this",
"->",
"getLimit",
"(",
")",
";",
"}",
"return",
"$",
"sql",
";",
"}"
] |
Get SQL delete query
@return string
|
[
"Get",
"SQL",
"delete",
"query"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Query.php#L599-L610
|
21,572 |
m4grio/bangkok-insurance-php
|
src/Client/BeansTrait.php
|
BeansTrait.mergeParams
|
public function mergeParams($method, Array $params = [])
{
$newParams = [];
$preparedParams = $this->defaultParams;
$preparedParams['bean'] = $params;
$newParams[$method] = $preparedParams;
return $newParams;
}
|
php
|
public function mergeParams($method, Array $params = [])
{
$newParams = [];
$preparedParams = $this->defaultParams;
$preparedParams['bean'] = $params;
$newParams[$method] = $preparedParams;
return $newParams;
}
|
[
"public",
"function",
"mergeParams",
"(",
"$",
"method",
",",
"Array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"newParams",
"=",
"[",
"]",
";",
"$",
"preparedParams",
"=",
"$",
"this",
"->",
"defaultParams",
";",
"$",
"preparedParams",
"[",
"'bean'",
"]",
"=",
"$",
"params",
";",
"$",
"newParams",
"[",
"$",
"method",
"]",
"=",
"$",
"preparedParams",
";",
"return",
"$",
"newParams",
";",
"}"
] |
Group params in a bean
@param $method
@param array $params
@return array
|
[
"Group",
"params",
"in",
"a",
"bean"
] |
400266d043abe6b7cacb9da36064cbb169149c2a
|
https://github.com/m4grio/bangkok-insurance-php/blob/400266d043abe6b7cacb9da36064cbb169149c2a/src/Client/BeansTrait.php#L28-L37
|
21,573 |
i-lateral/silverstripe-modeladminplus
|
src/SearchContext.php
|
SearchContext.getSearchFields
|
public function getSearchFields()
{
$fields = parent::getSearchFields();
$class = $this->modelClass;
$use_autocomplete = $this->getConvertToAutocomplete();
$db = Config::inst()->get($class, "db");
$has_one = Config::inst()->get($class, "has_one");
$has_many = Config::inst()->get($class, "has_many");
$many_many = Config::inst()->get($class, "many_many");
$belongs_many_many = Config::inst()->get($class, "belongs_many_many");
$associations = array_merge(
$has_one,
$has_many,
$many_many,
$belongs_many_many
);
// Change currently scaffolded query fields to use conventional
// field names
/*foreach ($fields as $field) {
$field_class = $this->modelClass;
$name = $field->getName();
$title = $field->Title();
$db_field = $name;
$in_db = false;
// Find any text fields an replace with autocomplete fields
if (ClassInfo::class_name($field) == TextField::class && $use_autocomplete) {
// If this is a relation, switch class name
if (strpos($name, "__")) {
$parts = explode("__", $db_field);
$field_class = isset($associations[$parts[0]]) ? $associations[$parts[0]] : null;
$db_field = $parts[1];
$in_db = ($field_class) ? true : false;
}
// If this is in the DB (not casted)
if (in_array($db_field, array_keys($db))) {
$in_db = true;
}
if ($in_db) {
$fields->replaceField(
$name,
$field = AutoCompleteField::create(
$name,
$title,
$field->Value(),
$field_class,
$db_field
)->setDisplayField($db_field)
->setLabelField($db_field)
->setStoredField($db_field)
);
}
}
$field->setName($name);
}*/
return $fields;
}
|
php
|
public function getSearchFields()
{
$fields = parent::getSearchFields();
$class = $this->modelClass;
$use_autocomplete = $this->getConvertToAutocomplete();
$db = Config::inst()->get($class, "db");
$has_one = Config::inst()->get($class, "has_one");
$has_many = Config::inst()->get($class, "has_many");
$many_many = Config::inst()->get($class, "many_many");
$belongs_many_many = Config::inst()->get($class, "belongs_many_many");
$associations = array_merge(
$has_one,
$has_many,
$many_many,
$belongs_many_many
);
// Change currently scaffolded query fields to use conventional
// field names
/*foreach ($fields as $field) {
$field_class = $this->modelClass;
$name = $field->getName();
$title = $field->Title();
$db_field = $name;
$in_db = false;
// Find any text fields an replace with autocomplete fields
if (ClassInfo::class_name($field) == TextField::class && $use_autocomplete) {
// If this is a relation, switch class name
if (strpos($name, "__")) {
$parts = explode("__", $db_field);
$field_class = isset($associations[$parts[0]]) ? $associations[$parts[0]] : null;
$db_field = $parts[1];
$in_db = ($field_class) ? true : false;
}
// If this is in the DB (not casted)
if (in_array($db_field, array_keys($db))) {
$in_db = true;
}
if ($in_db) {
$fields->replaceField(
$name,
$field = AutoCompleteField::create(
$name,
$title,
$field->Value(),
$field_class,
$db_field
)->setDisplayField($db_field)
->setLabelField($db_field)
->setStoredField($db_field)
);
}
}
$field->setName($name);
}*/
return $fields;
}
|
[
"public",
"function",
"getSearchFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getSearchFields",
"(",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"modelClass",
";",
"$",
"use_autocomplete",
"=",
"$",
"this",
"->",
"getConvertToAutocomplete",
"(",
")",
";",
"$",
"db",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"\"db\"",
")",
";",
"$",
"has_one",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"\"has_one\"",
")",
";",
"$",
"has_many",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"\"has_many\"",
")",
";",
"$",
"many_many",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"\"many_many\"",
")",
";",
"$",
"belongs_many_many",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"\"belongs_many_many\"",
")",
";",
"$",
"associations",
"=",
"array_merge",
"(",
"$",
"has_one",
",",
"$",
"has_many",
",",
"$",
"many_many",
",",
"$",
"belongs_many_many",
")",
";",
"// Change currently scaffolded query fields to use conventional",
"// field names",
"/*foreach ($fields as $field) {\n $field_class = $this->modelClass;\n $name = $field->getName();\n $title = $field->Title();\n $db_field = $name;\n $in_db = false;\n\n // Find any text fields an replace with autocomplete fields\n if (ClassInfo::class_name($field) == TextField::class && $use_autocomplete) {\n // If this is a relation, switch class name\n if (strpos($name, \"__\")) {\n $parts = explode(\"__\", $db_field);\n $field_class = isset($associations[$parts[0]]) ? $associations[$parts[0]] : null;\n $db_field = $parts[1];\n $in_db = ($field_class) ? true : false;\n }\n\n // If this is in the DB (not casted)\n if (in_array($db_field, array_keys($db))) {\n $in_db = true;\n }\n\n if ($in_db) {\n $fields->replaceField(\n $name,\n $field = AutoCompleteField::create(\n $name,\n $title,\n $field->Value(),\n $field_class,\n $db_field\n )->setDisplayField($db_field)\n ->setLabelField($db_field)\n ->setStoredField($db_field)\n );\n }\n }\n\n $field->setName($name);\n }*/",
"return",
"$",
"fields",
";",
"}"
] |
Extend default search fields and add extra functionality.
@return \SilverStripe\Forms\FieldList
|
[
"Extend",
"default",
"search",
"fields",
"and",
"add",
"extra",
"functionality",
"."
] |
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
|
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/SearchContext.php#L25-L87
|
21,574 |
nabab/bbn
|
src/bbn/file/ftp.php
|
ftp.scan
|
public function scan(string $dir, string $type = null, &$res = [], int $timeout = 0): array
{
$res = [];
if ( $dirs = $this->listFiles($dir) ){
foreach ( $dirs as $d ){
if ( $type &&
(strpos($type, 'file') === 0) &&
!isset($d['num']) ){
$res[] = $d['name'];
}
else if ( $type &&
((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) &&
isset($d['num']) ){
$res[] = $d['name'];
}
else{
$res[] = $d['name'];
}
if ( isset($d['num']) ){
$this->scan($d['name'], $type, $res);
}
}
}
return $res;
}
|
php
|
public function scan(string $dir, string $type = null, &$res = [], int $timeout = 0): array
{
$res = [];
if ( $dirs = $this->listFiles($dir) ){
foreach ( $dirs as $d ){
if ( $type &&
(strpos($type, 'file') === 0) &&
!isset($d['num']) ){
$res[] = $d['name'];
}
else if ( $type &&
((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) &&
isset($d['num']) ){
$res[] = $d['name'];
}
else{
$res[] = $d['name'];
}
if ( isset($d['num']) ){
$this->scan($d['name'], $type, $res);
}
}
}
return $res;
}
|
[
"public",
"function",
"scan",
"(",
"string",
"$",
"dir",
",",
"string",
"$",
"type",
"=",
"null",
",",
"&",
"$",
"res",
"=",
"[",
"]",
",",
"int",
"$",
"timeout",
"=",
"0",
")",
":",
"array",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"dirs",
"=",
"$",
"this",
"->",
"listFiles",
"(",
"$",
"dir",
")",
")",
"{",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"d",
")",
"{",
"if",
"(",
"$",
"type",
"&&",
"(",
"strpos",
"(",
"$",
"type",
",",
"'file'",
")",
"===",
"0",
")",
"&&",
"!",
"isset",
"(",
"$",
"d",
"[",
"'num'",
"]",
")",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"d",
"[",
"'name'",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"&&",
"(",
"(",
"strpos",
"(",
"$",
"type",
",",
"'dir'",
")",
"===",
"0",
")",
"||",
"(",
"strpos",
"(",
"$",
"type",
",",
"'fold'",
")",
"===",
"0",
")",
")",
"&&",
"isset",
"(",
"$",
"d",
"[",
"'num'",
"]",
")",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"d",
"[",
"'name'",
"]",
";",
"}",
"else",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"d",
"[",
"'name'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"d",
"[",
"'num'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"scan",
"(",
"$",
"d",
"[",
"'name'",
"]",
",",
"$",
"type",
",",
"$",
"res",
")",
";",
"}",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] |
Scans all the content from a directory, including the subdirectories
<code>
bbn\file\dir::scan("/home/me");
bbn\file\dir::delete("C:\Documents\Test");
</code>
@param string $dir The directory path.
@param string $type The type of item to return ('file', 'dir', default is both)
@return array
|
[
"Scans",
"all",
"the",
"content",
"from",
"a",
"directory",
"including",
"the",
"subdirectories"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/ftp.php#L164-L188
|
21,575 |
nabab/bbn
|
src/bbn/file/ftp.php
|
ftp.delete
|
public function delete($item){
self::log('delete:'.$item);
if ( $this->checkFilePath($item) &&
ftp_delete($this->cn,$item) ){
return true;
}
return false;
}
|
php
|
public function delete($item){
self::log('delete:'.$item);
if ( $this->checkFilePath($item) &&
ftp_delete($this->cn,$item) ){
return true;
}
return false;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"item",
")",
"{",
"self",
"::",
"log",
"(",
"'delete:'",
".",
"$",
"item",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkFilePath",
"(",
"$",
"item",
")",
"&&",
"ftp_delete",
"(",
"$",
"this",
"->",
"cn",
",",
"$",
"item",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Deletes a file from the server
@return boolean
|
[
"Deletes",
"a",
"file",
"from",
"the",
"server"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/ftp.php#L323-L330
|
21,576 |
nabab/bbn
|
src/bbn/file/ftp.php
|
ftp.put
|
public function put($src, $dest){
if ( file_exists($src) &&
($dest = $this->checkFilePath($dest)) &&
ftp_put($this->cn,$dest,$src,FTP_BINARY) ){
return true;
}
return false;
}
|
php
|
public function put($src, $dest){
if ( file_exists($src) &&
($dest = $this->checkFilePath($dest)) &&
ftp_put($this->cn,$dest,$src,FTP_BINARY) ){
return true;
}
return false;
}
|
[
"public",
"function",
"put",
"(",
"$",
"src",
",",
"$",
"dest",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"src",
")",
"&&",
"(",
"$",
"dest",
"=",
"$",
"this",
"->",
"checkFilePath",
"(",
"$",
"dest",
")",
")",
"&&",
"ftp_put",
"(",
"$",
"this",
"->",
"cn",
",",
"$",
"dest",
",",
"$",
"src",
",",
"FTP_BINARY",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Puts a file on the server
@return boolean
|
[
"Puts",
"a",
"file",
"on",
"the",
"server"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/ftp.php#L337-L344
|
21,577 |
nabab/bbn
|
src/bbn/file/ftp.php
|
ftp.get
|
public function get($src, $dest){
if ( $src = $this->checkFilePath($src) &&
ftp_get($this->cn, $dest, $src, FTP_BINARY) ){
return true;
}
return false;
}
|
php
|
public function get($src, $dest){
if ( $src = $this->checkFilePath($src) &&
ftp_get($this->cn, $dest, $src, FTP_BINARY) ){
return true;
}
return false;
}
|
[
"public",
"function",
"get",
"(",
"$",
"src",
",",
"$",
"dest",
")",
"{",
"if",
"(",
"$",
"src",
"=",
"$",
"this",
"->",
"checkFilePath",
"(",
"$",
"src",
")",
"&&",
"ftp_get",
"(",
"$",
"this",
"->",
"cn",
",",
"$",
"dest",
",",
"$",
"src",
",",
"FTP_BINARY",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Gets a file from the server
@return boolean
|
[
"Gets",
"a",
"file",
"from",
"the",
"server"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/ftp.php#L351-L357
|
21,578 |
nabab/bbn
|
src/bbn/file/ftp.php
|
ftp.move
|
public function move(string $old, string $new){
if (
!empty($old) &&
!empty($new) &&
($old = $this->checkFilePath($old)) &&
ftp_rename($this->cn, $old, $new)
){
return true;
}
return false;
}
|
php
|
public function move(string $old, string $new){
if (
!empty($old) &&
!empty($new) &&
($old = $this->checkFilePath($old)) &&
ftp_rename($this->cn, $old, $new)
){
return true;
}
return false;
}
|
[
"public",
"function",
"move",
"(",
"string",
"$",
"old",
",",
"string",
"$",
"new",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"old",
")",
"&&",
"!",
"empty",
"(",
"$",
"new",
")",
"&&",
"(",
"$",
"old",
"=",
"$",
"this",
"->",
"checkFilePath",
"(",
"$",
"old",
")",
")",
"&&",
"ftp_rename",
"(",
"$",
"this",
"->",
"cn",
",",
"$",
"old",
",",
"$",
"new",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Moves or renames a file on the server
@param string $old The old file full path
@param string $new The new file full path
@return bool
|
[
"Moves",
"or",
"renames",
"a",
"file",
"on",
"the",
"server"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/ftp.php#L373-L383
|
21,579 |
nabab/bbn
|
src/bbn/file/ftp.php
|
ftp.exists
|
public function exists(string $path){
if ( !empty($path) ){
$dir = dirname($path);
$ext = \bbn\str::file_ext($path);
$file = basename($path);
if ( \is_array($files = $this->listFiles($dir)) ){
foreach ( $files as $f ){
if ( $f['basename'] === $file ){
return true;
}
}
}
}
return false;
}
|
php
|
public function exists(string $path){
if ( !empty($path) ){
$dir = dirname($path);
$ext = \bbn\str::file_ext($path);
$file = basename($path);
if ( \is_array($files = $this->listFiles($dir)) ){
foreach ( $files as $f ){
if ( $f['basename'] === $file ){
return true;
}
}
}
}
return false;
}
|
[
"public",
"function",
"exists",
"(",
"string",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"$",
"ext",
"=",
"\\",
"bbn",
"\\",
"str",
"::",
"file_ext",
"(",
"$",
"path",
")",
";",
"$",
"file",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"files",
"=",
"$",
"this",
"->",
"listFiles",
"(",
"$",
"dir",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"$",
"f",
"[",
"'basename'",
"]",
"===",
"$",
"file",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if a file is present in a folder on the server
@param string $path The file or dir relative or full path
@return bool
|
[
"Checks",
"if",
"a",
"file",
"is",
"present",
"in",
"a",
"folder",
"on",
"the",
"server"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/ftp.php#L391-L405
|
21,580 |
j-d/draggy
|
src/Draggy/Utils/Indenter/AbstractLineIndenter.php
|
AbstractLineIndenter.findEndStandardBlock
|
protected function findEndStandardBlock($name, $lineNumber, $maxLine, $targetStepsInto = 0)
{
$stepsInto = 0;
for ($i = $lineNumber; $i <= $maxLine; $i++) {
if ($this->lineTypes['end' . $name][$i] && $i > $lineNumber) {
$stepsInto--;
if ($stepsInto === $targetStepsInto) {
return $i;
}
}
if ($this->lineTypes['start' . $name][$i]) {
$stepsInto++;
}
}
throw new \RuntimeException('Cannot find the end of the ' . $name . ' block starting in line ' . $lineNumber . ' (' . $this->indenterMachine->getLine($lineNumber) . ')');
}
|
php
|
protected function findEndStandardBlock($name, $lineNumber, $maxLine, $targetStepsInto = 0)
{
$stepsInto = 0;
for ($i = $lineNumber; $i <= $maxLine; $i++) {
if ($this->lineTypes['end' . $name][$i] && $i > $lineNumber) {
$stepsInto--;
if ($stepsInto === $targetStepsInto) {
return $i;
}
}
if ($this->lineTypes['start' . $name][$i]) {
$stepsInto++;
}
}
throw new \RuntimeException('Cannot find the end of the ' . $name . ' block starting in line ' . $lineNumber . ' (' . $this->indenterMachine->getLine($lineNumber) . ')');
}
|
[
"protected",
"function",
"findEndStandardBlock",
"(",
"$",
"name",
",",
"$",
"lineNumber",
",",
"$",
"maxLine",
",",
"$",
"targetStepsInto",
"=",
"0",
")",
"{",
"$",
"stepsInto",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"lineNumber",
";",
"$",
"i",
"<=",
"$",
"maxLine",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lineTypes",
"[",
"'end'",
".",
"$",
"name",
"]",
"[",
"$",
"i",
"]",
"&&",
"$",
"i",
">",
"$",
"lineNumber",
")",
"{",
"$",
"stepsInto",
"--",
";",
"if",
"(",
"$",
"stepsInto",
"===",
"$",
"targetStepsInto",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"lineTypes",
"[",
"'start'",
".",
"$",
"name",
"]",
"[",
"$",
"i",
"]",
")",
"{",
"$",
"stepsInto",
"++",
";",
"}",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot find the end of the '",
".",
"$",
"name",
".",
"' block starting in line '",
".",
"$",
"lineNumber",
".",
"' ('",
".",
"$",
"this",
"->",
"indenterMachine",
"->",
"getLine",
"(",
"$",
"lineNumber",
")",
".",
"')'",
")",
";",
"}"
] |
Generic algorithm to find the end of a block
@param string $name Name of the block
@param int $lineNumber Starting line
@param int $maxLine Max line
@param int $targetStepsInto Targets steps into the source code, used as a stop criteria
@return int
@throws \RuntimeException
|
[
"Generic",
"algorithm",
"to",
"find",
"the",
"end",
"of",
"a",
"block"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Utils/Indenter/AbstractLineIndenter.php#L72-L91
|
21,581 |
mothership-ec/composer
|
src/Composer/DependencyResolver/Rule.php
|
Rule.equals
|
public function equals(Rule $rule)
{
if ($this->ruleHash !== $rule->ruleHash) {
return false;
}
if (count($this->literals) != count($rule->literals)) {
return false;
}
for ($i = 0, $n = count($this->literals); $i < $n; $i++) {
if ($this->literals[$i] !== $rule->literals[$i]) {
return false;
}
}
return true;
}
|
php
|
public function equals(Rule $rule)
{
if ($this->ruleHash !== $rule->ruleHash) {
return false;
}
if (count($this->literals) != count($rule->literals)) {
return false;
}
for ($i = 0, $n = count($this->literals); $i < $n; $i++) {
if ($this->literals[$i] !== $rule->literals[$i]) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"equals",
"(",
"Rule",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ruleHash",
"!==",
"$",
"rule",
"->",
"ruleHash",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"literals",
")",
"!=",
"count",
"(",
"$",
"rule",
"->",
"literals",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"n",
"=",
"count",
"(",
"$",
"this",
"->",
"literals",
")",
";",
"$",
"i",
"<",
"$",
"n",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"literals",
"[",
"$",
"i",
"]",
"!==",
"$",
"rule",
"->",
"literals",
"[",
"$",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if this rule is equal to another one
Ignores whether either of the rules is disabled.
@param Rule $rule The rule to check against
@return bool Whether the rules are equal
|
[
"Checks",
"if",
"this",
"rule",
"is",
"equal",
"to",
"another",
"one"
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/Rule.php#L115-L132
|
21,582 |
inhere/php-librarys
|
src/Helpers/FormatHelper.php
|
FormatHelper.convertBytes
|
public static function convertBytes($value)
{
if (is_numeric($value)) {
return $value;
}
$value_length = \strlen($value);
$qty = (int)substr($value, 0, $value_length - 1);
$unit = Str::strtolower(substr($value, $value_length - 1));
switch ($unit) {
case 'k':
$qty *= 1024;
break;
case 'm':
$qty *= 1048576;
break;
case 'g':
$qty *= 1073741824;
break;
}
return $qty;
}
|
php
|
public static function convertBytes($value)
{
if (is_numeric($value)) {
return $value;
}
$value_length = \strlen($value);
$qty = (int)substr($value, 0, $value_length - 1);
$unit = Str::strtolower(substr($value, $value_length - 1));
switch ($unit) {
case 'k':
$qty *= 1024;
break;
case 'm':
$qty *= 1048576;
break;
case 'g':
$qty *= 1073741824;
break;
}
return $qty;
}
|
[
"public",
"static",
"function",
"convertBytes",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"value_length",
"=",
"\\",
"strlen",
"(",
"$",
"value",
")",
";",
"$",
"qty",
"=",
"(",
"int",
")",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"$",
"value_length",
"-",
"1",
")",
";",
"$",
"unit",
"=",
"Str",
"::",
"strtolower",
"(",
"substr",
"(",
"$",
"value",
",",
"$",
"value_length",
"-",
"1",
")",
")",
";",
"switch",
"(",
"$",
"unit",
")",
"{",
"case",
"'k'",
":",
"$",
"qty",
"*=",
"1024",
";",
"break",
";",
"case",
"'m'",
":",
"$",
"qty",
"*=",
"1048576",
";",
"break",
";",
"case",
"'g'",
":",
"$",
"qty",
"*=",
"1073741824",
";",
"break",
";",
"}",
"return",
"$",
"qty",
";",
"}"
] |
Convert a shorthand byte value from a PHP configuration directive to an integer value
@param string $value value to convert
@return int
|
[
"Convert",
"a",
"shorthand",
"byte",
"value",
"from",
"a",
"PHP",
"configuration",
"directive",
"to",
"an",
"integer",
"value"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/FormatHelper.php#L142-L164
|
21,583 |
rattfieldnz/url-validation
|
src/RattfieldNz/UrlValidation/ExternalSources/Jmathai/PhpMultiCurl/EpiCurl.php
|
EpiCurl.addURL
|
public function addURL($url,$options=array()) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
foreach($options as $option=>$value) {
curl_setopt($ch, $option, $value);
}
return $this->addCurl($ch);
}
|
php
|
public function addURL($url,$options=array()) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
foreach($options as $option=>$value) {
curl_setopt($ch, $option, $value);
}
return $this->addCurl($ch);
}
|
[
"public",
"function",
"addURL",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
"=>",
"$",
"value",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"$",
"option",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addCurl",
"(",
"$",
"ch",
")",
";",
"}"
] |
simplifies example and allows for additional curl options to be passed in via array
|
[
"simplifies",
"example",
"and",
"allows",
"for",
"additional",
"curl",
"options",
"to",
"be",
"passed",
"in",
"via",
"array"
] |
ff44a463a9119fa3bea9bd7fef3d44b7e6f9a44c
|
https://github.com/rattfieldnz/url-validation/blob/ff44a463a9119fa3bea9bd7fef3d44b7e6f9a44c/src/RattfieldNz/UrlValidation/ExternalSources/Jmathai/PhpMultiCurl/EpiCurl.php#L38-L45
|
21,584 |
Litecms/Team
|
src/Policies/TeamPolicy.php
|
TeamPolicy.update
|
public function update(UserPolicy $user, Team $team)
{
if ($user->canDo('team.team.edit') && $user->isAdmin()) {
return true;
}
return $team->user_id == user_id() && $team->user_type == user_type();
}
|
php
|
public function update(UserPolicy $user, Team $team)
{
if ($user->canDo('team.team.edit') && $user->isAdmin()) {
return true;
}
return $team->user_id == user_id() && $team->user_type == user_type();
}
|
[
"public",
"function",
"update",
"(",
"UserPolicy",
"$",
"user",
",",
"Team",
"$",
"team",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"canDo",
"(",
"'team.team.edit'",
")",
"&&",
"$",
"user",
"->",
"isAdmin",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"team",
"->",
"user_id",
"==",
"user_id",
"(",
")",
"&&",
"$",
"team",
"->",
"user_type",
"==",
"user_type",
"(",
")",
";",
"}"
] |
Determine if the given user can update the given team.
@param UserPolicy $user
@param Team $team
@return bool
|
[
"Determine",
"if",
"the",
"given",
"user",
"can",
"update",
"the",
"given",
"team",
"."
] |
a444a6a6604c969df138ac0eb57ed5f4696b0f00
|
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Policies/TeamPolicy.php#L49-L56
|
21,585 |
Litecms/Team
|
src/Policies/TeamPolicy.php
|
TeamPolicy.destroy
|
public function destroy(UserPolicy $user, Team $team)
{
return $team->user_id == user_id() && $team->user_type == user_type();
}
|
php
|
public function destroy(UserPolicy $user, Team $team)
{
return $team->user_id == user_id() && $team->user_type == user_type();
}
|
[
"public",
"function",
"destroy",
"(",
"UserPolicy",
"$",
"user",
",",
"Team",
"$",
"team",
")",
"{",
"return",
"$",
"team",
"->",
"user_id",
"==",
"user_id",
"(",
")",
"&&",
"$",
"team",
"->",
"user_type",
"==",
"user_type",
"(",
")",
";",
"}"
] |
Determine if the given user can delete the given team.
@param UserPolicy $user
@param Team $team
@return bool
|
[
"Determine",
"if",
"the",
"given",
"user",
"can",
"delete",
"the",
"given",
"team",
"."
] |
a444a6a6604c969df138ac0eb57ed5f4696b0f00
|
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Policies/TeamPolicy.php#L66-L69
|
21,586 |
surebert/surebert-framework
|
src/sb/Controller/HTML/HTML5.php
|
HTML5.includeJavascript
|
public function includeJavascript($scripts)
{
$src = (!is_array($scripts)) ? Array($scripts) : $scripts;
$html = '';
foreach ($scripts as $s) {
if (!strstr($s, '/')) {
$s = '/js/' . $s;
}
$html .= "\n" . '<script type="text/javascript" src="' . $s . '"></script>';
}
return $html;
}
|
php
|
public function includeJavascript($scripts)
{
$src = (!is_array($scripts)) ? Array($scripts) : $scripts;
$html = '';
foreach ($scripts as $s) {
if (!strstr($s, '/')) {
$s = '/js/' . $s;
}
$html .= "\n" . '<script type="text/javascript" src="' . $s . '"></script>';
}
return $html;
}
|
[
"public",
"function",
"includeJavascript",
"(",
"$",
"scripts",
")",
"{",
"$",
"src",
"=",
"(",
"!",
"is_array",
"(",
"$",
"scripts",
")",
")",
"?",
"Array",
"(",
"$",
"scripts",
")",
":",
"$",
"scripts",
";",
"$",
"html",
"=",
"''",
";",
"foreach",
"(",
"$",
"scripts",
"as",
"$",
"s",
")",
"{",
"if",
"(",
"!",
"strstr",
"(",
"$",
"s",
",",
"'/'",
")",
")",
"{",
"$",
"s",
"=",
"'/js/'",
".",
"$",
"s",
";",
"}",
"$",
"html",
".=",
"\"\\n\"",
".",
"'<script type=\"text/javascript\" src=\"'",
".",
"$",
"s",
".",
"'\"></script>'",
";",
"}",
"return",
"$",
"html",
";",
"}"
] |
Creates a javascript include tag
@param $scripts array/string The file names or an array of file names to include
|
[
"Creates",
"a",
"javascript",
"include",
"tag"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTML/HTML5.php#L72-L85
|
21,587 |
surebert/surebert-framework
|
src/sb/Controller/HTML/HTML5.php
|
HTML5.htmlHead
|
public function htmlHead($custom_head_markup = '')
{
if (!empty($custom_head_markup)) {
$this->custom_head_markup = $custom_head_markup;
}
$html = $this->doc_type . "\n";
$html .= $this->opening_html_tag . "\n";
$html .= '<head>' . "\n";
$html .= '<meta http-equiv="Content-Type" content="text/html; charset=' . $this->charset . '" />' . "\n";
$html .= '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'."\n";
$html .= '<title>' . $this->title . '</title>' . "\n";
if ($this->meta instanceof HeadMeta) {
foreach (get_object_vars($this->meta) as $key => $val) {
$html .= '<meta name="' . $key . '" content="' . $val . '" />' . "\n";
}
}
$html .= '<style type="text/css">';
foreach ($this->styles as $style) {
if (!preg_match("~^(http|/)~", $style)) {
$style = '/css/' . $style;
}
$html .= "@import '" . $style . "';\n";
}
$html .= "</style>\n";
if (!empty($this->custom_head_markup)) {
$html.= $this->custom_head_markup;
}
$html.= "</head>\n";
return $html;
}
|
php
|
public function htmlHead($custom_head_markup = '')
{
if (!empty($custom_head_markup)) {
$this->custom_head_markup = $custom_head_markup;
}
$html = $this->doc_type . "\n";
$html .= $this->opening_html_tag . "\n";
$html .= '<head>' . "\n";
$html .= '<meta http-equiv="Content-Type" content="text/html; charset=' . $this->charset . '" />' . "\n";
$html .= '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'."\n";
$html .= '<title>' . $this->title . '</title>' . "\n";
if ($this->meta instanceof HeadMeta) {
foreach (get_object_vars($this->meta) as $key => $val) {
$html .= '<meta name="' . $key . '" content="' . $val . '" />' . "\n";
}
}
$html .= '<style type="text/css">';
foreach ($this->styles as $style) {
if (!preg_match("~^(http|/)~", $style)) {
$style = '/css/' . $style;
}
$html .= "@import '" . $style . "';\n";
}
$html .= "</style>\n";
if (!empty($this->custom_head_markup)) {
$html.= $this->custom_head_markup;
}
$html.= "</head>\n";
return $html;
}
|
[
"public",
"function",
"htmlHead",
"(",
"$",
"custom_head_markup",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"custom_head_markup",
")",
")",
"{",
"$",
"this",
"->",
"custom_head_markup",
"=",
"$",
"custom_head_markup",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"doc_type",
".",
"\"\\n\"",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"opening_html_tag",
".",
"\"\\n\"",
";",
"$",
"html",
".=",
"'<head>'",
".",
"\"\\n\"",
";",
"$",
"html",
".=",
"'<meta http-equiv=\"Content-Type\" content=\"text/html; charset='",
".",
"$",
"this",
"->",
"charset",
".",
"'\" />'",
".",
"\"\\n\"",
";",
"$",
"html",
".=",
"'<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />'",
".",
"\"\\n\"",
";",
"$",
"html",
".=",
"'<title>'",
".",
"$",
"this",
"->",
"title",
".",
"'</title>'",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"meta",
"instanceof",
"HeadMeta",
")",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
"->",
"meta",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"html",
".=",
"'<meta name=\"'",
".",
"$",
"key",
".",
"'\" content=\"'",
".",
"$",
"val",
".",
"'\" />'",
".",
"\"\\n\"",
";",
"}",
"}",
"$",
"html",
".=",
"'<style type=\"text/css\">'",
";",
"foreach",
"(",
"$",
"this",
"->",
"styles",
"as",
"$",
"style",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"\"~^(http|/)~\"",
",",
"$",
"style",
")",
")",
"{",
"$",
"style",
"=",
"'/css/'",
".",
"$",
"style",
";",
"}",
"$",
"html",
".=",
"\"@import '\"",
".",
"$",
"style",
".",
"\"';\\n\"",
";",
"}",
"$",
"html",
".=",
"\"</style>\\n\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"custom_head_markup",
")",
")",
"{",
"$",
"html",
".=",
"$",
"this",
"->",
"custom_head_markup",
";",
"}",
"$",
"html",
".=",
"\"</head>\\n\"",
";",
"return",
"$",
"html",
";",
"}"
] |
Renders the HTML head
@param $custom_head_markup string A string of data to include in the HTML head, right before </head>
|
[
"Renders",
"the",
"HTML",
"head"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTML/HTML5.php#L91-L128
|
21,588 |
loevgaard/altapay-php-sdk
|
src/Payload/Payload.php
|
Payload.simplePayload
|
public static function simplePayload(array $payload) : array
{
$payload = array_filter($payload, function ($val) {
if ($val instanceof PayloadInterface) {
$val = $val->getPayload();
}
// this will effectively remove empty arrays
if (is_array($val) && empty($val)) {
return false;
}
if (is_null($val)) {
return false;
}
if ($val === '') {
return false;
}
return true;
});
foreach ($payload as $key => $val) {
if (is_array($val)) {
$payload[$key] = static::simplePayload($val);
} elseif ($val instanceof PayloadInterface) {
$payload[$key] = static::simplePayload($val->getPayload());
}
}
return $payload;
}
|
php
|
public static function simplePayload(array $payload) : array
{
$payload = array_filter($payload, function ($val) {
if ($val instanceof PayloadInterface) {
$val = $val->getPayload();
}
// this will effectively remove empty arrays
if (is_array($val) && empty($val)) {
return false;
}
if (is_null($val)) {
return false;
}
if ($val === '') {
return false;
}
return true;
});
foreach ($payload as $key => $val) {
if (is_array($val)) {
$payload[$key] = static::simplePayload($val);
} elseif ($val instanceof PayloadInterface) {
$payload[$key] = static::simplePayload($val->getPayload());
}
}
return $payload;
}
|
[
"public",
"static",
"function",
"simplePayload",
"(",
"array",
"$",
"payload",
")",
":",
"array",
"{",
"$",
"payload",
"=",
"array_filter",
"(",
"$",
"payload",
",",
"function",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"instanceof",
"PayloadInterface",
")",
"{",
"$",
"val",
"=",
"$",
"val",
"->",
"getPayload",
"(",
")",
";",
"}",
"// this will effectively remove empty arrays",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
"&&",
"empty",
"(",
"$",
"val",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"val",
"===",
"''",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"payload",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"payload",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"simplePayload",
"(",
"$",
"val",
")",
";",
"}",
"elseif",
"(",
"$",
"val",
"instanceof",
"PayloadInterface",
")",
"{",
"$",
"payload",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"simplePayload",
"(",
"$",
"val",
"->",
"getPayload",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"payload",
";",
"}"
] |
If the input array contains objects of PayloadInterface it will convert these to simple arrays
Also it will remove values that are null, empty string or empty arrays
@param array $payload
@return array
|
[
"If",
"the",
"input",
"array",
"contains",
"objects",
"of",
"PayloadInterface",
"it",
"will",
"convert",
"these",
"to",
"simple",
"arrays",
"Also",
"it",
"will",
"remove",
"values",
"that",
"are",
"null",
"empty",
"string",
"or",
"empty",
"arrays"
] |
476664e8725407249c04ca7ae76f92882e4f4583
|
https://github.com/loevgaard/altapay-php-sdk/blob/476664e8725407249c04ca7ae76f92882e4f4583/src/Payload/Payload.php#L21-L53
|
21,589 |
InactiveProjects/limoncello-illuminate
|
app/Database/Migrations/Runner.php
|
Runner.rollback
|
public static function rollback()
{
foreach (array_reverse(self::$migrationClasses) as $migrationClass) {
/** @var Migration $instance */
$instance = new $migrationClass;
$instance->rollback();
}
}
|
php
|
public static function rollback()
{
foreach (array_reverse(self::$migrationClasses) as $migrationClass) {
/** @var Migration $instance */
$instance = new $migrationClass;
$instance->rollback();
}
}
|
[
"public",
"static",
"function",
"rollback",
"(",
")",
"{",
"foreach",
"(",
"array_reverse",
"(",
"self",
"::",
"$",
"migrationClasses",
")",
"as",
"$",
"migrationClass",
")",
"{",
"/** @var Migration $instance */",
"$",
"instance",
"=",
"new",
"$",
"migrationClass",
";",
"$",
"instance",
"->",
"rollback",
"(",
")",
";",
"}",
"}"
] |
Rollback application migrations.
@return void
|
[
"Rollback",
"application",
"migrations",
"."
] |
cae6fc26190efcf090495a5c3582c10fa2430897
|
https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Migrations/Runner.php#L39-L46
|
21,590 |
skmetaly/laravel-twitch-restful-api
|
src/API/Search.php
|
Search.streamsChannel
|
public function streamsChannel($channel)
{
$response = $this->client->get(config('twitch-api.api_url') . '/kraken/streams/' . $channel);
return $response->json();
}
|
php
|
public function streamsChannel($channel)
{
$response = $this->client->get(config('twitch-api.api_url') . '/kraken/streams/' . $channel);
return $response->json();
}
|
[
"public",
"function",
"streamsChannel",
"(",
"$",
"channel",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/streams/'",
".",
"$",
"channel",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] |
Returns a stream object if live.
@param $channel
@return json
|
[
"Returns",
"a",
"stream",
"object",
"if",
"live",
"."
] |
70c83e441deb411ade2e343ad5cb0339c90dc6c2
|
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Search.php#L109-L114
|
21,591 |
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/MethodDescriptor.php
|
MethodDescriptor.getInheritedElement
|
public function getInheritedElement()
{
if ($this->inheritedElement !== null) {
return $this->inheritedElement;
}
/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */
$associatedClass = $this->getParent();
if (!$associatedClass instanceof ClassDescriptor && !$associatedClass instanceof InterfaceDescriptor) {
return null;
}
/** @var ClassDescriptor|InterfaceDescriptor $parentClass|null */
$parentClass = $associatedClass->getParent();
if ($parentClass instanceof ClassDescriptor || $parentClass instanceof Collection) {
// the parent of a class is always a class, but the parent of an interface is a collection of interfaces.
$parents = $parentClass instanceof ClassDescriptor ? array($parentClass) : $parentClass->getAll();
foreach ($parents as $parent) {
if ($parent instanceof ClassDescriptor || $parent instanceof InterfaceDescriptor) {
$parentMethod = $parent->getMethods()->get($this->getName());
if ($parentMethod) {
$this->inheritedElement = $parentMethod;
return $this->inheritedElement;
}
}
}
}
// also check all implemented interfaces next if the parent is a class and not an interface
if ($associatedClass instanceof ClassDescriptor) {
/** @var InterfaceDescriptor $interface */
foreach ($associatedClass->getInterfaces() as $interface) {
if (!$interface instanceof InterfaceDescriptor) {
continue;
}
$parentMethod = $interface->getMethods()->get($this->getName());
if ($parentMethod) {
$this->inheritedElement = $parentMethod;
return $this->inheritedElement;
}
}
}
return null;
}
|
php
|
public function getInheritedElement()
{
if ($this->inheritedElement !== null) {
return $this->inheritedElement;
}
/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */
$associatedClass = $this->getParent();
if (!$associatedClass instanceof ClassDescriptor && !$associatedClass instanceof InterfaceDescriptor) {
return null;
}
/** @var ClassDescriptor|InterfaceDescriptor $parentClass|null */
$parentClass = $associatedClass->getParent();
if ($parentClass instanceof ClassDescriptor || $parentClass instanceof Collection) {
// the parent of a class is always a class, but the parent of an interface is a collection of interfaces.
$parents = $parentClass instanceof ClassDescriptor ? array($parentClass) : $parentClass->getAll();
foreach ($parents as $parent) {
if ($parent instanceof ClassDescriptor || $parent instanceof InterfaceDescriptor) {
$parentMethod = $parent->getMethods()->get($this->getName());
if ($parentMethod) {
$this->inheritedElement = $parentMethod;
return $this->inheritedElement;
}
}
}
}
// also check all implemented interfaces next if the parent is a class and not an interface
if ($associatedClass instanceof ClassDescriptor) {
/** @var InterfaceDescriptor $interface */
foreach ($associatedClass->getInterfaces() as $interface) {
if (!$interface instanceof InterfaceDescriptor) {
continue;
}
$parentMethod = $interface->getMethods()->get($this->getName());
if ($parentMethod) {
$this->inheritedElement = $parentMethod;
return $this->inheritedElement;
}
}
}
return null;
}
|
[
"public",
"function",
"getInheritedElement",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inheritedElement",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"inheritedElement",
";",
"}",
"/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */",
"$",
"associatedClass",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"associatedClass",
"instanceof",
"ClassDescriptor",
"&&",
"!",
"$",
"associatedClass",
"instanceof",
"InterfaceDescriptor",
")",
"{",
"return",
"null",
";",
"}",
"/** @var ClassDescriptor|InterfaceDescriptor $parentClass|null */",
"$",
"parentClass",
"=",
"$",
"associatedClass",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"$",
"parentClass",
"instanceof",
"ClassDescriptor",
"||",
"$",
"parentClass",
"instanceof",
"Collection",
")",
"{",
"// the parent of a class is always a class, but the parent of an interface is a collection of interfaces.",
"$",
"parents",
"=",
"$",
"parentClass",
"instanceof",
"ClassDescriptor",
"?",
"array",
"(",
"$",
"parentClass",
")",
":",
"$",
"parentClass",
"->",
"getAll",
"(",
")",
";",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"parent",
"instanceof",
"ClassDescriptor",
"||",
"$",
"parent",
"instanceof",
"InterfaceDescriptor",
")",
"{",
"$",
"parentMethod",
"=",
"$",
"parent",
"->",
"getMethods",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"parentMethod",
")",
"{",
"$",
"this",
"->",
"inheritedElement",
"=",
"$",
"parentMethod",
";",
"return",
"$",
"this",
"->",
"inheritedElement",
";",
"}",
"}",
"}",
"}",
"// also check all implemented interfaces next if the parent is a class and not an interface",
"if",
"(",
"$",
"associatedClass",
"instanceof",
"ClassDescriptor",
")",
"{",
"/** @var InterfaceDescriptor $interface */",
"foreach",
"(",
"$",
"associatedClass",
"->",
"getInterfaces",
"(",
")",
"as",
"$",
"interface",
")",
"{",
"if",
"(",
"!",
"$",
"interface",
"instanceof",
"InterfaceDescriptor",
")",
"{",
"continue",
";",
"}",
"$",
"parentMethod",
"=",
"$",
"interface",
"->",
"getMethods",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"parentMethod",
")",
"{",
"$",
"this",
"->",
"inheritedElement",
"=",
"$",
"parentMethod",
";",
"return",
"$",
"this",
"->",
"inheritedElement",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the Method from which this method should inherit its information, if any.
The inheritance scheme for a method is more complicated than for most elements; the following business rules
apply:
1. if the parent class/interface extends another class or other interfaces (interfaces have multiple
inheritance!) then:
1. Check each parent class/interface's parent if they have a method with the exact same name
2. if a method is found with the same name; return the first one encountered.
2. if the parent is a class and implements interfaces, check each interface for a method with the exact same
name. If such a method is found, return the first hit.
@return MethodDescriptor|null
|
[
"Returns",
"the",
"Method",
"from",
"which",
"this",
"method",
"should",
"inherit",
"its",
"information",
"if",
"any",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/MethodDescriptor.php#L239-L286
|
21,592 |
GrupaZero/api
|
src/Gzero/Api/Transformer/ContentTranslationTransformer.php
|
ContentTranslationTransformer.transform
|
public function transform($translation)
{
$translation = $this->entityToArray(ContentTranslation::class, $translation);
return [
'id' => (int) $translation['id'],
'langCode' => $translation['lang_code'],
'title' => $translation['title'],
'teaser' => $translation['teaser'],
'body' => $translation['body'],
'seoTitle' => $translation['seo_title'],
'seoDescription' => $translation['seo_description'],
'isActive' => (bool) $translation['is_active'],
'createdAt' => $translation['created_at'],
'updatedAt' => $translation['updated_at'],
];
}
|
php
|
public function transform($translation)
{
$translation = $this->entityToArray(ContentTranslation::class, $translation);
return [
'id' => (int) $translation['id'],
'langCode' => $translation['lang_code'],
'title' => $translation['title'],
'teaser' => $translation['teaser'],
'body' => $translation['body'],
'seoTitle' => $translation['seo_title'],
'seoDescription' => $translation['seo_description'],
'isActive' => (bool) $translation['is_active'],
'createdAt' => $translation['created_at'],
'updatedAt' => $translation['updated_at'],
];
}
|
[
"public",
"function",
"transform",
"(",
"$",
"translation",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"ContentTranslation",
"::",
"class",
",",
"$",
"translation",
")",
";",
"return",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"translation",
"[",
"'id'",
"]",
",",
"'langCode'",
"=>",
"$",
"translation",
"[",
"'lang_code'",
"]",
",",
"'title'",
"=>",
"$",
"translation",
"[",
"'title'",
"]",
",",
"'teaser'",
"=>",
"$",
"translation",
"[",
"'teaser'",
"]",
",",
"'body'",
"=>",
"$",
"translation",
"[",
"'body'",
"]",
",",
"'seoTitle'",
"=>",
"$",
"translation",
"[",
"'seo_title'",
"]",
",",
"'seoDescription'",
"=>",
"$",
"translation",
"[",
"'seo_description'",
"]",
",",
"'isActive'",
"=>",
"(",
"bool",
")",
"$",
"translation",
"[",
"'is_active'",
"]",
",",
"'createdAt'",
"=>",
"$",
"translation",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"translation",
"[",
"'updated_at'",
"]",
",",
"]",
";",
"}"
] |
Transforms content translation entity
@param ContentTranslation|array $translation ContentTranslation entity
@return array
|
[
"Transforms",
"content",
"translation",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTranslationTransformer.php#L26-L41
|
21,593 |
oroinc/OroLayoutComponent
|
LayoutBuilder.php
|
LayoutBuilder.processBlockViewData
|
protected function processBlockViewData(
BlockView $blockView,
ContextInterface $context,
DataAccessor $data,
$deferred,
$encoding
) {
if ($deferred) {
$this->expressionProcessor->processExpressions($blockView->vars, $context, $data, true, $encoding);
}
$this->buildValueBags($blockView);
foreach ($blockView->children as $key => $childView) {
$this->processBlockViewData($childView, $context, $data, $deferred, $encoding);
if (!$childView->isVisible()) {
unset($blockView->children[$key]);
}
}
}
|
php
|
protected function processBlockViewData(
BlockView $blockView,
ContextInterface $context,
DataAccessor $data,
$deferred,
$encoding
) {
if ($deferred) {
$this->expressionProcessor->processExpressions($blockView->vars, $context, $data, true, $encoding);
}
$this->buildValueBags($blockView);
foreach ($blockView->children as $key => $childView) {
$this->processBlockViewData($childView, $context, $data, $deferred, $encoding);
if (!$childView->isVisible()) {
unset($blockView->children[$key]);
}
}
}
|
[
"protected",
"function",
"processBlockViewData",
"(",
"BlockView",
"$",
"blockView",
",",
"ContextInterface",
"$",
"context",
",",
"DataAccessor",
"$",
"data",
",",
"$",
"deferred",
",",
"$",
"encoding",
")",
"{",
"if",
"(",
"$",
"deferred",
")",
"{",
"$",
"this",
"->",
"expressionProcessor",
"->",
"processExpressions",
"(",
"$",
"blockView",
"->",
"vars",
",",
"$",
"context",
",",
"$",
"data",
",",
"true",
",",
"$",
"encoding",
")",
";",
"}",
"$",
"this",
"->",
"buildValueBags",
"(",
"$",
"blockView",
")",
";",
"foreach",
"(",
"$",
"blockView",
"->",
"children",
"as",
"$",
"key",
"=>",
"$",
"childView",
")",
"{",
"$",
"this",
"->",
"processBlockViewData",
"(",
"$",
"childView",
",",
"$",
"context",
",",
"$",
"data",
",",
"$",
"deferred",
",",
"$",
"encoding",
")",
";",
"if",
"(",
"!",
"$",
"childView",
"->",
"isVisible",
"(",
")",
")",
"{",
"unset",
"(",
"$",
"blockView",
"->",
"children",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}"
] |
Processes expressions that work with data
@param BlockView $blockView
@param ContextInterface $context
@param DataAccessor $data
@param bool $deferred
@param string $encoding
|
[
"Processes",
"expressions",
"that",
"work",
"with",
"data"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/LayoutBuilder.php#L282-L302
|
21,594 |
ekuiter/feature-php
|
FeaturePhp/Specification/FileSpecification.php
|
FileSpecification.fromArrayAndSettings
|
public static function fromArrayAndSettings($cfg, $settings, $artifact = null) {
$fileSpecification = new static($cfg, $settings->getDirectory(), $artifact);
$fileSpecification->set("relativeSource", $fileSpecification->getSource());
$fileSpecification->set("source", $settings->getPath($fileSpecification->getSource()));
$fileSpecification->set("target", fphp\Helper\Path::join(
$settings->getOptional("target", null), $fileSpecification->getTarget()));
if (!file_exists($fileSpecification->getSource()))
throw new FileSpecificationException("file \"{$fileSpecification->getSource()}\" does not exist");
return $fileSpecification;
}
|
php
|
public static function fromArrayAndSettings($cfg, $settings, $artifact = null) {
$fileSpecification = new static($cfg, $settings->getDirectory(), $artifact);
$fileSpecification->set("relativeSource", $fileSpecification->getSource());
$fileSpecification->set("source", $settings->getPath($fileSpecification->getSource()));
$fileSpecification->set("target", fphp\Helper\Path::join(
$settings->getOptional("target", null), $fileSpecification->getTarget()));
if (!file_exists($fileSpecification->getSource()))
throw new FileSpecificationException("file \"{$fileSpecification->getSource()}\" does not exist");
return $fileSpecification;
}
|
[
"public",
"static",
"function",
"fromArrayAndSettings",
"(",
"$",
"cfg",
",",
"$",
"settings",
",",
"$",
"artifact",
"=",
"null",
")",
"{",
"$",
"fileSpecification",
"=",
"new",
"static",
"(",
"$",
"cfg",
",",
"$",
"settings",
"->",
"getDirectory",
"(",
")",
",",
"$",
"artifact",
")",
";",
"$",
"fileSpecification",
"->",
"set",
"(",
"\"relativeSource\"",
",",
"$",
"fileSpecification",
"->",
"getSource",
"(",
")",
")",
";",
"$",
"fileSpecification",
"->",
"set",
"(",
"\"source\"",
",",
"$",
"settings",
"->",
"getPath",
"(",
"$",
"fileSpecification",
"->",
"getSource",
"(",
")",
")",
")",
";",
"$",
"fileSpecification",
"->",
"set",
"(",
"\"target\"",
",",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"join",
"(",
"$",
"settings",
"->",
"getOptional",
"(",
"\"target\"",
",",
"null",
")",
",",
"$",
"fileSpecification",
"->",
"getTarget",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileSpecification",
"->",
"getSource",
"(",
")",
")",
")",
"throw",
"new",
"FileSpecificationException",
"(",
"\"file \\\"{$fileSpecification->getSource()}\\\" does not exist\"",
")",
";",
"return",
"$",
"fileSpecification",
";",
"}"
] |
Creates a file specification from a plain settings array.
The settings context is taken into consideration to generate paths
relative to the settings.
@param array $cfg a plain settings array
@param \FeaturePhp\Settings $settings the settings context
@param \FeaturePhp\Artifact\Artifact $artifact
@return FileSpecification
|
[
"Creates",
"a",
"file",
"specification",
"from",
"a",
"plain",
"settings",
"array",
".",
"The",
"settings",
"context",
"is",
"taken",
"into",
"consideration",
"to",
"generate",
"paths",
"relative",
"to",
"the",
"settings",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Specification/FileSpecification.php#L56-L67
|
21,595 |
SporkCode/Spork
|
src/Mvc/Listener/Limit/Limit.php
|
Limit.setInterval
|
public function setInterval($interval)
{
$this->interval = $interval instanceof DateInterval ? $interval : new DateInterval($interval);
return $this;
}
|
php
|
public function setInterval($interval)
{
$this->interval = $interval instanceof DateInterval ? $interval : new DateInterval($interval);
return $this;
}
|
[
"public",
"function",
"setInterval",
"(",
"$",
"interval",
")",
"{",
"$",
"this",
"->",
"interval",
"=",
"$",
"interval",
"instanceof",
"DateInterval",
"?",
"$",
"interval",
":",
"new",
"DateInterval",
"(",
"$",
"interval",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the limit interval
@param string|DateInterval $interval
@return \Spork\Mvc\Listener\Limit\Limit
|
[
"Set",
"the",
"limit",
"interval"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/Limit/Limit.php#L115-L119
|
21,596 |
SporkCode/Spork
|
src/Mvc/Controller/Plugin/Back.php
|
Back.redirect
|
public function redirect($default = 'home')
{
$redirect = $this->getController()->plugin('redirect');
$route = $this->getSession()->route;
if (null === $route) {
return $redirect->toRoute($default);
}
return $redirect->toRoute($route->getMatchedRouteName(),
$route->getParams());
}
|
php
|
public function redirect($default = 'home')
{
$redirect = $this->getController()->plugin('redirect');
$route = $this->getSession()->route;
if (null === $route) {
return $redirect->toRoute($default);
}
return $redirect->toRoute($route->getMatchedRouteName(),
$route->getParams());
}
|
[
"public",
"function",
"redirect",
"(",
"$",
"default",
"=",
"'home'",
")",
"{",
"$",
"redirect",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"plugin",
"(",
"'redirect'",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"route",
";",
"if",
"(",
"null",
"===",
"$",
"route",
")",
"{",
"return",
"$",
"redirect",
"->",
"toRoute",
"(",
"$",
"default",
")",
";",
"}",
"return",
"$",
"redirect",
"->",
"toRoute",
"(",
"$",
"route",
"->",
"getMatchedRouteName",
"(",
")",
",",
"$",
"route",
"->",
"getParams",
"(",
")",
")",
";",
"}"
] |
Redirect to last route
@param string $default
Default route to use if previous route not found
|
[
"Redirect",
"to",
"last",
"route"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Controller/Plugin/Back.php#L116-L125
|
21,597 |
SporkCode/Spork
|
src/Mvc/Controller/Plugin/Back.php
|
Back.url
|
public function url($default = 'home')
{
$url = $this->getController()->plugin('url');
$route = $this->getSession()->route;
if (null === $route) {
return $url->fromRoute($default);
}
return $url->fromRoute($route->getMatchedRouteName(),
$route->getParams());
}
|
php
|
public function url($default = 'home')
{
$url = $this->getController()->plugin('url');
$route = $this->getSession()->route;
if (null === $route) {
return $url->fromRoute($default);
}
return $url->fromRoute($route->getMatchedRouteName(),
$route->getParams());
}
|
[
"public",
"function",
"url",
"(",
"$",
"default",
"=",
"'home'",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"plugin",
"(",
"'url'",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"route",
";",
"if",
"(",
"null",
"===",
"$",
"route",
")",
"{",
"return",
"$",
"url",
"->",
"fromRoute",
"(",
"$",
"default",
")",
";",
"}",
"return",
"$",
"url",
"->",
"fromRoute",
"(",
"$",
"route",
"->",
"getMatchedRouteName",
"(",
")",
",",
"$",
"route",
"->",
"getParams",
"(",
")",
")",
";",
"}"
] |
Get last route URL
@param string $default
|
[
"Get",
"last",
"route",
"URL"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Controller/Plugin/Back.php#L132-L141
|
21,598 |
SporkCode/Spork
|
src/Mvc/Controller/Plugin/Back.php
|
Back.storeRoute
|
public function storeRoute(MvcEvent $event)
{
if ($this->ignore) {
return;
}
$request = $event->getRequest();
if ($request->isXmlHttpRequest()) {
return;
}
$appConfig = $event->getApplication()
->getServiceManager()
->get('config');
$config = array_key_exists(self::CONFIG_KEY, $appConfig) ? $appConfig[self::CONFIG_KEY] : array();
if (array_key_exists('blacklist', $config)) {
$this->setBlacklist($config['blacklist']);
}
$routeMatch = $event->getRouteMatch();
if (null === $routeMatch ||
in_array($routeMatch->getMatchedRouteName(), $this->blacklist)) {
return;
}
$this->getSession()->route = $routeMatch;
}
|
php
|
public function storeRoute(MvcEvent $event)
{
if ($this->ignore) {
return;
}
$request = $event->getRequest();
if ($request->isXmlHttpRequest()) {
return;
}
$appConfig = $event->getApplication()
->getServiceManager()
->get('config');
$config = array_key_exists(self::CONFIG_KEY, $appConfig) ? $appConfig[self::CONFIG_KEY] : array();
if (array_key_exists('blacklist', $config)) {
$this->setBlacklist($config['blacklist']);
}
$routeMatch = $event->getRouteMatch();
if (null === $routeMatch ||
in_array($routeMatch->getMatchedRouteName(), $this->blacklist)) {
return;
}
$this->getSession()->route = $routeMatch;
}
|
[
"public",
"function",
"storeRoute",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ignore",
")",
"{",
"return",
";",
"}",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"appConfig",
"=",
"$",
"event",
"->",
"getApplication",
"(",
")",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"'config'",
")",
";",
"$",
"config",
"=",
"array_key_exists",
"(",
"self",
"::",
"CONFIG_KEY",
",",
"$",
"appConfig",
")",
"?",
"$",
"appConfig",
"[",
"self",
"::",
"CONFIG_KEY",
"]",
":",
"array",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'blacklist'",
",",
"$",
"config",
")",
")",
"{",
"$",
"this",
"->",
"setBlacklist",
"(",
"$",
"config",
"[",
"'blacklist'",
"]",
")",
";",
"}",
"$",
"routeMatch",
"=",
"$",
"event",
"->",
"getRouteMatch",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"routeMatch",
"||",
"in_array",
"(",
"$",
"routeMatch",
"->",
"getMatchedRouteName",
"(",
")",
",",
"$",
"this",
"->",
"blacklist",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"route",
"=",
"$",
"routeMatch",
";",
"}"
] |
Store route in session so it can be returned to later.
@param MvcEvent $event
|
[
"Store",
"route",
"in",
"session",
"so",
"it",
"can",
"be",
"returned",
"to",
"later",
"."
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Controller/Plugin/Back.php#L162-L188
|
21,599 |
brightmarch/rest-easy
|
src/Brightmarch/RestEasy/Controller/Controller.php
|
Controller.resourceSupports
|
public function resourceSupports()
{
$this->supportedTypes = array_merge(func_get_args(), $this->supportedTypes);
$this->canClientAcceptThisResponse();
return $this;
}
|
php
|
public function resourceSupports()
{
$this->supportedTypes = array_merge(func_get_args(), $this->supportedTypes);
$this->canClientAcceptThisResponse();
return $this;
}
|
[
"public",
"function",
"resourceSupports",
"(",
")",
"{",
"$",
"this",
"->",
"supportedTypes",
"=",
"array_merge",
"(",
"func_get_args",
"(",
")",
",",
"$",
"this",
"->",
"supportedTypes",
")",
";",
"$",
"this",
"->",
"canClientAcceptThisResponse",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a list of content types that this resource supports.
@param [string, string, ...]
@return Controller
|
[
"Set",
"a",
"list",
"of",
"content",
"types",
"that",
"this",
"resource",
"supports",
"."
] |
a6903cdff0a5de2e4466d3e3438c59b9903049f4
|
https://github.com/brightmarch/rest-easy/blob/a6903cdff0a5de2e4466d3e3438c59b9903049f4/src/Brightmarch/RestEasy/Controller/Controller.php#L42-L48
|
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.