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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
224,300
|
logical-and/php-oauth
|
src/UserData/Arguments/LoadersMap.php
|
LoadersMap.removeField
|
public function removeField($field)
{
$this->checkValidLoader();
if (in_array($field, $this->loaders[ $this->contextLoader ])) {
array_splice(
$this->loaders[ $this->contextLoader ],
array_search($field, $this->loaders[ $this->contextLoader ])
);
}
return $this;
}
|
php
|
public function removeField($field)
{
$this->checkValidLoader();
if (in_array($field, $this->loaders[ $this->contextLoader ])) {
array_splice(
$this->loaders[ $this->contextLoader ],
array_search($field, $this->loaders[ $this->contextLoader ])
);
}
return $this;
}
|
[
"public",
"function",
"removeField",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"checkValidLoader",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"loaders",
"[",
"$",
"this",
"->",
"contextLoader",
"]",
")",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"loaders",
"[",
"$",
"this",
"->",
"contextLoader",
"]",
",",
"array_search",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"loaders",
"[",
"$",
"this",
"->",
"contextLoader",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove field from context loader
@param string $field
@return $this
|
[
"Remove",
"field",
"from",
"context",
"loader"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/LoadersMap.php#L131-L143
|
224,301
|
logical-and/php-oauth
|
src/UserData/Arguments/LoadersMap.php
|
LoadersMap.readdField
|
public function readdField($field)
{
$this->checkValidLoader();
foreach ($this->loaders as $loader => $fields) {
if (in_array($field, $this->loaders[ $loader ])) {
array_splice($this->loaders[ $loader ], array_search($field, $this->loaders[ $loader ]), 1);
}
}
$this->addField($field);
return $this;
}
|
php
|
public function readdField($field)
{
$this->checkValidLoader();
foreach ($this->loaders as $loader => $fields) {
if (in_array($field, $this->loaders[ $loader ])) {
array_splice($this->loaders[ $loader ], array_search($field, $this->loaders[ $loader ]), 1);
}
}
$this->addField($field);
return $this;
}
|
[
"public",
"function",
"readdField",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"checkValidLoader",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"loaders",
"as",
"$",
"loader",
"=>",
"$",
"fields",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"loaders",
"[",
"$",
"loader",
"]",
")",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"loaders",
"[",
"$",
"loader",
"]",
",",
"array_search",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"loaders",
"[",
"$",
"loader",
"]",
")",
",",
"1",
")",
";",
"}",
"}",
"$",
"this",
"->",
"addField",
"(",
"$",
"field",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add field to context loader and remove field from any other loaders
@param $field
@return $this
|
[
"Add",
"field",
"to",
"context",
"loader",
"and",
"remove",
"field",
"from",
"any",
"other",
"loaders"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/LoadersMap.php#L168-L181
|
224,302
|
logical-and/php-oauth
|
src/UserData/Arguments/LoadersMap.php
|
LoadersMap.getLoaderForField
|
public function getLoaderForField($searchField)
{
foreach ($this->loaders as $loader => $fields) {
if (in_array($searchField, $fields, true)) {
return $loader;
}
}
throw new GenericException("Unable to find loader for field \"$searchField\"");
}
|
php
|
public function getLoaderForField($searchField)
{
foreach ($this->loaders as $loader => $fields) {
if (in_array($searchField, $fields, true)) {
return $loader;
}
}
throw new GenericException("Unable to find loader for field \"$searchField\"");
}
|
[
"public",
"function",
"getLoaderForField",
"(",
"$",
"searchField",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loaders",
"as",
"$",
"loader",
"=>",
"$",
"fields",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"searchField",
",",
"$",
"fields",
",",
"true",
")",
")",
"{",
"return",
"$",
"loader",
";",
"}",
"}",
"throw",
"new",
"GenericException",
"(",
"\"Unable to find loader for field \\\"$searchField\\\"\"",
")",
";",
"}"
] |
Get loader byfield name
@param string $searchField
@return int|string
@throws \OAuth\UserData\Exception\GenericException
|
[
"Get",
"loader",
"byfield",
"name"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/LoadersMap.php#L207-L216
|
224,303
|
oroinc/OroMessageQueueComponent
|
Job/JobStorage.php
|
JobStorage.findRootJobByJobNameAndStatuses
|
public function findRootJobByJobNameAndStatuses($jobName, array $statuses)
{
return $this->createJobQueryBuilder('job')
->where('job.rootJob is NULL and job.name = :jobName and job.status in (:statuses)')
->andWhere('job.interrupted != true')
->setParameter('jobName', $jobName)
->setParameter('statuses', $statuses)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
|
php
|
public function findRootJobByJobNameAndStatuses($jobName, array $statuses)
{
return $this->createJobQueryBuilder('job')
->where('job.rootJob is NULL and job.name = :jobName and job.status in (:statuses)')
->andWhere('job.interrupted != true')
->setParameter('jobName', $jobName)
->setParameter('statuses', $statuses)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
|
[
"public",
"function",
"findRootJobByJobNameAndStatuses",
"(",
"$",
"jobName",
",",
"array",
"$",
"statuses",
")",
"{",
"return",
"$",
"this",
"->",
"createJobQueryBuilder",
"(",
"'job'",
")",
"->",
"where",
"(",
"'job.rootJob is NULL and job.name = :jobName and job.status in (:statuses)'",
")",
"->",
"andWhere",
"(",
"'job.interrupted != true'",
")",
"->",
"setParameter",
"(",
"'jobName'",
",",
"$",
"jobName",
")",
"->",
"setParameter",
"(",
"'statuses'",
",",
"$",
"statuses",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getQuery",
"(",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"}"
] |
Finds root non interrupted job by name and given statuses.
@param string $jobName
@param array $statuses
@return Job|null
|
[
"Finds",
"root",
"non",
"interrupted",
"job",
"by",
"name",
"and",
"given",
"statuses",
"."
] |
6f1fdb12aebcfc6beae074ce492f496ed9847a77
|
https://github.com/oroinc/OroMessageQueueComponent/blob/6f1fdb12aebcfc6beae074ce492f496ed9847a77/Job/JobStorage.php#L79-L89
|
224,304
|
oroinc/OroMessageQueueComponent
|
Job/JobStorage.php
|
JobStorage.getChildJobIdsByRootJobAndStatus
|
public function getChildJobIdsByRootJobAndStatus(Job $rootJob, $status)
{
$qb = $this->createJobQueryBuilder('job');
$rawChildJobIds = $qb
->select('job.id')
->where(
$qb->expr()->andX(
'job.rootJob = :rootJob',
'job.status = :status'
)
)
->setParameters(
new ArrayCollection(
[
new Parameter('rootJob', $rootJob),
new Parameter('status', $status),
]
)
)
->getQuery()
->getScalarResult();
return array_column($rawChildJobIds, 'id');
}
|
php
|
public function getChildJobIdsByRootJobAndStatus(Job $rootJob, $status)
{
$qb = $this->createJobQueryBuilder('job');
$rawChildJobIds = $qb
->select('job.id')
->where(
$qb->expr()->andX(
'job.rootJob = :rootJob',
'job.status = :status'
)
)
->setParameters(
new ArrayCollection(
[
new Parameter('rootJob', $rootJob),
new Parameter('status', $status),
]
)
)
->getQuery()
->getScalarResult();
return array_column($rawChildJobIds, 'id');
}
|
[
"public",
"function",
"getChildJobIdsByRootJobAndStatus",
"(",
"Job",
"$",
"rootJob",
",",
"$",
"status",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createJobQueryBuilder",
"(",
"'job'",
")",
";",
"$",
"rawChildJobIds",
"=",
"$",
"qb",
"->",
"select",
"(",
"'job.id'",
")",
"->",
"where",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
"'job.rootJob = :rootJob'",
",",
"'job.status = :status'",
")",
")",
"->",
"setParameters",
"(",
"new",
"ArrayCollection",
"(",
"[",
"new",
"Parameter",
"(",
"'rootJob'",
",",
"$",
"rootJob",
")",
",",
"new",
"Parameter",
"(",
"'status'",
",",
"$",
"status",
")",
",",
"]",
")",
")",
"->",
"getQuery",
"(",
")",
"->",
"getScalarResult",
"(",
")",
";",
"return",
"array_column",
"(",
"$",
"rawChildJobIds",
",",
"'id'",
")",
";",
"}"
] |
Be warned that
In PGSQL function returns array of ids in DESC order, every id has integer type,
But in MYSQL it will be array of ids in ASC order, every id has string type
@param Job $rootJob
@param string $status
@return array
|
[
"Be",
"warned",
"that",
"In",
"PGSQL",
"function",
"returns",
"array",
"of",
"ids",
"in",
"DESC",
"order",
"every",
"id",
"has",
"integer",
"type",
"But",
"in",
"MYSQL",
"it",
"will",
"be",
"array",
"of",
"ids",
"in",
"ASC",
"order",
"every",
"id",
"has",
"string",
"type"
] |
6f1fdb12aebcfc6beae074ce492f496ed9847a77
|
https://github.com/oroinc/OroMessageQueueComponent/blob/6f1fdb12aebcfc6beae074ce492f496ed9847a77/Job/JobStorage.php#L142-L165
|
224,305
|
oroinc/OroMessageQueueComponent
|
Job/JobStorage.php
|
JobStorage.resetEntityManager
|
private function resetEntityManager()
{
$managers = $this->doctrine->getManagers();
foreach ($managers as $name => $manager) {
if (!$manager->getMetadataFactory()->isTransient($this->entityClass)) {
$this->doctrine->resetManager($name);
break;
}
}
}
|
php
|
private function resetEntityManager()
{
$managers = $this->doctrine->getManagers();
foreach ($managers as $name => $manager) {
if (!$manager->getMetadataFactory()->isTransient($this->entityClass)) {
$this->doctrine->resetManager($name);
break;
}
}
}
|
[
"private",
"function",
"resetEntityManager",
"(",
")",
"{",
"$",
"managers",
"=",
"$",
"this",
"->",
"doctrine",
"->",
"getManagers",
"(",
")",
";",
"foreach",
"(",
"$",
"managers",
"as",
"$",
"name",
"=>",
"$",
"manager",
")",
"{",
"if",
"(",
"!",
"$",
"manager",
"->",
"getMetadataFactory",
"(",
")",
"->",
"isTransient",
"(",
"$",
"this",
"->",
"entityClass",
")",
")",
"{",
"$",
"this",
"->",
"doctrine",
"->",
"resetManager",
"(",
"$",
"name",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Replaces the closed entity manager with new instance of entity manager.
|
[
"Replaces",
"the",
"closed",
"entity",
"manager",
"with",
"new",
"instance",
"of",
"entity",
"manager",
"."
] |
6f1fdb12aebcfc6beae074ce492f496ed9847a77
|
https://github.com/oroinc/OroMessageQueueComponent/blob/6f1fdb12aebcfc6beae074ce492f496ed9847a77/Job/JobStorage.php#L303-L312
|
224,306
|
A1essandro/perlin-noise-generator
|
src/PerlinNoiseGenerator.php
|
PerlinNoiseGenerator.initTerra
|
protected function initTerra()
{
if (empty($this->mapSeed)) {
$this->setMapSeed(microtime(true));
}
if (!$this->getPersistence()) {
throw new LogicException('Persistence must be set');
}
if (!$this->getSize()) {
throw new LogicException('Size must be set');
}
mt_srand($this->numericMapSeed * $this->persistence * $this->size);
$this->terra = new SplFixedArray($this->size);
for ($y = 0; $y < $this->size; $y++) {
$this->terra[$y] = new SplFixedArray($this->size);
for ($x = 0; $x < $this->size; $x++) {
$this->terra[$y][$x] = 0;
}
}
}
|
php
|
protected function initTerra()
{
if (empty($this->mapSeed)) {
$this->setMapSeed(microtime(true));
}
if (!$this->getPersistence()) {
throw new LogicException('Persistence must be set');
}
if (!$this->getSize()) {
throw new LogicException('Size must be set');
}
mt_srand($this->numericMapSeed * $this->persistence * $this->size);
$this->terra = new SplFixedArray($this->size);
for ($y = 0; $y < $this->size; $y++) {
$this->terra[$y] = new SplFixedArray($this->size);
for ($x = 0; $x < $this->size; $x++) {
$this->terra[$y][$x] = 0;
}
}
}
|
[
"protected",
"function",
"initTerra",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"mapSeed",
")",
")",
"{",
"$",
"this",
"->",
"setMapSeed",
"(",
"microtime",
"(",
"true",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getPersistence",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Persistence must be set'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getSize",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Size must be set'",
")",
";",
"}",
"mt_srand",
"(",
"$",
"this",
"->",
"numericMapSeed",
"*",
"$",
"this",
"->",
"persistence",
"*",
"$",
"this",
"->",
"size",
")",
";",
"$",
"this",
"->",
"terra",
"=",
"new",
"SplFixedArray",
"(",
"$",
"this",
"->",
"size",
")",
";",
"for",
"(",
"$",
"y",
"=",
"0",
";",
"$",
"y",
"<",
"$",
"this",
"->",
"size",
";",
"$",
"y",
"++",
")",
"{",
"$",
"this",
"->",
"terra",
"[",
"$",
"y",
"]",
"=",
"new",
"SplFixedArray",
"(",
"$",
"this",
"->",
"size",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"this",
"->",
"size",
";",
"$",
"x",
"++",
")",
"{",
"$",
"this",
"->",
"terra",
"[",
"$",
"y",
"]",
"[",
"$",
"x",
"]",
"=",
"0",
";",
"}",
"}",
"}"
] |
terra array initialization
|
[
"terra",
"array",
"initialization"
] |
dfc97a6ec05572d9a5c7b4c0353df8350554d953
|
https://github.com/A1essandro/perlin-noise-generator/blob/dfc97a6ec05572d9a5c7b4c0353df8350554d953/src/PerlinNoiseGenerator.php#L135-L158
|
224,307
|
ericmann/sessionz
|
php/Handlers/DefaultHandler.php
|
DefaultHandler.delete
|
public function delete($id, $next)
{
$status = $this->handler->destroy($id);
return $next($id) && $status;
}
|
php
|
public function delete($id, $next)
{
$status = $this->handler->destroy($id);
return $next($id) && $status;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"id",
",",
"$",
"next",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"handler",
"->",
"destroy",
"(",
"$",
"id",
")",
";",
"return",
"$",
"next",
"(",
"$",
"id",
")",
"&&",
"$",
"status",
";",
"}"
] |
Delete a session from storage by ID.
@param string $id ID of the session to remove
@param callable $next Callable to invoke the next layer in the stack
@return bool
|
[
"Delete",
"a",
"session",
"from",
"storage",
"by",
"ID",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Handlers/DefaultHandler.php#L49-L53
|
224,308
|
ericmann/sessionz
|
php/Handlers/DefaultHandler.php
|
DefaultHandler.clean
|
public function clean($maxlifetime, $next)
{
$status = $this->handler->gc($maxlifetime);
return $next($maxlifetime) && $status;
}
|
php
|
public function clean($maxlifetime, $next)
{
$status = $this->handler->gc($maxlifetime);
return $next($maxlifetime) && $status;
}
|
[
"public",
"function",
"clean",
"(",
"$",
"maxlifetime",
",",
"$",
"next",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"handler",
"->",
"gc",
"(",
"$",
"maxlifetime",
")",
";",
"return",
"$",
"next",
"(",
"$",
"maxlifetime",
")",
"&&",
"$",
"status",
";",
"}"
] |
Clean up all session older than the max lifetime specified.
@param int $maxlifetime Max number of seconds for a valid session
@param callable $next Callable to invoke the next layer in the stack
@return bool
|
[
"Clean",
"up",
"all",
"session",
"older",
"than",
"the",
"max",
"lifetime",
"specified",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Handlers/DefaultHandler.php#L63-L67
|
224,309
|
ericmann/sessionz
|
php/Handlers/DefaultHandler.php
|
DefaultHandler.create
|
public function create($path, $name, $next)
{
$status = $this->handler->open($path, $name);
return $next($path, $name) && $status;
}
|
php
|
public function create($path, $name, $next)
{
$status = $this->handler->open($path, $name);
return $next($path, $name) && $status;
}
|
[
"public",
"function",
"create",
"(",
"$",
"path",
",",
"$",
"name",
",",
"$",
"next",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"handler",
"->",
"open",
"(",
"$",
"path",
",",
"$",
"name",
")",
";",
"return",
"$",
"next",
"(",
"$",
"path",
",",
"$",
"name",
")",
"&&",
"$",
"status",
";",
"}"
] |
Create a new session store.
@param string $path Path where the storage lives
@param string $name Name of the session store to create
@param callable $next Callable to invoke the next layer in the stack
@return bool
|
[
"Create",
"a",
"new",
"session",
"store",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Handlers/DefaultHandler.php#L78-L82
|
224,310
|
ericmann/sessionz
|
php/Handlers/DefaultHandler.php
|
DefaultHandler.read
|
public function read($id, $next)
{
return empty($this->handler->read($id)) ? $next($id) : $this->handler->read($id);
}
|
php
|
public function read($id, $next)
{
return empty($this->handler->read($id)) ? $next($id) : $this->handler->read($id);
}
|
[
"public",
"function",
"read",
"(",
"$",
"id",
",",
"$",
"next",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"handler",
"->",
"read",
"(",
"$",
"id",
")",
")",
"?",
"$",
"next",
"(",
"$",
"id",
")",
":",
"$",
"this",
"->",
"handler",
"->",
"read",
"(",
"$",
"id",
")",
";",
"}"
] |
Read a specific session from storage.
@param string $id ID of the session to read
@param callable $next Callable to invoke the next layer in the stack
@return string
|
[
"Read",
"a",
"specific",
"session",
"from",
"storage",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Handlers/DefaultHandler.php#L92-L95
|
224,311
|
logical-and/php-oauth
|
src/UserData/Arguments/FieldsValues.php
|
FieldsValues.fieldValue
|
public function fieldValue($field, $value)
{
if (!in_array($field, $this->supports)) {
$this->supports[ ] = $field;
}
$this->values[ $field ] = $value;
return $this;
}
|
php
|
public function fieldValue($field, $value)
{
if (!in_array($field, $this->supports)) {
$this->supports[ ] = $field;
}
$this->values[ $field ] = $value;
return $this;
}
|
[
"public",
"function",
"fieldValue",
"(",
"$",
"field",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"supports",
")",
")",
"{",
"$",
"this",
"->",
"supports",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"$",
"this",
"->",
"values",
"[",
"$",
"field",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Set field default value
@param $field
@param $value
@return $this
|
[
"Set",
"field",
"default",
"value"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/FieldsValues.php#L65-L73
|
224,312
|
appkr/api
|
src/example/AuthorTransformer.php
|
AuthorTransformer.includeBooks
|
public function includeBooks(Author $author, ParamBag $paramBag = null)
{
$transformer = new BookTransformer($paramBag);
$books = $author->books()
->limit($transformer->getLimit())
->offset($transformer->getOffset())
->orderBy($transformer->getSortKey(), $transformer->getSortDirection())
->get();
return $this->collection($books, new BookTransformer);
}
|
php
|
public function includeBooks(Author $author, ParamBag $paramBag = null)
{
$transformer = new BookTransformer($paramBag);
$books = $author->books()
->limit($transformer->getLimit())
->offset($transformer->getOffset())
->orderBy($transformer->getSortKey(), $transformer->getSortDirection())
->get();
return $this->collection($books, new BookTransformer);
}
|
[
"public",
"function",
"includeBooks",
"(",
"Author",
"$",
"author",
",",
"ParamBag",
"$",
"paramBag",
"=",
"null",
")",
"{",
"$",
"transformer",
"=",
"new",
"BookTransformer",
"(",
"$",
"paramBag",
")",
";",
"$",
"books",
"=",
"$",
"author",
"->",
"books",
"(",
")",
"->",
"limit",
"(",
"$",
"transformer",
"->",
"getLimit",
"(",
")",
")",
"->",
"offset",
"(",
"$",
"transformer",
"->",
"getOffset",
"(",
")",
")",
"->",
"orderBy",
"(",
"$",
"transformer",
"->",
"getSortKey",
"(",
")",
",",
"$",
"transformer",
"->",
"getSortDirection",
"(",
")",
")",
"->",
"get",
"(",
")",
";",
"return",
"$",
"this",
"->",
"collection",
"(",
"$",
"books",
",",
"new",
"BookTransformer",
")",
";",
"}"
] |
Include books.
@param \Appkr\Api\Example\Author $author
@param \League\Fractal\ParamBag|null $paramBag
@return \League\Fractal\Resource\Collection
|
[
"Include",
"books",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/example/AuthorTransformer.php#L73-L84
|
224,313
|
mondalaci/supervisord-php-client
|
src/SupervisorClient/SupervisorClient.php
|
SupervisorClient._getSocket
|
protected function _getSocket()
{
if (is_resource($this->_socket)) {
if (feof($this->_socket)) {
// Supervisor sometimes seems to close the socket after a request is completed, which
// causes the following request made by SupervisorClient to fail mysteriously with an
// error about a missing content-length header. This check takes care of this issue.
fclose($this->_socket);
} else {
// Check if the socket already exists and is open, if it is return it.
return $this->_socket;
}
}
// Open the socket.
$this->_socket = @fsockopen(
$this->_hostname,
$this->_port,
$errno,
$errstr,
$this->_timeout
);
if (!$this->_socket) {
throw new Exception(sprintf("Cannot open socket: Error %d: \"%s\"", $errno, $errstr));
}
stream_set_timeout($this->_socket, $this->_timeout);
return $this->_socket;
}
|
php
|
protected function _getSocket()
{
if (is_resource($this->_socket)) {
if (feof($this->_socket)) {
// Supervisor sometimes seems to close the socket after a request is completed, which
// causes the following request made by SupervisorClient to fail mysteriously with an
// error about a missing content-length header. This check takes care of this issue.
fclose($this->_socket);
} else {
// Check if the socket already exists and is open, if it is return it.
return $this->_socket;
}
}
// Open the socket.
$this->_socket = @fsockopen(
$this->_hostname,
$this->_port,
$errno,
$errstr,
$this->_timeout
);
if (!$this->_socket) {
throw new Exception(sprintf("Cannot open socket: Error %d: \"%s\"", $errno, $errstr));
}
stream_set_timeout($this->_socket, $this->_timeout);
return $this->_socket;
}
|
[
"protected",
"function",
"_getSocket",
"(",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_socket",
")",
")",
"{",
"if",
"(",
"feof",
"(",
"$",
"this",
"->",
"_socket",
")",
")",
"{",
"// Supervisor sometimes seems to close the socket after a request is completed, which",
"// causes the following request made by SupervisorClient to fail mysteriously with an",
"// error about a missing content-length header. This check takes care of this issue.",
"fclose",
"(",
"$",
"this",
"->",
"_socket",
")",
";",
"}",
"else",
"{",
"// Check if the socket already exists and is open, if it is return it.",
"return",
"$",
"this",
"->",
"_socket",
";",
"}",
"}",
"// Open the socket.",
"$",
"this",
"->",
"_socket",
"=",
"@",
"fsockopen",
"(",
"$",
"this",
"->",
"_hostname",
",",
"$",
"this",
"->",
"_port",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"this",
"->",
"_timeout",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_socket",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"\"Cannot open socket: Error %d: \\\"%s\\\"\"",
",",
"$",
"errno",
",",
"$",
"errstr",
")",
")",
";",
"}",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"_socket",
",",
"$",
"this",
"->",
"_timeout",
")",
";",
"return",
"$",
"this",
"->",
"_socket",
";",
"}"
] |
Get the socket
@return resource
@throws \Exception
|
[
"Get",
"the",
"socket"
] |
c826f56b6652ab292799e2daed7bda16fbd5ad6a
|
https://github.com/mondalaci/supervisord-php-client/blob/c826f56b6652ab292799e2daed7bda16fbd5ad6a/src/SupervisorClient/SupervisorClient.php#L650-L680
|
224,314
|
mondalaci/supervisord-php-client
|
src/SupervisorClient/SupervisorClient.php
|
SupervisorClient._doRequest
|
protected function _doRequest($namespace, $method, $args)
{
// Create the authorization header.
$authorization = '';
if (!is_null($this->_username) && !is_null($this->_password)) {
$authorization = "\r\nAuthorization: Basic " . base64_encode($this->_username . ':' . $this->_password);
}
// Create the HTTP request.
$xmlRpc = \xmlrpc_encode_request("$namespace.$method", $args, array('encoding' => 'utf-8'));
$httpRequest = "POST /RPC2 HTTP/1.0\r\n" .
"Content-Length: " . strlen($xmlRpc) .
$authorization .
"\r\n\r\n" .
$xmlRpc;
// Write the request to the socket.
fwrite($this->_getSocket(), $httpRequest);
}
|
php
|
protected function _doRequest($namespace, $method, $args)
{
// Create the authorization header.
$authorization = '';
if (!is_null($this->_username) && !is_null($this->_password)) {
$authorization = "\r\nAuthorization: Basic " . base64_encode($this->_username . ':' . $this->_password);
}
// Create the HTTP request.
$xmlRpc = \xmlrpc_encode_request("$namespace.$method", $args, array('encoding' => 'utf-8'));
$httpRequest = "POST /RPC2 HTTP/1.0\r\n" .
"Content-Length: " . strlen($xmlRpc) .
$authorization .
"\r\n\r\n" .
$xmlRpc;
// Write the request to the socket.
fwrite($this->_getSocket(), $httpRequest);
}
|
[
"protected",
"function",
"_doRequest",
"(",
"$",
"namespace",
",",
"$",
"method",
",",
"$",
"args",
")",
"{",
"// Create the authorization header.",
"$",
"authorization",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_username",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_password",
")",
")",
"{",
"$",
"authorization",
"=",
"\"\\r\\nAuthorization: Basic \"",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"_username",
".",
"':'",
".",
"$",
"this",
"->",
"_password",
")",
";",
"}",
"// Create the HTTP request.",
"$",
"xmlRpc",
"=",
"\\",
"xmlrpc_encode_request",
"(",
"\"$namespace.$method\"",
",",
"$",
"args",
",",
"array",
"(",
"'encoding'",
"=>",
"'utf-8'",
")",
")",
";",
"$",
"httpRequest",
"=",
"\"POST /RPC2 HTTP/1.0\\r\\n\"",
".",
"\"Content-Length: \"",
".",
"strlen",
"(",
"$",
"xmlRpc",
")",
".",
"$",
"authorization",
".",
"\"\\r\\n\\r\\n\"",
".",
"$",
"xmlRpc",
";",
"// Write the request to the socket.",
"fwrite",
"(",
"$",
"this",
"->",
"_getSocket",
"(",
")",
",",
"$",
"httpRequest",
")",
";",
"}"
] |
Do a request to the supervisor XML-RPC API
@param string $namespace The namespace of the request
@param string $method The method in the namespace
@param mixed $args Optional arguments
|
[
"Do",
"a",
"request",
"to",
"the",
"supervisor",
"XML",
"-",
"RPC",
"API"
] |
c826f56b6652ab292799e2daed7bda16fbd5ad6a
|
https://github.com/mondalaci/supervisord-php-client/blob/c826f56b6652ab292799e2daed7bda16fbd5ad6a/src/SupervisorClient/SupervisorClient.php#L689-L707
|
224,315
|
EvanDotPro/EdpSuperluminal
|
Module.php
|
Module.cache
|
public function cache($e)
{
$request = $e->getRequest();
if ($request instanceof ConsoleRequest ||
$request->getQuery()->get('EDPSUPERLUMINAL_CACHE', null) === null) {
return;
}
if (file_exists(ZF_CLASS_CACHE)) {
$this->reflectClassCache();
$code = file_get_contents(ZF_CLASS_CACHE);
} else {
$code = "<?php\n";
}
$classes = array_merge(get_declared_interfaces(), get_declared_classes());
foreach ($classes as $class) {
// Skip non-Zend classes
if (0 !== strpos($class, 'Zend')) {
continue;
}
// Skip the autoloader factory and this class
if (in_array($class, array('Zend\Loader\AutoloaderFactory', __CLASS__))) {
continue;
}
if ($class === 'Zend\Loader\SplAutoloader') {
continue;
}
// Skip any classes we already know about
if (in_array($class, $this->knownClasses)) {
continue;
}
$this->knownClasses[] = $class;
$class = new ClassReflection($class);
// Skip ZF2-based autoloaders
if (in_array('Zend\Loader\SplAutoloader', $class->getInterfaceNames())) {
continue;
}
// Skip internal classes or classes from extensions
// (this shouldn't happen, as we're only caching Zend classes)
if ($class->isInternal()
|| $class->getExtensionName()
) {
continue;
}
$code .= static::getCacheCode($class);
}
file_put_contents(ZF_CLASS_CACHE, $code);
// minify the file
file_put_contents(ZF_CLASS_CACHE, php_strip_whitespace(ZF_CLASS_CACHE));
}
|
php
|
public function cache($e)
{
$request = $e->getRequest();
if ($request instanceof ConsoleRequest ||
$request->getQuery()->get('EDPSUPERLUMINAL_CACHE', null) === null) {
return;
}
if (file_exists(ZF_CLASS_CACHE)) {
$this->reflectClassCache();
$code = file_get_contents(ZF_CLASS_CACHE);
} else {
$code = "<?php\n";
}
$classes = array_merge(get_declared_interfaces(), get_declared_classes());
foreach ($classes as $class) {
// Skip non-Zend classes
if (0 !== strpos($class, 'Zend')) {
continue;
}
// Skip the autoloader factory and this class
if (in_array($class, array('Zend\Loader\AutoloaderFactory', __CLASS__))) {
continue;
}
if ($class === 'Zend\Loader\SplAutoloader') {
continue;
}
// Skip any classes we already know about
if (in_array($class, $this->knownClasses)) {
continue;
}
$this->knownClasses[] = $class;
$class = new ClassReflection($class);
// Skip ZF2-based autoloaders
if (in_array('Zend\Loader\SplAutoloader', $class->getInterfaceNames())) {
continue;
}
// Skip internal classes or classes from extensions
// (this shouldn't happen, as we're only caching Zend classes)
if ($class->isInternal()
|| $class->getExtensionName()
) {
continue;
}
$code .= static::getCacheCode($class);
}
file_put_contents(ZF_CLASS_CACHE, $code);
// minify the file
file_put_contents(ZF_CLASS_CACHE, php_strip_whitespace(ZF_CLASS_CACHE));
}
|
[
"public",
"function",
"cache",
"(",
"$",
"e",
")",
"{",
"$",
"request",
"=",
"$",
"e",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"instanceof",
"ConsoleRequest",
"||",
"$",
"request",
"->",
"getQuery",
"(",
")",
"->",
"get",
"(",
"'EDPSUPERLUMINAL_CACHE'",
",",
"null",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"file_exists",
"(",
"ZF_CLASS_CACHE",
")",
")",
"{",
"$",
"this",
"->",
"reflectClassCache",
"(",
")",
";",
"$",
"code",
"=",
"file_get_contents",
"(",
"ZF_CLASS_CACHE",
")",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"\"<?php\\n\"",
";",
"}",
"$",
"classes",
"=",
"array_merge",
"(",
"get_declared_interfaces",
"(",
")",
",",
"get_declared_classes",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"// Skip non-Zend classes",
"if",
"(",
"0",
"!==",
"strpos",
"(",
"$",
"class",
",",
"'Zend'",
")",
")",
"{",
"continue",
";",
"}",
"// Skip the autoloader factory and this class",
"if",
"(",
"in_array",
"(",
"$",
"class",
",",
"array",
"(",
"'Zend\\Loader\\AutoloaderFactory'",
",",
"__CLASS__",
")",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"class",
"===",
"'Zend\\Loader\\SplAutoloader'",
")",
"{",
"continue",
";",
"}",
"// Skip any classes we already know about",
"if",
"(",
"in_array",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"knownClasses",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"knownClasses",
"[",
"]",
"=",
"$",
"class",
";",
"$",
"class",
"=",
"new",
"ClassReflection",
"(",
"$",
"class",
")",
";",
"// Skip ZF2-based autoloaders",
"if",
"(",
"in_array",
"(",
"'Zend\\Loader\\SplAutoloader'",
",",
"$",
"class",
"->",
"getInterfaceNames",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"// Skip internal classes or classes from extensions",
"// (this shouldn't happen, as we're only caching Zend classes)",
"if",
"(",
"$",
"class",
"->",
"isInternal",
"(",
")",
"||",
"$",
"class",
"->",
"getExtensionName",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"code",
".=",
"static",
"::",
"getCacheCode",
"(",
"$",
"class",
")",
";",
"}",
"file_put_contents",
"(",
"ZF_CLASS_CACHE",
",",
"$",
"code",
")",
";",
"// minify the file",
"file_put_contents",
"(",
"ZF_CLASS_CACHE",
",",
"php_strip_whitespace",
"(",
"ZF_CLASS_CACHE",
")",
")",
";",
"}"
] |
Cache declared interfaces and classes to a single file
@param \Zend\Mvc\MvcEvent $e
@return void
|
[
"Cache",
"declared",
"interfaces",
"and",
"classes",
"to",
"a",
"single",
"file"
] |
59e8b98422bdcb162be397cd2dd181ba6ecdfa36
|
https://github.com/EvanDotPro/EdpSuperluminal/blob/59e8b98422bdcb162be397cd2dd181ba6ecdfa36/Module.php#L36-L94
|
224,316
|
turtledesign/royalmail-php
|
src/Validator/Validates.php
|
Validates.validate
|
static function validate($schema, $value, $helper = NULL) {
foreach (self::parseConstraints($schema) as $c) { // The constraints are in a numeric array as the order matters.
$constraint = key($c);
$params = $c[$constraint];
if (self::isBlank($value) && ! preg_match('/require|notblank/i', $constraint)) continue; // Only *require* validators should check blank values.
$value = self::constrain($value, $constraint, self::parseParams($params, $schema), $helper);
}
return $value;
}
|
php
|
static function validate($schema, $value, $helper = NULL) {
foreach (self::parseConstraints($schema) as $c) { // The constraints are in a numeric array as the order matters.
$constraint = key($c);
$params = $c[$constraint];
if (self::isBlank($value) && ! preg_match('/require|notblank/i', $constraint)) continue; // Only *require* validators should check blank values.
$value = self::constrain($value, $constraint, self::parseParams($params, $schema), $helper);
}
return $value;
}
|
[
"static",
"function",
"validate",
"(",
"$",
"schema",
",",
"$",
"value",
",",
"$",
"helper",
"=",
"NULL",
")",
"{",
"foreach",
"(",
"self",
"::",
"parseConstraints",
"(",
"$",
"schema",
")",
"as",
"$",
"c",
")",
"{",
"// The constraints are in a numeric array as the order matters.",
"$",
"constraint",
"=",
"key",
"(",
"$",
"c",
")",
";",
"$",
"params",
"=",
"$",
"c",
"[",
"$",
"constraint",
"]",
";",
"if",
"(",
"self",
"::",
"isBlank",
"(",
"$",
"value",
")",
"&&",
"!",
"preg_match",
"(",
"'/require|notblank/i'",
",",
"$",
"constraint",
")",
")",
"continue",
";",
"// Only *require* validators should check blank values.",
"$",
"value",
"=",
"self",
"::",
"constrain",
"(",
"$",
"value",
",",
"$",
"constraint",
",",
"self",
"::",
"parseParams",
"(",
"$",
"params",
",",
"$",
"schema",
")",
",",
"$",
"helper",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Validate the given values against the constraints given.
@param mixed $value
@param array $constraints
@return mixed $value - validated and cleaned.
|
[
"Validate",
"the",
"given",
"values",
"against",
"the",
"constraints",
"given",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Validator/Validates.php#L29-L40
|
224,317
|
turtledesign/royalmail-php
|
src/Validator/Validates.php
|
Validates.parseParams
|
static function parseParams($params, $schema) {
$params = (array) $params;
foreach (array_diff_key($schema, ['_validate' => 1]) as $k => $v) if (preg_match('/^_/', $k)) $params[$k] = $v;
return $params;
}
|
php
|
static function parseParams($params, $schema) {
$params = (array) $params;
foreach (array_diff_key($schema, ['_validate' => 1]) as $k => $v) if (preg_match('/^_/', $k)) $params[$k] = $v;
return $params;
}
|
[
"static",
"function",
"parseParams",
"(",
"$",
"params",
",",
"$",
"schema",
")",
"{",
"$",
"params",
"=",
"(",
"array",
")",
"$",
"params",
";",
"foreach",
"(",
"array_diff_key",
"(",
"$",
"schema",
",",
"[",
"'_validate'",
"=>",
"1",
"]",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"if",
"(",
"preg_match",
"(",
"'/^_/'",
",",
"$",
"k",
")",
")",
"$",
"params",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"return",
"$",
"params",
";",
"}"
] |
Adds extra settings values from the schema as they may be used by the validator as well as other things.
@param mixed $params
@param array $schema
@return array
|
[
"Adds",
"extra",
"settings",
"values",
"from",
"the",
"schema",
"as",
"they",
"may",
"be",
"used",
"by",
"the",
"validator",
"as",
"well",
"as",
"other",
"things",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Validator/Validates.php#L65-L71
|
224,318
|
turtledesign/royalmail-php
|
src/Validator/Validates.php
|
Validates.constrain
|
static function constrain($value, $constraint, $params = [], $helper = NULL) {
$constraint_method = get_called_class() . '::check' . $constraint;
if (! is_callable($constraint_method)) throw new \InvalidArgumentException('Invalid constraint method ' . $constraint_method . ' called');
return call_user_func_array($constraint_method, [$value, (array) $params, $helper]);
}
|
php
|
static function constrain($value, $constraint, $params = [], $helper = NULL) {
$constraint_method = get_called_class() . '::check' . $constraint;
if (! is_callable($constraint_method)) throw new \InvalidArgumentException('Invalid constraint method ' . $constraint_method . ' called');
return call_user_func_array($constraint_method, [$value, (array) $params, $helper]);
}
|
[
"static",
"function",
"constrain",
"(",
"$",
"value",
",",
"$",
"constraint",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"helper",
"=",
"NULL",
")",
"{",
"$",
"constraint_method",
"=",
"get_called_class",
"(",
")",
".",
"'::check'",
".",
"$",
"constraint",
";",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"constraint_method",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid constraint method '",
".",
"$",
"constraint_method",
".",
"' called'",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"constraint_method",
",",
"[",
"$",
"value",
",",
"(",
"array",
")",
"$",
"params",
",",
"$",
"helper",
"]",
")",
";",
"}"
] |
Apply the given constraints with the parameters given.
@param mixed $value
@param string $constraint
@param array $params
@return mixed
|
[
"Apply",
"the",
"given",
"constraints",
"with",
"the",
"parameters",
"given",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Validator/Validates.php#L84-L90
|
224,319
|
turtledesign/royalmail-php
|
src/Validator/Validates.php
|
Validates.checkThisRequiredWhenThat
|
static function checkThisRequiredWhenThat($value, $params, $helper) {
if (self::checkPath($params['that'], ['required' => TRUE, 'in' => (array) $params['is']], $helper)) {
$params = array_merge(['message' => 'required when ' . $params['that'] . ' in (' . implode(', ', (array) $params['is']) . ')'], $params);
return self::checkNotBlank($value, $params, $helper);
}
return $value;
}
|
php
|
static function checkThisRequiredWhenThat($value, $params, $helper) {
if (self::checkPath($params['that'], ['required' => TRUE, 'in' => (array) $params['is']], $helper)) {
$params = array_merge(['message' => 'required when ' . $params['that'] . ' in (' . implode(', ', (array) $params['is']) . ')'], $params);
return self::checkNotBlank($value, $params, $helper);
}
return $value;
}
|
[
"static",
"function",
"checkThisRequiredWhenThat",
"(",
"$",
"value",
",",
"$",
"params",
",",
"$",
"helper",
")",
"{",
"if",
"(",
"self",
"::",
"checkPath",
"(",
"$",
"params",
"[",
"'that'",
"]",
",",
"[",
"'required'",
"=>",
"TRUE",
",",
"'in'",
"=>",
"(",
"array",
")",
"$",
"params",
"[",
"'is'",
"]",
"]",
",",
"$",
"helper",
")",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"'message'",
"=>",
"'required when '",
".",
"$",
"params",
"[",
"'that'",
"]",
".",
"' in ('",
".",
"implode",
"(",
"', '",
",",
"(",
"array",
")",
"$",
"params",
"[",
"'is'",
"]",
")",
".",
"')'",
"]",
",",
"$",
"params",
")",
";",
"return",
"self",
"::",
"checkNotBlank",
"(",
"$",
"value",
",",
"$",
"params",
",",
"$",
"helper",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Check field exists based on the value of another field.
NB: Valitron's equals method checks against a field val, not a string, so 'in' is used for strings and arrays.
|
[
"Check",
"field",
"exists",
"based",
"on",
"the",
"value",
"of",
"another",
"field",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Validator/Validates.php#L219-L227
|
224,320
|
turtledesign/royalmail-php
|
src/Validator/Validates.php
|
Validates.checkPath
|
static function checkPath($path, $constraints, $helper) {
list($where, $path) = explode(':', $path);
if (empty($constraints)) $constraints = ['required' => TRUE];
foreach ($constraints as $con => $params) {
if ($con === 'required') $constraints['required'] = $path;
elseif ($con === 'in') $constraints['in'] = [[$path, $params]]; // !REM!: params for Valitron rule in indexed array.
else unset($constraints[$con]);
}
return self::is($helper[$where], $constraints);
}
|
php
|
static function checkPath($path, $constraints, $helper) {
list($where, $path) = explode(':', $path);
if (empty($constraints)) $constraints = ['required' => TRUE];
foreach ($constraints as $con => $params) {
if ($con === 'required') $constraints['required'] = $path;
elseif ($con === 'in') $constraints['in'] = [[$path, $params]]; // !REM!: params for Valitron rule in indexed array.
else unset($constraints[$con]);
}
return self::is($helper[$where], $constraints);
}
|
[
"static",
"function",
"checkPath",
"(",
"$",
"path",
",",
"$",
"constraints",
",",
"$",
"helper",
")",
"{",
"list",
"(",
"$",
"where",
",",
"$",
"path",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"path",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"constraints",
")",
")",
"$",
"constraints",
"=",
"[",
"'required'",
"=>",
"TRUE",
"]",
";",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"con",
"=>",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"'required'",
")",
"$",
"constraints",
"[",
"'required'",
"]",
"=",
"$",
"path",
";",
"elseif",
"(",
"$",
"con",
"===",
"'in'",
")",
"$",
"constraints",
"[",
"'in'",
"]",
"=",
"[",
"[",
"$",
"path",
",",
"$",
"params",
"]",
"]",
";",
"// !REM!: params for Valitron rule in indexed array.",
"else",
"unset",
"(",
"$",
"constraints",
"[",
"$",
"con",
"]",
")",
";",
"}",
"return",
"self",
"::",
"is",
"(",
"$",
"helper",
"[",
"$",
"where",
"]",
",",
"$",
"constraints",
")",
";",
"}"
] |
Build a Valitron ruleset from a given path and constraints.
@param string $path (input|output):dot.path.to.var.*.vars
@param array $constraints constraints and other settings, defaults to ['required' => TRUE] if empty
@param $helper ArrayObject data checks are run on.
@return Boolean True if rules validate, False otherwise.
|
[
"Build",
"a",
"Valitron",
"ruleset",
"from",
"a",
"given",
"path",
"and",
"constraints",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Validator/Validates.php#L262-L277
|
224,321
|
turtledesign/royalmail-php
|
src/Validator/Validates.php
|
Validates.fail
|
static function fail($value, $params, $defaults = []) {
$params = array_merge(['message' => 'value is invalid'], $defaults, $params);
$show_val = is_scalar($value) ? ' [' . $value . ']' : '';
throw new \RoyalMail\Exception\ValidatorException($params['message'] . $show_val);
}
|
php
|
static function fail($value, $params, $defaults = []) {
$params = array_merge(['message' => 'value is invalid'], $defaults, $params);
$show_val = is_scalar($value) ? ' [' . $value . ']' : '';
throw new \RoyalMail\Exception\ValidatorException($params['message'] . $show_val);
}
|
[
"static",
"function",
"fail",
"(",
"$",
"value",
",",
"$",
"params",
",",
"$",
"defaults",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"'message'",
"=>",
"'value is invalid'",
"]",
",",
"$",
"defaults",
",",
"$",
"params",
")",
";",
"$",
"show_val",
"=",
"is_scalar",
"(",
"$",
"value",
")",
"?",
"' ['",
".",
"$",
"value",
".",
"']'",
":",
"''",
";",
"throw",
"new",
"\\",
"RoyalMail",
"\\",
"Exception",
"\\",
"ValidatorException",
"(",
"$",
"params",
"[",
"'message'",
"]",
".",
"$",
"show_val",
")",
";",
"}"
] |
Handle failed validation constraint.
@param mixed $value
@param array $params
@param array $defaults
@throws \RoyalMail\Exception\ValidatorException
|
[
"Handle",
"failed",
"validation",
"constraint",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Validator/Validates.php#L308-L313
|
224,322
|
DevGroup-ru/yii2-multilingual
|
src/controllers/CountryLanguageManageController.php
|
CountryLanguageManageController.actionIndex
|
public function actionIndex()
{
$model = new CountryLanguage(['scenario' => 'search']);
$dataProvider = $model->search(Yii::$app->request->queryParams);
return $this->render(
'index',
[
'model' => $model,
'dataProvider' => $dataProvider,
]
);
}
|
php
|
public function actionIndex()
{
$model = new CountryLanguage(['scenario' => 'search']);
$dataProvider = $model->search(Yii::$app->request->queryParams);
return $this->render(
'index',
[
'model' => $model,
'dataProvider' => $dataProvider,
]
);
}
|
[
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"CountryLanguage",
"(",
"[",
"'scenario'",
"=>",
"'search'",
"]",
")",
";",
"$",
"dataProvider",
"=",
"$",
"model",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"]",
")",
";",
"}"
] |
Lists all CountryLanguage models.
@return mixed
|
[
"Lists",
"all",
"CountryLanguage",
"models",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/controllers/CountryLanguageManageController.php#L48-L59
|
224,323
|
DevGroup-ru/yii2-multilingual
|
src/controllers/CountryLanguageManageController.php
|
CountryLanguageManageController.actionEdit
|
public function actionEdit($id = null)
{
if ($id === null) {
$model = new CountryLanguage;
} else {
$model = $this->findModel($id);
}
$isLoaded = $model->load(Yii::$app->request->post());
$hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-country-language'))
|| (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-country-language'));
if ($isLoaded && !$hasAccess) {
throw new ForbiddenHttpException;
}
if ($isLoaded && $model->save()) {
return $this->redirect(['edit', 'id' => $model->id]);
} else {
return $this->render(
'edit',
[
'hasAccess' => $hasAccess,
'model' => $model,
]
);
}
}
|
php
|
public function actionEdit($id = null)
{
if ($id === null) {
$model = new CountryLanguage;
} else {
$model = $this->findModel($id);
}
$isLoaded = $model->load(Yii::$app->request->post());
$hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-country-language'))
|| (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-country-language'));
if ($isLoaded && !$hasAccess) {
throw new ForbiddenHttpException;
}
if ($isLoaded && $model->save()) {
return $this->redirect(['edit', 'id' => $model->id]);
} else {
return $this->render(
'edit',
[
'hasAccess' => $hasAccess,
'model' => $model,
]
);
}
}
|
[
"public",
"function",
"actionEdit",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"$",
"model",
"=",
"new",
"CountryLanguage",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"}",
"$",
"isLoaded",
"=",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
";",
"$",
"hasAccess",
"=",
"(",
"$",
"model",
"->",
"isNewRecord",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'multilingual-create-country-language'",
")",
")",
"||",
"(",
"!",
"$",
"model",
"->",
"isNewRecord",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'multilingual-edit-country-language'",
")",
")",
";",
"if",
"(",
"$",
"isLoaded",
"&&",
"!",
"$",
"hasAccess",
")",
"{",
"throw",
"new",
"ForbiddenHttpException",
";",
"}",
"if",
"(",
"$",
"isLoaded",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'edit'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'edit'",
",",
"[",
"'hasAccess'",
"=>",
"$",
"hasAccess",
",",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] |
Updates an existing CountryLanguage model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
|
[
"Updates",
"an",
"existing",
"CountryLanguage",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/controllers/CountryLanguageManageController.php#L67-L91
|
224,324
|
ericmann/sessionz
|
php/Handlers/EncryptionHandler.php
|
EncryptionHandler.write
|
public function write($id, $data, $next)
{
$return = empty( $data ) ? $data : $this->encrypt( $data );
return $next( $id, $return );
}
|
php
|
public function write($id, $data, $next)
{
$return = empty( $data ) ? $data : $this->encrypt( $data );
return $next( $id, $return );
}
|
[
"public",
"function",
"write",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"next",
")",
"{",
"$",
"return",
"=",
"empty",
"(",
"$",
"data",
")",
"?",
"$",
"data",
":",
"$",
"this",
"->",
"encrypt",
"(",
"$",
"data",
")",
";",
"return",
"$",
"next",
"(",
"$",
"id",
",",
"$",
"return",
")",
";",
"}"
] |
Encrypt the incoming data payload, then pass it along to the next handler
in the stack.
@param string $id ID of the session to write
@param string $data Data to be written
@param callable $next Callable to invoke the next layer in the stack
@return bool
|
[
"Encrypt",
"the",
"incoming",
"data",
"payload",
"then",
"pass",
"it",
"along",
"to",
"the",
"next",
"handler",
"in",
"the",
"stack",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Handlers/EncryptionHandler.php#L86-L90
|
224,325
|
JeffreyHyer/bamboohr
|
src/Api/Login.php
|
Login.login
|
public function login($username, $password, $appKey, $deviceId = "")
{
return $this->post("login", ['username' => $username, 'password' => $password, 'applicationKey' => $appKey, 'deviceId' => $deviceId]);
}
|
php
|
public function login($username, $password, $appKey, $deviceId = "")
{
return $this->post("login", ['username' => $username, 'password' => $password, 'applicationKey' => $appKey, 'deviceId' => $deviceId]);
}
|
[
"public",
"function",
"login",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"appKey",
",",
"$",
"deviceId",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"post",
"(",
"\"login\"",
",",
"[",
"'username'",
"=>",
"$",
"username",
",",
"'password'",
"=>",
"$",
"password",
",",
"'applicationKey'",
"=>",
"$",
"appKey",
",",
"'deviceId'",
"=>",
"$",
"deviceId",
"]",
")",
";",
"}"
] |
Login as a given user, identified by the provided username and password.
@param string $username Username
@param string $password Password
@param string $appKey Application Key
@param string $deviceId [Optional] A unique ID specific to a users device
@return \BambooHR\Api\Response
|
[
"Login",
"as",
"a",
"given",
"user",
"identified",
"by",
"the",
"provided",
"username",
"and",
"password",
"."
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/Login.php#L23-L26
|
224,326
|
DevGroup-ru/yii2-multilingual
|
src/behaviors/MultilingualActiveRecord.php
|
MultilingualActiveRecord.hasTranslation
|
public function hasTranslation($language_id = null, $checkIsPublished = true)
{
/** @var \DevGroup\Multilingual\Multilingual $multilingual */
$multilingual = Yii::$app->multilingual;
if ($language_id === null) {
$language_id = $multilingual->language_id;
}
/** @var ActiveRecord $owner */
$owner = $this->owner;
if ($language_id === $multilingual->language_id) {
// we were asked for default language
/** @var ActiveRecord $translation */
$translation = $owner->{$this->defaultTranslationRelation};
if ($translation === null) {
return false;
}
if ($checkIsPublished === true) {
return $this->checkIsPublished($translation);
}
}
/* @var ActiveRecord $translation */
foreach ($owner->{$this->translationRelation} as $translation) {
if ($translation->getAttribute('language_id') === $language_id) {
if ($checkIsPublished === true) {
return $this->checkIsPublished($translation);
} else {
return true;
}
}
}
return false;
}
|
php
|
public function hasTranslation($language_id = null, $checkIsPublished = true)
{
/** @var \DevGroup\Multilingual\Multilingual $multilingual */
$multilingual = Yii::$app->multilingual;
if ($language_id === null) {
$language_id = $multilingual->language_id;
}
/** @var ActiveRecord $owner */
$owner = $this->owner;
if ($language_id === $multilingual->language_id) {
// we were asked for default language
/** @var ActiveRecord $translation */
$translation = $owner->{$this->defaultTranslationRelation};
if ($translation === null) {
return false;
}
if ($checkIsPublished === true) {
return $this->checkIsPublished($translation);
}
}
/* @var ActiveRecord $translation */
foreach ($owner->{$this->translationRelation} as $translation) {
if ($translation->getAttribute('language_id') === $language_id) {
if ($checkIsPublished === true) {
return $this->checkIsPublished($translation);
} else {
return true;
}
}
}
return false;
}
|
[
"public",
"function",
"hasTranslation",
"(",
"$",
"language_id",
"=",
"null",
",",
"$",
"checkIsPublished",
"=",
"true",
")",
"{",
"/** @var \\DevGroup\\Multilingual\\Multilingual $multilingual */",
"$",
"multilingual",
"=",
"Yii",
"::",
"$",
"app",
"->",
"multilingual",
";",
"if",
"(",
"$",
"language_id",
"===",
"null",
")",
"{",
"$",
"language_id",
"=",
"$",
"multilingual",
"->",
"language_id",
";",
"}",
"/** @var ActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"if",
"(",
"$",
"language_id",
"===",
"$",
"multilingual",
"->",
"language_id",
")",
"{",
"// we were asked for default language",
"/** @var ActiveRecord $translation */",
"$",
"translation",
"=",
"$",
"owner",
"->",
"{",
"$",
"this",
"->",
"defaultTranslationRelation",
"}",
";",
"if",
"(",
"$",
"translation",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"checkIsPublished",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"checkIsPublished",
"(",
"$",
"translation",
")",
";",
"}",
"}",
"/* @var ActiveRecord $translation */",
"foreach",
"(",
"$",
"owner",
"->",
"{",
"$",
"this",
"->",
"translationRelation",
"}",
"as",
"$",
"translation",
")",
"{",
"if",
"(",
"$",
"translation",
"->",
"getAttribute",
"(",
"'language_id'",
")",
"===",
"$",
"language_id",
")",
"{",
"if",
"(",
"$",
"checkIsPublished",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"checkIsPublished",
"(",
"$",
"translation",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns a value indicating whether the translation model for the specified language exists.
@param string|null $language_id
@param bool $checkIsPublished Check if translation is published
@return boolean
|
[
"Returns",
"a",
"value",
"indicating",
"whether",
"the",
"translation",
"model",
"for",
"the",
"specified",
"language",
"exists",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/behaviors/MultilingualActiveRecord.php#L146-L180
|
224,327
|
DevGroup-ru/yii2-multilingual
|
src/behaviors/MultilingualActiveRecord.php
|
MultilingualActiveRecord.checkIsPublished
|
public function checkIsPublished(ActiveRecord $translationRecord)
{
if ($this->translationPublishedAttribute === false) {
return true;
}
return
$translationRecord->getAttribute($this->translationPublishedAttribute)
== $this->translationPublishedAttributeValue;
}
|
php
|
public function checkIsPublished(ActiveRecord $translationRecord)
{
if ($this->translationPublishedAttribute === false) {
return true;
}
return
$translationRecord->getAttribute($this->translationPublishedAttribute)
== $this->translationPublishedAttributeValue;
}
|
[
"public",
"function",
"checkIsPublished",
"(",
"ActiveRecord",
"$",
"translationRecord",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"translationPublishedAttribute",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"translationRecord",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"translationPublishedAttribute",
")",
"==",
"$",
"this",
"->",
"translationPublishedAttributeValue",
";",
"}"
] |
Performs a check of publish state for translation record
@param ActiveRecord $translationRecord
@return bool
|
[
"Performs",
"a",
"check",
"of",
"publish",
"state",
"for",
"translation",
"record"
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/behaviors/MultilingualActiveRecord.php#L187-L195
|
224,328
|
ericmann/sessionz
|
php/Objects/MemoryItem.php
|
MemoryItem.is_valid
|
public function is_valid($lifetime = null, $now = null)
{
if (null === $now) $now = time();
if (null === $lifetime) $lifetime = ini_get('session.gc_maxlifetime');
return (int) $now - $this->_time < (int) $lifetime;
}
|
php
|
public function is_valid($lifetime = null, $now = null)
{
if (null === $now) $now = time();
if (null === $lifetime) $lifetime = ini_get('session.gc_maxlifetime');
return (int) $now - $this->_time < (int) $lifetime;
}
|
[
"public",
"function",
"is_valid",
"(",
"$",
"lifetime",
"=",
"null",
",",
"$",
"now",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"now",
")",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"lifetime",
")",
"$",
"lifetime",
"=",
"ini_get",
"(",
"'session.gc_maxlifetime'",
")",
";",
"return",
"(",
"int",
")",
"$",
"now",
"-",
"$",
"this",
"->",
"_time",
"<",
"(",
"int",
")",
"$",
"lifetime",
";",
"}"
] |
Test whether an item is still valid
@param int [$lifetime]
@param int [$now]
@return bool
|
[
"Test",
"whether",
"an",
"item",
"is",
"still",
"valid"
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Objects/MemoryItem.php#L73-L79
|
224,329
|
eloquent/equality
|
src/Comparator.php
|
Comparator.arrayEquals
|
protected function arrayEquals(array $left, $right)
{
if (!is_array($right)) {
return false;
}
if (array_keys($left) !== array_keys($right)) {
return false;
}
foreach ($left as $key => $value) {
if (!$this->valueEquals($value, $right[$key])) {
return false;
}
}
return true;
}
|
php
|
protected function arrayEquals(array $left, $right)
{
if (!is_array($right)) {
return false;
}
if (array_keys($left) !== array_keys($right)) {
return false;
}
foreach ($left as $key => $value) {
if (!$this->valueEquals($value, $right[$key])) {
return false;
}
}
return true;
}
|
[
"protected",
"function",
"arrayEquals",
"(",
"array",
"$",
"left",
",",
"$",
"right",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_keys",
"(",
"$",
"left",
")",
"!==",
"array_keys",
"(",
"$",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"left",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valueEquals",
"(",
"$",
"value",
",",
"$",
"right",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Compare an array to another arbitrary value.
@param array $left The left value.
@param mixed $right The right value.
@return boolean True if the values are deeply equal.
|
[
"Compare",
"an",
"array",
"to",
"another",
"arbitrary",
"value",
"."
] |
5af459d2e06e97bbec51c750c691bd2f9d4256cc
|
https://github.com/eloquent/equality/blob/5af459d2e06e97bbec51c750c691bd2f9d4256cc/src/Comparator.php#L92-L108
|
224,330
|
eloquent/equality
|
src/Comparator.php
|
Comparator.objectEquals
|
protected function objectEquals($left, $right)
{
if (!is_object($right)) {
return false;
}
if (get_class($left) !== get_class($right)) {
return false;
}
$stackKey = $this->objectComparisonStackKey($left, $right);
if (array_key_exists($stackKey, $this->objectComparisonStack)) {
return true;
}
$this->objectComparisonStack[$stackKey] = true;
return $this->arrayEquals(
$this->objectProperties($left),
$this->objectProperties($right)
);
}
|
php
|
protected function objectEquals($left, $right)
{
if (!is_object($right)) {
return false;
}
if (get_class($left) !== get_class($right)) {
return false;
}
$stackKey = $this->objectComparisonStackKey($left, $right);
if (array_key_exists($stackKey, $this->objectComparisonStack)) {
return true;
}
$this->objectComparisonStack[$stackKey] = true;
return $this->arrayEquals(
$this->objectProperties($left),
$this->objectProperties($right)
);
}
|
[
"protected",
"function",
"objectEquals",
"(",
"$",
"left",
",",
"$",
"right",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"left",
")",
"!==",
"get_class",
"(",
"$",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"stackKey",
"=",
"$",
"this",
"->",
"objectComparisonStackKey",
"(",
"$",
"left",
",",
"$",
"right",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"stackKey",
",",
"$",
"this",
"->",
"objectComparisonStack",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"objectComparisonStack",
"[",
"$",
"stackKey",
"]",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"arrayEquals",
"(",
"$",
"this",
"->",
"objectProperties",
"(",
"$",
"left",
")",
",",
"$",
"this",
"->",
"objectProperties",
"(",
"$",
"right",
")",
")",
";",
"}"
] |
Compare an object to another arbitrary value.
@param object $left The left value.
@param mixed $right The right value.
@return boolean True if the values are deeply equal.
|
[
"Compare",
"an",
"object",
"to",
"another",
"arbitrary",
"value",
"."
] |
5af459d2e06e97bbec51c750c691bd2f9d4256cc
|
https://github.com/eloquent/equality/blob/5af459d2e06e97bbec51c750c691bd2f9d4256cc/src/Comparator.php#L118-L137
|
224,331
|
eloquent/equality
|
src/Comparator.php
|
Comparator.objectProperties
|
protected function objectProperties($object)
{
$properties = array();
$reflector = new ReflectionObject($object);
while ($reflector) {
foreach ($reflector->getProperties() as $property) {
if ($property->isStatic()) {
continue;
}
$key = sprintf(
'%s::%s',
$property->getDeclaringClass()->getName(),
$property->getName()
);
$property->setAccessible(true);
$properties[$key] = $property->getValue($object);
}
$reflector = $reflector->getParentClass();
}
return $properties;
}
|
php
|
protected function objectProperties($object)
{
$properties = array();
$reflector = new ReflectionObject($object);
while ($reflector) {
foreach ($reflector->getProperties() as $property) {
if ($property->isStatic()) {
continue;
}
$key = sprintf(
'%s::%s',
$property->getDeclaringClass()->getName(),
$property->getName()
);
$property->setAccessible(true);
$properties[$key] = $property->getValue($object);
}
$reflector = $reflector->getParentClass();
}
return $properties;
}
|
[
"protected",
"function",
"objectProperties",
"(",
"$",
"object",
")",
"{",
"$",
"properties",
"=",
"array",
"(",
")",
";",
"$",
"reflector",
"=",
"new",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"while",
"(",
"$",
"reflector",
")",
"{",
"foreach",
"(",
"$",
"reflector",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"isStatic",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"key",
"=",
"sprintf",
"(",
"'%s::%s'",
",",
"$",
"property",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"properties",
"[",
"$",
"key",
"]",
"=",
"$",
"property",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"}",
"$",
"reflector",
"=",
"$",
"reflector",
"->",
"getParentClass",
"(",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] |
Get the properties of the supplied object, including protected and
private values.
@param object $object The object to inspect.
@return array<string,mixed> The object's properties.
|
[
"Get",
"the",
"properties",
"of",
"the",
"supplied",
"object",
"including",
"protected",
"and",
"private",
"values",
"."
] |
5af459d2e06e97bbec51c750c691bd2f9d4256cc
|
https://github.com/eloquent/equality/blob/5af459d2e06e97bbec51c750c691bd2f9d4256cc/src/Comparator.php#L147-L172
|
224,332
|
eloquent/equality
|
src/Comparator.php
|
Comparator.objectComparisonStackKey
|
protected function objectComparisonStackKey($left, $right)
{
$ids = array(
spl_object_hash($left),
spl_object_hash($right)
);
sort($ids);
return implode('.', $ids);
}
|
php
|
protected function objectComparisonStackKey($left, $right)
{
$ids = array(
spl_object_hash($left),
spl_object_hash($right)
);
sort($ids);
return implode('.', $ids);
}
|
[
"protected",
"function",
"objectComparisonStackKey",
"(",
"$",
"left",
",",
"$",
"right",
")",
"{",
"$",
"ids",
"=",
"array",
"(",
"spl_object_hash",
"(",
"$",
"left",
")",
",",
"spl_object_hash",
"(",
"$",
"right",
")",
")",
";",
"sort",
"(",
"$",
"ids",
")",
";",
"return",
"implode",
"(",
"'.'",
",",
"$",
"ids",
")",
";",
"}"
] |
Return a unique key for the current comparison, which can be used to
avoid recursion issues.
@param object $left The left value.
@param object $right The right value.
@return string The unique comparison key.
|
[
"Return",
"a",
"unique",
"key",
"for",
"the",
"current",
"comparison",
"which",
"can",
"be",
"used",
"to",
"avoid",
"recursion",
"issues",
"."
] |
5af459d2e06e97bbec51c750c691bd2f9d4256cc
|
https://github.com/eloquent/equality/blob/5af459d2e06e97bbec51c750c691bd2f9d4256cc/src/Comparator.php#L183-L192
|
224,333
|
jasny/audio
|
src/Jasny/Audio/Track.php
|
Track.getStats
|
public function getStats()
{
if (isset($this->stats)) return $this->stats;
$stats = array();
$stats['channels'] = '1';
foreach (explode("\n", $this->sox('-n', 'stats')) as $line) {
if (empty($line) || preg_match('/^\S+ WARN/', $line)) continue;
if ($line[0] == ' ') {
$stats['channels'] = (string)count(preg_split('/\s+/', trim($line))) - 1;
continue;
}
list($key, $value) = preg_split('/\s{2,}/', $line) + array(1=>null);
if (!isset($value)) continue;
$key = strtolower(preg_replace(array('/\s(s|dB)$/', '/\W+/'), array('', '_'), $key));
$value = preg_replace('/\s.*$/', '', $value);
$stats[$key] = $value;
}
foreach (explode("\n", $this->sox('-n', 'stat')) as $line) {
if (preg_match('/^\S+ WARN/', $line)) continue;
list($key, $value) = explode(':', $line) + array(1=>null);
if (!isset($value)) continue;
if ($key == 'Samples read') $key = 'samples';
elseif ($key == 'Length (seconds)') $key = 'length';
else $key = strtolower(preg_replace('/\s+/', '_', $key));
$stats[$key] = trim($value);
}
unset($stats['num_samples']);
$stats['sample_rate'] = (string)round(($stats['samples'] / $stats['channels']) / $stats['length']);
$this->stats = (object)$stats;
return $this->stats;
}
|
php
|
public function getStats()
{
if (isset($this->stats)) return $this->stats;
$stats = array();
$stats['channels'] = '1';
foreach (explode("\n", $this->sox('-n', 'stats')) as $line) {
if (empty($line) || preg_match('/^\S+ WARN/', $line)) continue;
if ($line[0] == ' ') {
$stats['channels'] = (string)count(preg_split('/\s+/', trim($line))) - 1;
continue;
}
list($key, $value) = preg_split('/\s{2,}/', $line) + array(1=>null);
if (!isset($value)) continue;
$key = strtolower(preg_replace(array('/\s(s|dB)$/', '/\W+/'), array('', '_'), $key));
$value = preg_replace('/\s.*$/', '', $value);
$stats[$key] = $value;
}
foreach (explode("\n", $this->sox('-n', 'stat')) as $line) {
if (preg_match('/^\S+ WARN/', $line)) continue;
list($key, $value) = explode(':', $line) + array(1=>null);
if (!isset($value)) continue;
if ($key == 'Samples read') $key = 'samples';
elseif ($key == 'Length (seconds)') $key = 'length';
else $key = strtolower(preg_replace('/\s+/', '_', $key));
$stats[$key] = trim($value);
}
unset($stats['num_samples']);
$stats['sample_rate'] = (string)round(($stats['samples'] / $stats['channels']) / $stats['length']);
$this->stats = (object)$stats;
return $this->stats;
}
|
[
"public",
"function",
"getStats",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"stats",
")",
")",
"return",
"$",
"this",
"->",
"stats",
";",
"$",
"stats",
"=",
"array",
"(",
")",
";",
"$",
"stats",
"[",
"'channels'",
"]",
"=",
"'1'",
";",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"sox",
"(",
"'-n'",
",",
"'stats'",
")",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"line",
")",
"||",
"preg_match",
"(",
"'/^\\S+ WARN/'",
",",
"$",
"line",
")",
")",
"continue",
";",
"if",
"(",
"$",
"line",
"[",
"0",
"]",
"==",
"' '",
")",
"{",
"$",
"stats",
"[",
"'channels'",
"]",
"=",
"(",
"string",
")",
"count",
"(",
"preg_split",
"(",
"'/\\s+/'",
",",
"trim",
"(",
"$",
"line",
")",
")",
")",
"-",
"1",
";",
"continue",
";",
"}",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"preg_split",
"(",
"'/\\s{2,}/'",
",",
"$",
"line",
")",
"+",
"array",
"(",
"1",
"=>",
"null",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"continue",
";",
"$",
"key",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"array",
"(",
"'/\\s(s|dB)$/'",
",",
"'/\\W+/'",
")",
",",
"array",
"(",
"''",
",",
"'_'",
")",
",",
"$",
"key",
")",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/\\s.*$/'",
",",
"''",
",",
"$",
"value",
")",
";",
"$",
"stats",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"sox",
"(",
"'-n'",
",",
"'stat'",
")",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\S+ WARN/'",
",",
"$",
"line",
")",
")",
"continue",
";",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"line",
")",
"+",
"array",
"(",
"1",
"=>",
"null",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"continue",
";",
"if",
"(",
"$",
"key",
"==",
"'Samples read'",
")",
"$",
"key",
"=",
"'samples'",
";",
"elseif",
"(",
"$",
"key",
"==",
"'Length (seconds)'",
")",
"$",
"key",
"=",
"'length'",
";",
"else",
"$",
"key",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"'/\\s+/'",
",",
"'_'",
",",
"$",
"key",
")",
")",
";",
"$",
"stats",
"[",
"$",
"key",
"]",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"}",
"unset",
"(",
"$",
"stats",
"[",
"'num_samples'",
"]",
")",
";",
"$",
"stats",
"[",
"'sample_rate'",
"]",
"=",
"(",
"string",
")",
"round",
"(",
"(",
"$",
"stats",
"[",
"'samples'",
"]",
"/",
"$",
"stats",
"[",
"'channels'",
"]",
")",
"/",
"$",
"stats",
"[",
"'length'",
"]",
")",
";",
"$",
"this",
"->",
"stats",
"=",
"(",
"object",
")",
"$",
"stats",
";",
"return",
"$",
"this",
"->",
"stats",
";",
"}"
] |
Get statistics of the audio file
@return array
|
[
"Get",
"statistics",
"of",
"the",
"audio",
"file"
] |
5c8bcb93ab4243c79971342f4a414747c716fedf
|
https://github.com/jasny/audio/blob/5c8bcb93ab4243c79971342f4a414747c716fedf/src/Jasny/Audio/Track.php#L84-L125
|
224,334
|
jasny/audio
|
src/Jasny/Audio/Track.php
|
Track.getStat
|
private function getStat($stat, $soxi_arg, $cast)
{
if (!isset($this->$stat)) {
$this->$stat = isset($this->stats) ?
(float)$this->stats->$stat :
(float)$this->soxi($soxi_arg);
settype($this->$stat, $cast);
}
return $this->$stat;
}
|
php
|
private function getStat($stat, $soxi_arg, $cast)
{
if (!isset($this->$stat)) {
$this->$stat = isset($this->stats) ?
(float)$this->stats->$stat :
(float)$this->soxi($soxi_arg);
settype($this->$stat, $cast);
}
return $this->$stat;
}
|
[
"private",
"function",
"getStat",
"(",
"$",
"stat",
",",
"$",
"soxi_arg",
",",
"$",
"cast",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"$",
"stat",
")",
")",
"{",
"$",
"this",
"->",
"$",
"stat",
"=",
"isset",
"(",
"$",
"this",
"->",
"stats",
")",
"?",
"(",
"float",
")",
"$",
"this",
"->",
"stats",
"->",
"$",
"stat",
":",
"(",
"float",
")",
"$",
"this",
"->",
"soxi",
"(",
"$",
"soxi_arg",
")",
";",
"settype",
"(",
"$",
"this",
"->",
"$",
"stat",
",",
"$",
"cast",
")",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"stat",
";",
"}"
] |
Get the a stat of the track
@param string $stat
@param string $soxi_arg
@param string $cast
@return mixed
|
[
"Get",
"the",
"a",
"stat",
"of",
"the",
"track"
] |
5c8bcb93ab4243c79971342f4a414747c716fedf
|
https://github.com/jasny/audio/blob/5c8bcb93ab4243c79971342f4a414747c716fedf/src/Jasny/Audio/Track.php#L135-L146
|
224,335
|
jasny/audio
|
src/Jasny/Audio/Track.php
|
Track.combine
|
public function combine($method, $in, $out)
{
if ($in instanceof self) $in = $in->filename;
$this->sox('--combine', $method, $in, $out);
return new static($out);
}
|
php
|
public function combine($method, $in, $out)
{
if ($in instanceof self) $in = $in->filename;
$this->sox('--combine', $method, $in, $out);
return new static($out);
}
|
[
"public",
"function",
"combine",
"(",
"$",
"method",
",",
"$",
"in",
",",
"$",
"out",
")",
"{",
"if",
"(",
"$",
"in",
"instanceof",
"self",
")",
"$",
"in",
"=",
"$",
"in",
"->",
"filename",
";",
"$",
"this",
"->",
"sox",
"(",
"'--combine'",
",",
"$",
"method",
",",
"$",
"in",
",",
"$",
"out",
")",
";",
"return",
"new",
"static",
"(",
"$",
"out",
")",
";",
"}"
] |
Combine two audio files
@param string $method 'concatenate', 'merge', 'mix', 'mix-power', 'multiply', 'sequence'
@param string|Track $in File to mix with
@param string $out New filename
@return Track
|
[
"Combine",
"two",
"audio",
"files"
] |
5c8bcb93ab4243c79971342f4a414747c716fedf
|
https://github.com/jasny/audio/blob/5c8bcb93ab4243c79971342f4a414747c716fedf/src/Jasny/Audio/Track.php#L247-L253
|
224,336
|
jasny/audio
|
src/Jasny/Audio/Track.php
|
Track.sox
|
public function sox()
{
$args = func_get_args();
array_unshift($args, $this->filename);
return self::exec('sox', $args);
}
|
php
|
public function sox()
{
$args = func_get_args();
array_unshift($args, $this->filename);
return self::exec('sox', $args);
}
|
[
"public",
"function",
"sox",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
"->",
"filename",
")",
";",
"return",
"self",
"::",
"exec",
"(",
"'sox'",
",",
"$",
"args",
")",
";",
"}"
] |
Execute sox.
Each argument will be used in the command.
@return string
|
[
"Execute",
"sox",
".",
"Each",
"argument",
"will",
"be",
"used",
"in",
"the",
"command",
"."
] |
5c8bcb93ab4243c79971342f4a414747c716fedf
|
https://github.com/jasny/audio/blob/5c8bcb93ab4243c79971342f4a414747c716fedf/src/Jasny/Audio/Track.php#L262-L268
|
224,337
|
appkr/api
|
src/example/BookTransformer.php
|
BookTransformer.includeAuthor
|
public function includeAuthor(Book $book, ParamBag $paramBag = null)
{
return $this->item($book->author, new AuthorTransformer($paramBag));
}
|
php
|
public function includeAuthor(Book $book, ParamBag $paramBag = null)
{
return $this->item($book->author, new AuthorTransformer($paramBag));
}
|
[
"public",
"function",
"includeAuthor",
"(",
"Book",
"$",
"book",
",",
"ParamBag",
"$",
"paramBag",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"book",
"->",
"author",
",",
"new",
"AuthorTransformer",
"(",
"$",
"paramBag",
")",
")",
";",
"}"
] |
Include Author.
@param \Appkr\Api\Example\Book $book
@param \League\Fractal\ParamBag $paramBag
@return \League\Fractal\Resource\Item
|
[
"Include",
"Author",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/example/BookTransformer.php#L76-L79
|
224,338
|
appkr/api
|
src/TransformerAbstract.php
|
TransformerAbstract.buildPayload
|
public function buildPayload(array $payload)
{
if ($visible = $this->getVisible()) {
$payload = array_only($payload, $visible);
}
if ($hidden = $this->getHidden()) {
$payload = array_except($payload, $hidden);
}
return $payload;
}
|
php
|
public function buildPayload(array $payload)
{
if ($visible = $this->getVisible()) {
$payload = array_only($payload, $visible);
}
if ($hidden = $this->getHidden()) {
$payload = array_except($payload, $hidden);
}
return $payload;
}
|
[
"public",
"function",
"buildPayload",
"(",
"array",
"$",
"payload",
")",
"{",
"if",
"(",
"$",
"visible",
"=",
"$",
"this",
"->",
"getVisible",
"(",
")",
")",
"{",
"$",
"payload",
"=",
"array_only",
"(",
"$",
"payload",
",",
"$",
"visible",
")",
";",
"}",
"if",
"(",
"$",
"hidden",
"=",
"$",
"this",
"->",
"getHidden",
"(",
")",
")",
"{",
"$",
"payload",
"=",
"array_except",
"(",
"$",
"payload",
",",
"$",
"hidden",
")",
";",
"}",
"return",
"$",
"payload",
";",
"}"
] |
Filter fields to respond.
@param array $payload
@return array
|
[
"Filter",
"fields",
"to",
"respond",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/TransformerAbstract.php#L224-L235
|
224,339
|
appkr/api
|
src/TransformerAbstract.php
|
TransformerAbstract.setProperties
|
protected function setProperties()
{
// Fetch request query string values passed by an API client.
list($limit, $offset) = $this->paramBag->get('limit');
list($sortKey, $sortDirection) = $this->paramBag->get('sort');
// If nothing is passed by API client,
// falling back to class property's value.
$this->limit = $limit ?: $this->limit;
$this->offset = $offset ?: $this->offset;
$this->sortKey = $sortKey ?: $this->sortKey;
$this->sortDirection = $sortDirection ?: $this->sortDirection;
}
|
php
|
protected function setProperties()
{
// Fetch request query string values passed by an API client.
list($limit, $offset) = $this->paramBag->get('limit');
list($sortKey, $sortDirection) = $this->paramBag->get('sort');
// If nothing is passed by API client,
// falling back to class property's value.
$this->limit = $limit ?: $this->limit;
$this->offset = $offset ?: $this->offset;
$this->sortKey = $sortKey ?: $this->sortKey;
$this->sortDirection = $sortDirection ?: $this->sortDirection;
}
|
[
"protected",
"function",
"setProperties",
"(",
")",
"{",
"// Fetch request query string values passed by an API client.",
"list",
"(",
"$",
"limit",
",",
"$",
"offset",
")",
"=",
"$",
"this",
"->",
"paramBag",
"->",
"get",
"(",
"'limit'",
")",
";",
"list",
"(",
"$",
"sortKey",
",",
"$",
"sortDirection",
")",
"=",
"$",
"this",
"->",
"paramBag",
"->",
"get",
"(",
"'sort'",
")",
";",
"// If nothing is passed by API client,",
"// falling back to class property's value.",
"$",
"this",
"->",
"limit",
"=",
"$",
"limit",
"?",
":",
"$",
"this",
"->",
"limit",
";",
"$",
"this",
"->",
"offset",
"=",
"$",
"offset",
"?",
":",
"$",
"this",
"->",
"offset",
";",
"$",
"this",
"->",
"sortKey",
"=",
"$",
"sortKey",
"?",
":",
"$",
"this",
"->",
"sortKey",
";",
"$",
"this",
"->",
"sortDirection",
"=",
"$",
"sortDirection",
"?",
":",
"$",
"this",
"->",
"sortDirection",
";",
"}"
] |
Set class properties by request query string.
|
[
"Set",
"class",
"properties",
"by",
"request",
"query",
"string",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/TransformerAbstract.php#L240-L252
|
224,340
|
appkr/api
|
src/TransformerAbstract.php
|
TransformerAbstract.validateIncludeParams
|
protected function validateIncludeParams()
{
$validParams = array_keys($this->config['include']['params']);
$usedParams = array_keys(iterator_to_array($this->paramBag));
if ($invalidParams = array_diff($usedParams, $validParams)) {
// This validates query string KEY passed by an API client.
throw new UnexpectedIncludesParamException(
sprintf(
'Used param(s): "%s". Valid param(s): "%s"',
implode(',', $usedParams),
implode(',', $validParams)
)
);
}
$errors = [];
if ($limit = $this->paramBag->get('limit')) {
if (count($limit) !== 2) {
array_push(
$errors,
'Invalid "limit" value. Valid usage: limit(int|int) where the first int is number of items to retrieve and the second is offset to skip over.'
);
}
foreach($limit as $item) {
if (! is_numeric($item)) {
array_push(
$errors,
'Invalid "limit" value. Expecting: integer. Given: ' . gettype($item) . " \"{$item}\"."
);
}
}
}
if ($sort = $this->paramBag->get('sort')) {
if (count($sort) !== 2) {
array_push(
$errors,
'Invalid "sort" value. Valid usage: sort(string|string) where the first string is attribute name to order by and the second is the sort direction(asc or desc)'
);
}
$allowedSortDirection = ['asc', 'desc'];
if (isset($sort[1]) && ! in_array(strtolower($sort[1]), $allowedSortDirection)) {
array_push(
$errors,
'Invalid "sort" value. Allowed: ' . implode(',', $allowedSortDirection) . ". Given: \"{$sort[1]}\""
);
}
}
if (! empty($errors)) {
throw new UnexpectedIncludesParamException(implode(PHP_EOL, $errors));
}
return true;
}
|
php
|
protected function validateIncludeParams()
{
$validParams = array_keys($this->config['include']['params']);
$usedParams = array_keys(iterator_to_array($this->paramBag));
if ($invalidParams = array_diff($usedParams, $validParams)) {
// This validates query string KEY passed by an API client.
throw new UnexpectedIncludesParamException(
sprintf(
'Used param(s): "%s". Valid param(s): "%s"',
implode(',', $usedParams),
implode(',', $validParams)
)
);
}
$errors = [];
if ($limit = $this->paramBag->get('limit')) {
if (count($limit) !== 2) {
array_push(
$errors,
'Invalid "limit" value. Valid usage: limit(int|int) where the first int is number of items to retrieve and the second is offset to skip over.'
);
}
foreach($limit as $item) {
if (! is_numeric($item)) {
array_push(
$errors,
'Invalid "limit" value. Expecting: integer. Given: ' . gettype($item) . " \"{$item}\"."
);
}
}
}
if ($sort = $this->paramBag->get('sort')) {
if (count($sort) !== 2) {
array_push(
$errors,
'Invalid "sort" value. Valid usage: sort(string|string) where the first string is attribute name to order by and the second is the sort direction(asc or desc)'
);
}
$allowedSortDirection = ['asc', 'desc'];
if (isset($sort[1]) && ! in_array(strtolower($sort[1]), $allowedSortDirection)) {
array_push(
$errors,
'Invalid "sort" value. Allowed: ' . implode(',', $allowedSortDirection) . ". Given: \"{$sort[1]}\""
);
}
}
if (! empty($errors)) {
throw new UnexpectedIncludesParamException(implode(PHP_EOL, $errors));
}
return true;
}
|
[
"protected",
"function",
"validateIncludeParams",
"(",
")",
"{",
"$",
"validParams",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"config",
"[",
"'include'",
"]",
"[",
"'params'",
"]",
")",
";",
"$",
"usedParams",
"=",
"array_keys",
"(",
"iterator_to_array",
"(",
"$",
"this",
"->",
"paramBag",
")",
")",
";",
"if",
"(",
"$",
"invalidParams",
"=",
"array_diff",
"(",
"$",
"usedParams",
",",
"$",
"validParams",
")",
")",
"{",
"// This validates query string KEY passed by an API client.",
"throw",
"new",
"UnexpectedIncludesParamException",
"(",
"sprintf",
"(",
"'Used param(s): \"%s\". Valid param(s): \"%s\"'",
",",
"implode",
"(",
"','",
",",
"$",
"usedParams",
")",
",",
"implode",
"(",
"','",
",",
"$",
"validParams",
")",
")",
")",
";",
"}",
"$",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"limit",
"=",
"$",
"this",
"->",
"paramBag",
"->",
"get",
"(",
"'limit'",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"limit",
")",
"!==",
"2",
")",
"{",
"array_push",
"(",
"$",
"errors",
",",
"'Invalid \"limit\" value. Valid usage: limit(int|int) where the first int is number of items to retrieve and the second is offset to skip over.'",
")",
";",
"}",
"foreach",
"(",
"$",
"limit",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"item",
")",
")",
"{",
"array_push",
"(",
"$",
"errors",
",",
"'Invalid \"limit\" value. Expecting: integer. Given: '",
".",
"gettype",
"(",
"$",
"item",
")",
".",
"\" \\\"{$item}\\\".\"",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"sort",
"=",
"$",
"this",
"->",
"paramBag",
"->",
"get",
"(",
"'sort'",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"sort",
")",
"!==",
"2",
")",
"{",
"array_push",
"(",
"$",
"errors",
",",
"'Invalid \"sort\" value. Valid usage: sort(string|string) where the first string is attribute name to order by and the second is the sort direction(asc or desc)'",
")",
";",
"}",
"$",
"allowedSortDirection",
"=",
"[",
"'asc'",
",",
"'desc'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"sort",
"[",
"1",
"]",
")",
"&&",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"sort",
"[",
"1",
"]",
")",
",",
"$",
"allowedSortDirection",
")",
")",
"{",
"array_push",
"(",
"$",
"errors",
",",
"'Invalid \"sort\" value. Allowed: '",
".",
"implode",
"(",
"','",
",",
"$",
"allowedSortDirection",
")",
".",
"\". Given: \\\"{$sort[1]}\\\"\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"throw",
"new",
"UnexpectedIncludesParamException",
"(",
"implode",
"(",
"PHP_EOL",
",",
"$",
"errors",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Validate include params.
We already define the white lists in the config.
@return bool
@throws UnexpectedIncludesParamException
|
[
"Validate",
"include",
"params",
".",
"We",
"already",
"define",
"the",
"white",
"lists",
"in",
"the",
"config",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/TransformerAbstract.php#L261-L320
|
224,341
|
appkr/api
|
src/Transformers/SimpleArrayTransformer.php
|
SimpleArrayTransformer.transform
|
public function transform($model)
{
if (is_array($model)) {
return $model;
}
if ($model instanceof Collection) {
return $model->toArray();
}
if ($model instanceof JsonSerializable) {
return $model->jsonSerialize();
}
if ($model instanceof \stdClass) {
return (array) $model;
}
throw new \Exception(
'Expecting an instance of \Illuminate\Support\Collection, '
. get_class($model)
. ' given.'
);
}
|
php
|
public function transform($model)
{
if (is_array($model)) {
return $model;
}
if ($model instanceof Collection) {
return $model->toArray();
}
if ($model instanceof JsonSerializable) {
return $model->jsonSerialize();
}
if ($model instanceof \stdClass) {
return (array) $model;
}
throw new \Exception(
'Expecting an instance of \Illuminate\Support\Collection, '
. get_class($model)
. ' given.'
);
}
|
[
"public",
"function",
"transform",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"model",
")",
")",
"{",
"return",
"$",
"model",
";",
"}",
"if",
"(",
"$",
"model",
"instanceof",
"Collection",
")",
"{",
"return",
"$",
"model",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"$",
"model",
"instanceof",
"JsonSerializable",
")",
"{",
"return",
"$",
"model",
"->",
"jsonSerialize",
"(",
")",
";",
"}",
"if",
"(",
"$",
"model",
"instanceof",
"\\",
"stdClass",
")",
"{",
"return",
"(",
"array",
")",
"$",
"model",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Expecting an instance of \\Illuminate\\Support\\Collection, '",
".",
"get_class",
"(",
"$",
"model",
")",
".",
"' given.'",
")",
";",
"}"
] |
Transform single resource
@param Collection|array $model
@return array
@throws \Exception
|
[
"Transform",
"single",
"resource"
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/Transformers/SimpleArrayTransformer.php#L18-L41
|
224,342
|
JeffreyHyer/bamboohr
|
src/Api/Photos.php
|
Photos.getPhotoUrl
|
public function getPhotoUrl(string $email, bool $secure = true)
{
$hash = md5(strtolower(trim($email)));
$url = ($secure ? "https://" : "http://");
$url .= "{$this->bamboo->domain}.bamboohr.com/employees/photos/?h={$hash}";
return $url;
}
|
php
|
public function getPhotoUrl(string $email, bool $secure = true)
{
$hash = md5(strtolower(trim($email)));
$url = ($secure ? "https://" : "http://");
$url .= "{$this->bamboo->domain}.bamboohr.com/employees/photos/?h={$hash}";
return $url;
}
|
[
"public",
"function",
"getPhotoUrl",
"(",
"string",
"$",
"email",
",",
"bool",
"$",
"secure",
"=",
"true",
")",
"{",
"$",
"hash",
"=",
"md5",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"email",
")",
")",
")",
";",
"$",
"url",
"=",
"(",
"$",
"secure",
"?",
"\"https://\"",
":",
"\"http://\"",
")",
";",
"$",
"url",
".=",
"\"{$this->bamboo->domain}.bamboohr.com/employees/photos/?h={$hash}\"",
";",
"return",
"$",
"url",
";",
"}"
] |
Get the URL of an employee's photo
This works similar to Gravatar where the URL scheme is known
so no API call is made to the BambooHR service when using this
method.
NOTES:
- Returns the URL to a JPEG image that is 150px square
- If an image does not exist for the given employee it
will return customized placeholder image (e.g. employees
initials on a solid background)
@param string $email The email address of the employee
@param bool $secure Return a secure URL (HTTPS)
@return string
|
[
"Get",
"the",
"URL",
"of",
"an",
"employee",
"s",
"photo"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/Photos.php#L63-L71
|
224,343
|
JeffreyHyer/bamboohr
|
src/Api/Metadata.php
|
Metadata.addEditList
|
public function addEditList($listId, array $options)
{
$xml = "<options>";
foreach ($options as $option) {
$xml .= "<option";
if (isset($option['id'])) {
$xml .= " id=\"{$option['id']}\"";
}
if (isset($option['archived'])) {
$xml .= " archived=\"{$option['archived']}\"";
}
$xml .= ">{$option['value']}</option>";
}
$xml .= "</options>";
return $this->put("meta/lists/{$listId}", $xml);
}
|
php
|
public function addEditList($listId, array $options)
{
$xml = "<options>";
foreach ($options as $option) {
$xml .= "<option";
if (isset($option['id'])) {
$xml .= " id=\"{$option['id']}\"";
}
if (isset($option['archived'])) {
$xml .= " archived=\"{$option['archived']}\"";
}
$xml .= ">{$option['value']}</option>";
}
$xml .= "</options>";
return $this->put("meta/lists/{$listId}", $xml);
}
|
[
"public",
"function",
"addEditList",
"(",
"$",
"listId",
",",
"array",
"$",
"options",
")",
"{",
"$",
"xml",
"=",
"\"<options>\"",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"xml",
".=",
"\"<option\"",
";",
"if",
"(",
"isset",
"(",
"$",
"option",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\" id=\\\"{$option['id']}\\\"\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"option",
"[",
"'archived'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\" archived=\\\"{$option['archived']}\\\"\"",
";",
"}",
"$",
"xml",
".=",
"\">{$option['value']}</option>\"",
";",
"}",
"$",
"xml",
".=",
"\"</options>\"",
";",
"return",
"$",
"this",
"->",
"put",
"(",
"\"meta/lists/{$listId}\"",
",",
"$",
"xml",
")",
";",
"}"
] |
Add or update values for "list" fields
@param string $listId
@param array $options [['id' => string (optional), 'archived' => 'yes|no' (optional), 'value' => string (required)], ...]
@return BambooHR\Api\Response
|
[
"Add",
"or",
"update",
"values",
"for",
"list",
"fields"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/Metadata.php#L51-L72
|
224,344
|
DevGroup-ru/yii2-multilingual
|
src/controllers/ContextManageController.php
|
ContextManageController.actionEdit
|
public function actionEdit($id = null)
{
if ($id === null) {
$model = new Context;
$dataProvider = null;
} else {
$model = $this->findModel($id);
$dataProvider = new ActiveDataProvider(
[
'query' => Language::find()->where(['context_id' => $model->id]),
]
);
}
$isLoaded = $model->load(Yii::$app->request->post());
$hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-context'))
|| (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-context'));
if ($isLoaded && !$hasAccess) {
throw new ForbiddenHttpException;
}
if ($isLoaded && $model->save()) {
return $this->redirect(['edit', 'id' => $model->id]);
} else {
return $this->render(
'edit',
[
'dataProvider' => $dataProvider,
'hasAccess' => $hasAccess,
'model' => $model,
]
);
}
}
|
php
|
public function actionEdit($id = null)
{
if ($id === null) {
$model = new Context;
$dataProvider = null;
} else {
$model = $this->findModel($id);
$dataProvider = new ActiveDataProvider(
[
'query' => Language::find()->where(['context_id' => $model->id]),
]
);
}
$isLoaded = $model->load(Yii::$app->request->post());
$hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-context'))
|| (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-context'));
if ($isLoaded && !$hasAccess) {
throw new ForbiddenHttpException;
}
if ($isLoaded && $model->save()) {
return $this->redirect(['edit', 'id' => $model->id]);
} else {
return $this->render(
'edit',
[
'dataProvider' => $dataProvider,
'hasAccess' => $hasAccess,
'model' => $model,
]
);
}
}
|
[
"public",
"function",
"actionEdit",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"$",
"model",
"=",
"new",
"Context",
";",
"$",
"dataProvider",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"dataProvider",
"=",
"new",
"ActiveDataProvider",
"(",
"[",
"'query'",
"=>",
"Language",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'context_id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
",",
"]",
")",
";",
"}",
"$",
"isLoaded",
"=",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
";",
"$",
"hasAccess",
"=",
"(",
"$",
"model",
"->",
"isNewRecord",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'multilingual-create-context'",
")",
")",
"||",
"(",
"!",
"$",
"model",
"->",
"isNewRecord",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'multilingual-edit-context'",
")",
")",
";",
"if",
"(",
"$",
"isLoaded",
"&&",
"!",
"$",
"hasAccess",
")",
"{",
"throw",
"new",
"ForbiddenHttpException",
";",
"}",
"if",
"(",
"$",
"isLoaded",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'edit'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'edit'",
",",
"[",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'hasAccess'",
"=>",
"$",
"hasAccess",
",",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] |
Updates an existing Context model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
|
[
"Updates",
"an",
"existing",
"Context",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/controllers/ContextManageController.php#L79-L110
|
224,345
|
DevGroup-ru/yii2-multilingual
|
src/controllers/ContextManageController.php
|
ContextManageController.actionEditLanguage
|
public function actionEditLanguage($id = null, $contextId = null)
{
if ($id === null) {
$model = new Language();
} else {
$model = $this->findLanguageModel($id);
}
if ($contextId !== null) {
$model->context_id = $contextId;
}
$hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-language'))
|| (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-language'));
$isLoaded = $model->load(Yii::$app->request->post());
if ($isLoaded && !$hasAccess) {
throw new ForbiddenHttpException;
}
if ($isLoaded && $model->save()) {
return $this->redirect(['edit-language', 'id' => $model->id]);
} else {
return $this->render(
'edit-language',
[
'hasAccess' => $hasAccess,
'model' => $model,
]
);
}
}
|
php
|
public function actionEditLanguage($id = null, $contextId = null)
{
if ($id === null) {
$model = new Language();
} else {
$model = $this->findLanguageModel($id);
}
if ($contextId !== null) {
$model->context_id = $contextId;
}
$hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-language'))
|| (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-language'));
$isLoaded = $model->load(Yii::$app->request->post());
if ($isLoaded && !$hasAccess) {
throw new ForbiddenHttpException;
}
if ($isLoaded && $model->save()) {
return $this->redirect(['edit-language', 'id' => $model->id]);
} else {
return $this->render(
'edit-language',
[
'hasAccess' => $hasAccess,
'model' => $model,
]
);
}
}
|
[
"public",
"function",
"actionEditLanguage",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"contextId",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"$",
"model",
"=",
"new",
"Language",
"(",
")",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findLanguageModel",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"contextId",
"!==",
"null",
")",
"{",
"$",
"model",
"->",
"context_id",
"=",
"$",
"contextId",
";",
"}",
"$",
"hasAccess",
"=",
"(",
"$",
"model",
"->",
"isNewRecord",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'multilingual-create-language'",
")",
")",
"||",
"(",
"!",
"$",
"model",
"->",
"isNewRecord",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"can",
"(",
"'multilingual-edit-language'",
")",
")",
";",
"$",
"isLoaded",
"=",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
";",
"if",
"(",
"$",
"isLoaded",
"&&",
"!",
"$",
"hasAccess",
")",
"{",
"throw",
"new",
"ForbiddenHttpException",
";",
"}",
"if",
"(",
"$",
"isLoaded",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'edit-language'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'edit-language'",
",",
"[",
"'hasAccess'",
"=>",
"$",
"hasAccess",
",",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] |
Updates an existing Language model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
|
[
"Updates",
"an",
"existing",
"Language",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/controllers/ContextManageController.php#L118-L145
|
224,346
|
DevGroup-ru/yii2-multilingual
|
src/controllers/ContextManageController.php
|
ContextManageController.actionDeleteLanguage
|
public function actionDeleteLanguage($id)
{
$model = $this->findLanguageModel($id);
$model->delete();
return $this->redirect(['edit', 'id' => $model->context_id]);
}
|
php
|
public function actionDeleteLanguage($id)
{
$model = $this->findLanguageModel($id);
$model->delete();
return $this->redirect(['edit', 'id' => $model->context_id]);
}
|
[
"public",
"function",
"actionDeleteLanguage",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findLanguageModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'edit'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"context_id",
"]",
")",
";",
"}"
] |
Deletes an existing Language model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
|
[
"Deletes",
"an",
"existing",
"Language",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/controllers/ContextManageController.php#L165-L170
|
224,347
|
logical-and/php-oauth
|
src/OAuth2/Service/Mailchimp.php
|
Mailchimp.setBaseApiUri
|
protected function setBaseApiUri(TokenInterface $token)
{
// Make request uri.
$endpoint = 'https://login.mailchimp.com/oauth2/metadata?oauth_token=' . $token->getAccessToken();
// Grab meta data about the token.
$response = $this->httpRequest($endpoint, [], [], 'GET');
// Parse JSON.
$meta = json_decode($response, true);
// Set base api uri.
$this->baseApiUri = new Url('https://' . $meta[ 'dc' ] . '.api.mailchimp.com/{apiVersion}/');
// Allow chaining.
return $this;
}
|
php
|
protected function setBaseApiUri(TokenInterface $token)
{
// Make request uri.
$endpoint = 'https://login.mailchimp.com/oauth2/metadata?oauth_token=' . $token->getAccessToken();
// Grab meta data about the token.
$response = $this->httpRequest($endpoint, [], [], 'GET');
// Parse JSON.
$meta = json_decode($response, true);
// Set base api uri.
$this->baseApiUri = new Url('https://' . $meta[ 'dc' ] . '.api.mailchimp.com/{apiVersion}/');
// Allow chaining.
return $this;
}
|
[
"protected",
"function",
"setBaseApiUri",
"(",
"TokenInterface",
"$",
"token",
")",
"{",
"// Make request uri.",
"$",
"endpoint",
"=",
"'https://login.mailchimp.com/oauth2/metadata?oauth_token='",
".",
"$",
"token",
"->",
"getAccessToken",
"(",
")",
";",
"// Grab meta data about the token.",
"$",
"response",
"=",
"$",
"this",
"->",
"httpRequest",
"(",
"$",
"endpoint",
",",
"[",
"]",
",",
"[",
"]",
",",
"'GET'",
")",
";",
"// Parse JSON.",
"$",
"meta",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"// Set base api uri.",
"$",
"this",
"->",
"baseApiUri",
"=",
"new",
"Url",
"(",
"'https://'",
".",
"$",
"meta",
"[",
"'dc'",
"]",
".",
"'.api.mailchimp.com/{apiVersion}/'",
")",
";",
"// Allow chaining.",
"return",
"$",
"this",
";",
"}"
] |
Set the right base endpoint.
@param \OAuth\Common\Token\TokenInterface $token
@return $this
|
[
"Set",
"the",
"right",
"base",
"endpoint",
"."
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/OAuth2/Service/Mailchimp.php#L71-L87
|
224,348
|
darrylkuhn/dialect
|
src/Dialect/Json.php
|
Json.inspectJsonColumns
|
public function inspectJsonColumns()
{
foreach ($this->jsonColumns as $col) {
if (!$this->showJsonColumns) {
$this->hidden[] = $col;
}
if(array_key_exists($col, $this->attributes)) {
$obj = json_decode($this->attributes[$col]);
}
else {
$obj = json_decode($this->$col);
}
if (is_object($obj)) {
foreach ($obj as $key => $value) {
$this->flagJsonAttribute($key, $col);
if ($this->showJsonAttributes) {
$this->appends[] = $key;
}
}
}
}
}
|
php
|
public function inspectJsonColumns()
{
foreach ($this->jsonColumns as $col) {
if (!$this->showJsonColumns) {
$this->hidden[] = $col;
}
if(array_key_exists($col, $this->attributes)) {
$obj = json_decode($this->attributes[$col]);
}
else {
$obj = json_decode($this->$col);
}
if (is_object($obj)) {
foreach ($obj as $key => $value) {
$this->flagJsonAttribute($key, $col);
if ($this->showJsonAttributes) {
$this->appends[] = $key;
}
}
}
}
}
|
[
"public",
"function",
"inspectJsonColumns",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"jsonColumns",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"showJsonColumns",
")",
"{",
"$",
"this",
"->",
"hidden",
"[",
"]",
"=",
"$",
"col",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"$",
"obj",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"col",
"]",
")",
";",
"}",
"else",
"{",
"$",
"obj",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"$",
"col",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"foreach",
"(",
"$",
"obj",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"flagJsonAttribute",
"(",
"$",
"key",
",",
"$",
"col",
")",
";",
"if",
"(",
"$",
"this",
"->",
"showJsonAttributes",
")",
"{",
"$",
"this",
"->",
"appends",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"}",
"}",
"}"
] |
Decodes each of the declared JSON attributes and records the attributes
on each.
|
[
"Decodes",
"each",
"of",
"the",
"declared",
"JSON",
"attributes",
"and",
"records",
"the",
"attributes",
"on",
"each",
"."
] |
3027abf3423f0ba1032b07d5ad34a8d1c97900e8
|
https://github.com/darrylkuhn/dialect/blob/3027abf3423f0ba1032b07d5ad34a8d1c97900e8/src/Dialect/Json.php#L79-L102
|
224,349
|
darrylkuhn/dialect
|
src/Dialect/Json.php
|
Json.hintJsonStructure
|
public function hintJsonStructure($column, $structure)
{
if (json_decode($structure) === null) {
throw new InvalidJsonException();
}
$this->hintedJsonAttributes[$column] = $structure;
// Run the call to add hinted attributes to the internal json
// attributes array. This allows callers to get/set parameters when
// working with new models
$this->addHintedAttributes();
}
|
php
|
public function hintJsonStructure($column, $structure)
{
if (json_decode($structure) === null) {
throw new InvalidJsonException();
}
$this->hintedJsonAttributes[$column] = $structure;
// Run the call to add hinted attributes to the internal json
// attributes array. This allows callers to get/set parameters when
// working with new models
$this->addHintedAttributes();
}
|
[
"public",
"function",
"hintJsonStructure",
"(",
"$",
"column",
",",
"$",
"structure",
")",
"{",
"if",
"(",
"json_decode",
"(",
"$",
"structure",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidJsonException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"hintedJsonAttributes",
"[",
"$",
"column",
"]",
"=",
"$",
"structure",
";",
"// Run the call to add hinted attributes to the internal json",
"// attributes array. This allows callers to get/set parameters when",
"// working with new models",
"$",
"this",
"->",
"addHintedAttributes",
"(",
")",
";",
"}"
] |
Sets a hint for a given column.
@param string $column name of column that we're hinting
@param string $structure json encoded structure
@throws InvalidJsonException
|
[
"Sets",
"a",
"hint",
"for",
"a",
"given",
"column",
"."
] |
3027abf3423f0ba1032b07d5ad34a8d1c97900e8
|
https://github.com/darrylkuhn/dialect/blob/3027abf3423f0ba1032b07d5ad34a8d1c97900e8/src/Dialect/Json.php#L141-L153
|
224,350
|
darrylkuhn/dialect
|
src/Dialect/Json.php
|
Json.hasGetMutator
|
public function hasGetMutator($key)
{
$jsonPattern = '/'.implode('|', self::$jsonOperators).'/';
if (array_key_exists($key, $this->jsonAttributes) !== false) {
return true;
} // In some cases the key specified may not be a simple key but rather a
// JSON expression (e.g. "jsonField->'some_key'). A common case would
// be when specifying a relation key. As such we test for JSON
// operators and expect a mutator if this is a JSON expression
elseif (preg_match($jsonPattern, $key) != false) {
return true;
}
return parent::hasGetMutator($key);
}
|
php
|
public function hasGetMutator($key)
{
$jsonPattern = '/'.implode('|', self::$jsonOperators).'/';
if (array_key_exists($key, $this->jsonAttributes) !== false) {
return true;
} // In some cases the key specified may not be a simple key but rather a
// JSON expression (e.g. "jsonField->'some_key'). A common case would
// be when specifying a relation key. As such we test for JSON
// operators and expect a mutator if this is a JSON expression
elseif (preg_match($jsonPattern, $key) != false) {
return true;
}
return parent::hasGetMutator($key);
}
|
[
"public",
"function",
"hasGetMutator",
"(",
"$",
"key",
")",
"{",
"$",
"jsonPattern",
"=",
"'/'",
".",
"implode",
"(",
"'|'",
",",
"self",
"::",
"$",
"jsonOperators",
")",
".",
"'/'",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"jsonAttributes",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"// In some cases the key specified may not be a simple key but rather a",
"// JSON expression (e.g. \"jsonField->'some_key'). A common case would",
"// be when specifying a relation key. As such we test for JSON",
"// operators and expect a mutator if this is a JSON expression",
"elseif",
"(",
"preg_match",
"(",
"$",
"jsonPattern",
",",
"$",
"key",
")",
"!=",
"false",
")",
"{",
"return",
"true",
";",
"}",
"return",
"parent",
"::",
"hasGetMutator",
"(",
"$",
"key",
")",
";",
"}"
] |
Include JSON column in the list of attributes that have a get mutator.
@param string $key
@return bool
|
[
"Include",
"JSON",
"column",
"in",
"the",
"list",
"of",
"attributes",
"that",
"have",
"a",
"get",
"mutator",
"."
] |
3027abf3423f0ba1032b07d5ad34a8d1c97900e8
|
https://github.com/darrylkuhn/dialect/blob/3027abf3423f0ba1032b07d5ad34a8d1c97900e8/src/Dialect/Json.php#L173-L188
|
224,351
|
darrylkuhn/dialect
|
src/Dialect/Json.php
|
Json.getMutatedAttributes
|
public function getMutatedAttributes()
{
$attributes = parent::getMutatedAttributes();
$jsonAttributes = array_keys($this->jsonAttributes);
return array_merge($attributes, $jsonAttributes);
}
|
php
|
public function getMutatedAttributes()
{
$attributes = parent::getMutatedAttributes();
$jsonAttributes = array_keys($this->jsonAttributes);
return array_merge($attributes, $jsonAttributes);
}
|
[
"public",
"function",
"getMutatedAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"parent",
"::",
"getMutatedAttributes",
"(",
")",
";",
"$",
"jsonAttributes",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"jsonAttributes",
")",
";",
"return",
"array_merge",
"(",
"$",
"attributes",
",",
"$",
"jsonAttributes",
")",
";",
"}"
] |
Include the JSON attributes in the list of mutated attributes for a
given instance.
@return array
|
[
"Include",
"the",
"JSON",
"attributes",
"in",
"the",
"list",
"of",
"mutated",
"attributes",
"for",
"a",
"given",
"instance",
"."
] |
3027abf3423f0ba1032b07d5ad34a8d1c97900e8
|
https://github.com/darrylkuhn/dialect/blob/3027abf3423f0ba1032b07d5ad34a8d1c97900e8/src/Dialect/Json.php#L196-L202
|
224,352
|
darrylkuhn/dialect
|
src/Dialect/Json.php
|
Json.mutateAttribute
|
protected function mutateAttribute($key, $value)
{
$jsonPattern = '/'.implode('|', self::$jsonOperators).'/';
// Test for JSON operators and reduce to end element
$containsJsonOperator = false;
if (preg_match($jsonPattern, $key)) {
$elems = preg_split($jsonPattern, $key);
$key = end($elems);
$key = str_replace(['>', "'"], '', $key);
$containsJsonOperator = true;
}
if (!parent::hasGetMutator($key) && array_key_exists($key, $this->jsonAttributes) != false) {
// Get the content of the column associated with this JSON
// attribute and parse it into an object
$value = $this->{$this->jsonAttributes[$key]};
$obj = json_decode($this->{$this->jsonAttributes[$key]});
// Make sure we were able to parse the json. It's possible here
// that we've only hinted at an attribute and the column that will
// hold that attribute is actually null. This isn't really a parse
// error though the json_encode method will return null (just like)
// a parse error. To distinguish the two states see if the original
// value was null (indicating there was nothing there to parse in
// the first place)
if ( !($value === 'null' || $value === null) && $obj === null ) {
throw new InvalidJsonException();
}
// Again it's possible the key will be in the jsonAttributes array
// (having been hinted) but not present on the actual record.
// Therefore test that the key is set before returning.
if (isset($obj->$key)) {
return $obj->$key;
} else {
return;
}
} elseif ($containsJsonOperator) {
return;
}
return parent::mutateAttribute($key, $value);
}
|
php
|
protected function mutateAttribute($key, $value)
{
$jsonPattern = '/'.implode('|', self::$jsonOperators).'/';
// Test for JSON operators and reduce to end element
$containsJsonOperator = false;
if (preg_match($jsonPattern, $key)) {
$elems = preg_split($jsonPattern, $key);
$key = end($elems);
$key = str_replace(['>', "'"], '', $key);
$containsJsonOperator = true;
}
if (!parent::hasGetMutator($key) && array_key_exists($key, $this->jsonAttributes) != false) {
// Get the content of the column associated with this JSON
// attribute and parse it into an object
$value = $this->{$this->jsonAttributes[$key]};
$obj = json_decode($this->{$this->jsonAttributes[$key]});
// Make sure we were able to parse the json. It's possible here
// that we've only hinted at an attribute and the column that will
// hold that attribute is actually null. This isn't really a parse
// error though the json_encode method will return null (just like)
// a parse error. To distinguish the two states see if the original
// value was null (indicating there was nothing there to parse in
// the first place)
if ( !($value === 'null' || $value === null) && $obj === null ) {
throw new InvalidJsonException();
}
// Again it's possible the key will be in the jsonAttributes array
// (having been hinted) but not present on the actual record.
// Therefore test that the key is set before returning.
if (isset($obj->$key)) {
return $obj->$key;
} else {
return;
}
} elseif ($containsJsonOperator) {
return;
}
return parent::mutateAttribute($key, $value);
}
|
[
"protected",
"function",
"mutateAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"jsonPattern",
"=",
"'/'",
".",
"implode",
"(",
"'|'",
",",
"self",
"::",
"$",
"jsonOperators",
")",
".",
"'/'",
";",
"// Test for JSON operators and reduce to end element",
"$",
"containsJsonOperator",
"=",
"false",
";",
"if",
"(",
"preg_match",
"(",
"$",
"jsonPattern",
",",
"$",
"key",
")",
")",
"{",
"$",
"elems",
"=",
"preg_split",
"(",
"$",
"jsonPattern",
",",
"$",
"key",
")",
";",
"$",
"key",
"=",
"end",
"(",
"$",
"elems",
")",
";",
"$",
"key",
"=",
"str_replace",
"(",
"[",
"'>'",
",",
"\"'\"",
"]",
",",
"''",
",",
"$",
"key",
")",
";",
"$",
"containsJsonOperator",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"parent",
"::",
"hasGetMutator",
"(",
"$",
"key",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"jsonAttributes",
")",
"!=",
"false",
")",
"{",
"// Get the content of the column associated with this JSON",
"// attribute and parse it into an object",
"$",
"value",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"jsonAttributes",
"[",
"$",
"key",
"]",
"}",
";",
"$",
"obj",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"jsonAttributes",
"[",
"$",
"key",
"]",
"}",
")",
";",
"// Make sure we were able to parse the json. It's possible here",
"// that we've only hinted at an attribute and the column that will",
"// hold that attribute is actually null. This isn't really a parse",
"// error though the json_encode method will return null (just like)",
"// a parse error. To distinguish the two states see if the original",
"// value was null (indicating there was nothing there to parse in",
"// the first place)",
"if",
"(",
"!",
"(",
"$",
"value",
"===",
"'null'",
"||",
"$",
"value",
"===",
"null",
")",
"&&",
"$",
"obj",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidJsonException",
"(",
")",
";",
"}",
"// Again it's possible the key will be in the jsonAttributes array",
"// (having been hinted) but not present on the actual record.",
"// Therefore test that the key is set before returning.",
"if",
"(",
"isset",
"(",
"$",
"obj",
"->",
"$",
"key",
")",
")",
"{",
"return",
"$",
"obj",
"->",
"$",
"key",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"elseif",
"(",
"$",
"containsJsonOperator",
")",
"{",
"return",
";",
"}",
"return",
"parent",
"::",
"mutateAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] |
Check if the key is a known json attribute and return that value.
@param string $key
@param mixed $value
@return mixed
@throws InvalidJsonException
|
[
"Check",
"if",
"the",
"key",
"is",
"a",
"known",
"json",
"attribute",
"and",
"return",
"that",
"value",
"."
] |
3027abf3423f0ba1032b07d5ad34a8d1c97900e8
|
https://github.com/darrylkuhn/dialect/blob/3027abf3423f0ba1032b07d5ad34a8d1c97900e8/src/Dialect/Json.php#L214-L260
|
224,353
|
jeroendesloovere/distance
|
src/Distance.php
|
Distance.between
|
public static function between(
$latitude1,
$longitude1,
$latitude2,
$longitude2,
$decimals = 1,
$unit = 'km'
) {
// define calculation variables
$theta = $longitude1 - $longitude2;
$distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2)))
+ (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)))
;
$distance = acos($distance);
$distance = rad2deg($distance);
$distance = $distance * 60 * 1.1515;
// unit is km
if ($unit == 'km') {
// redefine distance
$distance = $distance * 1.609344;
}
// return with one decimal
return round($distance, $decimals);
}
|
php
|
public static function between(
$latitude1,
$longitude1,
$latitude2,
$longitude2,
$decimals = 1,
$unit = 'km'
) {
// define calculation variables
$theta = $longitude1 - $longitude2;
$distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2)))
+ (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)))
;
$distance = acos($distance);
$distance = rad2deg($distance);
$distance = $distance * 60 * 1.1515;
// unit is km
if ($unit == 'km') {
// redefine distance
$distance = $distance * 1.609344;
}
// return with one decimal
return round($distance, $decimals);
}
|
[
"public",
"static",
"function",
"between",
"(",
"$",
"latitude1",
",",
"$",
"longitude1",
",",
"$",
"latitude2",
",",
"$",
"longitude2",
",",
"$",
"decimals",
"=",
"1",
",",
"$",
"unit",
"=",
"'km'",
")",
"{",
"// define calculation variables",
"$",
"theta",
"=",
"$",
"longitude1",
"-",
"$",
"longitude2",
";",
"$",
"distance",
"=",
"(",
"sin",
"(",
"deg2rad",
"(",
"$",
"latitude1",
")",
")",
"*",
"sin",
"(",
"deg2rad",
"(",
"$",
"latitude2",
")",
")",
")",
"+",
"(",
"cos",
"(",
"deg2rad",
"(",
"$",
"latitude1",
")",
")",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"latitude2",
")",
")",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"theta",
")",
")",
")",
";",
"$",
"distance",
"=",
"acos",
"(",
"$",
"distance",
")",
";",
"$",
"distance",
"=",
"rad2deg",
"(",
"$",
"distance",
")",
";",
"$",
"distance",
"=",
"$",
"distance",
"*",
"60",
"*",
"1.1515",
";",
"// unit is km",
"if",
"(",
"$",
"unit",
"==",
"'km'",
")",
"{",
"// redefine distance",
"$",
"distance",
"=",
"$",
"distance",
"*",
"1.609344",
";",
"}",
"// return with one decimal",
"return",
"round",
"(",
"$",
"distance",
",",
"$",
"decimals",
")",
";",
"}"
] |
Get distance between two coordinates
@return float
@param decimal $latitude1
@param decimal $longitude1
@param decimal $latitude2
@param decimal $longitude2
@param int $decimals[optional] The amount of decimals
@param string $unit[optional]
|
[
"Get",
"distance",
"between",
"two",
"coordinates"
] |
7dd9a9f9d9dbe5687ccc249b84f7dd2c64faf79a
|
https://github.com/jeroendesloovere/distance/blob/7dd9a9f9d9dbe5687ccc249b84f7dd2c64faf79a/src/Distance.php#L25-L50
|
224,354
|
jeroendesloovere/distance
|
src/Distance.php
|
Distance.getClosest
|
public static function getClosest(
$latitude1,
$longitude1,
$items,
$decimals = 1,
$unit = 'km'
) {
// init result
$distances = array();
// loop items
foreach ($items as $key => $item) {
// define second item
$latitude2 = $item['latitude'];
$longitude2 = $item['longitude'];
// define distance
$distance = self::between(
$latitude1,
$longitude1,
$latitude2,
$longitude2,
10,
$unit
);
// add distance
$distances[$distance] = $key;
// add rounded distance to array
$items[$key]['distance'] = round($distance, $decimals);
}
// return the item with the closest distance
return $items[$distances[min(array_keys($distances))]];
}
|
php
|
public static function getClosest(
$latitude1,
$longitude1,
$items,
$decimals = 1,
$unit = 'km'
) {
// init result
$distances = array();
// loop items
foreach ($items as $key => $item) {
// define second item
$latitude2 = $item['latitude'];
$longitude2 = $item['longitude'];
// define distance
$distance = self::between(
$latitude1,
$longitude1,
$latitude2,
$longitude2,
10,
$unit
);
// add distance
$distances[$distance] = $key;
// add rounded distance to array
$items[$key]['distance'] = round($distance, $decimals);
}
// return the item with the closest distance
return $items[$distances[min(array_keys($distances))]];
}
|
[
"public",
"static",
"function",
"getClosest",
"(",
"$",
"latitude1",
",",
"$",
"longitude1",
",",
"$",
"items",
",",
"$",
"decimals",
"=",
"1",
",",
"$",
"unit",
"=",
"'km'",
")",
"{",
"// init result",
"$",
"distances",
"=",
"array",
"(",
")",
";",
"// loop items",
"foreach",
"(",
"$",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"// define second item",
"$",
"latitude2",
"=",
"$",
"item",
"[",
"'latitude'",
"]",
";",
"$",
"longitude2",
"=",
"$",
"item",
"[",
"'longitude'",
"]",
";",
"// define distance",
"$",
"distance",
"=",
"self",
"::",
"between",
"(",
"$",
"latitude1",
",",
"$",
"longitude1",
",",
"$",
"latitude2",
",",
"$",
"longitude2",
",",
"10",
",",
"$",
"unit",
")",
";",
"// add distance",
"$",
"distances",
"[",
"$",
"distance",
"]",
"=",
"$",
"key",
";",
"// add rounded distance to array",
"$",
"items",
"[",
"$",
"key",
"]",
"[",
"'distance'",
"]",
"=",
"round",
"(",
"$",
"distance",
",",
"$",
"decimals",
")",
";",
"}",
"// return the item with the closest distance",
"return",
"$",
"items",
"[",
"$",
"distances",
"[",
"min",
"(",
"array_keys",
"(",
"$",
"distances",
")",
")",
"]",
"]",
";",
"}"
] |
Get closest location from all locations
@return array The item which is the closest + 'distance' to it.
@param decimal $latitude1
@param decimal $longitude1
@param array $items = array(array('latitude' => 'x', 'longitude' => 'x'), array(xxx))
@param int $decimals[optional] The amount of decimals
@param string $unit[optional]
|
[
"Get",
"closest",
"location",
"from",
"all",
"locations"
] |
7dd9a9f9d9dbe5687ccc249b84f7dd2c64faf79a
|
https://github.com/jeroendesloovere/distance/blob/7dd9a9f9d9dbe5687ccc249b84f7dd2c64faf79a/src/Distance.php#L62-L97
|
224,355
|
logical-and/php-oauth
|
src/UserData/ExtractorFactory.php
|
ExtractorFactory.searchExtractorClassInLib
|
protected function searchExtractorClassInLib($serviceFullyQualifiedClass)
{
$parts = explode('\\', $serviceFullyQualifiedClass);
$className = $parts[ sizeof($parts) - 1 ];
$extractorClass = sprintf('\OAuth\UserData\Extractor\%s', $className);
if (class_exists($extractorClass)) {
return $extractorClass;
}
return null;
}
|
php
|
protected function searchExtractorClassInLib($serviceFullyQualifiedClass)
{
$parts = explode('\\', $serviceFullyQualifiedClass);
$className = $parts[ sizeof($parts) - 1 ];
$extractorClass = sprintf('\OAuth\UserData\Extractor\%s', $className);
if (class_exists($extractorClass)) {
return $extractorClass;
}
return null;
}
|
[
"protected",
"function",
"searchExtractorClassInLib",
"(",
"$",
"serviceFullyQualifiedClass",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"serviceFullyQualifiedClass",
")",
";",
"$",
"className",
"=",
"$",
"parts",
"[",
"sizeof",
"(",
"$",
"parts",
")",
"-",
"1",
"]",
";",
"$",
"extractorClass",
"=",
"sprintf",
"(",
"'\\OAuth\\UserData\\Extractor\\%s'",
",",
"$",
"className",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"extractorClass",
")",
")",
"{",
"return",
"$",
"extractorClass",
";",
"}",
"return",
"null",
";",
"}"
] |
Search a mapping on the fly by inspecting the library code
@param string $serviceFullyQualifiedClass
@return null|string
|
[
"Search",
"a",
"mapping",
"on",
"the",
"fly",
"by",
"inspecting",
"the",
"library",
"code"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/ExtractorFactory.php#L80-L91
|
224,356
|
DevGroup-ru/yii2-multilingual
|
src/traits/FileActiveRecord.php
|
FileActiveRecord.initFileActiveRecord
|
public function initFileActiveRecord()
{
if (count(static::primaryKey()) === 1) {
$this->on(self::EVENT_BEFORE_INSERT, function ($event) {
if (empty($event->sender->{$event->data['pkName']})) {
/** @var ActiveRecord $className */
$className = $event->data['className'];
$lastModel = $className::find()->orderBy([$event->data['pkName'] => SORT_DESC])->one();
$event->sender->{$event->data['pkName']} = $lastModel !== null ? $lastModel->{$event->data['pkName']} + 1 : 1;
}
}, ['pkName' => static::primaryKey()[0], 'className' => static::class]);
}
}
|
php
|
public function initFileActiveRecord()
{
if (count(static::primaryKey()) === 1) {
$this->on(self::EVENT_BEFORE_INSERT, function ($event) {
if (empty($event->sender->{$event->data['pkName']})) {
/** @var ActiveRecord $className */
$className = $event->data['className'];
$lastModel = $className::find()->orderBy([$event->data['pkName'] => SORT_DESC])->one();
$event->sender->{$event->data['pkName']} = $lastModel !== null ? $lastModel->{$event->data['pkName']} + 1 : 1;
}
}, ['pkName' => static::primaryKey()[0], 'className' => static::class]);
}
}
|
[
"public",
"function",
"initFileActiveRecord",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"static",
"::",
"primaryKey",
"(",
")",
")",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"on",
"(",
"self",
"::",
"EVENT_BEFORE_INSERT",
",",
"function",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"event",
"->",
"sender",
"->",
"{",
"$",
"event",
"->",
"data",
"[",
"'pkName'",
"]",
"}",
")",
")",
"{",
"/** @var ActiveRecord $className */",
"$",
"className",
"=",
"$",
"event",
"->",
"data",
"[",
"'className'",
"]",
";",
"$",
"lastModel",
"=",
"$",
"className",
"::",
"find",
"(",
")",
"->",
"orderBy",
"(",
"[",
"$",
"event",
"->",
"data",
"[",
"'pkName'",
"]",
"=>",
"SORT_DESC",
"]",
")",
"->",
"one",
"(",
")",
";",
"$",
"event",
"->",
"sender",
"->",
"{",
"$",
"event",
"->",
"data",
"[",
"'pkName'",
"]",
"}",
"=",
"$",
"lastModel",
"!==",
"null",
"?",
"$",
"lastModel",
"->",
"{",
"$",
"event",
"->",
"data",
"[",
"'pkName'",
"]",
"}",
"+",
"1",
":",
"1",
";",
"}",
"}",
",",
"[",
"'pkName'",
"=>",
"static",
"::",
"primaryKey",
"(",
")",
"[",
"0",
"]",
",",
"'className'",
"=>",
"static",
"::",
"class",
"]",
")",
";",
"}",
"}"
] |
Init events of this trait.
|
[
"Init",
"events",
"of",
"this",
"trait",
"."
] |
50682a48e216df1dde48b56096640e2ff579a3e0
|
https://github.com/DevGroup-ru/yii2-multilingual/blob/50682a48e216df1dde48b56096640e2ff579a3e0/src/traits/FileActiveRecord.php#L12-L24
|
224,357
|
turtledesign/royalmail-php
|
src/Request/Builder.php
|
Builder.build
|
static function build($request_name, $params, $helper = NULL) {
return self::processSchema(self::getRequestSchema($request_name), $params, $helper);
}
|
php
|
static function build($request_name, $params, $helper = NULL) {
return self::processSchema(self::getRequestSchema($request_name), $params, $helper);
}
|
[
"static",
"function",
"build",
"(",
"$",
"request_name",
",",
"$",
"params",
",",
"$",
"helper",
"=",
"NULL",
")",
"{",
"return",
"self",
"::",
"processSchema",
"(",
"self",
"::",
"getRequestSchema",
"(",
"$",
"request_name",
")",
",",
"$",
"params",
",",
"$",
"helper",
")",
";",
"}"
] |
Build an individual request from schema and params.
@param string $request_name
@param array $params
@param \ArrayObject $helper
@return array
|
[
"Build",
"an",
"individual",
"request",
"from",
"schema",
"and",
"params",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Request/Builder.php#L27-L29
|
224,358
|
turtledesign/royalmail-php
|
src/Request/Builder.php
|
Builder.processSchema
|
static function processSchema($schema, $params, $helper = NULL) {
$built = [];
$errors = [];
(is_null($helper)) ? $helper = ['input' => $params] : $helper['input'] = $params;
$schema['defaults'] = @$schema['defaults'] ?: [];
if (isset($helper['override_defaults'])) $schema['defaults'] = array_merge($schema['defaults'], $helper['override_defaults']);
try {
foreach ($schema['properties'] as $k => $v) {
$built = self::addProperty($built, $schema['properties'][$k], $k, @$params[$k], $schema['defaults'], $helper);
}
} catch (\RoyalMail\Exception\ValidatorException $e) {
$errors[$k] = $k . ': ' . $e->getMessage();
} catch (\RoyalMail\Exception\RequestException $re) {
foreach ($re->getErrors() as $k_nested => $v) $errors[$k . ':' . $k_nested] = $v;
}
if (! empty($errors)) throw (new \RoyalMail\Exception\RequestException())->withErrors($errors);
if (defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION > 5) $built = self::derefArray($built);
return $built;
}
|
php
|
static function processSchema($schema, $params, $helper = NULL) {
$built = [];
$errors = [];
(is_null($helper)) ? $helper = ['input' => $params] : $helper['input'] = $params;
$schema['defaults'] = @$schema['defaults'] ?: [];
if (isset($helper['override_defaults'])) $schema['defaults'] = array_merge($schema['defaults'], $helper['override_defaults']);
try {
foreach ($schema['properties'] as $k => $v) {
$built = self::addProperty($built, $schema['properties'][$k], $k, @$params[$k], $schema['defaults'], $helper);
}
} catch (\RoyalMail\Exception\ValidatorException $e) {
$errors[$k] = $k . ': ' . $e->getMessage();
} catch (\RoyalMail\Exception\RequestException $re) {
foreach ($re->getErrors() as $k_nested => $v) $errors[$k . ':' . $k_nested] = $v;
}
if (! empty($errors)) throw (new \RoyalMail\Exception\RequestException())->withErrors($errors);
if (defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION > 5) $built = self::derefArray($built);
return $built;
}
|
[
"static",
"function",
"processSchema",
"(",
"$",
"schema",
",",
"$",
"params",
",",
"$",
"helper",
"=",
"NULL",
")",
"{",
"$",
"built",
"=",
"[",
"]",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"(",
"is_null",
"(",
"$",
"helper",
")",
")",
"?",
"$",
"helper",
"=",
"[",
"'input'",
"=>",
"$",
"params",
"]",
":",
"$",
"helper",
"[",
"'input'",
"]",
"=",
"$",
"params",
";",
"$",
"schema",
"[",
"'defaults'",
"]",
"=",
"@",
"$",
"schema",
"[",
"'defaults'",
"]",
"?",
":",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"helper",
"[",
"'override_defaults'",
"]",
")",
")",
"$",
"schema",
"[",
"'defaults'",
"]",
"=",
"array_merge",
"(",
"$",
"schema",
"[",
"'defaults'",
"]",
",",
"$",
"helper",
"[",
"'override_defaults'",
"]",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"schema",
"[",
"'properties'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"built",
"=",
"self",
"::",
"addProperty",
"(",
"$",
"built",
",",
"$",
"schema",
"[",
"'properties'",
"]",
"[",
"$",
"k",
"]",
",",
"$",
"k",
",",
"@",
"$",
"params",
"[",
"$",
"k",
"]",
",",
"$",
"schema",
"[",
"'defaults'",
"]",
",",
"$",
"helper",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"RoyalMail",
"\\",
"Exception",
"\\",
"ValidatorException",
"$",
"e",
")",
"{",
"$",
"errors",
"[",
"$",
"k",
"]",
"=",
"$",
"k",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"RoyalMail",
"\\",
"Exception",
"\\",
"RequestException",
"$",
"re",
")",
"{",
"foreach",
"(",
"$",
"re",
"->",
"getErrors",
"(",
")",
"as",
"$",
"k_nested",
"=>",
"$",
"v",
")",
"$",
"errors",
"[",
"$",
"k",
".",
"':'",
".",
"$",
"k_nested",
"]",
"=",
"$",
"v",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"throw",
"(",
"new",
"\\",
"RoyalMail",
"\\",
"Exception",
"\\",
"RequestException",
"(",
")",
")",
"->",
"withErrors",
"(",
"$",
"errors",
")",
";",
"if",
"(",
"defined",
"(",
"'PHP_MAJOR_VERSION'",
")",
"&&",
"PHP_MAJOR_VERSION",
">",
"5",
")",
"$",
"built",
"=",
"self",
"::",
"derefArray",
"(",
"$",
"built",
")",
";",
"return",
"$",
"built",
";",
"}"
] |
Process the schema and params to validate and structure a request fragment.
@param array $schema instructions for processing the params.
@param array $params values to work with
@throws \RoyalMail\Exception\RequestException on validation failure with details of all failing field values.
@return array values structured for API request.
|
[
"Process",
"the",
"schema",
"and",
"params",
"to",
"validate",
"and",
"structure",
"a",
"request",
"fragment",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Request/Builder.php#L42-L69
|
224,359
|
logical-and/php-oauth
|
src/Common/Storage/File.php
|
File.updateFile
|
private function updateFile()
{
if (is_null($this->file_path)) {
throw new StorageException('Invalid file path');
}
file_put_contents(
$this->file_path,
serialize(
[
'tokens' => $this->tokens,
'states' => $this->states
]
)
);
}
|
php
|
private function updateFile()
{
if (is_null($this->file_path)) {
throw new StorageException('Invalid file path');
}
file_put_contents(
$this->file_path,
serialize(
[
'tokens' => $this->tokens,
'states' => $this->states
]
)
);
}
|
[
"private",
"function",
"updateFile",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"file_path",
")",
")",
"{",
"throw",
"new",
"StorageException",
"(",
"'Invalid file path'",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"this",
"->",
"file_path",
",",
"serialize",
"(",
"[",
"'tokens'",
"=>",
"$",
"this",
"->",
"tokens",
",",
"'states'",
"=>",
"$",
"this",
"->",
"states",
"]",
")",
")",
";",
"}"
] |
Update file containing tokens and states
|
[
"Update",
"file",
"containing",
"tokens",
"and",
"states"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/Common/Storage/File.php#L176-L191
|
224,360
|
logical-and/php-oauth
|
src/Common/Storage/File.php
|
File.parseFromFile
|
private function parseFromFile()
{
if (is_null($this->file_path)) {
throw new StorageException('Invalid file path');
}
$data = unserialize(file_get_contents($this->file_path));
if ($data === false) {
throw new StorageException('File contents not unserializeable');
}
$this->tokens = $data[ 'tokens' ];
$this->states = $data[ 'states' ];
}
|
php
|
private function parseFromFile()
{
if (is_null($this->file_path)) {
throw new StorageException('Invalid file path');
}
$data = unserialize(file_get_contents($this->file_path));
if ($data === false) {
throw new StorageException('File contents not unserializeable');
}
$this->tokens = $data[ 'tokens' ];
$this->states = $data[ 'states' ];
}
|
[
"private",
"function",
"parseFromFile",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"file_path",
")",
")",
"{",
"throw",
"new",
"StorageException",
"(",
"'Invalid file path'",
")",
";",
"}",
"$",
"data",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"file_path",
")",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"throw",
"new",
"StorageException",
"(",
"'File contents not unserializeable'",
")",
";",
"}",
"$",
"this",
"->",
"tokens",
"=",
"$",
"data",
"[",
"'tokens'",
"]",
";",
"$",
"this",
"->",
"states",
"=",
"$",
"data",
"[",
"'states'",
"]",
";",
"}"
] |
Get serialized content from a file
|
[
"Get",
"serialized",
"content",
"from",
"a",
"file"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/Common/Storage/File.php#L196-L209
|
224,361
|
appkr/api
|
src/example/LinkController.php
|
LinkController.index
|
public function index(Response $response)
{
$payload = [
'resources' => route('v1.books.index'),
'authors' => route('v1.authors.index'),
];
return $response->setMeta([
'message' => "Hello, I'm a appkr/api example",
'version' => 1,
'documentation' => route('v1.doc'),
])->respond([
'link' => $payload,
]);
}
|
php
|
public function index(Response $response)
{
$payload = [
'resources' => route('v1.books.index'),
'authors' => route('v1.authors.index'),
];
return $response->setMeta([
'message' => "Hello, I'm a appkr/api example",
'version' => 1,
'documentation' => route('v1.doc'),
])->respond([
'link' => $payload,
]);
}
|
[
"public",
"function",
"index",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"payload",
"=",
"[",
"'resources'",
"=>",
"route",
"(",
"'v1.books.index'",
")",
",",
"'authors'",
"=>",
"route",
"(",
"'v1.authors.index'",
")",
",",
"]",
";",
"return",
"$",
"response",
"->",
"setMeta",
"(",
"[",
"'message'",
"=>",
"\"Hello, I'm a appkr/api example\"",
",",
"'version'",
"=>",
"1",
",",
"'documentation'",
"=>",
"route",
"(",
"'v1.doc'",
")",
",",
"]",
")",
"->",
"respond",
"(",
"[",
"'link'",
"=>",
"$",
"payload",
",",
"]",
")",
";",
"}"
] |
Exposure a listing of the endpoints.
@param \Appkr\Api\Http\Response $response
@return \Illuminate\Contracts\Http\Response
|
[
"Exposure",
"a",
"listing",
"of",
"the",
"endpoints",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/example/LinkController.php#L16-L30
|
224,362
|
logical-and/php-oauth
|
src/OAuth1/Service/AbstractService.php
|
AbstractService.buildAuthorizationHeaderForTokenRequest
|
protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = [])
{
$parameters = $this->getBasicAuthorizationHeaderInfo();
$parameters = array_merge($parameters, $extraParameters);
$parameters[ 'oauth_signature' ] = $this->signature->getSignature(
$this->getRequestTokenEndpoint(),
$parameters,
'POST'
);
$authorizationHeader = 'OAuth ';
$delimiter = '';
foreach ($parameters as $key => $value) {
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
$delimiter = ', ';
}
return $authorizationHeader;
}
|
php
|
protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = [])
{
$parameters = $this->getBasicAuthorizationHeaderInfo();
$parameters = array_merge($parameters, $extraParameters);
$parameters[ 'oauth_signature' ] = $this->signature->getSignature(
$this->getRequestTokenEndpoint(),
$parameters,
'POST'
);
$authorizationHeader = 'OAuth ';
$delimiter = '';
foreach ($parameters as $key => $value) {
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
$delimiter = ', ';
}
return $authorizationHeader;
}
|
[
"protected",
"function",
"buildAuthorizationHeaderForTokenRequest",
"(",
"array",
"$",
"extraParameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getBasicAuthorizationHeaderInfo",
"(",
")",
";",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"parameters",
",",
"$",
"extraParameters",
")",
";",
"$",
"parameters",
"[",
"'oauth_signature'",
"]",
"=",
"$",
"this",
"->",
"signature",
"->",
"getSignature",
"(",
"$",
"this",
"->",
"getRequestTokenEndpoint",
"(",
")",
",",
"$",
"parameters",
",",
"'POST'",
")",
";",
"$",
"authorizationHeader",
"=",
"'OAuth '",
";",
"$",
"delimiter",
"=",
"''",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"authorizationHeader",
".=",
"$",
"delimiter",
".",
"rawurlencode",
"(",
"$",
"key",
")",
".",
"'=\"'",
".",
"rawurlencode",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"$",
"delimiter",
"=",
"', '",
";",
"}",
"return",
"$",
"authorizationHeader",
";",
"}"
] |
Builds the authorization header for getting an access or request token.
@param array $extraParameters
@return string
|
[
"Builds",
"the",
"authorization",
"header",
"for",
"getting",
"an",
"access",
"or",
"request",
"token",
"."
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/OAuth1/Service/AbstractService.php#L173-L192
|
224,363
|
logical-and/php-oauth
|
src/OAuth1/Service/AbstractService.php
|
AbstractService.buildAuthorizationHeaderForAPIRequest
|
protected function buildAuthorizationHeaderForAPIRequest(
$method,
Url $uri,
TokenInterface $token,
$bodyParams = null
) {
$this->signature->setTokenSecret($token->getAccessTokenSecret());
$authParameters = $this->getBasicAuthorizationHeaderInfo();
if (isset($authParameters[ 'oauth_callback' ])) {
unset($authParameters[ 'oauth_callback' ]);
}
$authParameters = array_merge($authParameters, ['oauth_token' => $token->getAccessToken()]);
$signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters;
$authParameters[ 'oauth_signature' ] = $this->signature->getSignature($uri, $signatureParams, $method);
$authorizationHeader = 'OAuth ';
$delimiter = '';
foreach ($authParameters as $key => $value) {
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
$delimiter = ', ';
}
return $authorizationHeader;
}
|
php
|
protected function buildAuthorizationHeaderForAPIRequest(
$method,
Url $uri,
TokenInterface $token,
$bodyParams = null
) {
$this->signature->setTokenSecret($token->getAccessTokenSecret());
$authParameters = $this->getBasicAuthorizationHeaderInfo();
if (isset($authParameters[ 'oauth_callback' ])) {
unset($authParameters[ 'oauth_callback' ]);
}
$authParameters = array_merge($authParameters, ['oauth_token' => $token->getAccessToken()]);
$signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters;
$authParameters[ 'oauth_signature' ] = $this->signature->getSignature($uri, $signatureParams, $method);
$authorizationHeader = 'OAuth ';
$delimiter = '';
foreach ($authParameters as $key => $value) {
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
$delimiter = ', ';
}
return $authorizationHeader;
}
|
[
"protected",
"function",
"buildAuthorizationHeaderForAPIRequest",
"(",
"$",
"method",
",",
"Url",
"$",
"uri",
",",
"TokenInterface",
"$",
"token",
",",
"$",
"bodyParams",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"signature",
"->",
"setTokenSecret",
"(",
"$",
"token",
"->",
"getAccessTokenSecret",
"(",
")",
")",
";",
"$",
"authParameters",
"=",
"$",
"this",
"->",
"getBasicAuthorizationHeaderInfo",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"authParameters",
"[",
"'oauth_callback'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"authParameters",
"[",
"'oauth_callback'",
"]",
")",
";",
"}",
"$",
"authParameters",
"=",
"array_merge",
"(",
"$",
"authParameters",
",",
"[",
"'oauth_token'",
"=>",
"$",
"token",
"->",
"getAccessToken",
"(",
")",
"]",
")",
";",
"$",
"signatureParams",
"=",
"(",
"is_array",
"(",
"$",
"bodyParams",
")",
")",
"?",
"array_merge",
"(",
"$",
"authParameters",
",",
"$",
"bodyParams",
")",
":",
"$",
"authParameters",
";",
"$",
"authParameters",
"[",
"'oauth_signature'",
"]",
"=",
"$",
"this",
"->",
"signature",
"->",
"getSignature",
"(",
"$",
"uri",
",",
"$",
"signatureParams",
",",
"$",
"method",
")",
";",
"$",
"authorizationHeader",
"=",
"'OAuth '",
";",
"$",
"delimiter",
"=",
"''",
";",
"foreach",
"(",
"$",
"authParameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"authorizationHeader",
".=",
"$",
"delimiter",
".",
"rawurlencode",
"(",
"$",
"key",
")",
".",
"'=\"'",
".",
"rawurlencode",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"$",
"delimiter",
"=",
"', '",
";",
"}",
"return",
"$",
"authorizationHeader",
";",
"}"
] |
Builds the authorization header for an authenticated API request
@param string $method
@param Url $uri The uri the request is headed
@param TokenInterface $token
@param array $bodyParams Request body if applicable (key/value pairs)
@return string
|
[
"Builds",
"the",
"authorization",
"header",
"for",
"an",
"authenticated",
"API",
"request"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/OAuth1/Service/AbstractService.php#L204-L230
|
224,364
|
logical-and/php-oauth
|
src/OAuth1/Service/AbstractService.php
|
AbstractService.getBasicAuthorizationHeaderInfo
|
protected function getBasicAuthorizationHeaderInfo()
{
$dateTime = new \DateTime();
$headerParameters = [
'oauth_callback' => $this->credentials->getCallbackUrl(),
'oauth_consumer_key' => $this->credentials->getConsumerId(),
'oauth_nonce' => $this->generateNonce(),
'oauth_signature_method' => $this->getSignatureMethod(),
'oauth_timestamp' => $dateTime->format('U'),
'oauth_version' => $this->getVersion(),
];
return $headerParameters;
}
|
php
|
protected function getBasicAuthorizationHeaderInfo()
{
$dateTime = new \DateTime();
$headerParameters = [
'oauth_callback' => $this->credentials->getCallbackUrl(),
'oauth_consumer_key' => $this->credentials->getConsumerId(),
'oauth_nonce' => $this->generateNonce(),
'oauth_signature_method' => $this->getSignatureMethod(),
'oauth_timestamp' => $dateTime->format('U'),
'oauth_version' => $this->getVersion(),
];
return $headerParameters;
}
|
[
"protected",
"function",
"getBasicAuthorizationHeaderInfo",
"(",
")",
"{",
"$",
"dateTime",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"headerParameters",
"=",
"[",
"'oauth_callback'",
"=>",
"$",
"this",
"->",
"credentials",
"->",
"getCallbackUrl",
"(",
")",
",",
"'oauth_consumer_key'",
"=>",
"$",
"this",
"->",
"credentials",
"->",
"getConsumerId",
"(",
")",
",",
"'oauth_nonce'",
"=>",
"$",
"this",
"->",
"generateNonce",
"(",
")",
",",
"'oauth_signature_method'",
"=>",
"$",
"this",
"->",
"getSignatureMethod",
"(",
")",
",",
"'oauth_timestamp'",
"=>",
"$",
"dateTime",
"->",
"format",
"(",
"'U'",
")",
",",
"'oauth_version'",
"=>",
"$",
"this",
"->",
"getVersion",
"(",
")",
",",
"]",
";",
"return",
"$",
"headerParameters",
";",
"}"
] |
Builds the authorization header array.
@return array
|
[
"Builds",
"the",
"authorization",
"header",
"array",
"."
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/OAuth1/Service/AbstractService.php#L237-L250
|
224,365
|
logical-and/php-oauth
|
src/OAuth1/Service/AbstractService.php
|
AbstractService.generateNonce
|
protected function generateNonce($length = 32)
{
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$nonce = '';
$maxRand = strlen($characters) - 1;
for ($i = 0; $i < $length; $i++) {
$nonce .= $characters[ rand(0, $maxRand) ];
}
return $nonce;
}
|
php
|
protected function generateNonce($length = 32)
{
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$nonce = '';
$maxRand = strlen($characters) - 1;
for ($i = 0; $i < $length; $i++) {
$nonce .= $characters[ rand(0, $maxRand) ];
}
return $nonce;
}
|
[
"protected",
"function",
"generateNonce",
"(",
"$",
"length",
"=",
"32",
")",
"{",
"$",
"characters",
"=",
"'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'",
";",
"$",
"nonce",
"=",
"''",
";",
"$",
"maxRand",
"=",
"strlen",
"(",
"$",
"characters",
")",
"-",
"1",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"nonce",
".=",
"$",
"characters",
"[",
"rand",
"(",
"0",
",",
"$",
"maxRand",
")",
"]",
";",
"}",
"return",
"$",
"nonce",
";",
"}"
] |
Pseudo random string generator used to build a unique string to sign each request
@param int $length
@return string
|
[
"Pseudo",
"random",
"string",
"generator",
"used",
"to",
"build",
"a",
"unique",
"string",
"to",
"sign",
"each",
"request"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/OAuth1/Service/AbstractService.php#L259-L270
|
224,366
|
turtledesign/royalmail-php
|
src/Connector/soapConnector.php
|
soapConnector.doRequest
|
function doRequest($action, $params = [], $config = []) {
$this->request_input = ['action' => $action, 'parameters' => $params];
return $this->getSoapClient($config)->__soapCall($action, [$params]);
}
|
php
|
function doRequest($action, $params = [], $config = []) {
$this->request_input = ['action' => $action, 'parameters' => $params];
return $this->getSoapClient($config)->__soapCall($action, [$params]);
}
|
[
"function",
"doRequest",
"(",
"$",
"action",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"request_input",
"=",
"[",
"'action'",
"=>",
"$",
"action",
",",
"'parameters'",
"=>",
"$",
"params",
"]",
";",
"return",
"$",
"this",
"->",
"getSoapClient",
"(",
"$",
"config",
")",
"->",
"__soapCall",
"(",
"$",
"action",
",",
"[",
"$",
"params",
"]",
")",
";",
"}"
] |
Send off the request to the Royal Mail API
@see baseConnector::doRequest()
@return \RoyalMail\Response\baseResponse Response class for the request sent.
|
[
"Send",
"off",
"the",
"request",
"to",
"the",
"Royal",
"Mail",
"API"
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Connector/soapConnector.php#L35-L39
|
224,367
|
appkr/api
|
src/Commands/OptionParser.php
|
OptionParser.parseSegments
|
private function parseSegments($field)
{
$field = starts_with('\\', $field) ? $field : '\\' . $field;
$segments = explode(':', $field);
if (count($segments) < 2) {
throw new \Exception(
'--includes option should be consist of string value of model, separated by colon(:),
and string value of relationship. e.g. App\User:author, App\Comment:comments:true.
If the third element is provided as true, yes, or 1, the command will interpret the include as an collection.'
);
}
$fqcn = array_shift($segments);
$relationship = array_shift($segments);
$type = in_array(array_shift($segments), ['yes', 'y', 'true', true, '1', 1])
? 'collection' : 'item';
$namespace = config('api.transformer.namespace');
$namespace = (starts_with($namespace, '\\') ? $namespace : '\\' . $namespace);
$namespace = (ends_with($namespace, '\\') ? $namespace : $namespace . '\\');
$obj = new \stdClass;
$obj->type = $type;
$obj->fqcn = $fqcn;
$obj->model = ltrim($fqcn, '\\');
$obj->basename = class_basename($fqcn);
$obj->relationship = $relationship;
$obj->method = 'include' . ucfirst($relationship);
$obj->transformer = $namespace . ucfirst($obj->basename) . 'Transformer';
return $obj;
}
|
php
|
private function parseSegments($field)
{
$field = starts_with('\\', $field) ? $field : '\\' . $field;
$segments = explode(':', $field);
if (count($segments) < 2) {
throw new \Exception(
'--includes option should be consist of string value of model, separated by colon(:),
and string value of relationship. e.g. App\User:author, App\Comment:comments:true.
If the third element is provided as true, yes, or 1, the command will interpret the include as an collection.'
);
}
$fqcn = array_shift($segments);
$relationship = array_shift($segments);
$type = in_array(array_shift($segments), ['yes', 'y', 'true', true, '1', 1])
? 'collection' : 'item';
$namespace = config('api.transformer.namespace');
$namespace = (starts_with($namespace, '\\') ? $namespace : '\\' . $namespace);
$namespace = (ends_with($namespace, '\\') ? $namespace : $namespace . '\\');
$obj = new \stdClass;
$obj->type = $type;
$obj->fqcn = $fqcn;
$obj->model = ltrim($fqcn, '\\');
$obj->basename = class_basename($fqcn);
$obj->relationship = $relationship;
$obj->method = 'include' . ucfirst($relationship);
$obj->transformer = $namespace . ucfirst($obj->basename) . 'Transformer';
return $obj;
}
|
[
"private",
"function",
"parseSegments",
"(",
"$",
"field",
")",
"{",
"$",
"field",
"=",
"starts_with",
"(",
"'\\\\'",
",",
"$",
"field",
")",
"?",
"$",
"field",
":",
"'\\\\'",
".",
"$",
"field",
";",
"$",
"segments",
"=",
"explode",
"(",
"':'",
",",
"$",
"field",
")",
";",
"if",
"(",
"count",
"(",
"$",
"segments",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'--includes option should be consist of string value of model, separated by colon(:),\n and string value of relationship. e.g. App\\User:author, App\\Comment:comments:true.\n If the third element is provided as true, yes, or 1, the command will interpret the include as an collection.'",
")",
";",
"}",
"$",
"fqcn",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"$",
"relationship",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"$",
"type",
"=",
"in_array",
"(",
"array_shift",
"(",
"$",
"segments",
")",
",",
"[",
"'yes'",
",",
"'y'",
",",
"'true'",
",",
"true",
",",
"'1'",
",",
"1",
"]",
")",
"?",
"'collection'",
":",
"'item'",
";",
"$",
"namespace",
"=",
"config",
"(",
"'api.transformer.namespace'",
")",
";",
"$",
"namespace",
"=",
"(",
"starts_with",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
"?",
"$",
"namespace",
":",
"'\\\\'",
".",
"$",
"namespace",
")",
";",
"$",
"namespace",
"=",
"(",
"ends_with",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
"?",
"$",
"namespace",
":",
"$",
"namespace",
".",
"'\\\\'",
")",
";",
"$",
"obj",
"=",
"new",
"\\",
"stdClass",
";",
"$",
"obj",
"->",
"type",
"=",
"$",
"type",
";",
"$",
"obj",
"->",
"fqcn",
"=",
"$",
"fqcn",
";",
"$",
"obj",
"->",
"model",
"=",
"ltrim",
"(",
"$",
"fqcn",
",",
"'\\\\'",
")",
";",
"$",
"obj",
"->",
"basename",
"=",
"class_basename",
"(",
"$",
"fqcn",
")",
";",
"$",
"obj",
"->",
"relationship",
"=",
"$",
"relationship",
";",
"$",
"obj",
"->",
"method",
"=",
"'include'",
".",
"ucfirst",
"(",
"$",
"relationship",
")",
";",
"$",
"obj",
"->",
"transformer",
"=",
"$",
"namespace",
".",
"ucfirst",
"(",
"$",
"obj",
"->",
"basename",
")",
".",
"'Transformer'",
";",
"return",
"$",
"obj",
";",
"}"
] |
Get the segments of the option field.
@param string $field
@return array
@throws \Exception
|
[
"Get",
"the",
"segments",
"of",
"the",
"option",
"field",
"."
] |
5b676f6cf3bc74c9e429226c87505f7455700716
|
https://github.com/appkr/api/blob/5b676f6cf3bc74c9e429226c87505f7455700716/src/Commands/OptionParser.php#L53-L86
|
224,368
|
JeffreyHyer/bamboohr
|
src/Api/Company.php
|
Company.updateFile
|
public function updateFile($fileId, array $data)
{
$xml = "<file>";
if (isset($data['name'])) {
$xml .= "<name>{$data['name']}</name>";
}
if (isset($data['categoryId'])) {
$xml .= "<categoryId>{$data['categoryId']}</categoryId>";
}
if (isset($data['shareWithEmployee'])) {
$xml .= "<shareWithEmployee>{$data['shareWithEmployee']}</shareWithEmployee>";
}
$xml .= "</file>";
return $this->post("files/{$fileId}", $xml);
}
|
php
|
public function updateFile($fileId, array $data)
{
$xml = "<file>";
if (isset($data['name'])) {
$xml .= "<name>{$data['name']}</name>";
}
if (isset($data['categoryId'])) {
$xml .= "<categoryId>{$data['categoryId']}</categoryId>";
}
if (isset($data['shareWithEmployee'])) {
$xml .= "<shareWithEmployee>{$data['shareWithEmployee']}</shareWithEmployee>";
}
$xml .= "</file>";
return $this->post("files/{$fileId}", $xml);
}
|
[
"public",
"function",
"updateFile",
"(",
"$",
"fileId",
",",
"array",
"$",
"data",
")",
"{",
"$",
"xml",
"=",
"\"<file>\"",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\"<name>{$data['name']}</name>\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'categoryId'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\"<categoryId>{$data['categoryId']}</categoryId>\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'shareWithEmployee'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\"<shareWithEmployee>{$data['shareWithEmployee']}</shareWithEmployee>\"",
";",
"}",
"$",
"xml",
".=",
"\"</file>\"",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"\"files/{$fileId}\"",
",",
"$",
"xml",
")",
";",
"}"
] |
Update a given file
@param string $fileId
@param array $data ['name' => string, 'categoryId' => integer, 'shareWithEmployee' => 'yes|no']
@return BambooHR\Api\Response
|
[
"Update",
"a",
"given",
"file"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/Company.php#L40-L59
|
224,369
|
logical-and/php-oauth
|
src/UserData/Extractor/LazyExtractor.php
|
LazyExtractor.getLoaderData
|
protected function getLoaderData($field)
{
$loaderName = $this->loadersMap->getLoaderForField($field);
if (!isset($this->loadersResults[ $loaderName ])) {
$this->loadersResults[ $loaderName ] = $this->{sprintf('%sLoader', $loaderName)}();
}
return $this->loadersResults[ $loaderName ];
}
|
php
|
protected function getLoaderData($field)
{
$loaderName = $this->loadersMap->getLoaderForField($field);
if (!isset($this->loadersResults[ $loaderName ])) {
$this->loadersResults[ $loaderName ] = $this->{sprintf('%sLoader', $loaderName)}();
}
return $this->loadersResults[ $loaderName ];
}
|
[
"protected",
"function",
"getLoaderData",
"(",
"$",
"field",
")",
"{",
"$",
"loaderName",
"=",
"$",
"this",
"->",
"loadersMap",
"->",
"getLoaderForField",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"loadersResults",
"[",
"$",
"loaderName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"loadersResults",
"[",
"$",
"loaderName",
"]",
"=",
"$",
"this",
"->",
"{",
"sprintf",
"(",
"'%sLoader'",
",",
"$",
"loaderName",
")",
"}",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"loadersResults",
"[",
"$",
"loaderName",
"]",
";",
"}"
] |
Get data from a loader.
A loader is a function who is delegated to fetch a request to get the raw data
@param string $field
@return mixed
|
[
"Get",
"data",
"from",
"a",
"loader",
".",
"A",
"loader",
"is",
"a",
"function",
"who",
"is",
"delegated",
"to",
"fetch",
"a",
"request",
"to",
"get",
"the",
"raw",
"data"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Extractor/LazyExtractor.php#L141-L149
|
224,370
|
logical-and/php-oauth
|
src/UserData/Extractor/LazyExtractor.php
|
LazyExtractor.extraNormalizer
|
protected function extraNormalizer($data, $path = '')
{
if (is_array($data)) {
if (!$path) {
$path = $this->normalizersMap->getPathContext();
}
$path = trim($path, '.');
$pathsFields = [];
foreach ($this->normalizersMap->getPathNormalizers() as $normalizer) {
$pathsFields[ ] = $normalizer[ 'pathWithoutContext' ];
}
// Remove all paths fields
return ArrayUtils::removeKeys(ArrayUtils::getNested($data, $path, []), $pathsFields);
}
return [];
}
|
php
|
protected function extraNormalizer($data, $path = '')
{
if (is_array($data)) {
if (!$path) {
$path = $this->normalizersMap->getPathContext();
}
$path = trim($path, '.');
$pathsFields = [];
foreach ($this->normalizersMap->getPathNormalizers() as $normalizer) {
$pathsFields[ ] = $normalizer[ 'pathWithoutContext' ];
}
// Remove all paths fields
return ArrayUtils::removeKeys(ArrayUtils::getNested($data, $path, []), $pathsFields);
}
return [];
}
|
[
"protected",
"function",
"extraNormalizer",
"(",
"$",
"data",
",",
"$",
"path",
"=",
"''",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"normalizersMap",
"->",
"getPathContext",
"(",
")",
";",
"}",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
",",
"'.'",
")",
";",
"$",
"pathsFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"normalizersMap",
"->",
"getPathNormalizers",
"(",
")",
"as",
"$",
"normalizer",
")",
"{",
"$",
"pathsFields",
"[",
"]",
"=",
"$",
"normalizer",
"[",
"'pathWithoutContext'",
"]",
";",
"}",
"// Remove all paths fields",
"return",
"ArrayUtils",
"::",
"removeKeys",
"(",
"ArrayUtils",
"::",
"getNested",
"(",
"$",
"data",
",",
"$",
"path",
",",
"[",
"]",
")",
",",
"$",
"pathsFields",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Generic "extra normalizer"
@param $data
@param string $path To be overridden
@return array
|
[
"Generic",
"extra",
"normalizer"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Extractor/LazyExtractor.php#L181-L199
|
224,371
|
ericmann/sessionz
|
php/Manager.php
|
Manager.seedHandlerStack
|
protected function seedHandlerStack()
{
if (!is_null($this->handlers)) {
throw new \RuntimeException('Handler stacks can only be seeded once.');
}
$this->stacks = [];
$base = new BaseHandler();
$this->handlers = [$base];
$this->stacks['delete'] = new \SplStack();
$this->stacks['clean'] = new \SplStack();
$this->stacks['create'] = new \SplStack();
$this->stacks['read'] = new \SplStack();
$this->stacks['write'] = new \SplStack();
foreach($this->stacks as $id => $stack) {
$stack->setIteratorMode(\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_KEEP);
$stack[] = array( $base, $id );
}
}
|
php
|
protected function seedHandlerStack()
{
if (!is_null($this->handlers)) {
throw new \RuntimeException('Handler stacks can only be seeded once.');
}
$this->stacks = [];
$base = new BaseHandler();
$this->handlers = [$base];
$this->stacks['delete'] = new \SplStack();
$this->stacks['clean'] = new \SplStack();
$this->stacks['create'] = new \SplStack();
$this->stacks['read'] = new \SplStack();
$this->stacks['write'] = new \SplStack();
foreach($this->stacks as $id => $stack) {
$stack->setIteratorMode(\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_KEEP);
$stack[] = array( $base, $id );
}
}
|
[
"protected",
"function",
"seedHandlerStack",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"handlers",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Handler stacks can only be seeded once.'",
")",
";",
"}",
"$",
"this",
"->",
"stacks",
"=",
"[",
"]",
";",
"$",
"base",
"=",
"new",
"BaseHandler",
"(",
")",
";",
"$",
"this",
"->",
"handlers",
"=",
"[",
"$",
"base",
"]",
";",
"$",
"this",
"->",
"stacks",
"[",
"'delete'",
"]",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'clean'",
"]",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'create'",
"]",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'read'",
"]",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'write'",
"]",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"stacks",
"as",
"$",
"id",
"=>",
"$",
"stack",
")",
"{",
"$",
"stack",
"->",
"setIteratorMode",
"(",
"\\",
"SplDoublyLinkedList",
"::",
"IT_MODE_LIFO",
"|",
"\\",
"SplDoublyLinkedList",
"::",
"IT_MODE_KEEP",
")",
";",
"$",
"stack",
"[",
"]",
"=",
"array",
"(",
"$",
"base",
",",
"$",
"id",
")",
";",
"}",
"}"
] |
Seed handler stack with first callable
@throws \RuntimeException if the stack is seeded more than once
|
[
"Seed",
"handler",
"stack",
"with",
"first",
"callable"
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Manager.php#L99-L118
|
224,372
|
ericmann/sessionz
|
php/Manager.php
|
Manager.initialize
|
public static function initialize()
{
$manager = self::$manager = new self();
$manager->seedHandlerStack();
session_set_save_handler($manager);
return $manager;
}
|
php
|
public static function initialize()
{
$manager = self::$manager = new self();
$manager->seedHandlerStack();
session_set_save_handler($manager);
return $manager;
}
|
[
"public",
"static",
"function",
"initialize",
"(",
")",
"{",
"$",
"manager",
"=",
"self",
"::",
"$",
"manager",
"=",
"new",
"self",
"(",
")",
";",
"$",
"manager",
"->",
"seedHandlerStack",
"(",
")",
";",
"session_set_save_handler",
"(",
"$",
"manager",
")",
";",
"return",
"$",
"manager",
";",
"}"
] |
Initialize the session manager.
Invoking this function multiple times will reset the manager itself
and purge any handlers already registered with the system.
@return Manager
|
[
"Initialize",
"the",
"session",
"manager",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Manager.php#L128-L136
|
224,373
|
ericmann/sessionz
|
php/Manager.php
|
Manager.close
|
public function close()
{
$this->handlerLock = true;
while (count($this->handlers) > 0) {
array_pop($this->handlers);
$this->stacks['delete']->pop();
$this->stacks['clean']->pop();
$this->stacks['create']->pop();
$this->stacks['read']->pop();
$this->stacks['write']->pop();
}
$this->handlerLock = false;
return true;
}
|
php
|
public function close()
{
$this->handlerLock = true;
while (count($this->handlers) > 0) {
array_pop($this->handlers);
$this->stacks['delete']->pop();
$this->stacks['clean']->pop();
$this->stacks['create']->pop();
$this->stacks['read']->pop();
$this->stacks['write']->pop();
}
$this->handlerLock = false;
return true;
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"$",
"this",
"->",
"handlerLock",
"=",
"true",
";",
"while",
"(",
"count",
"(",
"$",
"this",
"->",
"handlers",
")",
">",
"0",
")",
"{",
"array_pop",
"(",
"$",
"this",
"->",
"handlers",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'delete'",
"]",
"->",
"pop",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'clean'",
"]",
"->",
"pop",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'create'",
"]",
"->",
"pop",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'read'",
"]",
"->",
"pop",
"(",
")",
";",
"$",
"this",
"->",
"stacks",
"[",
"'write'",
"]",
"->",
"pop",
"(",
")",
";",
"}",
"$",
"this",
"->",
"handlerLock",
"=",
"false",
";",
"return",
"true",
";",
"}"
] |
Close the current session.
Will iterate through all handlers registered to the manager and
remove them from the stack. This has the effect of removing the
objects from scope and triggering their destructors. Any cleanup
should happen there.
@return true
|
[
"Close",
"the",
"current",
"session",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Manager.php#L148-L163
|
224,374
|
ericmann/sessionz
|
php/Manager.php
|
Manager.destroy
|
public function destroy($session_id)
{
if (is_null($this->handlers)) {
$this->seedHandlerStack();
}
/** @var callable $start */
$start = $this->stacks['delete']->top();
$this->handlerLock = true;
$data = $start($session_id);
$this->handlerLock = false;
return $data;
}
|
php
|
public function destroy($session_id)
{
if (is_null($this->handlers)) {
$this->seedHandlerStack();
}
/** @var callable $start */
$start = $this->stacks['delete']->top();
$this->handlerLock = true;
$data = $start($session_id);
$this->handlerLock = false;
return $data;
}
|
[
"public",
"function",
"destroy",
"(",
"$",
"session_id",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"handlers",
")",
")",
"{",
"$",
"this",
"->",
"seedHandlerStack",
"(",
")",
";",
"}",
"/** @var callable $start */",
"$",
"start",
"=",
"$",
"this",
"->",
"stacks",
"[",
"'delete'",
"]",
"->",
"top",
"(",
")",
";",
"$",
"this",
"->",
"handlerLock",
"=",
"true",
";",
"$",
"data",
"=",
"$",
"start",
"(",
"$",
"session_id",
")",
";",
"$",
"this",
"->",
"handlerLock",
"=",
"false",
";",
"return",
"$",
"data",
";",
"}"
] |
Destroy a session by either invalidating it or forcibly removing
it from session storage.
@param string $session_id ID of the session to destroy.
@return bool
|
[
"Destroy",
"a",
"session",
"by",
"either",
"invalidating",
"it",
"or",
"forcibly",
"removing",
"it",
"from",
"session",
"storage",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Manager.php#L173-L185
|
224,375
|
ericmann/sessionz
|
php/Manager.php
|
Manager.open
|
public function open($save_path, $name)
{
if (is_null($this->handlers)) {
$this->seedHandlerStack();
}
/** @var callable $start */
$start = $this->stacks['create']->top();
$this->handlerLock = true;
$data = $start($save_path, $name);
$this->handlerLock = false;
return $data;
}
|
php
|
public function open($save_path, $name)
{
if (is_null($this->handlers)) {
$this->seedHandlerStack();
}
/** @var callable $start */
$start = $this->stacks['create']->top();
$this->handlerLock = true;
$data = $start($save_path, $name);
$this->handlerLock = false;
return $data;
}
|
[
"public",
"function",
"open",
"(",
"$",
"save_path",
",",
"$",
"name",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"handlers",
")",
")",
"{",
"$",
"this",
"->",
"seedHandlerStack",
"(",
")",
";",
"}",
"/** @var callable $start */",
"$",
"start",
"=",
"$",
"this",
"->",
"stacks",
"[",
"'create'",
"]",
"->",
"top",
"(",
")",
";",
"$",
"this",
"->",
"handlerLock",
"=",
"true",
";",
"$",
"data",
"=",
"$",
"start",
"(",
"$",
"save_path",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"handlerLock",
"=",
"false",
";",
"return",
"$",
"data",
";",
"}"
] |
Create a new session storage.
@param string $save_path File location/path where sessions should be written.
@param string $name Unique name of the storage instance.
@return bool
|
[
"Create",
"a",
"new",
"session",
"storage",
"."
] |
b1a278c54aa13035ed0ca0c297fb117d04036d9b
|
https://github.com/ericmann/sessionz/blob/b1a278c54aa13035ed0ca0c297fb117d04036d9b/php/Manager.php#L217-L229
|
224,376
|
logical-and/php-oauth
|
src/UserData/Extractor/Extractor.php
|
Extractor.getField
|
protected function getField($field)
{
if ($this->isFieldSupported($field) && isset($this->fields[ $field ])) {
return $this->fields[ $field ];
}
return null;
}
|
php
|
protected function getField($field)
{
if ($this->isFieldSupported($field) && isset($this->fields[ $field ])) {
return $this->fields[ $field ];
}
return null;
}
|
[
"protected",
"function",
"getField",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFieldSupported",
"(",
"$",
"field",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the value for a given field
@param string $field the name of the field
@return null|mixed
|
[
"Get",
"the",
"value",
"for",
"a",
"given",
"field"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Extractor/Extractor.php#L377-L384
|
224,377
|
logical-and/php-oauth
|
src/UserData/Extractor/Extractor.php
|
Extractor.getAllFields
|
protected static function getAllFields()
{
return FieldsValues::construct(
[
self::FIELD_UNIQUE_ID,
self::FIELD_USERNAME,
self::FIELD_FIRST_NAME,
self::FIELD_LAST_NAME,
self::FIELD_FULL_NAME,
self::FIELD_EMAIL,
self::FIELD_DESCRIPTION,
self::FIELD_LOCATION,
self::FIELD_PROFILE_URL,
self::FIELD_IMAGE_URL,
self::FIELD_WEBSITES,
self::FIELD_VERIFIED_EMAIL,
self::FIELD_EXTRA
]
);
}
|
php
|
protected static function getAllFields()
{
return FieldsValues::construct(
[
self::FIELD_UNIQUE_ID,
self::FIELD_USERNAME,
self::FIELD_FIRST_NAME,
self::FIELD_LAST_NAME,
self::FIELD_FULL_NAME,
self::FIELD_EMAIL,
self::FIELD_DESCRIPTION,
self::FIELD_LOCATION,
self::FIELD_PROFILE_URL,
self::FIELD_IMAGE_URL,
self::FIELD_WEBSITES,
self::FIELD_VERIFIED_EMAIL,
self::FIELD_EXTRA
]
);
}
|
[
"protected",
"static",
"function",
"getAllFields",
"(",
")",
"{",
"return",
"FieldsValues",
"::",
"construct",
"(",
"[",
"self",
"::",
"FIELD_UNIQUE_ID",
",",
"self",
"::",
"FIELD_USERNAME",
",",
"self",
"::",
"FIELD_FIRST_NAME",
",",
"self",
"::",
"FIELD_LAST_NAME",
",",
"self",
"::",
"FIELD_FULL_NAME",
",",
"self",
"::",
"FIELD_EMAIL",
",",
"self",
"::",
"FIELD_DESCRIPTION",
",",
"self",
"::",
"FIELD_LOCATION",
",",
"self",
"::",
"FIELD_PROFILE_URL",
",",
"self",
"::",
"FIELD_IMAGE_URL",
",",
"self",
"::",
"FIELD_WEBSITES",
",",
"self",
"::",
"FIELD_VERIFIED_EMAIL",
",",
"self",
"::",
"FIELD_EXTRA",
"]",
")",
";",
"}"
] |
Get an array listing all fields names
@return FieldsValues
|
[
"Get",
"an",
"array",
"listing",
"all",
"fields",
"names"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Extractor/Extractor.php#L403-L422
|
224,378
|
JeffreyHyer/bamboohr
|
src/Api/TimeOff.php
|
TimeOff.submitRequest
|
public function submitRequest($employeeId, array $data = [])
{
$xml = "<request>";
if (isset($data['status'])) {
$xml .= "<status>{$data['status']}</status>";
} else {
$xml .= "<status>requested</status>";
}
$xml .= "<start>{$data['start']}</start>
<end>{$data['end']}</end>
<timeOffTypeId>{$data['timeOffTypeId']}</timeOffTypeId>
<amount>{$data['amount']}</amount>";
if (isset($data['notes'])) {
$xml .= "<notes><note from=\"employee\">{$data['notes']}</note></notes>";
}
$xml .= "<dates>";
foreach ($data['dates'] as $date => $hours) {
$xml .= "<date ymd=\"{$date}\" amount=\"{$hours}\" />";
}
$xml .= "</dates>";
if (isset($data['previousRequest'])) {
$xml .="<previousRequest>{$data['previousRequest']}</previousRequest>";
}
$xml .= "</request>";
return $this->put("employees/{$employeeId}/time_off/request", $xml);
}
|
php
|
public function submitRequest($employeeId, array $data = [])
{
$xml = "<request>";
if (isset($data['status'])) {
$xml .= "<status>{$data['status']}</status>";
} else {
$xml .= "<status>requested</status>";
}
$xml .= "<start>{$data['start']}</start>
<end>{$data['end']}</end>
<timeOffTypeId>{$data['timeOffTypeId']}</timeOffTypeId>
<amount>{$data['amount']}</amount>";
if (isset($data['notes'])) {
$xml .= "<notes><note from=\"employee\">{$data['notes']}</note></notes>";
}
$xml .= "<dates>";
foreach ($data['dates'] as $date => $hours) {
$xml .= "<date ymd=\"{$date}\" amount=\"{$hours}\" />";
}
$xml .= "</dates>";
if (isset($data['previousRequest'])) {
$xml .="<previousRequest>{$data['previousRequest']}</previousRequest>";
}
$xml .= "</request>";
return $this->put("employees/{$employeeId}/time_off/request", $xml);
}
|
[
"public",
"function",
"submitRequest",
"(",
"$",
"employeeId",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"xml",
"=",
"\"<request>\"",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'status'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\"<status>{$data['status']}</status>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<status>requested</status>\"",
";",
"}",
"$",
"xml",
".=",
"\"<start>{$data['start']}</start>\n <end>{$data['end']}</end>\n <timeOffTypeId>{$data['timeOffTypeId']}</timeOffTypeId>\n <amount>{$data['amount']}</amount>\"",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'notes'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\"<notes><note from=\\\"employee\\\">{$data['notes']}</note></notes>\"",
";",
"}",
"$",
"xml",
".=",
"\"<dates>\"",
";",
"foreach",
"(",
"$",
"data",
"[",
"'dates'",
"]",
"as",
"$",
"date",
"=>",
"$",
"hours",
")",
"{",
"$",
"xml",
".=",
"\"<date ymd=\\\"{$date}\\\" amount=\\\"{$hours}\\\" />\"",
";",
"}",
"$",
"xml",
".=",
"\"</dates>\"",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'previousRequest'",
"]",
")",
")",
"{",
"$",
"xml",
".=",
"\"<previousRequest>{$data['previousRequest']}</previousRequest>\"",
";",
"}",
"$",
"xml",
".=",
"\"</request>\"",
";",
"return",
"$",
"this",
"->",
"put",
"(",
"\"employees/{$employeeId}/time_off/request\"",
",",
"$",
"xml",
")",
";",
"}"
] |
Submit a new time off request for a given employeeId
@param string $employeeId
@param array $data An array of data describing the time off request
[
'start' => [ISO-8601 Date],
'end' => [ISO-8601 Date],
'timeOffTypeId' => [integer], // Comes from the Metadata API...
'amount' => [integer], // Ignored if 'dates' is provided below
'notes' => [string],
'dates' => [
'YYYY-MM-DD' => [integer] // Number of hours to request for the given date
],
'previousRequest' => [integer]
]
@return BambooHR\Api\Response
|
[
"Submit",
"a",
"new",
"time",
"off",
"request",
"for",
"a",
"given",
"employeeId"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/TimeOff.php#L46-L80
|
224,379
|
JeffreyHyer/bamboohr
|
src/Api/TimeOff.php
|
TimeOff.addHistoryEntry
|
public function addHistoryEntry($employeeId, $requestId, string $date, string $note)
{
$xml = "
<history>
<date>{$date}</date>
<eventType>used</eventType>
<timeOffRequestId>{$requestId}</timeOffRequestId>
<note>{$note}</note>
</history>
";
$this->put("employees/{$employeeId}/time_off/history", $xml);
}
|
php
|
public function addHistoryEntry($employeeId, $requestId, string $date, string $note)
{
$xml = "
<history>
<date>{$date}</date>
<eventType>used</eventType>
<timeOffRequestId>{$requestId}</timeOffRequestId>
<note>{$note}</note>
</history>
";
$this->put("employees/{$employeeId}/time_off/history", $xml);
}
|
[
"public",
"function",
"addHistoryEntry",
"(",
"$",
"employeeId",
",",
"$",
"requestId",
",",
"string",
"$",
"date",
",",
"string",
"$",
"note",
")",
"{",
"$",
"xml",
"=",
"\"\n <history>\n <date>{$date}</date>\n <eventType>used</eventType>\n <timeOffRequestId>{$requestId}</timeOffRequestId>\n <note>{$note}</note>\n </history>\n \"",
";",
"$",
"this",
"->",
"put",
"(",
"\"employees/{$employeeId}/time_off/history\"",
",",
"$",
"xml",
")",
";",
"}"
] |
Add a time off history entry
@param string $employeeId
@param string $requestId
@param string $date
@param string $note
@return \BambooHR\Api\Response
|
[
"Add",
"a",
"time",
"off",
"history",
"entry"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/TimeOff.php#L113-L125
|
224,380
|
JeffreyHyer/bamboohr
|
src/Api/TimeOff.php
|
TimeOff.assignedPolicies
|
public function assignedPolicies($employeeId)
{
$this->bamboo->options['version'] = 'v1_1';
$response = $this->get("employees/{$employeeId}/time_off/policies");
$this->bamboo->options['version'] = 'v1';
return $response;
}
|
php
|
public function assignedPolicies($employeeId)
{
$this->bamboo->options['version'] = 'v1_1';
$response = $this->get("employees/{$employeeId}/time_off/policies");
$this->bamboo->options['version'] = 'v1';
return $response;
}
|
[
"public",
"function",
"assignedPolicies",
"(",
"$",
"employeeId",
")",
"{",
"$",
"this",
"->",
"bamboo",
"->",
"options",
"[",
"'version'",
"]",
"=",
"'v1_1'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"get",
"(",
"\"employees/{$employeeId}/time_off/policies\"",
")",
";",
"$",
"this",
"->",
"bamboo",
"->",
"options",
"[",
"'version'",
"]",
"=",
"'v1'",
";",
"return",
"$",
"response",
";",
"}"
] |
List assigned time off policies for a given employee
@param string $employeeId
@return \BambooHR\Api\Response
|
[
"List",
"assigned",
"time",
"off",
"policies",
"for",
"a",
"given",
"employee"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/TimeOff.php#L134-L143
|
224,381
|
JeffreyHyer/bamboohr
|
src/Api/TimeOff.php
|
TimeOff.assignPolicy
|
public function assignPolicy($employeeId, array $policies)
{
$this->bamboo->options['version'] = 'v1_1';
$response = $this->put("employees/{$employeeId}/time_off/policies", json_encode($policies));
$this->bamboo->options['version'] = 'v1';
return $response;
}
|
php
|
public function assignPolicy($employeeId, array $policies)
{
$this->bamboo->options['version'] = 'v1_1';
$response = $this->put("employees/{$employeeId}/time_off/policies", json_encode($policies));
$this->bamboo->options['version'] = 'v1';
return $response;
}
|
[
"public",
"function",
"assignPolicy",
"(",
"$",
"employeeId",
",",
"array",
"$",
"policies",
")",
"{",
"$",
"this",
"->",
"bamboo",
"->",
"options",
"[",
"'version'",
"]",
"=",
"'v1_1'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"put",
"(",
"\"employees/{$employeeId}/time_off/policies\"",
",",
"json_encode",
"(",
"$",
"policies",
")",
")",
";",
"$",
"this",
"->",
"bamboo",
"->",
"options",
"[",
"'version'",
"]",
"=",
"'v1'",
";",
"return",
"$",
"response",
";",
"}"
] |
Assign one or more time off policies to a given employee
@link https://www.bamboohr.com/api/documentation/time_off.php#assignTimeOffPolicies1.1
@param string $employeeId
@param array $policies
@return \BambooHR\Api\Response
|
[
"Assign",
"one",
"or",
"more",
"time",
"off",
"policies",
"to",
"a",
"given",
"employee"
] |
bdf8beab6573a818e906e4f0a3516b68f37c3b17
|
https://github.com/JeffreyHyer/bamboohr/blob/bdf8beab6573a818e906e4f0a3516b68f37c3b17/src/Api/TimeOff.php#L155-L164
|
224,382
|
oroinc/OroMessageQueueComponent
|
Transport/QueueCollection.php
|
QueueCollection.get
|
public function get($queueName)
{
if (!isset($this->queues[$queueName])) {
throw new \OutOfBoundsException(sprintf('The collection does not contain the queue "%s".', $queueName));
}
return $this->queues[$queueName];
}
|
php
|
public function get($queueName)
{
if (!isset($this->queues[$queueName])) {
throw new \OutOfBoundsException(sprintf('The collection does not contain the queue "%s".', $queueName));
}
return $this->queues[$queueName];
}
|
[
"public",
"function",
"get",
"(",
"$",
"queueName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"queueName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The collection does not contain the queue \"%s\".'",
",",
"$",
"queueName",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"queues",
"[",
"$",
"queueName",
"]",
";",
"}"
] |
Gets the queue by its name.
@param string $queueName
@return QueueInterface
|
[
"Gets",
"the",
"queue",
"by",
"its",
"name",
"."
] |
6f1fdb12aebcfc6beae074ce492f496ed9847a77
|
https://github.com/oroinc/OroMessageQueueComponent/blob/6f1fdb12aebcfc6beae074ce492f496ed9847a77/Transport/QueueCollection.php#L32-L39
|
224,383
|
oroinc/OroMessageQueueComponent
|
Transport/QueueCollection.php
|
QueueCollection.remove
|
public function remove($queueName)
{
$queue = null;
if (isset($this->queues[$queueName])) {
$queue = $this->queues[$queueName];
}
unset($this->queues[$queueName]);
return $queue;
}
|
php
|
public function remove($queueName)
{
$queue = null;
if (isset($this->queues[$queueName])) {
$queue = $this->queues[$queueName];
}
unset($this->queues[$queueName]);
return $queue;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"queueName",
")",
"{",
"$",
"queue",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"queueName",
"]",
")",
")",
"{",
"$",
"queue",
"=",
"$",
"this",
"->",
"queues",
"[",
"$",
"queueName",
"]",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"queueName",
"]",
")",
";",
"return",
"$",
"queue",
";",
"}"
] |
Removes the queue from the collection.
@param string $queueName
@return QueueInterface|null The removed queue or NULL,
if the collection did not contain a queue with the given name.
|
[
"Removes",
"the",
"queue",
"from",
"the",
"collection",
"."
] |
6f1fdb12aebcfc6beae074ce492f496ed9847a77
|
https://github.com/oroinc/OroMessageQueueComponent/blob/6f1fdb12aebcfc6beae074ce492f496ed9847a77/Transport/QueueCollection.php#L61-L70
|
224,384
|
turtledesign/royalmail-php
|
src/Filter/Filters.php
|
Filters.doSkipThisIfThatEmpty
|
static function doSkipThisIfThatEmpty($val, $settings, $helper = NULL) {
if (is_string($settings)) $settings = ['that' => $settings];
if (! self::checkPath($settings['that'], [], $helper)) throw new SkipException('Skipping as ' . $settings['that'] . ' is blank');
return $val;
}
|
php
|
static function doSkipThisIfThatEmpty($val, $settings, $helper = NULL) {
if (is_string($settings)) $settings = ['that' => $settings];
if (! self::checkPath($settings['that'], [], $helper)) throw new SkipException('Skipping as ' . $settings['that'] . ' is blank');
return $val;
}
|
[
"static",
"function",
"doSkipThisIfThatEmpty",
"(",
"$",
"val",
",",
"$",
"settings",
",",
"$",
"helper",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"settings",
")",
")",
"$",
"settings",
"=",
"[",
"'that'",
"=>",
"$",
"settings",
"]",
";",
"if",
"(",
"!",
"self",
"::",
"checkPath",
"(",
"$",
"settings",
"[",
"'that'",
"]",
",",
"[",
"]",
",",
"$",
"helper",
")",
")",
"throw",
"new",
"SkipException",
"(",
"'Skipping as '",
".",
"$",
"settings",
"[",
"'that'",
"]",
".",
"' is blank'",
")",
";",
"return",
"$",
"val",
";",
"}"
] |
Skip this field if another field is empty - works on input array so far, can add output test later.
|
[
"Skip",
"this",
"field",
"if",
"another",
"field",
"is",
"empty",
"-",
"works",
"on",
"input",
"array",
"so",
"far",
"can",
"add",
"output",
"test",
"later",
"."
] |
750c4277bcff5466ac73927ece8aae439b74efde
|
https://github.com/turtledesign/royalmail-php/blob/750c4277bcff5466ac73927ece8aae439b74efde/src/Filter/Filters.php#L173-L179
|
224,385
|
pug-php/pug-assets
|
src/Pug/Assets.php
|
Assets.unsetMinify
|
public function unsetMinify()
{
$this->pug->removeKeyword('assets');
$this->pug->removeKeyword('concat');
$this->pug->removeKeyword('concat-to');
$this->pug->removeKeyword('minify');
$this->pug->removeKeyword('minify-to');
$this->minify = null;
return $this;
}
|
php
|
public function unsetMinify()
{
$this->pug->removeKeyword('assets');
$this->pug->removeKeyword('concat');
$this->pug->removeKeyword('concat-to');
$this->pug->removeKeyword('minify');
$this->pug->removeKeyword('minify-to');
$this->minify = null;
return $this;
}
|
[
"public",
"function",
"unsetMinify",
"(",
")",
"{",
"$",
"this",
"->",
"pug",
"->",
"removeKeyword",
"(",
"'assets'",
")",
";",
"$",
"this",
"->",
"pug",
"->",
"removeKeyword",
"(",
"'concat'",
")",
";",
"$",
"this",
"->",
"pug",
"->",
"removeKeyword",
"(",
"'concat-to'",
")",
";",
"$",
"this",
"->",
"pug",
"->",
"removeKeyword",
"(",
"'minify'",
")",
";",
"$",
"this",
"->",
"pug",
"->",
"removeKeyword",
"(",
"'minify-to'",
")",
";",
"$",
"this",
"->",
"minify",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove the keywords.
@return self $this
|
[
"Remove",
"the",
"keywords",
"."
] |
65dcf323517cc1ffa407d5200b50f4910056cf3c
|
https://github.com/pug-php/pug-assets/blob/65dcf323517cc1ffa407d5200b50f4910056cf3c/src/Pug/Assets.php#L133-L143
|
224,386
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.method
|
public function method($field, $methodName = null)
{
if (!$methodName) {
$methodName = $field;
}
if (!is_string($field)) {
throw new GenericException('Must be a string!');
}
if (!is_string($methodName)) {
throw new GenericException('Must be a string!');
}
$this->fields[ $field ] = [
'type' => self::TYPE_METHOD,
'method' => $methodName
];
return $this;
}
|
php
|
public function method($field, $methodName = null)
{
if (!$methodName) {
$methodName = $field;
}
if (!is_string($field)) {
throw new GenericException('Must be a string!');
}
if (!is_string($methodName)) {
throw new GenericException('Must be a string!');
}
$this->fields[ $field ] = [
'type' => self::TYPE_METHOD,
'method' => $methodName
];
return $this;
}
|
[
"public",
"function",
"method",
"(",
"$",
"field",
",",
"$",
"methodName",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"methodName",
")",
"{",
"$",
"methodName",
"=",
"$",
"field",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"throw",
"new",
"GenericException",
"(",
"'Must be a string!'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"methodName",
")",
")",
"{",
"throw",
"new",
"GenericException",
"(",
"'Must be a string!'",
")",
";",
"}",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
"=",
"[",
"'type'",
"=>",
"self",
"::",
"TYPE_METHOD",
",",
"'method'",
"=>",
"$",
"methodName",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Add field method
@param $field
@param null $methodName
@return $this
@throws GenericException
|
[
"Add",
"field",
"method"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L107-L126
|
224,387
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.methods
|
public function methods(array $fieldsMethods)
{
foreach ($fieldsMethods as $field => $path) {
$this->method($field, $path);
}
return $this;
}
|
php
|
public function methods(array $fieldsMethods)
{
foreach ($fieldsMethods as $field => $path) {
$this->method($field, $path);
}
return $this;
}
|
[
"public",
"function",
"methods",
"(",
"array",
"$",
"fieldsMethods",
")",
"{",
"foreach",
"(",
"$",
"fieldsMethods",
"as",
"$",
"field",
"=>",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"method",
"(",
"$",
"field",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add fields methods
@param array $fieldsMethods
@return $this
|
[
"Add",
"fields",
"methods"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L135-L142
|
224,388
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.path
|
public function path($field, $path, $defaultValue = null)
{
if (!is_string($field)) {
throw new GenericException('Must be a string!');
}
if (!is_string($path)) {
throw new GenericException('Must be not empty string!');
}
$this->fields[ $field ] = [
'type' => self::TYPE_ARRAY_PATH,
'path' => $this->contextPath . $path,
'defaultValue' => $defaultValue,
'contextPath' => $this->contextPath,
'pathWithoutContext' => $path
];
return $this;
}
|
php
|
public function path($field, $path, $defaultValue = null)
{
if (!is_string($field)) {
throw new GenericException('Must be a string!');
}
if (!is_string($path)) {
throw new GenericException('Must be not empty string!');
}
$this->fields[ $field ] = [
'type' => self::TYPE_ARRAY_PATH,
'path' => $this->contextPath . $path,
'defaultValue' => $defaultValue,
'contextPath' => $this->contextPath,
'pathWithoutContext' => $path
];
return $this;
}
|
[
"public",
"function",
"path",
"(",
"$",
"field",
",",
"$",
"path",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"throw",
"new",
"GenericException",
"(",
"'Must be a string!'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"GenericException",
"(",
"'Must be not empty string!'",
")",
";",
"}",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
"=",
"[",
"'type'",
"=>",
"self",
"::",
"TYPE_ARRAY_PATH",
",",
"'path'",
"=>",
"$",
"this",
"->",
"contextPath",
".",
"$",
"path",
",",
"'defaultValue'",
"=>",
"$",
"defaultValue",
",",
"'contextPath'",
"=>",
"$",
"this",
"->",
"contextPath",
",",
"'pathWithoutContext'",
"=>",
"$",
"path",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Add field path
@param $field
@param $path
@param null $defaultValue
@return $this
@throws GenericException
|
[
"Add",
"field",
"path"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L154-L172
|
224,389
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.paths
|
public function paths(array $fieldPaths)
{
foreach ($fieldPaths as $field => $path) {
if (is_array($path)) {
$this->path($field, $path[ 0 ], $path[ 1 ]);
} else {
$this->path($field, $path);
}
}
return $this;
}
|
php
|
public function paths(array $fieldPaths)
{
foreach ($fieldPaths as $field => $path) {
if (is_array($path)) {
$this->path($field, $path[ 0 ], $path[ 1 ]);
} else {
$this->path($field, $path);
}
}
return $this;
}
|
[
"public",
"function",
"paths",
"(",
"array",
"$",
"fieldPaths",
")",
"{",
"foreach",
"(",
"$",
"fieldPaths",
"as",
"$",
"field",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"path",
"(",
"$",
"field",
",",
"$",
"path",
"[",
"0",
"]",
",",
"$",
"path",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"path",
"(",
"$",
"field",
",",
"$",
"path",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add fields paths
@param array $fieldPaths
@return $this
|
[
"Add",
"fields",
"paths"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L181-L192
|
224,390
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.prefilled
|
public function prefilled($field, $value)
{
$this->fields[ $field ] = [
'type' => self::TYPE_PREFILLED_VALUE,
'value' => $value
];
return $this;
}
|
php
|
public function prefilled($field, $value)
{
$this->fields[ $field ] = [
'type' => self::TYPE_PREFILLED_VALUE,
'value' => $value
];
return $this;
}
|
[
"public",
"function",
"prefilled",
"(",
"$",
"field",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
"=",
"[",
"'type'",
"=>",
"self",
"::",
"TYPE_PREFILLED_VALUE",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Only return value if data loaded
@param $field
@param $value
@return $this
|
[
"Only",
"return",
"value",
"if",
"data",
"loaded"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L216-L224
|
224,391
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.getNormalizerForField
|
public function getNormalizerForField($field)
{
if (!empty($this->fields[ $field ])) {
return $this->fields[ $field ];
} else {
return false;
}
}
|
php
|
public function getNormalizerForField($field)
{
if (!empty($this->fields[ $field ])) {
return $this->fields[ $field ];
} else {
return false;
}
}
|
[
"public",
"function",
"getNormalizerForField",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"]",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Get normalizer for field
@param $field
@return bool|array Array if found or false otherwise
|
[
"Get",
"normalizer",
"for",
"field"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L235-L242
|
224,392
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.pathContext
|
public function pathContext($pathContext)
{
if (!is_string($pathContext)) {
throw new GenericException('Must be a string!');
}
$this->contextPath = ltrim($pathContext . '.', '.');
return $this;
}
|
php
|
public function pathContext($pathContext)
{
if (!is_string($pathContext)) {
throw new GenericException('Must be a string!');
}
$this->contextPath = ltrim($pathContext . '.', '.');
return $this;
}
|
[
"public",
"function",
"pathContext",
"(",
"$",
"pathContext",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"pathContext",
")",
")",
"{",
"throw",
"new",
"GenericException",
"(",
"'Must be a string!'",
")",
";",
"}",
"$",
"this",
"->",
"contextPath",
"=",
"ltrim",
"(",
"$",
"pathContext",
".",
"'.'",
",",
"'.'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set path context. All next fields will be added with prepended path
@see NormalizersMap::prependByPathContext
@param $pathContext
@return $this
@throws \OAuth\UserData\Exception\GenericException
|
[
"Set",
"path",
"context",
".",
"All",
"next",
"fields",
"will",
"be",
"added",
"with",
"prepended",
"path"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L279-L288
|
224,393
|
logical-and/php-oauth
|
src/UserData/Arguments/NormalizersMap.php
|
NormalizersMap.prependByPathContext
|
public function prependByPathContext($pathContext)
{
$this->pathContext($pathContext);
foreach ($this->getPathNormalizers() as $field => $normalizer) {
$this->path($field, $normalizer[ 'pathWithoutContext' ], $normalizer[ 'defaultValue' ]);
}
return $this;
}
|
php
|
public function prependByPathContext($pathContext)
{
$this->pathContext($pathContext);
foreach ($this->getPathNormalizers() as $field => $normalizer) {
$this->path($field, $normalizer[ 'pathWithoutContext' ], $normalizer[ 'defaultValue' ]);
}
return $this;
}
|
[
"public",
"function",
"prependByPathContext",
"(",
"$",
"pathContext",
")",
"{",
"$",
"this",
"->",
"pathContext",
"(",
"$",
"pathContext",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPathNormalizers",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"normalizer",
")",
"{",
"$",
"this",
"->",
"path",
"(",
"$",
"field",
",",
"$",
"normalizer",
"[",
"'pathWithoutContext'",
"]",
",",
"$",
"normalizer",
"[",
"'defaultValue'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Prepend all added fields paths
@param $pathContext
@return $this
|
[
"Prepend",
"all",
"added",
"fields",
"paths"
] |
48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf
|
https://github.com/logical-and/php-oauth/blob/48fa6e74b147f5a689cb6a03dcf9ea67d1d98bbf/src/UserData/Arguments/NormalizersMap.php#L297-L306
|
224,394
|
oroinc/OroMessageQueueComponent
|
Job/JobProcessor.php
|
JobProcessor.cancelAllNotStartedChildJobs
|
public function cancelAllNotStartedChildJobs(Job $job)
{
if (!$job->isRoot() || !$job->getChildJobs()) {
return;
}
foreach ($job->getChildJobs() as $childJob) {
if (in_array($childJob->getStatus(), $this->getNotStartedJobStatuses(), true)) {
$this->cancelChildJob($childJob);
}
}
}
|
php
|
public function cancelAllNotStartedChildJobs(Job $job)
{
if (!$job->isRoot() || !$job->getChildJobs()) {
return;
}
foreach ($job->getChildJobs() as $childJob) {
if (in_array($childJob->getStatus(), $this->getNotStartedJobStatuses(), true)) {
$this->cancelChildJob($childJob);
}
}
}
|
[
"public",
"function",
"cancelAllNotStartedChildJobs",
"(",
"Job",
"$",
"job",
")",
"{",
"if",
"(",
"!",
"$",
"job",
"->",
"isRoot",
"(",
")",
"||",
"!",
"$",
"job",
"->",
"getChildJobs",
"(",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"job",
"->",
"getChildJobs",
"(",
")",
"as",
"$",
"childJob",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"childJob",
"->",
"getStatus",
"(",
")",
",",
"$",
"this",
"->",
"getNotStartedJobStatuses",
"(",
")",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"cancelChildJob",
"(",
"$",
"childJob",
")",
";",
"}",
"}",
"}"
] |
Cancels running for all child jobs that are not in run status.
@param Job $job
|
[
"Cancels",
"running",
"for",
"all",
"child",
"jobs",
"that",
"are",
"not",
"in",
"run",
"status",
"."
] |
6f1fdb12aebcfc6beae074ce492f496ed9847a77
|
https://github.com/oroinc/OroMessageQueueComponent/blob/6f1fdb12aebcfc6beae074ce492f496ed9847a77/Job/JobProcessor.php#L404-L415
|
224,395
|
projek-xyz/slim-framework
|
src/DefaultMiddleware.php
|
DefaultMiddleware.filterTrailingSlash
|
protected function filterTrailingSlash(UriInterface $uri)
{
$path = $uri->getPath();
if (strlen($path) > 1 && substr($path, -1) === '/') {
$path = substr($path, 0, -1);
}
return $path;
}
|
php
|
protected function filterTrailingSlash(UriInterface $uri)
{
$path = $uri->getPath();
if (strlen($path) > 1 && substr($path, -1) === '/') {
$path = substr($path, 0, -1);
}
return $path;
}
|
[
"protected",
"function",
"filterTrailingSlash",
"(",
"UriInterface",
"$",
"uri",
")",
"{",
"$",
"path",
"=",
"$",
"uri",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
">",
"1",
"&&",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
")",
"===",
"'/'",
")",
"{",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Provide filter to trim trailing slashes in URI path
@deprecated
@param \Psr\Http\Message\UriInterface $uri
@return string
|
[
"Provide",
"filter",
"to",
"trim",
"trailing",
"slashes",
"in",
"URI",
"path"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/DefaultMiddleware.php#L50-L59
|
224,396
|
projek-xyz/slim-framework
|
src/DefaultMiddleware.php
|
DefaultMiddleware.filterRequestMethod
|
protected function filterRequestMethod(Request $req)
{
$method = strtoupper($req->getMethod());
if ($method != 'POST') {
return $req;
}
$params = $req->getParsedBody();
if (isset($params['_method'])) {
$req = $req->withMethod($params['_method']);
}
return $req;
}
|
php
|
protected function filterRequestMethod(Request $req)
{
$method = strtoupper($req->getMethod());
if ($method != 'POST') {
return $req;
}
$params = $req->getParsedBody();
if (isset($params['_method'])) {
$req = $req->withMethod($params['_method']);
}
return $req;
}
|
[
"protected",
"function",
"filterRequestMethod",
"(",
"Request",
"$",
"req",
")",
"{",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"req",
"->",
"getMethod",
"(",
")",
")",
";",
"if",
"(",
"$",
"method",
"!=",
"'POST'",
")",
"{",
"return",
"$",
"req",
";",
"}",
"$",
"params",
"=",
"$",
"req",
"->",
"getParsedBody",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'_method'",
"]",
")",
")",
"{",
"$",
"req",
"=",
"$",
"req",
"->",
"withMethod",
"(",
"$",
"params",
"[",
"'_method'",
"]",
")",
";",
"}",
"return",
"$",
"req",
";",
"}"
] |
This provide a method-overwrite for GET and POST request
@param \Slim\Http\Request $req
@return \Slim\Http\Request
|
[
"This",
"provide",
"a",
"method",
"-",
"overwrite",
"for",
"GET",
"and",
"POST",
"request"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/DefaultMiddleware.php#L67-L82
|
224,397
|
maxmind/ccfd-api-php
|
src/CreditCardFraudDetection.php
|
CreditCardFraudDetection.filter_field
|
public function filter_field($key, $value)
{
if ($key == 'emailMD5' && false !== strpos($value, '@')) {
return md5(strtolower($value));
}
if (($key == 'usernameMD5' || $key == 'passwordMD5')
&& strlen($value) != 32
) {
return md5(strtolower($value));
}
return $value;
}
|
php
|
public function filter_field($key, $value)
{
if ($key == 'emailMD5' && false !== strpos($value, '@')) {
return md5(strtolower($value));
}
if (($key == 'usernameMD5' || $key == 'passwordMD5')
&& strlen($value) != 32
) {
return md5(strtolower($value));
}
return $value;
}
|
[
"public",
"function",
"filter_field",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'emailMD5'",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"value",
",",
"'@'",
")",
")",
"{",
"return",
"md5",
"(",
"strtolower",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"$",
"key",
"==",
"'usernameMD5'",
"||",
"$",
"key",
"==",
"'passwordMD5'",
")",
"&&",
"strlen",
"(",
"$",
"value",
")",
"!=",
"32",
")",
"{",
"return",
"md5",
"(",
"strtolower",
"(",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
If key matches one of 'emailMD5', 'usernameMD5' or 'passwordMD5',
convert value to lowercase and return the md5.
If key does not match one of the above, just return the value.
@see HTTPBase::filter_field()
@param string $key
@param string $value
@return string
|
[
"If",
"key",
"matches",
"one",
"of",
"emailMD5",
"usernameMD5",
"or",
"passwordMD5",
"convert",
"value",
"to",
"lowercase",
"and",
"return",
"the",
"md5",
"."
] |
5f6c2a5454e755f1c56be17a1fc0c97576ff010e
|
https://github.com/maxmind/ccfd-api-php/blob/5f6c2a5454e755f1c56be17a1fc0c97576ff010e/src/CreditCardFraudDetection.php#L119-L132
|
224,398
|
projek-xyz/slim-framework
|
src/Mailer.php
|
Mailer.send
|
public function send($subject, $content, $data = [], callable $callback = null)
{
$this->driver->subject($subject)->content($content, $data);
if (null !== $callback) {
$callback($this->driver);
}
return $this->driver->send();
}
|
php
|
public function send($subject, $content, $data = [], callable $callback = null)
{
$this->driver->subject($subject)->content($content, $data);
if (null !== $callback) {
$callback($this->driver);
}
return $this->driver->send();
}
|
[
"public",
"function",
"send",
"(",
"$",
"subject",
",",
"$",
"content",
",",
"$",
"data",
"=",
"[",
"]",
",",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"driver",
"->",
"subject",
"(",
"$",
"subject",
")",
"->",
"content",
"(",
"$",
"content",
",",
"$",
"data",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"this",
"->",
"driver",
")",
";",
"}",
"return",
"$",
"this",
"->",
"driver",
"->",
"send",
"(",
")",
";",
"}"
] |
Send the thing.
@param string $subject
@param string $content
@param array $data
@param callable|null $callback
@return mixed
|
[
"Send",
"the",
"thing",
"."
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Mailer.php#L59-L68
|
224,399
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Search/SqLiteQueryBuilder.php
|
SqLiteQueryBuilder.injectIndexClient
|
public function injectIndexClient(\Flowpack\SimpleSearch\Domain\Service\IndexInterface $indexClient) {
$this->indexClient = $indexClient;
}
|
php
|
public function injectIndexClient(\Flowpack\SimpleSearch\Domain\Service\IndexInterface $indexClient) {
$this->indexClient = $indexClient;
}
|
[
"public",
"function",
"injectIndexClient",
"(",
"\\",
"Flowpack",
"\\",
"SimpleSearch",
"\\",
"Domain",
"\\",
"Service",
"\\",
"IndexInterface",
"$",
"indexClient",
")",
"{",
"$",
"this",
"->",
"indexClient",
"=",
"$",
"indexClient",
";",
"}"
] |
Injection method used by Flow dependency injection
@param \Flowpack\SimpleSearch\Domain\Service\IndexInterface $indexClient
|
[
"Injection",
"method",
"used",
"by",
"Flow",
"dependency",
"injection"
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Search/SqLiteQueryBuilder.php#L50-L52
|
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.