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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
227,100
|
BootstrapCMS/Credentials
|
src/Repositories/PaginateRepositoryTrait.php
|
PaginateRepositoryTrait.isPageInRange
|
protected function isPageInRange(LengthAwarePaginator $paginator)
{
return $paginator->currentPage() <= ceil($paginator->lastItem() / $paginator->perPage());
}
|
php
|
protected function isPageInRange(LengthAwarePaginator $paginator)
{
return $paginator->currentPage() <= ceil($paginator->lastItem() / $paginator->perPage());
}
|
[
"protected",
"function",
"isPageInRange",
"(",
"LengthAwarePaginator",
"$",
"paginator",
")",
"{",
"return",
"$",
"paginator",
"->",
"currentPage",
"(",
")",
"<=",
"ceil",
"(",
"$",
"paginator",
"->",
"lastItem",
"(",
")",
"/",
"$",
"paginator",
"->",
"perPage",
"(",
")",
")",
";",
"}"
] |
Is this current page in range?
@param \Illuminate\Pagination\LengthAwarePaginator $paginator
@return bool
|
[
"Is",
"this",
"current",
"page",
"in",
"range?"
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Repositories/PaginateRepositoryTrait.php#L66-L69
|
227,101
|
ARCANEDEV/LaravelAuth
|
src/Models/User.php
|
User.roles
|
public function roles()
{
return $this->belongsToMany(
config('laravel-auth.roles.model', Role::class),
$this->getPrefix().config('laravel-auth.role-user.table', 'role_user')
)
->using(Pivots\RoleUser::class)
->withTimestamps();
}
|
php
|
public function roles()
{
return $this->belongsToMany(
config('laravel-auth.roles.model', Role::class),
$this->getPrefix().config('laravel-auth.role-user.table', 'role_user')
)
->using(Pivots\RoleUser::class)
->withTimestamps();
}
|
[
"public",
"function",
"roles",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"belongsToMany",
"(",
"config",
"(",
"'laravel-auth.roles.model'",
",",
"Role",
"::",
"class",
")",
",",
"$",
"this",
"->",
"getPrefix",
"(",
")",
".",
"config",
"(",
"'laravel-auth.role-user.table'",
",",
"'role_user'",
")",
")",
"->",
"using",
"(",
"Pivots",
"\\",
"RoleUser",
"::",
"class",
")",
"->",
"withTimestamps",
"(",
")",
";",
"}"
] |
User belongs to many roles.
@return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
[
"User",
"belongs",
"to",
"many",
"roles",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/User.php#L177-L185
|
227,102
|
ARCANEDEV/LaravelAuth
|
src/Models/User.php
|
User.getPermissionsAttribute
|
public function getPermissionsAttribute()
{
return $this->active_roles
->pluck('permissions')
->flatten()
->unique(function (PermissionContract $permission) {
return $permission->getKey();
});
}
|
php
|
public function getPermissionsAttribute()
{
return $this->active_roles
->pluck('permissions')
->flatten()
->unique(function (PermissionContract $permission) {
return $permission->getKey();
});
}
|
[
"public",
"function",
"getPermissionsAttribute",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"active_roles",
"->",
"pluck",
"(",
"'permissions'",
")",
"->",
"flatten",
"(",
")",
"->",
"unique",
"(",
"function",
"(",
"PermissionContract",
"$",
"permission",
")",
"{",
"return",
"$",
"permission",
"->",
"getKey",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Get all user permissions.
@return \Illuminate\Support\Collection
|
[
"Get",
"all",
"user",
"permissions",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/User.php#L192-L200
|
227,103
|
ARCANEDEV/LaravelAuth
|
src/Models/User.php
|
User.scopeLastActive
|
public function scopeLastActive($query, $minutes = null)
{
$date = $this->freshTimestamp()->subMinutes(
$minutes ?: config('laravel_auth.track-activity.minutes', 5)
)->toDateTimeString();
return $query->where('last_activity', '>=', $date);
}
|
php
|
public function scopeLastActive($query, $minutes = null)
{
$date = $this->freshTimestamp()->subMinutes(
$minutes ?: config('laravel_auth.track-activity.minutes', 5)
)->toDateTimeString();
return $query->where('last_activity', '>=', $date);
}
|
[
"public",
"function",
"scopeLastActive",
"(",
"$",
"query",
",",
"$",
"minutes",
"=",
"null",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"freshTimestamp",
"(",
")",
"->",
"subMinutes",
"(",
"$",
"minutes",
"?",
":",
"config",
"(",
"'laravel_auth.track-activity.minutes'",
",",
"5",
")",
")",
"->",
"toDateTimeString",
"(",
")",
";",
"return",
"$",
"query",
"->",
"where",
"(",
"'last_activity'",
",",
"'>='",
",",
"$",
"date",
")",
";",
"}"
] |
Scope last active users.
@param \Illuminate\Database\Eloquent\Builder $query
@param int|null $minutes
@return \Illuminate\Database\Eloquent\Builder
|
[
"Scope",
"last",
"active",
"users",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/User.php#L215-L222
|
227,104
|
ARCANEDEV/LaravelAuth
|
src/Models/User.php
|
User.activate
|
public function activate($save = true)
{
event(new ActivatingUser($this));
$result = $this->switchActive(true, $save);
event(new ActivatedUser($this));
return $result;
}
|
php
|
public function activate($save = true)
{
event(new ActivatingUser($this));
$result = $this->switchActive(true, $save);
event(new ActivatedUser($this));
return $result;
}
|
[
"public",
"function",
"activate",
"(",
"$",
"save",
"=",
"true",
")",
"{",
"event",
"(",
"new",
"ActivatingUser",
"(",
"$",
"this",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"switchActive",
"(",
"true",
",",
"$",
"save",
")",
";",
"event",
"(",
"new",
"ActivatedUser",
"(",
"$",
"this",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Activate the model.
@param bool $save
@return bool
|
[
"Activate",
"the",
"model",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/User.php#L325-L332
|
227,105
|
ARCANEDEV/LaravelAuth
|
src/Models/User.php
|
User.deactivate
|
public function deactivate($save = true)
{
event(new DeactivatingUser($this));
$result = $this->switchActive(false, $save);
event(new DeactivatedUser($this));
return $result;
}
|
php
|
public function deactivate($save = true)
{
event(new DeactivatingUser($this));
$result = $this->switchActive(false, $save);
event(new DeactivatedUser($this));
return $result;
}
|
[
"public",
"function",
"deactivate",
"(",
"$",
"save",
"=",
"true",
")",
"{",
"event",
"(",
"new",
"DeactivatingUser",
"(",
"$",
"this",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"switchActive",
"(",
"false",
",",
"$",
"save",
")",
";",
"event",
"(",
"new",
"DeactivatedUser",
"(",
"$",
"this",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Deactivate the model.
@param bool $save
@return bool
|
[
"Deactivate",
"the",
"model",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/User.php#L341-L348
|
227,106
|
ARCANEDEV/LaravelAuth
|
src/Models/User.php
|
User.updateLastActivity
|
public function updateLastActivity($save = true)
{
$this->forceFill(['last_activity' => $this->freshTimestamp()]);
if ($save) $this->save();
}
|
php
|
public function updateLastActivity($save = true)
{
$this->forceFill(['last_activity' => $this->freshTimestamp()]);
if ($save) $this->save();
}
|
[
"public",
"function",
"updateLastActivity",
"(",
"$",
"save",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"forceFill",
"(",
"[",
"'last_activity'",
"=>",
"$",
"this",
"->",
"freshTimestamp",
"(",
")",
"]",
")",
";",
"if",
"(",
"$",
"save",
")",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] |
Update the user's last activity.
@param bool $save
|
[
"Update",
"the",
"user",
"s",
"last",
"activity",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/User.php#L431-L436
|
227,107
|
hscstudio/yii2-heart
|
helpers/DateTimeCompareValidator.php
|
DateTimeCompareValidator.compareValues
|
protected function compareValues($operator, $value, $compareValue)
{
switch ($operator) {
case '==':
return $value == $compareValue;
case '===':
return $value === $compareValue;
case '!=':
return $value != $compareValue;
case '!==':
return $value !== $compareValue;
case '>':
return $value > $compareValue;
case '>=':
return $value >= $compareValue;
case '<':
return $value < $compareValue;
case '<=':
return $value <= $compareValue;
default:
return false;
}
}
|
php
|
protected function compareValues($operator, $value, $compareValue)
{
switch ($operator) {
case '==':
return $value == $compareValue;
case '===':
return $value === $compareValue;
case '!=':
return $value != $compareValue;
case '!==':
return $value !== $compareValue;
case '>':
return $value > $compareValue;
case '>=':
return $value >= $compareValue;
case '<':
return $value < $compareValue;
case '<=':
return $value <= $compareValue;
default:
return false;
}
}
|
[
"protected",
"function",
"compareValues",
"(",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"compareValue",
")",
"{",
"switch",
"(",
"$",
"operator",
")",
"{",
"case",
"'=='",
":",
"return",
"$",
"value",
"==",
"$",
"compareValue",
";",
"case",
"'==='",
":",
"return",
"$",
"value",
"===",
"$",
"compareValue",
";",
"case",
"'!='",
":",
"return",
"$",
"value",
"!=",
"$",
"compareValue",
";",
"case",
"'!=='",
":",
"return",
"$",
"value",
"!==",
"$",
"compareValue",
";",
"case",
"'>'",
":",
"return",
"$",
"value",
">",
"$",
"compareValue",
";",
"case",
"'>='",
":",
"return",
"$",
"value",
">=",
"$",
"compareValue",
";",
"case",
"'<'",
":",
"return",
"$",
"value",
"<",
"$",
"compareValue",
";",
"case",
"'<='",
":",
"return",
"$",
"value",
"<=",
"$",
"compareValue",
";",
"default",
":",
"return",
"false",
";",
"}",
"}"
] |
Compares two values with the specified operator.
@param string $operator the comparison operator
@param mixed $value the value being compared
@param mixed $compareValue another value being compared
@return boolean whether the comparison using the specified operator is true.
|
[
"Compares",
"two",
"values",
"with",
"the",
"specified",
"operator",
"."
] |
7c54c7794c5045c0beb1d8bd70b287278eddbeee
|
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/helpers/DateTimeCompareValidator.php#L145-L167
|
227,108
|
secit-pl/schema-org
|
SchemaOrg/Mapping/Type/ItemList.php
|
ItemList.setItemListElements
|
public function setItemListElements($itemListElements) {
if (!is_array($itemListElements)) {
throw new \Exception('The value is expected to be an array');
}
foreach ($itemListElements as $itemListElement) {
if (!$itemListElement instanceof Property\ItemListElement) {
throw new \Exception('Unexpected value type');
}
}
$this->itemListElement = $itemListElements;
return $this;
}
|
php
|
public function setItemListElements($itemListElements) {
if (!is_array($itemListElements)) {
throw new \Exception('The value is expected to be an array');
}
foreach ($itemListElements as $itemListElement) {
if (!$itemListElement instanceof Property\ItemListElement) {
throw new \Exception('Unexpected value type');
}
}
$this->itemListElement = $itemListElements;
return $this;
}
|
[
"public",
"function",
"setItemListElements",
"(",
"$",
"itemListElements",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"itemListElements",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The value is expected to be an array'",
")",
";",
"}",
"foreach",
"(",
"$",
"itemListElements",
"as",
"$",
"itemListElement",
")",
"{",
"if",
"(",
"!",
"$",
"itemListElement",
"instanceof",
"Property",
"\\",
"ItemListElement",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unexpected value type'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"itemListElement",
"=",
"$",
"itemListElements",
";",
"return",
"$",
"this",
";",
"}"
] |
Set item list elements.
@param array|Property\ItemListElement[] $itemListElements
@return ItemList
|
[
"Set",
"item",
"list",
"elements",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg/Mapping/Type/ItemList.php#L108-L120
|
227,109
|
BootstrapCMS/Credentials
|
src/Credentials.php
|
Credentials.check
|
public function check()
{
if ($this->cache === null) {
$this->cache = $this->sentry->check();
}
return $this->cache && $this->getUser();
}
|
php
|
public function check()
{
if ($this->cache === null) {
$this->cache = $this->sentry->check();
}
return $this->cache && $this->getUser();
}
|
[
"public",
"function",
"check",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"$",
"this",
"->",
"sentry",
"->",
"check",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"&&",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"}"
] |
Call Sentry's check method or load of cached value.
@return bool
|
[
"Call",
"Sentry",
"s",
"check",
"method",
"or",
"load",
"of",
"cached",
"value",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Credentials.php#L64-L71
|
227,110
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.index
|
public function index()
{
$users = UserRepository::paginate();
$links = UserRepository::links();
return View::make('credentials::users.index', compact('users', 'links'));
}
|
php
|
public function index()
{
$users = UserRepository::paginate();
$links = UserRepository::links();
return View::make('credentials::users.index', compact('users', 'links'));
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"users",
"=",
"UserRepository",
"::",
"paginate",
"(",
")",
";",
"$",
"links",
"=",
"UserRepository",
"::",
"links",
"(",
")",
";",
"return",
"View",
"::",
"make",
"(",
"'credentials::users.index'",
",",
"compact",
"(",
"'users'",
",",
"'links'",
")",
")",
";",
"}"
] |
Display a listing of the users.
@return \Illuminate\View\View
|
[
"Display",
"a",
"listing",
"of",
"the",
"users",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L66-L72
|
227,111
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.store
|
public function store()
{
$password = Str::random();
$input = array_merge(Binput::only(['first_name', 'last_name', 'email']), [
'password' => $password,
'activated' => true,
'activated_at' => new DateTime(),
]);
$rules = UserRepository::rules(array_keys($input));
$rules['password'] = 'required|min:6';
$val = UserRepository::validate($input, $rules, true);
if ($val->fails()) {
return Redirect::route('users.create')->withInput()->withErrors($val->errors());
}
try {
$user = UserRepository::create($input);
$groups = GroupRepository::index();
foreach ($groups as $group) {
if (Binput::get('group_'.$group->id) === 'on') {
$user->addGroup($group);
}
}
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'password' => $password,
'email' => $user->getLogin(),
'subject' => Config::get('app.name').' - New Account Information',
];
Mail::queue('credentials::emails.newuser', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.show', ['users' => $user->id])
->with('success', 'The user has been created successfully. Their password has been emailed to them.');
} catch (UserExistsException $e) {
return Redirect::route('users.create')->withInput()->withErrors($val->errors())
->with('error', 'That email address is taken.');
}
}
|
php
|
public function store()
{
$password = Str::random();
$input = array_merge(Binput::only(['first_name', 'last_name', 'email']), [
'password' => $password,
'activated' => true,
'activated_at' => new DateTime(),
]);
$rules = UserRepository::rules(array_keys($input));
$rules['password'] = 'required|min:6';
$val = UserRepository::validate($input, $rules, true);
if ($val->fails()) {
return Redirect::route('users.create')->withInput()->withErrors($val->errors());
}
try {
$user = UserRepository::create($input);
$groups = GroupRepository::index();
foreach ($groups as $group) {
if (Binput::get('group_'.$group->id) === 'on') {
$user->addGroup($group);
}
}
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'password' => $password,
'email' => $user->getLogin(),
'subject' => Config::get('app.name').' - New Account Information',
];
Mail::queue('credentials::emails.newuser', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.show', ['users' => $user->id])
->with('success', 'The user has been created successfully. Their password has been emailed to them.');
} catch (UserExistsException $e) {
return Redirect::route('users.create')->withInput()->withErrors($val->errors())
->with('error', 'That email address is taken.');
}
}
|
[
"public",
"function",
"store",
"(",
")",
"{",
"$",
"password",
"=",
"Str",
"::",
"random",
"(",
")",
";",
"$",
"input",
"=",
"array_merge",
"(",
"Binput",
"::",
"only",
"(",
"[",
"'first_name'",
",",
"'last_name'",
",",
"'email'",
"]",
")",
",",
"[",
"'password'",
"=>",
"$",
"password",
",",
"'activated'",
"=>",
"true",
",",
"'activated_at'",
"=>",
"new",
"DateTime",
"(",
")",
",",
"]",
")",
";",
"$",
"rules",
"=",
"UserRepository",
"::",
"rules",
"(",
"array_keys",
"(",
"$",
"input",
")",
")",
";",
"$",
"rules",
"[",
"'password'",
"]",
"=",
"'required|min:6'",
";",
"$",
"val",
"=",
"UserRepository",
"::",
"validate",
"(",
"$",
"input",
",",
"$",
"rules",
",",
"true",
")",
";",
"if",
"(",
"$",
"val",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'users.create'",
")",
"->",
"withInput",
"(",
")",
"->",
"withErrors",
"(",
"$",
"val",
"->",
"errors",
"(",
")",
")",
";",
"}",
"try",
"{",
"$",
"user",
"=",
"UserRepository",
"::",
"create",
"(",
"$",
"input",
")",
";",
"$",
"groups",
"=",
"GroupRepository",
"::",
"index",
"(",
")",
";",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"Binput",
"::",
"get",
"(",
"'group_'",
".",
"$",
"group",
"->",
"id",
")",
"===",
"'on'",
")",
"{",
"$",
"user",
"->",
"addGroup",
"(",
"$",
"group",
")",
";",
"}",
"}",
"$",
"mail",
"=",
"[",
"'url'",
"=>",
"URL",
"::",
"to",
"(",
"Config",
"::",
"get",
"(",
"'credentials.home'",
",",
"'/'",
")",
")",
",",
"'password'",
"=>",
"$",
"password",
",",
"'email'",
"=>",
"$",
"user",
"->",
"getLogin",
"(",
")",
",",
"'subject'",
"=>",
"Config",
"::",
"get",
"(",
"'app.name'",
")",
".",
"' - New Account Information'",
",",
"]",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.newuser'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'email'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"'The user has been created successfully. Their password has been emailed to them.'",
")",
";",
"}",
"catch",
"(",
"UserExistsException",
"$",
"e",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'users.create'",
")",
"->",
"withInput",
"(",
")",
"->",
"withErrors",
"(",
"$",
"val",
"->",
"errors",
"(",
")",
")",
"->",
"with",
"(",
"'error'",
",",
"'That email address is taken.'",
")",
";",
"}",
"}"
] |
Store a new user.
@return \Illuminate\Http\Response
|
[
"Store",
"a",
"new",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L91-L136
|
227,112
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.show
|
public function show($id)
{
$user = UserRepository::find($id);
$this->checkUser($user);
if ($user->activated_at) {
$activated = html_ago($user->activated_at);
} else {
if (Credentials::hasAccess('admin') && Config::get('credentials.activation')) {
$activated = 'No - <a href="#resend_user" data-toggle="modal" data-target="#resend_user">Resend Email</a>';
} else {
$activated = 'Not Activated';
}
}
if (Credentials::getThrottleProvider()->findByUserId($id)->isSuspended()) {
$suspended = 'Currently Suspended';
} else {
$suspended = 'Not Suspended';
}
$groups = $user->getGroups();
if (count($groups) >= 1) {
$data = [];
foreach ($groups as $group) {
$data[] = $group->name;
}
$groups = implode(', ', $data);
} else {
$groups = 'No Group Memberships';
}
return View::make('credentials::users.show', compact('user', 'groups', 'activated', 'suspended'));
}
|
php
|
public function show($id)
{
$user = UserRepository::find($id);
$this->checkUser($user);
if ($user->activated_at) {
$activated = html_ago($user->activated_at);
} else {
if (Credentials::hasAccess('admin') && Config::get('credentials.activation')) {
$activated = 'No - <a href="#resend_user" data-toggle="modal" data-target="#resend_user">Resend Email</a>';
} else {
$activated = 'Not Activated';
}
}
if (Credentials::getThrottleProvider()->findByUserId($id)->isSuspended()) {
$suspended = 'Currently Suspended';
} else {
$suspended = 'Not Suspended';
}
$groups = $user->getGroups();
if (count($groups) >= 1) {
$data = [];
foreach ($groups as $group) {
$data[] = $group->name;
}
$groups = implode(', ', $data);
} else {
$groups = 'No Group Memberships';
}
return View::make('credentials::users.show', compact('user', 'groups', 'activated', 'suspended'));
}
|
[
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"UserRepository",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"checkUser",
"(",
"$",
"user",
")",
";",
"if",
"(",
"$",
"user",
"->",
"activated_at",
")",
"{",
"$",
"activated",
"=",
"html_ago",
"(",
"$",
"user",
"->",
"activated_at",
")",
";",
"}",
"else",
"{",
"if",
"(",
"Credentials",
"::",
"hasAccess",
"(",
"'admin'",
")",
"&&",
"Config",
"::",
"get",
"(",
"'credentials.activation'",
")",
")",
"{",
"$",
"activated",
"=",
"'No - <a href=\"#resend_user\" data-toggle=\"modal\" data-target=\"#resend_user\">Resend Email</a>'",
";",
"}",
"else",
"{",
"$",
"activated",
"=",
"'Not Activated'",
";",
"}",
"}",
"if",
"(",
"Credentials",
"::",
"getThrottleProvider",
"(",
")",
"->",
"findByUserId",
"(",
"$",
"id",
")",
"->",
"isSuspended",
"(",
")",
")",
"{",
"$",
"suspended",
"=",
"'Currently Suspended'",
";",
"}",
"else",
"{",
"$",
"suspended",
"=",
"'Not Suspended'",
";",
"}",
"$",
"groups",
"=",
"$",
"user",
"->",
"getGroups",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"groups",
")",
">=",
"1",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"group",
"->",
"name",
";",
"}",
"$",
"groups",
"=",
"implode",
"(",
"', '",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"groups",
"=",
"'No Group Memberships'",
";",
"}",
"return",
"View",
"::",
"make",
"(",
"'credentials::users.show'",
",",
"compact",
"(",
"'user'",
",",
"'groups'",
",",
"'activated'",
",",
"'suspended'",
")",
")",
";",
"}"
] |
Show the specified user.
@param int $id
@return \Illuminate\View\View
|
[
"Show",
"the",
"specified",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L145-L178
|
227,113
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.update
|
public function update($id)
{
$input = Binput::only(['first_name', 'last_name', 'email']);
$val = UserRepository::validate($input, array_keys($input));
if ($val->fails()) {
return Redirect::route('users.edit', ['users' => $id])
->withInput()->withErrors($val->errors());
}
$user = UserRepository::find($id);
$this->checkUser($user);
$email = $user['email'];
$user->update($input);
$groups = GroupRepository::index();
$changed = false;
foreach ($groups as $group) {
if ($user->inGroup($group)) {
if (Binput::get('group_'.$group->id) !== 'on') {
$user->removeGroup($group);
$changed = true;
}
} else {
if (Binput::get('group_'.$group->id) === 'on') {
$user->addGroup($group);
$changed = true;
}
}
}
if ($email !== $input['email']) {
$mail = [
'old' => $email,
'new' => $input['email'],
'url' => URL::to(Config::get('credentials.home', '/')),
'subject' => Config::get('app.name').' - New Email Information',
];
Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
$message->to($mail['old'])->subject($mail['subject']);
});
Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
$message->to($mail['new'])->subject($mail['subject']);
});
}
if ($changed) {
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'email' => $input['email'],
'subject' => Config::get('app.name').' - Group Membership Changes',
];
Mail::queue('credentials::emails.groups', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
}
return Redirect::route('users.show', ['users' => $user->id])
->with('success', 'The user has been updated successfully.');
}
|
php
|
public function update($id)
{
$input = Binput::only(['first_name', 'last_name', 'email']);
$val = UserRepository::validate($input, array_keys($input));
if ($val->fails()) {
return Redirect::route('users.edit', ['users' => $id])
->withInput()->withErrors($val->errors());
}
$user = UserRepository::find($id);
$this->checkUser($user);
$email = $user['email'];
$user->update($input);
$groups = GroupRepository::index();
$changed = false;
foreach ($groups as $group) {
if ($user->inGroup($group)) {
if (Binput::get('group_'.$group->id) !== 'on') {
$user->removeGroup($group);
$changed = true;
}
} else {
if (Binput::get('group_'.$group->id) === 'on') {
$user->addGroup($group);
$changed = true;
}
}
}
if ($email !== $input['email']) {
$mail = [
'old' => $email,
'new' => $input['email'],
'url' => URL::to(Config::get('credentials.home', '/')),
'subject' => Config::get('app.name').' - New Email Information',
];
Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
$message->to($mail['old'])->subject($mail['subject']);
});
Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
$message->to($mail['new'])->subject($mail['subject']);
});
}
if ($changed) {
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'email' => $input['email'],
'subject' => Config::get('app.name').' - Group Membership Changes',
];
Mail::queue('credentials::emails.groups', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
}
return Redirect::route('users.show', ['users' => $user->id])
->with('success', 'The user has been updated successfully.');
}
|
[
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"$",
"input",
"=",
"Binput",
"::",
"only",
"(",
"[",
"'first_name'",
",",
"'last_name'",
",",
"'email'",
"]",
")",
";",
"$",
"val",
"=",
"UserRepository",
"::",
"validate",
"(",
"$",
"input",
",",
"array_keys",
"(",
"$",
"input",
")",
")",
";",
"if",
"(",
"$",
"val",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'users.edit'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"withInput",
"(",
")",
"->",
"withErrors",
"(",
"$",
"val",
"->",
"errors",
"(",
")",
")",
";",
"}",
"$",
"user",
"=",
"UserRepository",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"checkUser",
"(",
"$",
"user",
")",
";",
"$",
"email",
"=",
"$",
"user",
"[",
"'email'",
"]",
";",
"$",
"user",
"->",
"update",
"(",
"$",
"input",
")",
";",
"$",
"groups",
"=",
"GroupRepository",
"::",
"index",
"(",
")",
";",
"$",
"changed",
"=",
"false",
";",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"inGroup",
"(",
"$",
"group",
")",
")",
"{",
"if",
"(",
"Binput",
"::",
"get",
"(",
"'group_'",
".",
"$",
"group",
"->",
"id",
")",
"!==",
"'on'",
")",
"{",
"$",
"user",
"->",
"removeGroup",
"(",
"$",
"group",
")",
";",
"$",
"changed",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"Binput",
"::",
"get",
"(",
"'group_'",
".",
"$",
"group",
"->",
"id",
")",
"===",
"'on'",
")",
"{",
"$",
"user",
"->",
"addGroup",
"(",
"$",
"group",
")",
";",
"$",
"changed",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"email",
"!==",
"$",
"input",
"[",
"'email'",
"]",
")",
"{",
"$",
"mail",
"=",
"[",
"'old'",
"=>",
"$",
"email",
",",
"'new'",
"=>",
"$",
"input",
"[",
"'email'",
"]",
",",
"'url'",
"=>",
"URL",
"::",
"to",
"(",
"Config",
"::",
"get",
"(",
"'credentials.home'",
",",
"'/'",
")",
")",
",",
"'subject'",
"=>",
"Config",
"::",
"get",
"(",
"'app.name'",
")",
".",
"' - New Email Information'",
",",
"]",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.newemail'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'old'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.newemail'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'new'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"$",
"changed",
")",
"{",
"$",
"mail",
"=",
"[",
"'url'",
"=>",
"URL",
"::",
"to",
"(",
"Config",
"::",
"get",
"(",
"'credentials.home'",
",",
"'/'",
")",
")",
",",
"'email'",
"=>",
"$",
"input",
"[",
"'email'",
"]",
",",
"'subject'",
"=>",
"Config",
"::",
"get",
"(",
"'app.name'",
")",
".",
"' - Group Membership Changes'",
",",
"]",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.groups'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'email'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"}",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"'The user has been updated successfully.'",
")",
";",
"}"
] |
Update an existing user.
@param int $id
@return \Illuminate\Http\Response
|
[
"Update",
"an",
"existing",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L204-L270
|
227,114
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.suspend
|
public function suspend($id)
{
try {
$throttle = Credentials::getThrottleProvider()->findByUserId($id);
$throttle->suspend();
} catch (UserNotFoundException $e) {
throw new NotFoundHttpException('User Not Found', $e);
} catch (UserSuspendedException $e) {
$time = $throttle->getSuspensionTime();
return Redirect::route('users.suspend', ['users' => $id])->withInput()
->with('error', "This user is already suspended for $time minutes.");
} catch (UserBannedException $e) {
return Redirect::route('users.suspend', ['users' => $id])->withInput()
->with('error', 'This user has already been banned.');
}
return Redirect::route('users.show', ['users' => $id])
->with('success', 'The user has been suspended successfully.');
}
|
php
|
public function suspend($id)
{
try {
$throttle = Credentials::getThrottleProvider()->findByUserId($id);
$throttle->suspend();
} catch (UserNotFoundException $e) {
throw new NotFoundHttpException('User Not Found', $e);
} catch (UserSuspendedException $e) {
$time = $throttle->getSuspensionTime();
return Redirect::route('users.suspend', ['users' => $id])->withInput()
->with('error', "This user is already suspended for $time minutes.");
} catch (UserBannedException $e) {
return Redirect::route('users.suspend', ['users' => $id])->withInput()
->with('error', 'This user has already been banned.');
}
return Redirect::route('users.show', ['users' => $id])
->with('success', 'The user has been suspended successfully.');
}
|
[
"public",
"function",
"suspend",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"throttle",
"=",
"Credentials",
"::",
"getThrottleProvider",
"(",
")",
"->",
"findByUserId",
"(",
"$",
"id",
")",
";",
"$",
"throttle",
"->",
"suspend",
"(",
")",
";",
"}",
"catch",
"(",
"UserNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'User Not Found'",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"UserSuspendedException",
"$",
"e",
")",
"{",
"$",
"time",
"=",
"$",
"throttle",
"->",
"getSuspensionTime",
"(",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'users.suspend'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"withInput",
"(",
")",
"->",
"with",
"(",
"'error'",
",",
"\"This user is already suspended for $time minutes.\"",
")",
";",
"}",
"catch",
"(",
"UserBannedException",
"$",
"e",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'users.suspend'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"withInput",
"(",
")",
"->",
"with",
"(",
"'error'",
",",
"'This user has already been banned.'",
")",
";",
"}",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"'The user has been suspended successfully.'",
")",
";",
"}"
] |
Suspend an existing user.
@param int $id
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
@return \Illuminate\Http\Response
|
[
"Suspend",
"an",
"existing",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L281-L300
|
227,115
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.reset
|
public function reset($id)
{
$password = Str::random();
$input = [
'password' => $password,
];
$rules = [
'password' => 'required|min:6',
];
$val = UserRepository::validate($input, $rules, true);
if ($val->fails()) {
return Redirect::route('users.show', ['users' => $id])->withErrors($val->errors());
}
$user = UserRepository::find($id);
$this->checkUser($user);
$user->update($input);
$mail = [
'password' => $password,
'email' => $user->getLogin(),
'subject' => Config::get('app.name').' - New Password Information',
];
Mail::queue('credentials::emails.password', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.show', ['users' => $id])
->with('success', 'The user\'s password has been reset successfully, and has been emailed to them.');
}
|
php
|
public function reset($id)
{
$password = Str::random();
$input = [
'password' => $password,
];
$rules = [
'password' => 'required|min:6',
];
$val = UserRepository::validate($input, $rules, true);
if ($val->fails()) {
return Redirect::route('users.show', ['users' => $id])->withErrors($val->errors());
}
$user = UserRepository::find($id);
$this->checkUser($user);
$user->update($input);
$mail = [
'password' => $password,
'email' => $user->getLogin(),
'subject' => Config::get('app.name').' - New Password Information',
];
Mail::queue('credentials::emails.password', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.show', ['users' => $id])
->with('success', 'The user\'s password has been reset successfully, and has been emailed to them.');
}
|
[
"public",
"function",
"reset",
"(",
"$",
"id",
")",
"{",
"$",
"password",
"=",
"Str",
"::",
"random",
"(",
")",
";",
"$",
"input",
"=",
"[",
"'password'",
"=>",
"$",
"password",
",",
"]",
";",
"$",
"rules",
"=",
"[",
"'password'",
"=>",
"'required|min:6'",
",",
"]",
";",
"$",
"val",
"=",
"UserRepository",
"::",
"validate",
"(",
"$",
"input",
",",
"$",
"rules",
",",
"true",
")",
";",
"if",
"(",
"$",
"val",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"withErrors",
"(",
"$",
"val",
"->",
"errors",
"(",
")",
")",
";",
"}",
"$",
"user",
"=",
"UserRepository",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"checkUser",
"(",
"$",
"user",
")",
";",
"$",
"user",
"->",
"update",
"(",
"$",
"input",
")",
";",
"$",
"mail",
"=",
"[",
"'password'",
"=>",
"$",
"password",
",",
"'email'",
"=>",
"$",
"user",
"->",
"getLogin",
"(",
")",
",",
"'subject'",
"=>",
"Config",
"::",
"get",
"(",
"'app.name'",
")",
".",
"' - New Password Information'",
",",
"]",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.password'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'email'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"'The user\\'s password has been reset successfully, and has been emailed to them.'",
")",
";",
"}"
] |
Reset the password of an existing user.
@param int $id
@return \Illuminate\Http\Response
|
[
"Reset",
"the",
"password",
"of",
"an",
"existing",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L309-L343
|
227,116
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.resend
|
public function resend($id)
{
$user = UserRepository::find($id);
$this->checkUser($user);
if ($user->activated) {
return Redirect::route('account.resend')->withInput()
->with('error', 'That user is already activated.');
}
$code = $user->getActivationCode();
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]),
'email' => $user->getLogin(),
'subject' => Config::get('app.name').' - Activation',
];
Mail::queue('credentials::emails.resend', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.show', ['users' => $id])
->with('success', 'The user\'s activation email has been sent successfully.');
}
|
php
|
public function resend($id)
{
$user = UserRepository::find($id);
$this->checkUser($user);
if ($user->activated) {
return Redirect::route('account.resend')->withInput()
->with('error', 'That user is already activated.');
}
$code = $user->getActivationCode();
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]),
'email' => $user->getLogin(),
'subject' => Config::get('app.name').' - Activation',
];
Mail::queue('credentials::emails.resend', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.show', ['users' => $id])
->with('success', 'The user\'s activation email has been sent successfully.');
}
|
[
"public",
"function",
"resend",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"UserRepository",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"checkUser",
"(",
"$",
"user",
")",
";",
"if",
"(",
"$",
"user",
"->",
"activated",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'account.resend'",
")",
"->",
"withInput",
"(",
")",
"->",
"with",
"(",
"'error'",
",",
"'That user is already activated.'",
")",
";",
"}",
"$",
"code",
"=",
"$",
"user",
"->",
"getActivationCode",
"(",
")",
";",
"$",
"mail",
"=",
"[",
"'url'",
"=>",
"URL",
"::",
"to",
"(",
"Config",
"::",
"get",
"(",
"'credentials.home'",
",",
"'/'",
")",
")",
",",
"'link'",
"=>",
"URL",
"::",
"route",
"(",
"'account.activate'",
",",
"[",
"'id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'code'",
"=>",
"$",
"code",
"]",
")",
",",
"'email'",
"=>",
"$",
"user",
"->",
"getLogin",
"(",
")",
",",
"'subject'",
"=>",
"Config",
"::",
"get",
"(",
"'app.name'",
")",
".",
"' - Activation'",
",",
"]",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.resend'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'email'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"'The user\\'s activation email has been sent successfully.'",
")",
";",
"}"
] |
Resend the activation email of an existing user.
@param int $id
@return \Illuminate\Http\Response
|
[
"Resend",
"the",
"activation",
"email",
"of",
"an",
"existing",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L352-L377
|
227,117
|
BootstrapCMS/Credentials
|
src/Http/Controllers/UserController.php
|
UserController.destroy
|
public function destroy($id)
{
$user = UserRepository::find($id);
$this->checkUser($user);
$email = $user->getLogin();
try {
$user->delete();
} catch (\Exception $e) {
return Redirect::route('users.show', ['users' => $id])
->with('error', 'We were unable to delete the account.');
}
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'email' => $email,
'subject' => Config::get('app.name').' - Account Deleted Notification',
];
Mail::queue('credentials::emails.admindeleted', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.index')
->with('success', 'The user has been deleted successfully.');
}
|
php
|
public function destroy($id)
{
$user = UserRepository::find($id);
$this->checkUser($user);
$email = $user->getLogin();
try {
$user->delete();
} catch (\Exception $e) {
return Redirect::route('users.show', ['users' => $id])
->with('error', 'We were unable to delete the account.');
}
$mail = [
'url' => URL::to(Config::get('credentials.home', '/')),
'email' => $email,
'subject' => Config::get('app.name').' - Account Deleted Notification',
];
Mail::queue('credentials::emails.admindeleted', $mail, function ($message) use ($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('users.index')
->with('success', 'The user has been deleted successfully.');
}
|
[
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"UserRepository",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"checkUser",
"(",
"$",
"user",
")",
";",
"$",
"email",
"=",
"$",
"user",
"->",
"getLogin",
"(",
")",
";",
"try",
"{",
"$",
"user",
"->",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'users.show'",
",",
"[",
"'users'",
"=>",
"$",
"id",
"]",
")",
"->",
"with",
"(",
"'error'",
",",
"'We were unable to delete the account.'",
")",
";",
"}",
"$",
"mail",
"=",
"[",
"'url'",
"=>",
"URL",
"::",
"to",
"(",
"Config",
"::",
"get",
"(",
"'credentials.home'",
",",
"'/'",
")",
")",
",",
"'email'",
"=>",
"$",
"email",
",",
"'subject'",
"=>",
"Config",
"::",
"get",
"(",
"'app.name'",
")",
".",
"' - Account Deleted Notification'",
",",
"]",
";",
"Mail",
"::",
"queue",
"(",
"'credentials::emails.admindeleted'",
",",
"$",
"mail",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"mail",
")",
"{",
"$",
"message",
"->",
"to",
"(",
"$",
"mail",
"[",
"'email'",
"]",
")",
"->",
"subject",
"(",
"$",
"mail",
"[",
"'subject'",
"]",
")",
";",
"}",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'users.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"'The user has been deleted successfully.'",
")",
";",
"}"
] |
Delete an existing user.
@param int $id
@return \Illuminate\Http\Response
|
[
"Delete",
"an",
"existing",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/UserController.php#L386-L412
|
227,118
|
cagartner/sql-anywhere-client
|
src/Cagartner/SQLAnywhereClient.php
|
SQLAnywhereClient.query
|
public function query($sql_string, $return=self::FETCH_ASSOC)
{
$query = self::exec( $sql_string );
if ( $query ) {
return $query->fetch($return);
}
return 0;
}
|
php
|
public function query($sql_string, $return=self::FETCH_ASSOC)
{
$query = self::exec( $sql_string );
if ( $query ) {
return $query->fetch($return);
}
return 0;
}
|
[
"public",
"function",
"query",
"(",
"$",
"sql_string",
",",
"$",
"return",
"=",
"self",
"::",
"FETCH_ASSOC",
")",
"{",
"$",
"query",
"=",
"self",
"::",
"exec",
"(",
"$",
"sql_string",
")",
";",
"if",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"fetch",
"(",
"$",
"return",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Retunr Array of itens
@param string $sql_string SQL command
@return array|boolean
|
[
"Retunr",
"Array",
"of",
"itens"
] |
95280faf5b2cbf34d827665ce3cbc1de187d6f11
|
https://github.com/cagartner/sql-anywhere-client/blob/95280faf5b2cbf34d827665ce3cbc1de187d6f11/src/Cagartner/SQLAnywhereClient.php#L79-L86
|
227,119
|
cagartner/sql-anywhere-client
|
src/Cagartner/SQLAnywhereClient.php
|
SQLAnywhereClient.exec
|
public function exec($sql_string)
{
$this->sql_string = $sql_string;
$query = sasql_query( $this->connection, $this->sql_string );
if ( $query ) {
return new SQLAnywhereQuery( $query, $this->connection );
} else {
throw new Exception("SQL String Problem :: " . sasql_error( $this->connection ), 110);
}
return 0;
}
|
php
|
public function exec($sql_string)
{
$this->sql_string = $sql_string;
$query = sasql_query( $this->connection, $this->sql_string );
if ( $query ) {
return new SQLAnywhereQuery( $query, $this->connection );
} else {
throw new Exception("SQL String Problem :: " . sasql_error( $this->connection ), 110);
}
return 0;
}
|
[
"public",
"function",
"exec",
"(",
"$",
"sql_string",
")",
"{",
"$",
"this",
"->",
"sql_string",
"=",
"$",
"sql_string",
";",
"$",
"query",
"=",
"sasql_query",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"sql_string",
")",
";",
"if",
"(",
"$",
"query",
")",
"{",
"return",
"new",
"SQLAnywhereQuery",
"(",
"$",
"query",
",",
"$",
"this",
"->",
"connection",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"SQL String Problem :: \"",
".",
"sasql_error",
"(",
"$",
"this",
"->",
"connection",
")",
",",
"110",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Exec a query os sql comand
@param string $sql_string SQÇ Command
@return SQLAnywhereQuery|boolean
|
[
"Exec",
"a",
"query",
"os",
"sql",
"comand"
] |
95280faf5b2cbf34d827665ce3cbc1de187d6f11
|
https://github.com/cagartner/sql-anywhere-client/blob/95280faf5b2cbf34d827665ce3cbc1de187d6f11/src/Cagartner/SQLAnywhereClient.php#L93-L103
|
227,120
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.createPermission
|
public function createPermission(array $attributes, $reload = true)
{
$this->permissions()->create($attributes);
$this->loadPermissions($reload);
}
|
php
|
public function createPermission(array $attributes, $reload = true)
{
$this->permissions()->create($attributes);
$this->loadPermissions($reload);
}
|
[
"public",
"function",
"createPermission",
"(",
"array",
"$",
"attributes",
",",
"$",
"reload",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"create",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"reload",
")",
";",
"}"
] |
Create and attach a permission.
@param array $attributes
@param bool $reload
|
[
"Create",
"and",
"attach",
"a",
"permission",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L142-L147
|
227,121
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.attachPermission
|
public function attachPermission(&$permission, $reload = true)
{
if ($this->hasPermission($permission)) return;
event(new AttachingPermissionToGroup($this, $permission));
$permission = $this->permissions()->save($permission);
event(new AttachedPermissionToGroup($this, $permission));
$this->loadPermissions($reload);
}
|
php
|
public function attachPermission(&$permission, $reload = true)
{
if ($this->hasPermission($permission)) return;
event(new AttachingPermissionToGroup($this, $permission));
$permission = $this->permissions()->save($permission);
event(new AttachedPermissionToGroup($this, $permission));
$this->loadPermissions($reload);
}
|
[
"public",
"function",
"attachPermission",
"(",
"&",
"$",
"permission",
",",
"$",
"reload",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasPermission",
"(",
"$",
"permission",
")",
")",
"return",
";",
"event",
"(",
"new",
"AttachingPermissionToGroup",
"(",
"$",
"this",
",",
"$",
"permission",
")",
")",
";",
"$",
"permission",
"=",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"save",
"(",
"$",
"permission",
")",
";",
"event",
"(",
"new",
"AttachedPermissionToGroup",
"(",
"$",
"this",
",",
"$",
"permission",
")",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"reload",
")",
";",
"}"
] |
Attach the permission to a group.
@param \Arcanesoft\Contracts\Auth\Models\Permission $permission
@param bool $reload
|
[
"Attach",
"the",
"permission",
"to",
"a",
"group",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L155-L164
|
227,122
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.attachPermissions
|
public function attachPermissions($permissions, $reload = true)
{
event(new AttachingPermissionsToGroup($this, $permissions));
$permissions = $this->permissions()->saveMany($permissions);
event(new AttachedPermissionsToGroup($this, $permissions));
$this->loadPermissions($reload);
return $permissions;
}
|
php
|
public function attachPermissions($permissions, $reload = true)
{
event(new AttachingPermissionsToGroup($this, $permissions));
$permissions = $this->permissions()->saveMany($permissions);
event(new AttachedPermissionsToGroup($this, $permissions));
$this->loadPermissions($reload);
return $permissions;
}
|
[
"public",
"function",
"attachPermissions",
"(",
"$",
"permissions",
",",
"$",
"reload",
"=",
"true",
")",
"{",
"event",
"(",
"new",
"AttachingPermissionsToGroup",
"(",
"$",
"this",
",",
"$",
"permissions",
")",
")",
";",
"$",
"permissions",
"=",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"saveMany",
"(",
"$",
"permissions",
")",
";",
"event",
"(",
"new",
"AttachedPermissionsToGroup",
"(",
"$",
"this",
",",
"$",
"permissions",
")",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"reload",
")",
";",
"return",
"$",
"permissions",
";",
"}"
] |
Attach a collection of permissions to the group.
@param \Illuminate\Database\Eloquent\Collection|array $permissions
@param bool $reload
@return \Illuminate\Database\Eloquent\Collection|array
|
[
"Attach",
"a",
"collection",
"of",
"permissions",
"to",
"the",
"group",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L192-L201
|
227,123
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.detachPermission
|
public function detachPermission(&$permission, $reload = true)
{
if ( ! $this->hasPermission($permission))
return;
/** @var \Arcanesoft\Contracts\Auth\Models\Permission $permission */
$permission = $this->getPermissionFromGroup($permission);
event(new DetachingPermissionFromGroup($this, $permission));
$permission->update(['group_id' => 0]);
event(new DetachedPermissionFromGroup($this, $permission));
$this->loadPermissions($reload);
}
|
php
|
public function detachPermission(&$permission, $reload = true)
{
if ( ! $this->hasPermission($permission))
return;
/** @var \Arcanesoft\Contracts\Auth\Models\Permission $permission */
$permission = $this->getPermissionFromGroup($permission);
event(new DetachingPermissionFromGroup($this, $permission));
$permission->update(['group_id' => 0]);
event(new DetachedPermissionFromGroup($this, $permission));
$this->loadPermissions($reload);
}
|
[
"public",
"function",
"detachPermission",
"(",
"&",
"$",
"permission",
",",
"$",
"reload",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPermission",
"(",
"$",
"permission",
")",
")",
"return",
";",
"/** @var \\Arcanesoft\\Contracts\\Auth\\Models\\Permission $permission */",
"$",
"permission",
"=",
"$",
"this",
"->",
"getPermissionFromGroup",
"(",
"$",
"permission",
")",
";",
"event",
"(",
"new",
"DetachingPermissionFromGroup",
"(",
"$",
"this",
",",
"$",
"permission",
")",
")",
";",
"$",
"permission",
"->",
"update",
"(",
"[",
"'group_id'",
"=>",
"0",
"]",
")",
";",
"event",
"(",
"new",
"DetachedPermissionFromGroup",
"(",
"$",
"this",
",",
"$",
"permission",
")",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"reload",
")",
";",
"}"
] |
Attach the permission from a group.
@param \Arcanesoft\Contracts\Auth\Models\Permission $permission
@param bool $reload
|
[
"Attach",
"the",
"permission",
"from",
"a",
"group",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L209-L222
|
227,124
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.detachPermissions
|
public function detachPermissions(array $ids, $reload = true)
{
event(new DetachingPermissionsFromGroup($this, $ids));
$detached = $this->permissions()->whereIn('id', $ids)->update(['group_id' => 0]);
event(new DetachedPermissionsFromGroup($this, $ids, $detached));
$this->loadPermissions($reload);
return $detached;
}
|
php
|
public function detachPermissions(array $ids, $reload = true)
{
event(new DetachingPermissionsFromGroup($this, $ids));
$detached = $this->permissions()->whereIn('id', $ids)->update(['group_id' => 0]);
event(new DetachedPermissionsFromGroup($this, $ids, $detached));
$this->loadPermissions($reload);
return $detached;
}
|
[
"public",
"function",
"detachPermissions",
"(",
"array",
"$",
"ids",
",",
"$",
"reload",
"=",
"true",
")",
"{",
"event",
"(",
"new",
"DetachingPermissionsFromGroup",
"(",
"$",
"this",
",",
"$",
"ids",
")",
")",
";",
"$",
"detached",
"=",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"whereIn",
"(",
"'id'",
",",
"$",
"ids",
")",
"->",
"update",
"(",
"[",
"'group_id'",
"=>",
"0",
"]",
")",
";",
"event",
"(",
"new",
"DetachedPermissionsFromGroup",
"(",
"$",
"this",
",",
"$",
"ids",
",",
"$",
"detached",
")",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"reload",
")",
";",
"return",
"$",
"detached",
";",
"}"
] |
Detach multiple permissions by ids.
@param array $ids
@param bool $reload
@return int
|
[
"Detach",
"multiple",
"permissions",
"by",
"ids",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L248-L257
|
227,125
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.detachAllPermissions
|
public function detachAllPermissions($reload = true)
{
event(new DetachingAllPermissions($this));
$detached = $this->permissions()->update(['group_id' => 0]);
event(new DetachedAllPermissions($this, $detached));
$this->loadPermissions($reload);
return $detached;
}
|
php
|
public function detachAllPermissions($reload = true)
{
event(new DetachingAllPermissions($this));
$detached = $this->permissions()->update(['group_id' => 0]);
event(new DetachedAllPermissions($this, $detached));
$this->loadPermissions($reload);
return $detached;
}
|
[
"public",
"function",
"detachAllPermissions",
"(",
"$",
"reload",
"=",
"true",
")",
"{",
"event",
"(",
"new",
"DetachingAllPermissions",
"(",
"$",
"this",
")",
")",
";",
"$",
"detached",
"=",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"update",
"(",
"[",
"'group_id'",
"=>",
"0",
"]",
")",
";",
"event",
"(",
"new",
"DetachedAllPermissions",
"(",
"$",
"this",
",",
"$",
"detached",
")",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"reload",
")",
";",
"return",
"$",
"detached",
";",
"}"
] |
Detach all permissions from the group.
@param bool $reload
@return int
|
[
"Detach",
"all",
"permissions",
"from",
"the",
"group",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L266-L275
|
227,126
|
ARCANEDEV/LaravelAuth
|
src/Models/PermissionsGroup.php
|
PermissionsGroup.getPermissionFromGroup
|
private function getPermissionFromGroup($id)
{
if ($id instanceof Eloquent) $id = $id->getKey();
$this->loadPermissions();
return $this->permissions
->filter(function (PermissionContract $permission) use ($id) {
return $permission->getKey() == $id;
})
->first();
}
|
php
|
private function getPermissionFromGroup($id)
{
if ($id instanceof Eloquent) $id = $id->getKey();
$this->loadPermissions();
return $this->permissions
->filter(function (PermissionContract $permission) use ($id) {
return $permission->getKey() == $id;
})
->first();
}
|
[
"private",
"function",
"getPermissionFromGroup",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"Eloquent",
")",
"$",
"id",
"=",
"$",
"id",
"->",
"getKey",
"(",
")",
";",
"$",
"this",
"->",
"loadPermissions",
"(",
")",
";",
"return",
"$",
"this",
"->",
"permissions",
"->",
"filter",
"(",
"function",
"(",
"PermissionContract",
"$",
"permission",
")",
"use",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"permission",
"->",
"getKey",
"(",
")",
"==",
"$",
"id",
";",
"}",
")",
"->",
"first",
"(",
")",
";",
"}"
] |
Get a permission from the group.
@param \Arcanesoft\Contracts\Auth\Models\Permission|int $id
@return \Arcanesoft\Contracts\Auth\Models\Permission|null
|
[
"Get",
"a",
"permission",
"from",
"the",
"group",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/PermissionsGroup.php#L308-L319
|
227,127
|
BootstrapCMS/Credentials
|
src/Repositories/SlugRepositoryTrait.php
|
SlugRepositoryTrait.find
|
public function find($slug, array $columns = ['*'])
{
$model = $this->model;
return $model::where('slug', '=', $slug)->first($columns);
}
|
php
|
public function find($slug, array $columns = ['*'])
{
$model = $this->model;
return $model::where('slug', '=', $slug)->first($columns);
}
|
[
"public",
"function",
"find",
"(",
"$",
"slug",
",",
"array",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"return",
"$",
"model",
"::",
"where",
"(",
"'slug'",
",",
"'='",
",",
"$",
"slug",
")",
"->",
"first",
"(",
"$",
"columns",
")",
";",
"}"
] |
Find an existing model by slug.
@param string $slug
@param string[] $columns
@return \Illuminate\Database\Eloquent\Model
|
[
"Find",
"an",
"existing",
"model",
"by",
"slug",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Repositories/SlugRepositoryTrait.php#L29-L34
|
227,128
|
hscstudio/yii2-heart
|
widgets/SideNavMetro.php
|
SideNavMetro.run
|
public function run()
{
$heading = '';
if (isset($this->heading) && $this->heading != '') {
Html::addCssClass($this->headingOptions, 'panel-heading');
$heading = Html::tag('div', '<h3 class="panel-title">' . $this->heading . '</h3>', $this->headingOptions);
}
$body = Html::tag('div', $this->renderMenu(), ['class' => 'metro table']);
$type = in_array($this->type, self::$_validTypes) ? $this->type : self::TYPE_DEFAULT;
Html::addCssClass($this->containerOptions, "panel panel-{$type}");
$this->containerOptions['style']="padding-left:10px;";
echo Html::tag('div', $heading . $body, $this->containerOptions);
}
|
php
|
public function run()
{
$heading = '';
if (isset($this->heading) && $this->heading != '') {
Html::addCssClass($this->headingOptions, 'panel-heading');
$heading = Html::tag('div', '<h3 class="panel-title">' . $this->heading . '</h3>', $this->headingOptions);
}
$body = Html::tag('div', $this->renderMenu(), ['class' => 'metro table']);
$type = in_array($this->type, self::$_validTypes) ? $this->type : self::TYPE_DEFAULT;
Html::addCssClass($this->containerOptions, "panel panel-{$type}");
$this->containerOptions['style']="padding-left:10px;";
echo Html::tag('div', $heading . $body, $this->containerOptions);
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"heading",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"heading",
")",
"&&",
"$",
"this",
"->",
"heading",
"!=",
"''",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"headingOptions",
",",
"'panel-heading'",
")",
";",
"$",
"heading",
"=",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"'<h3 class=\"panel-title\">'",
".",
"$",
"this",
"->",
"heading",
".",
"'</h3>'",
",",
"$",
"this",
"->",
"headingOptions",
")",
";",
"}",
"$",
"body",
"=",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"$",
"this",
"->",
"renderMenu",
"(",
")",
",",
"[",
"'class'",
"=>",
"'metro table'",
"]",
")",
";",
"$",
"type",
"=",
"in_array",
"(",
"$",
"this",
"->",
"type",
",",
"self",
"::",
"$",
"_validTypes",
")",
"?",
"$",
"this",
"->",
"type",
":",
"self",
"::",
"TYPE_DEFAULT",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"containerOptions",
",",
"\"panel panel-{$type}\"",
")",
";",
"$",
"this",
"->",
"containerOptions",
"[",
"'style'",
"]",
"=",
"\"padding-left:10px;\"",
";",
"echo",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"$",
"heading",
".",
"$",
"body",
",",
"$",
"this",
"->",
"containerOptions",
")",
";",
"}"
] |
Renders the side navigation menu.
with the heading and panel containers
|
[
"Renders",
"the",
"side",
"navigation",
"menu",
".",
"with",
"the",
"heading",
"and",
"panel",
"containers"
] |
7c54c7794c5045c0beb1d8bd70b287278eddbeee
|
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/widgets/SideNavMetro.php#L109-L121
|
227,129
|
hscstudio/yii2-heart
|
widgets/SideNavMetro.php
|
SideNavMetro.renderMenu
|
protected function renderMenu()
{
if ($this->route === null && Yii::$app->controller !== null) {
$this->route = Yii::$app->controller->getRoute();
}
if ($this->params === null) {
$this->params = $_GET;
}
$items = $this->normalizeItems($this->items, $hasActiveChild);
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'ul');
return Html::tag($tag, $this->renderItems($items), $options);
}
|
php
|
protected function renderMenu()
{
if ($this->route === null && Yii::$app->controller !== null) {
$this->route = Yii::$app->controller->getRoute();
}
if ($this->params === null) {
$this->params = $_GET;
}
$items = $this->normalizeItems($this->items, $hasActiveChild);
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'ul');
return Html::tag($tag, $this->renderItems($items), $options);
}
|
[
"protected",
"function",
"renderMenu",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"route",
"===",
"null",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"controller",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"route",
"=",
"Yii",
"::",
"$",
"app",
"->",
"controller",
"->",
"getRoute",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"params",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"_GET",
";",
"}",
"$",
"items",
"=",
"$",
"this",
"->",
"normalizeItems",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"hasActiveChild",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"tag",
"=",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"options",
",",
"'tag'",
",",
"'ul'",
")",
";",
"return",
"Html",
"::",
"tag",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"renderItems",
"(",
"$",
"items",
")",
",",
"$",
"options",
")",
";",
"}"
] |
Renders the main menu
|
[
"Renders",
"the",
"main",
"menu"
] |
7c54c7794c5045c0beb1d8bd70b287278eddbeee
|
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/widgets/SideNavMetro.php#L126-L138
|
227,130
|
hscstudio/yii2-heart
|
widgets/SideNavMetro.php
|
SideNavMetro.markTopItems
|
protected function markTopItems()
{
$items = [];
foreach ($this->items as $item) {
if (empty($item['items'])) {
$item['top'] = true;
}
$items[] = $item;
}
$this->items = $items;
}
|
php
|
protected function markTopItems()
{
$items = [];
foreach ($this->items as $item) {
if (empty($item['items'])) {
$item['top'] = true;
}
$items[] = $item;
}
$this->items = $items;
}
|
[
"protected",
"function",
"markTopItems",
"(",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"item",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'top'",
"]",
"=",
"true",
";",
"}",
"$",
"items",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"$",
"this",
"->",
"items",
"=",
"$",
"items",
";",
"}"
] |
Marks each topmost level item which is not a submenu
|
[
"Marks",
"each",
"topmost",
"level",
"item",
"which",
"is",
"not",
"a",
"submenu"
] |
7c54c7794c5045c0beb1d8bd70b287278eddbeee
|
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/widgets/SideNavMetro.php#L143-L153
|
227,131
|
hscstudio/yii2-heart
|
widgets/SideNavMetro.php
|
SideNavMetro.renderItem
|
protected function renderItem($item)
{
$this->validateItems($item);
$template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
$url = Url::to(ArrayHelper::getValue($item, 'url', '#'));
if (empty($item['top'])) {
if (empty($item['items'])) {
$template = str_replace('{icon}', $this->indItem . '{icon}', $template);
} else {
$template = '<a href="{url}" class="kv-toggle">{icon}{label}</a>';
$openOptions = ($item['active']) ? ['class' => 'opened'] : ['class' => 'opened', 'style' => 'display:none'];
$closeOptions = ($item['active']) ? ['class' => 'closed', 'style' => 'display:none'] : ['class' => 'closed'];
$indicator = Html::tag('span', $this->indMenuOpen, $openOptions) . Html::tag('span', $this->indMenuClose, $closeOptions);
$template = str_replace('{icon}', $indicator . '{icon}', $template);
}
}
$icon = empty($item['icon']) ? '' : '<span class="' . $this->iconPrefix . $item['icon'] . '"></span> ';
unset($item['icon'], $item['top']);
return strtr($template, [
'{url}' => $url,
'{label}' => $item['label'],
'{icon}' => $icon
]);
}
|
php
|
protected function renderItem($item)
{
$this->validateItems($item);
$template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
$url = Url::to(ArrayHelper::getValue($item, 'url', '#'));
if (empty($item['top'])) {
if (empty($item['items'])) {
$template = str_replace('{icon}', $this->indItem . '{icon}', $template);
} else {
$template = '<a href="{url}" class="kv-toggle">{icon}{label}</a>';
$openOptions = ($item['active']) ? ['class' => 'opened'] : ['class' => 'opened', 'style' => 'display:none'];
$closeOptions = ($item['active']) ? ['class' => 'closed', 'style' => 'display:none'] : ['class' => 'closed'];
$indicator = Html::tag('span', $this->indMenuOpen, $openOptions) . Html::tag('span', $this->indMenuClose, $closeOptions);
$template = str_replace('{icon}', $indicator . '{icon}', $template);
}
}
$icon = empty($item['icon']) ? '' : '<span class="' . $this->iconPrefix . $item['icon'] . '"></span> ';
unset($item['icon'], $item['top']);
return strtr($template, [
'{url}' => $url,
'{label}' => $item['label'],
'{icon}' => $icon
]);
}
|
[
"protected",
"function",
"renderItem",
"(",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"validateItems",
"(",
"$",
"item",
")",
";",
"$",
"template",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'template'",
",",
"$",
"this",
"->",
"linkTemplate",
")",
";",
"$",
"url",
"=",
"Url",
"::",
"to",
"(",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'url'",
",",
"'#'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"item",
"[",
"'top'",
"]",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"item",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"template",
"=",
"str_replace",
"(",
"'{icon}'",
",",
"$",
"this",
"->",
"indItem",
".",
"'{icon}'",
",",
"$",
"template",
")",
";",
"}",
"else",
"{",
"$",
"template",
"=",
"'<a href=\"{url}\" class=\"kv-toggle\">{icon}{label}</a>'",
";",
"$",
"openOptions",
"=",
"(",
"$",
"item",
"[",
"'active'",
"]",
")",
"?",
"[",
"'class'",
"=>",
"'opened'",
"]",
":",
"[",
"'class'",
"=>",
"'opened'",
",",
"'style'",
"=>",
"'display:none'",
"]",
";",
"$",
"closeOptions",
"=",
"(",
"$",
"item",
"[",
"'active'",
"]",
")",
"?",
"[",
"'class'",
"=>",
"'closed'",
",",
"'style'",
"=>",
"'display:none'",
"]",
":",
"[",
"'class'",
"=>",
"'closed'",
"]",
";",
"$",
"indicator",
"=",
"Html",
"::",
"tag",
"(",
"'span'",
",",
"$",
"this",
"->",
"indMenuOpen",
",",
"$",
"openOptions",
")",
".",
"Html",
"::",
"tag",
"(",
"'span'",
",",
"$",
"this",
"->",
"indMenuClose",
",",
"$",
"closeOptions",
")",
";",
"$",
"template",
"=",
"str_replace",
"(",
"'{icon}'",
",",
"$",
"indicator",
".",
"'{icon}'",
",",
"$",
"template",
")",
";",
"}",
"}",
"$",
"icon",
"=",
"empty",
"(",
"$",
"item",
"[",
"'icon'",
"]",
")",
"?",
"''",
":",
"'<span class=\"'",
".",
"$",
"this",
"->",
"iconPrefix",
".",
"$",
"item",
"[",
"'icon'",
"]",
".",
"'\"></span> '",
";",
"unset",
"(",
"$",
"item",
"[",
"'icon'",
"]",
",",
"$",
"item",
"[",
"'top'",
"]",
")",
";",
"return",
"strtr",
"(",
"$",
"template",
",",
"[",
"'{url}'",
"=>",
"$",
"url",
",",
"'{label}'",
"=>",
"$",
"item",
"[",
"'label'",
"]",
",",
"'{icon}'",
"=>",
"$",
"icon",
"]",
")",
";",
"}"
] |
Renders the content of a side navigation menu item.
@param array $item the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
@return string the rendering result
@throws InvalidConfigException
|
[
"Renders",
"the",
"content",
"of",
"a",
"side",
"navigation",
"menu",
"item",
"."
] |
7c54c7794c5045c0beb1d8bd70b287278eddbeee
|
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/widgets/SideNavMetro.php#L162-L185
|
227,132
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php
|
QueryConfigurationBuilder.drawCall
|
public function drawCall($drawCall)
{
if (!is_string($drawCall) && !is_numeric($drawCall)) {
throw new \InvalidArgumentException('$drawCall needs to be a string or numeric');
}
$this->drawCall = $drawCall;
return $this;
}
|
php
|
public function drawCall($drawCall)
{
if (!is_string($drawCall) && !is_numeric($drawCall)) {
throw new \InvalidArgumentException('$drawCall needs to be a string or numeric');
}
$this->drawCall = $drawCall;
return $this;
}
|
[
"public",
"function",
"drawCall",
"(",
"$",
"drawCall",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"drawCall",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"drawCall",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$drawCall needs to be a string or numeric'",
")",
";",
"}",
"$",
"this",
"->",
"drawCall",
"=",
"$",
"drawCall",
";",
"return",
"$",
"this",
";",
"}"
] |
Will set the drawCall parameter send by the frontend.
@param mixed $drawCall The draw call parameter
@return $this
|
[
"Will",
"set",
"the",
"drawCall",
"parameter",
"send",
"by",
"the",
"frontend",
"."
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php#L54-L61
|
227,133
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php
|
QueryConfigurationBuilder.searchRegex
|
public function searchRegex($searchRegex)
{
if (!is_bool($searchRegex) && $searchRegex !== 'false' && $searchRegex !== 'true') {
throw new \InvalidArgumentException('$searchRegex needs to be a boolean');
}
$this->searchRegex = $searchRegex;
return $this;
}
|
php
|
public function searchRegex($searchRegex)
{
if (!is_bool($searchRegex) && $searchRegex !== 'false' && $searchRegex !== 'true') {
throw new \InvalidArgumentException('$searchRegex needs to be a boolean');
}
$this->searchRegex = $searchRegex;
return $this;
}
|
[
"public",
"function",
"searchRegex",
"(",
"$",
"searchRegex",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"searchRegex",
")",
"&&",
"$",
"searchRegex",
"!==",
"'false'",
"&&",
"$",
"searchRegex",
"!==",
"'true'",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$searchRegex needs to be a boolean'",
")",
";",
"}",
"$",
"this",
"->",
"searchRegex",
"=",
"$",
"searchRegex",
";",
"return",
"$",
"this",
";",
"}"
] |
Will indicate if the global search value should be used as a regular expression
@param bool $searchRegex
@return $this
|
[
"Will",
"indicate",
"if",
"the",
"global",
"search",
"value",
"should",
"be",
"used",
"as",
"a",
"regular",
"expression"
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php#L110-L117
|
227,134
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php
|
QueryConfigurationBuilder.columnSearch
|
public function columnSearch($columnName, $searchValue)
{
if (!is_string($searchValue)) {
throw new \InvalidArgumentException('$searchValue needs to be a string');
}
$this->columSearches[$columnName] = new ColumnSearch($columnName, $searchValue);
return $this;
}
|
php
|
public function columnSearch($columnName, $searchValue)
{
if (!is_string($searchValue)) {
throw new \InvalidArgumentException('$searchValue needs to be a string');
}
$this->columSearches[$columnName] = new ColumnSearch($columnName, $searchValue);
return $this;
}
|
[
"public",
"function",
"columnSearch",
"(",
"$",
"columnName",
",",
"$",
"searchValue",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"searchValue",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$searchValue needs to be a string'",
")",
";",
"}",
"$",
"this",
"->",
"columSearches",
"[",
"$",
"columnName",
"]",
"=",
"new",
"ColumnSearch",
"(",
"$",
"columnName",
",",
"$",
"searchValue",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Will add the given search value to the given column which indicates that the frontend wants to search on the
given column for the given value
@param string $columnName The name of the column that will be searched
@param string $searchValue The value to search for
@return $this
|
[
"Will",
"add",
"the",
"given",
"search",
"value",
"to",
"the",
"given",
"column",
"which",
"indicates",
"that",
"the",
"frontend",
"wants",
"to",
"search",
"on",
"the",
"given",
"column",
"for",
"the",
"given",
"value"
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php#L126-L133
|
227,135
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php
|
QueryConfigurationBuilder.columnOrder
|
public function columnOrder($columnName, $orderDirection)
{
if (!is_string($orderDirection)) {
throw new \InvalidArgumentException('$orderDirection "' . $orderDirection . '" needs to be a string');
}
$isAscOrdering = $orderDirection === "asc" ? true : false;
$this->columnOrders[] = new ColumnOrder($columnName, $isAscOrdering);
return $this;
}
|
php
|
public function columnOrder($columnName, $orderDirection)
{
if (!is_string($orderDirection)) {
throw new \InvalidArgumentException('$orderDirection "' . $orderDirection . '" needs to be a string');
}
$isAscOrdering = $orderDirection === "asc" ? true : false;
$this->columnOrders[] = new ColumnOrder($columnName, $isAscOrdering);
return $this;
}
|
[
"public",
"function",
"columnOrder",
"(",
"$",
"columnName",
",",
"$",
"orderDirection",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"orderDirection",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$orderDirection \"'",
".",
"$",
"orderDirection",
".",
"'\" needs to be a string'",
")",
";",
"}",
"$",
"isAscOrdering",
"=",
"$",
"orderDirection",
"===",
"\"asc\"",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"columnOrders",
"[",
"]",
"=",
"new",
"ColumnOrder",
"(",
"$",
"columnName",
",",
"$",
"isAscOrdering",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Will set the ordering of the column to the given direction if possible
@param string $columnName The column name that should be ordered
@param string $orderDirection the direction that the column should be ordered by
@return $this
|
[
"Will",
"set",
"the",
"ordering",
"of",
"the",
"column",
"to",
"the",
"given",
"direction",
"if",
"possible"
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php#L141-L149
|
227,136
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php
|
QueryConfigurationBuilder.build
|
public function build()
{
return new QueryConfiguration(
$this->drawCall,
$this->start,
$this->length,
$this->searchValue,
$this->searchRegex,
$this->columSearches,
$this->columnOrders
);
}
|
php
|
public function build()
{
return new QueryConfiguration(
$this->drawCall,
$this->start,
$this->length,
$this->searchValue,
$this->searchRegex,
$this->columSearches,
$this->columnOrders
);
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"return",
"new",
"QueryConfiguration",
"(",
"$",
"this",
"->",
"drawCall",
",",
"$",
"this",
"->",
"start",
",",
"$",
"this",
"->",
"length",
",",
"$",
"this",
"->",
"searchValue",
",",
"$",
"this",
"->",
"searchRegex",
",",
"$",
"this",
"->",
"columSearches",
",",
"$",
"this",
"->",
"columnOrders",
")",
";",
"}"
] |
Will build the final QueryConfiguration that will be used later in the process pipeline
@return QueryConfiguration
|
[
"Will",
"build",
"the",
"final",
"QueryConfiguration",
"that",
"will",
"be",
"used",
"later",
"in",
"the",
"process",
"pipeline"
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Queries/QueryConfigurationBuilder.php#L155-L166
|
227,137
|
javanile/moldable
|
src/Parser/Mysql/ValueTrait.php
|
ValueTrait.getNotationValue
|
public function getNotationValue($notation, &$errors = null)
{
$type = $this->getNotationType($notation, $params, $errors);
if (in_array($type, static::TYPE_WITHOUT_VALUE)) {
return;
}
switch ($type) {
case 'integer':
return (int) $notation;
case 'boolean':
return (bool) $notation;
case 'string':
return isset($params['Default']) ? $params['Default'] : (string) $notation;
case 'float':
return (float) $notation;
case 'double':
return (float) $notation;
case 'enum':
return $params['Default'];
case 'time':
return static::parseTime($notation);
case 'date':
return static::parseDate($notation);
case 'datetime':
return static::parseDatetime($notation);
}
$errors[] = "irrational value for '{$notation}' by type '{$type}'";
// called if detected type not is handled
//throw new Exception("No PSEUDOTYPE value for '{$type}' => '{$notation}'");
}
|
php
|
public function getNotationValue($notation, &$errors = null)
{
$type = $this->getNotationType($notation, $params, $errors);
if (in_array($type, static::TYPE_WITHOUT_VALUE)) {
return;
}
switch ($type) {
case 'integer':
return (int) $notation;
case 'boolean':
return (bool) $notation;
case 'string':
return isset($params['Default']) ? $params['Default'] : (string) $notation;
case 'float':
return (float) $notation;
case 'double':
return (float) $notation;
case 'enum':
return $params['Default'];
case 'time':
return static::parseTime($notation);
case 'date':
return static::parseDate($notation);
case 'datetime':
return static::parseDatetime($notation);
}
$errors[] = "irrational value for '{$notation}' by type '{$type}'";
// called if detected type not is handled
//throw new Exception("No PSEUDOTYPE value for '{$type}' => '{$notation}'");
}
|
[
"public",
"function",
"getNotationValue",
"(",
"$",
"notation",
",",
"&",
"$",
"errors",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getNotationType",
"(",
"$",
"notation",
",",
"$",
"params",
",",
"$",
"errors",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"static",
"::",
"TYPE_WITHOUT_VALUE",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'integer'",
":",
"return",
"(",
"int",
")",
"$",
"notation",
";",
"case",
"'boolean'",
":",
"return",
"(",
"bool",
")",
"$",
"notation",
";",
"case",
"'string'",
":",
"return",
"isset",
"(",
"$",
"params",
"[",
"'Default'",
"]",
")",
"?",
"$",
"params",
"[",
"'Default'",
"]",
":",
"(",
"string",
")",
"$",
"notation",
";",
"case",
"'float'",
":",
"return",
"(",
"float",
")",
"$",
"notation",
";",
"case",
"'double'",
":",
"return",
"(",
"float",
")",
"$",
"notation",
";",
"case",
"'enum'",
":",
"return",
"$",
"params",
"[",
"'Default'",
"]",
";",
"case",
"'time'",
":",
"return",
"static",
"::",
"parseTime",
"(",
"$",
"notation",
")",
";",
"case",
"'date'",
":",
"return",
"static",
"::",
"parseDate",
"(",
"$",
"notation",
")",
";",
"case",
"'datetime'",
":",
"return",
"static",
"::",
"parseDatetime",
"(",
"$",
"notation",
")",
";",
"}",
"$",
"errors",
"[",
"]",
"=",
"\"irrational value for '{$notation}' by type '{$type}'\"",
";",
"// called if detected type not is handled",
"//throw new Exception(\"No PSEUDOTYPE value for '{$type}' => '{$notation}'\");",
"}"
] |
Retrieve value of a parsable notation
Value rapresent ...
@param type $notation
@return type
|
[
"Retrieve",
"value",
"of",
"a",
"parsable",
"notation",
"Value",
"rapresent",
"..."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/Mysql/ValueTrait.php#L24-L56
|
227,138
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/DatatableService.php
|
DatatableService.handleRequest
|
public function handleRequest()
{
$request = $this->prepareRequest();
$version = $request['version'];
$queryConfiguration = $request['queryConfiguration'];
$data = $this->provider->process();
return $version->createResponse($data, $queryConfiguration, $this->columnConfigurations);
}
|
php
|
public function handleRequest()
{
$request = $this->prepareRequest();
$version = $request['version'];
$queryConfiguration = $request['queryConfiguration'];
$data = $this->provider->process();
return $version->createResponse($data, $queryConfiguration, $this->columnConfigurations);
}
|
[
"public",
"function",
"handleRequest",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"prepareRequest",
"(",
")",
";",
"$",
"version",
"=",
"$",
"request",
"[",
"'version'",
"]",
";",
"$",
"queryConfiguration",
"=",
"$",
"request",
"[",
"'queryConfiguration'",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"provider",
"->",
"process",
"(",
")",
";",
"return",
"$",
"version",
"->",
"createResponse",
"(",
"$",
"data",
",",
"$",
"queryConfiguration",
",",
"$",
"this",
"->",
"columnConfigurations",
")",
";",
"}"
] |
Will handle the current request and returns the correct response
@return JsonResponse the response that should be returned to the client.
|
[
"Will",
"handle",
"the",
"current",
"request",
"and",
"returns",
"the",
"correct",
"response"
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/DatatableService.php#L97-L105
|
227,139
|
javanile/moldable
|
src/Model/ModelApi.php
|
ModelApi.getModel
|
public static function getModel()
{
$attribute = 'model';
if (!static::hasClassAttribute($attribute)) {
$class = static::getClass();
$slash = strrpos($class, '\\');
$model = $slash === false ? $class : substr($class, $slash + 1);
static::setClassAttribute($attribute, $model);
}
return static::getClassAttribute($attribute);
}
|
php
|
public static function getModel()
{
$attribute = 'model';
if (!static::hasClassAttribute($attribute)) {
$class = static::getClass();
$slash = strrpos($class, '\\');
$model = $slash === false ? $class : substr($class, $slash + 1);
static::setClassAttribute($attribute, $model);
}
return static::getClassAttribute($attribute);
}
|
[
"public",
"static",
"function",
"getModel",
"(",
")",
"{",
"$",
"attribute",
"=",
"'model'",
";",
"if",
"(",
"!",
"static",
"::",
"hasClassAttribute",
"(",
"$",
"attribute",
")",
")",
"{",
"$",
"class",
"=",
"static",
"::",
"getClass",
"(",
")",
";",
"$",
"slash",
"=",
"strrpos",
"(",
"$",
"class",
",",
"'\\\\'",
")",
";",
"$",
"model",
"=",
"$",
"slash",
"===",
"false",
"?",
"$",
"class",
":",
"substr",
"(",
"$",
"class",
",",
"$",
"slash",
"+",
"1",
")",
";",
"static",
"::",
"setClassAttribute",
"(",
"$",
"attribute",
",",
"$",
"model",
")",
";",
"}",
"return",
"static",
"::",
"getClassAttribute",
"(",
"$",
"attribute",
")",
";",
"}"
] |
Retrieve model name.
@return string
|
[
"Retrieve",
"model",
"name",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/ModelApi.php#L19-L32
|
227,140
|
aik099/CodingStandard
|
CodingStandard/Sniffs/NamingConventions/ValidFunctionNameSniff.php
|
ValidFunctionNameSniff.isExclusion
|
protected function isExclusion($className, $methodName, $isPublic)
{
foreach ($this->exclusions as $classRegExp => $excludedMethods) {
if (preg_match($classRegExp, $className)) {
return ($excludedMethods[0] == '*' && $isPublic) || in_array($methodName, $excludedMethods);
}
}
return false;
}
|
php
|
protected function isExclusion($className, $methodName, $isPublic)
{
foreach ($this->exclusions as $classRegExp => $excludedMethods) {
if (preg_match($classRegExp, $className)) {
return ($excludedMethods[0] == '*' && $isPublic) || in_array($methodName, $excludedMethods);
}
}
return false;
}
|
[
"protected",
"function",
"isExclusion",
"(",
"$",
"className",
",",
"$",
"methodName",
",",
"$",
"isPublic",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"exclusions",
"as",
"$",
"classRegExp",
"=>",
"$",
"excludedMethods",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"classRegExp",
",",
"$",
"className",
")",
")",
"{",
"return",
"(",
"$",
"excludedMethods",
"[",
"0",
"]",
"==",
"'*'",
"&&",
"$",
"isPublic",
")",
"||",
"in_array",
"(",
"$",
"methodName",
",",
"$",
"excludedMethods",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determines if a method name shouldn't be checked for camelCaps format.
@param string $className Class name.
@param string $methodName Method name.
@param bool $isPublic Public.
@return bool
|
[
"Determines",
"if",
"a",
"method",
"name",
"shouldn",
"t",
"be",
"checked",
"for",
"camelCaps",
"format",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/NamingConventions/ValidFunctionNameSniff.php#L203-L212
|
227,141
|
aik099/CodingStandard
|
CodingStandard/Sniffs/NamingConventions/ValidFunctionNameSniff.php
|
ValidFunctionNameSniff.isEventHandlerExclusion
|
protected function isEventHandlerExclusion($className, $methodName, array $methodParams)
{
if (strpos($className, 'EventHandler') === false) {
// Not EventHandler class.
return false;
}
return substr($methodName, 0, 2) == 'On' && count($methodParams) === 1 && $methodParams[0]['name'] === '$event';
}
|
php
|
protected function isEventHandlerExclusion($className, $methodName, array $methodParams)
{
if (strpos($className, 'EventHandler') === false) {
// Not EventHandler class.
return false;
}
return substr($methodName, 0, 2) == 'On' && count($methodParams) === 1 && $methodParams[0]['name'] === '$event';
}
|
[
"protected",
"function",
"isEventHandlerExclusion",
"(",
"$",
"className",
",",
"$",
"methodName",
",",
"array",
"$",
"methodParams",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"className",
",",
"'EventHandler'",
")",
"===",
"false",
")",
"{",
"// Not EventHandler class.",
"return",
"false",
";",
"}",
"return",
"substr",
"(",
"$",
"methodName",
",",
"0",
",",
"2",
")",
"==",
"'On'",
"&&",
"count",
"(",
"$",
"methodParams",
")",
"===",
"1",
"&&",
"$",
"methodParams",
"[",
"0",
"]",
"[",
"'name'",
"]",
"===",
"'$event'",
";",
"}"
] |
Determines if a method is an event in the event handler class.
@param string $className Class name.
@param string $methodName Method name.
@param array $methodParams Method parameters.
@return bool
|
[
"Determines",
"if",
"a",
"method",
"is",
"an",
"event",
"in",
"the",
"event",
"handler",
"class",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/NamingConventions/ValidFunctionNameSniff.php#L223-L231
|
227,142
|
aik099/CodingStandard
|
CodingStandard/Sniffs/NamingConventions/ValidFunctionNameSniff.php
|
ValidFunctionNameSniff.isTagProcessorExclusion
|
protected function isTagProcessorExclusion($className, $methodName, array $methodParams)
{
if (strpos($className, 'TagProcessor') === false) {
// Not TagProcessor class.
return false;
}
return count($methodParams) === 1 && $methodParams[0]['name'] === '$params';
}
|
php
|
protected function isTagProcessorExclusion($className, $methodName, array $methodParams)
{
if (strpos($className, 'TagProcessor') === false) {
// Not TagProcessor class.
return false;
}
return count($methodParams) === 1 && $methodParams[0]['name'] === '$params';
}
|
[
"protected",
"function",
"isTagProcessorExclusion",
"(",
"$",
"className",
",",
"$",
"methodName",
",",
"array",
"$",
"methodParams",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"className",
",",
"'TagProcessor'",
")",
"===",
"false",
")",
"{",
"// Not TagProcessor class.",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"$",
"methodParams",
")",
"===",
"1",
"&&",
"$",
"methodParams",
"[",
"0",
"]",
"[",
"'name'",
"]",
"===",
"'$params'",
";",
"}"
] |
Determines if a method is an tag in the tag processor class.
@param string $className Class name.
@param string $methodName Method name.
@param array $methodParams Method parameters.
@return bool
|
[
"Determines",
"if",
"a",
"method",
"is",
"an",
"tag",
"in",
"the",
"tag",
"processor",
"class",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/NamingConventions/ValidFunctionNameSniff.php#L243-L251
|
227,143
|
neoxygen/neo4j-neogen
|
src/Neogen.php
|
Neogen.generateGraph
|
public function generateGraph(array $userSchema)
{
$graphSchema = $this->getService('neogen.schema_builder')->buildGraph($userSchema);
return $this->getGraphGenerator()->generateGraph($graphSchema);
}
|
php
|
public function generateGraph(array $userSchema)
{
$graphSchema = $this->getService('neogen.schema_builder')->buildGraph($userSchema);
return $this->getGraphGenerator()->generateGraph($graphSchema);
}
|
[
"public",
"function",
"generateGraph",
"(",
"array",
"$",
"userSchema",
")",
"{",
"$",
"graphSchema",
"=",
"$",
"this",
"->",
"getService",
"(",
"'neogen.schema_builder'",
")",
"->",
"buildGraph",
"(",
"$",
"userSchema",
")",
";",
"return",
"$",
"this",
"->",
"getGraphGenerator",
"(",
")",
"->",
"generateGraph",
"(",
"$",
"graphSchema",
")",
";",
"}"
] |
Generates a graph based on a given user schema array
@param array $userSchema
@return Graph\Graph
|
[
"Generates",
"a",
"graph",
"based",
"on",
"a",
"given",
"user",
"schema",
"array"
] |
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
|
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Neogen.php#L83-L88
|
227,144
|
ForestAdmin/forest-php
|
src/ForestAdmin/Liana/Analyzer/DoctrineAnalyzer.php
|
DoctrineAnalyzer.getFieldForToOneAssociation
|
protected function getFieldForToOneAssociation($sourceAssociation)
{
$targetClassMetadata = $this->getClassMetadata($sourceAssociation['targetEntity']);
$joinedColumn = reset($sourceAssociation['joinColumns']);
if (!$joinedColumn) {
// One-to-One referenced only in foreign table => do not create field
return null;
}
$type = $this->getTypeForAssociation($sourceAssociation);
$fieldName = $sourceAssociation['fieldName'];
$inverseOf = $sourceAssociation['inversedBy'];
$foreignTableName = $targetClassMetadata->getTableName();
$foreignIdentifier = $targetClassMetadata->getIdentifier();
//if(count($foreignIdentifier) > 1) die(__METHOD__.'::'.__LINE__.': '.$foreignTableName.' has more than one identifier : '.json_encode($foreignIdentifier));
$foreignIdentifier = reset($foreignIdentifier);
$reference = $foreignTableName . '.' . $foreignIdentifier;
// $pivot is just the foreign key in current table
$pivot = new Pivot($joinedColumn['name']);
return new ForestField($fieldName, $type, $reference, $inverseOf, $pivot);
}
|
php
|
protected function getFieldForToOneAssociation($sourceAssociation)
{
$targetClassMetadata = $this->getClassMetadata($sourceAssociation['targetEntity']);
$joinedColumn = reset($sourceAssociation['joinColumns']);
if (!$joinedColumn) {
// One-to-One referenced only in foreign table => do not create field
return null;
}
$type = $this->getTypeForAssociation($sourceAssociation);
$fieldName = $sourceAssociation['fieldName'];
$inverseOf = $sourceAssociation['inversedBy'];
$foreignTableName = $targetClassMetadata->getTableName();
$foreignIdentifier = $targetClassMetadata->getIdentifier();
//if(count($foreignIdentifier) > 1) die(__METHOD__.'::'.__LINE__.': '.$foreignTableName.' has more than one identifier : '.json_encode($foreignIdentifier));
$foreignIdentifier = reset($foreignIdentifier);
$reference = $foreignTableName . '.' . $foreignIdentifier;
// $pivot is just the foreign key in current table
$pivot = new Pivot($joinedColumn['name']);
return new ForestField($fieldName, $type, $reference, $inverseOf, $pivot);
}
|
[
"protected",
"function",
"getFieldForToOneAssociation",
"(",
"$",
"sourceAssociation",
")",
"{",
"$",
"targetClassMetadata",
"=",
"$",
"this",
"->",
"getClassMetadata",
"(",
"$",
"sourceAssociation",
"[",
"'targetEntity'",
"]",
")",
";",
"$",
"joinedColumn",
"=",
"reset",
"(",
"$",
"sourceAssociation",
"[",
"'joinColumns'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"joinedColumn",
")",
"{",
"// One-to-One referenced only in foreign table => do not create field",
"return",
"null",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getTypeForAssociation",
"(",
"$",
"sourceAssociation",
")",
";",
"$",
"fieldName",
"=",
"$",
"sourceAssociation",
"[",
"'fieldName'",
"]",
";",
"$",
"inverseOf",
"=",
"$",
"sourceAssociation",
"[",
"'inversedBy'",
"]",
";",
"$",
"foreignTableName",
"=",
"$",
"targetClassMetadata",
"->",
"getTableName",
"(",
")",
";",
"$",
"foreignIdentifier",
"=",
"$",
"targetClassMetadata",
"->",
"getIdentifier",
"(",
")",
";",
"//if(count($foreignIdentifier) > 1) die(__METHOD__.'::'.__LINE__.': '.$foreignTableName.' has more than one identifier : '.json_encode($foreignIdentifier));",
"$",
"foreignIdentifier",
"=",
"reset",
"(",
"$",
"foreignIdentifier",
")",
";",
"$",
"reference",
"=",
"$",
"foreignTableName",
".",
"'.'",
".",
"$",
"foreignIdentifier",
";",
"// $pivot is just the foreign key in current table",
"$",
"pivot",
"=",
"new",
"Pivot",
"(",
"$",
"joinedColumn",
"[",
"'name'",
"]",
")",
";",
"return",
"new",
"ForestField",
"(",
"$",
"fieldName",
",",
"$",
"type",
",",
"$",
"reference",
",",
"$",
"inverseOf",
",",
"$",
"pivot",
")",
";",
"}"
] |
Create a schema array for one-to-one and many-to-one associations
@param $sourceAssociation
@return ForestField
|
[
"Create",
"a",
"schema",
"array",
"for",
"one",
"-",
"to",
"-",
"one",
"and",
"many",
"-",
"to",
"-",
"one",
"associations"
] |
5929816a8834d3a626125a7708d4f6aab7982134
|
https://github.com/ForestAdmin/forest-php/blob/5929816a8834d3a626125a7708d4f6aab7982134/src/ForestAdmin/Liana/Analyzer/DoctrineAnalyzer.php#L214-L240
|
227,145
|
andre487/php_rutils
|
struct/TimeParams.php
|
TimeParams.create
|
public static function create(array $aParams = null)
{
$params = new self();
if ($aParams === null) {
return $params;
}
foreach ($aParams as $name => $value) {
$params->$name = $value;
}
return $params;
}
|
php
|
public static function create(array $aParams = null)
{
$params = new self();
if ($aParams === null) {
return $params;
}
foreach ($aParams as $name => $value) {
$params->$name = $value;
}
return $params;
}
|
[
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"aParams",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"$",
"aParams",
"===",
"null",
")",
"{",
"return",
"$",
"params",
";",
"}",
"foreach",
"(",
"$",
"aParams",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"params",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"params",
";",
"}"
] |
Create params from array or with default values
@param array|null $aParams
@return TimeParams
|
[
"Create",
"params",
"from",
"array",
"or",
"with",
"default",
"values"
] |
f85a9f17d55259458326f657211c7b411a30bc53
|
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/struct/TimeParams.php#L54-L66
|
227,146
|
neoxygen/neo4j-neogen
|
src/Schema/Node.php
|
Node.getIndexedProperties
|
public function getIndexedProperties()
{
$props = [];
foreach ($this->properties as $property) {
if ($property->isIndexed()) {
$props[] = $property;
}
}
return $props;
}
|
php
|
public function getIndexedProperties()
{
$props = [];
foreach ($this->properties as $property) {
if ($property->isIndexed()) {
$props[] = $property;
}
}
return $props;
}
|
[
"public",
"function",
"getIndexedProperties",
"(",
")",
"{",
"$",
"props",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"isIndexed",
"(",
")",
")",
"{",
"$",
"props",
"[",
"]",
"=",
"$",
"property",
";",
"}",
"}",
"return",
"$",
"props",
";",
"}"
] |
Get all the properties that are indexed
@return array
|
[
"Get",
"all",
"the",
"properties",
"that",
"are",
"indexed"
] |
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
|
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Node.php#L98-L108
|
227,147
|
neoxygen/neo4j-neogen
|
src/Schema/Node.php
|
Node.getUniqueProperties
|
public function getUniqueProperties()
{
$props = [];
foreach ($this->properties as $property) {
if ($property->isUnique()) {
$props[] = $property;
}
}
return $props;
}
|
php
|
public function getUniqueProperties()
{
$props = [];
foreach ($this->properties as $property) {
if ($property->isUnique()) {
$props[] = $property;
}
}
return $props;
}
|
[
"public",
"function",
"getUniqueProperties",
"(",
")",
"{",
"$",
"props",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"isUnique",
"(",
")",
")",
"{",
"$",
"props",
"[",
"]",
"=",
"$",
"property",
";",
"}",
"}",
"return",
"$",
"props",
";",
"}"
] |
Get all the properties that are unique
@return array
|
[
"Get",
"all",
"the",
"properties",
"that",
"are",
"unique"
] |
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
|
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Node.php#L115-L125
|
227,148
|
neoxygen/neo4j-neogen
|
src/Schema/Node.php
|
Node.addLabel
|
public function addLabel($label)
{
if (null !== $label) {
$l = (string) $label;
if (!$this->hasLabel($l)) {
$this->labels->add($l);
return true;
}
}
return false;
}
|
php
|
public function addLabel($label)
{
if (null !== $label) {
$l = (string) $label;
if (!$this->hasLabel($l)) {
$this->labels->add($l);
return true;
}
}
return false;
}
|
[
"public",
"function",
"addLabel",
"(",
"$",
"label",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"label",
")",
"{",
"$",
"l",
"=",
"(",
"string",
")",
"$",
"label",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasLabel",
"(",
"$",
"l",
")",
")",
"{",
"$",
"this",
"->",
"labels",
"->",
"add",
"(",
"$",
"l",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Adds a label to this node, checks if the label does not exist to avoid duplicates
@param string $label
@return bool
|
[
"Adds",
"a",
"label",
"to",
"this",
"node",
"checks",
"if",
"the",
"label",
"does",
"not",
"exist",
"to",
"avoid",
"duplicates"
] |
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
|
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Node.php#L153-L165
|
227,149
|
neoxygen/neo4j-neogen
|
src/Schema/Node.php
|
Node.hasLabel
|
public function hasLabel($label)
{
if (null !== $label) {
$l = (string) $label;
if ($this->labels->contains($l)) {
return true;
}
}
return false;
}
|
php
|
public function hasLabel($label)
{
if (null !== $label) {
$l = (string) $label;
if ($this->labels->contains($l)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"hasLabel",
"(",
"$",
"label",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"label",
")",
"{",
"$",
"l",
"=",
"(",
"string",
")",
"$",
"label",
";",
"if",
"(",
"$",
"this",
"->",
"labels",
"->",
"contains",
"(",
"$",
"l",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks whether or not this node has the specified label
@param string $label
@return bool
|
[
"Checks",
"whether",
"or",
"not",
"this",
"node",
"has",
"the",
"specified",
"label"
] |
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
|
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Node.php#L185-L195
|
227,150
|
web2all/safebrowsingv4
|
src/GoogleSafeBrowsing/Lookup/URL.php
|
GoogleSafeBrowsing_Lookup_URL.makeRFC2396Valid
|
public static function makeRFC2396Valid($url)
{
// parse the url into parts
$parsed_url=@parse_url($url);
// check parsed url
if($parsed_url===false){
// unable to parse url
return null;
}
// when no scheme present, parse_url may go haywire
if(!isset($parsed_url['scheme'])){
// if its any kind of relative url. we are not interested and we should return null
// check if its only a fragment (starting with #)
if(preg_match('/^#/',$url)){
// yep, fragment
return null;
}
// check if it starts with a path (/some/path)
if(preg_match('#^/[^/]#',$url)){
// starts with / (but not //)
return null;
}
// check if starts with //
if(preg_match('#^//[^/]#',$url)){
// okay it starts with // (but not ///), so turn it into http://
$parsed_url=@parse_url('http:'.$url);
}else{
// okay, it doesnt have a scheme, but lets add one as it possibly could be an url
$parsed_url=@parse_url('http://'.$url);
}
if($parsed_url===false){
// unable to parse url
return null;
}
}
if(!isset($parsed_url['host'])){
// without host, we cannot do anything
return null;
}
// now create our url parts:
$scheme='http://';
if(isset($parsed_url['scheme'])){
$scheme=$parsed_url['scheme'].'://';
}
$hostname=$parsed_url['host'];
// todo: If the URL uses an internationalized domain name (IDN) it should be converted to the ASCII Punycode representation.
$port='';
if(isset($parsed_url['port'])){
$port=':'.$parsed_url['port'];
}
$path='/';
if(isset($parsed_url['path'])){
// actually path should always exist
$path=$parsed_url['path'];
}
$query='';
if(isset($parsed_url['query'])){
$query='?'.$parsed_url['query'];
}
$fragment='';
if(isset($parsed_url['fragment'])){
$fragment='#'.$parsed_url['fragment'];
}
return $scheme.$hostname.$port.$path.$query.$fragment;
}
|
php
|
public static function makeRFC2396Valid($url)
{
// parse the url into parts
$parsed_url=@parse_url($url);
// check parsed url
if($parsed_url===false){
// unable to parse url
return null;
}
// when no scheme present, parse_url may go haywire
if(!isset($parsed_url['scheme'])){
// if its any kind of relative url. we are not interested and we should return null
// check if its only a fragment (starting with #)
if(preg_match('/^#/',$url)){
// yep, fragment
return null;
}
// check if it starts with a path (/some/path)
if(preg_match('#^/[^/]#',$url)){
// starts with / (but not //)
return null;
}
// check if starts with //
if(preg_match('#^//[^/]#',$url)){
// okay it starts with // (but not ///), so turn it into http://
$parsed_url=@parse_url('http:'.$url);
}else{
// okay, it doesnt have a scheme, but lets add one as it possibly could be an url
$parsed_url=@parse_url('http://'.$url);
}
if($parsed_url===false){
// unable to parse url
return null;
}
}
if(!isset($parsed_url['host'])){
// without host, we cannot do anything
return null;
}
// now create our url parts:
$scheme='http://';
if(isset($parsed_url['scheme'])){
$scheme=$parsed_url['scheme'].'://';
}
$hostname=$parsed_url['host'];
// todo: If the URL uses an internationalized domain name (IDN) it should be converted to the ASCII Punycode representation.
$port='';
if(isset($parsed_url['port'])){
$port=':'.$parsed_url['port'];
}
$path='/';
if(isset($parsed_url['path'])){
// actually path should always exist
$path=$parsed_url['path'];
}
$query='';
if(isset($parsed_url['query'])){
$query='?'.$parsed_url['query'];
}
$fragment='';
if(isset($parsed_url['fragment'])){
$fragment='#'.$parsed_url['fragment'];
}
return $scheme.$hostname.$port.$path.$query.$fragment;
}
|
[
"public",
"static",
"function",
"makeRFC2396Valid",
"(",
"$",
"url",
")",
"{",
"// parse the url into parts",
"$",
"parsed_url",
"=",
"@",
"parse_url",
"(",
"$",
"url",
")",
";",
"// check parsed url",
"if",
"(",
"$",
"parsed_url",
"===",
"false",
")",
"{",
"// unable to parse url",
"return",
"null",
";",
"}",
"// when no scheme present, parse_url may go haywire",
"if",
"(",
"!",
"isset",
"(",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
")",
")",
"{",
"// if its any kind of relative url. we are not interested and we should return null",
"// check if its only a fragment (starting with #)",
"if",
"(",
"preg_match",
"(",
"'/^#/'",
",",
"$",
"url",
")",
")",
"{",
"// yep, fragment",
"return",
"null",
";",
"}",
"// check if it starts with a path (/some/path)",
"if",
"(",
"preg_match",
"(",
"'#^/[^/]#'",
",",
"$",
"url",
")",
")",
"{",
"// starts with / (but not //)",
"return",
"null",
";",
"}",
"// check if starts with //",
"if",
"(",
"preg_match",
"(",
"'#^//[^/]#'",
",",
"$",
"url",
")",
")",
"{",
"// okay it starts with // (but not ///), so turn it into http://",
"$",
"parsed_url",
"=",
"@",
"parse_url",
"(",
"'http:'",
".",
"$",
"url",
")",
";",
"}",
"else",
"{",
"// okay, it doesnt have a scheme, but lets add one as it possibly could be an url",
"$",
"parsed_url",
"=",
"@",
"parse_url",
"(",
"'http://'",
".",
"$",
"url",
")",
";",
"}",
"if",
"(",
"$",
"parsed_url",
"===",
"false",
")",
"{",
"// unable to parse url",
"return",
"null",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"parsed_url",
"[",
"'host'",
"]",
")",
")",
"{",
"// without host, we cannot do anything",
"return",
"null",
";",
"}",
"// now create our url parts:",
"$",
"scheme",
"=",
"'http://'",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
")",
")",
"{",
"$",
"scheme",
"=",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
".",
"'://'",
";",
"}",
"$",
"hostname",
"=",
"$",
"parsed_url",
"[",
"'host'",
"]",
";",
"// todo: If the URL uses an internationalized domain name (IDN) it should be converted to the ASCII Punycode representation.",
"$",
"port",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'port'",
"]",
")",
")",
"{",
"$",
"port",
"=",
"':'",
".",
"$",
"parsed_url",
"[",
"'port'",
"]",
";",
"}",
"$",
"path",
"=",
"'/'",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'path'",
"]",
")",
")",
"{",
"// actually path should always exist",
"$",
"path",
"=",
"$",
"parsed_url",
"[",
"'path'",
"]",
";",
"}",
"$",
"query",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"query",
"=",
"'?'",
".",
"$",
"parsed_url",
"[",
"'query'",
"]",
";",
"}",
"$",
"fragment",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'fragment'",
"]",
")",
")",
"{",
"$",
"fragment",
"=",
"'#'",
".",
"$",
"parsed_url",
"[",
"'fragment'",
"]",
";",
"}",
"return",
"$",
"scheme",
".",
"$",
"hostname",
".",
"$",
"port",
".",
"$",
"path",
".",
"$",
"query",
".",
"$",
"fragment",
";",
"}"
] |
Make valid url
Make it valid according to RFC 2396. If the URL uses an internationalized domain name (IDN),
it should be converted to the ASCII Punycode representation. The URL must include a path
component; that is, it must have a trailing slash ('http://google.com/').
@param string $url
@return string or null if not a valid url
|
[
"Make",
"valid",
"url"
] |
e506341efa8d919974c8eb362987bc1e2f398983
|
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Lookup/URL.php#L26-L93
|
227,151
|
web2all/safebrowsingv4
|
src/GoogleSafeBrowsing/Lookup/URL.php
|
GoogleSafeBrowsing_Lookup_URL.googleCanonicalize
|
public static function googleCanonicalize($url)
{
// First, remove tab (0x09), CR (0x0d), and LF (0x0a) characters from the URL. Do not remove escape sequences for these characters (e.g. '%0a').
$url=preg_replace('#[\x09\x0d\x0a]#', '', $url);
$url=self::makeRFC2396Valid(trim($url));
if(is_null($url)){
// unable to parse url
return null;
}
// Next, repeatedly percent-unescape the URL until it has no more percent-escapes.
$url=self::percentUnEscape($url);
// fixme: unescaped %23 are not handled correctly
// parse the url into parts
$parsed_url=parse_url($url);
// check parsed url
if($parsed_url===false){
// unable to parse url
return null;
}
if(!isset($parsed_url['host'])){
// without host, we cannot do anything
return null;
}
// now create our url parts:
$scheme=$parsed_url['scheme'].'://';
$hostname=$parsed_url['host'];
$hostname=strtolower($hostname);
$hostname=preg_replace('#(\.+)?(.*?)(\.+)?$#', '$2', $hostname);
// todo: handle ip address conversions
// is it IPv4 in decimal?
if(preg_match('/^[0-9]+$/',$hostname)){
// ok its a number
// lets see if its in the 32bit range
$ip4_hex=base_convert($hostname, 10, 16);
if(strlen($ip4_hex)<=8){
// ok, hex representation is less than 9 chars, so thats max FFFFFFFF
// convert to decimal dotted
// first make sure its 8 chars hex
$ip4_hex=str_pad($ip4_hex , 8, "0", STR_PAD_LEFT);
$ip4_dec_arr=array();
foreach(str_split($ip4_hex,2) as $octet){
$ip4_dec_arr[]=base_convert($octet, 16, 10);
}
$hostname=implode('.', $ip4_dec_arr);
}
}
$port='';
if(isset($parsed_url['port'])){
$port=':'.$parsed_url['port'];
}
// The sequences "/../" and "/./" in the path should be resolved by replacing "/./" with "/", and removing "/../" along with the preceding path component.
$path=preg_replace('#/\.(/|$)#', '/', $parsed_url['path']);
$path=preg_replace('#/[^/]+/\.\.(/|$)#', '/', $path);
// Replace runs of consecutive slashes with a single slash character
$path=preg_replace('#/+#', '/', $path);
$query='';
if(isset($parsed_url['query'])){
$query='?'.$parsed_url['query'];
}
// fixme: empty queries (only the questionmark) are not handled correctly, the questionmark is lost
return self::googlePercentEscape($scheme.$hostname.$port.$path.$query);
}
|
php
|
public static function googleCanonicalize($url)
{
// First, remove tab (0x09), CR (0x0d), and LF (0x0a) characters from the URL. Do not remove escape sequences for these characters (e.g. '%0a').
$url=preg_replace('#[\x09\x0d\x0a]#', '', $url);
$url=self::makeRFC2396Valid(trim($url));
if(is_null($url)){
// unable to parse url
return null;
}
// Next, repeatedly percent-unescape the URL until it has no more percent-escapes.
$url=self::percentUnEscape($url);
// fixme: unescaped %23 are not handled correctly
// parse the url into parts
$parsed_url=parse_url($url);
// check parsed url
if($parsed_url===false){
// unable to parse url
return null;
}
if(!isset($parsed_url['host'])){
// without host, we cannot do anything
return null;
}
// now create our url parts:
$scheme=$parsed_url['scheme'].'://';
$hostname=$parsed_url['host'];
$hostname=strtolower($hostname);
$hostname=preg_replace('#(\.+)?(.*?)(\.+)?$#', '$2', $hostname);
// todo: handle ip address conversions
// is it IPv4 in decimal?
if(preg_match('/^[0-9]+$/',$hostname)){
// ok its a number
// lets see if its in the 32bit range
$ip4_hex=base_convert($hostname, 10, 16);
if(strlen($ip4_hex)<=8){
// ok, hex representation is less than 9 chars, so thats max FFFFFFFF
// convert to decimal dotted
// first make sure its 8 chars hex
$ip4_hex=str_pad($ip4_hex , 8, "0", STR_PAD_LEFT);
$ip4_dec_arr=array();
foreach(str_split($ip4_hex,2) as $octet){
$ip4_dec_arr[]=base_convert($octet, 16, 10);
}
$hostname=implode('.', $ip4_dec_arr);
}
}
$port='';
if(isset($parsed_url['port'])){
$port=':'.$parsed_url['port'];
}
// The sequences "/../" and "/./" in the path should be resolved by replacing "/./" with "/", and removing "/../" along with the preceding path component.
$path=preg_replace('#/\.(/|$)#', '/', $parsed_url['path']);
$path=preg_replace('#/[^/]+/\.\.(/|$)#', '/', $path);
// Replace runs of consecutive slashes with a single slash character
$path=preg_replace('#/+#', '/', $path);
$query='';
if(isset($parsed_url['query'])){
$query='?'.$parsed_url['query'];
}
// fixme: empty queries (only the questionmark) are not handled correctly, the questionmark is lost
return self::googlePercentEscape($scheme.$hostname.$port.$path.$query);
}
|
[
"public",
"static",
"function",
"googleCanonicalize",
"(",
"$",
"url",
")",
"{",
"// First, remove tab (0x09), CR (0x0d), and LF (0x0a) characters from the URL. Do not remove escape sequences for these characters (e.g. '%0a').",
"$",
"url",
"=",
"preg_replace",
"(",
"'#[\\x09\\x0d\\x0a]#'",
",",
"''",
",",
"$",
"url",
")",
";",
"$",
"url",
"=",
"self",
"::",
"makeRFC2396Valid",
"(",
"trim",
"(",
"$",
"url",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"url",
")",
")",
"{",
"// unable to parse url",
"return",
"null",
";",
"}",
"// Next, repeatedly percent-unescape the URL until it has no more percent-escapes.",
"$",
"url",
"=",
"self",
"::",
"percentUnEscape",
"(",
"$",
"url",
")",
";",
"// fixme: unescaped %23 are not handled correctly",
"// parse the url into parts",
"$",
"parsed_url",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"// check parsed url",
"if",
"(",
"$",
"parsed_url",
"===",
"false",
")",
"{",
"// unable to parse url",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"parsed_url",
"[",
"'host'",
"]",
")",
")",
"{",
"// without host, we cannot do anything",
"return",
"null",
";",
"}",
"// now create our url parts:",
"$",
"scheme",
"=",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
".",
"'://'",
";",
"$",
"hostname",
"=",
"$",
"parsed_url",
"[",
"'host'",
"]",
";",
"$",
"hostname",
"=",
"strtolower",
"(",
"$",
"hostname",
")",
";",
"$",
"hostname",
"=",
"preg_replace",
"(",
"'#(\\.+)?(.*?)(\\.+)?$#'",
",",
"'$2'",
",",
"$",
"hostname",
")",
";",
"// todo: handle ip address conversions",
"// is it IPv4 in decimal?",
"if",
"(",
"preg_match",
"(",
"'/^[0-9]+$/'",
",",
"$",
"hostname",
")",
")",
"{",
"// ok its a number",
"// lets see if its in the 32bit range",
"$",
"ip4_hex",
"=",
"base_convert",
"(",
"$",
"hostname",
",",
"10",
",",
"16",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"ip4_hex",
")",
"<=",
"8",
")",
"{",
"// ok, hex representation is less than 9 chars, so thats max FFFFFFFF",
"// convert to decimal dotted",
"// first make sure its 8 chars hex",
"$",
"ip4_hex",
"=",
"str_pad",
"(",
"$",
"ip4_hex",
",",
"8",
",",
"\"0\"",
",",
"STR_PAD_LEFT",
")",
";",
"$",
"ip4_dec_arr",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"str_split",
"(",
"$",
"ip4_hex",
",",
"2",
")",
"as",
"$",
"octet",
")",
"{",
"$",
"ip4_dec_arr",
"[",
"]",
"=",
"base_convert",
"(",
"$",
"octet",
",",
"16",
",",
"10",
")",
";",
"}",
"$",
"hostname",
"=",
"implode",
"(",
"'.'",
",",
"$",
"ip4_dec_arr",
")",
";",
"}",
"}",
"$",
"port",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'port'",
"]",
")",
")",
"{",
"$",
"port",
"=",
"':'",
".",
"$",
"parsed_url",
"[",
"'port'",
"]",
";",
"}",
"// The sequences \"/../\" and \"/./\" in the path should be resolved by replacing \"/./\" with \"/\", and removing \"/../\" along with the preceding path component.",
"$",
"path",
"=",
"preg_replace",
"(",
"'#/\\.(/|$)#'",
",",
"'/'",
",",
"$",
"parsed_url",
"[",
"'path'",
"]",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'#/[^/]+/\\.\\.(/|$)#'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"// Replace runs of consecutive slashes with a single slash character",
"$",
"path",
"=",
"preg_replace",
"(",
"'#/+#'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"query",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"query",
"=",
"'?'",
".",
"$",
"parsed_url",
"[",
"'query'",
"]",
";",
"}",
"// fixme: empty queries (only the questionmark) are not handled correctly, the questionmark is lost",
"return",
"self",
"::",
"googlePercentEscape",
"(",
"$",
"scheme",
".",
"$",
"hostname",
".",
"$",
"port",
".",
"$",
"path",
".",
"$",
"query",
")",
";",
"}"
] |
Canonicalize the url according to google's wishes
First, remove tab (0x09), CR (0x0d), and LF (0x0a) characters from the URL. Do not remove escape sequences for these characters (e.g. '%0a').
If the URL ends in a fragment, remove the fragment. For example, shorten 'http://google.com/#frag' to 'http://google.com/'.
Next, repeatedly percent-unescape the URL until it has no more percent-escapes.
To canonicalize the hostname:
Extract the hostname from the URL and then:
1.Remove all leading and trailing dots.
2.Replace consecutive dots with a single dot.
3.If the hostname can be parsed as an IP address, normalize it to 4 dot-separated decimal values. The client should handle any
legal IP- address encoding, including octal, hex, and fewer than 4 components.
4.Lowercase the whole string.
To canonicalize the path:
- The sequences "/../" and "/./" in the path should be resolved by replacing "/./" with "/", and removing "/../" along with the preceding path component.
- Replace runs of consecutive slashes with a single slash character.
Do not apply these path canonicalizations to the query parameters.
In the URL, percent-escape all characters that are <= ASCII 32, >= 127, "#", or "%". The escapes should use uppercase hex characters.
@param string $url
@return string or null if no valid url
|
[
"Canonicalize",
"the",
"url",
"according",
"to",
"google",
"s",
"wishes"
] |
e506341efa8d919974c8eb362987bc1e2f398983
|
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Lookup/URL.php#L124-L189
|
227,152
|
web2all/safebrowsingv4
|
src/GoogleSafeBrowsing/Lookup/URL.php
|
GoogleSafeBrowsing_Lookup_URL.isHostnameIP
|
public static function isHostnameIP($hostname)
{
// IP-literal: encased in square brackets
// we match starting [ character followed by non ] characters followed by ] character as last character in hostname
if(preg_match('/^\[[^\]]\]$/',$hostname)){
// ok its an IP-literal, we do not parse the literal to see if its valid
return true;
}
// IPv4 in decimal
if(preg_match('/^[0-9]+$/',$hostname)){
// ok its a number
// lets see if its in the 32bit range
$ip4_hex=base_convert($hostname, 10, 16);
if(strlen($ip4_hex)<=8){
// ok, hex representation is less than 9 chars, so thats max FFFFFFFF
return true;
}
}
$ip_parts=Array();
if(!preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/',$hostname,$ip_parts)){
return false;
}
// check if each block is in byte range (hard to test with regex)
for($j=1;$j<=4;$j++){
if(($ip_parts[$j]>255) || ($ip_parts[$j]<0)){
return false;
}
}
return true;
}
|
php
|
public static function isHostnameIP($hostname)
{
// IP-literal: encased in square brackets
// we match starting [ character followed by non ] characters followed by ] character as last character in hostname
if(preg_match('/^\[[^\]]\]$/',$hostname)){
// ok its an IP-literal, we do not parse the literal to see if its valid
return true;
}
// IPv4 in decimal
if(preg_match('/^[0-9]+$/',$hostname)){
// ok its a number
// lets see if its in the 32bit range
$ip4_hex=base_convert($hostname, 10, 16);
if(strlen($ip4_hex)<=8){
// ok, hex representation is less than 9 chars, so thats max FFFFFFFF
return true;
}
}
$ip_parts=Array();
if(!preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/',$hostname,$ip_parts)){
return false;
}
// check if each block is in byte range (hard to test with regex)
for($j=1;$j<=4;$j++){
if(($ip_parts[$j]>255) || ($ip_parts[$j]<0)){
return false;
}
}
return true;
}
|
[
"public",
"static",
"function",
"isHostnameIP",
"(",
"$",
"hostname",
")",
"{",
"// IP-literal: encased in square brackets",
"// we match starting [ character followed by non ] characters followed by ] character as last character in hostname",
"if",
"(",
"preg_match",
"(",
"'/^\\[[^\\]]\\]$/'",
",",
"$",
"hostname",
")",
")",
"{",
"// ok its an IP-literal, we do not parse the literal to see if its valid",
"return",
"true",
";",
"}",
"// IPv4 in decimal",
"if",
"(",
"preg_match",
"(",
"'/^[0-9]+$/'",
",",
"$",
"hostname",
")",
")",
"{",
"// ok its a number",
"// lets see if its in the 32bit range",
"$",
"ip4_hex",
"=",
"base_convert",
"(",
"$",
"hostname",
",",
"10",
",",
"16",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"ip4_hex",
")",
"<=",
"8",
")",
"{",
"// ok, hex representation is less than 9 chars, so thats max FFFFFFFF",
"return",
"true",
";",
"}",
"}",
"$",
"ip_parts",
"=",
"Array",
"(",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/'",
",",
"$",
"hostname",
",",
"$",
"ip_parts",
")",
")",
"{",
"return",
"false",
";",
"}",
"// check if each block is in byte range (hard to test with regex)",
"for",
"(",
"$",
"j",
"=",
"1",
";",
"$",
"j",
"<=",
"4",
";",
"$",
"j",
"++",
")",
"{",
"if",
"(",
"(",
"$",
"ip_parts",
"[",
"$",
"j",
"]",
">",
"255",
")",
"||",
"(",
"$",
"ip_parts",
"[",
"$",
"j",
"]",
"<",
"0",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if the given hostname is an ip address
@param string $hostname
@return boolean
|
[
"Check",
"if",
"the",
"given",
"hostname",
"is",
"an",
"ip",
"address"
] |
e506341efa8d919974c8eb362987bc1e2f398983
|
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Lookup/URL.php#L320-L349
|
227,153
|
web2all/safebrowsingv4
|
src/GoogleSafeBrowsing/Lookup/URL.php
|
GoogleSafeBrowsing_Lookup_URL.percentUnEscape
|
public static function percentUnEscape($string)
{
// Next, repeatedly percent-unescape the URL until it has no more percent-escapes.
// this is not trivial, because the percent character could be in the url, when are we done?
// lets unescape till there are no more percentages, or the only percentages are %25 (the % char)
$keep_unescaping=true;
while($keep_unescaping){
if(strpos($string, '%')===false){
// no % found, done
break;
}
// replace al %25 sequences
$test_string=preg_replace('#%25#s', '', $string);
// now see if any % left
// no? then we must decode exactly one more time
if(strpos($test_string, '%')===false){
// no % found
$keep_unescaping=false;
}
$dec_string=urldecode($string);
if($dec_string==$string){
// decoding has no effect, bail out
break;
}
$string=$dec_string;
}
return $string;
}
|
php
|
public static function percentUnEscape($string)
{
// Next, repeatedly percent-unescape the URL until it has no more percent-escapes.
// this is not trivial, because the percent character could be in the url, when are we done?
// lets unescape till there are no more percentages, or the only percentages are %25 (the % char)
$keep_unescaping=true;
while($keep_unescaping){
if(strpos($string, '%')===false){
// no % found, done
break;
}
// replace al %25 sequences
$test_string=preg_replace('#%25#s', '', $string);
// now see if any % left
// no? then we must decode exactly one more time
if(strpos($test_string, '%')===false){
// no % found
$keep_unescaping=false;
}
$dec_string=urldecode($string);
if($dec_string==$string){
// decoding has no effect, bail out
break;
}
$string=$dec_string;
}
return $string;
}
|
[
"public",
"static",
"function",
"percentUnEscape",
"(",
"$",
"string",
")",
"{",
"// Next, repeatedly percent-unescape the URL until it has no more percent-escapes.",
"// this is not trivial, because the percent character could be in the url, when are we done?",
"// lets unescape till there are no more percentages, or the only percentages are %25 (the % char)",
"$",
"keep_unescaping",
"=",
"true",
";",
"while",
"(",
"$",
"keep_unescaping",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"string",
",",
"'%'",
")",
"===",
"false",
")",
"{",
"// no % found, done",
"break",
";",
"}",
"// replace al %25 sequences",
"$",
"test_string",
"=",
"preg_replace",
"(",
"'#%25#s'",
",",
"''",
",",
"$",
"string",
")",
";",
"// now see if any % left",
"// no? then we must decode exactly one more time",
"if",
"(",
"strpos",
"(",
"$",
"test_string",
",",
"'%'",
")",
"===",
"false",
")",
"{",
"// no % found",
"$",
"keep_unescaping",
"=",
"false",
";",
"}",
"$",
"dec_string",
"=",
"urldecode",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"dec_string",
"==",
"$",
"string",
")",
"{",
"// decoding has no effect, bail out",
"break",
";",
"}",
"$",
"string",
"=",
"$",
"dec_string",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
unescape the string
@param string $string
@return string
|
[
"unescape",
"the",
"string"
] |
e506341efa8d919974c8eb362987bc1e2f398983
|
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Lookup/URL.php#L377-L404
|
227,154
|
javanile/moldable
|
src/Model/QueryApi.php
|
QueryApi.query
|
public static function query($query)
{
//
static::applySchema();
//
$table = self::getTable();
$whereArray = [];
//
if (isset($query['where'])) {
$whereArray[] = '('.$query['where'].')';
unset($query['where']);
}
//
foreach ($query as $field => $value) {
if (in_array($field, ['order', 'limit'])) {
continue;
}
$whereArray[] = "{$field} = '{$value}'";
}
//
$where = count($whereArray) > 0 ? 'WHERE '.implode(' AND ', $whereArray) : '';
$order = isset($query['order']) ? 'ORDER BY '.$query['order'] : '';
$limit = isset($query['limit']) ? 'LIMIT '.$query['limit'] : '';
$sql = "SELECT * FROM {$table} {$where} {$order} {$limit}";
$results = static::getDatabase()->getResults($sql);
//
foreach ($results as &$record) {
$record = static::create($record);
}
return $results;
}
|
php
|
public static function query($query)
{
//
static::applySchema();
//
$table = self::getTable();
$whereArray = [];
//
if (isset($query['where'])) {
$whereArray[] = '('.$query['where'].')';
unset($query['where']);
}
//
foreach ($query as $field => $value) {
if (in_array($field, ['order', 'limit'])) {
continue;
}
$whereArray[] = "{$field} = '{$value}'";
}
//
$where = count($whereArray) > 0 ? 'WHERE '.implode(' AND ', $whereArray) : '';
$order = isset($query['order']) ? 'ORDER BY '.$query['order'] : '';
$limit = isset($query['limit']) ? 'LIMIT '.$query['limit'] : '';
$sql = "SELECT * FROM {$table} {$where} {$order} {$limit}";
$results = static::getDatabase()->getResults($sql);
//
foreach ($results as &$record) {
$record = static::create($record);
}
return $results;
}
|
[
"public",
"static",
"function",
"query",
"(",
"$",
"query",
")",
"{",
"//",
"static",
"::",
"applySchema",
"(",
")",
";",
"//",
"$",
"table",
"=",
"self",
"::",
"getTable",
"(",
")",
";",
"$",
"whereArray",
"=",
"[",
"]",
";",
"//",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'where'",
"]",
")",
")",
"{",
"$",
"whereArray",
"[",
"]",
"=",
"'('",
".",
"$",
"query",
"[",
"'where'",
"]",
".",
"')'",
";",
"unset",
"(",
"$",
"query",
"[",
"'where'",
"]",
")",
";",
"}",
"//",
"foreach",
"(",
"$",
"query",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"field",
",",
"[",
"'order'",
",",
"'limit'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"whereArray",
"[",
"]",
"=",
"\"{$field} = '{$value}'\"",
";",
"}",
"//",
"$",
"where",
"=",
"count",
"(",
"$",
"whereArray",
")",
">",
"0",
"?",
"'WHERE '",
".",
"implode",
"(",
"' AND '",
",",
"$",
"whereArray",
")",
":",
"''",
";",
"$",
"order",
"=",
"isset",
"(",
"$",
"query",
"[",
"'order'",
"]",
")",
"?",
"'ORDER BY '",
".",
"$",
"query",
"[",
"'order'",
"]",
":",
"''",
";",
"$",
"limit",
"=",
"isset",
"(",
"$",
"query",
"[",
"'limit'",
"]",
")",
"?",
"'LIMIT '",
".",
"$",
"query",
"[",
"'limit'",
"]",
":",
"''",
";",
"$",
"sql",
"=",
"\"SELECT * FROM {$table} {$where} {$order} {$limit}\"",
";",
"$",
"results",
"=",
"static",
"::",
"getDatabase",
"(",
")",
"->",
"getResults",
"(",
"$",
"sql",
")",
";",
"//",
"foreach",
"(",
"$",
"results",
"as",
"&",
"$",
"record",
")",
"{",
"$",
"record",
"=",
"static",
"::",
"create",
"(",
"$",
"record",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Query a list of records.
@param type $query
@return type
|
[
"Query",
"a",
"list",
"of",
"records",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/QueryApi.php#L21-L57
|
227,155
|
neoxygen/neo4j-neogen
|
src/Parser/YamlFileParser.php
|
YamlFileParser.getSchemaFileContent
|
public function getSchemaFileContent($filePath)
{
if (!$this->fs->exists($filePath)) {
throw new SchemaDefinitionException(sprintf('The schema file "%s" was not found', $filePath));
}
$content = file_get_contents($filePath);
try {
$schema = Yaml::parse($content);
return $schema;
} catch (ParseException $e) {
throw new SchemaDefinitionException($e->getMessage());
}
}
|
php
|
public function getSchemaFileContent($filePath)
{
if (!$this->fs->exists($filePath)) {
throw new SchemaDefinitionException(sprintf('The schema file "%s" was not found', $filePath));
}
$content = file_get_contents($filePath);
try {
$schema = Yaml::parse($content);
return $schema;
} catch (ParseException $e) {
throw new SchemaDefinitionException($e->getMessage());
}
}
|
[
"public",
"function",
"getSchemaFileContent",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fs",
"->",
"exists",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"SchemaDefinitionException",
"(",
"sprintf",
"(",
"'The schema file \"%s\" was not found'",
",",
"$",
"filePath",
")",
")",
";",
"}",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"filePath",
")",
";",
"try",
"{",
"$",
"schema",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"content",
")",
";",
"return",
"$",
"schema",
";",
"}",
"catch",
"(",
"ParseException",
"$",
"e",
")",
"{",
"throw",
"new",
"SchemaDefinitionException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Get the contents of the User Schema YAML File and transforms it to php array
@param $filePath
@return array
@throws SchemaDefinitionException
|
[
"Get",
"the",
"contents",
"of",
"the",
"User",
"Schema",
"YAML",
"File",
"and",
"transforms",
"it",
"to",
"php",
"array"
] |
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
|
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Parser/YamlFileParser.php#L65-L80
|
227,156
|
hscstudio/yii2-heart
|
helpers/Heart.php
|
Heart.abjad
|
public static function abjad($start=0,$end=0){
$abjadList = [];
for($i=65;$i<=90;$i++){
$abjadList[]=chr($i);
if($i==90){
for($j=65;$j<=90;$j++){
for($k=65;$k<=90;$k++){
$abjadList[]=chr($j).chr($k);
}
}
}
}
$abjad = [];
if($end<$start) $end=$start;
for($x=$start;$x<=$end;$x++){
if($x>=702) break;
$abjad[$x] = $abjadList[$x];
}
return $abjad;
}
|
php
|
public static function abjad($start=0,$end=0){
$abjadList = [];
for($i=65;$i<=90;$i++){
$abjadList[]=chr($i);
if($i==90){
for($j=65;$j<=90;$j++){
for($k=65;$k<=90;$k++){
$abjadList[]=chr($j).chr($k);
}
}
}
}
$abjad = [];
if($end<$start) $end=$start;
for($x=$start;$x<=$end;$x++){
if($x>=702) break;
$abjad[$x] = $abjadList[$x];
}
return $abjad;
}
|
[
"public",
"static",
"function",
"abjad",
"(",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"0",
")",
"{",
"$",
"abjadList",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"65",
";",
"$",
"i",
"<=",
"90",
";",
"$",
"i",
"++",
")",
"{",
"$",
"abjadList",
"[",
"]",
"=",
"chr",
"(",
"$",
"i",
")",
";",
"if",
"(",
"$",
"i",
"==",
"90",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"65",
";",
"$",
"j",
"<=",
"90",
";",
"$",
"j",
"++",
")",
"{",
"for",
"(",
"$",
"k",
"=",
"65",
";",
"$",
"k",
"<=",
"90",
";",
"$",
"k",
"++",
")",
"{",
"$",
"abjadList",
"[",
"]",
"=",
"chr",
"(",
"$",
"j",
")",
".",
"chr",
"(",
"$",
"k",
")",
";",
"}",
"}",
"}",
"}",
"$",
"abjad",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"end",
"<",
"$",
"start",
")",
"$",
"end",
"=",
"$",
"start",
";",
"for",
"(",
"$",
"x",
"=",
"$",
"start",
";",
"$",
"x",
"<=",
"$",
"end",
";",
"$",
"x",
"++",
")",
"{",
"if",
"(",
"$",
"x",
">=",
"702",
")",
"break",
";",
"$",
"abjad",
"[",
"$",
"x",
"]",
"=",
"$",
"abjadList",
"[",
"$",
"x",
"]",
";",
"}",
"return",
"$",
"abjad",
";",
"}"
] |
Generates abjad list column.
@param integer $start
@param integer $end
Example(s):
~~~
echo Heart::abjad(0); // [A]
echo Heart::abjad(28); // [AB]
echo Heart::abjad(1,3); // [B,C,D]
~~~
@see Excel columns
|
[
"Generates",
"abjad",
"list",
"column",
"."
] |
7c54c7794c5045c0beb1d8bd70b287278eddbeee
|
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/helpers/Heart.php#L43-L63
|
227,157
|
aik099/CodingStandard
|
CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
|
ControlStructureSpacingSniff.checkBracketSpacing
|
protected function checkBracketSpacing(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
return;
}
$parenOpener = $tokens[$stackPtr]['parenthesis_opener'];
$parenCloser = $tokens[$stackPtr]['parenthesis_closer'];
$spaceAfterOpen = 0;
if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) {
$spaceAfterOpen = $tokens[($parenOpener + 1)]['length'];
}
if ($spaceAfterOpen !== $this->requiredSpacesAfterOpen) {
$error = 'Expected %s spaces after "%s" opening bracket; %s found';
$data = array(
$this->requiredSpacesAfterOpen,
$tokens[$stackPtr]['content'],
$spaceAfterOpen,
);
$fix = $phpcsFile->addFixableError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = $spaceAfterOpen; $i < $this->requiredSpacesAfterOpen; $i++) {
$phpcsFile->fixer->addContent($parenOpener, ' ');
}
$phpcsFile->fixer->endChangeset();
}
}
if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line']) {
$spaceBeforeClose = 0;
if ($tokens[($parenCloser - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($parenCloser - 1)]['length'];
}
if ($spaceBeforeClose !== $this->requiredSpacesBeforeClose) {
$error = 'Expected %s spaces before "%s" closing bracket; %s found';
$data = array(
$this->requiredSpacesBeforeClose,
$tokens[$stackPtr]['content'],
$spaceBeforeClose,
);
$fix = $phpcsFile->addFixableError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = $spaceBeforeClose; $i < $this->requiredSpacesBeforeClose; $i++) {
$phpcsFile->fixer->addContentBefore($parenCloser, ' ');
}
$phpcsFile->fixer->endChangeset();
}
}
}//end if
}
|
php
|
protected function checkBracketSpacing(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
return;
}
$parenOpener = $tokens[$stackPtr]['parenthesis_opener'];
$parenCloser = $tokens[$stackPtr]['parenthesis_closer'];
$spaceAfterOpen = 0;
if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) {
$spaceAfterOpen = $tokens[($parenOpener + 1)]['length'];
}
if ($spaceAfterOpen !== $this->requiredSpacesAfterOpen) {
$error = 'Expected %s spaces after "%s" opening bracket; %s found';
$data = array(
$this->requiredSpacesAfterOpen,
$tokens[$stackPtr]['content'],
$spaceAfterOpen,
);
$fix = $phpcsFile->addFixableError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = $spaceAfterOpen; $i < $this->requiredSpacesAfterOpen; $i++) {
$phpcsFile->fixer->addContent($parenOpener, ' ');
}
$phpcsFile->fixer->endChangeset();
}
}
if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line']) {
$spaceBeforeClose = 0;
if ($tokens[($parenCloser - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($parenCloser - 1)]['length'];
}
if ($spaceBeforeClose !== $this->requiredSpacesBeforeClose) {
$error = 'Expected %s spaces before "%s" closing bracket; %s found';
$data = array(
$this->requiredSpacesBeforeClose,
$tokens[$stackPtr]['content'],
$spaceBeforeClose,
);
$fix = $phpcsFile->addFixableError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = $spaceBeforeClose; $i < $this->requiredSpacesBeforeClose; $i++) {
$phpcsFile->fixer->addContentBefore($parenCloser, ' ');
}
$phpcsFile->fixer->endChangeset();
}
}
}//end if
}
|
[
"protected",
"function",
"checkBracketSpacing",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'parenthesis_opener'",
"]",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"parenOpener",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'parenthesis_opener'",
"]",
";",
"$",
"parenCloser",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'parenthesis_closer'",
"]",
";",
"$",
"spaceAfterOpen",
"=",
"0",
";",
"if",
"(",
"$",
"tokens",
"[",
"(",
"$",
"parenOpener",
"+",
"1",
")",
"]",
"[",
"'code'",
"]",
"===",
"T_WHITESPACE",
")",
"{",
"$",
"spaceAfterOpen",
"=",
"$",
"tokens",
"[",
"(",
"$",
"parenOpener",
"+",
"1",
")",
"]",
"[",
"'length'",
"]",
";",
"}",
"if",
"(",
"$",
"spaceAfterOpen",
"!==",
"$",
"this",
"->",
"requiredSpacesAfterOpen",
")",
"{",
"$",
"error",
"=",
"'Expected %s spaces after \"%s\" opening bracket; %s found'",
";",
"$",
"data",
"=",
"array",
"(",
"$",
"this",
"->",
"requiredSpacesAfterOpen",
",",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'content'",
"]",
",",
"$",
"spaceAfterOpen",
",",
")",
";",
"$",
"fix",
"=",
"$",
"phpcsFile",
"->",
"addFixableError",
"(",
"$",
"error",
",",
"(",
"$",
"parenOpener",
"+",
"1",
")",
",",
"'SpacingAfterOpenBrace'",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"fix",
"===",
"true",
")",
"{",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"beginChangeset",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"spaceAfterOpen",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"requiredSpacesAfterOpen",
";",
"$",
"i",
"++",
")",
"{",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"addContent",
"(",
"$",
"parenOpener",
",",
"' '",
")",
";",
"}",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"endChangeset",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"tokens",
"[",
"$",
"parenOpener",
"]",
"[",
"'line'",
"]",
"===",
"$",
"tokens",
"[",
"$",
"parenCloser",
"]",
"[",
"'line'",
"]",
")",
"{",
"$",
"spaceBeforeClose",
"=",
"0",
";",
"if",
"(",
"$",
"tokens",
"[",
"(",
"$",
"parenCloser",
"-",
"1",
")",
"]",
"[",
"'code'",
"]",
"===",
"T_WHITESPACE",
")",
"{",
"$",
"spaceBeforeClose",
"=",
"$",
"tokens",
"[",
"(",
"$",
"parenCloser",
"-",
"1",
")",
"]",
"[",
"'length'",
"]",
";",
"}",
"if",
"(",
"$",
"spaceBeforeClose",
"!==",
"$",
"this",
"->",
"requiredSpacesBeforeClose",
")",
"{",
"$",
"error",
"=",
"'Expected %s spaces before \"%s\" closing bracket; %s found'",
";",
"$",
"data",
"=",
"array",
"(",
"$",
"this",
"->",
"requiredSpacesBeforeClose",
",",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'content'",
"]",
",",
"$",
"spaceBeforeClose",
",",
")",
";",
"$",
"fix",
"=",
"$",
"phpcsFile",
"->",
"addFixableError",
"(",
"$",
"error",
",",
"(",
"$",
"parenCloser",
"-",
"1",
")",
",",
"'SpaceBeforeCloseBrace'",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"fix",
"===",
"true",
")",
"{",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"beginChangeset",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"spaceBeforeClose",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"requiredSpacesBeforeClose",
";",
"$",
"i",
"++",
")",
"{",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"addContentBefore",
"(",
"$",
"parenCloser",
",",
"' '",
")",
";",
"}",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"endChangeset",
"(",
")",
";",
"}",
"}",
"}",
"//end if",
"}"
] |
Checks bracket spacing.
@param File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return void
|
[
"Checks",
"bracket",
"spacing",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L121-L182
|
227,158
|
aik099/CodingStandard
|
CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
|
ControlStructureSpacingSniff.getLeadingCommentOrSelf
|
protected function getLeadingCommentOrSelf(File $phpcsFile, $stackPtr)
{
$prevTokens = array($stackPtr);
$tokens = $phpcsFile->getTokens();
do {
$prev = end($prevTokens);
$newPrev = $phpcsFile->findPrevious(
T_WHITESPACE,
($prev - 1),
null,
true
);
if ($tokens[$newPrev]['code'] === T_COMMENT
&& $tokens[$newPrev]['line'] === ($tokens[$prev]['line'] - 1)
) {
$prevTokens[] = $newPrev;
} else {
break;
}
} while (true);
return end($prevTokens);
}
|
php
|
protected function getLeadingCommentOrSelf(File $phpcsFile, $stackPtr)
{
$prevTokens = array($stackPtr);
$tokens = $phpcsFile->getTokens();
do {
$prev = end($prevTokens);
$newPrev = $phpcsFile->findPrevious(
T_WHITESPACE,
($prev - 1),
null,
true
);
if ($tokens[$newPrev]['code'] === T_COMMENT
&& $tokens[$newPrev]['line'] === ($tokens[$prev]['line'] - 1)
) {
$prevTokens[] = $newPrev;
} else {
break;
}
} while (true);
return end($prevTokens);
}
|
[
"protected",
"function",
"getLeadingCommentOrSelf",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"prevTokens",
"=",
"array",
"(",
"$",
"stackPtr",
")",
";",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"do",
"{",
"$",
"prev",
"=",
"end",
"(",
"$",
"prevTokens",
")",
";",
"$",
"newPrev",
"=",
"$",
"phpcsFile",
"->",
"findPrevious",
"(",
"T_WHITESPACE",
",",
"(",
"$",
"prev",
"-",
"1",
")",
",",
"null",
",",
"true",
")",
";",
"if",
"(",
"$",
"tokens",
"[",
"$",
"newPrev",
"]",
"[",
"'code'",
"]",
"===",
"T_COMMENT",
"&&",
"$",
"tokens",
"[",
"$",
"newPrev",
"]",
"[",
"'line'",
"]",
"===",
"(",
"$",
"tokens",
"[",
"$",
"prev",
"]",
"[",
"'line'",
"]",
"-",
"1",
")",
")",
"{",
"$",
"prevTokens",
"[",
"]",
"=",
"$",
"newPrev",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"while",
"(",
"true",
")",
";",
"return",
"end",
"(",
"$",
"prevTokens",
")",
";",
"}"
] |
Returns leading comment or self.
@param File $phpcsFile All the tokens found in the document.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return bool|int
|
[
"Returns",
"leading",
"comment",
"or",
"self",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L408-L432
|
227,159
|
aik099/CodingStandard
|
CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
|
ControlStructureSpacingSniff.getScopeCloser
|
protected function getScopeCloser(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$scopeCloser = $tokens[$stackPtr]['scope_closer'];
if ($tokens[$stackPtr]['code'] !== T_DO) {
return $scopeCloser;
}
$trailingContent = $phpcsFile->findNext(
Tokens::$emptyTokens,
($scopeCloser + 1),
null,
true
);
if ($tokens[$trailingContent]['code'] === T_WHILE) {
return ($tokens[$trailingContent]['parenthesis_closer'] + 1);
}
// @codeCoverageIgnoreStart
$phpcsFile->addError('Expected "while" not found after "do"', $stackPtr, 'InvalidDo');
return $scopeCloser;
// @codeCoverageIgnoreEnd
}
|
php
|
protected function getScopeCloser(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$scopeCloser = $tokens[$stackPtr]['scope_closer'];
if ($tokens[$stackPtr]['code'] !== T_DO) {
return $scopeCloser;
}
$trailingContent = $phpcsFile->findNext(
Tokens::$emptyTokens,
($scopeCloser + 1),
null,
true
);
if ($tokens[$trailingContent]['code'] === T_WHILE) {
return ($tokens[$trailingContent]['parenthesis_closer'] + 1);
}
// @codeCoverageIgnoreStart
$phpcsFile->addError('Expected "while" not found after "do"', $stackPtr, 'InvalidDo');
return $scopeCloser;
// @codeCoverageIgnoreEnd
}
|
[
"protected",
"function",
"getScopeCloser",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"scopeCloser",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'scope_closer'",
"]",
";",
"if",
"(",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'code'",
"]",
"!==",
"T_DO",
")",
"{",
"return",
"$",
"scopeCloser",
";",
"}",
"$",
"trailingContent",
"=",
"$",
"phpcsFile",
"->",
"findNext",
"(",
"Tokens",
"::",
"$",
"emptyTokens",
",",
"(",
"$",
"scopeCloser",
"+",
"1",
")",
",",
"null",
",",
"true",
")",
";",
"if",
"(",
"$",
"tokens",
"[",
"$",
"trailingContent",
"]",
"[",
"'code'",
"]",
"===",
"T_WHILE",
")",
"{",
"return",
"(",
"$",
"tokens",
"[",
"$",
"trailingContent",
"]",
"[",
"'parenthesis_closer'",
"]",
"+",
"1",
")",
";",
"}",
"// @codeCoverageIgnoreStart",
"$",
"phpcsFile",
"->",
"addError",
"(",
"'Expected \"while\" not found after \"do\"'",
",",
"$",
"stackPtr",
",",
"'InvalidDo'",
")",
";",
"return",
"$",
"scopeCloser",
";",
"// @codeCoverageIgnoreEnd",
"}"
] |
Returns scope closer with special check for "do...while" statements.
@param File $phpcsFile All the tokens found in the document.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return int|bool
|
[
"Returns",
"scope",
"closer",
"with",
"special",
"check",
"for",
"do",
"...",
"while",
"statements",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L532-L557
|
227,160
|
aik099/CodingStandard
|
CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
|
ControlStructureSpacingSniff.getTrailingContent
|
protected function getTrailingContent(File $phpcsFile, $stackPtr)
{
$nextNonWhitespace = $phpcsFile->findNext(
array(
T_WHITESPACE,
T_COMMENT,
),
($stackPtr + 1),
null,
true
);
return $nextNonWhitespace;
}
|
php
|
protected function getTrailingContent(File $phpcsFile, $stackPtr)
{
$nextNonWhitespace = $phpcsFile->findNext(
array(
T_WHITESPACE,
T_COMMENT,
),
($stackPtr + 1),
null,
true
);
return $nextNonWhitespace;
}
|
[
"protected",
"function",
"getTrailingContent",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"nextNonWhitespace",
"=",
"$",
"phpcsFile",
"->",
"findNext",
"(",
"array",
"(",
"T_WHITESPACE",
",",
"T_COMMENT",
",",
")",
",",
"(",
"$",
"stackPtr",
"+",
"1",
")",
",",
"null",
",",
"true",
")",
";",
"return",
"$",
"nextNonWhitespace",
";",
"}"
] |
Returns trailing content token.
@param File $phpcsFile All the tokens found in the document.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return int|bool
|
[
"Returns",
"trailing",
"content",
"token",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L569-L582
|
227,161
|
aik099/CodingStandard
|
CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
|
ControlStructureSpacingSniff.getTrailingCommentOrSelf
|
protected function getTrailingCommentOrSelf(File $phpcsFile, $stackPtr)
{
$nextTokens = array($stackPtr);
$tokens = $phpcsFile->getTokens();
do {
$next = end($nextTokens);
$newNext = $phpcsFile->findNext(
T_WHITESPACE,
($next + 1),
null,
true
);
if ($tokens[$newNext]['code'] === T_COMMENT
&& $tokens[$newNext]['line'] === ($tokens[$next]['line'] + 1)
) {
$nextTokens[] = $newNext;
} else {
break;
}
} while (true);
return end($nextTokens);
}
|
php
|
protected function getTrailingCommentOrSelf(File $phpcsFile, $stackPtr)
{
$nextTokens = array($stackPtr);
$tokens = $phpcsFile->getTokens();
do {
$next = end($nextTokens);
$newNext = $phpcsFile->findNext(
T_WHITESPACE,
($next + 1),
null,
true
);
if ($tokens[$newNext]['code'] === T_COMMENT
&& $tokens[$newNext]['line'] === ($tokens[$next]['line'] + 1)
) {
$nextTokens[] = $newNext;
} else {
break;
}
} while (true);
return end($nextTokens);
}
|
[
"protected",
"function",
"getTrailingCommentOrSelf",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"nextTokens",
"=",
"array",
"(",
"$",
"stackPtr",
")",
";",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"do",
"{",
"$",
"next",
"=",
"end",
"(",
"$",
"nextTokens",
")",
";",
"$",
"newNext",
"=",
"$",
"phpcsFile",
"->",
"findNext",
"(",
"T_WHITESPACE",
",",
"(",
"$",
"next",
"+",
"1",
")",
",",
"null",
",",
"true",
")",
";",
"if",
"(",
"$",
"tokens",
"[",
"$",
"newNext",
"]",
"[",
"'code'",
"]",
"===",
"T_COMMENT",
"&&",
"$",
"tokens",
"[",
"$",
"newNext",
"]",
"[",
"'line'",
"]",
"===",
"(",
"$",
"tokens",
"[",
"$",
"next",
"]",
"[",
"'line'",
"]",
"+",
"1",
")",
")",
"{",
"$",
"nextTokens",
"[",
"]",
"=",
"$",
"newNext",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"while",
"(",
"true",
")",
";",
"return",
"end",
"(",
"$",
"nextTokens",
")",
";",
"}"
] |
Returns trailing comment or self.
@param File $phpcsFile All the tokens found in the document.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return bool|int
|
[
"Returns",
"trailing",
"comment",
"or",
"self",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L594-L618
|
227,162
|
aik099/CodingStandard
|
CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
|
ControlStructureSpacingSniff.isClosure
|
protected function isClosure(File $phpcsFile, $stackPtr, $scopeConditionPtr)
{
$tokens = $phpcsFile->getTokens();
if ($this->isScopeCondition($phpcsFile, $scopeConditionPtr, T_CLOSURE) === true
&& ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true
|| $phpcsFile->hasCondition($stackPtr, T_CLOSURE) === true
|| isset($tokens[$stackPtr]['nested_parenthesis']) === true)
) {
return true;
}
return false;
}
|
php
|
protected function isClosure(File $phpcsFile, $stackPtr, $scopeConditionPtr)
{
$tokens = $phpcsFile->getTokens();
if ($this->isScopeCondition($phpcsFile, $scopeConditionPtr, T_CLOSURE) === true
&& ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true
|| $phpcsFile->hasCondition($stackPtr, T_CLOSURE) === true
|| isset($tokens[$stackPtr]['nested_parenthesis']) === true)
) {
return true;
}
return false;
}
|
[
"protected",
"function",
"isClosure",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"$",
"scopeConditionPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isScopeCondition",
"(",
"$",
"phpcsFile",
",",
"$",
"scopeConditionPtr",
",",
"T_CLOSURE",
")",
"===",
"true",
"&&",
"(",
"$",
"phpcsFile",
"->",
"hasCondition",
"(",
"$",
"stackPtr",
",",
"T_FUNCTION",
")",
"===",
"true",
"||",
"$",
"phpcsFile",
"->",
"hasCondition",
"(",
"$",
"stackPtr",
",",
"T_CLOSURE",
")",
"===",
"true",
"||",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'nested_parenthesis'",
"]",
")",
"===",
"true",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Determines that a closure is located at given position.
@param File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token.
in the stack passed in $tokens.
@param int $scopeConditionPtr Position of scope condition.
@return bool
|
[
"Determines",
"that",
"a",
"closure",
"is",
"located",
"at",
"given",
"position",
"."
] |
0f65c52bf2d95d5068af9f73110770ddb9de8de7
|
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L767-L780
|
227,163
|
matthewbdaly/laravel-repositories
|
src/Repositories/Decorators/BaseDecorator.php
|
BaseDecorator.firstOrCreate
|
public function firstOrCreate(array $input)
{
$this->cache->tags($this->getModel())->flush();
return $this->repository->firstOrCreate($input);
}
|
php
|
public function firstOrCreate(array $input)
{
$this->cache->tags($this->getModel())->flush();
return $this->repository->firstOrCreate($input);
}
|
[
"public",
"function",
"firstOrCreate",
"(",
"array",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"tags",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"repository",
"->",
"firstOrCreate",
"(",
"$",
"input",
")",
";",
"}"
] |
Get or create row
@param array $input The input data.
@return \Illuminate\Database\Eloquent\Model
|
[
"Get",
"or",
"create",
"row"
] |
af05180e3674fa3a9f5ba6f9ecccdda10b41135a
|
https://github.com/matthewbdaly/laravel-repositories/blob/af05180e3674fa3a9f5ba6f9ecccdda10b41135a/src/Repositories/Decorators/BaseDecorator.php#L190-L194
|
227,164
|
matthewbdaly/laravel-repositories
|
src/Repositories/Decorators/BaseDecorator.php
|
BaseDecorator.updateOrCreate
|
public function updateOrCreate(array $input)
{
$this->cache->tags($this->getModel())->flush();
return $this->repository->updateOrCreate($input);
}
|
php
|
public function updateOrCreate(array $input)
{
$this->cache->tags($this->getModel())->flush();
return $this->repository->updateOrCreate($input);
}
|
[
"public",
"function",
"updateOrCreate",
"(",
"array",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"tags",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"repository",
"->",
"updateOrCreate",
"(",
"$",
"input",
")",
";",
"}"
] |
Update or create row
@param array $input The input data.
@return \Illuminate\Database\Eloquent\Model
|
[
"Update",
"or",
"create",
"row"
] |
af05180e3674fa3a9f5ba6f9ecccdda10b41135a
|
https://github.com/matthewbdaly/laravel-repositories/blob/af05180e3674fa3a9f5ba6f9ecccdda10b41135a/src/Repositories/Decorators/BaseDecorator.php#L202-L206
|
227,165
|
BootstrapCMS/Credentials
|
src/Models/Throttle.php
|
Throttle.suspend
|
public function suspend()
{
RevisionRepository::create([
'revisionable_type' => Config::get('sentry.users.model'),
'revisionable_id' => $this['user_id'],
'key' => 'suspended_at',
'old_value' => $this['suspended_at'],
'new_value' => new DateTime(),
'user_id' => null,
]);
parent::suspend();
}
|
php
|
public function suspend()
{
RevisionRepository::create([
'revisionable_type' => Config::get('sentry.users.model'),
'revisionable_id' => $this['user_id'],
'key' => 'suspended_at',
'old_value' => $this['suspended_at'],
'new_value' => new DateTime(),
'user_id' => null,
]);
parent::suspend();
}
|
[
"public",
"function",
"suspend",
"(",
")",
"{",
"RevisionRepository",
"::",
"create",
"(",
"[",
"'revisionable_type'",
"=>",
"Config",
"::",
"get",
"(",
"'sentry.users.model'",
")",
",",
"'revisionable_id'",
"=>",
"$",
"this",
"[",
"'user_id'",
"]",
",",
"'key'",
"=>",
"'suspended_at'",
",",
"'old_value'",
"=>",
"$",
"this",
"[",
"'suspended_at'",
"]",
",",
"'new_value'",
"=>",
"new",
"DateTime",
"(",
")",
",",
"'user_id'",
"=>",
"null",
",",
"]",
")",
";",
"parent",
"::",
"suspend",
"(",
")",
";",
"}"
] |
Suspend the user associated with the throttle.
@return void
|
[
"Suspend",
"the",
"user",
"associated",
"with",
"the",
"throttle",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Throttle.php#L66-L78
|
227,166
|
javanile/moldable
|
src/Parser/MysqlParser.php
|
MysqlParser.parse
|
public function parse(&$schema)
{
// loop throh tables on the schema
foreach ($schema as &$table) {
static::parseTable($table);
}
// loop throh tables on the schema
foreach ($schema as &$table) {
foreach ($table as $aspects) {
if (isset($aspects['Relation']) && $aspects['Relation'] == 'many-to-many') {
$schema['Cioa'] = [[]];
}
}
}
}
|
php
|
public function parse(&$schema)
{
// loop throh tables on the schema
foreach ($schema as &$table) {
static::parseTable($table);
}
// loop throh tables on the schema
foreach ($schema as &$table) {
foreach ($table as $aspects) {
if (isset($aspects['Relation']) && $aspects['Relation'] == 'many-to-many') {
$schema['Cioa'] = [[]];
}
}
}
}
|
[
"public",
"function",
"parse",
"(",
"&",
"$",
"schema",
")",
"{",
"// loop throh tables on the schema",
"foreach",
"(",
"$",
"schema",
"as",
"&",
"$",
"table",
")",
"{",
"static",
"::",
"parseTable",
"(",
"$",
"table",
")",
";",
"}",
"// loop throh tables on the schema",
"foreach",
"(",
"$",
"schema",
"as",
"&",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"as",
"$",
"aspects",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"aspects",
"[",
"'Relation'",
"]",
")",
"&&",
"$",
"aspects",
"[",
"'Relation'",
"]",
"==",
"'many-to-many'",
")",
"{",
"$",
"schema",
"[",
"'Cioa'",
"]",
"=",
"[",
"[",
"]",
"]",
";",
"}",
"}",
"}",
"}"
] |
parse a multi-table schema to sanitize end explode implicit info.
@param type $schema
@return type
|
[
"parse",
"a",
"multi",
"-",
"table",
"schema",
"to",
"sanitize",
"end",
"explode",
"implicit",
"info",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/MysqlParser.php#L48-L63
|
227,167
|
javanile/moldable
|
src/Parser/MysqlParser.php
|
MysqlParser.parseTable
|
public function parseTable(&$table, &$errors = null, $namespace = '\\')
{
// for first field no have before
$before = false;
// loop throuh fields on table
foreach ($table as $field => &$notation) {
$notation = static::getNotationAspects(
$notation,
$field,
$before,
$errors,
$namespace
);
$before = $field;
}
}
|
php
|
public function parseTable(&$table, &$errors = null, $namespace = '\\')
{
// for first field no have before
$before = false;
// loop throuh fields on table
foreach ($table as $field => &$notation) {
$notation = static::getNotationAspects(
$notation,
$field,
$before,
$errors,
$namespace
);
$before = $field;
}
}
|
[
"public",
"function",
"parseTable",
"(",
"&",
"$",
"table",
",",
"&",
"$",
"errors",
"=",
"null",
",",
"$",
"namespace",
"=",
"'\\\\'",
")",
"{",
"// for first field no have before",
"$",
"before",
"=",
"false",
";",
"// loop throuh fields on table",
"foreach",
"(",
"$",
"table",
"as",
"$",
"field",
"=>",
"&",
"$",
"notation",
")",
"{",
"$",
"notation",
"=",
"static",
"::",
"getNotationAspects",
"(",
"$",
"notation",
",",
"$",
"field",
",",
"$",
"before",
",",
"$",
"errors",
",",
"$",
"namespace",
")",
";",
"$",
"before",
"=",
"$",
"field",
";",
"}",
"}"
] |
Parse table schema to sanitize end explod implicit info.
@param type $schema
@param mixed $namespace
@return type
|
[
"Parse",
"table",
"schema",
"to",
"sanitize",
"end",
"explod",
"implicit",
"info",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/MysqlParser.php#L73-L89
|
227,168
|
javanile/moldable
|
src/Parser/MysqlParser.php
|
MysqlParser.getNotationAspects
|
public function getNotationAspects(
$notation,
$field = null,
$before = null,
&$errors = null,
$namespace = null
) {
$params = null;
$type = $this->getNotationType($notation, $params, $errors, $namespace);
$aspects = $this->getNotationCommonAspects($field, $before);
// Looking type
switch ($type) {
case 'schema':
return $this->getNotationAspectsSchema($notation, $aspects);
case 'json':
return $this->getNotationAspectsJson($notation, $aspects);
case 'date':
return $this->getNotationAspectsDate($notation, $aspects);
case 'time':
return $this->getNotationAspectsTime($notation, $aspects);
case 'datetime':
return $this->getNotationAspectsDatetime($notation, $aspects);
case 'timestamp':
return $this->getNotationAspectsTimestamp($notation, $aspects);
case 'primary_key':
return $this->getNotationAspectsPrimaryKey($notation, $aspects, $params);
case 'string':
return $this->getNotationAspectsString($notation, $aspects);
case 'text':
return $this->getNotationAspectsText($notation, $aspects);
case 'null':
return $this->getNotationAspectsNull($notation, $aspects);
case 'boolean':
return $this->getNotationAspectsBoolean($notation, $aspects);
case 'integer':
return $this->getNotationAspectsInteger($notation, $aspects);
case 'float':
return $this->getNotationAspectsFloat($notation, $aspects);
case 'double':
return $this->getNotationAspectsDouble($notation, $aspects);
case 'enum':
return $this->getNotationAspectsEnum($notation, $aspects);
case 'class':
return static::getNotationAspectsClass($notation, $aspects, $params, $namespace);
case 'vector':
return static::getNotationAspectsVector($notation, $aspects, $params, $namespace);
case 'matchs':
return static::getNotationAspectsMatchs($notation, $aspects, $params, $namespace);
}
$errors[] = "irrational notation '{$notation}' by type '{$type}'";
}
|
php
|
public function getNotationAspects(
$notation,
$field = null,
$before = null,
&$errors = null,
$namespace = null
) {
$params = null;
$type = $this->getNotationType($notation, $params, $errors, $namespace);
$aspects = $this->getNotationCommonAspects($field, $before);
// Looking type
switch ($type) {
case 'schema':
return $this->getNotationAspectsSchema($notation, $aspects);
case 'json':
return $this->getNotationAspectsJson($notation, $aspects);
case 'date':
return $this->getNotationAspectsDate($notation, $aspects);
case 'time':
return $this->getNotationAspectsTime($notation, $aspects);
case 'datetime':
return $this->getNotationAspectsDatetime($notation, $aspects);
case 'timestamp':
return $this->getNotationAspectsTimestamp($notation, $aspects);
case 'primary_key':
return $this->getNotationAspectsPrimaryKey($notation, $aspects, $params);
case 'string':
return $this->getNotationAspectsString($notation, $aspects);
case 'text':
return $this->getNotationAspectsText($notation, $aspects);
case 'null':
return $this->getNotationAspectsNull($notation, $aspects);
case 'boolean':
return $this->getNotationAspectsBoolean($notation, $aspects);
case 'integer':
return $this->getNotationAspectsInteger($notation, $aspects);
case 'float':
return $this->getNotationAspectsFloat($notation, $aspects);
case 'double':
return $this->getNotationAspectsDouble($notation, $aspects);
case 'enum':
return $this->getNotationAspectsEnum($notation, $aspects);
case 'class':
return static::getNotationAspectsClass($notation, $aspects, $params, $namespace);
case 'vector':
return static::getNotationAspectsVector($notation, $aspects, $params, $namespace);
case 'matchs':
return static::getNotationAspectsMatchs($notation, $aspects, $params, $namespace);
}
$errors[] = "irrational notation '{$notation}' by type '{$type}'";
}
|
[
"public",
"function",
"getNotationAspects",
"(",
"$",
"notation",
",",
"$",
"field",
"=",
"null",
",",
"$",
"before",
"=",
"null",
",",
"&",
"$",
"errors",
"=",
"null",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"null",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"getNotationType",
"(",
"$",
"notation",
",",
"$",
"params",
",",
"$",
"errors",
",",
"$",
"namespace",
")",
";",
"$",
"aspects",
"=",
"$",
"this",
"->",
"getNotationCommonAspects",
"(",
"$",
"field",
",",
"$",
"before",
")",
";",
"// Looking type",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'schema'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsSchema",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'json'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsJson",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'date'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsDate",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'time'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsTime",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'datetime'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsDatetime",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'timestamp'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsTimestamp",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'primary_key'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsPrimaryKey",
"(",
"$",
"notation",
",",
"$",
"aspects",
",",
"$",
"params",
")",
";",
"case",
"'string'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsString",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'text'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsText",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'null'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsNull",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'boolean'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsBoolean",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'integer'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsInteger",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'float'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsFloat",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'double'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsDouble",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'enum'",
":",
"return",
"$",
"this",
"->",
"getNotationAspectsEnum",
"(",
"$",
"notation",
",",
"$",
"aspects",
")",
";",
"case",
"'class'",
":",
"return",
"static",
"::",
"getNotationAspectsClass",
"(",
"$",
"notation",
",",
"$",
"aspects",
",",
"$",
"params",
",",
"$",
"namespace",
")",
";",
"case",
"'vector'",
":",
"return",
"static",
"::",
"getNotationAspectsVector",
"(",
"$",
"notation",
",",
"$",
"aspects",
",",
"$",
"params",
",",
"$",
"namespace",
")",
";",
"case",
"'matchs'",
":",
"return",
"static",
"::",
"getNotationAspectsMatchs",
"(",
"$",
"notation",
",",
"$",
"aspects",
",",
"$",
"params",
",",
"$",
"namespace",
")",
";",
"}",
"$",
"errors",
"[",
"]",
"=",
"\"irrational notation '{$notation}' by type '{$type}'\"",
";",
"}"
] |
Parse notation of a field.
@param type $notation
@param type $field
@param type $before
@param null|mixed $namespace
@return string
|
[
"Parse",
"notation",
"of",
"a",
"field",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/MysqlParser.php#L101-L154
|
227,169
|
javanile/moldable
|
src/Parser/MysqlParser.php
|
MysqlParser.getNotationCommonAspects
|
private function getNotationCommonAspects($field, $before)
{
$aspects = [
'Field' => null,
'Key' => '',
'Type' => '',
'Null' => 'YES',
'Extra' => '',
'Default' => '',
'Relation' => null,
];
if (!is_null($field)) {
$aspects['Field'] = $field;
}
if (!is_null($before)) {
$aspects['First'] = !$before;
$aspects['Before'] = $before;
}
return $aspects;
}
|
php
|
private function getNotationCommonAspects($field, $before)
{
$aspects = [
'Field' => null,
'Key' => '',
'Type' => '',
'Null' => 'YES',
'Extra' => '',
'Default' => '',
'Relation' => null,
];
if (!is_null($field)) {
$aspects['Field'] = $field;
}
if (!is_null($before)) {
$aspects['First'] = !$before;
$aspects['Before'] = $before;
}
return $aspects;
}
|
[
"private",
"function",
"getNotationCommonAspects",
"(",
"$",
"field",
",",
"$",
"before",
")",
"{",
"$",
"aspects",
"=",
"[",
"'Field'",
"=>",
"null",
",",
"'Key'",
"=>",
"''",
",",
"'Type'",
"=>",
"''",
",",
"'Null'",
"=>",
"'YES'",
",",
"'Extra'",
"=>",
"''",
",",
"'Default'",
"=>",
"''",
",",
"'Relation'",
"=>",
"null",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"$",
"aspects",
"[",
"'Field'",
"]",
"=",
"$",
"field",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"before",
")",
")",
"{",
"$",
"aspects",
"[",
"'First'",
"]",
"=",
"!",
"$",
"before",
";",
"$",
"aspects",
"[",
"'Before'",
"]",
"=",
"$",
"before",
";",
"}",
"return",
"$",
"aspects",
";",
"}"
] |
Get common or default aspects.
@param mixed $field
@param mixed $before
|
[
"Get",
"common",
"or",
"default",
"aspects",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/MysqlParser.php#L162-L184
|
227,170
|
BootstrapCMS/Credentials
|
src/Repositories/BaseRepositoryTrait.php
|
BaseRepositoryTrait.find
|
public function find($id, array $columns = ['*'])
{
$model = $this->model;
return $model::find($id, $columns);
}
|
php
|
public function find($id, array $columns = ['*'])
{
$model = $this->model;
return $model::find($id, $columns);
}
|
[
"public",
"function",
"find",
"(",
"$",
"id",
",",
"array",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"return",
"$",
"model",
"::",
"find",
"(",
"$",
"id",
",",
"$",
"columns",
")",
";",
"}"
] |
Find an existing model.
@param int $id
@param string[] $columns
@return \Illuminate\Database\Eloquent\Model
|
[
"Find",
"an",
"existing",
"model",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Repositories/BaseRepositoryTrait.php#L43-L48
|
227,171
|
BootstrapCMS/Credentials
|
src/Repositories/BaseRepositoryTrait.php
|
BaseRepositoryTrait.index
|
public function index()
{
$model = $this->model;
if (property_exists($model, 'order')) {
return $model::orderBy($model::$order, $model::$sort)->get($model::$index);
}
return $model::get($model::$index);
}
|
php
|
public function index()
{
$model = $this->model;
if (property_exists($model, 'order')) {
return $model::orderBy($model::$order, $model::$sort)->get($model::$index);
}
return $model::get($model::$index);
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"property_exists",
"(",
"$",
"model",
",",
"'order'",
")",
")",
"{",
"return",
"$",
"model",
"::",
"orderBy",
"(",
"$",
"model",
"::",
"$",
"order",
",",
"$",
"model",
"::",
"$",
"sort",
")",
"->",
"get",
"(",
"$",
"model",
"::",
"$",
"index",
")",
";",
"}",
"return",
"$",
"model",
"::",
"get",
"(",
"$",
"model",
"::",
"$",
"index",
")",
";",
"}"
] |
Get a list of the models.
@return \Illuminate\Database\Eloquent\Collection
|
[
"Get",
"a",
"list",
"of",
"the",
"models",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Repositories/BaseRepositoryTrait.php#L69-L78
|
227,172
|
BootstrapCMS/Credentials
|
src/Repositories/BaseRepositoryTrait.php
|
BaseRepositoryTrait.rules
|
public function rules($query = null)
{
$model = $this->model;
// get rules from the model if set
if (isset($model::$rules)) {
$rules = $model::$rules;
} else {
$rules = [];
}
// if the there are no rules
if (!is_array($rules) || !$rules) {
// return an empty array
return [];
}
// if the query is empty
if (!$query) {
// return all of the rules
return array_filter($rules);
}
// return the relevant rules
return array_filter(array_only($rules, $query));
}
|
php
|
public function rules($query = null)
{
$model = $this->model;
// get rules from the model if set
if (isset($model::$rules)) {
$rules = $model::$rules;
} else {
$rules = [];
}
// if the there are no rules
if (!is_array($rules) || !$rules) {
// return an empty array
return [];
}
// if the query is empty
if (!$query) {
// return all of the rules
return array_filter($rules);
}
// return the relevant rules
return array_filter(array_only($rules, $query));
}
|
[
"public",
"function",
"rules",
"(",
"$",
"query",
"=",
"null",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"// get rules from the model if set",
"if",
"(",
"isset",
"(",
"$",
"model",
"::",
"$",
"rules",
")",
")",
"{",
"$",
"rules",
"=",
"$",
"model",
"::",
"$",
"rules",
";",
"}",
"else",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"}",
"// if the there are no rules",
"if",
"(",
"!",
"is_array",
"(",
"$",
"rules",
")",
"||",
"!",
"$",
"rules",
")",
"{",
"// return an empty array",
"return",
"[",
"]",
";",
"}",
"// if the query is empty",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"// return all of the rules",
"return",
"array_filter",
"(",
"$",
"rules",
")",
";",
"}",
"// return the relevant rules",
"return",
"array_filter",
"(",
"array_only",
"(",
"$",
"rules",
",",
"$",
"query",
")",
")",
";",
"}"
] |
Return the rules.
@param string|string[] $query
@return string[]
|
[
"Return",
"the",
"rules",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Repositories/BaseRepositoryTrait.php#L114-L139
|
227,173
|
javanile/moldable
|
src/Database/Socket/LaravelSocket.php
|
LaravelSocket.getRow
|
public function getRow($sql, $params = null)
{
return $this->_socket->getRow($sql, $params = null);
}
|
php
|
public function getRow($sql, $params = null)
{
return $this->_socket->getRow($sql, $params = null);
}
|
[
"public",
"function",
"getRow",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_socket",
"->",
"getRow",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"null",
")",
";",
"}"
] |
Get a single row.
@param type $sql
@param null|mixed $params
@return type
|
[
"Get",
"a",
"single",
"row",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/Socket/LaravelSocket.php#L72-L75
|
227,174
|
javanile/moldable
|
src/Database/Socket/LaravelSocket.php
|
LaravelSocket.getResults
|
public function getResults($sql, $params = null)
{
return $this->_socket->getResults($sql, $params = null);
}
|
php
|
public function getResults($sql, $params = null)
{
return $this->_socket->getResults($sql, $params = null);
}
|
[
"public",
"function",
"getResults",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_socket",
"->",
"getResults",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"null",
")",
";",
"}"
] |
Get list of records.
@param type $sql
@param null|mixed $params
@return type
|
[
"Get",
"list",
"of",
"records",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/Socket/LaravelSocket.php#L85-L88
|
227,175
|
secit-pl/schema-org
|
SchemaOrg.php
|
SchemaOrg.toJsonLd
|
public function toJsonLd(Type\TypeInterface $thing, $addScriptTag = true)
{
$return = json_encode($this->toJsonLdDataArray($thing));
if ($addScriptTag) {
return '<script type="application/ld+json">'.$return.'</script>';
}
return $return;
}
|
php
|
public function toJsonLd(Type\TypeInterface $thing, $addScriptTag = true)
{
$return = json_encode($this->toJsonLdDataArray($thing));
if ($addScriptTag) {
return '<script type="application/ld+json">'.$return.'</script>';
}
return $return;
}
|
[
"public",
"function",
"toJsonLd",
"(",
"Type",
"\\",
"TypeInterface",
"$",
"thing",
",",
"$",
"addScriptTag",
"=",
"true",
")",
"{",
"$",
"return",
"=",
"json_encode",
"(",
"$",
"this",
"->",
"toJsonLdDataArray",
"(",
"$",
"thing",
")",
")",
";",
"if",
"(",
"$",
"addScriptTag",
")",
"{",
"return",
"'<script type=\"application/ld+json\">'",
".",
"$",
"return",
".",
"'</script>'",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Convert schema.rg type to the json-ld string.
@param Type\TypeInterface $thing
@param bool $addScriptTag Wrap returned json-ld with the <script type="application/ld+json"></script> tag
@return string
|
[
"Convert",
"schema",
".",
"rg",
"type",
"to",
"the",
"json",
"-",
"ld",
"string",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg.php#L24-L32
|
227,176
|
secit-pl/schema-org
|
SchemaOrg.php
|
SchemaOrg.typeToJsonLd
|
protected function typeToJsonLd(Type\TypeInterface $type)
{
$typeName = (new \ReflectionClass($type))->getShortName();
if (strlen($typeName) > 4 && substr($typeName, -4) === 'Type') {
$typeName = substr($typeName, 0, -4);
}
$jsonLd = [
'@type' => $typeName,
];
if ($type->getId()) {
$jsonLd['@id'] = $type->getId();
}
$publicMethods = (new \ReflectionClass($type))->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($publicMethods as $method) {
$methodName = $method->getName();
if (substr($methodName, 0, 3) !== 'get') {
continue;
}
$key = lcfirst(substr($methodName, 3));
if ($key == 'itemListElements') {
$key = 'itemListElement';
}
$value = $type->$methodName();
if (in_array($methodName, ['getId', 'getSchemaUrl']) || $value === null) {
continue;
} elseif (is_array($value)) {
$jsonLd[$key] = [];
foreach ($value as $item) {
$jsonLd[$key][] = $this->valueToJsonLd($item);
}
} else {
$jsonLd[$key] = $this->valueToJsonLd($value);
}
}
return $jsonLd;
}
|
php
|
protected function typeToJsonLd(Type\TypeInterface $type)
{
$typeName = (new \ReflectionClass($type))->getShortName();
if (strlen($typeName) > 4 && substr($typeName, -4) === 'Type') {
$typeName = substr($typeName, 0, -4);
}
$jsonLd = [
'@type' => $typeName,
];
if ($type->getId()) {
$jsonLd['@id'] = $type->getId();
}
$publicMethods = (new \ReflectionClass($type))->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($publicMethods as $method) {
$methodName = $method->getName();
if (substr($methodName, 0, 3) !== 'get') {
continue;
}
$key = lcfirst(substr($methodName, 3));
if ($key == 'itemListElements') {
$key = 'itemListElement';
}
$value = $type->$methodName();
if (in_array($methodName, ['getId', 'getSchemaUrl']) || $value === null) {
continue;
} elseif (is_array($value)) {
$jsonLd[$key] = [];
foreach ($value as $item) {
$jsonLd[$key][] = $this->valueToJsonLd($item);
}
} else {
$jsonLd[$key] = $this->valueToJsonLd($value);
}
}
return $jsonLd;
}
|
[
"protected",
"function",
"typeToJsonLd",
"(",
"Type",
"\\",
"TypeInterface",
"$",
"type",
")",
"{",
"$",
"typeName",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"type",
")",
")",
"->",
"getShortName",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"typeName",
")",
">",
"4",
"&&",
"substr",
"(",
"$",
"typeName",
",",
"-",
"4",
")",
"===",
"'Type'",
")",
"{",
"$",
"typeName",
"=",
"substr",
"(",
"$",
"typeName",
",",
"0",
",",
"-",
"4",
")",
";",
"}",
"$",
"jsonLd",
"=",
"[",
"'@type'",
"=>",
"$",
"typeName",
",",
"]",
";",
"if",
"(",
"$",
"type",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"jsonLd",
"[",
"'@id'",
"]",
"=",
"$",
"type",
"->",
"getId",
"(",
")",
";",
"}",
"$",
"publicMethods",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"type",
")",
")",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
";",
"foreach",
"(",
"$",
"publicMethods",
"as",
"$",
"method",
")",
"{",
"$",
"methodName",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"methodName",
",",
"0",
",",
"3",
")",
"!==",
"'get'",
")",
"{",
"continue",
";",
"}",
"$",
"key",
"=",
"lcfirst",
"(",
"substr",
"(",
"$",
"methodName",
",",
"3",
")",
")",
";",
"if",
"(",
"$",
"key",
"==",
"'itemListElements'",
")",
"{",
"$",
"key",
"=",
"'itemListElement'",
";",
"}",
"$",
"value",
"=",
"$",
"type",
"->",
"$",
"methodName",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"methodName",
",",
"[",
"'getId'",
",",
"'getSchemaUrl'",
"]",
")",
"||",
"$",
"value",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"jsonLd",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"item",
")",
"{",
"$",
"jsonLd",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"valueToJsonLd",
"(",
"$",
"item",
")",
";",
"}",
"}",
"else",
"{",
"$",
"jsonLd",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"valueToJsonLd",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"jsonLd",
";",
"}"
] |
Convert type to json-ld data array.
@param Type\TypeInterface $type
@return array
|
[
"Convert",
"type",
"to",
"json",
"-",
"ld",
"data",
"array",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg.php#L55-L96
|
227,177
|
secit-pl/schema-org
|
SchemaOrg.php
|
SchemaOrg.valueToJsonLd
|
protected function valueToJsonLd($value)
{
if (is_array($value)) {
$return = [];
foreach ($value as $item) {
$return[] = $this->valueToJsonLd($item);
}
return $return;
} elseif ($value instanceof Type\EnumerationType || $value instanceof Type\Enumeration) {
return $value->getSchemaUrl();
} elseif ($value instanceof Type\TypeInterface) {
return $this->typeToJsonLd($value);
} elseif ($value instanceof Property\PropertyInterface) {
return $this->propertyToJsonLd($value);
} elseif ($value instanceof DataType\DataTypeInterface) {
return $this->dataTypeToJsonLd($value);
}
throw new \Exception('Unexpected data type '.gettype($value));
}
|
php
|
protected function valueToJsonLd($value)
{
if (is_array($value)) {
$return = [];
foreach ($value as $item) {
$return[] = $this->valueToJsonLd($item);
}
return $return;
} elseif ($value instanceof Type\EnumerationType || $value instanceof Type\Enumeration) {
return $value->getSchemaUrl();
} elseif ($value instanceof Type\TypeInterface) {
return $this->typeToJsonLd($value);
} elseif ($value instanceof Property\PropertyInterface) {
return $this->propertyToJsonLd($value);
} elseif ($value instanceof DataType\DataTypeInterface) {
return $this->dataTypeToJsonLd($value);
}
throw new \Exception('Unexpected data type '.gettype($value));
}
|
[
"protected",
"function",
"valueToJsonLd",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"item",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"this",
"->",
"valueToJsonLd",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"return",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Type",
"\\",
"EnumerationType",
"||",
"$",
"value",
"instanceof",
"Type",
"\\",
"Enumeration",
")",
"{",
"return",
"$",
"value",
"->",
"getSchemaUrl",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Type",
"\\",
"TypeInterface",
")",
"{",
"return",
"$",
"this",
"->",
"typeToJsonLd",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Property",
"\\",
"PropertyInterface",
")",
"{",
"return",
"$",
"this",
"->",
"propertyToJsonLd",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"DataType",
"\\",
"DataTypeInterface",
")",
"{",
"return",
"$",
"this",
"->",
"dataTypeToJsonLd",
"(",
"$",
"value",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unexpected data type '",
".",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"}"
] |
Convert value to json-ld format.
@param mixed $value
@return array|string
@throws \Exception
|
[
"Convert",
"value",
"to",
"json",
"-",
"ld",
"format",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg.php#L131-L151
|
227,178
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.boot
|
public static function boot()
{
parent::boot();
static::saving(function ($model) {
$model->preSave();
});
static::saved(function ($model) {
$model->postSave();
});
static::deleted(function ($model) {
$model->preSave();
$model->postDelete();
});
}
|
php
|
public static function boot()
{
parent::boot();
static::saving(function ($model) {
$model->preSave();
});
static::saved(function ($model) {
$model->postSave();
});
static::deleted(function ($model) {
$model->preSave();
$model->postDelete();
});
}
|
[
"public",
"static",
"function",
"boot",
"(",
")",
"{",
"parent",
"::",
"boot",
"(",
")",
";",
"static",
"::",
"saving",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"preSave",
"(",
")",
";",
"}",
")",
";",
"static",
"::",
"saved",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"postSave",
"(",
")",
";",
"}",
")",
";",
"static",
"::",
"deleted",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"preSave",
"(",
")",
";",
"$",
"model",
"->",
"postDelete",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Create the event listeners for the saving and saved events.
@return void
|
[
"Create",
"the",
"event",
"listeners",
"for",
"the",
"saving",
"and",
"saved",
"events",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L77-L93
|
227,179
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.preSave
|
public function preSave()
{
$this->originalData = $this->original;
$this->updatedData = $this->attributes;
// we can only safely compare basic items, so for now we drop any object based
// items apart from DateTime objects where we compare them specially
foreach ($this->updatedData as $key => $val) {
if (is_object($val)) {
if (!($val instanceof DateTime)) {
unset($this->originalData[$key]);
unset($this->updatedData[$key]);
}
}
}
// the below is ugly, for sure, but it's required so we can save the standard model
// then use the keep / dontkeep values for later, in the isRevisionable method
$this->dontKeep = isset($this->dontKeepRevisionOf) ?
$this->dontKeepRevisionOf + $this->dontKeep
: $this->dontKeep;
$this->doKeep = isset($this->keepRevisionOf) ?
$this->keepRevisionOf + $this->doKeep
: $this->doKeep;
unset($this->attributes['dontKeepRevisionOf']);
unset($this->attributes['keepRevisionOf']);
$this->dirtyData = $this->getDirty();
$this->updating = $this->exists;
}
|
php
|
public function preSave()
{
$this->originalData = $this->original;
$this->updatedData = $this->attributes;
// we can only safely compare basic items, so for now we drop any object based
// items apart from DateTime objects where we compare them specially
foreach ($this->updatedData as $key => $val) {
if (is_object($val)) {
if (!($val instanceof DateTime)) {
unset($this->originalData[$key]);
unset($this->updatedData[$key]);
}
}
}
// the below is ugly, for sure, but it's required so we can save the standard model
// then use the keep / dontkeep values for later, in the isRevisionable method
$this->dontKeep = isset($this->dontKeepRevisionOf) ?
$this->dontKeepRevisionOf + $this->dontKeep
: $this->dontKeep;
$this->doKeep = isset($this->keepRevisionOf) ?
$this->keepRevisionOf + $this->doKeep
: $this->doKeep;
unset($this->attributes['dontKeepRevisionOf']);
unset($this->attributes['keepRevisionOf']);
$this->dirtyData = $this->getDirty();
$this->updating = $this->exists;
}
|
[
"public",
"function",
"preSave",
"(",
")",
"{",
"$",
"this",
"->",
"originalData",
"=",
"$",
"this",
"->",
"original",
";",
"$",
"this",
"->",
"updatedData",
"=",
"$",
"this",
"->",
"attributes",
";",
"// we can only safely compare basic items, so for now we drop any object based",
"// items apart from DateTime objects where we compare them specially",
"foreach",
"(",
"$",
"this",
"->",
"updatedData",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"val",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"val",
"instanceof",
"DateTime",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"originalData",
"[",
"$",
"key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"updatedData",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"// the below is ugly, for sure, but it's required so we can save the standard model",
"// then use the keep / dontkeep values for later, in the isRevisionable method",
"$",
"this",
"->",
"dontKeep",
"=",
"isset",
"(",
"$",
"this",
"->",
"dontKeepRevisionOf",
")",
"?",
"$",
"this",
"->",
"dontKeepRevisionOf",
"+",
"$",
"this",
"->",
"dontKeep",
":",
"$",
"this",
"->",
"dontKeep",
";",
"$",
"this",
"->",
"doKeep",
"=",
"isset",
"(",
"$",
"this",
"->",
"keepRevisionOf",
")",
"?",
"$",
"this",
"->",
"keepRevisionOf",
"+",
"$",
"this",
"->",
"doKeep",
":",
"$",
"this",
"->",
"doKeep",
";",
"unset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'dontKeepRevisionOf'",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'keepRevisionOf'",
"]",
")",
";",
"$",
"this",
"->",
"dirtyData",
"=",
"$",
"this",
"->",
"getDirty",
"(",
")",
";",
"$",
"this",
"->",
"updating",
"=",
"$",
"this",
"->",
"exists",
";",
"}"
] |
Do some work before we start the saving process.
@return void
|
[
"Do",
"some",
"work",
"before",
"we",
"start",
"the",
"saving",
"process",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L110-L141
|
227,180
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.getDataValue
|
protected function getDataValue($type, $key)
{
if ($key == 'password') {
return;
}
$name = $type.'Data';
return array_get($this->$name, $key);
}
|
php
|
protected function getDataValue($type, $key)
{
if ($key == 'password') {
return;
}
$name = $type.'Data';
return array_get($this->$name, $key);
}
|
[
"protected",
"function",
"getDataValue",
"(",
"$",
"type",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'password'",
")",
"{",
"return",
";",
"}",
"$",
"name",
"=",
"$",
"type",
".",
"'Data'",
";",
"return",
"array_get",
"(",
"$",
"this",
"->",
"$",
"name",
",",
"$",
"key",
")",
";",
"}"
] |
Get the value to be saved, stripping passwords.
@param string $type
@param string $key
@return string|\DateTime
|
[
"Get",
"the",
"value",
"to",
"be",
"saved",
"stripping",
"passwords",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L184-L193
|
227,181
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.postDelete
|
public function postDelete()
{
RevisionRepository::create([
'revisionable_type' => get_class($this),
'revisionable_id' => $this->getKey(),
'key' => 'deleted_at',
'old_value' => null,
'new_value' => new DateTime(),
'user_id' => $this->getUserId(),
]);
}
|
php
|
public function postDelete()
{
RevisionRepository::create([
'revisionable_type' => get_class($this),
'revisionable_id' => $this->getKey(),
'key' => 'deleted_at',
'old_value' => null,
'new_value' => new DateTime(),
'user_id' => $this->getUserId(),
]);
}
|
[
"public",
"function",
"postDelete",
"(",
")",
"{",
"RevisionRepository",
"::",
"create",
"(",
"[",
"'revisionable_type'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"'revisionable_id'",
"=>",
"$",
"this",
"->",
"getKey",
"(",
")",
",",
"'key'",
"=>",
"'deleted_at'",
",",
"'old_value'",
"=>",
"null",
",",
"'new_value'",
"=>",
"new",
"DateTime",
"(",
")",
",",
"'user_id'",
"=>",
"$",
"this",
"->",
"getUserId",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Store the deleted time.
@return void
|
[
"Store",
"the",
"deleted",
"time",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L200-L210
|
227,182
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.getUserId
|
protected function getUserId()
{
if (Credentials::check()) {
return Credentials::getUser()->id;
} elseif (isset($this['user_id']) && $this['user_id']) {
return $this['user_id'];
}
}
|
php
|
protected function getUserId()
{
if (Credentials::check()) {
return Credentials::getUser()->id;
} elseif (isset($this['user_id']) && $this['user_id']) {
return $this['user_id'];
}
}
|
[
"protected",
"function",
"getUserId",
"(",
")",
"{",
"if",
"(",
"Credentials",
"::",
"check",
"(",
")",
")",
"{",
"return",
"Credentials",
"::",
"getUser",
"(",
")",
"->",
"id",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"[",
"'user_id'",
"]",
")",
"&&",
"$",
"this",
"[",
"'user_id'",
"]",
")",
"{",
"return",
"$",
"this",
"[",
"'user_id'",
"]",
";",
"}",
"}"
] |
Attempt to find the user id of the currently logged in user.
@return int|null
|
[
"Attempt",
"to",
"find",
"the",
"user",
"id",
"of",
"the",
"currently",
"logged",
"in",
"user",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L217-L224
|
227,183
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.changedRevisionableFields
|
protected function changedRevisionableFields()
{
$changes = [];
foreach ($this->dirtyData as $key => $value) {
// check that the field is revisionable, and the data is dirty enough
if ($this->isRevisionable($key) && !is_array($value)) {
if (is_object($original = array_get($this->originalData, $key)) || is_string($original)) {
$original = trim($original);
}
if (is_object($updated = array_get($this->updatedData, $key)) || is_string($updated)) {
$updated = trim($updated);
}
if ($original != $updated) {
$changes[$key] = $value;
}
} else {
// if it's not dirty enough, then remove the field from the array
unset($this->updatedData[$key]);
unset($this->originalData[$key]);
}
}
return $changes;
}
|
php
|
protected function changedRevisionableFields()
{
$changes = [];
foreach ($this->dirtyData as $key => $value) {
// check that the field is revisionable, and the data is dirty enough
if ($this->isRevisionable($key) && !is_array($value)) {
if (is_object($original = array_get($this->originalData, $key)) || is_string($original)) {
$original = trim($original);
}
if (is_object($updated = array_get($this->updatedData, $key)) || is_string($updated)) {
$updated = trim($updated);
}
if ($original != $updated) {
$changes[$key] = $value;
}
} else {
// if it's not dirty enough, then remove the field from the array
unset($this->updatedData[$key]);
unset($this->originalData[$key]);
}
}
return $changes;
}
|
[
"protected",
"function",
"changedRevisionableFields",
"(",
")",
"{",
"$",
"changes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"dirtyData",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// check that the field is revisionable, and the data is dirty enough",
"if",
"(",
"$",
"this",
"->",
"isRevisionable",
"(",
"$",
"key",
")",
"&&",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"original",
"=",
"array_get",
"(",
"$",
"this",
"->",
"originalData",
",",
"$",
"key",
")",
")",
"||",
"is_string",
"(",
"$",
"original",
")",
")",
"{",
"$",
"original",
"=",
"trim",
"(",
"$",
"original",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"updated",
"=",
"array_get",
"(",
"$",
"this",
"->",
"updatedData",
",",
"$",
"key",
")",
")",
"||",
"is_string",
"(",
"$",
"updated",
")",
")",
"{",
"$",
"updated",
"=",
"trim",
"(",
"$",
"updated",
")",
";",
"}",
"if",
"(",
"$",
"original",
"!=",
"$",
"updated",
")",
"{",
"$",
"changes",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"// if it's not dirty enough, then remove the field from the array",
"unset",
"(",
"$",
"this",
"->",
"updatedData",
"[",
"$",
"key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"originalData",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"changes",
";",
"}"
] |
Get the fields for all of the storable changes that have been made.
@return string[]
|
[
"Get",
"the",
"fields",
"for",
"all",
"of",
"the",
"storable",
"changes",
"that",
"have",
"been",
"made",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L231-L256
|
227,184
|
BootstrapCMS/Credentials
|
src/Models/Relations/RevisionableTrait.php
|
RevisionableTrait.isRevisionable
|
protected function isRevisionable($key)
{
if (isset($this->doKeep) && in_array($key, $this->doKeep)) {
return true;
}
if (isset($this->dontKeep) && in_array($key, $this->dontKeep)) {
return false;
}
return empty($this->doKeep);
}
|
php
|
protected function isRevisionable($key)
{
if (isset($this->doKeep) && in_array($key, $this->doKeep)) {
return true;
}
if (isset($this->dontKeep) && in_array($key, $this->dontKeep)) {
return false;
}
return empty($this->doKeep);
}
|
[
"protected",
"function",
"isRevisionable",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"doKeep",
")",
"&&",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"doKeep",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"dontKeep",
")",
"&&",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"dontKeep",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"empty",
"(",
"$",
"this",
"->",
"doKeep",
")",
";",
"}"
] |
Check if this field should have a revision kept.
If we are not tracking updates that null the field, and the update nulls
the field, then return false. If the field is explicitly revisionable,
then return true. If it's explicitly not revisionable, return false.
Otherwise, if neither condition is met, only return true if we aren't
specifying revisionable fields.
@param string $key
@return bool
|
[
"Check",
"if",
"this",
"field",
"should",
"have",
"a",
"revision",
"kept",
"."
] |
128c5359eea7417ca95670933a28d4e6c7e01e6b
|
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/Relations/RevisionableTrait.php#L271-L282
|
227,185
|
amphp/uri
|
src/Uri.php
|
Uri.normalize
|
public function normalize(): string {
if (!$this->uri) {
return '';
}
$path = $this->path ?: '/';
$path = $this->removeDotSegments($path);
$path = $this->decodeUnreservedCharacters($path);
$path = $this->decodeReservedSubDelimiters($path);
return $this->reconstitute(
$this->scheme,
$this->getAuthority(),
$path,
$this->query,
$this->fragment
);
}
|
php
|
public function normalize(): string {
if (!$this->uri) {
return '';
}
$path = $this->path ?: '/';
$path = $this->removeDotSegments($path);
$path = $this->decodeUnreservedCharacters($path);
$path = $this->decodeReservedSubDelimiters($path);
return $this->reconstitute(
$this->scheme,
$this->getAuthority(),
$path,
$this->query,
$this->fragment
);
}
|
[
"public",
"function",
"normalize",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"uri",
")",
"{",
"return",
"''",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
"?",
":",
"'/'",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"removeDotSegments",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"decodeUnreservedCharacters",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"decodeReservedSubDelimiters",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"reconstitute",
"(",
"$",
"this",
"->",
"scheme",
",",
"$",
"this",
"->",
"getAuthority",
"(",
")",
",",
"$",
"path",
",",
"$",
"this",
"->",
"query",
",",
"$",
"this",
"->",
"fragment",
")",
";",
"}"
] |
Normalizes the URI for maximal comparison success.
@return string
|
[
"Normalizes",
"the",
"URI",
"for",
"maximal",
"comparison",
"success",
"."
] |
b1b0aa74ba76aad7a75693fdc87e017b0c349316
|
https://github.com/amphp/uri/blob/b1b0aa74ba76aad7a75693fdc87e017b0c349316/src/Uri.php#L126-L143
|
227,186
|
amphp/uri
|
src/Uri.php
|
Uri.getAbsoluteUri
|
public function getAbsoluteUri() {
return $this->reconstitute(
$this->scheme,
$this->getAuthority(),
$this->path,
$this->query,
$fragment = ''
);
}
|
php
|
public function getAbsoluteUri() {
return $this->reconstitute(
$this->scheme,
$this->getAuthority(),
$this->path,
$this->query,
$fragment = ''
);
}
|
[
"public",
"function",
"getAbsoluteUri",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"reconstitute",
"(",
"$",
"this",
"->",
"scheme",
",",
"$",
"this",
"->",
"getAuthority",
"(",
")",
",",
"$",
"this",
"->",
"path",
",",
"$",
"this",
"->",
"query",
",",
"$",
"fragment",
"=",
"''",
")",
";",
"}"
] |
Retrieve the URI without the fragment component.
|
[
"Retrieve",
"the",
"URI",
"without",
"the",
"fragment",
"component",
"."
] |
b1b0aa74ba76aad7a75693fdc87e017b0c349316
|
https://github.com/amphp/uri/blob/b1b0aa74ba76aad7a75693fdc87e017b0c349316/src/Uri.php#L363-L371
|
227,187
|
amphp/uri
|
src/Uri.php
|
Uri.isValid
|
public static function isValid(string $uri): bool {
try {
new self($uri);
} catch (InvalidUriException $e) {
return false;
}
return true;
}
|
php
|
public static function isValid(string $uri): bool {
try {
new self($uri);
} catch (InvalidUriException $e) {
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"isValid",
"(",
"string",
"$",
"uri",
")",
":",
"bool",
"{",
"try",
"{",
"new",
"self",
"(",
"$",
"uri",
")",
";",
"}",
"catch",
"(",
"InvalidUriException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Test whether the specified string is a valid URI.
@param string $uri
@return bool
|
[
"Test",
"whether",
"the",
"specified",
"string",
"is",
"a",
"valid",
"URI",
"."
] |
b1b0aa74ba76aad7a75693fdc87e017b0c349316
|
https://github.com/amphp/uri/blob/b1b0aa74ba76aad7a75693fdc87e017b0c349316/src/Uri.php#L474-L482
|
227,188
|
ARCANEDEV/LaravelAuth
|
database/migrations/2015_01_01_000001_create_auth_users_table.php
|
CreateAuthUsersTable.addCredentialsColumns
|
private function addCredentialsColumns(Blueprint $table)
{
if (SocialAuthenticator::isEnabled()) {
$table->string('password')->nullable();
// Social network columns
$table->string('social_provider')->nullable();
$table->string('social_provider_id')->unique()->nullable();
}
else {
$table->string('password');
}
}
|
php
|
private function addCredentialsColumns(Blueprint $table)
{
if (SocialAuthenticator::isEnabled()) {
$table->string('password')->nullable();
// Social network columns
$table->string('social_provider')->nullable();
$table->string('social_provider_id')->unique()->nullable();
}
else {
$table->string('password');
}
}
|
[
"private",
"function",
"addCredentialsColumns",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"if",
"(",
"SocialAuthenticator",
"::",
"isEnabled",
"(",
")",
")",
"{",
"$",
"table",
"->",
"string",
"(",
"'password'",
")",
"->",
"nullable",
"(",
")",
";",
"// Social network columns",
"$",
"table",
"->",
"string",
"(",
"'social_provider'",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'social_provider_id'",
")",
"->",
"unique",
"(",
")",
"->",
"nullable",
"(",
")",
";",
"}",
"else",
"{",
"$",
"table",
"->",
"string",
"(",
"'password'",
")",
";",
"}",
"}"
] |
Add credentials columns.
@param \Illuminate\Database\Schema\Blueprint $table
|
[
"Add",
"credentials",
"columns",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/database/migrations/2015_01_01_000001_create_auth_users_table.php#L68-L79
|
227,189
|
javanile/moldable
|
src/Database/FieldApi.php
|
FieldApi.getPrimaryKeyOrMainField
|
public function getPrimaryKeyOrMainField($model)
{
$key = $this->getPrimaryKey($model);
return $key ? $key : $this->getMainField($model);
}
|
php
|
public function getPrimaryKeyOrMainField($model)
{
$key = $this->getPrimaryKey($model);
return $key ? $key : $this->getMainField($model);
}
|
[
"public",
"function",
"getPrimaryKeyOrMainField",
"(",
"$",
"model",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getPrimaryKey",
"(",
"$",
"model",
")",
";",
"return",
"$",
"key",
"?",
"$",
"key",
":",
"$",
"this",
"->",
"getMainField",
"(",
"$",
"model",
")",
";",
"}"
] |
Get primary key or main field.
@param mixed $model
|
[
"Get",
"primary",
"key",
"or",
"main",
"field",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/FieldApi.php#L39-L44
|
227,190
|
javanile/moldable
|
src/Database/FieldApi.php
|
FieldApi.getMainField
|
public function getMainField($model)
{
// describe the model
$desc = $this->desc($model);
// search by fields for primary key
foreach (array_keys($desc[$model]) as $field) {
return $field;
}
}
|
php
|
public function getMainField($model)
{
// describe the model
$desc = $this->desc($model);
// search by fields for primary key
foreach (array_keys($desc[$model]) as $field) {
return $field;
}
}
|
[
"public",
"function",
"getMainField",
"(",
"$",
"model",
")",
"{",
"// describe the model",
"$",
"desc",
"=",
"$",
"this",
"->",
"desc",
"(",
"$",
"model",
")",
";",
"// search by fields for primary key",
"foreach",
"(",
"array_keys",
"(",
"$",
"desc",
"[",
"$",
"model",
"]",
")",
"as",
"$",
"field",
")",
"{",
"return",
"$",
"field",
";",
"}",
"}"
] |
Get the main field.
@param mixed $model
|
[
"Get",
"the",
"main",
"field",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/FieldApi.php#L51-L60
|
227,191
|
ARCANEDEV/LaravelAuth
|
src/Models/Traits/Roleable.php
|
Roleable.isAll
|
public function isAll($roles, &$failed = null)
{
$this->isOne($roles, $failed);
return $failed->isEmpty();
}
|
php
|
public function isAll($roles, &$failed = null)
{
$this->isOne($roles, $failed);
return $failed->isEmpty();
}
|
[
"public",
"function",
"isAll",
"(",
"$",
"roles",
",",
"&",
"$",
"failed",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"isOne",
"(",
"$",
"roles",
",",
"$",
"failed",
")",
";",
"return",
"$",
"failed",
"->",
"isEmpty",
"(",
")",
";",
"}"
] |
Check if has all roles.
@param \Illuminate\Support\Collection|array $roles
@param \Illuminate\Support\Collection &$failed
@return bool
|
[
"Check",
"if",
"has",
"all",
"roles",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Traits/Roleable.php#L63-L68
|
227,192
|
ARCANEDEV/LaravelAuth
|
src/Models/Traits/Roleable.php
|
Roleable.isOne
|
public function isOne($roles, &$failed = null)
{
$roles = is_array($roles) ? collect($roles) : $roles;
$failed = $roles->reject(function ($role) {
return $this->hasRoleSlug($role);
})->values();
return $roles->count() !== $failed->count();
}
|
php
|
public function isOne($roles, &$failed = null)
{
$roles = is_array($roles) ? collect($roles) : $roles;
$failed = $roles->reject(function ($role) {
return $this->hasRoleSlug($role);
})->values();
return $roles->count() !== $failed->count();
}
|
[
"public",
"function",
"isOne",
"(",
"$",
"roles",
",",
"&",
"$",
"failed",
"=",
"null",
")",
"{",
"$",
"roles",
"=",
"is_array",
"(",
"$",
"roles",
")",
"?",
"collect",
"(",
"$",
"roles",
")",
":",
"$",
"roles",
";",
"$",
"failed",
"=",
"$",
"roles",
"->",
"reject",
"(",
"function",
"(",
"$",
"role",
")",
"{",
"return",
"$",
"this",
"->",
"hasRoleSlug",
"(",
"$",
"role",
")",
";",
"}",
")",
"->",
"values",
"(",
")",
";",
"return",
"$",
"roles",
"->",
"count",
"(",
")",
"!==",
"$",
"failed",
"->",
"count",
"(",
")",
";",
"}"
] |
Check if has at least one role.
@param \Illuminate\Support\Collection|array $roles
@param \Illuminate\Support\Collection &$failed
@return bool
|
[
"Check",
"if",
"has",
"at",
"least",
"one",
"role",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Traits/Roleable.php#L78-L87
|
227,193
|
ARCANEDEV/LaravelAuth
|
src/Models/Traits/Roleable.php
|
Roleable.hasRoleSlug
|
public function hasRoleSlug($slug)
{
$roles = $this->active_roles->filter(function (Role $role) use ($slug) {
return $role->hasSlug($slug);
});
return ! $roles->isEmpty();
}
|
php
|
public function hasRoleSlug($slug)
{
$roles = $this->active_roles->filter(function (Role $role) use ($slug) {
return $role->hasSlug($slug);
});
return ! $roles->isEmpty();
}
|
[
"public",
"function",
"hasRoleSlug",
"(",
"$",
"slug",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"active_roles",
"->",
"filter",
"(",
"function",
"(",
"Role",
"$",
"role",
")",
"use",
"(",
"$",
"slug",
")",
"{",
"return",
"$",
"role",
"->",
"hasSlug",
"(",
"$",
"slug",
")",
";",
"}",
")",
";",
"return",
"!",
"$",
"roles",
"->",
"isEmpty",
"(",
")",
";",
"}"
] |
Check if has a role by its slug.
@param string $slug
@return bool
|
[
"Check",
"if",
"has",
"a",
"role",
"by",
"its",
"slug",
"."
] |
a2719e924c2299f931879139c6cd97642e80acc7
|
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Traits/Roleable.php#L96-L103
|
227,194
|
javanile/moldable
|
src/Model/DeleteApi.php
|
DeleteApi.delete
|
public static function delete($query)
{
static::applySchema();
$key = static::getPrimaryKeyOrMainField();
if ($key && !is_array($query)) {
$query = [$key => $query];
}
$whereArray = [];
if (isset($query['where'])) {
$whereArray[] = $query['where'];
unset($query['where']);
}
$params = [];
foreach ($query as $field => $value) {
$token = ':'.$field;
$whereArray[] = "`{$field}` = {$token}";
$params[$token] = $value;
}
$where = $whereArray
? 'WHERE '.implode(' AND ', $whereArray)
: '';
$table = static::getTable();
$sql = "DELETE FROM {$table} {$where}";
static::getDatabase()->execute($sql, $params);
}
|
php
|
public static function delete($query)
{
static::applySchema();
$key = static::getPrimaryKeyOrMainField();
if ($key && !is_array($query)) {
$query = [$key => $query];
}
$whereArray = [];
if (isset($query['where'])) {
$whereArray[] = $query['where'];
unset($query['where']);
}
$params = [];
foreach ($query as $field => $value) {
$token = ':'.$field;
$whereArray[] = "`{$field}` = {$token}";
$params[$token] = $value;
}
$where = $whereArray
? 'WHERE '.implode(' AND ', $whereArray)
: '';
$table = static::getTable();
$sql = "DELETE FROM {$table} {$where}";
static::getDatabase()->execute($sql, $params);
}
|
[
"public",
"static",
"function",
"delete",
"(",
"$",
"query",
")",
"{",
"static",
"::",
"applySchema",
"(",
")",
";",
"$",
"key",
"=",
"static",
"::",
"getPrimaryKeyOrMainField",
"(",
")",
";",
"if",
"(",
"$",
"key",
"&&",
"!",
"is_array",
"(",
"$",
"query",
")",
")",
"{",
"$",
"query",
"=",
"[",
"$",
"key",
"=>",
"$",
"query",
"]",
";",
"}",
"$",
"whereArray",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'where'",
"]",
")",
")",
"{",
"$",
"whereArray",
"[",
"]",
"=",
"$",
"query",
"[",
"'where'",
"]",
";",
"unset",
"(",
"$",
"query",
"[",
"'where'",
"]",
")",
";",
"}",
"$",
"params",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"token",
"=",
"':'",
".",
"$",
"field",
";",
"$",
"whereArray",
"[",
"]",
"=",
"\"`{$field}` = {$token}\"",
";",
"$",
"params",
"[",
"$",
"token",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"where",
"=",
"$",
"whereArray",
"?",
"'WHERE '",
".",
"implode",
"(",
"' AND '",
",",
"$",
"whereArray",
")",
":",
"''",
";",
"$",
"table",
"=",
"static",
"::",
"getTable",
"(",
")",
";",
"$",
"sql",
"=",
"\"DELETE FROM {$table} {$where}\"",
";",
"static",
"::",
"getDatabase",
"(",
")",
"->",
"execute",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"}"
] |
Delete element by primary key or query.
@param type $query
|
[
"Delete",
"element",
"by",
"primary",
"key",
"or",
"query",
"."
] |
463ec60ba1fc00ffac39416302103af47aae42fb
|
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/DeleteApi.php#L19-L51
|
227,195
|
OpenSkill/Datatable
|
src/OpenSkill/Datatable/Composers/ColumnComposer.php
|
ColumnComposer.column
|
public function column($name, $callable = null, Searchable $searchable = null, Orderable $orderable = null)
{
/**
* @var ColumnConfigurationBuilder
*/
$config = ColumnConfigurationBuilder::create();
if (is_string($name)) {
$config->name($name);
} else {
throw new \InvalidArgumentException('$name must be a string');
}
if (!is_null($callable)) {
$this->setCallableColumn($config, $callable);
}
if (is_null($searchable)) {
$config->searchable(Searchable::NORMAL());
}
if (is_null($orderable)) {
$config->orderable(Orderable::BOTH());
}
$this->columnConfiguration[] = $config->build();
return $this;
}
|
php
|
public function column($name, $callable = null, Searchable $searchable = null, Orderable $orderable = null)
{
/**
* @var ColumnConfigurationBuilder
*/
$config = ColumnConfigurationBuilder::create();
if (is_string($name)) {
$config->name($name);
} else {
throw new \InvalidArgumentException('$name must be a string');
}
if (!is_null($callable)) {
$this->setCallableColumn($config, $callable);
}
if (is_null($searchable)) {
$config->searchable(Searchable::NORMAL());
}
if (is_null($orderable)) {
$config->orderable(Orderable::BOTH());
}
$this->columnConfiguration[] = $config->build();
return $this;
}
|
[
"public",
"function",
"column",
"(",
"$",
"name",
",",
"$",
"callable",
"=",
"null",
",",
"Searchable",
"$",
"searchable",
"=",
"null",
",",
"Orderable",
"$",
"orderable",
"=",
"null",
")",
"{",
"/**\n * @var ColumnConfigurationBuilder\n */",
"$",
"config",
"=",
"ColumnConfigurationBuilder",
"::",
"create",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"$",
"config",
"->",
"name",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$name must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"callable",
")",
")",
"{",
"$",
"this",
"->",
"setCallableColumn",
"(",
"$",
"config",
",",
"$",
"callable",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"searchable",
")",
")",
"{",
"$",
"config",
"->",
"searchable",
"(",
"Searchable",
"::",
"NORMAL",
"(",
")",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"orderable",
")",
")",
"{",
"$",
"config",
"->",
"orderable",
"(",
"Orderable",
"::",
"BOTH",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"columnConfiguration",
"[",
"]",
"=",
"$",
"config",
"->",
"build",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Will create a new ColumnConfiguration with all defaults but allows overriding of all properties through the method.
@param string $name The name of the configuration, required for the configuration
@param string|callable $callable The function to execute, defaults to null which means the default will be set.
@param Searchable $searchable If the column should be searchable or not
@param Orderable $orderable If the column should be orderable or not
@return $this
|
[
"Will",
"create",
"a",
"new",
"ColumnConfiguration",
"with",
"all",
"defaults",
"but",
"allows",
"overriding",
"of",
"all",
"properties",
"through",
"the",
"method",
"."
] |
e9814345dca4d0427da512f17c24117797e6ffbb
|
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Composers/ColumnComposer.php#L96-L123
|
227,196
|
moust/silex-cache-service-provider
|
src/Moust/Silex/Cache/RedisCache.php
|
RedisCache.setRedis
|
public function setRedis(\Redis $redis)
{
$redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
$this->_redis = $redis;
}
|
php
|
public function setRedis(\Redis $redis)
{
$redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
$this->_redis = $redis;
}
|
[
"public",
"function",
"setRedis",
"(",
"\\",
"Redis",
"$",
"redis",
")",
"{",
"$",
"redis",
"->",
"setOption",
"(",
"Redis",
"::",
"OPT_SERIALIZER",
",",
"$",
"this",
"->",
"getSerializerValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"_redis",
"=",
"$",
"redis",
";",
"}"
] |
Sets the Redis instance to use.
@param Redis $redis
|
[
"Sets",
"the",
"Redis",
"instance",
"to",
"use",
"."
] |
b3ca953def0f95676eec6a47573a3da168486b37
|
https://github.com/moust/silex-cache-service-provider/blob/b3ca953def0f95676eec6a47573a3da168486b37/src/Moust/Silex/Cache/RedisCache.php#L45-L49
|
227,197
|
secit-pl/schema-org
|
SchemaOrg/Generator.php
|
Generator.generatePropertyInterface
|
public function generatePropertyInterface()
{
$interface = new PhpInterface($this->propertyInterfaceName);
$interface
->setQualifiedName('SecIT\\SchemaOrg\\Mapping\\Property\\'.$this->propertyInterfaceName)
->setDescription('Interface '.$this->propertyInterfaceName.'.')
->setMethod(PhpMethod::create('getSchemaUrl')
->setDescription('Get schema URL.')
->setType('string')
)
->setMethod(PhpMethod::create('getValue')
->setDescription('Get value.')
->setType('string')
)
->setMethod(PhpMethod::create('isValueValid')
->setDescription('Check is value valid.')
->addParameter(PhpParameter::create('value')
->setType('string')
)
->setType('bool')
)
;
$generator = new CodeGenerator();
$code = $generator->generate($interface);
$directory = $this->getMappingDirectory('Property');
file_put_contents($directory.$this->propertyInterfaceName.'.php', "<?php\n\n".$code);
}
|
php
|
public function generatePropertyInterface()
{
$interface = new PhpInterface($this->propertyInterfaceName);
$interface
->setQualifiedName('SecIT\\SchemaOrg\\Mapping\\Property\\'.$this->propertyInterfaceName)
->setDescription('Interface '.$this->propertyInterfaceName.'.')
->setMethod(PhpMethod::create('getSchemaUrl')
->setDescription('Get schema URL.')
->setType('string')
)
->setMethod(PhpMethod::create('getValue')
->setDescription('Get value.')
->setType('string')
)
->setMethod(PhpMethod::create('isValueValid')
->setDescription('Check is value valid.')
->addParameter(PhpParameter::create('value')
->setType('string')
)
->setType('bool')
)
;
$generator = new CodeGenerator();
$code = $generator->generate($interface);
$directory = $this->getMappingDirectory('Property');
file_put_contents($directory.$this->propertyInterfaceName.'.php', "<?php\n\n".$code);
}
|
[
"public",
"function",
"generatePropertyInterface",
"(",
")",
"{",
"$",
"interface",
"=",
"new",
"PhpInterface",
"(",
"$",
"this",
"->",
"propertyInterfaceName",
")",
";",
"$",
"interface",
"->",
"setQualifiedName",
"(",
"'SecIT\\\\SchemaOrg\\\\Mapping\\\\Property\\\\'",
".",
"$",
"this",
"->",
"propertyInterfaceName",
")",
"->",
"setDescription",
"(",
"'Interface '",
".",
"$",
"this",
"->",
"propertyInterfaceName",
".",
"'.'",
")",
"->",
"setMethod",
"(",
"PhpMethod",
"::",
"create",
"(",
"'getSchemaUrl'",
")",
"->",
"setDescription",
"(",
"'Get schema URL.'",
")",
"->",
"setType",
"(",
"'string'",
")",
")",
"->",
"setMethod",
"(",
"PhpMethod",
"::",
"create",
"(",
"'getValue'",
")",
"->",
"setDescription",
"(",
"'Get value.'",
")",
"->",
"setType",
"(",
"'string'",
")",
")",
"->",
"setMethod",
"(",
"PhpMethod",
"::",
"create",
"(",
"'isValueValid'",
")",
"->",
"setDescription",
"(",
"'Check is value valid.'",
")",
"->",
"addParameter",
"(",
"PhpParameter",
"::",
"create",
"(",
"'value'",
")",
"->",
"setType",
"(",
"'string'",
")",
")",
"->",
"setType",
"(",
"'bool'",
")",
")",
";",
"$",
"generator",
"=",
"new",
"CodeGenerator",
"(",
")",
";",
"$",
"code",
"=",
"$",
"generator",
"->",
"generate",
"(",
"$",
"interface",
")",
";",
"$",
"directory",
"=",
"$",
"this",
"->",
"getMappingDirectory",
"(",
"'Property'",
")",
";",
"file_put_contents",
"(",
"$",
"directory",
".",
"$",
"this",
"->",
"propertyInterfaceName",
".",
"'.php'",
",",
"\"<?php\\n\\n\"",
".",
"$",
"code",
")",
";",
"}"
] |
Generate property interface.
|
[
"Generate",
"property",
"interface",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg/Generator.php#L154-L182
|
227,198
|
secit-pl/schema-org
|
SchemaOrg/Generator.php
|
Generator.generateTypeInterface
|
public function generateTypeInterface()
{
$interface = new PhpInterface($this->typeInterfaceName);
$interface
->setQualifiedName('SecIT\\SchemaOrg\\Mapping\\Type\\'.$this->typeInterfaceName)
->setDescription('Interface '.$this->typeInterfaceName.'.')
->setMethod(PhpMethod::create('getSchemaUrl')
->setDescription('Get schema URL.')
->setType('string')
)
->setMethod(PhpMethod::create('getId')
->setDescription('Get id.')
->setType('string')
)
;
$generator = new CodeGenerator();
$code = $generator->generate($interface);
$directory = $this->getMappingDirectory('Type');
file_put_contents($directory.$this->typeInterfaceName.'.php', "<?php\n\n".$code);
}
|
php
|
public function generateTypeInterface()
{
$interface = new PhpInterface($this->typeInterfaceName);
$interface
->setQualifiedName('SecIT\\SchemaOrg\\Mapping\\Type\\'.$this->typeInterfaceName)
->setDescription('Interface '.$this->typeInterfaceName.'.')
->setMethod(PhpMethod::create('getSchemaUrl')
->setDescription('Get schema URL.')
->setType('string')
)
->setMethod(PhpMethod::create('getId')
->setDescription('Get id.')
->setType('string')
)
;
$generator = new CodeGenerator();
$code = $generator->generate($interface);
$directory = $this->getMappingDirectory('Type');
file_put_contents($directory.$this->typeInterfaceName.'.php', "<?php\n\n".$code);
}
|
[
"public",
"function",
"generateTypeInterface",
"(",
")",
"{",
"$",
"interface",
"=",
"new",
"PhpInterface",
"(",
"$",
"this",
"->",
"typeInterfaceName",
")",
";",
"$",
"interface",
"->",
"setQualifiedName",
"(",
"'SecIT\\\\SchemaOrg\\\\Mapping\\\\Type\\\\'",
".",
"$",
"this",
"->",
"typeInterfaceName",
")",
"->",
"setDescription",
"(",
"'Interface '",
".",
"$",
"this",
"->",
"typeInterfaceName",
".",
"'.'",
")",
"->",
"setMethod",
"(",
"PhpMethod",
"::",
"create",
"(",
"'getSchemaUrl'",
")",
"->",
"setDescription",
"(",
"'Get schema URL.'",
")",
"->",
"setType",
"(",
"'string'",
")",
")",
"->",
"setMethod",
"(",
"PhpMethod",
"::",
"create",
"(",
"'getId'",
")",
"->",
"setDescription",
"(",
"'Get id.'",
")",
"->",
"setType",
"(",
"'string'",
")",
")",
";",
"$",
"generator",
"=",
"new",
"CodeGenerator",
"(",
")",
";",
"$",
"code",
"=",
"$",
"generator",
"->",
"generate",
"(",
"$",
"interface",
")",
";",
"$",
"directory",
"=",
"$",
"this",
"->",
"getMappingDirectory",
"(",
"'Type'",
")",
";",
"file_put_contents",
"(",
"$",
"directory",
".",
"$",
"this",
"->",
"typeInterfaceName",
".",
"'.php'",
",",
"\"<?php\\n\\n\"",
".",
"$",
"code",
")",
";",
"}"
] |
Generate type interface.
|
[
"Generate",
"type",
"interface",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg/Generator.php#L187-L208
|
227,199
|
secit-pl/schema-org
|
SchemaOrg/Generator.php
|
Generator.generateDataTypes
|
protected function generateDataTypes(array $schema)
{
$directory = $this->getMappingDirectory('DataType');
foreach ($schema['datatypes'] as $dataType => $data) {
$this->generateDataType($dataType, $data, $directory);
}
}
|
php
|
protected function generateDataTypes(array $schema)
{
$directory = $this->getMappingDirectory('DataType');
foreach ($schema['datatypes'] as $dataType => $data) {
$this->generateDataType($dataType, $data, $directory);
}
}
|
[
"protected",
"function",
"generateDataTypes",
"(",
"array",
"$",
"schema",
")",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"getMappingDirectory",
"(",
"'DataType'",
")",
";",
"foreach",
"(",
"$",
"schema",
"[",
"'datatypes'",
"]",
"as",
"$",
"dataType",
"=>",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"generateDataType",
"(",
"$",
"dataType",
",",
"$",
"data",
",",
"$",
"directory",
")",
";",
"}",
"}"
] |
Generate data types.
@param array $schema
|
[
"Generate",
"data",
"types",
"."
] |
5d1656153b5eebf7227cc72dd77562e288157346
|
https://github.com/secit-pl/schema-org/blob/5d1656153b5eebf7227cc72dd77562e288157346/SchemaOrg/Generator.php#L227-L233
|
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.