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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
232,300
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.setOneTimePasswordSecret
|
public function setOneTimePasswordSecret($secret)
{
if ($this->getIsNewRecord()) {
return false;
}
$this->one_time_password_secret = $secret;
return $this->save(false);
}
|
php
|
public function setOneTimePasswordSecret($secret)
{
if ($this->getIsNewRecord()) {
return false;
}
$this->one_time_password_secret = $secret;
return $this->save(false);
}
|
[
"public",
"function",
"setOneTimePasswordSecret",
"(",
"$",
"secret",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsNewRecord",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"one_time_password_secret",
"=",
"$",
"secret",
";",
"return",
"$",
"this",
"->",
"save",
"(",
"false",
")",
";",
"}"
] |
Sets current secret used to generate one time passwords. If it's null, two step auth is disabled.
@param string $secret
@return boolean
|
[
"Sets",
"current",
"secret",
"used",
"to",
"generate",
"one",
"time",
"passwords",
".",
"If",
"it",
"s",
"null",
"two",
"step",
"auth",
"is",
"disabled",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L471-L479
|
232,301
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.setOneTimePassword
|
public function setOneTimePassword($password, $counter = 1)
{
if ($this->getIsNewRecord()) {
return false;
}
$this->one_time_password_code = $password;
$this->one_time_password_counter = $counter;
return $this->save(false);
}
|
php
|
public function setOneTimePassword($password, $counter = 1)
{
if ($this->getIsNewRecord()) {
return false;
}
$this->one_time_password_code = $password;
$this->one_time_password_counter = $counter;
return $this->save(false);
}
|
[
"public",
"function",
"setOneTimePassword",
"(",
"$",
"password",
",",
"$",
"counter",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsNewRecord",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"one_time_password_code",
"=",
"$",
"password",
";",
"$",
"this",
"->",
"one_time_password_counter",
"=",
"$",
"counter",
";",
"return",
"$",
"this",
"->",
"save",
"(",
"false",
")",
";",
"}"
] |
Sets previously used one time password and value of counter used to generate current one time password, used in counter mode.
@return boolean
|
[
"Sets",
"previously",
"used",
"one",
"time",
"password",
"and",
"value",
"of",
"counter",
"used",
"to",
"generate",
"current",
"one",
"time",
"password",
"used",
"in",
"counter",
"mode",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L497-L506
|
232,302
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.findByProvider
|
public static function findByProvider($provider, $identifier)
{
$t = UserRemoteIdentity::tableName();
return self::find()
->leftJoin($t, self::tableName().'.[['.self::primaryKey()[0].']]='.$t.'.[[user_id]]')
->andWhere($t.'.[[provider]]=:provider', [':provider' => $provider])
->andWhere($t.'.[[identifier]]=:identifier', [':identifier' => $identifier])
->one();
}
|
php
|
public static function findByProvider($provider, $identifier)
{
$t = UserRemoteIdentity::tableName();
return self::find()
->leftJoin($t, self::tableName().'.[['.self::primaryKey()[0].']]='.$t.'.[[user_id]]')
->andWhere($t.'.[[provider]]=:provider', [':provider' => $provider])
->andWhere($t.'.[[identifier]]=:identifier', [':identifier' => $identifier])
->one();
}
|
[
"public",
"static",
"function",
"findByProvider",
"(",
"$",
"provider",
",",
"$",
"identifier",
")",
"{",
"$",
"t",
"=",
"UserRemoteIdentity",
"::",
"tableName",
"(",
")",
";",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"leftJoin",
"(",
"$",
"t",
",",
"self",
"::",
"tableName",
"(",
")",
".",
"'.[['",
".",
"self",
"::",
"primaryKey",
"(",
")",
"[",
"0",
"]",
".",
"']]='",
".",
"$",
"t",
".",
"'.[[user_id]]'",
")",
"->",
"andWhere",
"(",
"$",
"t",
".",
"'.[[provider]]=:provider'",
",",
"[",
"':provider'",
"=>",
"$",
"provider",
"]",
")",
"->",
"andWhere",
"(",
"$",
"t",
".",
"'.[[identifier]]=:identifier'",
",",
"[",
"':identifier'",
"=>",
"$",
"identifier",
"]",
")",
"->",
"one",
"(",
")",
";",
"}"
] |
Loads a specific user identity connected to specified provider by an identifier.
@param string $provider
@param string $identifier
@return object a user identity object or null if not found.
|
[
"Loads",
"a",
"specific",
"user",
"identity",
"connected",
"to",
"specified",
"provider",
"by",
"an",
"identifier",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L518-L527
|
232,303
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.addRemoteIdentity
|
public function addRemoteIdentity($provider, $identifier)
{
//! @todo delete all by provider and identifier
$model = new UserRemoteIdentity();
$model->setAttributes([
'user_id' => $this->id,
'provider' => $provider,
'identifier' => $identifier,
], false);
return $model->save();
}
|
php
|
public function addRemoteIdentity($provider, $identifier)
{
//! @todo delete all by provider and identifier
$model = new UserRemoteIdentity();
$model->setAttributes([
'user_id' => $this->id,
'provider' => $provider,
'identifier' => $identifier,
], false);
return $model->save();
}
|
[
"public",
"function",
"addRemoteIdentity",
"(",
"$",
"provider",
",",
"$",
"identifier",
")",
"{",
"//! @todo delete all by provider and identifier",
"$",
"model",
"=",
"new",
"UserRemoteIdentity",
"(",
")",
";",
"$",
"model",
"->",
"setAttributes",
"(",
"[",
"'user_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'provider'",
"=>",
"$",
"provider",
",",
"'identifier'",
"=>",
"$",
"identifier",
",",
"]",
",",
"false",
")",
";",
"return",
"$",
"model",
"->",
"save",
"(",
")",
";",
"}"
] |
Associates this identity with a remote one identified by a provider name and identifier.
@param string $provider
@param string $identifier
@return boolean
|
[
"Associates",
"this",
"identity",
"with",
"a",
"remote",
"one",
"identified",
"by",
"a",
"provider",
"name",
"and",
"identifier",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L535-L546
|
232,304
|
Speicher210/Reflection
|
src/ReflectionClassUse.php
|
ReflectionClassUse.findConflictResolutions
|
protected function findConflictResolutions()
{
$contents = '<?php' . PHP_EOL . $this->declaringClass->getBody();
$this->tokens = token_get_all($contents);
$this->tokensCount = count($this->tokens);
while (($token = $this->next()) !== null) {
if ($token[0] === T_USE) {
$conflicts = $this->extractConflictsFromUseStatement();
if ($conflicts !== null) {
$this->conflictResolutions = explode(';', implode('', $conflicts));
$this->conflictResolutions = array_map('trim', $this->conflictResolutions);
$this->conflictResolutions = array_filter($this->conflictResolutions);
return;
}
}
}
throw new InvalidArgumentException('Could not find the trait "' . $this->name . '".');
}
|
php
|
protected function findConflictResolutions()
{
$contents = '<?php' . PHP_EOL . $this->declaringClass->getBody();
$this->tokens = token_get_all($contents);
$this->tokensCount = count($this->tokens);
while (($token = $this->next()) !== null) {
if ($token[0] === T_USE) {
$conflicts = $this->extractConflictsFromUseStatement();
if ($conflicts !== null) {
$this->conflictResolutions = explode(';', implode('', $conflicts));
$this->conflictResolutions = array_map('trim', $this->conflictResolutions);
$this->conflictResolutions = array_filter($this->conflictResolutions);
return;
}
}
}
throw new InvalidArgumentException('Could not find the trait "' . $this->name . '".');
}
|
[
"protected",
"function",
"findConflictResolutions",
"(",
")",
"{",
"$",
"contents",
"=",
"'<?php'",
".",
"PHP_EOL",
".",
"$",
"this",
"->",
"declaringClass",
"->",
"getBody",
"(",
")",
";",
"$",
"this",
"->",
"tokens",
"=",
"token_get_all",
"(",
"$",
"contents",
")",
";",
"$",
"this",
"->",
"tokensCount",
"=",
"count",
"(",
"$",
"this",
"->",
"tokens",
")",
";",
"while",
"(",
"(",
"$",
"token",
"=",
"$",
"this",
"->",
"next",
"(",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"===",
"T_USE",
")",
"{",
"$",
"conflicts",
"=",
"$",
"this",
"->",
"extractConflictsFromUseStatement",
"(",
")",
";",
"if",
"(",
"$",
"conflicts",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"conflictResolutions",
"=",
"explode",
"(",
"';'",
",",
"implode",
"(",
"''",
",",
"$",
"conflicts",
")",
")",
";",
"$",
"this",
"->",
"conflictResolutions",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"this",
"->",
"conflictResolutions",
")",
";",
"$",
"this",
"->",
"conflictResolutions",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"conflictResolutions",
")",
";",
"return",
";",
"}",
"}",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Could not find the trait \"'",
".",
"$",
"this",
"->",
"name",
".",
"'\".'",
")",
";",
"}"
] |
Find the conflict resolutions of a trait.
@throws \Wingu\OctopusCore\Reflection\Annotation\Exceptions\InvalidArgumentException If the trait is not found.
|
[
"Find",
"the",
"conflict",
"resolutions",
"of",
"a",
"trait",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClassUse.php#L96-L116
|
232,305
|
Speicher210/Reflection
|
src/ReflectionClassUse.php
|
ReflectionClassUse.extractConflictsFromUseStatement
|
private function extractConflictsFromUseStatement()
{
$class = '';
$conflicts = array();
$inConflicts = false;
while (($token = $this->next($inConflicts)) !== null) {
if ($token !== '}' && $inConflicts === true) {
if (is_string($token) === true) {
$conflicts[] = trim($token);
} else {
$conflicts[] = $token[1];
}
continue;
}
if (($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR) === true) {
$class .= $token[1];
} else {
if ($token === ',') {
if ($this->isSearchedTrait($class) === true) {
return $conflicts;
}
$class = '';
} else {
if ($token === ';') {
if ($this->isSearchedTrait($class) === true) {
return $conflicts;
} else {
return null;
}
} else {
if ($token === '{') {
$inConflicts = true;
} else {
if ($token === '}') {
if ($this->isSearchedTrait($class) === true) {
return $conflicts;
} else {
return null;
}
} else {
break;
}
}
}
}
}
}
return null;
}
|
php
|
private function extractConflictsFromUseStatement()
{
$class = '';
$conflicts = array();
$inConflicts = false;
while (($token = $this->next($inConflicts)) !== null) {
if ($token !== '}' && $inConflicts === true) {
if (is_string($token) === true) {
$conflicts[] = trim($token);
} else {
$conflicts[] = $token[1];
}
continue;
}
if (($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR) === true) {
$class .= $token[1];
} else {
if ($token === ',') {
if ($this->isSearchedTrait($class) === true) {
return $conflicts;
}
$class = '';
} else {
if ($token === ';') {
if ($this->isSearchedTrait($class) === true) {
return $conflicts;
} else {
return null;
}
} else {
if ($token === '{') {
$inConflicts = true;
} else {
if ($token === '}') {
if ($this->isSearchedTrait($class) === true) {
return $conflicts;
} else {
return null;
}
} else {
break;
}
}
}
}
}
}
return null;
}
|
[
"private",
"function",
"extractConflictsFromUseStatement",
"(",
")",
"{",
"$",
"class",
"=",
"''",
";",
"$",
"conflicts",
"=",
"array",
"(",
")",
";",
"$",
"inConflicts",
"=",
"false",
";",
"while",
"(",
"(",
"$",
"token",
"=",
"$",
"this",
"->",
"next",
"(",
"$",
"inConflicts",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"token",
"!==",
"'}'",
"&&",
"$",
"inConflicts",
"===",
"true",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"token",
")",
"===",
"true",
")",
"{",
"$",
"conflicts",
"[",
"]",
"=",
"trim",
"(",
"$",
"token",
")",
";",
"}",
"else",
"{",
"$",
"conflicts",
"[",
"]",
"=",
"$",
"token",
"[",
"1",
"]",
";",
"}",
"continue",
";",
"}",
"if",
"(",
"(",
"$",
"token",
"[",
"0",
"]",
"===",
"T_STRING",
"||",
"$",
"token",
"[",
"0",
"]",
"===",
"T_NS_SEPARATOR",
")",
"===",
"true",
")",
"{",
"$",
"class",
".=",
"$",
"token",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"token",
"===",
"','",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSearchedTrait",
"(",
"$",
"class",
")",
"===",
"true",
")",
"{",
"return",
"$",
"conflicts",
";",
"}",
"$",
"class",
"=",
"''",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"token",
"===",
"';'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSearchedTrait",
"(",
"$",
"class",
")",
"===",
"true",
")",
"{",
"return",
"$",
"conflicts",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"token",
"===",
"'{'",
")",
"{",
"$",
"inConflicts",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"token",
"===",
"'}'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSearchedTrait",
"(",
"$",
"class",
")",
"===",
"true",
")",
"{",
"return",
"$",
"conflicts",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Extract the conflicts from the current use statement.
@return array
|
[
"Extract",
"the",
"conflicts",
"from",
"the",
"current",
"use",
"statement",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClassUse.php#L123-L175
|
232,306
|
Speicher210/Reflection
|
src/ReflectionClassUse.php
|
ReflectionClassUse.isSearchedTrait
|
private function isSearchedTrait($name)
{
if ($this->name === $name) {
return true;
}
if (strpos($name, '\\') === 0) {
return $this->name === $name || '\\' . $this->name === $name;
}
$name = $this->declaringClass->getNamespaceName() . '\\' . $name;
return $this->name === $name || $this->name === '\\' . $name;
}
|
php
|
private function isSearchedTrait($name)
{
if ($this->name === $name) {
return true;
}
if (strpos($name, '\\') === 0) {
return $this->name === $name || '\\' . $this->name === $name;
}
$name = $this->declaringClass->getNamespaceName() . '\\' . $name;
return $this->name === $name || $this->name === '\\' . $name;
}
|
[
"private",
"function",
"isSearchedTrait",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"===",
"$",
"name",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'\\\\'",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"name",
"===",
"$",
"name",
"||",
"'\\\\'",
".",
"$",
"this",
"->",
"name",
"===",
"$",
"name",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"declaringClass",
"->",
"getNamespaceName",
"(",
")",
".",
"'\\\\'",
".",
"$",
"name",
";",
"return",
"$",
"this",
"->",
"name",
"===",
"$",
"name",
"||",
"$",
"this",
"->",
"name",
"===",
"'\\\\'",
".",
"$",
"name",
";",
"}"
] |
Check if the found trait name is the one that we need to reflect.
@param string $name The name of the trait found.
@return boolean
|
[
"Check",
"if",
"the",
"found",
"trait",
"name",
"is",
"the",
"one",
"that",
"we",
"need",
"to",
"reflect",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClassUse.php#L183-L196
|
232,307
|
Speicher210/Reflection
|
src/ReflectionClassUse.php
|
ReflectionClassUse.next
|
private function next($includeWhiteSpace = false)
{
for ($i = $this->tokenPos; $i < $this->tokensCount; $i++) {
$this->tokenPos++;
if (($includeWhiteSpace === false && $this->tokens[$i][0] === T_WHITESPACE) || $this->tokens[$i][0] === T_COMMENT) {
continue;
}
return $this->tokens[$i];
}
return null;
}
|
php
|
private function next($includeWhiteSpace = false)
{
for ($i = $this->tokenPos; $i < $this->tokensCount; $i++) {
$this->tokenPos++;
if (($includeWhiteSpace === false && $this->tokens[$i][0] === T_WHITESPACE) || $this->tokens[$i][0] === T_COMMENT) {
continue;
}
return $this->tokens[$i];
}
return null;
}
|
[
"private",
"function",
"next",
"(",
"$",
"includeWhiteSpace",
"=",
"false",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"tokenPos",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"tokensCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"tokenPos",
"++",
";",
"if",
"(",
"(",
"$",
"includeWhiteSpace",
"===",
"false",
"&&",
"$",
"this",
"->",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"===",
"T_WHITESPACE",
")",
"||",
"$",
"this",
"->",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"===",
"T_COMMENT",
")",
"{",
"continue",
";",
"}",
"return",
"$",
"this",
"->",
"tokens",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Return the next token that is not a whitespace or comment.
@param boolean $includeWhiteSpace Flag if the whitespace should also be returned.
@return mixed
|
[
"Return",
"the",
"next",
"token",
"that",
"is",
"not",
"a",
"whitespace",
"or",
"comment",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClassUse.php#L204-L216
|
232,308
|
Speicher210/Reflection
|
src/ReflectionClassUse.php
|
ReflectionClassUse.export
|
public static function export($className, $name, $return = false)
{
$export = new self($className, $name);
$export = (string)$export;
if ($return === true) {
return $export;
} else {
echo $export;
return null;
}
}
|
php
|
public static function export($className, $name, $return = false)
{
$export = new self($className, $name);
$export = (string)$export;
if ($return === true) {
return $export;
} else {
echo $export;
return null;
}
}
|
[
"public",
"static",
"function",
"export",
"(",
"$",
"className",
",",
"$",
"name",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"export",
"=",
"new",
"self",
"(",
"$",
"className",
",",
"$",
"name",
")",
";",
"$",
"export",
"=",
"(",
"string",
")",
"$",
"export",
";",
"if",
"(",
"$",
"return",
"===",
"true",
")",
"{",
"return",
"$",
"export",
";",
"}",
"else",
"{",
"echo",
"$",
"export",
";",
"return",
"null",
";",
"}",
"}"
] |
Export the current use statement reflection.
@param string $className The class name where the use statement is defined.
@param string $name The name of the trait.
@param boolean $return Flag if the export should be returned or not.
@return string
|
[
"Export",
"the",
"current",
"use",
"statement",
"reflection",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClassUse.php#L226-L237
|
232,309
|
chippyash/Monad
|
src/chippyash/Monad/Map.php
|
Map.vUnion
|
final public function vUnion(Collection $other, $sortOrder = SORT_REGULAR)
{
throw new \BadMethodCallException(sprintf(self::ERR_TPL_BADM, __METHOD__));
}
|
php
|
final public function vUnion(Collection $other, $sortOrder = SORT_REGULAR)
{
throw new \BadMethodCallException(sprintf(self::ERR_TPL_BADM, __METHOD__));
}
|
[
"final",
"public",
"function",
"vUnion",
"(",
"Collection",
"$",
"other",
",",
"$",
"sortOrder",
"=",
"SORT_REGULAR",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"sprintf",
"(",
"self",
"::",
"ERR_TPL_BADM",
",",
"__METHOD__",
")",
")",
";",
"}"
] |
Value union is meaningless for a Map
@inheritdoc
@throws \BadMethodCallException
|
[
"Value",
"union",
"is",
"meaningless",
"for",
"a",
"Map"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Map.php#L81-L84
|
232,310
|
iwyg/jitimage
|
src/Thapp/JitImage/JitImageResolver.php
|
JitImageResolver.canResolve
|
protected function canResolve()
{
return is_array($this->input)
&& array_key_exists('parameter', $this->input)
&& array_key_exists('source', $this->input)
&& array_key_exists('filter', $this->input);
}
|
php
|
protected function canResolve()
{
return is_array($this->input)
&& array_key_exists('parameter', $this->input)
&& array_key_exists('source', $this->input)
&& array_key_exists('filter', $this->input);
}
|
[
"protected",
"function",
"canResolve",
"(",
")",
"{",
"return",
"is_array",
"(",
"$",
"this",
"->",
"input",
")",
"&&",
"array_key_exists",
"(",
"'parameter'",
",",
"$",
"this",
"->",
"input",
")",
"&&",
"array_key_exists",
"(",
"'source'",
",",
"$",
"this",
"->",
"input",
")",
"&&",
"array_key_exists",
"(",
"'filter'",
",",
"$",
"this",
"->",
"input",
")",
";",
"}"
] |
determine if all params are set
@access protected
@return bool
|
[
"determine",
"if",
"all",
"params",
"are",
"set"
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/JitImageResolver.php#L249-L255
|
232,311
|
iwyg/jitimage
|
src/Thapp/JitImage/JitImageResolver.php
|
JitImageResolver.parseFilter
|
protected function parseFilter()
{
if (isset($this->input['filter'])) {
$fragments = preg_split('%:%', $this->input['filter'], -1, PREG_SPLIT_NO_EMPTY);
$this->parameter['filter'] = $this->parseImageFilter($fragments);
return;
}
$this->parameter['filter'] = [];
}
|
php
|
protected function parseFilter()
{
if (isset($this->input['filter'])) {
$fragments = preg_split('%:%', $this->input['filter'], -1, PREG_SPLIT_NO_EMPTY);
$this->parameter['filter'] = $this->parseImageFilter($fragments);
return;
}
$this->parameter['filter'] = [];
}
|
[
"protected",
"function",
"parseFilter",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"input",
"[",
"'filter'",
"]",
")",
")",
"{",
"$",
"fragments",
"=",
"preg_split",
"(",
"'%:%'",
",",
"$",
"this",
"->",
"input",
"[",
"'filter'",
"]",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"$",
"this",
"->",
"parameter",
"[",
"'filter'",
"]",
"=",
"$",
"this",
"->",
"parseImageFilter",
"(",
"$",
"fragments",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"parameter",
"[",
"'filter'",
"]",
"=",
"[",
"]",
";",
"}"
] |
parse the filter input parameter
@access protected
@return mixed
|
[
"parse",
"the",
"filter",
"input",
"parameter"
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/JitImageResolver.php#L355-L365
|
232,312
|
iwyg/jitimage
|
src/Thapp/JitImage/JitImageResolver.php
|
JitImageResolver.getOptionalColor
|
protected function getOptionalColor(array &$parameter)
{
preg_match('/^[0-9A-Fa-f]{3,6}/', $parameter['source'], $color);
$length = strpos($parameter['source'], '/');
$hasColor = (6 === $length && 3 === $length) && $length === strlen(current($color));
if (!empty($color)) {
$parameter['source'] = substr($parameter['source'], strlen(current($color)));
}
if ($hasColor) {
$parameter['background'] = '#' . current($color);
}
}
|
php
|
protected function getOptionalColor(array &$parameter)
{
preg_match('/^[0-9A-Fa-f]{3,6}/', $parameter['source'], $color);
$length = strpos($parameter['source'], '/');
$hasColor = (6 === $length && 3 === $length) && $length === strlen(current($color));
if (!empty($color)) {
$parameter['source'] = substr($parameter['source'], strlen(current($color)));
}
if ($hasColor) {
$parameter['background'] = '#' . current($color);
}
}
|
[
"protected",
"function",
"getOptionalColor",
"(",
"array",
"&",
"$",
"parameter",
")",
"{",
"preg_match",
"(",
"'/^[0-9A-Fa-f]{3,6}/'",
",",
"$",
"parameter",
"[",
"'source'",
"]",
",",
"$",
"color",
")",
";",
"$",
"length",
"=",
"strpos",
"(",
"$",
"parameter",
"[",
"'source'",
"]",
",",
"'/'",
")",
";",
"$",
"hasColor",
"=",
"(",
"6",
"===",
"$",
"length",
"&&",
"3",
"===",
"$",
"length",
")",
"&&",
"$",
"length",
"===",
"strlen",
"(",
"current",
"(",
"$",
"color",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"color",
")",
")",
"{",
"$",
"parameter",
"[",
"'source'",
"]",
"=",
"substr",
"(",
"$",
"parameter",
"[",
"'source'",
"]",
",",
"strlen",
"(",
"current",
"(",
"$",
"color",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"hasColor",
")",
"{",
"$",
"parameter",
"[",
"'background'",
"]",
"=",
"'#'",
".",
"current",
"(",
"$",
"color",
")",
";",
"}",
"}"
] |
extract a possible color string from the parameter input
@param array $parameter
@access protected
@return void
|
[
"extract",
"a",
"possible",
"color",
"string",
"from",
"the",
"parameter",
"input"
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/JitImageResolver.php#L446-L461
|
232,313
|
iwyg/jitimage
|
src/Thapp/JitImage/JitImageResolver.php
|
JitImageResolver.getImageRequestId
|
protected function getImageRequestId($requestString, $source = null)
{
if (!isset($this->cachedNames[$requestString])) {
$this->cachedNames[$requestString] = $this->processCache->createKey(
$source,
$requestString,
$this->config->cache_prefix,
pathinfo($source, PATHINFO_EXTENSION)
);
}
return $this->cachedNames[$requestString];
}
|
php
|
protected function getImageRequestId($requestString, $source = null)
{
if (!isset($this->cachedNames[$requestString])) {
$this->cachedNames[$requestString] = $this->processCache->createKey(
$source,
$requestString,
$this->config->cache_prefix,
pathinfo($source, PATHINFO_EXTENSION)
);
}
return $this->cachedNames[$requestString];
}
|
[
"protected",
"function",
"getImageRequestId",
"(",
"$",
"requestString",
",",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cachedNames",
"[",
"$",
"requestString",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cachedNames",
"[",
"$",
"requestString",
"]",
"=",
"$",
"this",
"->",
"processCache",
"->",
"createKey",
"(",
"$",
"source",
",",
"$",
"requestString",
",",
"$",
"this",
"->",
"config",
"->",
"cache_prefix",
",",
"pathinfo",
"(",
"$",
"source",
",",
"PATHINFO_EXTENSION",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cachedNames",
"[",
"$",
"requestString",
"]",
";",
"}"
] |
returns the image cache id string
@param mixed $requestString
@param mixed $width
@param mixed $height
@access protected
@return string
|
[
"returns",
"the",
"image",
"cache",
"id",
"string"
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/JitImageResolver.php#L472-L485
|
232,314
|
funivan/PhpTokenizer
|
src/Pattern/Patterns/MethodPattern.php
|
MethodPattern.withoutDocComment
|
public function withoutDocComment() : self {
$this->docCommentChecker = function (Token $token) {
return $token->isValid() === false;
};
return $this;
}
|
php
|
public function withoutDocComment() : self {
$this->docCommentChecker = function (Token $token) {
return $token->isValid() === false;
};
return $this;
}
|
[
"public",
"function",
"withoutDocComment",
"(",
")",
":",
"self",
"{",
"$",
"this",
"->",
"docCommentChecker",
"=",
"function",
"(",
"Token",
"$",
"token",
")",
"{",
"return",
"$",
"token",
"->",
"isValid",
"(",
")",
"===",
"false",
";",
"}",
";",
"return",
"$",
"this",
";",
"}"
] |
Find functions without doc comments
|
[
"Find",
"functions",
"without",
"doc",
"comments"
] |
f31ec8f1440708518c2a785b3f129f130621e966
|
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Pattern/Patterns/MethodPattern.php#L162-L168
|
232,315
|
thephpleague/flysystem-eventable-filesystem
|
src/EventableFilesystem.php
|
EventableFilesystem.delegateMethodCall
|
public function delegateMethodCall($method, array $arguments = [])
{
$config = $arguments['config'];
if (isset($config['silent']) && $config['silent'] === true) {
return $this->callFilesystemMethod($method, $arguments);
}
list($continue, $result) = $this->emitBefore($method, $arguments);
if (! $continue) {
return $result;
}
$result = $this->callFilesystemMethod($method, $result);
return $this->emitAfter($method, $result, $arguments);
}
|
php
|
public function delegateMethodCall($method, array $arguments = [])
{
$config = $arguments['config'];
if (isset($config['silent']) && $config['silent'] === true) {
return $this->callFilesystemMethod($method, $arguments);
}
list($continue, $result) = $this->emitBefore($method, $arguments);
if (! $continue) {
return $result;
}
$result = $this->callFilesystemMethod($method, $result);
return $this->emitAfter($method, $result, $arguments);
}
|
[
"public",
"function",
"delegateMethodCall",
"(",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"$",
"arguments",
"[",
"'config'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'silent'",
"]",
")",
"&&",
"$",
"config",
"[",
"'silent'",
"]",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"callFilesystemMethod",
"(",
"$",
"method",
",",
"$",
"arguments",
")",
";",
"}",
"list",
"(",
"$",
"continue",
",",
"$",
"result",
")",
"=",
"$",
"this",
"->",
"emitBefore",
"(",
"$",
"method",
",",
"$",
"arguments",
")",
";",
"if",
"(",
"!",
"$",
"continue",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"callFilesystemMethod",
"(",
"$",
"method",
",",
"$",
"result",
")",
";",
"return",
"$",
"this",
"->",
"emitAfter",
"(",
"$",
"method",
",",
"$",
"result",
",",
"$",
"arguments",
")",
";",
"}"
] |
Do all the work to call the method and emit the events.
@param string $method
@param array $arguments
@return mixed
|
[
"Do",
"all",
"the",
"work",
"to",
"call",
"the",
"method",
"and",
"emit",
"the",
"events",
"."
] |
784ddbf1a1c0144c04686b439548286279f0f920
|
https://github.com/thephpleague/flysystem-eventable-filesystem/blob/784ddbf1a1c0144c04686b439548286279f0f920/src/EventableFilesystem.php#L381-L398
|
232,316
|
thephpleague/flysystem-eventable-filesystem
|
src/EventableFilesystem.php
|
EventableFilesystem.emitBefore
|
protected function emitBefore($method, array $arguments)
{
$event = new BeforeEvent($this, $method, $arguments);
$this->emit($event, $method);
if ($event->isPropagationStopped()) {
return [false, $event->getResult()];
}
return [true, $event->getArguments()];
}
|
php
|
protected function emitBefore($method, array $arguments)
{
$event = new BeforeEvent($this, $method, $arguments);
$this->emit($event, $method);
if ($event->isPropagationStopped()) {
return [false, $event->getResult()];
}
return [true, $event->getArguments()];
}
|
[
"protected",
"function",
"emitBefore",
"(",
"$",
"method",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"event",
"=",
"new",
"BeforeEvent",
"(",
"$",
"this",
",",
"$",
"method",
",",
"$",
"arguments",
")",
";",
"$",
"this",
"->",
"emit",
"(",
"$",
"event",
",",
"$",
"method",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isPropagationStopped",
"(",
")",
")",
"{",
"return",
"[",
"false",
",",
"$",
"event",
"->",
"getResult",
"(",
")",
"]",
";",
"}",
"return",
"[",
"true",
",",
"$",
"event",
"->",
"getArguments",
"(",
")",
"]",
";",
"}"
] |
Emit the before event.
@param string $method
@param array $arguments
@return array [continue, call result]
|
[
"Emit",
"the",
"before",
"event",
"."
] |
784ddbf1a1c0144c04686b439548286279f0f920
|
https://github.com/thephpleague/flysystem-eventable-filesystem/blob/784ddbf1a1c0144c04686b439548286279f0f920/src/EventableFilesystem.php#L408-L418
|
232,317
|
thephpleague/flysystem-eventable-filesystem
|
src/EventableFilesystem.php
|
EventableFilesystem.emitAfter
|
protected function emitAfter($method, $result, array $arguments)
{
$event = new AfterEvent($this, $method, $result, $arguments);
$this->emit($event);
return $event->getResult();
}
|
php
|
protected function emitAfter($method, $result, array $arguments)
{
$event = new AfterEvent($this, $method, $result, $arguments);
$this->emit($event);
return $event->getResult();
}
|
[
"protected",
"function",
"emitAfter",
"(",
"$",
"method",
",",
"$",
"result",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"event",
"=",
"new",
"AfterEvent",
"(",
"$",
"this",
",",
"$",
"method",
",",
"$",
"result",
",",
"$",
"arguments",
")",
";",
"$",
"this",
"->",
"emit",
"(",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Emit the after event.
@param string $method
@param mixed $result
@param array $arguments
@return mixed
|
[
"Emit",
"the",
"after",
"event",
"."
] |
784ddbf1a1c0144c04686b439548286279f0f920
|
https://github.com/thephpleague/flysystem-eventable-filesystem/blob/784ddbf1a1c0144c04686b439548286279f0f920/src/EventableFilesystem.php#L445-L451
|
232,318
|
funivan/PhpTokenizer
|
src/Collection.php
|
Collection.refresh
|
public function refresh() : self {
$string = $this->assemble();
$this->cleanCollection();
$tokens = Helper::getTokensFromString($string);
$this->setItems($tokens);
$this->rewind();
return $this;
}
|
php
|
public function refresh() : self {
$string = $this->assemble();
$this->cleanCollection();
$tokens = Helper::getTokensFromString($string);
$this->setItems($tokens);
$this->rewind();
return $this;
}
|
[
"public",
"function",
"refresh",
"(",
")",
":",
"self",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"assemble",
"(",
")",
";",
"$",
"this",
"->",
"cleanCollection",
"(",
")",
";",
"$",
"tokens",
"=",
"Helper",
"::",
"getTokensFromString",
"(",
"$",
"string",
")",
";",
"$",
"this",
"->",
"setItems",
"(",
"$",
"tokens",
")",
";",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove all invalid tokens in collection
Refresh index.
@return Collection
|
[
"Remove",
"all",
"invalid",
"tokens",
"in",
"collection",
"Refresh",
"index",
"."
] |
f31ec8f1440708518c2a785b3f129f130621e966
|
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Collection.php#L422-L431
|
232,319
|
funivan/PhpTokenizer
|
src/Collection.php
|
Collection.cleanCollection
|
protected function cleanCollection() : self {
foreach ($this as $index => $token) {
if ($token->isValid()) {
continue;
}
unset($this->items[$index]);
}
return $this;
}
|
php
|
protected function cleanCollection() : self {
foreach ($this as $index => $token) {
if ($token->isValid()) {
continue;
}
unset($this->items[$index]);
}
return $this;
}
|
[
"protected",
"function",
"cleanCollection",
"(",
")",
":",
"self",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"index",
"=>",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"isValid",
"(",
")",
")",
"{",
"continue",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"index",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove invalid tokens from collection
@return $this
|
[
"Remove",
"invalid",
"tokens",
"from",
"collection"
] |
f31ec8f1440708518c2a785b3f129f130621e966
|
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Collection.php#L503-L512
|
232,320
|
iwyg/jitimage
|
src/Thapp/JitImage/Controller/JitController.php
|
JitController.getImage
|
public function getImage($parameter, $source, $filter = null)
{
$this->imageResolver->setParameter($parameter);
$this->imageResolver->setSource($source);
$this->imageResolver->setFilter($filter);
if ($image = $this->imageResolver->resolve()) {
return $this->render($image);
}
return $this->notFound();
}
|
php
|
public function getImage($parameter, $source, $filter = null)
{
$this->imageResolver->setParameter($parameter);
$this->imageResolver->setSource($source);
$this->imageResolver->setFilter($filter);
if ($image = $this->imageResolver->resolve()) {
return $this->render($image);
}
return $this->notFound();
}
|
[
"public",
"function",
"getImage",
"(",
"$",
"parameter",
",",
"$",
"source",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"imageResolver",
"->",
"setParameter",
"(",
"$",
"parameter",
")",
";",
"$",
"this",
"->",
"imageResolver",
"->",
"setSource",
"(",
"$",
"source",
")",
";",
"$",
"this",
"->",
"imageResolver",
"->",
"setFilter",
"(",
"$",
"filter",
")",
";",
"if",
"(",
"$",
"image",
"=",
"$",
"this",
"->",
"imageResolver",
"->",
"resolve",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"image",
")",
";",
"}",
"return",
"$",
"this",
"->",
"notFound",
"(",
")",
";",
"}"
] |
Handler method that's being called for dynamic image processing.
@param string $mode
@param string $height
@param string $width
@param string $gravity
@param string $options
@access public
@return void
|
[
"Handler",
"method",
"that",
"s",
"being",
"called",
"for",
"dynamic",
"image",
"processing",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Controller/JitController.php#L80-L91
|
232,321
|
iwyg/jitimage
|
src/Thapp/JitImage/Controller/JitController.php
|
JitController.getResource
|
public function getResource($parameter, $source)
{
if ($params = $this->recipes->resolve($parameter)) {
extract($params);
return $this->getImage($parameters, $source, $filter);
}
return $this->notFound();
}
|
php
|
public function getResource($parameter, $source)
{
if ($params = $this->recipes->resolve($parameter)) {
extract($params);
return $this->getImage($parameters, $source, $filter);
}
return $this->notFound();
}
|
[
"public",
"function",
"getResource",
"(",
"$",
"parameter",
",",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"params",
"=",
"$",
"this",
"->",
"recipes",
"->",
"resolve",
"(",
"$",
"parameter",
")",
")",
"{",
"extract",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"getImage",
"(",
"$",
"parameters",
",",
"$",
"source",
",",
"$",
"filter",
")",
";",
"}",
"return",
"$",
"this",
"->",
"notFound",
"(",
")",
";",
"}"
] |
Handler method that's being called for aliased image processing.
@param string $source the source image to be processed
@access public
@return mixed
|
[
"Handler",
"method",
"that",
"s",
"being",
"called",
"for",
"aliased",
"image",
"processing",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Controller/JitController.php#L101-L109
|
232,322
|
iwyg/jitimage
|
src/Thapp/JitImage/Controller/JitController.php
|
JitController.getCached
|
public function getCached($key)
{
if ($image = $this->imageResolver->resolveFromCache($key)) {
return $this->render($image);
}
return $this->notFound();
}
|
php
|
public function getCached($key)
{
if ($image = $this->imageResolver->resolveFromCache($key)) {
return $this->render($image);
}
return $this->notFound();
}
|
[
"public",
"function",
"getCached",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"image",
"=",
"$",
"this",
"->",
"imageResolver",
"->",
"resolveFromCache",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"image",
")",
";",
"}",
"return",
"$",
"this",
"->",
"notFound",
"(",
")",
";",
"}"
] |
Handler method for resolving cached images.
@param mixed $key
@access public
@return void
|
[
"Handler",
"method",
"for",
"resolving",
"cached",
"images",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Controller/JitController.php#L118-L125
|
232,323
|
iwyg/jitimage
|
src/Thapp/JitImage/Controller/JitController.php
|
JitController.render
|
protected function render(ImageInterface $image)
{
$this->response->make($image);
$image->close();
return $this->response->getResponse();
}
|
php
|
protected function render(ImageInterface $image)
{
$this->response->make($image);
$image->close();
return $this->response->getResponse();
}
|
[
"protected",
"function",
"render",
"(",
"ImageInterface",
"$",
"image",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"make",
"(",
"$",
"image",
")",
";",
"$",
"image",
"->",
"close",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"->",
"getResponse",
"(",
")",
";",
"}"
] |
Create a new response and send its contents.
@access protected
@return void
|
[
"Create",
"a",
"new",
"response",
"and",
"send",
"its",
"contents",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Controller/JitController.php#L160-L166
|
232,324
|
iwyg/jitimage
|
src/Thapp/JitImage/Shell/ShellCommand.php
|
ShellCommand.runCmd
|
public function runCmd(
$cmd,
$exception = '\RuntimeException',
Closure $callback = null,
array $noEscapeChars = null
) {
$cmd = escapeshellcmd($cmd);
if (is_array($noEscapeChars) and !empty($noEscapeChars)) {
$repl = "\\\\" . implode("|\\\\", $noEscapeChars);
$cmd = preg_replace_callback(
"~$repl~",
function ($found) {
return trim($found[0], "\\");
},
$cmd
);
}
$this->cmds[] = $cmd;
$exitStatus = $this->execCmd($cmd, $stdout, $stderr);
if ($exitStatus > 0) {
if (!is_null($callback)) {
$callback($stderr);
}
throw new $exception(sprintf('Command exited with %d: %s', $exitStatus, $stderr));
}
return $stdout;
}
|
php
|
public function runCmd(
$cmd,
$exception = '\RuntimeException',
Closure $callback = null,
array $noEscapeChars = null
) {
$cmd = escapeshellcmd($cmd);
if (is_array($noEscapeChars) and !empty($noEscapeChars)) {
$repl = "\\\\" . implode("|\\\\", $noEscapeChars);
$cmd = preg_replace_callback(
"~$repl~",
function ($found) {
return trim($found[0], "\\");
},
$cmd
);
}
$this->cmds[] = $cmd;
$exitStatus = $this->execCmd($cmd, $stdout, $stderr);
if ($exitStatus > 0) {
if (!is_null($callback)) {
$callback($stderr);
}
throw new $exception(sprintf('Command exited with %d: %s', $exitStatus, $stderr));
}
return $stdout;
}
|
[
"public",
"function",
"runCmd",
"(",
"$",
"cmd",
",",
"$",
"exception",
"=",
"'\\RuntimeException'",
",",
"Closure",
"$",
"callback",
"=",
"null",
",",
"array",
"$",
"noEscapeChars",
"=",
"null",
")",
"{",
"$",
"cmd",
"=",
"escapeshellcmd",
"(",
"$",
"cmd",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"noEscapeChars",
")",
"and",
"!",
"empty",
"(",
"$",
"noEscapeChars",
")",
")",
"{",
"$",
"repl",
"=",
"\"\\\\\\\\\"",
".",
"implode",
"(",
"\"|\\\\\\\\\"",
",",
"$",
"noEscapeChars",
")",
";",
"$",
"cmd",
"=",
"preg_replace_callback",
"(",
"\"~$repl~\"",
",",
"function",
"(",
"$",
"found",
")",
"{",
"return",
"trim",
"(",
"$",
"found",
"[",
"0",
"]",
",",
"\"\\\\\"",
")",
";",
"}",
",",
"$",
"cmd",
")",
";",
"}",
"$",
"this",
"->",
"cmds",
"[",
"]",
"=",
"$",
"cmd",
";",
"$",
"exitStatus",
"=",
"$",
"this",
"->",
"execCmd",
"(",
"$",
"cmd",
",",
"$",
"stdout",
",",
"$",
"stderr",
")",
";",
"if",
"(",
"$",
"exitStatus",
">",
"0",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"stderr",
")",
";",
"}",
"throw",
"new",
"$",
"exception",
"(",
"sprintf",
"(",
"'Command exited with %d: %s'",
",",
"$",
"exitStatus",
",",
"$",
"stderr",
")",
")",
";",
"}",
"return",
"$",
"stdout",
";",
"}"
] |
run a shell command
@param string $cmd the shell command
@param string $exception exeption class
@param Closure $callback in case of an error call a
callback right before an exception is thrown
@access public
@throws \RuntimeException;
@return string the command result
|
[
"run",
"a",
"shell",
"command"
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Shell/ShellCommand.php#L48-L80
|
232,325
|
jack-theripper/transcoder
|
src/Format/VideoFormat.php
|
VideoFormat.setVideoBitrate
|
public function setVideoBitrate($bitrate)
{
if ( ! is_numeric($bitrate) || $bitrate < 0)
{
throw new \InvalidArgumentException('The video bit rate value must be a integer type.');
}
$this->videoBitrate = (int) $bitrate;
return $this;
}
|
php
|
public function setVideoBitrate($bitrate)
{
if ( ! is_numeric($bitrate) || $bitrate < 0)
{
throw new \InvalidArgumentException('The video bit rate value must be a integer type.');
}
$this->videoBitrate = (int) $bitrate;
return $this;
}
|
[
"public",
"function",
"setVideoBitrate",
"(",
"$",
"bitrate",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"bitrate",
")",
"||",
"$",
"bitrate",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The video bit rate value must be a integer type.'",
")",
";",
"}",
"$",
"this",
"->",
"videoBitrate",
"=",
"(",
"int",
")",
"$",
"bitrate",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the bitrate value.
@param int $bitrate
@return VideoFormat
@throws \InvalidArgumentException
|
[
"Set",
"the",
"bitrate",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/VideoFormat.php#L103-L113
|
232,326
|
jack-theripper/transcoder
|
src/Format/VideoFormat.php
|
VideoFormat.setPasses
|
public function setPasses($passes)
{
if ( ! is_int($passes) || $passes < 1)
{
throw new \InvalidArgumentException('The passes value must be a number greater then zero.');
}
$this->passes = $passes;
return $this;
}
|
php
|
public function setPasses($passes)
{
if ( ! is_int($passes) || $passes < 1)
{
throw new \InvalidArgumentException('The passes value must be a number greater then zero.');
}
$this->passes = $passes;
return $this;
}
|
[
"public",
"function",
"setPasses",
"(",
"$",
"passes",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"passes",
")",
"||",
"$",
"passes",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The passes value must be a number greater then zero.'",
")",
";",
"}",
"$",
"this",
"->",
"passes",
"=",
"$",
"passes",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the number of passes.
@param int $passes
@return VideoFormat
@throws \InvalidArgumentException
|
[
"Sets",
"the",
"number",
"of",
"passes",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/VideoFormat.php#L123-L133
|
232,327
|
jack-theripper/transcoder
|
src/Format/VideoFormat.php
|
VideoFormat.setFrameRate
|
public function setFrameRate($frameRate)
{
if ( ! is_numeric($frameRate) || $frameRate < 0)
{
throw new \InvalidArgumentException('Wrong the frame rate value.');
}
$this->videoFrameRate = $frameRate;
return $this;
}
|
php
|
public function setFrameRate($frameRate)
{
if ( ! is_numeric($frameRate) || $frameRate < 0)
{
throw new \InvalidArgumentException('Wrong the frame rate value.');
}
$this->videoFrameRate = $frameRate;
return $this;
}
|
[
"public",
"function",
"setFrameRate",
"(",
"$",
"frameRate",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"frameRate",
")",
"||",
"$",
"frameRate",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Wrong the frame rate value.'",
")",
";",
"}",
"$",
"this",
"->",
"videoFrameRate",
"=",
"$",
"frameRate",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the frame rate value.
@param float $frameRate
@return VideoFormat
@throws \InvalidArgumentException
|
[
"Set",
"the",
"frame",
"rate",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/VideoFormat.php#L153-L163
|
232,328
|
jack-theripper/transcoder
|
src/Format/VideoFormat.php
|
VideoFormat.setHeight
|
protected function setHeight($height)
{
if ( ! is_numeric($height) || $height < 1)
{
throw new \InvalidArgumentException('Wrong the height value.');
}
$this->height = $height;
return $this;
}
|
php
|
protected function setHeight($height)
{
if ( ! is_numeric($height) || $height < 1)
{
throw new \InvalidArgumentException('Wrong the height value.');
}
$this->height = $height;
return $this;
}
|
[
"protected",
"function",
"setHeight",
"(",
"$",
"height",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"height",
")",
"||",
"$",
"height",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Wrong the height value.'",
")",
";",
"}",
"$",
"this",
"->",
"height",
"=",
"$",
"height",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the height value.
@param int $height
@return self
@throws \InvalidArgumentException
|
[
"Set",
"the",
"height",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/VideoFormat.php#L264-L274
|
232,329
|
mmanos/laravel-api
|
src/Mmanos/Api/Api.php
|
Api.transform
|
public static function transform($object, $request = null)
{
return Transformations::transform($object, $request ?: Request::instance());
}
|
php
|
public static function transform($object, $request = null)
{
return Transformations::transform($object, $request ?: Request::instance());
}
|
[
"public",
"static",
"function",
"transform",
"(",
"$",
"object",
",",
"$",
"request",
"=",
"null",
")",
"{",
"return",
"Transformations",
"::",
"transform",
"(",
"$",
"object",
",",
"$",
"request",
"?",
":",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Apply any available transformations to the given model and return the result.
@param Model $model
@param Request $request
@return mixed
|
[
"Apply",
"any",
"available",
"transformations",
"to",
"the",
"given",
"model",
"and",
"return",
"the",
"result",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Api.php#L69-L72
|
232,330
|
mmanos/laravel-api
|
src/Mmanos/Api/Transformations.php
|
Transformations.getTransformer
|
public static function getTransformer($object)
{
$class = get_class($object);
if (isset(static::$transformations[$class])) {
return new static::$transformations[$class];
}
if (isset($object->transformer)) {
return new $object->transformer;
}
return null;
}
|
php
|
public static function getTransformer($object)
{
$class = get_class($object);
if (isset(static::$transformations[$class])) {
return new static::$transformations[$class];
}
if (isset($object->transformer)) {
return new $object->transformer;
}
return null;
}
|
[
"public",
"static",
"function",
"getTransformer",
"(",
"$",
"object",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"transformations",
"[",
"$",
"class",
"]",
")",
")",
"{",
"return",
"new",
"static",
"::",
"$",
"transformations",
"[",
"$",
"class",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"transformer",
")",
")",
"{",
"return",
"new",
"$",
"object",
"->",
"transformer",
";",
"}",
"return",
"null",
";",
"}"
] |
Return a transformer instance for the requested object.
@param object $object
@return object|null
|
[
"Return",
"a",
"transformer",
"instance",
"for",
"the",
"requested",
"object",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Transformations.php#L27-L40
|
232,331
|
mmanos/laravel-api
|
src/Mmanos/Api/Transformations.php
|
Transformations.transform
|
public static function transform($object, $request)
{
$transformer = static::getTransformer($object);
if (!$transformer) {
return $object;
}
return $transformer->transform($object, $request);
}
|
php
|
public static function transform($object, $request)
{
$transformer = static::getTransformer($object);
if (!$transformer) {
return $object;
}
return $transformer->transform($object, $request);
}
|
[
"public",
"static",
"function",
"transform",
"(",
"$",
"object",
",",
"$",
"request",
")",
"{",
"$",
"transformer",
"=",
"static",
"::",
"getTransformer",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"$",
"transformer",
")",
"{",
"return",
"$",
"object",
";",
"}",
"return",
"$",
"transformer",
"->",
"transform",
"(",
"$",
"object",
",",
"$",
"request",
")",
";",
"}"
] |
Transform the given object.
@param object $object
@param Request $request
@return mixed
|
[
"Transform",
"the",
"given",
"object",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Transformations.php#L50-L58
|
232,332
|
jack-theripper/transcoder
|
src/Video.php
|
Video.getFrame
|
public function getFrame($interval)
{
if ( ! $interval instanceof TimeInterval)
{
$interval = new TimeInterval($interval);
}
if ($interval->getSeconds() > $this->getDuration())
{
throw new \OutOfRangeException('The interval may not be a more than '.$this->getDuration());
}
$frame = new Frame($this->getFilePath(), $this->getService());
$frame->addFilter(new SimpleFilter(['seek_start' => $interval->__toString()]), 99);
return $frame;
}
|
php
|
public function getFrame($interval)
{
if ( ! $interval instanceof TimeInterval)
{
$interval = new TimeInterval($interval);
}
if ($interval->getSeconds() > $this->getDuration())
{
throw new \OutOfRangeException('The interval may not be a more than '.$this->getDuration());
}
$frame = new Frame($this->getFilePath(), $this->getService());
$frame->addFilter(new SimpleFilter(['seek_start' => $interval->__toString()]), 99);
return $frame;
}
|
[
"public",
"function",
"getFrame",
"(",
"$",
"interval",
")",
"{",
"if",
"(",
"!",
"$",
"interval",
"instanceof",
"TimeInterval",
")",
"{",
"$",
"interval",
"=",
"new",
"TimeInterval",
"(",
"$",
"interval",
")",
";",
"}",
"if",
"(",
"$",
"interval",
"->",
"getSeconds",
"(",
")",
">",
"$",
"this",
"->",
"getDuration",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'The interval may not be a more than '",
".",
"$",
"this",
"->",
"getDuration",
"(",
")",
")",
";",
"}",
"$",
"frame",
"=",
"new",
"Frame",
"(",
"$",
"this",
"->",
"getFilePath",
"(",
")",
",",
"$",
"this",
"->",
"getService",
"(",
")",
")",
";",
"$",
"frame",
"->",
"addFilter",
"(",
"new",
"SimpleFilter",
"(",
"[",
"'seek_start'",
"=>",
"$",
"interval",
"->",
"__toString",
"(",
")",
"]",
")",
",",
"99",
")",
";",
"return",
"$",
"frame",
";",
"}"
] |
Return a new Frame from by time interval.
@param TimeInterval|int|float $interval
@return Frame
|
[
"Return",
"a",
"new",
"Frame",
"from",
"by",
"time",
"interval",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Video.php#L134-L150
|
232,333
|
caffeinated/SEO
|
src/Handlers/Metadata.php
|
Metadata.setDescription
|
public function setDescription($description)
{
$description = strip_tags($description);
if (strlen($description) > $this->maxDescriptionLength) {
$description = substr($description, 0, $this->maxDescriptionLength);
}
$this->description = $description;
}
|
php
|
public function setDescription($description)
{
$description = strip_tags($description);
if (strlen($description) > $this->maxDescriptionLength) {
$description = substr($description, 0, $this->maxDescriptionLength);
}
$this->description = $description;
}
|
[
"public",
"function",
"setDescription",
"(",
"$",
"description",
")",
"{",
"$",
"description",
"=",
"strip_tags",
"(",
"$",
"description",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"description",
")",
">",
"$",
"this",
"->",
"maxDescriptionLength",
")",
"{",
"$",
"description",
"=",
"substr",
"(",
"$",
"description",
",",
"0",
",",
"$",
"this",
"->",
"maxDescriptionLength",
")",
";",
"}",
"$",
"this",
"->",
"description",
"=",
"$",
"description",
";",
"}"
] |
Set the metadata description.
@param string $description
@return null
|
[
"Set",
"the",
"metadata",
"description",
"."
] |
b2b93c08d11be06631bd72a89acdd6693681fa91
|
https://github.com/caffeinated/SEO/blob/b2b93c08d11be06631bd72a89acdd6693681fa91/src/Handlers/Metadata.php#L73-L82
|
232,334
|
caffeinated/SEO
|
src/Handlers/Metadata.php
|
Metadata.set
|
public function set($name, $content)
{
$content = strip_tags($content);
$this->miscellaneous[$name] = $content;
}
|
php
|
public function set($name, $content)
{
$content = strip_tags($content);
$this->miscellaneous[$name] = $content;
}
|
[
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"strip_tags",
"(",
"$",
"content",
")",
";",
"$",
"this",
"->",
"miscellaneous",
"[",
"$",
"name",
"]",
"=",
"$",
"content",
";",
"}"
] |
Set miscellaneous metadata.
@param string $name
@param string $content
@return null
|
[
"Set",
"miscellaneous",
"metadata",
"."
] |
b2b93c08d11be06631bd72a89acdd6693681fa91
|
https://github.com/caffeinated/SEO/blob/b2b93c08d11be06631bd72a89acdd6693681fa91/src/Handlers/Metadata.php#L113-L118
|
232,335
|
caffeinated/SEO
|
src/Handlers/Metadata.php
|
Metadata.generate
|
public function generate()
{
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$miscellaneous = $this->getMiscellaneous();
$canonical = $this->getCanonical();
$html[] = '<title>'.$title.'</title>'.PHP_EOL;
if (! is_null($description)) {
$html[] = '<meta name="description" content="'.$description.'">';
}
if (! is_null($keywords)) {
$html[] = '<meta name="keywords" content="'.$keywords.'">';
}
if (! is_null($miscellaneous)) {
foreach ($miscellaneous as $name => $content) {
$html[] = '<meta name="'.$name.'" content="'.$content.'">';
}
}
if (! is_null($canonical)) {
$currentUrl = $this->request->fullUrl();
if ($canonical != $currentUrl) {
$html[] = PHP_EOL.'<link rel="canonical" href="'.$canonical.'">';
}
}
return implode(PHP_EOL, $html);
}
|
php
|
public function generate()
{
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$miscellaneous = $this->getMiscellaneous();
$canonical = $this->getCanonical();
$html[] = '<title>'.$title.'</title>'.PHP_EOL;
if (! is_null($description)) {
$html[] = '<meta name="description" content="'.$description.'">';
}
if (! is_null($keywords)) {
$html[] = '<meta name="keywords" content="'.$keywords.'">';
}
if (! is_null($miscellaneous)) {
foreach ($miscellaneous as $name => $content) {
$html[] = '<meta name="'.$name.'" content="'.$content.'">';
}
}
if (! is_null($canonical)) {
$currentUrl = $this->request->fullUrl();
if ($canonical != $currentUrl) {
$html[] = PHP_EOL.'<link rel="canonical" href="'.$canonical.'">';
}
}
return implode(PHP_EOL, $html);
}
|
[
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"getTitle",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"getDescription",
"(",
")",
";",
"$",
"keywords",
"=",
"$",
"this",
"->",
"getKeywords",
"(",
")",
";",
"$",
"miscellaneous",
"=",
"$",
"this",
"->",
"getMiscellaneous",
"(",
")",
";",
"$",
"canonical",
"=",
"$",
"this",
"->",
"getCanonical",
"(",
")",
";",
"$",
"html",
"[",
"]",
"=",
"'<title>'",
".",
"$",
"title",
".",
"'</title>'",
".",
"PHP_EOL",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"description",
")",
")",
"{",
"$",
"html",
"[",
"]",
"=",
"'<meta name=\"description\" content=\"'",
".",
"$",
"description",
".",
"'\">'",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"keywords",
")",
")",
"{",
"$",
"html",
"[",
"]",
"=",
"'<meta name=\"keywords\" content=\"'",
".",
"$",
"keywords",
".",
"'\">'",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"miscellaneous",
")",
")",
"{",
"foreach",
"(",
"$",
"miscellaneous",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"{",
"$",
"html",
"[",
"]",
"=",
"'<meta name=\"'",
".",
"$",
"name",
".",
"'\" content=\"'",
".",
"$",
"content",
".",
"'\">'",
";",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"canonical",
")",
")",
"{",
"$",
"currentUrl",
"=",
"$",
"this",
"->",
"request",
"->",
"fullUrl",
"(",
")",
";",
"if",
"(",
"$",
"canonical",
"!=",
"$",
"currentUrl",
")",
"{",
"$",
"html",
"[",
"]",
"=",
"PHP_EOL",
".",
"'<link rel=\"canonical\" href=\"'",
".",
"$",
"canonical",
".",
"'\">'",
";",
"}",
"}",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"html",
")",
";",
"}"
] |
Generate and render the HTML metadata tags.
@return string
|
[
"Generate",
"and",
"render",
"the",
"HTML",
"metadata",
"tags",
"."
] |
b2b93c08d11be06631bd72a89acdd6693681fa91
|
https://github.com/caffeinated/SEO/blob/b2b93c08d11be06631bd72a89acdd6693681fa91/src/Handlers/Metadata.php#L189-L222
|
232,336
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.each
|
public function each(\Closure $function, array $args = [])
{
$content = $this->getArrayCopy();
return new static(
\array_combine(
\array_keys($content),
\array_map(
function ($value) use ($function, $args) {
return $this->callFunction($function, $value, $args);
},
\array_values($content)
)
)
);
}
|
php
|
public function each(\Closure $function, array $args = [])
{
$content = $this->getArrayCopy();
return new static(
\array_combine(
\array_keys($content),
\array_map(
function ($value) use ($function, $args) {
return $this->callFunction($function, $value, $args);
},
\array_values($content)
)
)
);
}
|
[
"public",
"function",
"each",
"(",
"\\",
"Closure",
"$",
"function",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
";",
"return",
"new",
"static",
"(",
"\\",
"array_combine",
"(",
"\\",
"array_keys",
"(",
"$",
"content",
")",
",",
"\\",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"function",
",",
"$",
"args",
")",
"{",
"return",
"$",
"this",
"->",
"callFunction",
"(",
"$",
"function",
",",
"$",
"value",
",",
"$",
"args",
")",
";",
"}",
",",
"\\",
"array_values",
"(",
"$",
"content",
")",
")",
")",
")",
";",
"}"
] |
For each item in the collection apply the function and return a new collection
@param callable|\Closure $function
@param array $args
@return Collection
|
[
"For",
"each",
"item",
"in",
"the",
"collection",
"apply",
"the",
"function",
"and",
"return",
"a",
"new",
"collection"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L104-L119
|
232,337
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.flatten
|
public function flatten()
{
$ret = [];
foreach ($this as $key => $value) {
$ret[$key] = Match::on($value)
->Closure(function ($v) {
return $v();
})
->Monad_Monadic(function ($v) {
return $v->flatten();
})
->any()
->flatten();
}
return new static($ret);
}
|
php
|
public function flatten()
{
$ret = [];
foreach ($this as $key => $value) {
$ret[$key] = Match::on($value)
->Closure(function ($v) {
return $v();
})
->Monad_Monadic(function ($v) {
return $v->flatten();
})
->any()
->flatten();
}
return new static($ret);
}
|
[
"public",
"function",
"flatten",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"Match",
"::",
"on",
"(",
"$",
"value",
")",
"->",
"Closure",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"(",
")",
";",
"}",
")",
"->",
"Monad_Monadic",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"->",
"flatten",
"(",
")",
";",
"}",
")",
"->",
"any",
"(",
")",
"->",
"flatten",
"(",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"ret",
")",
";",
"}"
] |
Return value of Monad as a base type.
If value === \Closure, will evaluate the function and return it's value
If value === \Monadic, will recurse
@return Collection
|
[
"Return",
"value",
"of",
"Monad",
"as",
"a",
"base",
"type",
"."
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L180-L196
|
232,338
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.kDiff
|
public function kDiff(Collection $other, \Closure $function = null)
{
if (is_null($function)) {
return new static(\array_diff_key($this->getArrayCopy(), $other->getArrayCopy()), $this->type);
}
return new static(\array_diff_ukey($this->getArrayCopy(), $other->getArrayCopy(), $function), $this->type);
}
|
php
|
public function kDiff(Collection $other, \Closure $function = null)
{
if (is_null($function)) {
return new static(\array_diff_key($this->getArrayCopy(), $other->getArrayCopy()), $this->type);
}
return new static(\array_diff_ukey($this->getArrayCopy(), $other->getArrayCopy(), $function), $this->type);
}
|
[
"public",
"function",
"kDiff",
"(",
"Collection",
"$",
"other",
",",
"\\",
"Closure",
"$",
"function",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"function",
")",
")",
"{",
"return",
"new",
"static",
"(",
"\\",
"array_diff_key",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}",
"return",
"new",
"static",
"(",
"\\",
"array_diff_ukey",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"function",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}"
] |
Compares this collection against another collection using its keys for
comparison and returns a new Collection with the values in this collection
that are not present in the other collection.
Note that keys are preserved
If the optional comparison function is supplied it must have signature
function(mixed $a, mixed $b){}. The comparison function must return an integer
less than, equal to, or greater than zero if the first argument is considered
to be respectively less than, equal to, or greater than the second.
@param Collection $other
@param \Closure $function optional function to compare values
@return Collection
|
[
"Compares",
"this",
"collection",
"against",
"another",
"collection",
"using",
"its",
"keys",
"for",
"comparison",
"and",
"returns",
"a",
"new",
"Collection",
"with",
"the",
"values",
"in",
"this",
"collection",
"that",
"are",
"not",
"present",
"in",
"the",
"other",
"collection",
"."
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L288-L295
|
232,339
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.vIntersect
|
public function vIntersect(Collection $other, \Closure $function = null)
{
if (is_null($function)) {
return new static(\array_intersect($this->getArrayCopy(), $other->getArrayCopy()), $this->type);
}
return new static(\array_uintersect($this->getArrayCopy(), $other->getArrayCopy(), $function), $this->type);
}
|
php
|
public function vIntersect(Collection $other, \Closure $function = null)
{
if (is_null($function)) {
return new static(\array_intersect($this->getArrayCopy(), $other->getArrayCopy()), $this->type);
}
return new static(\array_uintersect($this->getArrayCopy(), $other->getArrayCopy(), $function), $this->type);
}
|
[
"public",
"function",
"vIntersect",
"(",
"Collection",
"$",
"other",
",",
"\\",
"Closure",
"$",
"function",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"function",
")",
")",
"{",
"return",
"new",
"static",
"(",
"\\",
"array_intersect",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}",
"return",
"new",
"static",
"(",
"\\",
"array_uintersect",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"function",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}"
] |
Returns a Collection containing all the values of this Collection that are present
in the other Collection. Note that keys are preserved
If the optional comparison function is supplied it must have signature
function(mixed $a, mixed $b){}. The comparison function must return an integer
less than, equal to, or greater than zero if the first argument is considered
to be respectively less than, equal to, or greater than the second.
@param Collection $other
@param callable|\Closure $function Optional function to compare values
@return Collection
|
[
"Returns",
"a",
"Collection",
"containing",
"all",
"the",
"values",
"of",
"this",
"Collection",
"that",
"are",
"present",
"in",
"the",
"other",
"Collection",
".",
"Note",
"that",
"keys",
"are",
"preserved"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L324-L331
|
232,340
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.kIntersect
|
public function kIntersect(Collection $other, \Closure $function = null)
{
return new static(
Match::on(Option::create($function))
->Monad_Option_Some(function () use ($other, $function) {
return \array_intersect_ukey($this->getArrayCopy(), $other->getArrayCopy(), $function);
})
->Monad_Option_None(function () use ($other) {
return \array_intersect_key($this->getArrayCopy(), $other->getArrayCopy());
})
->value(),
$this->type
);
}
|
php
|
public function kIntersect(Collection $other, \Closure $function = null)
{
return new static(
Match::on(Option::create($function))
->Monad_Option_Some(function () use ($other, $function) {
return \array_intersect_ukey($this->getArrayCopy(), $other->getArrayCopy(), $function);
})
->Monad_Option_None(function () use ($other) {
return \array_intersect_key($this->getArrayCopy(), $other->getArrayCopy());
})
->value(),
$this->type
);
}
|
[
"public",
"function",
"kIntersect",
"(",
"Collection",
"$",
"other",
",",
"\\",
"Closure",
"$",
"function",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"Match",
"::",
"on",
"(",
"Option",
"::",
"create",
"(",
"$",
"function",
")",
")",
"->",
"Monad_Option_Some",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"other",
",",
"$",
"function",
")",
"{",
"return",
"\\",
"array_intersect_ukey",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"function",
")",
";",
"}",
")",
"->",
"Monad_Option_None",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"other",
")",
"{",
"return",
"\\",
"array_intersect_key",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
")",
";",
"}",
")",
"->",
"value",
"(",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}"
] |
Returns a Collection containing all the values of this Collection that are present
in the other Collection. Keys are used for comparison
If the optional comparison function is supplied it must have signature
function(mixed $a, mixed $b){}. The comparison function must return an integer
less than, equal to, or greater than zero if the first argument is considered
to be respectively less than, equal to, or greater than the second.
@param Collection $other
@param \Closure $function Optional function to compare values
@return Collection
|
[
"Returns",
"a",
"Collection",
"containing",
"all",
"the",
"values",
"of",
"this",
"Collection",
"that",
"are",
"present",
"in",
"the",
"other",
"Collection",
".",
"Keys",
"are",
"used",
"for",
"comparison"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L347-L360
|
232,341
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.vUnion
|
public function vUnion(Collection $other, $sortOrder = SORT_REGULAR)
{
return new static(
\array_unique(
\array_merge($this->getArrayCopy(), $other->getArrayCopy()),
$sortOrder
)
, $this->type
);
}
|
php
|
public function vUnion(Collection $other, $sortOrder = SORT_REGULAR)
{
return new static(
\array_unique(
\array_merge($this->getArrayCopy(), $other->getArrayCopy()),
$sortOrder
)
, $this->type
);
}
|
[
"public",
"function",
"vUnion",
"(",
"Collection",
"$",
"other",
",",
"$",
"sortOrder",
"=",
"SORT_REGULAR",
")",
"{",
"return",
"new",
"static",
"(",
"\\",
"array_unique",
"(",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"other",
"->",
"getArrayCopy",
"(",
")",
")",
",",
"$",
"sortOrder",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}"
] |
Return a Collection that is the union of the values of this Collection
and the other Collection. Note that keys may be discarded and new ones set
@param Collection $other
@param int $sortOrder arrayUnique sort order. one of SORT_...
@return Collection
|
[
"Return",
"a",
"Collection",
"that",
"is",
"the",
"union",
"of",
"the",
"values",
"of",
"this",
"Collection",
"and",
"the",
"other",
"Collection",
".",
"Note",
"that",
"keys",
"may",
"be",
"discarded",
"and",
"new",
"ones",
"set"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L371-L380
|
232,342
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.append
|
public function append($value)
{
$nValue = (is_array($value) ? $value : [$value]);
return $this->vUnion(new static($nValue));
}
|
php
|
public function append($value)
{
$nValue = (is_array($value) ? $value : [$value]);
return $this->vUnion(new static($nValue));
}
|
[
"public",
"function",
"append",
"(",
"$",
"value",
")",
"{",
"$",
"nValue",
"=",
"(",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"[",
"$",
"value",
"]",
")",
";",
"return",
"$",
"this",
"->",
"vUnion",
"(",
"new",
"static",
"(",
"$",
"nValue",
")",
")",
";",
"}"
] |
Append value and return a new collection
NB this uses vUnion
Value will be forced into an array if not already one
@param mixed $value
@return Collection
|
[
"Append",
"value",
"and",
"return",
"a",
"new",
"collection",
"NB",
"this",
"uses",
"vUnion"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L426-L430
|
232,343
|
chippyash/Monad
|
src/chippyash/Monad/Collection.php
|
Collection.callFunction
|
protected function callFunction(\Closure $function, $value, array $args = [])
{
if ($value instanceof Monadic && !$value instanceof Collection) {
return $value->bind($function, $args);
}
$val = ($value instanceof \Closure ? $value() : $value);
array_unshift($args, $val);
return call_user_func_array($function, $args);
}
|
php
|
protected function callFunction(\Closure $function, $value, array $args = [])
{
if ($value instanceof Monadic && !$value instanceof Collection) {
return $value->bind($function, $args);
}
$val = ($value instanceof \Closure ? $value() : $value);
array_unshift($args, $val);
return call_user_func_array($function, $args);
}
|
[
"protected",
"function",
"callFunction",
"(",
"\\",
"Closure",
"$",
"function",
",",
"$",
"value",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Monadic",
"&&",
"!",
"$",
"value",
"instanceof",
"Collection",
")",
"{",
"return",
"$",
"value",
"->",
"bind",
"(",
"$",
"function",
",",
"$",
"args",
")",
";",
"}",
"$",
"val",
"=",
"(",
"$",
"value",
"instanceof",
"\\",
"Closure",
"?",
"$",
"value",
"(",
")",
":",
"$",
"value",
")",
";",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"val",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"function",
",",
"$",
"args",
")",
";",
"}"
] |
Call function on value
@param \Closure $function
@param mixed $value
@param array $args additional arguments to pass to function
@return Monadic
|
[
"Call",
"function",
"on",
"value"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Collection.php#L560-L570
|
232,344
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Http/Requests/Request.php
|
Request.sanitize
|
public function sanitize()
{
if (method_exists($this, 'filters')) {
$filtry = \Filtry::make($this->all(), $this->filters());
$this->merge($filtry->getFiltered());
}
}
|
php
|
public function sanitize()
{
if (method_exists($this, 'filters')) {
$filtry = \Filtry::make($this->all(), $this->filters());
$this->merge($filtry->getFiltered());
}
}
|
[
"public",
"function",
"sanitize",
"(",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'filters'",
")",
")",
"{",
"$",
"filtry",
"=",
"\\",
"Filtry",
"::",
"make",
"(",
"$",
"this",
"->",
"all",
"(",
")",
",",
"$",
"this",
"->",
"filters",
"(",
")",
")",
";",
"$",
"this",
"->",
"merge",
"(",
"$",
"filtry",
"->",
"getFiltered",
"(",
")",
")",
";",
"}",
"}"
] |
Add filters from the filters method if it exists.
|
[
"Add",
"filters",
"from",
"the",
"filters",
"method",
"if",
"it",
"exists",
"."
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Http/Requests/Request.php#L10-L16
|
232,345
|
monarkee/bumble
|
Models/BumbleModel.php
|
BumbleModel.bootTraits
|
protected static function bootTraits()
{
$segment = Request::segment(1);
if ($segment == config('bumble.admin_prefix') && self::enableTraits() == true)
{
parent::bootTraits();
}
elseif ($segment !== config('bumble.admin_prefix'))
{
parent::bootTraits();
}
// Boot soft-delete trait all the time
if (method_exists(get_called_class(), $method = 'bootSoftDeletes'))
{
forward_static_call([get_called_class(), $method]);
}
}
|
php
|
protected static function bootTraits()
{
$segment = Request::segment(1);
if ($segment == config('bumble.admin_prefix') && self::enableTraits() == true)
{
parent::bootTraits();
}
elseif ($segment !== config('bumble.admin_prefix'))
{
parent::bootTraits();
}
// Boot soft-delete trait all the time
if (method_exists(get_called_class(), $method = 'bootSoftDeletes'))
{
forward_static_call([get_called_class(), $method]);
}
}
|
[
"protected",
"static",
"function",
"bootTraits",
"(",
")",
"{",
"$",
"segment",
"=",
"Request",
"::",
"segment",
"(",
"1",
")",
";",
"if",
"(",
"$",
"segment",
"==",
"config",
"(",
"'bumble.admin_prefix'",
")",
"&&",
"self",
"::",
"enableTraits",
"(",
")",
"==",
"true",
")",
"{",
"parent",
"::",
"bootTraits",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"segment",
"!==",
"config",
"(",
"'bumble.admin_prefix'",
")",
")",
"{",
"parent",
"::",
"bootTraits",
"(",
")",
";",
"}",
"// Boot soft-delete trait all the time",
"if",
"(",
"method_exists",
"(",
"get_called_class",
"(",
")",
",",
"$",
"method",
"=",
"'bootSoftDeletes'",
")",
")",
"{",
"forward_static_call",
"(",
"[",
"get_called_class",
"(",
")",
",",
"$",
"method",
"]",
")",
";",
"}",
"}"
] |
If not in the admin, boot the traits of the model
@return void
|
[
"If",
"not",
"in",
"the",
"admin",
"boot",
"the",
"traits",
"of",
"the",
"model"
] |
6e140e341980d6f9467418594eed48c3859c00f7
|
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Models/BumbleModel.php#L21-L39
|
232,346
|
monarkee/bumble
|
Models/BumbleModel.php
|
BumbleModel.hasFieldTypes
|
public function hasFieldTypes($type)
{
foreach ($this->getFields() as $component)
{
if ($component->isFieldType($type)) return true;
}
}
|
php
|
public function hasFieldTypes($type)
{
foreach ($this->getFields() as $component)
{
if ($component->isFieldType($type)) return true;
}
}
|
[
"public",
"function",
"hasFieldTypes",
"(",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"$",
"component",
"->",
"isFieldType",
"(",
"$",
"type",
")",
")",
"return",
"true",
";",
"}",
"}"
] |
Check for arbitrary Field Types on the model
@param $type
@return bool
|
[
"Check",
"for",
"arbitrary",
"Field",
"Types",
"on",
"the",
"model"
] |
6e140e341980d6f9467418594eed48c3859c00f7
|
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Models/BumbleModel.php#L293-L299
|
232,347
|
monarkee/bumble
|
Models/BumbleModel.php
|
BumbleModel.editingTitle
|
public function editingTitle()
{
$editingTitle = $this->admin()->editingTitle;
// Check for the custom option first and
// return it if it exists
if ($this->columnExists($editingTitle)) return $this->{$editingTitle};
// As a last-ditch effort, see if there's a title option
// we can use so the user doesn't have to ask for it
if ($this->columnExists('title')) return $this->title;
return;
}
|
php
|
public function editingTitle()
{
$editingTitle = $this->admin()->editingTitle;
// Check for the custom option first and
// return it if it exists
if ($this->columnExists($editingTitle)) return $this->{$editingTitle};
// As a last-ditch effort, see if there's a title option
// we can use so the user doesn't have to ask for it
if ($this->columnExists('title')) return $this->title;
return;
}
|
[
"public",
"function",
"editingTitle",
"(",
")",
"{",
"$",
"editingTitle",
"=",
"$",
"this",
"->",
"admin",
"(",
")",
"->",
"editingTitle",
";",
"// Check for the custom option first and",
"// return it if it exists",
"if",
"(",
"$",
"this",
"->",
"columnExists",
"(",
"$",
"editingTitle",
")",
")",
"return",
"$",
"this",
"->",
"{",
"$",
"editingTitle",
"}",
";",
"// As a last-ditch effort, see if there's a title option",
"// we can use so the user doesn't have to ask for it",
"if",
"(",
"$",
"this",
"->",
"columnExists",
"(",
"'title'",
")",
")",
"return",
"$",
"this",
"->",
"title",
";",
"return",
";",
"}"
] |
Get the editing title for the model
@return mixed
|
[
"Get",
"the",
"editing",
"title",
"for",
"the",
"model"
] |
6e140e341980d6f9467418594eed48c3859c00f7
|
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Models/BumbleModel.php#L328-L341
|
232,348
|
cawaphp/cawa
|
src/Intl/Translator.php
|
Translator.initLocale
|
private function initLocale()
{
$this->locale = $this->detectLocale();
// datetime format
if (!setlocale(LC_TIME, $this->locales[$this->locale])) {
throw new \Exception(sprintf("Unable to set locale to '%s'", $this->locales[$this->locale]));
}
// punic default value
Data::setDefaultLocale($this->getIETF());
if ('cli' !== PHP_SAPI) {
if (!self::request()->getCookie(self::COOKIE_LANGUAGE)) {
self::response()->addCookie(new Cookie(self::COOKIE_LANGUAGE, $this->locale, 60 * 60 * 24 * 365));
}
}
}
|
php
|
private function initLocale()
{
$this->locale = $this->detectLocale();
// datetime format
if (!setlocale(LC_TIME, $this->locales[$this->locale])) {
throw new \Exception(sprintf("Unable to set locale to '%s'", $this->locales[$this->locale]));
}
// punic default value
Data::setDefaultLocale($this->getIETF());
if ('cli' !== PHP_SAPI) {
if (!self::request()->getCookie(self::COOKIE_LANGUAGE)) {
self::response()->addCookie(new Cookie(self::COOKIE_LANGUAGE, $this->locale, 60 * 60 * 24 * 365));
}
}
}
|
[
"private",
"function",
"initLocale",
"(",
")",
"{",
"$",
"this",
"->",
"locale",
"=",
"$",
"this",
"->",
"detectLocale",
"(",
")",
";",
"// datetime format",
"if",
"(",
"!",
"setlocale",
"(",
"LC_TIME",
",",
"$",
"this",
"->",
"locales",
"[",
"$",
"this",
"->",
"locale",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"Unable to set locale to '%s'\"",
",",
"$",
"this",
"->",
"locales",
"[",
"$",
"this",
"->",
"locale",
"]",
")",
")",
";",
"}",
"// punic default value",
"Data",
"::",
"setDefaultLocale",
"(",
"$",
"this",
"->",
"getIETF",
"(",
")",
")",
";",
"if",
"(",
"'cli'",
"!==",
"PHP_SAPI",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"request",
"(",
")",
"->",
"getCookie",
"(",
"self",
"::",
"COOKIE_LANGUAGE",
")",
")",
"{",
"self",
"::",
"response",
"(",
")",
"->",
"addCookie",
"(",
"new",
"Cookie",
"(",
"self",
"::",
"COOKIE_LANGUAGE",
",",
"$",
"this",
"->",
"locale",
",",
"60",
"*",
"60",
"*",
"24",
"*",
"365",
")",
")",
";",
"}",
"}",
"}"
] |
detect locale & set cookie if neccesary.
@throws \Exception
|
[
"detect",
"locale",
"&",
"set",
"cookie",
"if",
"neccesary",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Intl/Translator.php#L119-L136
|
232,349
|
rymanalu/laravel-circuit-breaker
|
src/CircuitBreaker.php
|
CircuitBreaker.tooManyFailures
|
public function tooManyFailures($key, $maxFailures, $decayMinutes = 1)
{
if ($this->cache->has($key.':breakout')) {
return true;
}
if ($this->failures($key) > $maxFailures) {
$this->cache->add($key.':breakout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes);
$this->resetFailures($key);
return true;
}
return false;
}
|
php
|
public function tooManyFailures($key, $maxFailures, $decayMinutes = 1)
{
if ($this->cache->has($key.':breakout')) {
return true;
}
if ($this->failures($key) > $maxFailures) {
$this->cache->add($key.':breakout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes);
$this->resetFailures($key);
return true;
}
return false;
}
|
[
"public",
"function",
"tooManyFailures",
"(",
"$",
"key",
",",
"$",
"maxFailures",
",",
"$",
"decayMinutes",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"key",
".",
"':breakout'",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"failures",
"(",
"$",
"key",
")",
">",
"$",
"maxFailures",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"add",
"(",
"$",
"key",
".",
"':breakout'",
",",
"Carbon",
"::",
"now",
"(",
")",
"->",
"getTimestamp",
"(",
")",
"+",
"(",
"$",
"decayMinutes",
"*",
"60",
")",
",",
"$",
"decayMinutes",
")",
";",
"$",
"this",
"->",
"resetFailures",
"(",
"$",
"key",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Determine if the given key has too many failures.
@param string $key
@param int $maxFailures
@param int $decayMinutes
@return bool
|
[
"Determine",
"if",
"the",
"given",
"key",
"has",
"too",
"many",
"failures",
"."
] |
cea249e048eb0276c8a54fe3c81db830328298fe
|
https://github.com/rymanalu/laravel-circuit-breaker/blob/cea249e048eb0276c8a54fe3c81db830328298fe/src/CircuitBreaker.php#L72-L87
|
232,350
|
chippyash/Builder-Pattern
|
examples/Builder/PurchaseCollectionBuilder.php
|
PurchaseCollectionBuilder.setModifier
|
public function setModifier(EventManagerAwareInterface $modifier)
{
parent::setModifier($modifier);
$this->modifier->getEventManager()->attach(ModifiableInterface::PHASE_PRE_BUILD, [$this,'preBuildListener']);
}
|
php
|
public function setModifier(EventManagerAwareInterface $modifier)
{
parent::setModifier($modifier);
$this->modifier->getEventManager()->attach(ModifiableInterface::PHASE_PRE_BUILD, [$this,'preBuildListener']);
}
|
[
"public",
"function",
"setModifier",
"(",
"EventManagerAwareInterface",
"$",
"modifier",
")",
"{",
"parent",
"::",
"setModifier",
"(",
"$",
"modifier",
")",
";",
"$",
"this",
"->",
"modifier",
"->",
"getEventManager",
"(",
")",
"->",
"attach",
"(",
"ModifiableInterface",
"::",
"PHASE_PRE_BUILD",
",",
"[",
"$",
"this",
",",
"'preBuildListener'",
"]",
")",
";",
"}"
] |
Extend setModifier to add our listeners
@param EventManagerAwareInterface $modifier
|
[
"Extend",
"setModifier",
"to",
"add",
"our",
"listeners"
] |
00be4830438542abe494ac9be0bbd27723a0c984
|
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/examples/Builder/PurchaseCollectionBuilder.php#L28-L32
|
232,351
|
monarkee/bumble
|
Fields/PasswordField.php
|
PasswordField.process
|
public function process($model, $input)
{
$column = $this->getColumn();
// If the column is empty then it means they don't require it
// and so we can just return the model unchanged.
if (empty($input[$column])) return $model;
// Use our built-in hashing using Laravel's Hasher
if ($this->getHashOption())
{
$model->{$column} = $this->hasher->make($input[$column]);
return $model;
}
// The user hasn't disabled hashing or is using their own mutator
// so just save the value to the model and return it
$model->{$column} = $input[$column];
return $model;
}
|
php
|
public function process($model, $input)
{
$column = $this->getColumn();
// If the column is empty then it means they don't require it
// and so we can just return the model unchanged.
if (empty($input[$column])) return $model;
// Use our built-in hashing using Laravel's Hasher
if ($this->getHashOption())
{
$model->{$column} = $this->hasher->make($input[$column]);
return $model;
}
// The user hasn't disabled hashing or is using their own mutator
// so just save the value to the model and return it
$model->{$column} = $input[$column];
return $model;
}
|
[
"public",
"function",
"process",
"(",
"$",
"model",
",",
"$",
"input",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getColumn",
"(",
")",
";",
"// If the column is empty then it means they don't require it",
"// and so we can just return the model unchanged.",
"if",
"(",
"empty",
"(",
"$",
"input",
"[",
"$",
"column",
"]",
")",
")",
"return",
"$",
"model",
";",
"// Use our built-in hashing using Laravel's Hasher",
"if",
"(",
"$",
"this",
"->",
"getHashOption",
"(",
")",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"column",
"}",
"=",
"$",
"this",
"->",
"hasher",
"->",
"make",
"(",
"$",
"input",
"[",
"$",
"column",
"]",
")",
";",
"return",
"$",
"model",
";",
"}",
"// The user hasn't disabled hashing or is using their own mutator",
"// so just save the value to the model and return it",
"$",
"model",
"->",
"{",
"$",
"column",
"}",
"=",
"$",
"input",
"[",
"$",
"column",
"]",
";",
"return",
"$",
"model",
";",
"}"
] |
Process the password input and hash unless otherwise specified
@param $model
@param $input
@return mixed
|
[
"Process",
"the",
"password",
"input",
"and",
"hash",
"unless",
"otherwise",
"specified"
] |
6e140e341980d6f9467418594eed48c3859c00f7
|
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/PasswordField.php#L51-L71
|
232,352
|
axypro/sourcemap
|
helpers/MapBuilder.php
|
MapBuilder.build
|
public static function build($pointer)
{
if (is_string($pointer)) {
return SourceMap::loadFromFile($pointer);
}
if (is_array($pointer)) {
return new SourceMap($pointer);
}
if ($pointer instanceof SourceMap) {
return $pointer;
}
throw new \InvalidArgumentException('Argument must be a SourceMap or a data array or a file name');
}
|
php
|
public static function build($pointer)
{
if (is_string($pointer)) {
return SourceMap::loadFromFile($pointer);
}
if (is_array($pointer)) {
return new SourceMap($pointer);
}
if ($pointer instanceof SourceMap) {
return $pointer;
}
throw new \InvalidArgumentException('Argument must be a SourceMap or a data array or a file name');
}
|
[
"public",
"static",
"function",
"build",
"(",
"$",
"pointer",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"pointer",
")",
")",
"{",
"return",
"SourceMap",
"::",
"loadFromFile",
"(",
"$",
"pointer",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"pointer",
")",
")",
"{",
"return",
"new",
"SourceMap",
"(",
"$",
"pointer",
")",
";",
"}",
"if",
"(",
"$",
"pointer",
"instanceof",
"SourceMap",
")",
"{",
"return",
"$",
"pointer",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument must be a SourceMap or a data array or a file name'",
")",
";",
"}"
] |
Builds a source map instance
@param \axy\sourcemap\SourceMap|array|string $pointer
a source map, an array of data or a file name
@return \axy\sourcemap\SourceMap
@throws \axy\sourcemap\errors\IOError
@throws \axy\sourcemap\errors\InvalidFormat
@throws \InvalidArgumentException
|
[
"Builds",
"a",
"source",
"map",
"instance"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/helpers/MapBuilder.php#L26-L38
|
232,353
|
mailmotor/mailchimp-bundle
|
Gateway/MailChimpSubscriberGateway.php
|
MailChimpSubscriberGateway.get
|
private function get(string $email, string $listId): array
{
try {
/** @var Collection $result */
$result = $this->api->request(
'lists/' . $listId . '/members/' . $this->getHashedEmail($email),
array(),
'get'
);
// will return the one and only member array('id', ...) from Collection
return $result->all();
} catch (\Exception $e) {
return [];
}
}
|
php
|
private function get(string $email, string $listId): array
{
try {
/** @var Collection $result */
$result = $this->api->request(
'lists/' . $listId . '/members/' . $this->getHashedEmail($email),
array(),
'get'
);
// will return the one and only member array('id', ...) from Collection
return $result->all();
} catch (\Exception $e) {
return [];
}
}
|
[
"private",
"function",
"get",
"(",
"string",
"$",
"email",
",",
"string",
"$",
"listId",
")",
":",
"array",
"{",
"try",
"{",
"/** @var Collection $result */",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'lists/'",
".",
"$",
"listId",
".",
"'/members/'",
".",
"$",
"this",
"->",
"getHashedEmail",
"(",
"$",
"email",
")",
",",
"array",
"(",
")",
",",
"'get'",
")",
";",
"// will return the one and only member array('id', ...) from Collection",
"return",
"$",
"result",
"->",
"all",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"[",
"]",
";",
"}",
"}"
] |
Get a subscriber
@param string $email
@param string $listId
@return array
|
[
"Get",
"a",
"subscriber"
] |
97e5b409000cc60ea3e9e985b786b36ae0dc3175
|
https://github.com/mailmotor/mailchimp-bundle/blob/97e5b409000cc60ea3e9e985b786b36ae0dc3175/Gateway/MailChimpSubscriberGateway.php#L51-L66
|
232,354
|
youngguns-nl/moneybird_php_api
|
HttpClient/Oauth.php
|
Oauth.setConsumerAndToken
|
public function setConsumerAndToken(OAuthConsumer $consumer, OAuthConsumer $token)
{
$this->consumer = $consumer;
$this->token = $token;
return $this;
}
|
php
|
public function setConsumerAndToken(OAuthConsumer $consumer, OAuthConsumer $token)
{
$this->consumer = $consumer;
$this->token = $token;
return $this;
}
|
[
"public",
"function",
"setConsumerAndToken",
"(",
"OAuthConsumer",
"$",
"consumer",
",",
"OAuthConsumer",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"consumer",
"=",
"$",
"consumer",
";",
"$",
"this",
"->",
"token",
"=",
"$",
"token",
";",
"return",
"$",
"this",
";",
"}"
] |
Set Consumer and Token
@param Lib\OAuthConsumer $consumer
@param Lib\OAuthConsumer $token
@return HttpClient_Oauth
|
[
"Set",
"Consumer",
"and",
"Token"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/HttpClient/Oauth.php#L44-L49
|
232,355
|
axypro/sourcemap
|
parsing/Line.php
|
Line.loadFromPlainList
|
public static function loadFromPlainList($num, array $positions)
{
$rPositions = [];
foreach ($positions as $pos) {
$rPositions[$pos->generated->column] = $pos;
}
return new self($num, $rPositions);
}
|
php
|
public static function loadFromPlainList($num, array $positions)
{
$rPositions = [];
foreach ($positions as $pos) {
$rPositions[$pos->generated->column] = $pos;
}
return new self($num, $rPositions);
}
|
[
"public",
"static",
"function",
"loadFromPlainList",
"(",
"$",
"num",
",",
"array",
"$",
"positions",
")",
"{",
"$",
"rPositions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"positions",
"as",
"$",
"pos",
")",
"{",
"$",
"rPositions",
"[",
"$",
"pos",
"->",
"generated",
"->",
"column",
"]",
"=",
"$",
"pos",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"num",
",",
"$",
"rPositions",
")",
";",
"}"
] |
Loads the positions list from a numeric array
@param int $num
@param \axy\sourcemap\PosMap[] $positions
@return \axy\sourcemap\parsing\Line
|
[
"Loads",
"the",
"positions",
"list",
"from",
"a",
"numeric",
"array"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Line.php#L38-L45
|
232,356
|
axypro/sourcemap
|
parsing/Line.php
|
Line.loadFromMappings
|
public static function loadFromMappings($num, $lMappings, SegmentParser $parser, Context $context)
{
$positions = [];
$names = $context->names;
$files = $context->sources;
$parser->nextLine($num);
foreach (explode(',', $lMappings) as $segment) {
$pos = $parser->parse($segment);
$positions[$pos->generated->column] = $pos;
$source = $pos->source;
$fi = $source->fileIndex;
if ($fi !== null) {
if (isset($files[$fi])) {
$source->fileName = $files[$fi];
} else {
$message = 'Invalid segment "'.$segment.'" (source offset '.$fi.')';
throw new InvalidMappings($message);
}
$ni = $source->nameIndex;
if ($ni !== null) {
if (isset($names[$ni])) {
$source->name = $names[$ni];
} else {
$message = 'Invalid segment "'.$segment.'" (name offset '.$ni.')';
throw new InvalidMappings($message);
}
}
}
}
return new self($num, $positions);
}
|
php
|
public static function loadFromMappings($num, $lMappings, SegmentParser $parser, Context $context)
{
$positions = [];
$names = $context->names;
$files = $context->sources;
$parser->nextLine($num);
foreach (explode(',', $lMappings) as $segment) {
$pos = $parser->parse($segment);
$positions[$pos->generated->column] = $pos;
$source = $pos->source;
$fi = $source->fileIndex;
if ($fi !== null) {
if (isset($files[$fi])) {
$source->fileName = $files[$fi];
} else {
$message = 'Invalid segment "'.$segment.'" (source offset '.$fi.')';
throw new InvalidMappings($message);
}
$ni = $source->nameIndex;
if ($ni !== null) {
if (isset($names[$ni])) {
$source->name = $names[$ni];
} else {
$message = 'Invalid segment "'.$segment.'" (name offset '.$ni.')';
throw new InvalidMappings($message);
}
}
}
}
return new self($num, $positions);
}
|
[
"public",
"static",
"function",
"loadFromMappings",
"(",
"$",
"num",
",",
"$",
"lMappings",
",",
"SegmentParser",
"$",
"parser",
",",
"Context",
"$",
"context",
")",
"{",
"$",
"positions",
"=",
"[",
"]",
";",
"$",
"names",
"=",
"$",
"context",
"->",
"names",
";",
"$",
"files",
"=",
"$",
"context",
"->",
"sources",
";",
"$",
"parser",
"->",
"nextLine",
"(",
"$",
"num",
")",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"lMappings",
")",
"as",
"$",
"segment",
")",
"{",
"$",
"pos",
"=",
"$",
"parser",
"->",
"parse",
"(",
"$",
"segment",
")",
";",
"$",
"positions",
"[",
"$",
"pos",
"->",
"generated",
"->",
"column",
"]",
"=",
"$",
"pos",
";",
"$",
"source",
"=",
"$",
"pos",
"->",
"source",
";",
"$",
"fi",
"=",
"$",
"source",
"->",
"fileIndex",
";",
"if",
"(",
"$",
"fi",
"!==",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"$",
"fi",
"]",
")",
")",
"{",
"$",
"source",
"->",
"fileName",
"=",
"$",
"files",
"[",
"$",
"fi",
"]",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"'Invalid segment \"'",
".",
"$",
"segment",
".",
"'\" (source offset '",
".",
"$",
"fi",
".",
"')'",
";",
"throw",
"new",
"InvalidMappings",
"(",
"$",
"message",
")",
";",
"}",
"$",
"ni",
"=",
"$",
"source",
"->",
"nameIndex",
";",
"if",
"(",
"$",
"ni",
"!==",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"names",
"[",
"$",
"ni",
"]",
")",
")",
"{",
"$",
"source",
"->",
"name",
"=",
"$",
"names",
"[",
"$",
"ni",
"]",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"'Invalid segment \"'",
".",
"$",
"segment",
".",
"'\" (name offset '",
".",
"$",
"ni",
".",
"')'",
";",
"throw",
"new",
"InvalidMappings",
"(",
"$",
"message",
")",
";",
"}",
"}",
"}",
"}",
"return",
"new",
"self",
"(",
"$",
"num",
",",
"$",
"positions",
")",
";",
"}"
] |
Loads the positions list from a mappings line
@param int $num
@param string $lMappings
@param \axy\sourcemap\parsing\SegmentParser $parser
@param \axy\sourcemap\parsing\Context $context
@return \axy\sourcemap\parsing\Line
@throws \axy\sourcemap\errors\InvalidMappings
|
[
"Loads",
"the",
"positions",
"list",
"from",
"a",
"mappings",
"line"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Line.php#L57-L87
|
232,357
|
axypro/sourcemap
|
parsing/Line.php
|
Line.pack
|
public function pack(SegmentParser $parser)
{
ksort($this->positions);
$segments = [];
foreach ($this->positions as $pos) {
$segments[] = $parser->pack($pos);
}
return implode(',', $segments);
}
|
php
|
public function pack(SegmentParser $parser)
{
ksort($this->positions);
$segments = [];
foreach ($this->positions as $pos) {
$segments[] = $parser->pack($pos);
}
return implode(',', $segments);
}
|
[
"public",
"function",
"pack",
"(",
"SegmentParser",
"$",
"parser",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"positions",
")",
";",
"$",
"segments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"positions",
"as",
"$",
"pos",
")",
"{",
"$",
"segments",
"[",
"]",
"=",
"$",
"parser",
"->",
"pack",
"(",
"$",
"pos",
")",
";",
"}",
"return",
"implode",
"(",
"','",
",",
"$",
"segments",
")",
";",
"}"
] |
Packs the line to the mappings
@param \axy\sourcemap\parsing\SegmentParser $parser
@return string
|
[
"Packs",
"the",
"line",
"to",
"the",
"mappings"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Line.php#L115-L123
|
232,358
|
axypro/sourcemap
|
parsing/Line.php
|
Line.breakLine
|
public function breakLine($sColumn, $length, $newNum)
{
$newPositions = [];
foreach ($this->positions as $column => $position) {
if ($column >= $sColumn) {
$newColumn = $column + $length;
$position->generated->line = $newNum;
$position->generated->column = $newColumn;
$newPositions[$newColumn] = $position;
unset($this->positions[$column]);
}
}
if (empty($newPositions)) {
return null;
}
return new self($newNum, $newPositions);
}
|
php
|
public function breakLine($sColumn, $length, $newNum)
{
$newPositions = [];
foreach ($this->positions as $column => $position) {
if ($column >= $sColumn) {
$newColumn = $column + $length;
$position->generated->line = $newNum;
$position->generated->column = $newColumn;
$newPositions[$newColumn] = $position;
unset($this->positions[$column]);
}
}
if (empty($newPositions)) {
return null;
}
return new self($newNum, $newPositions);
}
|
[
"public",
"function",
"breakLine",
"(",
"$",
"sColumn",
",",
"$",
"length",
",",
"$",
"newNum",
")",
"{",
"$",
"newPositions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"positions",
"as",
"$",
"column",
"=>",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"column",
">=",
"$",
"sColumn",
")",
"{",
"$",
"newColumn",
"=",
"$",
"column",
"+",
"$",
"length",
";",
"$",
"position",
"->",
"generated",
"->",
"line",
"=",
"$",
"newNum",
";",
"$",
"position",
"->",
"generated",
"->",
"column",
"=",
"$",
"newColumn",
";",
"$",
"newPositions",
"[",
"$",
"newColumn",
"]",
"=",
"$",
"position",
";",
"unset",
"(",
"$",
"this",
"->",
"positions",
"[",
"$",
"column",
"]",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"newPositions",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"newNum",
",",
"$",
"newPositions",
")",
";",
"}"
] |
Breaks the line on a column
@param int $sColumn
@param int $length
@param int $newNum
@return \axy\sourcemap\parsing\Line
|
[
"Breaks",
"the",
"line",
"on",
"a",
"column"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Line.php#L344-L360
|
232,359
|
axypro/sourcemap
|
parsing/Line.php
|
Line.removeBlockBegin
|
public function removeBlockBegin($eColumn)
{
$shifts = [];
foreach ($this->positions as $column => $position) {
if ($column >= $eColumn) {
$newColumn = $column - $eColumn;
$position->generated->column = $newColumn;
$shifts[$newColumn] = $position;
}
unset($this->positions[$column]);
}
if (!empty($shifts)) {
$this->positions = array_replace($this->positions, $shifts);
}
}
|
php
|
public function removeBlockBegin($eColumn)
{
$shifts = [];
foreach ($this->positions as $column => $position) {
if ($column >= $eColumn) {
$newColumn = $column - $eColumn;
$position->generated->column = $newColumn;
$shifts[$newColumn] = $position;
}
unset($this->positions[$column]);
}
if (!empty($shifts)) {
$this->positions = array_replace($this->positions, $shifts);
}
}
|
[
"public",
"function",
"removeBlockBegin",
"(",
"$",
"eColumn",
")",
"{",
"$",
"shifts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"positions",
"as",
"$",
"column",
"=>",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"column",
">=",
"$",
"eColumn",
")",
"{",
"$",
"newColumn",
"=",
"$",
"column",
"-",
"$",
"eColumn",
";",
"$",
"position",
"->",
"generated",
"->",
"column",
"=",
"$",
"newColumn",
";",
"$",
"shifts",
"[",
"$",
"newColumn",
"]",
"=",
"$",
"position",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"positions",
"[",
"$",
"column",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"shifts",
")",
")",
"{",
"$",
"this",
"->",
"positions",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"positions",
",",
"$",
"shifts",
")",
";",
"}",
"}"
] |
Removes a block from the begin of the line
@param int $eColumn
|
[
"Removes",
"a",
"block",
"from",
"the",
"begin",
"of",
"the",
"line"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Line.php#L392-L406
|
232,360
|
axypro/sourcemap
|
parsing/Line.php
|
Line.setNum
|
public function setNum($num)
{
$this->num = $num;
foreach ($this->positions as $position) {
$position->generated->line = $num;
}
}
|
php
|
public function setNum($num)
{
$this->num = $num;
foreach ($this->positions as $position) {
$position->generated->line = $num;
}
}
|
[
"public",
"function",
"setNum",
"(",
"$",
"num",
")",
"{",
"$",
"this",
"->",
"num",
"=",
"$",
"num",
";",
"foreach",
"(",
"$",
"this",
"->",
"positions",
"as",
"$",
"position",
")",
"{",
"$",
"position",
"->",
"generated",
"->",
"line",
"=",
"$",
"num",
";",
"}",
"}"
] |
Sets num of the line
@param int $num
|
[
"Sets",
"num",
"of",
"the",
"line"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Line.php#L433-L439
|
232,361
|
praxisnetau/silverstripe-moderno-admin
|
code/extensions/ModernoAdminExtension.php
|
ModernoAdminExtension.init
|
public function init()
{
if (class_exists("SiteConfig") && $SiteConfig = SiteConfig::current_site_config()) {
// Load Moderno Custom CSS:
Requirements::customCSS($SiteConfig->renderWith('ModernoAdminCustomCSS'));
// Customise Application Name:
if ($application_name = $SiteConfig->ModernoApplicationName) {
Config::inst()->update(
'LeftAndMain',
'application_name',
$application_name
);
}
// Customise Application Link:
if ($application_link = $SiteConfig->ModernoApplicationLink) {
Config::inst()->update(
'LeftAndMain',
'application_link',
$SiteConfig->dbObject('ModernoApplicationLink')->URL()
);
}
}
}
|
php
|
public function init()
{
if (class_exists("SiteConfig") && $SiteConfig = SiteConfig::current_site_config()) {
// Load Moderno Custom CSS:
Requirements::customCSS($SiteConfig->renderWith('ModernoAdminCustomCSS'));
// Customise Application Name:
if ($application_name = $SiteConfig->ModernoApplicationName) {
Config::inst()->update(
'LeftAndMain',
'application_name',
$application_name
);
}
// Customise Application Link:
if ($application_link = $SiteConfig->ModernoApplicationLink) {
Config::inst()->update(
'LeftAndMain',
'application_link',
$SiteConfig->dbObject('ModernoApplicationLink')->URL()
);
}
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"class_exists",
"(",
"\"SiteConfig\"",
")",
"&&",
"$",
"SiteConfig",
"=",
"SiteConfig",
"::",
"current_site_config",
"(",
")",
")",
"{",
"// Load Moderno Custom CSS:",
"Requirements",
"::",
"customCSS",
"(",
"$",
"SiteConfig",
"->",
"renderWith",
"(",
"'ModernoAdminCustomCSS'",
")",
")",
";",
"// Customise Application Name:",
"if",
"(",
"$",
"application_name",
"=",
"$",
"SiteConfig",
"->",
"ModernoApplicationName",
")",
"{",
"Config",
"::",
"inst",
"(",
")",
"->",
"update",
"(",
"'LeftAndMain'",
",",
"'application_name'",
",",
"$",
"application_name",
")",
";",
"}",
"// Customise Application Link:",
"if",
"(",
"$",
"application_link",
"=",
"$",
"SiteConfig",
"->",
"ModernoApplicationLink",
")",
"{",
"Config",
"::",
"inst",
"(",
")",
"->",
"update",
"(",
"'LeftAndMain'",
",",
"'application_link'",
",",
"$",
"SiteConfig",
"->",
"dbObject",
"(",
"'ModernoApplicationLink'",
")",
"->",
"URL",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Initialises the extension by generating custom CSS for the CMS interface.
|
[
"Initialises",
"the",
"extension",
"by",
"generating",
"custom",
"CSS",
"for",
"the",
"CMS",
"interface",
"."
] |
8e09b43ca84eea6d3d556fe0f459860c2a397703
|
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/ModernoAdminExtension.php#L11-L44
|
232,362
|
mmanos/laravel-api
|
src/Mmanos/Api/Authentication/Client.php
|
Client.scopes
|
public function scopes()
{
if (isset($this->scopes)) {
return $this->scopes;
}
return $this->scopes = DB::table('oauth_client_scopes')
->select('scope_id')
->where('client_id', $this->id)
->lists('scope_id');
}
|
php
|
public function scopes()
{
if (isset($this->scopes)) {
return $this->scopes;
}
return $this->scopes = DB::table('oauth_client_scopes')
->select('scope_id')
->where('client_id', $this->id)
->lists('scope_id');
}
|
[
"public",
"function",
"scopes",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"scopes",
")",
")",
"{",
"return",
"$",
"this",
"->",
"scopes",
";",
"}",
"return",
"$",
"this",
"->",
"scopes",
"=",
"DB",
"::",
"table",
"(",
"'oauth_client_scopes'",
")",
"->",
"select",
"(",
"'scope_id'",
")",
"->",
"where",
"(",
"'client_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"lists",
"(",
"'scope_id'",
")",
";",
"}"
] |
Return the allowed scopes for this client.
@return array
|
[
"Return",
"the",
"allowed",
"scopes",
"for",
"this",
"client",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Authentication/Client.php#L32-L42
|
232,363
|
mmanos/laravel-api
|
src/Mmanos/Api/Authentication/Client.php
|
Client.endpoints
|
public function endpoints()
{
if (isset($this->endpoints)) {
return $this->endpoints;
}
return $this->endpoints = DB::table('oauth_client_endpoints')
->select('redirect_uri')
->where('client_id', $this->id)
->lists('redirect_uri');
}
|
php
|
public function endpoints()
{
if (isset($this->endpoints)) {
return $this->endpoints;
}
return $this->endpoints = DB::table('oauth_client_endpoints')
->select('redirect_uri')
->where('client_id', $this->id)
->lists('redirect_uri');
}
|
[
"public",
"function",
"endpoints",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"endpoints",
")",
")",
"{",
"return",
"$",
"this",
"->",
"endpoints",
";",
"}",
"return",
"$",
"this",
"->",
"endpoints",
"=",
"DB",
"::",
"table",
"(",
"'oauth_client_endpoints'",
")",
"->",
"select",
"(",
"'redirect_uri'",
")",
"->",
"where",
"(",
"'client_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"lists",
"(",
"'redirect_uri'",
")",
";",
"}"
] |
Return the allowed endpoints for this client.
@return array
|
[
"Return",
"the",
"allowed",
"endpoints",
"for",
"this",
"client",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Authentication/Client.php#L49-L59
|
232,364
|
mmanos/laravel-api
|
src/Mmanos/Api/Authentication/Client.php
|
Client.grants
|
public function grants()
{
if (isset($this->grants)) {
return $this->grants;
}
return $this->grants = DB::table('oauth_client_grants')
->select('grant_id')
->where('client_id', $this->id)
->lists('grant_id');
}
|
php
|
public function grants()
{
if (isset($this->grants)) {
return $this->grants;
}
return $this->grants = DB::table('oauth_client_grants')
->select('grant_id')
->where('client_id', $this->id)
->lists('grant_id');
}
|
[
"public",
"function",
"grants",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"grants",
")",
")",
"{",
"return",
"$",
"this",
"->",
"grants",
";",
"}",
"return",
"$",
"this",
"->",
"grants",
"=",
"DB",
"::",
"table",
"(",
"'oauth_client_grants'",
")",
"->",
"select",
"(",
"'grant_id'",
")",
"->",
"where",
"(",
"'client_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"lists",
"(",
"'grant_id'",
")",
";",
"}"
] |
Return the allowed grants for this client.
@return array
|
[
"Return",
"the",
"allowed",
"grants",
"for",
"this",
"client",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Authentication/Client.php#L66-L76
|
232,365
|
jack-theripper/transcoder
|
src/Filter/Volume.php
|
Volume.setPrecision
|
public function setPrecision($precision)
{
$available = [self::PRECISION_FIXED, self::PRECISION_DOUBLE, self::PRECISION_FLOAT];
if ( ! is_scalar($precision) || ! in_array($precision, $available, false))
{
throw new \InvalidArgumentException(sprintf('Wrong precision value for %s, available values are %s',
(string) $precision, implode(', ', $available)));
}
$this->precision = (string) $precision;
return $this;
}
|
php
|
public function setPrecision($precision)
{
$available = [self::PRECISION_FIXED, self::PRECISION_DOUBLE, self::PRECISION_FLOAT];
if ( ! is_scalar($precision) || ! in_array($precision, $available, false))
{
throw new \InvalidArgumentException(sprintf('Wrong precision value for %s, available values are %s',
(string) $precision, implode(', ', $available)));
}
$this->precision = (string) $precision;
return $this;
}
|
[
"public",
"function",
"setPrecision",
"(",
"$",
"precision",
")",
"{",
"$",
"available",
"=",
"[",
"self",
"::",
"PRECISION_FIXED",
",",
"self",
"::",
"PRECISION_DOUBLE",
",",
"self",
"::",
"PRECISION_FLOAT",
"]",
";",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"precision",
")",
"||",
"!",
"in_array",
"(",
"$",
"precision",
",",
"$",
"available",
",",
"false",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Wrong precision value for %s, available values are %s'",
",",
"(",
"string",
")",
"$",
"precision",
",",
"implode",
"(",
"', '",
",",
"$",
"available",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"precision",
"=",
"(",
"string",
")",
"$",
"precision",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the precision value.
@param string $precision
@return Volume
@throws \InvalidArgumentException
|
[
"Set",
"the",
"precision",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Volume.php#L184-L197
|
232,366
|
jack-theripper/transcoder
|
src/Filter/Volume.php
|
Volume.setReplayGain
|
public function setReplayGain($replayGain)
{
$values = [self::REPLAY_GAIN_DROP, self::REPLAY_GAIN_IGNORE, self::REPLAY_GAIN_TRACK, self::REPLAY_GAIN_ALBUM];
if ( ! is_scalar($replayGain) || ! in_array($replayGain, $values, false))
{
throw new \InvalidArgumentException(sprintf('Wrong replayGain value for %s, available values are %s',
(string) $replayGain, implode(', ', $values)));
}
$this->replayGain = (string) $replayGain;
return $this;
}
|
php
|
public function setReplayGain($replayGain)
{
$values = [self::REPLAY_GAIN_DROP, self::REPLAY_GAIN_IGNORE, self::REPLAY_GAIN_TRACK, self::REPLAY_GAIN_ALBUM];
if ( ! is_scalar($replayGain) || ! in_array($replayGain, $values, false))
{
throw new \InvalidArgumentException(sprintf('Wrong replayGain value for %s, available values are %s',
(string) $replayGain, implode(', ', $values)));
}
$this->replayGain = (string) $replayGain;
return $this;
}
|
[
"public",
"function",
"setReplayGain",
"(",
"$",
"replayGain",
")",
"{",
"$",
"values",
"=",
"[",
"self",
"::",
"REPLAY_GAIN_DROP",
",",
"self",
"::",
"REPLAY_GAIN_IGNORE",
",",
"self",
"::",
"REPLAY_GAIN_TRACK",
",",
"self",
"::",
"REPLAY_GAIN_ALBUM",
"]",
";",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"replayGain",
")",
"||",
"!",
"in_array",
"(",
"$",
"replayGain",
",",
"$",
"values",
",",
"false",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Wrong replayGain value for %s, available values are %s'",
",",
"(",
"string",
")",
"$",
"replayGain",
",",
"implode",
"(",
"', '",
",",
"$",
"values",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"replayGain",
"=",
"(",
"string",
")",
"$",
"replayGain",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the replay gain value.
@param string $replayGain
@return Volume
@throws \InvalidArgumentException
|
[
"Set",
"the",
"replay",
"gain",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Volume.php#L217-L230
|
232,367
|
jack-theripper/transcoder
|
src/Filter/Volume.php
|
Volume.setEval
|
public function setEval($eval)
{
$available = [self::EVAL_ONCE, self::EVAL_FRAME];
if ( ! is_scalar($eval) || ! in_array($eval, $available, false))
{
throw new \InvalidArgumentException(sprintf('Wrong eval value for %s, available values are %s',
(string) $eval, implode(', ', $available)));
}
$this->eval = (string) $eval;
return $this;
}
|
php
|
public function setEval($eval)
{
$available = [self::EVAL_ONCE, self::EVAL_FRAME];
if ( ! is_scalar($eval) || ! in_array($eval, $available, false))
{
throw new \InvalidArgumentException(sprintf('Wrong eval value for %s, available values are %s',
(string) $eval, implode(', ', $available)));
}
$this->eval = (string) $eval;
return $this;
}
|
[
"public",
"function",
"setEval",
"(",
"$",
"eval",
")",
"{",
"$",
"available",
"=",
"[",
"self",
"::",
"EVAL_ONCE",
",",
"self",
"::",
"EVAL_FRAME",
"]",
";",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"eval",
")",
"||",
"!",
"in_array",
"(",
"$",
"eval",
",",
"$",
"available",
",",
"false",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Wrong eval value for %s, available values are %s'",
",",
"(",
"string",
")",
"$",
"eval",
",",
"implode",
"(",
"', '",
",",
"$",
"available",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"eval",
"=",
"(",
"string",
")",
"$",
"eval",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the eval value.
@param string $eval
@return Volume
@throws \InvalidArgumentException
|
[
"Set",
"the",
"eval",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Volume.php#L280-L293
|
232,368
|
nineinchnick/yii2-usr
|
models/ExampleUserRemoteIdentity.php
|
ExampleUserRemoteIdentity.isUnique
|
public function isUnique($attribute, $params)
{
return null === self::find([
'user_id' => $this->user_id,
'provider' => $this->provider,
'identifier' => $this->identifier,
]);
}
|
php
|
public function isUnique($attribute, $params)
{
return null === self::find([
'user_id' => $this->user_id,
'provider' => $this->provider,
'identifier' => $this->identifier,
]);
}
|
[
"public",
"function",
"isUnique",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"return",
"null",
"===",
"self",
"::",
"find",
"(",
"[",
"'user_id'",
"=>",
"$",
"this",
"->",
"user_id",
",",
"'provider'",
"=>",
"$",
"this",
"->",
"provider",
",",
"'identifier'",
"=>",
"$",
"this",
"->",
"identifier",
",",
"]",
")",
";",
"}"
] |
An inline validator that checkes if there are no existing records
with same provider and identifier for specified user.
@param string $attribute
@param array $params
@return boolean
|
[
"An",
"inline",
"validator",
"that",
"checkes",
"if",
"there",
"are",
"no",
"existing",
"records",
"with",
"same",
"provider",
"and",
"identifier",
"for",
"specified",
"user",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUserRemoteIdentity.php#L50-L57
|
232,369
|
mmanos/laravel-api
|
src/Mmanos/Api/Cors.php
|
Cors.attachHeaders
|
public static function attachHeaders($response)
{
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', config('api.cors_allowed_headers', 'Origin, Content-Type, Accept, Authorization, X-Requested-With'));
$response->headers->set('Access-Control-Allow-Credentials', 'true');
if ($exposed = config('api.cors_exposed_headers', 'Pagination-Page, Pagination-Num, Pagination-Total, Pagination-Last-Page')) {
$response->headers->set('Access-Control-Expose-Headers', $exposed);
}
}
|
php
|
public static function attachHeaders($response)
{
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', config('api.cors_allowed_headers', 'Origin, Content-Type, Accept, Authorization, X-Requested-With'));
$response->headers->set('Access-Control-Allow-Credentials', 'true');
if ($exposed = config('api.cors_exposed_headers', 'Pagination-Page, Pagination-Num, Pagination-Total, Pagination-Last-Page')) {
$response->headers->set('Access-Control-Expose-Headers', $exposed);
}
}
|
[
"public",
"static",
"function",
"attachHeaders",
"(",
"$",
"response",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Allow-Methods'",
",",
"'GET, POST, PUT, DELETE, OPTIONS'",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Allow-Headers'",
",",
"config",
"(",
"'api.cors_allowed_headers'",
",",
"'Origin, Content-Type, Accept, Authorization, X-Requested-With'",
")",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Allow-Credentials'",
",",
"'true'",
")",
";",
"if",
"(",
"$",
"exposed",
"=",
"config",
"(",
"'api.cors_exposed_headers'",
",",
"'Pagination-Page, Pagination-Num, Pagination-Total, Pagination-Last-Page'",
")",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Expose-Headers'",
",",
"$",
"exposed",
")",
";",
"}",
"}"
] |
Attach CORS headers to the given response.
@param Response $response
@return void
|
[
"Attach",
"CORS",
"headers",
"to",
"the",
"given",
"response",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Cors.php#L18-L27
|
232,370
|
mmanos/laravel-api
|
src/Mmanos/Api/Cors.php
|
Cors.attachOriginHeader
|
public static function attachOriginHeader($response, $origin)
{
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
$response->headers->set('Access-Control-Allow-Origin', $origin);
return true;
}
if ('*' == config('api.cors_allowed_origin', 'client')) {
$response->headers->set('Access-Control-Allow-Origin', '*');
return true;
}
if ('client' == config('api.cors_allowed_origin', 'client')) {
$client = Authentication::instance()->client();
if (empty($client) || empty($client->endpoints())) {
return false;
}
foreach ($client->endpoints() as $endpoint) {
$parts = parse_url($endpoint);
if (empty($parts['scheme']) || empty($parts['host'])) {
continue;
}
$port = '';
if (array_get($parts, 'port')) {
$port = ':' . array_get($parts, 'port');
}
$url = $parts['scheme'] . '://' . $parts['host'] . $port;
if ($origin == $url) {
$response->headers->set('Access-Control-Allow-Origin', $url);
return true;
}
}
}
return false;
}
|
php
|
public static function attachOriginHeader($response, $origin)
{
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
$response->headers->set('Access-Control-Allow-Origin', $origin);
return true;
}
if ('*' == config('api.cors_allowed_origin', 'client')) {
$response->headers->set('Access-Control-Allow-Origin', '*');
return true;
}
if ('client' == config('api.cors_allowed_origin', 'client')) {
$client = Authentication::instance()->client();
if (empty($client) || empty($client->endpoints())) {
return false;
}
foreach ($client->endpoints() as $endpoint) {
$parts = parse_url($endpoint);
if (empty($parts['scheme']) || empty($parts['host'])) {
continue;
}
$port = '';
if (array_get($parts, 'port')) {
$port = ':' . array_get($parts, 'port');
}
$url = $parts['scheme'] . '://' . $parts['host'] . $port;
if ($origin == $url) {
$response->headers->set('Access-Control-Allow-Origin', $url);
return true;
}
}
}
return false;
}
|
[
"public",
"static",
"function",
"attachOriginHeader",
"(",
"$",
"response",
",",
"$",
"origin",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"===",
"'OPTIONS'",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Allow-Origin'",
",",
"$",
"origin",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"'*'",
"==",
"config",
"(",
"'api.cors_allowed_origin'",
",",
"'client'",
")",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Allow-Origin'",
",",
"'*'",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"'client'",
"==",
"config",
"(",
"'api.cors_allowed_origin'",
",",
"'client'",
")",
")",
"{",
"$",
"client",
"=",
"Authentication",
"::",
"instance",
"(",
")",
"->",
"client",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"client",
")",
"||",
"empty",
"(",
"$",
"client",
"->",
"endpoints",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"client",
"->",
"endpoints",
"(",
")",
"as",
"$",
"endpoint",
")",
"{",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"endpoint",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
")",
"||",
"empty",
"(",
"$",
"parts",
"[",
"'host'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"port",
"=",
"''",
";",
"if",
"(",
"array_get",
"(",
"$",
"parts",
",",
"'port'",
")",
")",
"{",
"$",
"port",
"=",
"':'",
".",
"array_get",
"(",
"$",
"parts",
",",
"'port'",
")",
";",
"}",
"$",
"url",
"=",
"$",
"parts",
"[",
"'scheme'",
"]",
".",
"'://'",
".",
"$",
"parts",
"[",
"'host'",
"]",
".",
"$",
"port",
";",
"if",
"(",
"$",
"origin",
"==",
"$",
"url",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Access-Control-Allow-Origin'",
",",
"$",
"url",
")",
";",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Attach a CORS origin header to the given response, if allowed.
Returns true if an origin header was set; false, otherwise.
@param Response $response
@param string $origin
@return bool
|
[
"Attach",
"a",
"CORS",
"origin",
"header",
"to",
"the",
"given",
"response",
"if",
"allowed",
".",
"Returns",
"true",
"if",
"an",
"origin",
"header",
"was",
"set",
";",
"false",
"otherwise",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/Cors.php#L38-L77
|
232,371
|
monarkee/bumble
|
Fields/DateTimeField.php
|
DateTimeField.process
|
public function process($model, $input)
{
$column = $this->getColumn();
// Handle a special case where the data in the database is 0000-00-00 00:00:00
if ($input[$column] == '-0001-11-30 00:00:00' || $input[$column] == '0000-00-00 00:00:00')
{
$model->{$column} = Carbon::now();
}
elseif (isset($input[$column]))
{
$model->{$column} = $input[$column];
}
if (empty($input[$column])) $model->{$column} = null;
return $model;
}
|
php
|
public function process($model, $input)
{
$column = $this->getColumn();
// Handle a special case where the data in the database is 0000-00-00 00:00:00
if ($input[$column] == '-0001-11-30 00:00:00' || $input[$column] == '0000-00-00 00:00:00')
{
$model->{$column} = Carbon::now();
}
elseif (isset($input[$column]))
{
$model->{$column} = $input[$column];
}
if (empty($input[$column])) $model->{$column} = null;
return $model;
}
|
[
"public",
"function",
"process",
"(",
"$",
"model",
",",
"$",
"input",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getColumn",
"(",
")",
";",
"// Handle a special case where the data in the database is 0000-00-00 00:00:00",
"if",
"(",
"$",
"input",
"[",
"$",
"column",
"]",
"==",
"'-0001-11-30 00:00:00'",
"||",
"$",
"input",
"[",
"$",
"column",
"]",
"==",
"'0000-00-00 00:00:00'",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"column",
"}",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"input",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"column",
"}",
"=",
"$",
"input",
"[",
"$",
"column",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"input",
"[",
"$",
"column",
"]",
")",
")",
"$",
"model",
"->",
"{",
"$",
"column",
"}",
"=",
"null",
";",
"return",
"$",
"model",
";",
"}"
] |
Process the DateTimeField data
@param $model
@param $input
@return BumbleModel
|
[
"Process",
"the",
"DateTimeField",
"data"
] |
6e140e341980d6f9467418594eed48c3859c00f7
|
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/DateTimeField.php#L34-L51
|
232,372
|
Speicher210/Reflection
|
src/ReflectionFile.php
|
ReflectionFile.reflect
|
private function reflect()
{
$tokens = token_get_all($this->reflectedFileContent);
$namespace = null;
$classLevel = 0;
$level = 0;
$res = $uses = array();
while (list(, $token) = each($tokens)) {
switch (is_array($token) ? $token[0] : $token) {
case T_CLASS:
case T_INTERFACE:
case T_TRAIT:
if ($name = $this->fetch($tokens, array(T_STRING))) {
$classLevel = $level + 1;
if ($namespace !== null) {
$objectFQN = $namespace . '\\' . $name;
} else {
$objectFQN = $name;
}
$this->objects[] = new ReflectionClass($objectFQN);
}
break;
case T_NAMESPACE:
$namespace = '\\' . ltrim($this->fetch($tokens, array(T_STRING, T_NS_SEPARATOR)), '\\');
$res[$namespace] = array();
$uses = array();
break;
case T_USE:
if ($classLevel === 0) {
while ($name = $this->fetch($tokens, array(T_STRING, T_NS_SEPARATOR))) {
$name = '\\' . ltrim($name, '\\');
if ($this->fetch($tokens, array(T_AS))) {
$uses[$this->fetch($tokens, array(T_STRING))] = $name;
} else {
$uses[$name] = $name;
}
if (!$this->fetch($tokens, array(','))) {
break;
}
}
$res[$namespace] = $uses;
}
break;
case T_CURLY_OPEN:
case T_DOLLAR_OPEN_CURLY_BRACES:
case '{':
$level++;
break;
case '}':
if ($level === $classLevel) {
$classLevel = 0;
}
$level--;
break;
}
}
$this->namespaces = array_keys($res);
$this->uses = $res;
}
|
php
|
private function reflect()
{
$tokens = token_get_all($this->reflectedFileContent);
$namespace = null;
$classLevel = 0;
$level = 0;
$res = $uses = array();
while (list(, $token) = each($tokens)) {
switch (is_array($token) ? $token[0] : $token) {
case T_CLASS:
case T_INTERFACE:
case T_TRAIT:
if ($name = $this->fetch($tokens, array(T_STRING))) {
$classLevel = $level + 1;
if ($namespace !== null) {
$objectFQN = $namespace . '\\' . $name;
} else {
$objectFQN = $name;
}
$this->objects[] = new ReflectionClass($objectFQN);
}
break;
case T_NAMESPACE:
$namespace = '\\' . ltrim($this->fetch($tokens, array(T_STRING, T_NS_SEPARATOR)), '\\');
$res[$namespace] = array();
$uses = array();
break;
case T_USE:
if ($classLevel === 0) {
while ($name = $this->fetch($tokens, array(T_STRING, T_NS_SEPARATOR))) {
$name = '\\' . ltrim($name, '\\');
if ($this->fetch($tokens, array(T_AS))) {
$uses[$this->fetch($tokens, array(T_STRING))] = $name;
} else {
$uses[$name] = $name;
}
if (!$this->fetch($tokens, array(','))) {
break;
}
}
$res[$namespace] = $uses;
}
break;
case T_CURLY_OPEN:
case T_DOLLAR_OPEN_CURLY_BRACES:
case '{':
$level++;
break;
case '}':
if ($level === $classLevel) {
$classLevel = 0;
}
$level--;
break;
}
}
$this->namespaces = array_keys($res);
$this->uses = $res;
}
|
[
"private",
"function",
"reflect",
"(",
")",
"{",
"$",
"tokens",
"=",
"token_get_all",
"(",
"$",
"this",
"->",
"reflectedFileContent",
")",
";",
"$",
"namespace",
"=",
"null",
";",
"$",
"classLevel",
"=",
"0",
";",
"$",
"level",
"=",
"0",
";",
"$",
"res",
"=",
"$",
"uses",
"=",
"array",
"(",
")",
";",
"while",
"(",
"list",
"(",
",",
"$",
"token",
")",
"=",
"each",
"(",
"$",
"tokens",
")",
")",
"{",
"switch",
"(",
"is_array",
"(",
"$",
"token",
")",
"?",
"$",
"token",
"[",
"0",
"]",
":",
"$",
"token",
")",
"{",
"case",
"T_CLASS",
":",
"case",
"T_INTERFACE",
":",
"case",
"T_TRAIT",
":",
"if",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"tokens",
",",
"array",
"(",
"T_STRING",
")",
")",
")",
"{",
"$",
"classLevel",
"=",
"$",
"level",
"+",
"1",
";",
"if",
"(",
"$",
"namespace",
"!==",
"null",
")",
"{",
"$",
"objectFQN",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"name",
";",
"}",
"else",
"{",
"$",
"objectFQN",
"=",
"$",
"name",
";",
"}",
"$",
"this",
"->",
"objects",
"[",
"]",
"=",
"new",
"ReflectionClass",
"(",
"$",
"objectFQN",
")",
";",
"}",
"break",
";",
"case",
"T_NAMESPACE",
":",
"$",
"namespace",
"=",
"'\\\\'",
".",
"ltrim",
"(",
"$",
"this",
"->",
"fetch",
"(",
"$",
"tokens",
",",
"array",
"(",
"T_STRING",
",",
"T_NS_SEPARATOR",
")",
")",
",",
"'\\\\'",
")",
";",
"$",
"res",
"[",
"$",
"namespace",
"]",
"=",
"array",
"(",
")",
";",
"$",
"uses",
"=",
"array",
"(",
")",
";",
"break",
";",
"case",
"T_USE",
":",
"if",
"(",
"$",
"classLevel",
"===",
"0",
")",
"{",
"while",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"tokens",
",",
"array",
"(",
"T_STRING",
",",
"T_NS_SEPARATOR",
")",
")",
")",
"{",
"$",
"name",
"=",
"'\\\\'",
".",
"ltrim",
"(",
"$",
"name",
",",
"'\\\\'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"fetch",
"(",
"$",
"tokens",
",",
"array",
"(",
"T_AS",
")",
")",
")",
"{",
"$",
"uses",
"[",
"$",
"this",
"->",
"fetch",
"(",
"$",
"tokens",
",",
"array",
"(",
"T_STRING",
")",
")",
"]",
"=",
"$",
"name",
";",
"}",
"else",
"{",
"$",
"uses",
"[",
"$",
"name",
"]",
"=",
"$",
"name",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"fetch",
"(",
"$",
"tokens",
",",
"array",
"(",
"','",
")",
")",
")",
"{",
"break",
";",
"}",
"}",
"$",
"res",
"[",
"$",
"namespace",
"]",
"=",
"$",
"uses",
";",
"}",
"break",
";",
"case",
"T_CURLY_OPEN",
":",
"case",
"T_DOLLAR_OPEN_CURLY_BRACES",
":",
"case",
"'{'",
":",
"$",
"level",
"++",
";",
"break",
";",
"case",
"'}'",
":",
"if",
"(",
"$",
"level",
"===",
"$",
"classLevel",
")",
"{",
"$",
"classLevel",
"=",
"0",
";",
"}",
"$",
"level",
"--",
";",
"break",
";",
"}",
"}",
"$",
"this",
"->",
"namespaces",
"=",
"array_keys",
"(",
"$",
"res",
")",
";",
"$",
"this",
"->",
"uses",
"=",
"$",
"res",
";",
"}"
] |
Do the reflection to gather data.
|
[
"Do",
"the",
"reflection",
"to",
"gather",
"data",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionFile.php#L67-L126
|
232,373
|
Speicher210/Reflection
|
src/ReflectionFile.php
|
ReflectionFile.fetch
|
private function fetch(& $tokens, array $take)
{
$res = null;
while ($token = current($tokens)) {
list($token, $s) = is_array($token) ? $token : array($token, $token);
if (in_array($token, $take, true)) {
$res .= $s;
} elseif (!in_array($token, array(T_DOC_COMMENT, T_WHITESPACE, T_COMMENT), true)) {
break;
}
next($tokens);
}
return $res;
}
|
php
|
private function fetch(& $tokens, array $take)
{
$res = null;
while ($token = current($tokens)) {
list($token, $s) = is_array($token) ? $token : array($token, $token);
if (in_array($token, $take, true)) {
$res .= $s;
} elseif (!in_array($token, array(T_DOC_COMMENT, T_WHITESPACE, T_COMMENT), true)) {
break;
}
next($tokens);
}
return $res;
}
|
[
"private",
"function",
"fetch",
"(",
"&",
"$",
"tokens",
",",
"array",
"$",
"take",
")",
"{",
"$",
"res",
"=",
"null",
";",
"while",
"(",
"$",
"token",
"=",
"current",
"(",
"$",
"tokens",
")",
")",
"{",
"list",
"(",
"$",
"token",
",",
"$",
"s",
")",
"=",
"is_array",
"(",
"$",
"token",
")",
"?",
"$",
"token",
":",
"array",
"(",
"$",
"token",
",",
"$",
"token",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"token",
",",
"$",
"take",
",",
"true",
")",
")",
"{",
"$",
"res",
".=",
"$",
"s",
";",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
"$",
"token",
",",
"array",
"(",
"T_DOC_COMMENT",
",",
"T_WHITESPACE",
",",
"T_COMMENT",
")",
",",
"true",
")",
")",
"{",
"break",
";",
"}",
"next",
"(",
"$",
"tokens",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Get the token value for the next token of type.
@param array $tokens The tokens array.
@param array $take The tokens to look for.
@return null|string
|
[
"Get",
"the",
"token",
"value",
"for",
"the",
"next",
"token",
"of",
"type",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionFile.php#L135-L149
|
232,374
|
Speicher210/Reflection
|
src/ReflectionFile.php
|
ReflectionFile.resolveFqnToAlias
|
public function resolveFqnToAlias($fqn)
{
foreach ($this->getUses() as $namespace => $uses) {
$alias = array_search($fqn, $uses, true);
if ($alias) {
$parts = explode('\\', $alias);
return end($parts);
}
}
return $fqn;
}
|
php
|
public function resolveFqnToAlias($fqn)
{
foreach ($this->getUses() as $namespace => $uses) {
$alias = array_search($fqn, $uses, true);
if ($alias) {
$parts = explode('\\', $alias);
return end($parts);
}
}
return $fqn;
}
|
[
"public",
"function",
"resolveFqnToAlias",
"(",
"$",
"fqn",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getUses",
"(",
")",
"as",
"$",
"namespace",
"=>",
"$",
"uses",
")",
"{",
"$",
"alias",
"=",
"array_search",
"(",
"$",
"fqn",
",",
"$",
"uses",
",",
"true",
")",
";",
"if",
"(",
"$",
"alias",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"alias",
")",
";",
"return",
"end",
"(",
"$",
"parts",
")",
";",
"}",
"}",
"return",
"$",
"fqn",
";",
"}"
] |
Resolve an alias for an FQN.
@param string $fqn The fully qualified name to get the alias for.
@return string
|
[
"Resolve",
"an",
"alias",
"for",
"an",
"FQN",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionFile.php#L197-L209
|
232,375
|
cawaphp/cawa
|
src/Net/Ip.php
|
Ip.isValid
|
public static function isValid(string $ip = null)
{
if (is_null($ip)) {
$ip = self::get();
}
return filter_var($ip, FILTER_VALIDATE_IP) == $ip;
}
|
php
|
public static function isValid(string $ip = null)
{
if (is_null($ip)) {
$ip = self::get();
}
return filter_var($ip, FILTER_VALIDATE_IP) == $ip;
}
|
[
"public",
"static",
"function",
"isValid",
"(",
"string",
"$",
"ip",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"ip",
")",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"get",
"(",
")",
";",
"}",
"return",
"filter_var",
"(",
"$",
"ip",
",",
"FILTER_VALIDATE_IP",
")",
"==",
"$",
"ip",
";",
"}"
] |
Control an ip.
@param string $ip
@return bool
|
[
"Control",
"an",
"ip",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Net/Ip.php#L62-L69
|
232,376
|
cawaphp/cawa
|
src/Net/Ip.php
|
Ip.isLocal
|
public static function isLocal(string $ip = null)
{
if (is_null($ip)) {
$ip = self::get();
}
if (stripos($ip, '127.') !== false) {
return true;
}
return !(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) == $ip);
}
|
php
|
public static function isLocal(string $ip = null)
{
if (is_null($ip)) {
$ip = self::get();
}
if (stripos($ip, '127.') !== false) {
return true;
}
return !(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) == $ip);
}
|
[
"public",
"static",
"function",
"isLocal",
"(",
"string",
"$",
"ip",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"ip",
")",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"get",
"(",
")",
";",
"}",
"if",
"(",
"stripos",
"(",
"$",
"ip",
",",
"'127.'",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"return",
"!",
"(",
"filter_var",
"(",
"$",
"ip",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_NO_PRIV_RANGE",
")",
"==",
"$",
"ip",
")",
";",
"}"
] |
If ip is for local network.
@param string $ip
@return bool
|
[
"If",
"ip",
"is",
"for",
"local",
"network",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Net/Ip.php#L78-L89
|
232,377
|
cawaphp/cawa
|
src/Net/Ip.php
|
Ip.toLong
|
public static function toLong(string $ip = null)
{
if (is_null($ip)) {
$ip = self::get();
}
return ip2long($ip);
}
|
php
|
public static function toLong(string $ip = null)
{
if (is_null($ip)) {
$ip = self::get();
}
return ip2long($ip);
}
|
[
"public",
"static",
"function",
"toLong",
"(",
"string",
"$",
"ip",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"ip",
")",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"get",
"(",
")",
";",
"}",
"return",
"ip2long",
"(",
"$",
"ip",
")",
";",
"}"
] |
Return numeric ip value.
@param string $ip
@return int
|
[
"Return",
"numeric",
"ip",
"value",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Net/Ip.php#L119-L126
|
232,378
|
jack-theripper/transcoder
|
src/Event/EventProgress.php
|
EventProgress.getPercent
|
public function getPercent()
{
if ($this->duration == 0)
{
return -1;
}
$percent = $this->time / $this->duration * 100 / $this->totalPass;
return round(min(100, $percent + 100 / $this->totalPass * ($this->currentPass - 1)), 2);
}
|
php
|
public function getPercent()
{
if ($this->duration == 0)
{
return -1;
}
$percent = $this->time / $this->duration * 100 / $this->totalPass;
return round(min(100, $percent + 100 / $this->totalPass * ($this->currentPass - 1)), 2);
}
|
[
"public",
"function",
"getPercent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"duration",
"==",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"$",
"percent",
"=",
"$",
"this",
"->",
"time",
"/",
"$",
"this",
"->",
"duration",
"*",
"100",
"/",
"$",
"this",
"->",
"totalPass",
";",
"return",
"round",
"(",
"min",
"(",
"100",
",",
"$",
"percent",
"+",
"100",
"/",
"$",
"this",
"->",
"totalPass",
"*",
"(",
"$",
"this",
"->",
"currentPass",
"-",
"1",
")",
")",
",",
"2",
")",
";",
"}"
] |
Get current percent or '-1'.
@return float
|
[
"Get",
"current",
"percent",
"or",
"-",
"1",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Event/EventProgress.php#L120-L130
|
232,379
|
jack-theripper/transcoder
|
src/Event/EventProgress.php
|
EventProgress.setDuration
|
protected function setDuration($duration)
{
if ( ! is_numeric($duration))
{
throw new \InvalidArgumentException('The duration value must be a float type.');
}
$this->duration = abs($duration);
return $this;
}
|
php
|
protected function setDuration($duration)
{
if ( ! is_numeric($duration))
{
throw new \InvalidArgumentException('The duration value must be a float type.');
}
$this->duration = abs($duration);
return $this;
}
|
[
"protected",
"function",
"setDuration",
"(",
"$",
"duration",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"duration",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The duration value must be a float type.'",
")",
";",
"}",
"$",
"this",
"->",
"duration",
"=",
"abs",
"(",
"$",
"duration",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets duration value.
@param float $duration
@return EventProgress
@throws \InvalidArgumentException
|
[
"Sets",
"duration",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Event/EventProgress.php#L197-L207
|
232,380
|
cawaphp/cawa
|
src/Date/DateTime.php
|
DateTime.init
|
private static function init()
{
$day = Calendar::getFirstWeekday();
$day = $day == 0 ? 7 : $day;
self::$weekStartsAt = $day;
$days = self::$days;
while (array_keys($days)[0] != $day) {
$key = array_keys($days)[0];
$value = $days[$key];
unset($days[$key]);
$days[$key] = $value;
}
self::$init = true;
}
|
php
|
private static function init()
{
$day = Calendar::getFirstWeekday();
$day = $day == 0 ? 7 : $day;
self::$weekStartsAt = $day;
$days = self::$days;
while (array_keys($days)[0] != $day) {
$key = array_keys($days)[0];
$value = $days[$key];
unset($days[$key]);
$days[$key] = $value;
}
self::$init = true;
}
|
[
"private",
"static",
"function",
"init",
"(",
")",
"{",
"$",
"day",
"=",
"Calendar",
"::",
"getFirstWeekday",
"(",
")",
";",
"$",
"day",
"=",
"$",
"day",
"==",
"0",
"?",
"7",
":",
"$",
"day",
";",
"self",
"::",
"$",
"weekStartsAt",
"=",
"$",
"day",
";",
"$",
"days",
"=",
"self",
"::",
"$",
"days",
";",
"while",
"(",
"array_keys",
"(",
"$",
"days",
")",
"[",
"0",
"]",
"!=",
"$",
"day",
")",
"{",
"$",
"key",
"=",
"array_keys",
"(",
"$",
"days",
")",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"days",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"days",
"[",
"$",
"key",
"]",
")",
";",
"$",
"days",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"self",
"::",
"$",
"init",
"=",
"true",
";",
"}"
] |
Reorder the days property based on current language.
|
[
"Reorder",
"the",
"days",
"property",
"based",
"on",
"current",
"language",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Date/DateTime.php#L87-L102
|
232,381
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.error
|
public function error($message)
{
$this->message = $message;
$this->type = 'danger';
$this->title = 'Whoops';
$this->icon = 'sl sl-icon-close danger ln-notify-icon';
$this->animate['enter'] = 'animated tada';
return $this->setNotifier();
}
|
php
|
public function error($message)
{
$this->message = $message;
$this->type = 'danger';
$this->title = 'Whoops';
$this->icon = 'sl sl-icon-close danger ln-notify-icon';
$this->animate['enter'] = 'animated tada';
return $this->setNotifier();
}
|
[
"public",
"function",
"error",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"type",
"=",
"'danger'",
";",
"$",
"this",
"->",
"title",
"=",
"'Whoops'",
";",
"$",
"this",
"->",
"icon",
"=",
"'sl sl-icon-close danger ln-notify-icon'",
";",
"$",
"this",
"->",
"animate",
"[",
"'enter'",
"]",
"=",
"'animated tada'",
";",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
Build error messages
@param string $message
@return mixed
|
[
"Build",
"error",
"messages"
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L157-L166
|
232,382
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.warning
|
public function warning($message)
{
$this->message = $message;
$this->type = 'warning';
$this->title = 'Warning';
$this->icon = 'sl sl-icon-bell warning ln-notify-icon';
return $this->setNotifier();
}
|
php
|
public function warning($message)
{
$this->message = $message;
$this->type = 'warning';
$this->title = 'Warning';
$this->icon = 'sl sl-icon-bell warning ln-notify-icon';
return $this->setNotifier();
}
|
[
"public",
"function",
"warning",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"type",
"=",
"'warning'",
";",
"$",
"this",
"->",
"title",
"=",
"'Warning'",
";",
"$",
"this",
"->",
"icon",
"=",
"'sl sl-icon-bell warning ln-notify-icon'",
";",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
Build warning messages
@param string $message
@return mixed
|
[
"Build",
"warning",
"messages"
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L173-L181
|
232,383
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.animate
|
public function animate($animation)
{
if (is_array($animation) && isset($animation[0]) && isset($animation[1])) {
$this->animate['enter'] = "animated " . $animation[0];
$this->animate['exit'] = "animated " . $animation[1];
}
if (is_array($animation) && isset($animation['enter']) && isset($animation['exit'])) {
$this->animate['enter'] = "animated {$animation['enter']}";
$this->animate['exit'] = "animated {$animation['exit']}";
}
if (is_bool($animation) && $animation == false) {
$this->animate['enter'] = null;
$this->animate['exit'] = null;
}
return $this->setNotifier();
}
|
php
|
public function animate($animation)
{
if (is_array($animation) && isset($animation[0]) && isset($animation[1])) {
$this->animate['enter'] = "animated " . $animation[0];
$this->animate['exit'] = "animated " . $animation[1];
}
if (is_array($animation) && isset($animation['enter']) && isset($animation['exit'])) {
$this->animate['enter'] = "animated {$animation['enter']}";
$this->animate['exit'] = "animated {$animation['exit']}";
}
if (is_bool($animation) && $animation == false) {
$this->animate['enter'] = null;
$this->animate['exit'] = null;
}
return $this->setNotifier();
}
|
[
"public",
"function",
"animate",
"(",
"$",
"animation",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"animation",
")",
"&&",
"isset",
"(",
"$",
"animation",
"[",
"0",
"]",
")",
"&&",
"isset",
"(",
"$",
"animation",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"animate",
"[",
"'enter'",
"]",
"=",
"\"animated \"",
".",
"$",
"animation",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"animate",
"[",
"'exit'",
"]",
"=",
"\"animated \"",
".",
"$",
"animation",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"animation",
")",
"&&",
"isset",
"(",
"$",
"animation",
"[",
"'enter'",
"]",
")",
"&&",
"isset",
"(",
"$",
"animation",
"[",
"'exit'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"animate",
"[",
"'enter'",
"]",
"=",
"\"animated {$animation['enter']}\"",
";",
"$",
"this",
"->",
"animate",
"[",
"'exit'",
"]",
"=",
"\"animated {$animation['exit']}\"",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"animation",
")",
"&&",
"$",
"animation",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"animate",
"[",
"'enter'",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"animate",
"[",
"'exit'",
"]",
"=",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
This will control the animation used to bring and remove the notification. Since version 1.0.0 all animations are controlled using css. Animate.css by Daniel Eden is already loaded for you on ln_header function.
@param boolean|array $animation
@return LaranotifyService
|
[
"This",
"will",
"control",
"the",
"animation",
"used",
"to",
"bring",
"and",
"remove",
"the",
"notification",
".",
"Since",
"version",
"1",
".",
"0",
".",
"0",
"all",
"animations",
"are",
"controlled",
"using",
"css",
".",
"Animate",
".",
"css",
"by",
"Daniel",
"Eden",
"is",
"already",
"loaded",
"for",
"you",
"on",
"ln_header",
"function",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L230-L248
|
232,384
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.progress
|
public function progress($bool)
{
if (is_bool($bool)) {
$this->progress = json_encode($bool);
}
return $this->setNotifier();
}
|
php
|
public function progress($bool)
{
if (is_bool($bool)) {
$this->progress = json_encode($bool);
}
return $this->setNotifier();
}
|
[
"public",
"function",
"progress",
"(",
"$",
"bool",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"bool",
")",
")",
"{",
"$",
"this",
"->",
"progress",
"=",
"json_encode",
"(",
"$",
"bool",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
This boolean is used to determine if the notification should display a progress bar.
@param boolean $bool
@return LaranotifyService
|
[
"This",
"boolean",
"is",
"used",
"to",
"determine",
"if",
"the",
"notification",
"should",
"display",
"a",
"progress",
"bar",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L279-L286
|
232,385
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.message
|
public function message($message, $type = '')
{
if ($type == 'danger') {
$this->animate['enter'] = 'animated tada';
}
if ($type != '') {
$this->type = $type;
}
$this->message = $message;
return $this->setNotifier();
}
|
php
|
public function message($message, $type = '')
{
if ($type == 'danger') {
$this->animate['enter'] = 'animated tada';
}
if ($type != '') {
$this->type = $type;
}
$this->message = $message;
return $this->setNotifier();
}
|
[
"public",
"function",
"message",
"(",
"$",
"message",
",",
"$",
"type",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'danger'",
")",
"{",
"$",
"this",
"->",
"animate",
"[",
"'enter'",
"]",
"=",
"'animated tada'",
";",
"}",
"if",
"(",
"$",
"type",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"}",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
";",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
This is the message that will be displayed within the notify notification.
@param string $type danger, warning, info, success
@param string $message
@return LaranotifyService
|
[
"This",
"is",
"the",
"message",
"that",
"will",
"be",
"displayed",
"within",
"the",
"notify",
"notification",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L308-L320
|
232,386
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.allowDismiss
|
public function allowDismiss($bool)
{
if (is_bool($bool)) {
$this->allowDismiss = json_encode($bool);
}
return $this->setNotifier();
}
|
php
|
public function allowDismiss($bool)
{
if (is_bool($bool)) {
$this->allowDismiss = json_encode($bool);
}
return $this->setNotifier();
}
|
[
"public",
"function",
"allowDismiss",
"(",
"$",
"bool",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"bool",
")",
")",
"{",
"$",
"this",
"->",
"allowDismiss",
"=",
"json_encode",
"(",
"$",
"bool",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
If this value is set to false it will hide the data-grow="dismiss" element.
Please keep in mind if you modify the template setting and do not include a data-notify="dismiss"
element even with this set to true, there will be no element for a user to click to close the notification.
@param boolean $bool
@return LaranotifyService
|
[
"If",
"this",
"value",
"is",
"set",
"to",
"false",
"it",
"will",
"hide",
"the",
"data",
"-",
"grow",
"=",
"dismiss",
"element",
".",
"Please",
"keep",
"in",
"mind",
"if",
"you",
"modify",
"the",
"template",
"setting",
"and",
"do",
"not",
"include",
"a",
"data",
"-",
"notify",
"=",
"dismiss",
"element",
"even",
"with",
"this",
"set",
"to",
"true",
"there",
"will",
"be",
"no",
"element",
"for",
"a",
"user",
"to",
"click",
"to",
"close",
"the",
"notification",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L505-L512
|
232,387
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.placement
|
public function placement($from, $align)
{
$this->placement['from'] = $from;
$this->placement['align'] = $align;
return $this->setNotifier();
}
|
php
|
public function placement($from, $align)
{
$this->placement['from'] = $from;
$this->placement['align'] = $align;
return $this->setNotifier();
}
|
[
"public",
"function",
"placement",
"(",
"$",
"from",
",",
"$",
"align",
")",
"{",
"$",
"this",
"->",
"placement",
"[",
"'from'",
"]",
"=",
"$",
"from",
";",
"$",
"this",
"->",
"placement",
"[",
"'align'",
"]",
"=",
"$",
"align",
";",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
This controls where the notification will be placed.
@param string $from top, bottom
@param string $align left, right, center
@return LaranotifyService
|
[
"This",
"controls",
"where",
"the",
"notification",
"will",
"be",
"placed",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L520-L526
|
232,388
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.withSound
|
public function withSound($path)
{
$sound = url("public/" . $path);
if (str_start('http://', $path) || str_start('https://', $path)) {
$sound = $path;
}
$this->onShow("
function() {
laranotifySound = new Audio('{$sound}');
laranotifySound.play();
}
");
$this->onClosed("
function() {
laranotifySound.currentTime = 0;
laranotifySound.src = '';
}
");
return $this;
}
|
php
|
public function withSound($path)
{
$sound = url("public/" . $path);
if (str_start('http://', $path) || str_start('https://', $path)) {
$sound = $path;
}
$this->onShow("
function() {
laranotifySound = new Audio('{$sound}');
laranotifySound.play();
}
");
$this->onClosed("
function() {
laranotifySound.currentTime = 0;
laranotifySound.src = '';
}
");
return $this;
}
|
[
"public",
"function",
"withSound",
"(",
"$",
"path",
")",
"{",
"$",
"sound",
"=",
"url",
"(",
"\"public/\"",
".",
"$",
"path",
")",
";",
"if",
"(",
"str_start",
"(",
"'http://'",
",",
"$",
"path",
")",
"||",
"str_start",
"(",
"'https://'",
",",
"$",
"path",
")",
")",
"{",
"$",
"sound",
"=",
"$",
"path",
";",
"}",
"$",
"this",
"->",
"onShow",
"(",
"\"\n function() {\n laranotifySound = new Audio('{$sound}'); \n laranotifySound.play(); \n }\n \"",
")",
";",
"$",
"this",
"->",
"onClosed",
"(",
"\"\n function() { \n laranotifySound.currentTime = 0;\n laranotifySound.src = ''; \n }\n \"",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Play a sound when the notification is shown and stop it when notification is closed.
You can pass a relative path or url. We will check if it's a url or not.
If you pass in path, we will assume it's coming from the public folder.
We are setting the relative path to start with public folder because it's recommended by Laravel that
all public files should come from the public folder.
@param string $path
@return $this
|
[
"Play",
"a",
"sound",
"when",
"the",
"notification",
"is",
"shown",
"and",
"stop",
"it",
"when",
"notification",
"is",
"closed",
".",
"You",
"can",
"pass",
"a",
"relative",
"path",
"or",
"url",
".",
"We",
"will",
"check",
"if",
"it",
"s",
"a",
"url",
"or",
"not",
".",
"If",
"you",
"pass",
"in",
"path",
"we",
"will",
"assume",
"it",
"s",
"coming",
"from",
"the",
"public",
"folder",
".",
"We",
"are",
"setting",
"the",
"relative",
"path",
"to",
"start",
"with",
"public",
"folder",
"because",
"it",
"s",
"recommended",
"by",
"Laravel",
"that",
"all",
"public",
"files",
"should",
"come",
"from",
"the",
"public",
"folder",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L609-L630
|
232,389
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.imageIcon
|
public function imageIcon($imageUrl = '')
{
$this->iconType = 'class';
$this->icon = "sl sl-icon-bell ln-notify-icon $this->type";
if ($imageUrl != '') {
$this->iconType = 'img';
$this->icon = $imageUrl;
}
return $this->setNotifier();
}
|
php
|
public function imageIcon($imageUrl = '')
{
$this->iconType = 'class';
$this->icon = "sl sl-icon-bell ln-notify-icon $this->type";
if ($imageUrl != '') {
$this->iconType = 'img';
$this->icon = $imageUrl;
}
return $this->setNotifier();
}
|
[
"public",
"function",
"imageIcon",
"(",
"$",
"imageUrl",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"iconType",
"=",
"'class'",
";",
"$",
"this",
"->",
"icon",
"=",
"\"sl sl-icon-bell ln-notify-icon $this->type\"",
";",
"if",
"(",
"$",
"imageUrl",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"iconType",
"=",
"'img'",
";",
"$",
"this",
"->",
"icon",
"=",
"$",
"imageUrl",
";",
"}",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
This will set set the icon to the image provided as @var $imageUrl
If the image couldn't be found, we will revoke to a default icon [bell].
It's expected that your image must have equal dimensions i.e same width and height.
@param string $imageUrl
@return LaranotifyService
|
[
"This",
"will",
"set",
"set",
"the",
"icon",
"to",
"the",
"image",
"provided",
"as"
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L639-L650
|
232,390
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.template
|
public function template($template)
{
$this->template = view($template, $this->data);
return $this->setNotifier();
}
|
php
|
public function template($template)
{
$this->template = view($template, $this->data);
return $this->setNotifier();
}
|
[
"public",
"function",
"template",
"(",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"template",
"=",
"view",
"(",
"$",
"template",
",",
"$",
"this",
"->",
"data",
")",
";",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
This gives you control over the layout of the notification where you can build your own template and set
it at the config file include the package.
Provide the name of your template view file.
This will then be set as the active template.
@param string $template Your template view file
@return LaranotifyService
|
[
"This",
"gives",
"you",
"control",
"over",
"the",
"layout",
"of",
"the",
"notification",
"where",
"you",
"can",
"build",
"your",
"own",
"template",
"and",
"set",
"it",
"at",
"the",
"config",
"file",
"include",
"the",
"package",
".",
"Provide",
"the",
"name",
"of",
"your",
"template",
"view",
"file",
".",
"This",
"will",
"then",
"be",
"set",
"as",
"the",
"active",
"template",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L660-L665
|
232,391
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.updateAfterInterval
|
public function updateAfterInterval($target_element, $contents, $interval = 0)
{
if (is_int($interval) && $interval != 0) {
$this->onShown("
function() {
setInterval(function() {
$('{$target_element}').html('{$contents}');
}, {$interval});
}
");
}
return $this->setNotifier();
}
|
php
|
public function updateAfterInterval($target_element, $contents, $interval = 0)
{
if (is_int($interval) && $interval != 0) {
$this->onShown("
function() {
setInterval(function() {
$('{$target_element}').html('{$contents}');
}, {$interval});
}
");
}
return $this->setNotifier();
}
|
[
"public",
"function",
"updateAfterInterval",
"(",
"$",
"target_element",
",",
"$",
"contents",
",",
"$",
"interval",
"=",
"0",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"interval",
")",
"&&",
"$",
"interval",
"!=",
"0",
")",
"{",
"$",
"this",
"->",
"onShown",
"(",
"\"\n function() {\n setInterval(function() {\n $('{$target_element}').html('{$contents}');\n }, {$interval});\n }\n \"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setNotifier",
"(",
")",
";",
"}"
] |
Update a particular element after the notification is displayed on screen.
You can even change the contents of notification.
This work with the DOM.
@param string $target_element
@param string $contents
@param int $interval
@return LaranotifyService
|
[
"Update",
"a",
"particular",
"element",
"after",
"the",
"notification",
"is",
"displayed",
"on",
"screen",
".",
"You",
"can",
"even",
"change",
"the",
"contents",
"of",
"notification",
".",
"This",
"work",
"with",
"the",
"DOM",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L777-L790
|
232,392
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.getTemplate
|
private function getTemplate()
{
$template = config('laranotify.template');
if ($template == '' && $this->template == '') {
return $this->defaultTemplate();
}
if ($this->template != '') {
return ($this->template);
}
return view($template);
}
|
php
|
private function getTemplate()
{
$template = config('laranotify.template');
if ($template == '' && $this->template == '') {
return $this->defaultTemplate();
}
if ($this->template != '') {
return ($this->template);
}
return view($template);
}
|
[
"private",
"function",
"getTemplate",
"(",
")",
"{",
"$",
"template",
"=",
"config",
"(",
"'laranotify.template'",
")",
";",
"if",
"(",
"$",
"template",
"==",
"''",
"&&",
"$",
"this",
"->",
"template",
"==",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"defaultTemplate",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"template",
"!=",
"''",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"template",
")",
";",
"}",
"return",
"view",
"(",
"$",
"template",
")",
";",
"}"
] |
Get the currently set template.
This will return default template if none is set.
@return string
|
[
"Get",
"the",
"currently",
"set",
"template",
".",
"This",
"will",
"return",
"default",
"template",
"if",
"none",
"is",
"set",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L797-L809
|
232,393
|
coderatio/laranotify
|
src/LaranotifyService.php
|
LaranotifyService.buildTemplate
|
private function buildTemplate($template)
{
$this->template = $template;
$offset = "{
x: $this->offsetX,
y: $this->offsetY
}";
if ($this->offsetX == 20 && $this->offsetY == 20 || $this->offset == 20) {
$offset = $this->offset;
}
$this->placement['enter'] = 'right';
return "{
icon: '$this->icon',
title: '$this->title',
message: '$this->message',
url: '$this->url',
target: '$this->target'
}, {
element: '$this->element',
position: $this->position,
type: '$this->type',
allow_dismiss: $this->allowDismiss,
newest_on_top: $this->newestFirst,
showProgressbar: $this->progress,
placement: " . json_encode($this->placement) . ",
offset: $offset,
spacing: $this->spacing,
z_index: $this->zIndex,
mouse_over: '$this->mouseOver',
delay: $this->delay,
timer: $this->timer,
url_target: '$this->urlTarget',
animate: " . json_encode($this->animate) . ",
onShow: $this->onShow,
onShown: $this->onShown,
onClose: $this->onClose,
onClosed: $this->onClosed,
icon_type: '$this->iconType',
template: `$this->template`
}
";
}
|
php
|
private function buildTemplate($template)
{
$this->template = $template;
$offset = "{
x: $this->offsetX,
y: $this->offsetY
}";
if ($this->offsetX == 20 && $this->offsetY == 20 || $this->offset == 20) {
$offset = $this->offset;
}
$this->placement['enter'] = 'right';
return "{
icon: '$this->icon',
title: '$this->title',
message: '$this->message',
url: '$this->url',
target: '$this->target'
}, {
element: '$this->element',
position: $this->position,
type: '$this->type',
allow_dismiss: $this->allowDismiss,
newest_on_top: $this->newestFirst,
showProgressbar: $this->progress,
placement: " . json_encode($this->placement) . ",
offset: $offset,
spacing: $this->spacing,
z_index: $this->zIndex,
mouse_over: '$this->mouseOver',
delay: $this->delay,
timer: $this->timer,
url_target: '$this->urlTarget',
animate: " . json_encode($this->animate) . ",
onShow: $this->onShow,
onShown: $this->onShown,
onClose: $this->onClose,
onClosed: $this->onClosed,
icon_type: '$this->iconType',
template: `$this->template`
}
";
}
|
[
"private",
"function",
"buildTemplate",
"(",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"template",
"=",
"$",
"template",
";",
"$",
"offset",
"=",
"\"{\n x: $this->offsetX,\n y: $this->offsetY\n }\"",
";",
"if",
"(",
"$",
"this",
"->",
"offsetX",
"==",
"20",
"&&",
"$",
"this",
"->",
"offsetY",
"==",
"20",
"||",
"$",
"this",
"->",
"offset",
"==",
"20",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"offset",
";",
"}",
"$",
"this",
"->",
"placement",
"[",
"'enter'",
"]",
"=",
"'right'",
";",
"return",
"\"{\n icon: '$this->icon',\n title: '$this->title',\n message: '$this->message',\n url: '$this->url',\n target: '$this->target'\n }, {\n element: '$this->element',\n position: $this->position,\n type: '$this->type',\n allow_dismiss: $this->allowDismiss,\n newest_on_top: $this->newestFirst,\n showProgressbar: $this->progress,\n placement: \"",
".",
"json_encode",
"(",
"$",
"this",
"->",
"placement",
")",
".",
"\",\n offset: $offset,\n spacing: $this->spacing,\n z_index: $this->zIndex,\n mouse_over: '$this->mouseOver',\n delay: $this->delay,\n timer: $this->timer,\n url_target: '$this->urlTarget',\n animate: \"",
".",
"json_encode",
"(",
"$",
"this",
"->",
"animate",
")",
".",
"\",\n onShow: $this->onShow,\n onShown: $this->onShown,\n onClose: $this->onClose,\n onClosed: $this->onClosed,\n icon_type: '$this->iconType',\n template: `$this->template`\n }\n \"",
";",
"}"
] |
Build template for notification.
You only need to pass the template content as the parameter.
Template can come from anywhere within your laravel project.
@param string $template
@return string, json
|
[
"Build",
"template",
"for",
"notification",
".",
"You",
"only",
"need",
"to",
"pass",
"the",
"template",
"content",
"as",
"the",
"parameter",
".",
"Template",
"can",
"come",
"from",
"anywhere",
"within",
"your",
"laravel",
"project",
"."
] |
f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d
|
https://github.com/coderatio/laranotify/blob/f5dc28b4c5fec00fc4f83270e5331ba00f15aa9d/src/LaranotifyService.php#L831-L875
|
232,394
|
youngguns-nl/moneybird_php_api
|
Domainmodel/AbstractModel.php
|
AbstractModel._initDisclosedAttributes
|
protected function _initDisclosedAttributes()
{
foreach (array_keys(get_class_vars(get_class($this))) as $property) {
if (substr($property, 0, 1) != '_') {
$this->_discloseAttr[] = $property;
}
}
}
|
php
|
protected function _initDisclosedAttributes()
{
foreach (array_keys(get_class_vars(get_class($this))) as $property) {
if (substr($property, 0, 1) != '_') {
$this->_discloseAttr[] = $property;
}
}
}
|
[
"protected",
"function",
"_initDisclosedAttributes",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"get_class_vars",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"property",
",",
"0",
",",
"1",
")",
"!=",
"'_'",
")",
"{",
"$",
"this",
"->",
"_discloseAttr",
"[",
"]",
"=",
"$",
"property",
";",
"}",
"}",
"}"
] |
Create disclosedAttributes array
|
[
"Create",
"disclosedAttributes",
"array"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Domainmodel/AbstractModel.php#L94-L101
|
232,395
|
youngguns-nl/moneybird_php_api
|
Domainmodel/AbstractModel.php
|
AbstractModel.isDirty
|
public function isDirty()
{
if (
!empty($this->_dirtyAttr) ||
(($this instanceof DeleteBySaving) && $this->isDeleted())
) {
return true;
}
foreach (array_keys(get_object_vars($this)) as $key) {
foreach ((array) $this->$key as $sub) {
if (($sub instanceof DirtyAware) && $sub->isDirty()) {
return true;
}
}
}
return false;
}
|
php
|
public function isDirty()
{
if (
!empty($this->_dirtyAttr) ||
(($this instanceof DeleteBySaving) && $this->isDeleted())
) {
return true;
}
foreach (array_keys(get_object_vars($this)) as $key) {
foreach ((array) $this->$key as $sub) {
if (($sub instanceof DirtyAware) && $sub->isDirty()) {
return true;
}
}
}
return false;
}
|
[
"public",
"function",
"isDirty",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_dirtyAttr",
")",
"||",
"(",
"(",
"$",
"this",
"instanceof",
"DeleteBySaving",
")",
"&&",
"$",
"this",
"->",
"isDeleted",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"array_keys",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
")",
"as",
"$",
"key",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"$",
"key",
"as",
"$",
"sub",
")",
"{",
"if",
"(",
"(",
"$",
"sub",
"instanceof",
"DirtyAware",
")",
"&&",
"$",
"sub",
"->",
"isDirty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true if the object contains any dirty attributes
@return bool
@access public
|
[
"Returns",
"true",
"if",
"the",
"object",
"contains",
"any",
"dirty",
"attributes"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Domainmodel/AbstractModel.php#L186-L203
|
232,396
|
youngguns-nl/moneybird_php_api
|
Domainmodel/AbstractModel.php
|
AbstractModel.getDirtyAttributes
|
public function getDirtyAttributes()
{
$values = array();
foreach (array_keys(get_object_vars($this)) as $key) {
if (in_array($key, $this->_dirtyAttr)) {
$values[$key] = $this->$key;
} elseif ($this->$key instanceof ArrayObject) {
foreach ($this->$key as $sub) {
if (($sub instanceof DirtyAware) && $sub->isDirty()) {
if (!array_key_exists($key, $values)) {
$values[$key] = new $this->$key;
}
$values[$key]->append($sub);
}
}
}
}
return $values;
}
|
php
|
public function getDirtyAttributes()
{
$values = array();
foreach (array_keys(get_object_vars($this)) as $key) {
if (in_array($key, $this->_dirtyAttr)) {
$values[$key] = $this->$key;
} elseif ($this->$key instanceof ArrayObject) {
foreach ($this->$key as $sub) {
if (($sub instanceof DirtyAware) && $sub->isDirty()) {
if (!array_key_exists($key, $values)) {
$values[$key] = new $this->$key;
}
$values[$key]->append($sub);
}
}
}
}
return $values;
}
|
[
"public",
"function",
"getDirtyAttributes",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_dirtyAttr",
")",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"$",
"key",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"$",
"key",
"instanceof",
"ArrayObject",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"$",
"key",
"as",
"$",
"sub",
")",
"{",
"if",
"(",
"(",
"$",
"sub",
"instanceof",
"DirtyAware",
")",
"&&",
"$",
"sub",
"->",
"isDirty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"values",
")",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"new",
"$",
"this",
"->",
"$",
"key",
";",
"}",
"$",
"values",
"[",
"$",
"key",
"]",
"->",
"append",
"(",
"$",
"sub",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] |
Returns an array representation of this object's dirty attributes
@return array
@access public
|
[
"Returns",
"an",
"array",
"representation",
"of",
"this",
"object",
"s",
"dirty",
"attributes"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Domainmodel/AbstractModel.php#L210-L228
|
232,397
|
youngguns-nl/moneybird_php_api
|
Domainmodel/AbstractModel.php
|
AbstractModel.selfToArray
|
protected function selfToArray(Array $filter = array())
{
$filter = array_flip($filter);
$hasFilter = count($filter) > 0;
$values = array();
foreach ($this as $key => $value) {
if (!$hasFilter || isset($filter[$key])) {
$values[$key] = $this->$key;
}
}
return $values;
}
|
php
|
protected function selfToArray(Array $filter = array())
{
$filter = array_flip($filter);
$hasFilter = count($filter) > 0;
$values = array();
foreach ($this as $key => $value) {
if (!$hasFilter || isset($filter[$key])) {
$values[$key] = $this->$key;
}
}
return $values;
}
|
[
"protected",
"function",
"selfToArray",
"(",
"Array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"array_flip",
"(",
"$",
"filter",
")",
";",
"$",
"hasFilter",
"=",
"count",
"(",
"$",
"filter",
")",
">",
"0",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"hasFilter",
"||",
"isset",
"(",
"$",
"filter",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"$",
"key",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] |
Returns an array representation of this object
@return array
@access protected
|
[
"Returns",
"an",
"array",
"representation",
"of",
"this",
"object"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Domainmodel/AbstractModel.php#L235-L246
|
232,398
|
youngguns-nl/moneybird_php_api
|
Domainmodel/AbstractModel.php
|
AbstractModel.setClean
|
protected function setClean($attr = null)
{
if ($attr === null) {
$this->_dirtyAttr = array();
} else {
foreach (array_keys($this->_dirtyAttr, $attr) as $key) {
unset($this->_dirtyAttr[$key]);
}
}
return $this;
}
|
php
|
protected function setClean($attr = null)
{
if ($attr === null) {
$this->_dirtyAttr = array();
} else {
foreach (array_keys($this->_dirtyAttr, $attr) as $key) {
unset($this->_dirtyAttr[$key]);
}
}
return $this;
}
|
[
"protected",
"function",
"setClean",
"(",
"$",
"attr",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"attr",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_dirtyAttr",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_dirtyAttr",
",",
"$",
"attr",
")",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_dirtyAttr",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set dirty state to clean
@param string $attr Name of attribute, if null (default) set all attribures clean
@return self
|
[
"Set",
"dirty",
"state",
"to",
"clean"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Domainmodel/AbstractModel.php#L292-L302
|
232,399
|
youngguns-nl/moneybird_php_api
|
Domainmodel/AbstractModel.php
|
AbstractModel.setDirty
|
protected function setDirty($attr = null)
{
if ($attr === null) {
$this->setClean();
foreach (array_keys(get_object_vars($this)) as $key) {
$this->setDirty($key);
}
} elseif (
!in_array($attr, $this->_dirtyAttr) &&
!in_array($attr, $this->_readonlyAttr) &&
substr($attr, 0, 1) != '_' &&
$attr != 'id'
) {
$this->_dirtyAttr[] = $attr;
}
return $this;
}
|
php
|
protected function setDirty($attr = null)
{
if ($attr === null) {
$this->setClean();
foreach (array_keys(get_object_vars($this)) as $key) {
$this->setDirty($key);
}
} elseif (
!in_array($attr, $this->_dirtyAttr) &&
!in_array($attr, $this->_readonlyAttr) &&
substr($attr, 0, 1) != '_' &&
$attr != 'id'
) {
$this->_dirtyAttr[] = $attr;
}
return $this;
}
|
[
"protected",
"function",
"setDirty",
"(",
"$",
"attr",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"attr",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setClean",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
")",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"setDirty",
"(",
"$",
"key",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
"$",
"attr",
",",
"$",
"this",
"->",
"_dirtyAttr",
")",
"&&",
"!",
"in_array",
"(",
"$",
"attr",
",",
"$",
"this",
"->",
"_readonlyAttr",
")",
"&&",
"substr",
"(",
"$",
"attr",
",",
"0",
",",
"1",
")",
"!=",
"'_'",
"&&",
"$",
"attr",
"!=",
"'id'",
")",
"{",
"$",
"this",
"->",
"_dirtyAttr",
"[",
"]",
"=",
"$",
"attr",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set dirty state to dirty
@param string $attr Name of attribute, if null (default) set all attribures dirty
@return self
|
[
"Set",
"dirty",
"state",
"to",
"dirty"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Domainmodel/AbstractModel.php#L309-L325
|
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.