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
|
---|---|---|---|---|---|---|---|---|---|---|---|
13,400 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.searchByEmailArray | public function searchByEmailArray($email) {
$results = $this->ldap->search($this->basedn,
$this->search_mail_array . '=' . $email);
return $results;
} | php | public function searchByEmailArray($email) {
$results = $this->ldap->search($this->basedn,
$this->search_mail_array . '=' . $email);
return $results;
} | [
"public",
"function",
"searchByEmailArray",
"(",
"$",
"email",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"ldap",
"->",
"search",
"(",
"$",
"this",
"->",
"basedn",
",",
"$",
"this",
"->",
"search_mail_array",
".",
"'='",
".",
"$",
"email",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| Queries LDAP for the record with the specified mailLocalAddress.
@param string $email The mailLocalAddress to use for searching
@return Result-instance | [
"Queries",
"LDAP",
"for",
"the",
"record",
"with",
"the",
"specified",
"mailLocalAddress",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L439-L443 |
13,401 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.searchByQuery | public function searchByQuery($query) {
$results = $this->ldap->search($this->basedn, $query);
return $results;
} | php | public function searchByQuery($query) {
$results = $this->ldap->search($this->basedn, $query);
return $results;
} | [
"public",
"function",
"searchByQuery",
"(",
"$",
"query",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"ldap",
"->",
"search",
"(",
"$",
"this",
"->",
"basedn",
",",
"$",
"query",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| Queries LDAP for the records using the specified query.
@param string $query Any valid LDAP query to use for searching
@return Result-instance | [
"Queries",
"LDAP",
"for",
"the",
"records",
"using",
"the",
"specified",
"query",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L451-L454 |
13,402 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.searchByUid | public function searchByUid($uid) {
$results = $this->ldap->search($this->basedn,
$this->search_username . '=' . $uid);
return $results;
} | php | public function searchByUid($uid) {
$results = $this->ldap->search($this->basedn,
$this->search_username . '=' . $uid);
return $results;
} | [
"public",
"function",
"searchByUid",
"(",
"$",
"uid",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"ldap",
"->",
"search",
"(",
"$",
"this",
"->",
"basedn",
",",
"$",
"this",
"->",
"search_username",
".",
"'='",
".",
"$",
"uid",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| Queries LDAP for the record with the specified uid.
@param string $uid The uid to use for searching
@return Result-instance | [
"Queries",
"LDAP",
"for",
"the",
"record",
"with",
"the",
"specified",
"uid",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L462-L466 |
13,403 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.addObject | public function addObject($identifier, $attributes) {
// bind using the add credentials
$this->bind(
$this->add_dn,
$this->add_pw
);
// generate a new node and set its DN within the add subtree
$node = new Node();
// if the identifier contains a comma, it's likely a DN
if(strpos($identifier, ',') !== FALSE) {
$dn = $identifier;
}
else
{
// generate the DN from the identifier
$dn = $this->search_username . '=' . $identifier . ',' .
$this->add_base_dn;
}
$node->setDn($dn);
// if the node already exists we want to return false to prevent any
// potential updates (as updates would be performed by modifyObject())
try {
$this->ldap->getNode($dn);
return false;
}
catch(NodeNotFoundException $e) {
// iterate over the attributes and add them to the node
foreach($attributes as $key => $value) {
// this can handle both arrays of values as well as single values
// to be added for the record
$node->get($key, true)->add($value);
}
// save the node into the store
$this->ldap->save($node);
return true;
}
} | php | public function addObject($identifier, $attributes) {
// bind using the add credentials
$this->bind(
$this->add_dn,
$this->add_pw
);
// generate a new node and set its DN within the add subtree
$node = new Node();
// if the identifier contains a comma, it's likely a DN
if(strpos($identifier, ',') !== FALSE) {
$dn = $identifier;
}
else
{
// generate the DN from the identifier
$dn = $this->search_username . '=' . $identifier . ',' .
$this->add_base_dn;
}
$node->setDn($dn);
// if the node already exists we want to return false to prevent any
// potential updates (as updates would be performed by modifyObject())
try {
$this->ldap->getNode($dn);
return false;
}
catch(NodeNotFoundException $e) {
// iterate over the attributes and add them to the node
foreach($attributes as $key => $value) {
// this can handle both arrays of values as well as single values
// to be added for the record
$node->get($key, true)->add($value);
}
// save the node into the store
$this->ldap->save($node);
return true;
}
} | [
"public",
"function",
"addObject",
"(",
"$",
"identifier",
",",
"$",
"attributes",
")",
"{",
"// bind using the add credentials",
"$",
"this",
"->",
"bind",
"(",
"$",
"this",
"->",
"add_dn",
",",
"$",
"this",
"->",
"add_pw",
")",
";",
"// generate a new node and set its DN within the add subtree",
"$",
"node",
"=",
"new",
"Node",
"(",
")",
";",
"// if the identifier contains a comma, it's likely a DN",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"','",
")",
"!==",
"FALSE",
")",
"{",
"$",
"dn",
"=",
"$",
"identifier",
";",
"}",
"else",
"{",
"// generate the DN from the identifier",
"$",
"dn",
"=",
"$",
"this",
"->",
"search_username",
".",
"'='",
".",
"$",
"identifier",
".",
"','",
".",
"$",
"this",
"->",
"add_base_dn",
";",
"}",
"$",
"node",
"->",
"setDn",
"(",
"$",
"dn",
")",
";",
"// if the node already exists we want to return false to prevent any",
"// potential updates (as updates would be performed by modifyObject())",
"try",
"{",
"$",
"this",
"->",
"ldap",
"->",
"getNode",
"(",
"$",
"dn",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"NodeNotFoundException",
"$",
"e",
")",
"{",
"// iterate over the attributes and add them to the node",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// this can handle both arrays of values as well as single values",
"// to be added for the record",
"$",
"node",
"->",
"get",
"(",
"$",
"key",
",",
"true",
")",
"->",
"add",
"(",
"$",
"value",
")",
";",
"}",
"// save the node into the store",
"$",
"this",
"->",
"ldap",
"->",
"save",
"(",
"$",
"node",
")",
";",
"return",
"true",
";",
"}",
"}"
]
| Adds an object into the add subtree using the specified identifier and
an associative array of attributes. Returns a boolean describing whether
the operation was successful. Throws an exception if the bind fails.
@param string $identifier The value to use as the "username" identifier
@param array $attributes Associative array of attributes to add
@return bool
@throws BindException | [
"Adds",
"an",
"object",
"into",
"the",
"add",
"subtree",
"using",
"the",
"specified",
"identifier",
"and",
"an",
"associative",
"array",
"of",
"attributes",
".",
"Returns",
"a",
"boolean",
"describing",
"whether",
"the",
"operation",
"was",
"successful",
".",
"Throws",
"an",
"exception",
"if",
"the",
"bind",
"fails",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L479-L520 |
13,404 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.modifyObject | public function modifyObject($identifier, $attributes) {
// bind using the modify credentials if anything other than "self"
// has been set as the method
if($this->modify_method != "self") {
$this->bind(
$this->modify_dn,
$this->modify_pw
);
}
// if the identifier contains a comma, it's likely a DN
if(strpos($identifier, ',') !== FALSE) {
$dn = $identifier;
}
else
{
// generate the DN from the identifier
$dn = $this->search_username . '=' . $identifier . ',' .
$this->modify_base_dn;
}
try
{
// ensure the node exists before we perform an update since addition
// of nodes would be handled by addObject() instead
$node = $this->ldap->getNode($dn);
// iterate over the attributes and apply the changes. If an
// attribute already exists, set its value; otherwise, add the
// new value
foreach($attributes as $key => $value) {
if($node->has($key)) {
// if the value is either null or an empty array, just
// remove the attribute; otherwise, set it to a value
$node->get($key)->set($value);
}
else
{
$node->get($key, true)->add($value);
}
}
// save the node into the store
$this->ldap->save($node);
return true;
}
catch(NodeNotFoundException $e) {
// node does not exist
return false;
}
} | php | public function modifyObject($identifier, $attributes) {
// bind using the modify credentials if anything other than "self"
// has been set as the method
if($this->modify_method != "self") {
$this->bind(
$this->modify_dn,
$this->modify_pw
);
}
// if the identifier contains a comma, it's likely a DN
if(strpos($identifier, ',') !== FALSE) {
$dn = $identifier;
}
else
{
// generate the DN from the identifier
$dn = $this->search_username . '=' . $identifier . ',' .
$this->modify_base_dn;
}
try
{
// ensure the node exists before we perform an update since addition
// of nodes would be handled by addObject() instead
$node = $this->ldap->getNode($dn);
// iterate over the attributes and apply the changes. If an
// attribute already exists, set its value; otherwise, add the
// new value
foreach($attributes as $key => $value) {
if($node->has($key)) {
// if the value is either null or an empty array, just
// remove the attribute; otherwise, set it to a value
$node->get($key)->set($value);
}
else
{
$node->get($key, true)->add($value);
}
}
// save the node into the store
$this->ldap->save($node);
return true;
}
catch(NodeNotFoundException $e) {
// node does not exist
return false;
}
} | [
"public",
"function",
"modifyObject",
"(",
"$",
"identifier",
",",
"$",
"attributes",
")",
"{",
"// bind using the modify credentials if anything other than \"self\"",
"// has been set as the method",
"if",
"(",
"$",
"this",
"->",
"modify_method",
"!=",
"\"self\"",
")",
"{",
"$",
"this",
"->",
"bind",
"(",
"$",
"this",
"->",
"modify_dn",
",",
"$",
"this",
"->",
"modify_pw",
")",
";",
"}",
"// if the identifier contains a comma, it's likely a DN",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"','",
")",
"!==",
"FALSE",
")",
"{",
"$",
"dn",
"=",
"$",
"identifier",
";",
"}",
"else",
"{",
"// generate the DN from the identifier",
"$",
"dn",
"=",
"$",
"this",
"->",
"search_username",
".",
"'='",
".",
"$",
"identifier",
".",
"','",
".",
"$",
"this",
"->",
"modify_base_dn",
";",
"}",
"try",
"{",
"// ensure the node exists before we perform an update since addition",
"// of nodes would be handled by addObject() instead",
"$",
"node",
"=",
"$",
"this",
"->",
"ldap",
"->",
"getNode",
"(",
"$",
"dn",
")",
";",
"// iterate over the attributes and apply the changes. If an",
"// attribute already exists, set its value; otherwise, add the",
"// new value",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"// if the value is either null or an empty array, just",
"// remove the attribute; otherwise, set it to a value",
"$",
"node",
"->",
"get",
"(",
"$",
"key",
")",
"->",
"set",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"node",
"->",
"get",
"(",
"$",
"key",
",",
"true",
")",
"->",
"add",
"(",
"$",
"value",
")",
";",
"}",
"}",
"// save the node into the store",
"$",
"this",
"->",
"ldap",
"->",
"save",
"(",
"$",
"node",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"NodeNotFoundException",
"$",
"e",
")",
"{",
"// node does not exist",
"return",
"false",
";",
"}",
"}"
]
| Modifies an object in the modify subtree using the specified identifier
and an associative array of attributes. Returns a boolean describing
whether the operation was successful. Throws an exception if the bind
fails.
@param string $identifier The value to use as the "username" identifier
@param array $attributes Associative array of attributes to modify
@return bool
@throws BindException | [
"Modifies",
"an",
"object",
"in",
"the",
"modify",
"subtree",
"using",
"the",
"specified",
"identifier",
"and",
"an",
"associative",
"array",
"of",
"attributes",
".",
"Returns",
"a",
"boolean",
"describing",
"whether",
"the",
"operation",
"was",
"successful",
".",
"Throws",
"an",
"exception",
"if",
"the",
"bind",
"fails",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L534-L584 |
13,405 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.setAddBaseDN | public function setAddBaseDN($add_base_dn) {
if(!empty($add_base_dn)) {
$this->add_base_dn = $add_base_dn;
}
else
{
$this->add_base_dn = $this->basedn;
}
} | php | public function setAddBaseDN($add_base_dn) {
if(!empty($add_base_dn)) {
$this->add_base_dn = $add_base_dn;
}
else
{
$this->add_base_dn = $this->basedn;
}
} | [
"public",
"function",
"setAddBaseDN",
"(",
"$",
"add_base_dn",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"add_base_dn",
")",
")",
"{",
"$",
"this",
"->",
"add_base_dn",
"=",
"$",
"add_base_dn",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"add_base_dn",
"=",
"$",
"this",
"->",
"basedn",
";",
"}",
"}"
]
| Sets the base DN for add operations in a subtree.
@param string $add_base_dn The base DN for add operations | [
"Sets",
"the",
"base",
"DN",
"for",
"add",
"operations",
"in",
"a",
"subtree",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L659-L667 |
13,406 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.setAddDN | public function setAddDN($add_dn) {
if(!empty($add_dn)) {
$this->add_dn = $add_dn;
}
else
{
$this->add_dn = $this->dn;
}
} | php | public function setAddDN($add_dn) {
if(!empty($add_dn)) {
$this->add_dn = $add_dn;
}
else
{
$this->add_dn = $this->dn;
}
} | [
"public",
"function",
"setAddDN",
"(",
"$",
"add_dn",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"add_dn",
")",
")",
"{",
"$",
"this",
"->",
"add_dn",
"=",
"$",
"add_dn",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"add_dn",
"=",
"$",
"this",
"->",
"dn",
";",
"}",
"}"
]
| Sets the admin DN for add operations in a subtree. If the parameter is
left empty, the search admin DN will be used instead.
@param string $add_dn The admin DN for add operations | [
"Sets",
"the",
"admin",
"DN",
"for",
"add",
"operations",
"in",
"a",
"subtree",
".",
"If",
"the",
"parameter",
"is",
"left",
"empty",
"the",
"search",
"admin",
"DN",
"will",
"be",
"used",
"instead",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L675-L683 |
13,407 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.setAddPassword | public function setAddPassword($add_pw) {
if(!empty($add_pw)) {
$this->add_pw = $add_pw;
}
else
{
$this->add_pw = $this->password;
}
} | php | public function setAddPassword($add_pw) {
if(!empty($add_pw)) {
$this->add_pw = $add_pw;
}
else
{
$this->add_pw = $this->password;
}
} | [
"public",
"function",
"setAddPassword",
"(",
"$",
"add_pw",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"add_pw",
")",
")",
"{",
"$",
"this",
"->",
"add_pw",
"=",
"$",
"add_pw",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"add_pw",
"=",
"$",
"this",
"->",
"password",
";",
"}",
"}"
]
| Sets the admin password for add operations in a subtree. If the
parameter is left empty, the search admin password will be used instead.
@param string $add_pw The admin password for add operations | [
"Sets",
"the",
"admin",
"password",
"for",
"add",
"operations",
"in",
"a",
"subtree",
".",
"If",
"the",
"parameter",
"is",
"left",
"empty",
"the",
"search",
"admin",
"password",
"will",
"be",
"used",
"instead",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L691-L699 |
13,408 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.setModifyBaseDN | public function setModifyBaseDN($modify_base_dn) {
if(!empty($modify_base_dn)) {
$this->modify_base_dn = $modify_base_dn;
}
else
{
$this->modify_base_dn = $this->add_base_dn;
}
} | php | public function setModifyBaseDN($modify_base_dn) {
if(!empty($modify_base_dn)) {
$this->modify_base_dn = $modify_base_dn;
}
else
{
$this->modify_base_dn = $this->add_base_dn;
}
} | [
"public",
"function",
"setModifyBaseDN",
"(",
"$",
"modify_base_dn",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"modify_base_dn",
")",
")",
"{",
"$",
"this",
"->",
"modify_base_dn",
"=",
"$",
"modify_base_dn",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"modify_base_dn",
"=",
"$",
"this",
"->",
"add_base_dn",
";",
"}",
"}"
]
| Sets the base DN for modify operations in a subtree. If the parameter is
left empty, the add base DN will be used instead.
@param string $modify_base_dn The base DN for modify operations | [
"Sets",
"the",
"base",
"DN",
"for",
"modify",
"operations",
"in",
"a",
"subtree",
".",
"If",
"the",
"parameter",
"is",
"left",
"empty",
"the",
"add",
"base",
"DN",
"will",
"be",
"used",
"instead",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L724-L732 |
13,409 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.setModifyDN | public function setModifyDN($modify_dn) {
if(!empty($modify_dn)) {
$this->modify_dn = $modify_dn;
}
else
{
$this->modify_dn = $this->add_dn;
}
} | php | public function setModifyDN($modify_dn) {
if(!empty($modify_dn)) {
$this->modify_dn = $modify_dn;
}
else
{
$this->modify_dn = $this->add_dn;
}
} | [
"public",
"function",
"setModifyDN",
"(",
"$",
"modify_dn",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"modify_dn",
")",
")",
"{",
"$",
"this",
"->",
"modify_dn",
"=",
"$",
"modify_dn",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"modify_dn",
"=",
"$",
"this",
"->",
"add_dn",
";",
"}",
"}"
]
| Sets the admin DN for modify operations in a subtree. If the parameter
is left empty, the add admin DN will be used instead.
@param string $modify_dn The admin DN for modify operations | [
"Sets",
"the",
"admin",
"DN",
"for",
"modify",
"operations",
"in",
"a",
"subtree",
".",
"If",
"the",
"parameter",
"is",
"left",
"empty",
"the",
"add",
"admin",
"DN",
"will",
"be",
"used",
"instead",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L740-L748 |
13,410 | csun-metalab/laravel-directory-authentication | src/Authentication/Handlers/HandlerLDAP.php | HandlerLDAP.setModifyPassword | public function setModifyPassword($modify_pw) {
if(!empty($modify_pw)) {
$this->modify_pw = $modify_pw;
}
else
{
$this->modify_pw = $this->add_pw;
}
} | php | public function setModifyPassword($modify_pw) {
if(!empty($modify_pw)) {
$this->modify_pw = $modify_pw;
}
else
{
$this->modify_pw = $this->add_pw;
}
} | [
"public",
"function",
"setModifyPassword",
"(",
"$",
"modify_pw",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"modify_pw",
")",
")",
"{",
"$",
"this",
"->",
"modify_pw",
"=",
"$",
"modify_pw",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"modify_pw",
"=",
"$",
"this",
"->",
"add_pw",
";",
"}",
"}"
]
| Sets the admin password for modify operations in a subtree. If the
parameter is left empty, the add admin password will be used instead.
@param string $modify_dn The admin password for modify operations | [
"Sets",
"the",
"admin",
"password",
"for",
"modify",
"operations",
"in",
"a",
"subtree",
".",
"If",
"the",
"parameter",
"is",
"left",
"empty",
"the",
"add",
"admin",
"password",
"will",
"be",
"used",
"instead",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Handlers/HandlerLDAP.php#L756-L764 |
13,411 | venta/framework | src/ServiceProvider/src/AbstractServiceProvider.php | AbstractServiceProvider.loadConfigFromFiles | protected function loadConfigFromFiles(string ...$configFiles)
{
foreach ($configFiles as $configFile) {
$this->config->merge(require $configFile);
}
} | php | protected function loadConfigFromFiles(string ...$configFiles)
{
foreach ($configFiles as $configFile) {
$this->config->merge(require $configFile);
}
} | [
"protected",
"function",
"loadConfigFromFiles",
"(",
"string",
"...",
"$",
"configFiles",
")",
"{",
"foreach",
"(",
"$",
"configFiles",
"as",
"$",
"configFile",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"merge",
"(",
"require",
"$",
"configFile",
")",
";",
"}",
"}"
]
| Merges config params from service provider with the global configuration.
@param string[] ...$configFiles | [
"Merges",
"config",
"params",
"from",
"service",
"provider",
"with",
"the",
"global",
"configuration",
"."
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/ServiceProvider/src/AbstractServiceProvider.php#L82-L87 |
13,412 | venta/framework | src/ServiceProvider/src/AbstractServiceProvider.php | AbstractServiceProvider.provideCommands | protected function provideCommands(string ...$commandClasses)
{
/** @var CommandCollection $commandCollector */
$commandCollector = $this->container->get(CommandCollection::class);
foreach ($commandClasses as $commandClass) {
$commandCollector->add($commandClass);
}
} | php | protected function provideCommands(string ...$commandClasses)
{
/** @var CommandCollection $commandCollector */
$commandCollector = $this->container->get(CommandCollection::class);
foreach ($commandClasses as $commandClass) {
$commandCollector->add($commandClass);
}
} | [
"protected",
"function",
"provideCommands",
"(",
"string",
"...",
"$",
"commandClasses",
")",
"{",
"/** @var CommandCollection $commandCollector */",
"$",
"commandCollector",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"CommandCollection",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"commandClasses",
"as",
"$",
"commandClass",
")",
"{",
"$",
"commandCollector",
"->",
"add",
"(",
"$",
"commandClass",
")",
";",
"}",
"}"
]
| Registers commands exposed by service provider.
@param string[] ...$commandClasses | [
"Registers",
"commands",
"exposed",
"by",
"service",
"provider",
"."
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/ServiceProvider/src/AbstractServiceProvider.php#L94-L101 |
13,413 | incraigulous/contentful-sdk | src/ManagementClient.php | ManagementClient.post | function post($resource, $payload = array(), $headers = array())
{
$result = $this->client->post($this->build_url($resource), [
'headers' => array_merge([
'Content-Type' => $this->getContentType(),
'Authorization' => $this->getBearer(),
'Content-Length' => (!count($payload)) ? 0 : strlen(json_encode($payload)),
], $headers),
'body' => json_encode($payload)
]);
return $result;
} | php | function post($resource, $payload = array(), $headers = array())
{
$result = $this->client->post($this->build_url($resource), [
'headers' => array_merge([
'Content-Type' => $this->getContentType(),
'Authorization' => $this->getBearer(),
'Content-Length' => (!count($payload)) ? 0 : strlen(json_encode($payload)),
], $headers),
'body' => json_encode($payload)
]);
return $result;
} | [
"function",
"post",
"(",
"$",
"resource",
",",
"$",
"payload",
"=",
"array",
"(",
")",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"build_url",
"(",
"$",
"resource",
")",
",",
"[",
"'headers'",
"=>",
"array_merge",
"(",
"[",
"'Content-Type'",
"=>",
"$",
"this",
"->",
"getContentType",
"(",
")",
",",
"'Authorization'",
"=>",
"$",
"this",
"->",
"getBearer",
"(",
")",
",",
"'Content-Length'",
"=>",
"(",
"!",
"count",
"(",
"$",
"payload",
")",
")",
"?",
"0",
":",
"strlen",
"(",
"json_encode",
"(",
"$",
"payload",
")",
")",
",",
"]",
",",
"$",
"headers",
")",
",",
"'body'",
"=>",
"json_encode",
"(",
"$",
"payload",
")",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Build and make a POST request.
@param $resource
@param array $payload
@param array $headers
@return GuzzleHttp\Message\FutureResponse|GuzzleHttp\Message\ResponseInterface|GuzzleHttp\Ring\Future\FutureInterface|mixed|null | [
"Build",
"and",
"make",
"a",
"POST",
"request",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/ManagementClient.php#L42-L53 |
13,414 | incraigulous/contentful-sdk | src/ManagementClient.php | ManagementClient.delete | function delete($resource, $headers = array())
{
$result = $this->client->delete($this->build_url($resource), [
'headers' => array_merge([
'Authorization' => $this->getBearer()
], $headers)
]);
return $result;
} | php | function delete($resource, $headers = array())
{
$result = $this->client->delete($this->build_url($resource), [
'headers' => array_merge([
'Authorization' => $this->getBearer()
], $headers)
]);
return $result;
} | [
"function",
"delete",
"(",
"$",
"resource",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"build_url",
"(",
"$",
"resource",
")",
",",
"[",
"'headers'",
"=>",
"array_merge",
"(",
"[",
"'Authorization'",
"=>",
"$",
"this",
"->",
"getBearer",
"(",
")",
"]",
",",
"$",
"headers",
")",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Build and make a DELETE request.
@param $resource
@param array $headers
@return GuzzleHttp\Message\FutureResponse|GuzzleHttp\Message\ResponseInterface|GuzzleHttp\Ring\Future\FutureInterface|mixed|null | [
"Build",
"and",
"make",
"a",
"DELETE",
"request",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/ManagementClient.php#L82-L90 |
13,415 | attm2x/m2x-php | src/HttpRequest.php | HttpRequest.request | public function request($method, $url, $params = array(), $vars = array()) {
$this->request = curl_init();
$this->setRequestMethod($method);
$this->setOptions($url, $method, $params, $vars);
$data = curl_exec($this->request);
if ($data === false) {
throw new \Exception('Curl Error: ' . curl_error($this->request));
}
$response = new HttpResponse($data);
curl_close($this->request);
return $response;
} | php | public function request($method, $url, $params = array(), $vars = array()) {
$this->request = curl_init();
$this->setRequestMethod($method);
$this->setOptions($url, $method, $params, $vars);
$data = curl_exec($this->request);
if ($data === false) {
throw new \Exception('Curl Error: ' . curl_error($this->request));
}
$response = new HttpResponse($data);
curl_close($this->request);
return $response;
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"curl_init",
"(",
")",
";",
"$",
"this",
"->",
"setRequestMethod",
"(",
"$",
"method",
")",
";",
"$",
"this",
"->",
"setOptions",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"params",
",",
"$",
"vars",
")",
";",
"$",
"data",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"request",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Curl Error: '",
".",
"curl_error",
"(",
"$",
"this",
"->",
"request",
")",
")",
";",
"}",
"$",
"response",
"=",
"new",
"HttpResponse",
"(",
"$",
"data",
")",
";",
"curl_close",
"(",
"$",
"this",
"->",
"request",
")",
";",
"return",
"$",
"response",
";",
"}"
]
| Executes a request
@param string $method
@param string $url
@param array $params
@param array $vars
@return HttpResponse | [
"Executes",
"a",
"request"
]
| 4c2ff6d70af50538818855e648af24bf5cf16ead | https://github.com/attm2x/m2x-php/blob/4c2ff6d70af50538818855e648af24bf5cf16ead/src/HttpRequest.php#L86-L103 |
13,416 | attm2x/m2x-php | src/HttpRequest.php | HttpRequest.setRequestMethod | protected function setRequestMethod($method) {
switch (strtoupper($method)) {
case 'HEAD':
curl_setopt($this->request, CURLOPT_NOBODY, true);
break;
case 'GET':
# Hack to allow a request body to be set via CURLOPT_POSTFIELDS
# for GET requests.
curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, 'GET');
break;
case 'POST':
curl_setopt($this->request, CURLOPT_POST, true);
break;
default:
curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, $method);
}
} | php | protected function setRequestMethod($method) {
switch (strtoupper($method)) {
case 'HEAD':
curl_setopt($this->request, CURLOPT_NOBODY, true);
break;
case 'GET':
# Hack to allow a request body to be set via CURLOPT_POSTFIELDS
# for GET requests.
curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, 'GET');
break;
case 'POST':
curl_setopt($this->request, CURLOPT_POST, true);
break;
default:
curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, $method);
}
} | [
"protected",
"function",
"setRequestMethod",
"(",
"$",
"method",
")",
"{",
"switch",
"(",
"strtoupper",
"(",
"$",
"method",
")",
")",
"{",
"case",
"'HEAD'",
":",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_NOBODY",
",",
"true",
")",
";",
"break",
";",
"case",
"'GET'",
":",
"# Hack to allow a request body to be set via CURLOPT_POSTFIELDS",
"# for GET requests.",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'GET'",
")",
";",
"break",
";",
"case",
"'POST'",
":",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"break",
";",
"default",
":",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"method",
")",
";",
"}",
"}"
]
| Set the associated CURL options for a request method
@param string $method
@return void | [
"Set",
"the",
"associated",
"CURL",
"options",
"for",
"a",
"request",
"method"
]
| 4c2ff6d70af50538818855e648af24bf5cf16ead | https://github.com/attm2x/m2x-php/blob/4c2ff6d70af50538818855e648af24bf5cf16ead/src/HttpRequest.php#L111-L127 |
13,417 | attm2x/m2x-php | src/HttpRequest.php | HttpRequest.setOptions | protected function setOptions($url, $method, $params, $vars) {
if(!empty($params)) {
$url = $url . "?" . http_build_query($params);
}
curl_setopt($this->request, CURLOPT_URL, $url);
curl_setopt($this->request, CURLOPT_HEADER, true);
curl_setopt($this->request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, true);
if (in_array($method, array('POST', 'PUT')) || ($method == 'GET' && !empty($vars))) {
$this->setJSONPayload($vars);
}
$headers = array();
foreach ($this->headers as $key => $value) {
$headers[] = $key . ':' . $value;
}
curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
} | php | protected function setOptions($url, $method, $params, $vars) {
if(!empty($params)) {
$url = $url . "?" . http_build_query($params);
}
curl_setopt($this->request, CURLOPT_URL, $url);
curl_setopt($this->request, CURLOPT_HEADER, true);
curl_setopt($this->request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, true);
if (in_array($method, array('POST', 'PUT')) || ($method == 'GET' && !empty($vars))) {
$this->setJSONPayload($vars);
}
$headers = array();
foreach ($this->headers as $key => $value) {
$headers[] = $key . ':' . $value;
}
curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
} | [
"protected",
"function",
"setOptions",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"params",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"url",
"=",
"$",
"url",
".",
"\"?\"",
".",
"http_build_query",
"(",
"$",
"params",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_HEADER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"method",
",",
"array",
"(",
"'POST'",
",",
"'PUT'",
")",
")",
"||",
"(",
"$",
"method",
"==",
"'GET'",
"&&",
"!",
"empty",
"(",
"$",
"vars",
")",
")",
")",
"{",
"$",
"this",
"->",
"setJSONPayload",
"(",
"$",
"vars",
")",
";",
"}",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"$",
"key",
".",
"':'",
".",
"$",
"value",
";",
"}",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"headers",
")",
";",
"}"
]
| Set the CURL options
@param string $url
@param array $method
@param array $params
@param array $vars
@return void | [
"Set",
"the",
"CURL",
"options"
]
| 4c2ff6d70af50538818855e648af24bf5cf16ead | https://github.com/attm2x/m2x-php/blob/4c2ff6d70af50538818855e648af24bf5cf16ead/src/HttpRequest.php#L138-L158 |
13,418 | attm2x/m2x-php | src/HttpRequest.php | HttpRequest.setJSONPayload | protected function setJSONPayload($vars) {
$this->headers['Content-Type'] = 'application/json';
$this->headers['Content-Length'] = 0;
$this->headers['Expect'] = '';
if (!empty($vars)) {
$data = json_encode($vars);
$this->headers['Content-Length'] = strlen($data);
curl_setopt($this->request, CURLOPT_POSTFIELDS, $data);
}
} | php | protected function setJSONPayload($vars) {
$this->headers['Content-Type'] = 'application/json';
$this->headers['Content-Length'] = 0;
$this->headers['Expect'] = '';
if (!empty($vars)) {
$data = json_encode($vars);
$this->headers['Content-Length'] = strlen($data);
curl_setopt($this->request, CURLOPT_POSTFIELDS, $data);
}
} | [
"protected",
"function",
"setJSONPayload",
"(",
"$",
"vars",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/json'",
";",
"$",
"this",
"->",
"headers",
"[",
"'Content-Length'",
"]",
"=",
"0",
";",
"$",
"this",
"->",
"headers",
"[",
"'Expect'",
"]",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"vars",
")",
")",
"{",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"vars",
")",
";",
"$",
"this",
"->",
"headers",
"[",
"'Content-Length'",
"]",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data",
")",
";",
"}",
"}"
]
| Set the JSON payload
@param array $vars | [
"Set",
"the",
"JSON",
"payload"
]
| 4c2ff6d70af50538818855e648af24bf5cf16ead | https://github.com/attm2x/m2x-php/blob/4c2ff6d70af50538818855e648af24bf5cf16ead/src/HttpRequest.php#L165-L175 |
13,419 | kriskbx/mikado | src/Formatters/MetaFormatter.php | MetaFormatter.format | public function format($data)
{
if (!$data->hasProperty('meta')) {
return $data;
}
// Loop through the meta arrays/objects/whatever
foreach ($data->getProperty('meta') as $meta) {
$regex = false;
// Check if the meta array is valid
if (!$this->metaKeyExists($meta) && !($regex = $this->metaKeyIsRegex($meta))) {
continue;
}
// Get the property
if ($regex) {
$property = $this->getRegexProperty($regex, $regex['value']);
} else {
$property = $this->metaFields[$meta['meta_key']];
}
// Get the value
$value = $this->getUnserializedValue($meta);
// Set it
$data->setProperty($property, $value);
}
$data->unsetProperty('meta');
return $data;
} | php | public function format($data)
{
if (!$data->hasProperty('meta')) {
return $data;
}
// Loop through the meta arrays/objects/whatever
foreach ($data->getProperty('meta') as $meta) {
$regex = false;
// Check if the meta array is valid
if (!$this->metaKeyExists($meta) && !($regex = $this->metaKeyIsRegex($meta))) {
continue;
}
// Get the property
if ($regex) {
$property = $this->getRegexProperty($regex, $regex['value']);
} else {
$property = $this->metaFields[$meta['meta_key']];
}
// Get the value
$value = $this->getUnserializedValue($meta);
// Set it
$data->setProperty($property, $value);
}
$data->unsetProperty('meta');
return $data;
} | [
"public",
"function",
"format",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"->",
"hasProperty",
"(",
"'meta'",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"// Loop through the meta arrays/objects/whatever",
"foreach",
"(",
"$",
"data",
"->",
"getProperty",
"(",
"'meta'",
")",
"as",
"$",
"meta",
")",
"{",
"$",
"regex",
"=",
"false",
";",
"// Check if the meta array is valid",
"if",
"(",
"!",
"$",
"this",
"->",
"metaKeyExists",
"(",
"$",
"meta",
")",
"&&",
"!",
"(",
"$",
"regex",
"=",
"$",
"this",
"->",
"metaKeyIsRegex",
"(",
"$",
"meta",
")",
")",
")",
"{",
"continue",
";",
"}",
"// Get the property",
"if",
"(",
"$",
"regex",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"getRegexProperty",
"(",
"$",
"regex",
",",
"$",
"regex",
"[",
"'value'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"metaFields",
"[",
"$",
"meta",
"[",
"'meta_key'",
"]",
"]",
";",
"}",
"// Get the value",
"$",
"value",
"=",
"$",
"this",
"->",
"getUnserializedValue",
"(",
"$",
"meta",
")",
";",
"// Set it",
"$",
"data",
"->",
"setProperty",
"(",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"$",
"data",
"->",
"unsetProperty",
"(",
"'meta'",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Format the meta fields from the given data.
@param FormatAble $data
@return FormatAble | [
"Format",
"the",
"meta",
"fields",
"from",
"the",
"given",
"data",
"."
]
| f00e566d682a66796f3f8a68b348920fadd9ee87 | https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/src/Formatters/MetaFormatter.php#L41-L73 |
13,420 | kriskbx/mikado | src/Formatters/MetaFormatter.php | MetaFormatter.metaKeyIsRegex | protected function metaKeyIsRegex($meta)
{
if (!isset($meta['meta_key'])) {
return false;
}
return $this->pregMatchArray($meta['meta_key'], $this->regex);
} | php | protected function metaKeyIsRegex($meta)
{
if (!isset($meta['meta_key'])) {
return false;
}
return $this->pregMatchArray($meta['meta_key'], $this->regex);
} | [
"protected",
"function",
"metaKeyIsRegex",
"(",
"$",
"meta",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"meta",
"[",
"'meta_key'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"pregMatchArray",
"(",
"$",
"meta",
"[",
"'meta_key'",
"]",
",",
"$",
"this",
"->",
"regex",
")",
";",
"}"
]
| Meta key is regex?
@param array $meta
@return array|bool | [
"Meta",
"key",
"is",
"regex?"
]
| f00e566d682a66796f3f8a68b348920fadd9ee87 | https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/src/Formatters/MetaFormatter.php#L98-L105 |
13,421 | kriskbx/mikado | src/Formatters/MetaFormatter.php | MetaFormatter.getUnserializedValue | protected function getUnserializedValue($meta)
{
$value = $meta['meta_value'];
if ($unserializedValue = @unserialize($value)) {
$value = $unserializedValue;
}
return $value;
} | php | protected function getUnserializedValue($meta)
{
$value = $meta['meta_value'];
if ($unserializedValue = @unserialize($value)) {
$value = $unserializedValue;
}
return $value;
} | [
"protected",
"function",
"getUnserializedValue",
"(",
"$",
"meta",
")",
"{",
"$",
"value",
"=",
"$",
"meta",
"[",
"'meta_value'",
"]",
";",
"if",
"(",
"$",
"unserializedValue",
"=",
"@",
"unserialize",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"unserializedValue",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Get unserialized value.
@param array $meta
@return mixed | [
"Get",
"unserialized",
"value",
"."
]
| f00e566d682a66796f3f8a68b348920fadd9ee87 | https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/src/Formatters/MetaFormatter.php#L114-L123 |
13,422 | ikwattro/guzzle-stereo | src/Recorder.php | Recorder.processConfig | private function processConfig()
{
$processor = new Processor();
$coreConfig = Yaml::parse(file_get_contents(__DIR__.'/Resources/core_filters.yml'));
$configs = array($this->config, $coreConfig);
$configuration = new StereoConfiguration();
$processedConfiguration = $processor->processConfiguration(
$configuration,
$configs
);
foreach ($processedConfiguration['core_filters'] as $filterClass) {
$this->mixer->addFilter($filterClass);
}
foreach ($processedConfiguration['custom_filters'] as $customFilterClass) {
$this->mixer->addFilter($customFilterClass);
}
foreach ($processedConfiguration['tapes'] as $name => $settings) {
$tape = new Tape($name);
foreach ($settings['filters'] as $k => $args) {
$filter = $this->mixer->createFilter($k, $args);
$tape->addFilter($filter);
}
$this->addTape($tape);
}
} | php | private function processConfig()
{
$processor = new Processor();
$coreConfig = Yaml::parse(file_get_contents(__DIR__.'/Resources/core_filters.yml'));
$configs = array($this->config, $coreConfig);
$configuration = new StereoConfiguration();
$processedConfiguration = $processor->processConfiguration(
$configuration,
$configs
);
foreach ($processedConfiguration['core_filters'] as $filterClass) {
$this->mixer->addFilter($filterClass);
}
foreach ($processedConfiguration['custom_filters'] as $customFilterClass) {
$this->mixer->addFilter($customFilterClass);
}
foreach ($processedConfiguration['tapes'] as $name => $settings) {
$tape = new Tape($name);
foreach ($settings['filters'] as $k => $args) {
$filter = $this->mixer->createFilter($k, $args);
$tape->addFilter($filter);
}
$this->addTape($tape);
}
} | [
"private",
"function",
"processConfig",
"(",
")",
"{",
"$",
"processor",
"=",
"new",
"Processor",
"(",
")",
";",
"$",
"coreConfig",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"__DIR__",
".",
"'/Resources/core_filters.yml'",
")",
")",
";",
"$",
"configs",
"=",
"array",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"coreConfig",
")",
";",
"$",
"configuration",
"=",
"new",
"StereoConfiguration",
"(",
")",
";",
"$",
"processedConfiguration",
"=",
"$",
"processor",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"foreach",
"(",
"$",
"processedConfiguration",
"[",
"'core_filters'",
"]",
"as",
"$",
"filterClass",
")",
"{",
"$",
"this",
"->",
"mixer",
"->",
"addFilter",
"(",
"$",
"filterClass",
")",
";",
"}",
"foreach",
"(",
"$",
"processedConfiguration",
"[",
"'custom_filters'",
"]",
"as",
"$",
"customFilterClass",
")",
"{",
"$",
"this",
"->",
"mixer",
"->",
"addFilter",
"(",
"$",
"customFilterClass",
")",
";",
"}",
"foreach",
"(",
"$",
"processedConfiguration",
"[",
"'tapes'",
"]",
"as",
"$",
"name",
"=>",
"$",
"settings",
")",
"{",
"$",
"tape",
"=",
"new",
"Tape",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"settings",
"[",
"'filters'",
"]",
"as",
"$",
"k",
"=>",
"$",
"args",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"mixer",
"->",
"createFilter",
"(",
"$",
"k",
",",
"$",
"args",
")",
";",
"$",
"tape",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"}",
"$",
"this",
"->",
"addTape",
"(",
"$",
"tape",
")",
";",
"}",
"}"
]
| Process configuration for registering tapes and filters. | [
"Process",
"configuration",
"for",
"registering",
"tapes",
"and",
"filters",
"."
]
| a76f19b0a81048eca104f07bd490bf06a46b6e9d | https://github.com/ikwattro/guzzle-stereo/blob/a76f19b0a81048eca104f07bd490bf06a46b6e9d/src/Recorder.php#L145-L172 |
13,423 | ikwattro/guzzle-stereo | src/Recorder.php | Recorder.dump | public function dump()
{
foreach ($this->tapes as $tape) {
if ($tape->hasResponses()) {
$fileName = 'record_'.$tape->getName().'.json';
$content = $this->formatter->encodeResponsesCollection($tape->getResponses());
$this->writer->write($fileName, $content);
}
}
} | php | public function dump()
{
foreach ($this->tapes as $tape) {
if ($tape->hasResponses()) {
$fileName = 'record_'.$tape->getName().'.json';
$content = $this->formatter->encodeResponsesCollection($tape->getResponses());
$this->writer->write($fileName, $content);
}
}
} | [
"public",
"function",
"dump",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tapes",
"as",
"$",
"tape",
")",
"{",
"if",
"(",
"$",
"tape",
"->",
"hasResponses",
"(",
")",
")",
"{",
"$",
"fileName",
"=",
"'record_'",
".",
"$",
"tape",
"->",
"getName",
"(",
")",
".",
"'.json'",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"formatter",
"->",
"encodeResponsesCollection",
"(",
"$",
"tape",
"->",
"getResponses",
"(",
")",
")",
";",
"$",
"this",
"->",
"writer",
"->",
"write",
"(",
"$",
"fileName",
",",
"$",
"content",
")",
";",
"}",
"}",
"}"
]
| Dumps the tapes on disk. | [
"Dumps",
"the",
"tapes",
"on",
"disk",
"."
]
| a76f19b0a81048eca104f07bd490bf06a46b6e9d | https://github.com/ikwattro/guzzle-stereo/blob/a76f19b0a81048eca104f07bd490bf06a46b6e9d/src/Recorder.php#L185-L194 |
13,424 | ikwattro/guzzle-stereo | src/Recorder.php | Recorder.getTapeContent | public function getTapeContent($name)
{
$tape = $this->getTape($name);
if ($tape->hasResponses()) {
$content = $this->formatter->encodeResponsesCollection($tape->getResponses());
return $content;
}
return;
} | php | public function getTapeContent($name)
{
$tape = $this->getTape($name);
if ($tape->hasResponses()) {
$content = $this->formatter->encodeResponsesCollection($tape->getResponses());
return $content;
}
return;
} | [
"public",
"function",
"getTapeContent",
"(",
"$",
"name",
")",
"{",
"$",
"tape",
"=",
"$",
"this",
"->",
"getTape",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"tape",
"->",
"hasResponses",
"(",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"formatter",
"->",
"encodeResponsesCollection",
"(",
"$",
"tape",
"->",
"getResponses",
"(",
")",
")",
";",
"return",
"$",
"content",
";",
"}",
"return",
";",
"}"
]
| Returns the content of a specific tape without writing it to disk.
@param string $name
@return null|string | [
"Returns",
"the",
"content",
"of",
"a",
"specific",
"tape",
"without",
"writing",
"it",
"to",
"disk",
"."
]
| a76f19b0a81048eca104f07bd490bf06a46b6e9d | https://github.com/ikwattro/guzzle-stereo/blob/a76f19b0a81048eca104f07bd490bf06a46b6e9d/src/Recorder.php#L203-L213 |
13,425 | DevGroup-ru/yii2-data-structure-tools | src/widgets/PropertiesForm.php | PropertiesForm.buildTabsArray | protected function buildTabsArray($availableGroups, $attachedGroups)
{
$addGroupItems = [];
$tabs = [];
foreach ($availableGroups as $id => $name) {
if (!in_array($id, $attachedGroups)) {
$addGroupItems[$id] = $name;
}
$isAttached = in_array($id, $attachedGroups);
if ($isAttached) {
$content = '';
/** @var Property[] $properties */
$properties = Property::find()
->from(Property::tableName() . ' p')
->innerJoin(
PropertyPropertyGroup::tableName() . ' ppg',
'p.id = ppg.property_id'
)
->where(['ppg.property_group_id' => $id])
->all();
foreach ($properties as $property) {
$content .= $property
->handler()
->renderProperty(
$this->model,
$property,
AbstractPropertyHandler::BACKEND_EDIT,
$this->form
);
}
$tabs[] = [
'label' => Html::encode($name)
. ' '
. Html::button(
new Icon('close'),
[
'class' => 'btn btn-danger btn-xs',
'data-group-id' => $id,
'data-action' => 'delete-property-group',
]
),
'content' => $content . Html::hiddenInput(
'propertyGroupIds[]',
$id,
[
'class' => 'property-group-ids',
]
),
];
}
}
$tabs[] = [
'label' => Select2::widget([
'data' => $addGroupItems,
'name' => 'plus-group',
'options' => [
'placeholder' => Module::t('widget', '(+) Add group'),
'style' => [
'min-width' => '100px'
]
],
'pluginOptions' => [
'allowClear' => true
],
]),
'url' => '#',
];
return $tabs;
} | php | protected function buildTabsArray($availableGroups, $attachedGroups)
{
$addGroupItems = [];
$tabs = [];
foreach ($availableGroups as $id => $name) {
if (!in_array($id, $attachedGroups)) {
$addGroupItems[$id] = $name;
}
$isAttached = in_array($id, $attachedGroups);
if ($isAttached) {
$content = '';
/** @var Property[] $properties */
$properties = Property::find()
->from(Property::tableName() . ' p')
->innerJoin(
PropertyPropertyGroup::tableName() . ' ppg',
'p.id = ppg.property_id'
)
->where(['ppg.property_group_id' => $id])
->all();
foreach ($properties as $property) {
$content .= $property
->handler()
->renderProperty(
$this->model,
$property,
AbstractPropertyHandler::BACKEND_EDIT,
$this->form
);
}
$tabs[] = [
'label' => Html::encode($name)
. ' '
. Html::button(
new Icon('close'),
[
'class' => 'btn btn-danger btn-xs',
'data-group-id' => $id,
'data-action' => 'delete-property-group',
]
),
'content' => $content . Html::hiddenInput(
'propertyGroupIds[]',
$id,
[
'class' => 'property-group-ids',
]
),
];
}
}
$tabs[] = [
'label' => Select2::widget([
'data' => $addGroupItems,
'name' => 'plus-group',
'options' => [
'placeholder' => Module::t('widget', '(+) Add group'),
'style' => [
'min-width' => '100px'
]
],
'pluginOptions' => [
'allowClear' => true
],
]),
'url' => '#',
];
return $tabs;
} | [
"protected",
"function",
"buildTabsArray",
"(",
"$",
"availableGroups",
",",
"$",
"attachedGroups",
")",
"{",
"$",
"addGroupItems",
"=",
"[",
"]",
";",
"$",
"tabs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"availableGroups",
"as",
"$",
"id",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"id",
",",
"$",
"attachedGroups",
")",
")",
"{",
"$",
"addGroupItems",
"[",
"$",
"id",
"]",
"=",
"$",
"name",
";",
"}",
"$",
"isAttached",
"=",
"in_array",
"(",
"$",
"id",
",",
"$",
"attachedGroups",
")",
";",
"if",
"(",
"$",
"isAttached",
")",
"{",
"$",
"content",
"=",
"''",
";",
"/** @var Property[] $properties */",
"$",
"properties",
"=",
"Property",
"::",
"find",
"(",
")",
"->",
"from",
"(",
"Property",
"::",
"tableName",
"(",
")",
".",
"' p'",
")",
"->",
"innerJoin",
"(",
"PropertyPropertyGroup",
"::",
"tableName",
"(",
")",
".",
"' ppg'",
",",
"'p.id = ppg.property_id'",
")",
"->",
"where",
"(",
"[",
"'ppg.property_group_id'",
"=>",
"$",
"id",
"]",
")",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"content",
".=",
"$",
"property",
"->",
"handler",
"(",
")",
"->",
"renderProperty",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"property",
",",
"AbstractPropertyHandler",
"::",
"BACKEND_EDIT",
",",
"$",
"this",
"->",
"form",
")",
";",
"}",
"$",
"tabs",
"[",
"]",
"=",
"[",
"'label'",
"=>",
"Html",
"::",
"encode",
"(",
"$",
"name",
")",
".",
"' '",
".",
"Html",
"::",
"button",
"(",
"new",
"Icon",
"(",
"'close'",
")",
",",
"[",
"'class'",
"=>",
"'btn btn-danger btn-xs'",
",",
"'data-group-id'",
"=>",
"$",
"id",
",",
"'data-action'",
"=>",
"'delete-property-group'",
",",
"]",
")",
",",
"'content'",
"=>",
"$",
"content",
".",
"Html",
"::",
"hiddenInput",
"(",
"'propertyGroupIds[]'",
",",
"$",
"id",
",",
"[",
"'class'",
"=>",
"'property-group-ids'",
",",
"]",
")",
",",
"]",
";",
"}",
"}",
"$",
"tabs",
"[",
"]",
"=",
"[",
"'label'",
"=>",
"Select2",
"::",
"widget",
"(",
"[",
"'data'",
"=>",
"$",
"addGroupItems",
",",
"'name'",
"=>",
"'plus-group'",
",",
"'options'",
"=>",
"[",
"'placeholder'",
"=>",
"Module",
"::",
"t",
"(",
"'widget'",
",",
"'(+) Add group'",
")",
",",
"'style'",
"=>",
"[",
"'min-width'",
"=>",
"'100px'",
"]",
"]",
",",
"'pluginOptions'",
"=>",
"[",
"'allowClear'",
"=>",
"true",
"]",
",",
"]",
")",
",",
"'url'",
"=>",
"'#'",
",",
"]",
";",
"return",
"$",
"tabs",
";",
"}"
]
| Build array for tabs.
@param array $availableGroups
@param array $attachedGroups
@return array | [
"Build",
"array",
"for",
"tabs",
"."
]
| a5b24d7c0b24d4b0d58cacd91ec7fd876e979097 | https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/widgets/PropertiesForm.php#L60-L131 |
13,426 | taskforcedev/laravel-support | src/Helpers/Composer.php | Composer.packageExists | public function packageExists($namespace, $package)
{
$folder = $this->vendorFolder . $namespace;
$folderExists = file_exists($folder);
if (!$folderExists) {
return false;
}
$packageFolder = $folder . '/' . $package;
$packageFolderExists = file_exists($packageFolder);
return $packageFolderExists;
} | php | public function packageExists($namespace, $package)
{
$folder = $this->vendorFolder . $namespace;
$folderExists = file_exists($folder);
if (!$folderExists) {
return false;
}
$packageFolder = $folder . '/' . $package;
$packageFolderExists = file_exists($packageFolder);
return $packageFolderExists;
} | [
"public",
"function",
"packageExists",
"(",
"$",
"namespace",
",",
"$",
"package",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"vendorFolder",
".",
"$",
"namespace",
";",
"$",
"folderExists",
"=",
"file_exists",
"(",
"$",
"folder",
")",
";",
"if",
"(",
"!",
"$",
"folderExists",
")",
"{",
"return",
"false",
";",
"}",
"$",
"packageFolder",
"=",
"$",
"folder",
".",
"'/'",
".",
"$",
"package",
";",
"$",
"packageFolderExists",
"=",
"file_exists",
"(",
"$",
"packageFolder",
")",
";",
"return",
"$",
"packageFolderExists",
";",
"}"
]
| Determine if a composer package exists.
@param string $namespace Package namespace.
@param string $package Package name.
@return bool | [
"Determine",
"if",
"a",
"composer",
"package",
"exists",
"."
]
| fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221 | https://github.com/taskforcedev/laravel-support/blob/fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221/src/Helpers/Composer.php#L21-L34 |
13,427 | Runscope/guzzle-runscope | src/Runscope/Plugin/RunscopePlugin.php | RunscopePlugin.onBeforeSend | public function onBeforeSend(Event $event)
{
/** @var \Guzzle\Http\Message\Request $request */
$request = $event['request'];
list($newUrl, $port) = $this->proxify(
$request->getUrl(),
$this->bucketKey,
$this->gatewayHost
);
$request->setUrl($newUrl);
if ($port) {
$request->setHeader('Runscope-Request-Port', $port);
}
if ($this->authToken) {
$request->setHeader('Runscope-Bucket-Auth', $this->authToken);
}
} | php | public function onBeforeSend(Event $event)
{
/** @var \Guzzle\Http\Message\Request $request */
$request = $event['request'];
list($newUrl, $port) = $this->proxify(
$request->getUrl(),
$this->bucketKey,
$this->gatewayHost
);
$request->setUrl($newUrl);
if ($port) {
$request->setHeader('Runscope-Request-Port', $port);
}
if ($this->authToken) {
$request->setHeader('Runscope-Bucket-Auth', $this->authToken);
}
} | [
"public",
"function",
"onBeforeSend",
"(",
"Event",
"$",
"event",
")",
"{",
"/** @var \\Guzzle\\Http\\Message\\Request $request */",
"$",
"request",
"=",
"$",
"event",
"[",
"'request'",
"]",
";",
"list",
"(",
"$",
"newUrl",
",",
"$",
"port",
")",
"=",
"$",
"this",
"->",
"proxify",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
",",
"$",
"this",
"->",
"bucketKey",
",",
"$",
"this",
"->",
"gatewayHost",
")",
";",
"$",
"request",
"->",
"setUrl",
"(",
"$",
"newUrl",
")",
";",
"if",
"(",
"$",
"port",
")",
"{",
"$",
"request",
"->",
"setHeader",
"(",
"'Runscope-Request-Port'",
",",
"$",
"port",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"authToken",
")",
"{",
"$",
"request",
"->",
"setHeader",
"(",
"'Runscope-Bucket-Auth'",
",",
"$",
"this",
"->",
"authToken",
")",
";",
"}",
"}"
]
| Event triggered right before sending a request
@param Event $event | [
"Event",
"triggered",
"right",
"before",
"sending",
"a",
"request"
]
| e369cb90e0dabfc835d32a1e0614e0e2954d510b | https://github.com/Runscope/guzzle-runscope/blob/e369cb90e0dabfc835d32a1e0614e0e2954d510b/src/Runscope/Plugin/RunscopePlugin.php#L41-L61 |
13,428 | LightboxDigital/wp-dynamic-image-resizer | includes/class-dynamic-image-resizer-loader.php | Dynamic_Image_Resizer_Loader.add_action | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
} | php | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
} | [
"public",
"function",
"add_action",
"(",
"$",
"hook",
",",
"$",
"component",
",",
"$",
"callback",
",",
"$",
"priority",
"=",
"10",
",",
"$",
"accepted_args",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"actions",
"=",
"$",
"this",
"->",
"add",
"(",
"$",
"this",
"->",
"actions",
",",
"$",
"hook",
",",
"$",
"component",
",",
"$",
"callback",
",",
"$",
"priority",
",",
"$",
"accepted_args",
")",
";",
"}"
]
| Add a new action to the collection to be registered with WordPress.
@since 1.0.0
@param string $hook The name of the WordPress action that is being registered.
@param object $component A reference to the instance of the object on which the action is defined.
@param string $callback The name of the function definition on the $component.
@param int $priority Optional. he priority at which the function should be fired. Default is 10.
@param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. | [
"Add",
"a",
"new",
"action",
"to",
"the",
"collection",
"to",
"be",
"registered",
"with",
"WordPress",
"."
]
| cc1d67192c8463eba4c0920130abec933ed2296b | https://github.com/LightboxDigital/wp-dynamic-image-resizer/blob/cc1d67192c8463eba4c0920130abec933ed2296b/includes/class-dynamic-image-resizer-loader.php#L66-L68 |
13,429 | LightboxDigital/wp-dynamic-image-resizer | includes/class-dynamic-image-resizer-loader.php | Dynamic_Image_Resizer_Loader.add_filter | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
} | php | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
} | [
"public",
"function",
"add_filter",
"(",
"$",
"hook",
",",
"$",
"component",
",",
"$",
"callback",
",",
"$",
"priority",
"=",
"10",
",",
"$",
"accepted_args",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"$",
"this",
"->",
"add",
"(",
"$",
"this",
"->",
"filters",
",",
"$",
"hook",
",",
"$",
"component",
",",
"$",
"callback",
",",
"$",
"priority",
",",
"$",
"accepted_args",
")",
";",
"}"
]
| Add a new filter to the collection to be registered with WordPress.
@since 1.0.0
@param string $hook The name of the WordPress filter that is being registered.
@param object $component A reference to the instance of the object on which the filter is defined.
@param string $callback The name of the function definition on the $component.
@param int $priority Optional. he priority at which the function should be fired. Default is 10.
@param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. | [
"Add",
"a",
"new",
"filter",
"to",
"the",
"collection",
"to",
"be",
"registered",
"with",
"WordPress",
"."
]
| cc1d67192c8463eba4c0920130abec933ed2296b | https://github.com/LightboxDigital/wp-dynamic-image-resizer/blob/cc1d67192c8463eba4c0920130abec933ed2296b/includes/class-dynamic-image-resizer-loader.php#L81-L83 |
13,430 | LightboxDigital/wp-dynamic-image-resizer | includes/class-dynamic-image-resizer-loader.php | Dynamic_Image_Resizer_Loader.run | public function run() {
foreach ( $this->filters as $hook ) {
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
foreach ( $this->actions as $hook ) {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
} | php | public function run() {
foreach ( $this->filters as $hook ) {
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
foreach ( $this->actions as $hook ) {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"hook",
")",
"{",
"add_filter",
"(",
"$",
"hook",
"[",
"'hook'",
"]",
",",
"array",
"(",
"$",
"hook",
"[",
"'component'",
"]",
",",
"$",
"hook",
"[",
"'callback'",
"]",
")",
",",
"$",
"hook",
"[",
"'priority'",
"]",
",",
"$",
"hook",
"[",
"'accepted_args'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"actions",
"as",
"$",
"hook",
")",
"{",
"add_action",
"(",
"$",
"hook",
"[",
"'hook'",
"]",
",",
"array",
"(",
"$",
"hook",
"[",
"'component'",
"]",
",",
"$",
"hook",
"[",
"'callback'",
"]",
")",
",",
"$",
"hook",
"[",
"'priority'",
"]",
",",
"$",
"hook",
"[",
"'accepted_args'",
"]",
")",
";",
"}",
"}"
]
| Register the filters and actions with WordPress.
@since 1.0.0 | [
"Register",
"the",
"filters",
"and",
"actions",
"with",
"WordPress",
"."
]
| cc1d67192c8463eba4c0920130abec933ed2296b | https://github.com/LightboxDigital/wp-dynamic-image-resizer/blob/cc1d67192c8463eba4c0920130abec933ed2296b/includes/class-dynamic-image-resizer-loader.php#L119-L129 |
13,431 | sifophp/sifo-common-instance | models/i18n/translator.php | I18nTranslatorModel.getTranslations | public function getTranslations( $language, $instance, $parent_instance = false )
{
$sql = <<<TRANSLATIONS
SELECT
id,
message,
comment,
SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as destination_instance,
SUBSTRING_INDEX(GROUP_CONCAT(language ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as language,
SUBSTRING_INDEX(GROUP_CONCAT(translation ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as translation,
SUBSTRING_INDEX(GROUP_CONCAT(author ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as author,
SUBSTRING_INDEX(GROUP_CONCAT(modified ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as modified,
SUBSTRING_INDEX(GROUP_CONCAT(is_base_lang ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as is_base_lang
FROM
(
SELECT
m.id,
m.message,
m.comment,
m.instance AS message_instance,
t.instance AS translation_instance,
i.instance AS destination_instance,
ip.instance AS instance_parent,
(
SELECT
COUNT(ip_x.instance) as depth
FROM
i18n_instances i_x
JOIN i18n_instances ip_x ON i_x.lft BETWEEN ip_x.lft AND ip_x.rgt
WHERE
i_x.instance = t.instance
GROUP BY
i_x.instance
) as instance_depth,
t.lang as origin_language,
l.lang as language,
(
SELECT
COUNT(lp_x.lang) as depth
FROM
i18n_languages l_x
JOIN i18n_languages lp_x ON l_x.lft BETWEEN lp_x.lft AND lp_x.rgt
WHERE
l_x.lang = lp.lang
GROUP BY
l_x.lang
) as language_depth,
t.translation AS translation,
t.author AS author,
t.modified AS modified,
IF(t.lang = l.lang, 1, 0) as is_base_lang
FROM
i18n_messages m
LEFT JOIN i18n_languages l ON l.lang = ?
LEFT JOIN i18n_languages lp ON l.lft BETWEEN lp.lft AND lp.rgt
LEFT JOIN i18n_translations t ON m.id = t.id_message AND t.lang = lp.lang
LEFT JOIN i18n_instances i ON i.instance = ?
LEFT JOIN i18n_instances ip ON i.lft BETWEEN ip.lft AND ip.rgt
WHERE
t.instance = ip.instance
ORDER BY
IF(t.id_message IS NULL,0,1), LOWER(CONVERT(m.message USING utf8)), m.id, t.lang = l.lang DESC
) tbl
GROUP BY id;
TRANSLATIONS;
return $this->GetArray( $sql, array(
$language,
$instance,
'tag' => 'Get all translations for current language'
) );
} | php | public function getTranslations( $language, $instance, $parent_instance = false )
{
$sql = <<<TRANSLATIONS
SELECT
id,
message,
comment,
SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as destination_instance,
SUBSTRING_INDEX(GROUP_CONCAT(language ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as language,
SUBSTRING_INDEX(GROUP_CONCAT(translation ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as translation,
SUBSTRING_INDEX(GROUP_CONCAT(author ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as author,
SUBSTRING_INDEX(GROUP_CONCAT(modified ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as modified,
SUBSTRING_INDEX(GROUP_CONCAT(is_base_lang ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as is_base_lang
FROM
(
SELECT
m.id,
m.message,
m.comment,
m.instance AS message_instance,
t.instance AS translation_instance,
i.instance AS destination_instance,
ip.instance AS instance_parent,
(
SELECT
COUNT(ip_x.instance) as depth
FROM
i18n_instances i_x
JOIN i18n_instances ip_x ON i_x.lft BETWEEN ip_x.lft AND ip_x.rgt
WHERE
i_x.instance = t.instance
GROUP BY
i_x.instance
) as instance_depth,
t.lang as origin_language,
l.lang as language,
(
SELECT
COUNT(lp_x.lang) as depth
FROM
i18n_languages l_x
JOIN i18n_languages lp_x ON l_x.lft BETWEEN lp_x.lft AND lp_x.rgt
WHERE
l_x.lang = lp.lang
GROUP BY
l_x.lang
) as language_depth,
t.translation AS translation,
t.author AS author,
t.modified AS modified,
IF(t.lang = l.lang, 1, 0) as is_base_lang
FROM
i18n_messages m
LEFT JOIN i18n_languages l ON l.lang = ?
LEFT JOIN i18n_languages lp ON l.lft BETWEEN lp.lft AND lp.rgt
LEFT JOIN i18n_translations t ON m.id = t.id_message AND t.lang = lp.lang
LEFT JOIN i18n_instances i ON i.instance = ?
LEFT JOIN i18n_instances ip ON i.lft BETWEEN ip.lft AND ip.rgt
WHERE
t.instance = ip.instance
ORDER BY
IF(t.id_message IS NULL,0,1), LOWER(CONVERT(m.message USING utf8)), m.id, t.lang = l.lang DESC
) tbl
GROUP BY id;
TRANSLATIONS;
return $this->GetArray( $sql, array(
$language,
$instance,
'tag' => 'Get all translations for current language'
) );
} | [
"public",
"function",
"getTranslations",
"(",
"$",
"language",
",",
"$",
"instance",
",",
"$",
"parent_instance",
"=",
"false",
")",
"{",
"$",
"sql",
"=",
" <<<TRANSLATIONS\n SELECT\n id,\n message,\n comment,\n SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as destination_instance,\n SUBSTRING_INDEX(GROUP_CONCAT(language ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as language,\n SUBSTRING_INDEX(GROUP_CONCAT(translation ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as translation,\n SUBSTRING_INDEX(GROUP_CONCAT(author ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as author,\n SUBSTRING_INDEX(GROUP_CONCAT(modified ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as modified,\n SUBSTRING_INDEX(GROUP_CONCAT(is_base_lang ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as is_base_lang\n FROM\n (\n SELECT\n m.id,\n m.message,\n m.comment,\n m.instance AS message_instance,\n t.instance AS translation_instance,\n i.instance AS destination_instance,\n ip.instance AS instance_parent,\n (\n SELECT\n COUNT(ip_x.instance) as depth\n FROM\n i18n_instances i_x\n JOIN i18n_instances ip_x ON i_x.lft BETWEEN ip_x.lft AND ip_x.rgt\n WHERE\n i_x.instance = t.instance\n GROUP BY\n i_x.instance\n ) as instance_depth,\t\n t.lang as origin_language,\n l.lang as language,\n (\n SELECT\n COUNT(lp_x.lang) as depth\n FROM\n i18n_languages l_x\n JOIN i18n_languages lp_x ON l_x.lft BETWEEN lp_x.lft AND lp_x.rgt\n WHERE\n l_x.lang = lp.lang\n GROUP BY\n l_x.lang\n ) as language_depth,\t\n t.translation AS translation,\n t.author AS author,\n t.modified AS modified,\n IF(t.lang = l.lang, 1, 0) as is_base_lang\n \n FROM\n i18n_messages m\n LEFT JOIN i18n_languages l ON l.lang = ?\n LEFT JOIN i18n_languages lp ON l.lft BETWEEN lp.lft AND lp.rgt\t\n LEFT JOIN i18n_translations t ON m.id = t.id_message AND t.lang = lp.lang\n LEFT JOIN i18n_instances i ON i.instance = ?\n LEFT JOIN i18n_instances ip ON i.lft BETWEEN ip.lft AND ip.rgt\n WHERE\n t.instance = ip.instance\n ORDER BY\n IF(t.id_message IS NULL,0,1), LOWER(CONVERT(m.message USING utf8)), m.id, t.lang = l.lang DESC\n ) tbl\n GROUP BY id;\nTRANSLATIONS",
";",
"return",
"$",
"this",
"->",
"GetArray",
"(",
"$",
"sql",
",",
"array",
"(",
"$",
"language",
",",
"$",
"instance",
",",
"'tag'",
"=>",
"'Get all translations for current language'",
")",
")",
";",
"}"
]
| Returns the translations list for a given langauge.
@param string $language
@return array | [
"Returns",
"the",
"translations",
"list",
"for",
"a",
"given",
"langauge",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/models/i18n/translator.php#L16-L88 |
13,432 | sifophp/sifo-common-instance | models/i18n/translator.php | I18nTranslatorModel.getStats | public function getStats( $instance, $parent_instance )
{
$parent_instance_sql = '';
$parent_instance_sub_sql = 'm.instance = ? OR t.instance = ?';
if ( $parent_instance )
{
$parent_instance_sql = ' OR instance IS NULL ';
$parent_instance_sub_sql = '( m.instance = ? OR m.instance IS NULL ) AND ( t.instance = ? OR t.instance IS NULL )';
}
$sql = <<<TRANSLATIONS
SELECT
l.english_name,
l.lang,
lc.local_name AS name,
@lang := l.lang AS lang,
@translated := (SELECT COUNT(*) FROM i18n_translations WHERE ( instance = ? $parent_instance_sql ) AND lang = @lang AND translation != '' AND translation IS NOT NULL ) AS total_translated,
@total := (SELECT COUNT(DISTINCT(m.id)) FROM i18n_messages m LEFT JOIN i18n_translations t ON m.id=t.id_message AND t.lang = @lang WHERE $parent_instance_sub_sql ) AS total,
ROUND( ( @translated / @total) * 100, 2 ) AS percent,
( @total - @translated ) AS missing
FROM
i18n_languages l
LEFT JOIN i18n_language_codes lc ON l.lang = lc.l10n
ORDER BY
percent DESC, english_name ASC
TRANSLATIONS;
return $this->GetArray( $sql, array(
'tag' => 'Get current stats',
$instance,
$instance,
$instance,
$instance,
$instance
) );
} | php | public function getStats( $instance, $parent_instance )
{
$parent_instance_sql = '';
$parent_instance_sub_sql = 'm.instance = ? OR t.instance = ?';
if ( $parent_instance )
{
$parent_instance_sql = ' OR instance IS NULL ';
$parent_instance_sub_sql = '( m.instance = ? OR m.instance IS NULL ) AND ( t.instance = ? OR t.instance IS NULL )';
}
$sql = <<<TRANSLATIONS
SELECT
l.english_name,
l.lang,
lc.local_name AS name,
@lang := l.lang AS lang,
@translated := (SELECT COUNT(*) FROM i18n_translations WHERE ( instance = ? $parent_instance_sql ) AND lang = @lang AND translation != '' AND translation IS NOT NULL ) AS total_translated,
@total := (SELECT COUNT(DISTINCT(m.id)) FROM i18n_messages m LEFT JOIN i18n_translations t ON m.id=t.id_message AND t.lang = @lang WHERE $parent_instance_sub_sql ) AS total,
ROUND( ( @translated / @total) * 100, 2 ) AS percent,
( @total - @translated ) AS missing
FROM
i18n_languages l
LEFT JOIN i18n_language_codes lc ON l.lang = lc.l10n
ORDER BY
percent DESC, english_name ASC
TRANSLATIONS;
return $this->GetArray( $sql, array(
'tag' => 'Get current stats',
$instance,
$instance,
$instance,
$instance,
$instance
) );
} | [
"public",
"function",
"getStats",
"(",
"$",
"instance",
",",
"$",
"parent_instance",
")",
"{",
"$",
"parent_instance_sql",
"=",
"''",
";",
"$",
"parent_instance_sub_sql",
"=",
"'m.instance = ? OR t.instance = ?'",
";",
"if",
"(",
"$",
"parent_instance",
")",
"{",
"$",
"parent_instance_sql",
"=",
"' OR instance IS NULL '",
";",
"$",
"parent_instance_sub_sql",
"=",
"'( m.instance = ? OR m.instance IS NULL ) AND ( t.instance = ? OR t.instance IS NULL )'",
";",
"}",
"$",
"sql",
"=",
" <<<TRANSLATIONS\nSELECT\n\tl.english_name,\n\tl.lang,\n\tlc.local_name AS name,\n\t@lang \t\t\t:= l.lang AS lang,\n\t@translated \t:= (SELECT COUNT(*) FROM i18n_translations WHERE ( instance = ? $parent_instance_sql ) AND lang = @lang AND translation != '' AND translation IS NOT NULL ) AS total_translated,\n\t@total \t\t\t:= (SELECT COUNT(DISTINCT(m.id)) FROM i18n_messages m LEFT JOIN i18n_translations t ON m.id=t.id_message AND t.lang = @lang WHERE $parent_instance_sub_sql ) AS total,\n\tROUND( ( @translated / @total) * 100, 2 ) AS percent,\n\t( @total - @translated ) AS missing\nFROM\n\ti18n_languages l\n\tLEFT JOIN i18n_language_codes lc ON l.lang = lc.l10n\nORDER BY\n\tpercent DESC, english_name ASC\nTRANSLATIONS",
";",
"return",
"$",
"this",
"->",
"GetArray",
"(",
"$",
"sql",
",",
"array",
"(",
"'tag'",
"=>",
"'Get current stats'",
",",
"$",
"instance",
",",
"$",
"instance",
",",
"$",
"instance",
",",
"$",
"instance",
",",
"$",
"instance",
")",
")",
";",
"}"
]
| Get stats of translations.
@return array | [
"Get",
"stats",
"of",
"translations",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/models/i18n/translator.php#L115-L150 |
13,433 | sifophp/sifo-common-instance | models/i18n/translator.php | I18nTranslatorModel.addMessage | public function addMessage( $message, $instance = null )
{
$sql = <<<SQL
INSERT INTO
i18n_messages
SET
message = ?,
instance = ?
SQL;
return $this->Execute( $sql, array(
'tag' => 'Add message',
$message,
$instance
) );
} | php | public function addMessage( $message, $instance = null )
{
$sql = <<<SQL
INSERT INTO
i18n_messages
SET
message = ?,
instance = ?
SQL;
return $this->Execute( $sql, array(
'tag' => 'Add message',
$message,
$instance
) );
} | [
"public",
"function",
"addMessage",
"(",
"$",
"message",
",",
"$",
"instance",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
" <<<SQL\nINSERT INTO\n\ti18n_messages\nSET\n\tmessage \t= ?,\n\tinstance\t= ?\nSQL",
";",
"return",
"$",
"this",
"->",
"Execute",
"(",
"$",
"sql",
",",
"array",
"(",
"'tag'",
"=>",
"'Add message'",
",",
"$",
"message",
",",
"$",
"instance",
")",
")",
";",
"}"
]
| Add message in database.
@param $message
@return mixed | [
"Add",
"message",
"in",
"database",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/models/i18n/translator.php#L157-L172 |
13,434 | venta/framework | src/Routing/src/Exception/MethodNotAllowedException.php | MethodNotAllowedException.buildMessage | protected function buildMessage(array $allowedMethods): string
{
$ending = 'Allowed method is: %s';
if (count($allowedMethods) > 1) {
$ending = 'Allowed methods are: %s';
}
return sprintf('Method is not allowed. ' . $ending, implode(', ', $allowedMethods));
} | php | protected function buildMessage(array $allowedMethods): string
{
$ending = 'Allowed method is: %s';
if (count($allowedMethods) > 1) {
$ending = 'Allowed methods are: %s';
}
return sprintf('Method is not allowed. ' . $ending, implode(', ', $allowedMethods));
} | [
"protected",
"function",
"buildMessage",
"(",
"array",
"$",
"allowedMethods",
")",
":",
"string",
"{",
"$",
"ending",
"=",
"'Allowed method is: %s'",
";",
"if",
"(",
"count",
"(",
"$",
"allowedMethods",
")",
">",
"1",
")",
"{",
"$",
"ending",
"=",
"'Allowed methods are: %s'",
";",
"}",
"return",
"sprintf",
"(",
"'Method is not allowed. '",
".",
"$",
"ending",
",",
"implode",
"(",
"', '",
",",
"$",
"allowedMethods",
")",
")",
";",
"}"
]
| Builds error message
@param array $allowedMethods
@return string | [
"Builds",
"error",
"message"
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Routing/src/Exception/MethodNotAllowedException.php#L30-L39 |
13,435 | crysalead/net | src/Http/Request.php | Request.accepts | public function accepts()
{
$accepts = $this->hasHeader('Accept') ? $this->getHeader('Accept') : ['text/html'];
foreach ($accepts as $i => $value) {
list($mime, $q) = preg_split('/;\s*q\s*=\s*/', $value, 2) + [$value, 1.0];
$stars = substr_count($mime, '*');
$score = $stars ? (0.03 - $stars * 0.01) : $q;
$score = $score * 100000 + strlen($mime); //RFC 4288 assumes a max length of 127/127 = 255 chars for mime.
$preferences[$score][strtolower(trim($mime))] = (float) $q;
}
krsort($preferences);
$preferences = call_user_func_array('array_merge', $preferences);
return $preferences;
} | php | public function accepts()
{
$accepts = $this->hasHeader('Accept') ? $this->getHeader('Accept') : ['text/html'];
foreach ($accepts as $i => $value) {
list($mime, $q) = preg_split('/;\s*q\s*=\s*/', $value, 2) + [$value, 1.0];
$stars = substr_count($mime, '*');
$score = $stars ? (0.03 - $stars * 0.01) : $q;
$score = $score * 100000 + strlen($mime); //RFC 4288 assumes a max length of 127/127 = 255 chars for mime.
$preferences[$score][strtolower(trim($mime))] = (float) $q;
}
krsort($preferences);
$preferences = call_user_func_array('array_merge', $preferences);
return $preferences;
} | [
"public",
"function",
"accepts",
"(",
")",
"{",
"$",
"accepts",
"=",
"$",
"this",
"->",
"hasHeader",
"(",
"'Accept'",
")",
"?",
"$",
"this",
"->",
"getHeader",
"(",
"'Accept'",
")",
":",
"[",
"'text/html'",
"]",
";",
"foreach",
"(",
"$",
"accepts",
"as",
"$",
"i",
"=>",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"mime",
",",
"$",
"q",
")",
"=",
"preg_split",
"(",
"'/;\\s*q\\s*=\\s*/'",
",",
"$",
"value",
",",
"2",
")",
"+",
"[",
"$",
"value",
",",
"1.0",
"]",
";",
"$",
"stars",
"=",
"substr_count",
"(",
"$",
"mime",
",",
"'*'",
")",
";",
"$",
"score",
"=",
"$",
"stars",
"?",
"(",
"0.03",
"-",
"$",
"stars",
"*",
"0.01",
")",
":",
"$",
"q",
";",
"$",
"score",
"=",
"$",
"score",
"*",
"100000",
"+",
"strlen",
"(",
"$",
"mime",
")",
";",
"//RFC 4288 assumes a max length of 127/127 = 255 chars for mime.",
"$",
"preferences",
"[",
"$",
"score",
"]",
"[",
"strtolower",
"(",
"trim",
"(",
"$",
"mime",
")",
")",
"]",
"=",
"(",
"float",
")",
"$",
"q",
";",
"}",
"krsort",
"(",
"$",
"preferences",
")",
";",
"$",
"preferences",
"=",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"preferences",
")",
";",
"return",
"$",
"preferences",
";",
"}"
]
| Return information about the mime of content that the client is requesting.
@param boolean $all If `true` lists all accepted content mimes
@return mixed Returns the negotiated mime or the accepted content mimes sorted by
client preference if `$all` is set to `true`. | [
"Return",
"information",
"about",
"the",
"mime",
"of",
"content",
"that",
"the",
"client",
"is",
"requesting",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L197-L211 |
13,436 | crysalead/net | src/Http/Request.php | Request.url | public function url()
{
$scheme = $this->scheme();
$scheme = $scheme ? $scheme . '://' : '//';
$query = $this->query() ? '?' . http_build_query($this->query()) : '';
$fragment = $this->fragment() ? '#' . $this->fragment() : '';
return $scheme . $this->host() . $this->path() . $query . $fragment;
} | php | public function url()
{
$scheme = $this->scheme();
$scheme = $scheme ? $scheme . '://' : '//';
$query = $this->query() ? '?' . http_build_query($this->query()) : '';
$fragment = $this->fragment() ? '#' . $this->fragment() : '';
return $scheme . $this->host() . $this->path() . $query . $fragment;
} | [
"public",
"function",
"url",
"(",
")",
"{",
"$",
"scheme",
"=",
"$",
"this",
"->",
"scheme",
"(",
")",
";",
"$",
"scheme",
"=",
"$",
"scheme",
"?",
"$",
"scheme",
".",
"'://'",
":",
"'//'",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"query",
"(",
")",
"?",
"'?'",
".",
"http_build_query",
"(",
"$",
"this",
"->",
"query",
"(",
")",
")",
":",
"''",
";",
"$",
"fragment",
"=",
"$",
"this",
"->",
"fragment",
"(",
")",
"?",
"'#'",
".",
"$",
"this",
"->",
"fragment",
"(",
")",
":",
"''",
";",
"return",
"$",
"scheme",
".",
"$",
"this",
"->",
"host",
"(",
")",
".",
"$",
"this",
"->",
"path",
"(",
")",
".",
"$",
"query",
".",
"$",
"fragment",
";",
"}"
]
| Returns the message URI.
@return string | [
"Returns",
"the",
"message",
"URI",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L341-L348 |
13,437 | crysalead/net | src/Http/Request.php | Request.credential | public function credential()
{
if (!$username = $this->username()) {
return '';
}
$credentials = $username;
if ($password = $this->password()) {
$credentials .= ':' . $password;
}
return $credentials;
} | php | public function credential()
{
if (!$username = $this->username()) {
return '';
}
$credentials = $username;
if ($password = $this->password()) {
$credentials .= ':' . $password;
}
return $credentials;
} | [
"public",
"function",
"credential",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"username",
"=",
"$",
"this",
"->",
"username",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"credentials",
"=",
"$",
"username",
";",
"if",
"(",
"$",
"password",
"=",
"$",
"this",
"->",
"password",
"(",
")",
")",
"{",
"$",
"credentials",
".=",
"':'",
".",
"$",
"password",
";",
"}",
"return",
"$",
"credentials",
";",
"}"
]
| Returns the credential.
@return string|null The credential string. | [
"Returns",
"the",
"credential",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L355-L365 |
13,438 | crysalead/net | src/Http/Request.php | Request.requestTarget | public function requestTarget()
{
if ($this->method() === 'CONNECT' || $this->mode() === 'authority') {
$credential = $this->credential();
return ($credential ? $credential. '@' : '') . $this->host();
}
if ($this->mode() === 'absolute') {
return $this->url();
}
if ($this->mode() === 'asterisk') {
return '*';
}
$query = $this->query() ? '?' . http_build_query($this->query()) : '';
$fragment = $this->fragment();
return $this->path() . $query . ($fragment ? '#' . $fragment : '');
} | php | public function requestTarget()
{
if ($this->method() === 'CONNECT' || $this->mode() === 'authority') {
$credential = $this->credential();
return ($credential ? $credential. '@' : '') . $this->host();
}
if ($this->mode() === 'absolute') {
return $this->url();
}
if ($this->mode() === 'asterisk') {
return '*';
}
$query = $this->query() ? '?' . http_build_query($this->query()) : '';
$fragment = $this->fragment();
return $this->path() . $query . ($fragment ? '#' . $fragment : '');
} | [
"public",
"function",
"requestTarget",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"method",
"(",
")",
"===",
"'CONNECT'",
"||",
"$",
"this",
"->",
"mode",
"(",
")",
"===",
"'authority'",
")",
"{",
"$",
"credential",
"=",
"$",
"this",
"->",
"credential",
"(",
")",
";",
"return",
"(",
"$",
"credential",
"?",
"$",
"credential",
".",
"'@'",
":",
"''",
")",
".",
"$",
"this",
"->",
"host",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mode",
"(",
")",
"===",
"'absolute'",
")",
"{",
"return",
"$",
"this",
"->",
"url",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mode",
"(",
")",
"===",
"'asterisk'",
")",
"{",
"return",
"'*'",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"query",
"(",
")",
"?",
"'?'",
".",
"http_build_query",
"(",
"$",
"this",
"->",
"query",
"(",
")",
")",
":",
"''",
";",
"$",
"fragment",
"=",
"$",
"this",
"->",
"fragment",
"(",
")",
";",
"return",
"$",
"this",
"->",
"path",
"(",
")",
".",
"$",
"query",
".",
"(",
"$",
"fragment",
"?",
"'#'",
".",
"$",
"fragment",
":",
"''",
")",
";",
"}"
]
| Returns the request target present in the status line.
@return string | [
"Returns",
"the",
"request",
"target",
"present",
"in",
"the",
"status",
"line",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L400-L415 |
13,439 | crysalead/net | src/Http/Request.php | Request.auth | public function auth($auth = true)
{
$headers = $this->headers();
if ($auth === false) {
unset($headers['Authorization']);
}
if (!$auth) {
return;
}
if (is_array($auth) && !empty($auth['nonce'])) {
$data = ['method' => $this->method(), 'uri' => $this->path()];
$data += $auth;
} else {
$data = [];
}
$auth = $this->_classes['auth'];
$data = $auth::encode($this->username(), $this->password(), $data);
$headers['Authorization'] = $auth::header($data);
return $this;
} | php | public function auth($auth = true)
{
$headers = $this->headers();
if ($auth === false) {
unset($headers['Authorization']);
}
if (!$auth) {
return;
}
if (is_array($auth) && !empty($auth['nonce'])) {
$data = ['method' => $this->method(), 'uri' => $this->path()];
$data += $auth;
} else {
$data = [];
}
$auth = $this->_classes['auth'];
$data = $auth::encode($this->username(), $this->password(), $data);
$headers['Authorization'] = $auth::header($data);
return $this;
} | [
"public",
"function",
"auth",
"(",
"$",
"auth",
"=",
"true",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"headers",
"(",
")",
";",
"if",
"(",
"$",
"auth",
"===",
"false",
")",
"{",
"unset",
"(",
"$",
"headers",
"[",
"'Authorization'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"auth",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"auth",
")",
"&&",
"!",
"empty",
"(",
"$",
"auth",
"[",
"'nonce'",
"]",
")",
")",
"{",
"$",
"data",
"=",
"[",
"'method'",
"=>",
"$",
"this",
"->",
"method",
"(",
")",
",",
"'uri'",
"=>",
"$",
"this",
"->",
"path",
"(",
")",
"]",
";",
"$",
"data",
"+=",
"$",
"auth",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"$",
"auth",
"=",
"$",
"this",
"->",
"_classes",
"[",
"'auth'",
"]",
";",
"$",
"data",
"=",
"$",
"auth",
"::",
"encode",
"(",
"$",
"this",
"->",
"username",
"(",
")",
",",
"$",
"this",
"->",
"password",
"(",
")",
",",
"$",
"data",
")",
";",
"$",
"headers",
"[",
"'Authorization'",
"]",
"=",
"$",
"auth",
"::",
"header",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the request authorization.
@param mixed $auth Any array with a 'nonce' attribute implies Digest authentication.
Defaults to Basic authentication otherwise.
If `false` the Authorization header will be removed.
@return mixed | [
"Sets",
"the",
"request",
"authorization",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L425-L444 |
13,440 | crysalead/net | src/Http/Request.php | Request.applyCookies | public function applyCookies($cookies)
{
$values = [];
foreach ($cookies as $cookie) {
if ($cookie->matches($this->url())) {
$values[$cookie->path()] = $cookie->name() . '=' . $cookie->value();
}
}
$keys = array_map('strlen', array_keys($values));
array_multisort($keys, SORT_DESC, $values);
$headers = $this->headers();
if ($values) {
$headers['Cookie'] = implode('; ', $values);
} else {
unset($headers['Cookie']);
}
return $this;
} | php | public function applyCookies($cookies)
{
$values = [];
foreach ($cookies as $cookie) {
if ($cookie->matches($this->url())) {
$values[$cookie->path()] = $cookie->name() . '=' . $cookie->value();
}
}
$keys = array_map('strlen', array_keys($values));
array_multisort($keys, SORT_DESC, $values);
$headers = $this->headers();
if ($values) {
$headers['Cookie'] = implode('; ', $values);
} else {
unset($headers['Cookie']);
}
return $this;
} | [
"public",
"function",
"applyCookies",
"(",
"$",
"cookies",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"cookie",
")",
"{",
"if",
"(",
"$",
"cookie",
"->",
"matches",
"(",
"$",
"this",
"->",
"url",
"(",
")",
")",
")",
"{",
"$",
"values",
"[",
"$",
"cookie",
"->",
"path",
"(",
")",
"]",
"=",
"$",
"cookie",
"->",
"name",
"(",
")",
".",
"'='",
".",
"$",
"cookie",
"->",
"value",
"(",
")",
";",
"}",
"}",
"$",
"keys",
"=",
"array_map",
"(",
"'strlen'",
",",
"array_keys",
"(",
"$",
"values",
")",
")",
";",
"array_multisort",
"(",
"$",
"keys",
",",
"SORT_DESC",
",",
"$",
"values",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"headers",
"(",
")",
";",
"if",
"(",
"$",
"values",
")",
"{",
"$",
"headers",
"[",
"'Cookie'",
"]",
"=",
"implode",
"(",
"'; '",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"headers",
"[",
"'Cookie'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the Cookie header
@param array $cookies The cookies.
@return self | [
"Set",
"the",
"Cookie",
"header"
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L498-L516 |
13,441 | crysalead/net | src/Http/Request.php | Request.cookieValues | public function cookieValues()
{
$headers = $request->headers();
return isset($headers['Cookie']) ? CookieValues::toArray($headers['Cookie']->value()) : [];
} | php | public function cookieValues()
{
$headers = $request->headers();
return isset($headers['Cookie']) ? CookieValues::toArray($headers['Cookie']->value()) : [];
} | [
"public",
"function",
"cookieValues",
"(",
")",
"{",
"$",
"headers",
"=",
"$",
"request",
"->",
"headers",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"headers",
"[",
"'Cookie'",
"]",
")",
"?",
"CookieValues",
"::",
"toArray",
"(",
"$",
"headers",
"[",
"'Cookie'",
"]",
"->",
"value",
"(",
")",
")",
":",
"[",
"]",
";",
"}"
]
| Extract cookies value.
@return array The cookies value. | [
"Extract",
"cookies",
"value",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L523-L527 |
13,442 | crysalead/net | src/Http/Request.php | Request.create | public static function create($method = 'GET', $url = null, $config = [])
{
if (func_num_args()) {
if(!preg_match('~^(?:[a-z]+:)?//~i', $url) || !$defaults = parse_url($url)) {
throw new NetException("Invalid url: `'{$url}'`.");
}
$defaults['username'] = isset($defaults['user']) ? $defaults['user'] : null;
$defaults['password'] = isset($defaults['pass']) ? $defaults['pass'] : null;
}
$config['method'] = strtoupper($method);
return new static($config + $defaults);
} | php | public static function create($method = 'GET', $url = null, $config = [])
{
if (func_num_args()) {
if(!preg_match('~^(?:[a-z]+:)?//~i', $url) || !$defaults = parse_url($url)) {
throw new NetException("Invalid url: `'{$url}'`.");
}
$defaults['username'] = isset($defaults['user']) ? $defaults['user'] : null;
$defaults['password'] = isset($defaults['pass']) ? $defaults['pass'] : null;
}
$config['method'] = strtoupper($method);
return new static($config + $defaults);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"method",
"=",
"'GET'",
",",
"$",
"url",
"=",
"null",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'~^(?:[a-z]+:)?//~i'",
",",
"$",
"url",
")",
"||",
"!",
"$",
"defaults",
"=",
"parse_url",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"NetException",
"(",
"\"Invalid url: `'{$url}'`.\"",
")",
";",
"}",
"$",
"defaults",
"[",
"'username'",
"]",
"=",
"isset",
"(",
"$",
"defaults",
"[",
"'user'",
"]",
")",
"?",
"$",
"defaults",
"[",
"'user'",
"]",
":",
"null",
";",
"$",
"defaults",
"[",
"'password'",
"]",
"=",
"isset",
"(",
"$",
"defaults",
"[",
"'pass'",
"]",
")",
"?",
"$",
"defaults",
"[",
"'pass'",
"]",
":",
"null",
";",
"}",
"$",
"config",
"[",
"'method'",
"]",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"return",
"new",
"static",
"(",
"$",
"config",
"+",
"$",
"defaults",
")",
";",
"}"
]
| Creates a request instance using an absolute URL.
@param string $url An absolute URL.
@param array $config The config array.
@return self | [
"Creates",
"a",
"request",
"instance",
"using",
"an",
"absolute",
"URL",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Request.php#L562-L573 |
13,443 | crysalead/net | src/Mime/Message.php | Message.addTo | public function addTo($address, $name = null)
{
$address = $this->_addRecipient('To', $address, $name);
$this->_recipients[$address->email()] = $address;
return $this;
} | php | public function addTo($address, $name = null)
{
$address = $this->_addRecipient('To', $address, $name);
$this->_recipients[$address->email()] = $address;
return $this;
} | [
"public",
"function",
"addTo",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"address",
"=",
"$",
"this",
"->",
"_addRecipient",
"(",
"'To'",
",",
"$",
"address",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"_recipients",
"[",
"$",
"address",
"->",
"email",
"(",
")",
"]",
"=",
"$",
"address",
";",
"return",
"$",
"this",
";",
"}"
]
| Add an email recipient.
@param string $address The email address.
@param mixed $name The name.
@return self | [
"Add",
"an",
"email",
"recipient",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L316-L321 |
13,444 | crysalead/net | src/Mime/Message.php | Message.addCc | public function addCc($address, $name = null)
{
$address = $this->_addRecipient('Cc', $address, $name);
$this->_recipients[$address->email()] = $address;
return $this;
} | php | public function addCc($address, $name = null)
{
$address = $this->_addRecipient('Cc', $address, $name);
$this->_recipients[$address->email()] = $address;
return $this;
} | [
"public",
"function",
"addCc",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"address",
"=",
"$",
"this",
"->",
"_addRecipient",
"(",
"'Cc'",
",",
"$",
"address",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"_recipients",
"[",
"$",
"address",
"->",
"email",
"(",
")",
"]",
"=",
"$",
"address",
";",
"return",
"$",
"this",
";",
"}"
]
| Adds carbon copy email recipient.
@param string $address The email address.
@param mixed $name The name.
@return self | [
"Adds",
"carbon",
"copy",
"email",
"recipient",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L330-L335 |
13,445 | crysalead/net | src/Mime/Message.php | Message.addBcc | public function addBcc($address, $name = null)
{
$class = $this->_classes['address'];
$bcc = new $class($address, $name);
$this->_recipients[$bcc->email()] = $bcc;
return $this;
} | php | public function addBcc($address, $name = null)
{
$class = $this->_classes['address'];
$bcc = new $class($address, $name);
$this->_recipients[$bcc->email()] = $bcc;
return $this;
} | [
"public",
"function",
"addBcc",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"_classes",
"[",
"'address'",
"]",
";",
"$",
"bcc",
"=",
"new",
"$",
"class",
"(",
"$",
"address",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"_recipients",
"[",
"$",
"bcc",
"->",
"email",
"(",
")",
"]",
"=",
"$",
"bcc",
";",
"return",
"$",
"this",
";",
"}"
]
| Adds blind carbon copy email recipient.
@param string $address The sender email address.
@param mixed $name The sender name.
@return self | [
"Adds",
"blind",
"carbon",
"copy",
"email",
"recipient",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L344-L350 |
13,446 | crysalead/net | src/Mime/Message.php | Message._addRecipient | protected function _addRecipient($type, $address, $name = null)
{
$classes = $this->_classes;
$headers = $this->headers();
if (!isset($headers[$type])) {
$addresses = $classes['addresses'];
$headers[$type] = new $addresses();
}
$class = $classes['address'];
$value = new $class($address, $name);
$headers[$type][] = $value;
return $value;
} | php | protected function _addRecipient($type, $address, $name = null)
{
$classes = $this->_classes;
$headers = $this->headers();
if (!isset($headers[$type])) {
$addresses = $classes['addresses'];
$headers[$type] = new $addresses();
}
$class = $classes['address'];
$value = new $class($address, $name);
$headers[$type][] = $value;
return $value;
} | [
"protected",
"function",
"_addRecipient",
"(",
"$",
"type",
",",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"_classes",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"headers",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"headers",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"addresses",
"=",
"$",
"classes",
"[",
"'addresses'",
"]",
";",
"$",
"headers",
"[",
"$",
"type",
"]",
"=",
"new",
"$",
"addresses",
"(",
")",
";",
"}",
"$",
"class",
"=",
"$",
"classes",
"[",
"'address'",
"]",
";",
"$",
"value",
"=",
"new",
"$",
"class",
"(",
"$",
"address",
",",
"$",
"name",
")",
";",
"$",
"headers",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"value",
";",
"}"
]
| Add a recipient to a specific type section.
@param string $type The type of recipient.
@param string $address The email address.
@param mixed $name The name.
@return objedt The created address. | [
"Add",
"a",
"recipient",
"to",
"a",
"specific",
"type",
"section",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L360-L372 |
13,447 | crysalead/net | src/Mime/Message.php | Message.addInline | public function addInline($path, $name = null, $mime = true, $encoding = true)
{
$cid = static::generateId($this->client());
$filename = basename($path);
$this->_inlines[$path] = [
'filename' => $name ?: $filename,
'disposition' => 'attachment',
'mime' => $mime,
'headers' => ['Content-ID: ' . $cid]
];
return $cid;
} | php | public function addInline($path, $name = null, $mime = true, $encoding = true)
{
$cid = static::generateId($this->client());
$filename = basename($path);
$this->_inlines[$path] = [
'filename' => $name ?: $filename,
'disposition' => 'attachment',
'mime' => $mime,
'headers' => ['Content-ID: ' . $cid]
];
return $cid;
} | [
"public",
"function",
"addInline",
"(",
"$",
"path",
",",
"$",
"name",
"=",
"null",
",",
"$",
"mime",
"=",
"true",
",",
"$",
"encoding",
"=",
"true",
")",
"{",
"$",
"cid",
"=",
"static",
"::",
"generateId",
"(",
"$",
"this",
"->",
"client",
"(",
")",
")",
";",
"$",
"filename",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"_inlines",
"[",
"$",
"path",
"]",
"=",
"[",
"'filename'",
"=>",
"$",
"name",
"?",
":",
"$",
"filename",
",",
"'disposition'",
"=>",
"'attachment'",
",",
"'mime'",
"=>",
"$",
"mime",
",",
"'headers'",
"=>",
"[",
"'Content-ID: '",
".",
"$",
"cid",
"]",
"]",
";",
"return",
"$",
"cid",
";",
"}"
]
| Add an embedded file. | [
"Add",
"an",
"embedded",
"file",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L407-L418 |
13,448 | crysalead/net | src/Mime/Message.php | Message.addAttachment | public function addAttachment($path, $name = null, $mime = true, $encoding = true)
{
$cid = static::generateId($this->client());
$filename = basename($path);
$this->_attachments[$path] = [
'filename' => $name ?: $filename,
'disposition' => 'attachment',
'mime' => $mime,
'headers' => ['Content-ID: ' . $cid]
];
return $cid;
} | php | public function addAttachment($path, $name = null, $mime = true, $encoding = true)
{
$cid = static::generateId($this->client());
$filename = basename($path);
$this->_attachments[$path] = [
'filename' => $name ?: $filename,
'disposition' => 'attachment',
'mime' => $mime,
'headers' => ['Content-ID: ' . $cid]
];
return $cid;
} | [
"public",
"function",
"addAttachment",
"(",
"$",
"path",
",",
"$",
"name",
"=",
"null",
",",
"$",
"mime",
"=",
"true",
",",
"$",
"encoding",
"=",
"true",
")",
"{",
"$",
"cid",
"=",
"static",
"::",
"generateId",
"(",
"$",
"this",
"->",
"client",
"(",
")",
")",
";",
"$",
"filename",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"_attachments",
"[",
"$",
"path",
"]",
"=",
"[",
"'filename'",
"=>",
"$",
"name",
"?",
":",
"$",
"filename",
",",
"'disposition'",
"=>",
"'attachment'",
",",
"'mime'",
"=>",
"$",
"mime",
",",
"'headers'",
"=>",
"[",
"'Content-ID: '",
".",
"$",
"cid",
"]",
"]",
";",
"return",
"$",
"cid",
";",
"}"
]
| Add an attachment. | [
"Add",
"an",
"attachment",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L423-L434 |
13,449 | crysalead/net | src/Mime/Message.php | Message.html | public function html($body, $basePath = null)
{
if (!func_num_args()) {
return $this->_body;
}
if ($basePath) {
$cids = [];
$hasInline = preg_match_all('~
(<img[^<>]*\s src\s*=\s*
|<body[^<>]*\s background\s*=\s*
|<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
|<style[^>]*>[^<]+ [:\s] url\()
(["\']?)(?![a-z]+:|[/#])([^"\'>)\s]+)
|\[\[ ([\w()+./@\\~-]+) \]\]
~ix', $body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
if ($hasInline) {
foreach (array_reverse($matches) as $m) {
$file = rtrim($basePath, '/\\') . '/' . (isset($m[4]) ? $m[4][0] : urldecode($m[3][0]));
if (!isset($cids[$file])) {
$cids[$file] = substr($this->addInline($file), 1, -1);
}
$body = substr_replace($body, "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}", $m[0][1], strlen($m[0][0]));
}
}
}
$this->body($body);
$this->mime('text/html');
$this->charset(Mime::optimalCharset($body));
$this->_altBody = static::stripTags($this->_body);
return $this;
} | php | public function html($body, $basePath = null)
{
if (!func_num_args()) {
return $this->_body;
}
if ($basePath) {
$cids = [];
$hasInline = preg_match_all('~
(<img[^<>]*\s src\s*=\s*
|<body[^<>]*\s background\s*=\s*
|<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
|<style[^>]*>[^<]+ [:\s] url\()
(["\']?)(?![a-z]+:|[/#])([^"\'>)\s]+)
|\[\[ ([\w()+./@\\~-]+) \]\]
~ix', $body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
if ($hasInline) {
foreach (array_reverse($matches) as $m) {
$file = rtrim($basePath, '/\\') . '/' . (isset($m[4]) ? $m[4][0] : urldecode($m[3][0]));
if (!isset($cids[$file])) {
$cids[$file] = substr($this->addInline($file), 1, -1);
}
$body = substr_replace($body, "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}", $m[0][1], strlen($m[0][0]));
}
}
}
$this->body($body);
$this->mime('text/html');
$this->charset(Mime::optimalCharset($body));
$this->_altBody = static::stripTags($this->_body);
return $this;
} | [
"public",
"function",
"html",
"(",
"$",
"body",
",",
"$",
"basePath",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"func_num_args",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_body",
";",
"}",
"if",
"(",
"$",
"basePath",
")",
"{",
"$",
"cids",
"=",
"[",
"]",
";",
"$",
"hasInline",
"=",
"preg_match_all",
"(",
"'~\n (<img[^<>]*\\s src\\s*=\\s*\n |<body[^<>]*\\s background\\s*=\\s*\n |<[^<>]+\\s style\\s*=\\s* [\"\\'][^\"\\'>]+[:\\s] url\\(\n |<style[^>]*>[^<]+ [:\\s] url\\()\n ([\"\\']?)(?![a-z]+:|[/#])([^\"\\'>)\\s]+)\n |\\[\\[ ([\\w()+./@\\\\~-]+) \\]\\]\n ~ix'",
",",
"$",
"body",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
"|",
"PREG_SET_ORDER",
")",
";",
"if",
"(",
"$",
"hasInline",
")",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"matches",
")",
"as",
"$",
"m",
")",
"{",
"$",
"file",
"=",
"rtrim",
"(",
"$",
"basePath",
",",
"'/\\\\'",
")",
".",
"'/'",
".",
"(",
"isset",
"(",
"$",
"m",
"[",
"4",
"]",
")",
"?",
"$",
"m",
"[",
"4",
"]",
"[",
"0",
"]",
":",
"urldecode",
"(",
"$",
"m",
"[",
"3",
"]",
"[",
"0",
"]",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cids",
"[",
"$",
"file",
"]",
")",
")",
"{",
"$",
"cids",
"[",
"$",
"file",
"]",
"=",
"substr",
"(",
"$",
"this",
"->",
"addInline",
"(",
"$",
"file",
")",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"$",
"body",
"=",
"substr_replace",
"(",
"$",
"body",
",",
"\"{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}\"",
",",
"$",
"m",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"strlen",
"(",
"$",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
")",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"body",
"(",
"$",
"body",
")",
";",
"$",
"this",
"->",
"mime",
"(",
"'text/html'",
")",
";",
"$",
"this",
"->",
"charset",
"(",
"Mime",
"::",
"optimalCharset",
"(",
"$",
"body",
")",
")",
";",
"$",
"this",
"->",
"_altBody",
"=",
"static",
"::",
"stripTags",
"(",
"$",
"this",
"->",
"_body",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the HTML body message with an optionnal alternative body.
@param string $body The HTML body message.
@param string $altBody The alt body.
@return string|self | [
"Set",
"the",
"HTML",
"body",
"message",
"with",
"an",
"optionnal",
"alternative",
"body",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L473-L507 |
13,450 | crysalead/net | src/Mime/Message.php | Message.stripTags | public static function stripTags($html, $charset = 'UTF-8')
{
$patterns = [
'~<(style|script|head).*</\\1>~Uis' => '',
'~<t[dh][ >]~i' => ' $0',
'~<a\s[^>]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)</a>~is' => '$2 <$1>',
'~[\r\n ]+~' => ' ',
'~<(/?p|/?h\d|li|br|/tr)[ >/]~i' => "\n$0",
];
$text = preg_replace(array_keys($patterns), array_values($patterns), $html);
$text = html_entity_decode(strip_tags($text), ENT_QUOTES, $charset);
$text = preg_replace('~[ \t]+~', ' ', $text);
return trim($text);
} | php | public static function stripTags($html, $charset = 'UTF-8')
{
$patterns = [
'~<(style|script|head).*</\\1>~Uis' => '',
'~<t[dh][ >]~i' => ' $0',
'~<a\s[^>]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)</a>~is' => '$2 <$1>',
'~[\r\n ]+~' => ' ',
'~<(/?p|/?h\d|li|br|/tr)[ >/]~i' => "\n$0",
];
$text = preg_replace(array_keys($patterns), array_values($patterns), $html);
$text = html_entity_decode(strip_tags($text), ENT_QUOTES, $charset);
$text = preg_replace('~[ \t]+~', ' ', $text);
return trim($text);
} | [
"public",
"static",
"function",
"stripTags",
"(",
"$",
"html",
",",
"$",
"charset",
"=",
"'UTF-8'",
")",
"{",
"$",
"patterns",
"=",
"[",
"'~<(style|script|head).*</\\\\1>~Uis'",
"=>",
"''",
",",
"'~<t[dh][ >]~i'",
"=>",
"' $0'",
",",
"'~<a\\s[^>]*href=(?|\"([^\"]+)\"|\\'([^\\']+)\\')[^>]*>(.*?)</a>~is'",
"=>",
"'$2 <$1>'",
",",
"'~[\\r\\n ]+~'",
"=>",
"' '",
",",
"'~<(/?p|/?h\\d|li|br|/tr)[ >/]~i'",
"=>",
"\"\\n$0\"",
",",
"]",
";",
"$",
"text",
"=",
"preg_replace",
"(",
"array_keys",
"(",
"$",
"patterns",
")",
",",
"array_values",
"(",
"$",
"patterns",
")",
",",
"$",
"html",
")",
";",
"$",
"text",
"=",
"html_entity_decode",
"(",
"strip_tags",
"(",
"$",
"text",
")",
",",
"ENT_QUOTES",
",",
"$",
"charset",
")",
";",
"$",
"text",
"=",
"preg_replace",
"(",
"'~[ \\t]+~'",
",",
"' '",
",",
"$",
"text",
")",
";",
"return",
"trim",
"(",
"$",
"text",
")",
";",
"}"
]
| Strip HTML tags
@param string $html The html content
@return string | [
"Strip",
"HTML",
"tags"
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Message.php#L632-L646 |
13,451 | antarestupin/Accessible | lib/Accessible/AutoConstructTrait.php | AutoConstructTrait.initializeProperties | protected function initializeProperties($properties = null)
{
$this->getPropertiesInfo();
// Initialize the properties that were defined using the Initialize / InitializeObject annotations
$initializeValueValidationEnabled = Configuration::isInitializeValuesValidationEnabled();
foreach ($this->_initialPropertiesValues as $propertyName => $initialization) {
$value = null;
switch ($initialization['type']) {
case 'initialize':
$value = $initialization['value'];
break;
default:
$className = $initialization['value'];
$value = new $className();
break;
}
if ($initializeValueValidationEnabled) {
$this->assertPropertyValue($propertyName, $value);
}
$this->$propertyName = $value;
$this->updateInitializedPropertyValue($propertyName, $value);
}
// Initialize the propeties using given arguments
if ($this->_initializationNeededArguments !== null && $properties !== null) {
$numberOfNeededArguments = count($this->_initializationNeededArguments);
MethodCallManager::assertArgsNumber($numberOfNeededArguments, $properties);
for ($i = 0; $i < $numberOfNeededArguments; $i++) {
$propertyName = $this->_initializationNeededArguments[$i];
$argument = $properties[$i];
$this->assertPropertyValue($propertyName, $argument);
$this->$propertyName = $argument;
$this->updateInitializedPropertyValue($propertyName, $argument);
}
}
} | php | protected function initializeProperties($properties = null)
{
$this->getPropertiesInfo();
// Initialize the properties that were defined using the Initialize / InitializeObject annotations
$initializeValueValidationEnabled = Configuration::isInitializeValuesValidationEnabled();
foreach ($this->_initialPropertiesValues as $propertyName => $initialization) {
$value = null;
switch ($initialization['type']) {
case 'initialize':
$value = $initialization['value'];
break;
default:
$className = $initialization['value'];
$value = new $className();
break;
}
if ($initializeValueValidationEnabled) {
$this->assertPropertyValue($propertyName, $value);
}
$this->$propertyName = $value;
$this->updateInitializedPropertyValue($propertyName, $value);
}
// Initialize the propeties using given arguments
if ($this->_initializationNeededArguments !== null && $properties !== null) {
$numberOfNeededArguments = count($this->_initializationNeededArguments);
MethodCallManager::assertArgsNumber($numberOfNeededArguments, $properties);
for ($i = 0; $i < $numberOfNeededArguments; $i++) {
$propertyName = $this->_initializationNeededArguments[$i];
$argument = $properties[$i];
$this->assertPropertyValue($propertyName, $argument);
$this->$propertyName = $argument;
$this->updateInitializedPropertyValue($propertyName, $argument);
}
}
} | [
"protected",
"function",
"initializeProperties",
"(",
"$",
"properties",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getPropertiesInfo",
"(",
")",
";",
"// Initialize the properties that were defined using the Initialize / InitializeObject annotations",
"$",
"initializeValueValidationEnabled",
"=",
"Configuration",
"::",
"isInitializeValuesValidationEnabled",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_initialPropertiesValues",
"as",
"$",
"propertyName",
"=>",
"$",
"initialization",
")",
"{",
"$",
"value",
"=",
"null",
";",
"switch",
"(",
"$",
"initialization",
"[",
"'type'",
"]",
")",
"{",
"case",
"'initialize'",
":",
"$",
"value",
"=",
"$",
"initialization",
"[",
"'value'",
"]",
";",
"break",
";",
"default",
":",
"$",
"className",
"=",
"$",
"initialization",
"[",
"'value'",
"]",
";",
"$",
"value",
"=",
"new",
"$",
"className",
"(",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"initializeValueValidationEnabled",
")",
"{",
"$",
"this",
"->",
"assertPropertyValue",
"(",
"$",
"propertyName",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"$",
"propertyName",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"updateInitializedPropertyValue",
"(",
"$",
"propertyName",
",",
"$",
"value",
")",
";",
"}",
"// Initialize the propeties using given arguments",
"if",
"(",
"$",
"this",
"->",
"_initializationNeededArguments",
"!==",
"null",
"&&",
"$",
"properties",
"!==",
"null",
")",
"{",
"$",
"numberOfNeededArguments",
"=",
"count",
"(",
"$",
"this",
"->",
"_initializationNeededArguments",
")",
";",
"MethodCallManager",
"::",
"assertArgsNumber",
"(",
"$",
"numberOfNeededArguments",
",",
"$",
"properties",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numberOfNeededArguments",
";",
"$",
"i",
"++",
")",
"{",
"$",
"propertyName",
"=",
"$",
"this",
"->",
"_initializationNeededArguments",
"[",
"$",
"i",
"]",
";",
"$",
"argument",
"=",
"$",
"properties",
"[",
"$",
"i",
"]",
";",
"$",
"this",
"->",
"assertPropertyValue",
"(",
"$",
"propertyName",
",",
"$",
"argument",
")",
";",
"$",
"this",
"->",
"$",
"propertyName",
"=",
"$",
"argument",
";",
"$",
"this",
"->",
"updateInitializedPropertyValue",
"(",
"$",
"propertyName",
",",
"$",
"argument",
")",
";",
"}",
"}",
"}"
]
| Initializes the object according to its class specification and given arguments.
@param array $properties The values to give to the properties. | [
"Initializes",
"the",
"object",
"according",
"to",
"its",
"class",
"specification",
"and",
"given",
"arguments",
"."
]
| d12ce93d72f74c099dfd2109371fcd6ddfffdca4 | https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/AutoConstructTrait.php#L22-L63 |
13,452 | antarestupin/Accessible | lib/Accessible/AutoConstructTrait.php | AutoConstructTrait.updateInitializedPropertyValue | private function updateInitializedPropertyValue($propertyName, $value)
{
if (empty($this->_collectionsItemNames['byProperty'][$propertyName])) {
$this->updatePropertyAssociation($propertyName, array("oldValue" => null, "newValue" => $value));
} else {
foreach ($value as $newValue) {
$this->updatePropertyAssociation($propertyName, array("oldValue" => null, "newValue" => $newValue));
}
}
} | php | private function updateInitializedPropertyValue($propertyName, $value)
{
if (empty($this->_collectionsItemNames['byProperty'][$propertyName])) {
$this->updatePropertyAssociation($propertyName, array("oldValue" => null, "newValue" => $value));
} else {
foreach ($value as $newValue) {
$this->updatePropertyAssociation($propertyName, array("oldValue" => null, "newValue" => $newValue));
}
}
} | [
"private",
"function",
"updateInitializedPropertyValue",
"(",
"$",
"propertyName",
",",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_collectionsItemNames",
"[",
"'byProperty'",
"]",
"[",
"$",
"propertyName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"updatePropertyAssociation",
"(",
"$",
"propertyName",
",",
"array",
"(",
"\"oldValue\"",
"=>",
"null",
",",
"\"newValue\"",
"=>",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"newValue",
")",
"{",
"$",
"this",
"->",
"updatePropertyAssociation",
"(",
"$",
"propertyName",
",",
"array",
"(",
"\"oldValue\"",
"=>",
"null",
",",
"\"newValue\"",
"=>",
"$",
"newValue",
")",
")",
";",
"}",
"}",
"}"
]
| Update an initialized value.
@param string $propertyName
@param mixed $value | [
"Update",
"an",
"initialized",
"value",
"."
]
| d12ce93d72f74c099dfd2109371fcd6ddfffdca4 | https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/AutoConstructTrait.php#L71-L80 |
13,453 | ssnepenthe/soter | src/class-upgrader.php | Upgrader.delete_vulnerabilities | protected function delete_vulnerabilities() {
$query = new WP_Query( [
'fields' => 'ids',
'no_found_rows' => true,
'post_type' => 'soter_vulnerability',
'post_status' => 'private',
// @todo Vulnerabilities were previously garbage collected on a daily
// basis so it shouldn't be a problem to get all of them - worth testing.
'posts_per_page' => -1,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
] );
// Can be empty.
foreach ( $query->posts as $id ) {
wp_delete_post( $id );
}
} | php | protected function delete_vulnerabilities() {
$query = new WP_Query( [
'fields' => 'ids',
'no_found_rows' => true,
'post_type' => 'soter_vulnerability',
'post_status' => 'private',
// @todo Vulnerabilities were previously garbage collected on a daily
// basis so it shouldn't be a problem to get all of them - worth testing.
'posts_per_page' => -1,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
] );
// Can be empty.
foreach ( $query->posts as $id ) {
wp_delete_post( $id );
}
} | [
"protected",
"function",
"delete_vulnerabilities",
"(",
")",
"{",
"$",
"query",
"=",
"new",
"WP_Query",
"(",
"[",
"'fields'",
"=>",
"'ids'",
",",
"'no_found_rows'",
"=>",
"true",
",",
"'post_type'",
"=>",
"'soter_vulnerability'",
",",
"'post_status'",
"=>",
"'private'",
",",
"// @todo Vulnerabilities were previously garbage collected on a daily",
"// basis so it shouldn't be a problem to get all of them - worth testing.",
"'posts_per_page'",
"=>",
"-",
"1",
",",
"'update_post_meta_cache'",
"=>",
"false",
",",
"'update_post_term_cache'",
"=>",
"false",
",",
"]",
")",
";",
"// Can be empty.",
"foreach",
"(",
"$",
"query",
"->",
"posts",
"as",
"$",
"id",
")",
"{",
"wp_delete_post",
"(",
"$",
"id",
")",
";",
"}",
"}"
]
| Deletes any lingering soter_vulnerability posts.
@return void | [
"Deletes",
"any",
"lingering",
"soter_vulnerability",
"posts",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-upgrader.php#L51-L68 |
13,454 | ssnepenthe/soter | src/class-upgrader.php | Upgrader.prepare_ignored_plugins | protected function prepare_ignored_plugins( array $plugins ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$valid_slugs = array_map( function( $file ) {
if ( false === strpos( $file, '/' ) ) {
$slug = basename( $file, '.php' );
} else {
$slug = dirname( $file );
}
return $slug;
}, array_keys( get_plugins() ) );
return array_values( array_intersect( $valid_slugs, $plugins ) );
} | php | protected function prepare_ignored_plugins( array $plugins ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$valid_slugs = array_map( function( $file ) {
if ( false === strpos( $file, '/' ) ) {
$slug = basename( $file, '.php' );
} else {
$slug = dirname( $file );
}
return $slug;
}, array_keys( get_plugins() ) );
return array_values( array_intersect( $valid_slugs, $plugins ) );
} | [
"protected",
"function",
"prepare_ignored_plugins",
"(",
"array",
"$",
"plugins",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'get_plugins'",
")",
")",
"{",
"require_once",
"ABSPATH",
".",
"'wp-admin/includes/plugin.php'",
";",
"}",
"$",
"valid_slugs",
"=",
"array_map",
"(",
"function",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"file",
",",
"'/'",
")",
")",
"{",
"$",
"slug",
"=",
"basename",
"(",
"$",
"file",
",",
"'.php'",
")",
";",
"}",
"else",
"{",
"$",
"slug",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"slug",
";",
"}",
",",
"array_keys",
"(",
"get_plugins",
"(",
")",
")",
")",
";",
"return",
"array_values",
"(",
"array_intersect",
"(",
"$",
"valid_slugs",
",",
"$",
"plugins",
")",
")",
";",
"}"
]
| Ensure ignored plugins setting only contains currently installed plugins.
@param array $plugins List of ignored plugins.
@return array | [
"Ensure",
"ignored",
"plugins",
"setting",
"only",
"contains",
"currently",
"installed",
"plugins",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-upgrader.php#L77-L93 |
13,455 | ssnepenthe/soter | src/class-upgrader.php | Upgrader.prepare_ignored_themes | protected function prepare_ignored_themes( array $themes ) {
$valid_slugs = array_values( wp_list_pluck(
wp_get_themes(),
'stylesheet'
) );
return array_values( array_intersect( $valid_slugs, $themes ) );
} | php | protected function prepare_ignored_themes( array $themes ) {
$valid_slugs = array_values( wp_list_pluck(
wp_get_themes(),
'stylesheet'
) );
return array_values( array_intersect( $valid_slugs, $themes ) );
} | [
"protected",
"function",
"prepare_ignored_themes",
"(",
"array",
"$",
"themes",
")",
"{",
"$",
"valid_slugs",
"=",
"array_values",
"(",
"wp_list_pluck",
"(",
"wp_get_themes",
"(",
")",
",",
"'stylesheet'",
")",
")",
";",
"return",
"array_values",
"(",
"array_intersect",
"(",
"$",
"valid_slugs",
",",
"$",
"themes",
")",
")",
";",
"}"
]
| Ensure ignored themes setting only contains currently installed themes.
@param array $themes List of ignored themes.
@return array | [
"Ensure",
"ignored",
"themes",
"setting",
"only",
"contains",
"currently",
"installed",
"themes",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-upgrader.php#L102-L109 |
13,456 | ssnepenthe/soter | src/class-upgrader.php | Upgrader.upgrade_to_050 | protected function upgrade_to_050() {
if ( $this->options->installed_version ) {
return;
}
$this->upgrade_cron();
$this->upgrade_options();
$this->upgrade_results();
$this->delete_vulnerabilities();
// Set installed version so upgrader does not run again.
$this->options->get_store()->set( 'installed_version', '0.5.0' );
} | php | protected function upgrade_to_050() {
if ( $this->options->installed_version ) {
return;
}
$this->upgrade_cron();
$this->upgrade_options();
$this->upgrade_results();
$this->delete_vulnerabilities();
// Set installed version so upgrader does not run again.
$this->options->get_store()->set( 'installed_version', '0.5.0' );
} | [
"protected",
"function",
"upgrade_to_050",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"->",
"installed_version",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"upgrade_cron",
"(",
")",
";",
"$",
"this",
"->",
"upgrade_options",
"(",
")",
";",
"$",
"this",
"->",
"upgrade_results",
"(",
")",
";",
"$",
"this",
"->",
"delete_vulnerabilities",
"(",
")",
";",
"// Set installed version so upgrader does not run again.",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'installed_version'",
",",
"'0.5.0'",
")",
";",
"}"
]
| Required logic for upgrading to v0.5.0.
@return void | [
"Required",
"logic",
"for",
"upgrading",
"to",
"v0",
".",
"5",
".",
"0",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-upgrader.php#L116-L129 |
13,457 | ssnepenthe/soter | src/class-upgrader.php | Upgrader.upgrade_options | protected function upgrade_options() {
// Pre-0.4.0 options array to 0.5.0+ individual option entries.
$old_options = (array) $this->options->get_store()->get( 'settings', [] );
if ( isset( $old_options['email_address'] ) ) {
$sanitized = sanitize_email( $old_options['email_address'] );
if ( $sanitized ) {
$this->options->get_store()->set( 'email_address', $old_options['email_address'] );
}
}
if ( isset( $old_options['html_email'] ) && $old_options['html_email'] ) {
$this->options->get_store()->set( 'email_type', 'html' );
}
if (
isset( $old_options['ignored_plugins'] )
&& is_array( $old_options['ignored_plugins'] )
) {
$ignored_plugins = $this->prepare_ignored_plugins( $old_options['ignored_plugins'] );
if ( ! empty( $ignored_plugins ) ) {
$this->options->get_store()->set( 'ignored_plugins', $ignored_plugins );
}
}
if (
isset( $old_options['ignored_themes'] )
&& is_array( $old_options['ignored_themes'] )
) {
$ignored_themes = $this->prepare_ignored_themes( $old_options['ignored_themes'] );
if ( ! empty( $ignored_themes ) ) {
$this->options->get_store()->set( 'ignored_themes', $ignored_themes );
}
}
// These options don't technically get set because they are the same as the
// defaults we have defined in the options manager class...
$this->options->get_store()->set( 'email_enabled', 'yes' );
$this->options->get_store()->set( 'last_scan_hash', '' );
$this->options->get_store()->set( 'should_nag', 'yes' );
$this->options->get_store()->set( 'slack_enabled', 'no' );
$this->options->get_store()->set( 'slack_url', '' );
$this->options->get_store()->delete( 'settings' );
} | php | protected function upgrade_options() {
// Pre-0.4.0 options array to 0.5.0+ individual option entries.
$old_options = (array) $this->options->get_store()->get( 'settings', [] );
if ( isset( $old_options['email_address'] ) ) {
$sanitized = sanitize_email( $old_options['email_address'] );
if ( $sanitized ) {
$this->options->get_store()->set( 'email_address', $old_options['email_address'] );
}
}
if ( isset( $old_options['html_email'] ) && $old_options['html_email'] ) {
$this->options->get_store()->set( 'email_type', 'html' );
}
if (
isset( $old_options['ignored_plugins'] )
&& is_array( $old_options['ignored_plugins'] )
) {
$ignored_plugins = $this->prepare_ignored_plugins( $old_options['ignored_plugins'] );
if ( ! empty( $ignored_plugins ) ) {
$this->options->get_store()->set( 'ignored_plugins', $ignored_plugins );
}
}
if (
isset( $old_options['ignored_themes'] )
&& is_array( $old_options['ignored_themes'] )
) {
$ignored_themes = $this->prepare_ignored_themes( $old_options['ignored_themes'] );
if ( ! empty( $ignored_themes ) ) {
$this->options->get_store()->set( 'ignored_themes', $ignored_themes );
}
}
// These options don't technically get set because they are the same as the
// defaults we have defined in the options manager class...
$this->options->get_store()->set( 'email_enabled', 'yes' );
$this->options->get_store()->set( 'last_scan_hash', '' );
$this->options->get_store()->set( 'should_nag', 'yes' );
$this->options->get_store()->set( 'slack_enabled', 'no' );
$this->options->get_store()->set( 'slack_url', '' );
$this->options->get_store()->delete( 'settings' );
} | [
"protected",
"function",
"upgrade_options",
"(",
")",
"{",
"// Pre-0.4.0 options array to 0.5.0+ individual option entries.",
"$",
"old_options",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"get",
"(",
"'settings'",
",",
"[",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"old_options",
"[",
"'email_address'",
"]",
")",
")",
"{",
"$",
"sanitized",
"=",
"sanitize_email",
"(",
"$",
"old_options",
"[",
"'email_address'",
"]",
")",
";",
"if",
"(",
"$",
"sanitized",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'email_address'",
",",
"$",
"old_options",
"[",
"'email_address'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"old_options",
"[",
"'html_email'",
"]",
")",
"&&",
"$",
"old_options",
"[",
"'html_email'",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'email_type'",
",",
"'html'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"old_options",
"[",
"'ignored_plugins'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"old_options",
"[",
"'ignored_plugins'",
"]",
")",
")",
"{",
"$",
"ignored_plugins",
"=",
"$",
"this",
"->",
"prepare_ignored_plugins",
"(",
"$",
"old_options",
"[",
"'ignored_plugins'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ignored_plugins",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'ignored_plugins'",
",",
"$",
"ignored_plugins",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"old_options",
"[",
"'ignored_themes'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"old_options",
"[",
"'ignored_themes'",
"]",
")",
")",
"{",
"$",
"ignored_themes",
"=",
"$",
"this",
"->",
"prepare_ignored_themes",
"(",
"$",
"old_options",
"[",
"'ignored_themes'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ignored_themes",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'ignored_themes'",
",",
"$",
"ignored_themes",
")",
";",
"}",
"}",
"// These options don't technically get set because they are the same as the",
"// defaults we have defined in the options manager class...",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'email_enabled'",
",",
"'yes'",
")",
";",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'last_scan_hash'",
",",
"''",
")",
";",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'should_nag'",
",",
"'yes'",
")",
";",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'slack_enabled'",
",",
"'no'",
")",
";",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'slack_url'",
",",
"''",
")",
";",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"delete",
"(",
"'settings'",
")",
";",
"}"
]
| Upgrade to latest options implementation.
@return void | [
"Upgrade",
"to",
"latest",
"options",
"implementation",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-upgrader.php#L153-L200 |
13,458 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Devices.php | Devices.create | public function create($device, array $tagNames = array()){
if (!empty($tagNames)){
$tagEndpoint = new Tags($this->client);
$tags = $tagEndpoint->findAll($tagNames);
if(!empty($tags['notFound'])){
foreach($tags['notFound'] as $name){
$tags['tags'][] = $tagEndpoint->create($name);
}
}
$formattedTags = $tagEndpoint->format($tags['tags'], 'other');
$device['tags'] = $formattedTags['tags'];
}
$device = $this->makeJsonReady($device);
return $this->post('inventory/devices/', $device);
} | php | public function create($device, array $tagNames = array()){
if (!empty($tagNames)){
$tagEndpoint = new Tags($this->client);
$tags = $tagEndpoint->findAll($tagNames);
if(!empty($tags['notFound'])){
foreach($tags['notFound'] as $name){
$tags['tags'][] = $tagEndpoint->create($name);
}
}
$formattedTags = $tagEndpoint->format($tags['tags'], 'other');
$device['tags'] = $formattedTags['tags'];
}
$device = $this->makeJsonReady($device);
return $this->post('inventory/devices/', $device);
} | [
"public",
"function",
"create",
"(",
"$",
"device",
",",
"array",
"$",
"tagNames",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"tagNames",
")",
")",
"{",
"$",
"tagEndpoint",
"=",
"new",
"Tags",
"(",
"$",
"this",
"->",
"client",
")",
";",
"$",
"tags",
"=",
"$",
"tagEndpoint",
"->",
"findAll",
"(",
"$",
"tagNames",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tags",
"[",
"'notFound'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"tags",
"[",
"'notFound'",
"]",
"as",
"$",
"name",
")",
"{",
"$",
"tags",
"[",
"'tags'",
"]",
"[",
"]",
"=",
"$",
"tagEndpoint",
"->",
"create",
"(",
"$",
"name",
")",
";",
"}",
"}",
"$",
"formattedTags",
"=",
"$",
"tagEndpoint",
"->",
"format",
"(",
"$",
"tags",
"[",
"'tags'",
"]",
",",
"'other'",
")",
";",
"$",
"device",
"[",
"'tags'",
"]",
"=",
"$",
"formattedTags",
"[",
"'tags'",
"]",
";",
"}",
"$",
"device",
"=",
"$",
"this",
"->",
"makeJsonReady",
"(",
"$",
"device",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'inventory/devices/'",
",",
"$",
"device",
")",
";",
"}"
]
| Create a device
@link https://developer.serverdensity.com/v2.0/docs/creating-a-device
@param array $device with all its attributes.
@return an array that is the device. | [
"Create",
"a",
"device"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Devices.php#L13-L29 |
13,459 | reinvanoyen/aegis | lib/Aegis/Lexer.php | Lexer.tokenize | public function tokenize(string $input) : TokenStream
{
$this->prepare($input);
// Loop each character
while ($this->cursor < $this->end) {
$this->currentChar = $this->input[$this->cursor];
if (preg_match('@'.Token::REGEX_T_EOL.'@', $this->currentChar)) {
if ($this->mode !== self::MODE_IDENT) {
++$this->line;
$this->lineOffset = $this->cursor + 1;
}
}
switch ($this->mode) {
case self::MODE_ALL:
$this->lexAll();
break;
case self::MODE_INSIDE_TAG:
$this->lexInsideTag();
break;
case self::MODE_IDENT:
$this->lexIdent();
break;
case self::MODE_VAR:
$this->lexVar();
break;
case self::MODE_STRING:
$this->lexString();
break;
case self::MODE_NUMBER:
$this->lexNumber();
break;
case self::MODE_OP:
$this->lexOperator();
break;
}
}
return $this->stream;
} | php | public function tokenize(string $input) : TokenStream
{
$this->prepare($input);
// Loop each character
while ($this->cursor < $this->end) {
$this->currentChar = $this->input[$this->cursor];
if (preg_match('@'.Token::REGEX_T_EOL.'@', $this->currentChar)) {
if ($this->mode !== self::MODE_IDENT) {
++$this->line;
$this->lineOffset = $this->cursor + 1;
}
}
switch ($this->mode) {
case self::MODE_ALL:
$this->lexAll();
break;
case self::MODE_INSIDE_TAG:
$this->lexInsideTag();
break;
case self::MODE_IDENT:
$this->lexIdent();
break;
case self::MODE_VAR:
$this->lexVar();
break;
case self::MODE_STRING:
$this->lexString();
break;
case self::MODE_NUMBER:
$this->lexNumber();
break;
case self::MODE_OP:
$this->lexOperator();
break;
}
}
return $this->stream;
} | [
"public",
"function",
"tokenize",
"(",
"string",
"$",
"input",
")",
":",
"TokenStream",
"{",
"$",
"this",
"->",
"prepare",
"(",
"$",
"input",
")",
";",
"// Loop each character",
"while",
"(",
"$",
"this",
"->",
"cursor",
"<",
"$",
"this",
"->",
"end",
")",
"{",
"$",
"this",
"->",
"currentChar",
"=",
"$",
"this",
"->",
"input",
"[",
"$",
"this",
"->",
"cursor",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'@'",
".",
"Token",
"::",
"REGEX_T_EOL",
".",
"'@'",
",",
"$",
"this",
"->",
"currentChar",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
"!==",
"self",
"::",
"MODE_IDENT",
")",
"{",
"++",
"$",
"this",
"->",
"line",
";",
"$",
"this",
"->",
"lineOffset",
"=",
"$",
"this",
"->",
"cursor",
"+",
"1",
";",
"}",
"}",
"switch",
"(",
"$",
"this",
"->",
"mode",
")",
"{",
"case",
"self",
"::",
"MODE_ALL",
":",
"$",
"this",
"->",
"lexAll",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"MODE_INSIDE_TAG",
":",
"$",
"this",
"->",
"lexInsideTag",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"MODE_IDENT",
":",
"$",
"this",
"->",
"lexIdent",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"MODE_VAR",
":",
"$",
"this",
"->",
"lexVar",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"MODE_STRING",
":",
"$",
"this",
"->",
"lexString",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"MODE_NUMBER",
":",
"$",
"this",
"->",
"lexNumber",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"MODE_OP",
":",
"$",
"this",
"->",
"lexOperator",
"(",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"stream",
";",
"}"
]
| Tokenizes a string into a TokenStream
@param $input
@return TokenStream | [
"Tokenizes",
"a",
"string",
"into",
"a",
"TokenStream"
]
| ecd831fd6f3ceb4fb20fb5af83483d73cad8e323 | https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Lexer.php#L92-L134 |
13,460 | reinvanoyen/aegis | lib/Aegis/Lexer.php | Lexer.prepare | private function prepare(string $input)
{
$this->input = str_replace(["\n\r", "\r"], "\n", $input);
// Create new token stream
$this->stream = new TokenStream();
$this->cursor = 0;
$this->line = 1;
$this->lineOffset = 0;
$this->end = strlen($this->input);
$this->lastCharPos = $this->end - 1;
$this->currentChar = '';
$this->currentValue = '';
$this->modeStartChar = '';
$this->modeStartPosition = 0;
$this->modeStartLine = 0;
// Set the mode to "ALL"
$this->setMode(self::MODE_ALL);
} | php | private function prepare(string $input)
{
$this->input = str_replace(["\n\r", "\r"], "\n", $input);
// Create new token stream
$this->stream = new TokenStream();
$this->cursor = 0;
$this->line = 1;
$this->lineOffset = 0;
$this->end = strlen($this->input);
$this->lastCharPos = $this->end - 1;
$this->currentChar = '';
$this->currentValue = '';
$this->modeStartChar = '';
$this->modeStartPosition = 0;
$this->modeStartLine = 0;
// Set the mode to "ALL"
$this->setMode(self::MODE_ALL);
} | [
"private",
"function",
"prepare",
"(",
"string",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"str_replace",
"(",
"[",
"\"\\n\\r\"",
",",
"\"\\r\"",
"]",
",",
"\"\\n\"",
",",
"$",
"input",
")",
";",
"// Create new token stream",
"$",
"this",
"->",
"stream",
"=",
"new",
"TokenStream",
"(",
")",
";",
"$",
"this",
"->",
"cursor",
"=",
"0",
";",
"$",
"this",
"->",
"line",
"=",
"1",
";",
"$",
"this",
"->",
"lineOffset",
"=",
"0",
";",
"$",
"this",
"->",
"end",
"=",
"strlen",
"(",
"$",
"this",
"->",
"input",
")",
";",
"$",
"this",
"->",
"lastCharPos",
"=",
"$",
"this",
"->",
"end",
"-",
"1",
";",
"$",
"this",
"->",
"currentChar",
"=",
"''",
";",
"$",
"this",
"->",
"currentValue",
"=",
"''",
";",
"$",
"this",
"->",
"modeStartChar",
"=",
"''",
";",
"$",
"this",
"->",
"modeStartPosition",
"=",
"0",
";",
"$",
"this",
"->",
"modeStartLine",
"=",
"0",
";",
"// Set the mode to \"ALL\"",
"$",
"this",
"->",
"setMode",
"(",
"self",
"::",
"MODE_ALL",
")",
";",
"}"
]
| Prepares the Lexer for tokenizing a string
@param string $input | [
"Prepares",
"the",
"Lexer",
"for",
"tokenizing",
"a",
"string"
]
| ecd831fd6f3ceb4fb20fb5af83483d73cad8e323 | https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Lexer.php#L141-L162 |
13,461 | reinvanoyen/aegis | lib/Aegis/Lexer.php | Lexer.setMode | private function setMode(int $mode)
{
$this->mode = $mode;
$this->modeStartLine = $this->line;
$this->modeStartPosition = $this->getCurrentLinePosition();
} | php | private function setMode(int $mode)
{
$this->mode = $mode;
$this->modeStartLine = $this->line;
$this->modeStartPosition = $this->getCurrentLinePosition();
} | [
"private",
"function",
"setMode",
"(",
"int",
"$",
"mode",
")",
"{",
"$",
"this",
"->",
"mode",
"=",
"$",
"mode",
";",
"$",
"this",
"->",
"modeStartLine",
"=",
"$",
"this",
"->",
"line",
";",
"$",
"this",
"->",
"modeStartPosition",
"=",
"$",
"this",
"->",
"getCurrentLinePosition",
"(",
")",
";",
"}"
]
| Sets the lexing mode
@param int $mode | [
"Sets",
"the",
"lexing",
"mode"
]
| ecd831fd6f3ceb4fb20fb5af83483d73cad8e323 | https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Lexer.php#L336-L341 |
13,462 | kriskbx/mikado | src/Providers/MikadoServiceProvider.php | MikadoServiceProvider.addManager | protected function addManager($fileInfo, &$mikado)
{
$manager = new Manager();
$pathParts = pathinfo($fileInfo->getBasename());
$model = $pathParts['filename'];
$this->addFormatter($manager, $model, 'MetaFormatter');
$this->addFormatter($manager, $model, 'RemapFormatter');
$this->addFormatter($manager, $model, 'FilterFormatter');
$mikado->add($model, $manager);
} | php | protected function addManager($fileInfo, &$mikado)
{
$manager = new Manager();
$pathParts = pathinfo($fileInfo->getBasename());
$model = $pathParts['filename'];
$this->addFormatter($manager, $model, 'MetaFormatter');
$this->addFormatter($manager, $model, 'RemapFormatter');
$this->addFormatter($manager, $model, 'FilterFormatter');
$mikado->add($model, $manager);
} | [
"protected",
"function",
"addManager",
"(",
"$",
"fileInfo",
",",
"&",
"$",
"mikado",
")",
"{",
"$",
"manager",
"=",
"new",
"Manager",
"(",
")",
";",
"$",
"pathParts",
"=",
"pathinfo",
"(",
"$",
"fileInfo",
"->",
"getBasename",
"(",
")",
")",
";",
"$",
"model",
"=",
"$",
"pathParts",
"[",
"'filename'",
"]",
";",
"$",
"this",
"->",
"addFormatter",
"(",
"$",
"manager",
",",
"$",
"model",
",",
"'MetaFormatter'",
")",
";",
"$",
"this",
"->",
"addFormatter",
"(",
"$",
"manager",
",",
"$",
"model",
",",
"'RemapFormatter'",
")",
";",
"$",
"this",
"->",
"addFormatter",
"(",
"$",
"manager",
",",
"$",
"model",
",",
"'FilterFormatter'",
")",
";",
"$",
"mikado",
"->",
"add",
"(",
"$",
"model",
",",
"$",
"manager",
")",
";",
"}"
]
| Add manager to mikado.
@param DirectoryIterator $fileInfo
@param Mikado $mikado | [
"Add",
"manager",
"to",
"mikado",
"."
]
| f00e566d682a66796f3f8a68b348920fadd9ee87 | https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/src/Providers/MikadoServiceProvider.php#L56-L68 |
13,463 | kriskbx/mikado | src/Providers/MikadoServiceProvider.php | MikadoServiceProvider.addFormatter | protected function addFormatter(&$manager, $model, $formatter)
{
// Get the config
$config = (include $this->configPath . '/' . $model . '.php');
if(!isset($config[$formatter]))
return;
$formatterClass = 'kriskbx\mikado\Formatters\\' . $formatter;
if (is_array($config[$formatter]) && count($config[$formatter]) > 0) {
$manager->add(new $formatterClass($config[$formatter]));
}
} | php | protected function addFormatter(&$manager, $model, $formatter)
{
// Get the config
$config = (include $this->configPath . '/' . $model . '.php');
if(!isset($config[$formatter]))
return;
$formatterClass = 'kriskbx\mikado\Formatters\\' . $formatter;
if (is_array($config[$formatter]) && count($config[$formatter]) > 0) {
$manager->add(new $formatterClass($config[$formatter]));
}
} | [
"protected",
"function",
"addFormatter",
"(",
"&",
"$",
"manager",
",",
"$",
"model",
",",
"$",
"formatter",
")",
"{",
"// Get the config",
"$",
"config",
"=",
"(",
"include",
"$",
"this",
"->",
"configPath",
".",
"'/'",
".",
"$",
"model",
".",
"'.php'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"formatter",
"]",
")",
")",
"return",
";",
"$",
"formatterClass",
"=",
"'kriskbx\\mikado\\Formatters\\\\'",
".",
"$",
"formatter",
";",
"if",
"(",
"is_array",
"(",
"$",
"config",
"[",
"$",
"formatter",
"]",
")",
"&&",
"count",
"(",
"$",
"config",
"[",
"$",
"formatter",
"]",
")",
">",
"0",
")",
"{",
"$",
"manager",
"->",
"add",
"(",
"new",
"$",
"formatterClass",
"(",
"$",
"config",
"[",
"$",
"formatter",
"]",
")",
")",
";",
"}",
"}"
]
| Add formatter to manager.
@param Manager $manager
@param string $model
@param string $formatter | [
"Add",
"formatter",
"to",
"manager",
"."
]
| f00e566d682a66796f3f8a68b348920fadd9ee87 | https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/src/Providers/MikadoServiceProvider.php#L77-L90 |
13,464 | delatbabel/site-config | src/Models/Config.php | Config.isJson | protected function isJson($string) {
// json_decode a numeric string doesn't throw an error, so we have to check it manually
if (! is_string($string) || is_numeric($string)) {
return false;
}
$result = @json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
} | php | protected function isJson($string) {
// json_decode a numeric string doesn't throw an error, so we have to check it manually
if (! is_string($string) || is_numeric($string)) {
return false;
}
$result = @json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
} | [
"protected",
"function",
"isJson",
"(",
"$",
"string",
")",
"{",
"// json_decode a numeric string doesn't throw an error, so we have to check it manually",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
"||",
"is_numeric",
"(",
"$",
"string",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"@",
"json_decode",
"(",
"$",
"string",
")",
";",
"return",
"(",
"json_last_error",
"(",
")",
"==",
"JSON_ERROR_NONE",
")",
";",
"}"
]
| Check to see if a string is JSON.
@param $string
@return bool | [
"Check",
"to",
"see",
"if",
"a",
"string",
"is",
"JSON",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Config.php#L44-L51 |
13,465 | delatbabel/site-config | src/Models/Config.php | Config.fetchSettings | public static function fetchSettings($environment = null, $website_id = null, $group = 'config')
{
$model = static::where('group', '=', $group);
// Environment can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($environment) {
if (empty($environment)) {
$query->whereNull('environment');
} else {
$query->where('environment', '=', $environment)
->orWhereNull('environment');
}
});
// Website can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($website_id) {
if (empty($website_id)) {
$query->whereNull('website_id');
} else {
$query->where('website_id', '=', $website_id)
->orWhereNull('website_id');
}
});
// Order by relevance.
$model->orderBy(DB::raw('CASE
WHEN website_id IS NOT NULL AND environment IS NOT NULL THEN 1
WHEN website_id IS NOT NULL THEN 2
WHEN environment IS NOT NULL THEN 3
ELSE 4
END'));
/*
Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
'Config SQL query: ' . $model->toSql());
*/
/** @var Collection $collection */
$collection = $model->get();
return static::normaliseCollection($collection);
} | php | public static function fetchSettings($environment = null, $website_id = null, $group = 'config')
{
$model = static::where('group', '=', $group);
// Environment can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($environment) {
if (empty($environment)) {
$query->whereNull('environment');
} else {
$query->where('environment', '=', $environment)
->orWhereNull('environment');
}
});
// Website can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($website_id) {
if (empty($website_id)) {
$query->whereNull('website_id');
} else {
$query->where('website_id', '=', $website_id)
->orWhereNull('website_id');
}
});
// Order by relevance.
$model->orderBy(DB::raw('CASE
WHEN website_id IS NOT NULL AND environment IS NOT NULL THEN 1
WHEN website_id IS NOT NULL THEN 2
WHEN environment IS NOT NULL THEN 3
ELSE 4
END'));
/*
Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
'Config SQL query: ' . $model->toSql());
*/
/** @var Collection $collection */
$collection = $model->get();
return static::normaliseCollection($collection);
} | [
"public",
"static",
"function",
"fetchSettings",
"(",
"$",
"environment",
"=",
"null",
",",
"$",
"website_id",
"=",
"null",
",",
"$",
"group",
"=",
"'config'",
")",
"{",
"$",
"model",
"=",
"static",
"::",
"where",
"(",
"'group'",
",",
"'='",
",",
"$",
"group",
")",
";",
"// Environment can be null, or must match or use the null wildcard.",
"$",
"model",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"environment",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"environment",
")",
")",
"{",
"$",
"query",
"->",
"whereNull",
"(",
"'environment'",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"where",
"(",
"'environment'",
",",
"'='",
",",
"$",
"environment",
")",
"->",
"orWhereNull",
"(",
"'environment'",
")",
";",
"}",
"}",
")",
";",
"// Website can be null, or must match or use the null wildcard.",
"$",
"model",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"website_id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"website_id",
")",
")",
"{",
"$",
"query",
"->",
"whereNull",
"(",
"'website_id'",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"where",
"(",
"'website_id'",
",",
"'='",
",",
"$",
"website_id",
")",
"->",
"orWhereNull",
"(",
"'website_id'",
")",
";",
"}",
"}",
")",
";",
"// Order by relevance.",
"$",
"model",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"'CASE\n WHEN website_id IS NOT NULL AND environment IS NOT NULL THEN 1\n WHEN website_id IS NOT NULL THEN 2\n WHEN environment IS NOT NULL THEN 3\n ELSE 4\n END'",
")",
")",
";",
"/*\n Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .\n 'Config SQL query: ' . $model->toSql());\n */",
"/** @var Collection $collection */",
"$",
"collection",
"=",
"$",
"model",
"->",
"get",
"(",
")",
";",
"return",
"static",
"::",
"normaliseCollection",
"(",
"$",
"collection",
")",
";",
"}"
]
| Return the configuration data for a specific environment & group.
What this function tries to achieve is to return the configuration
for a given environment and group, The configuration table contains
2 limiting columns, which are website_id and environment. The way
that the limiting columns work is that if there is an entry in that
column then that config item applies only for that host or environment.
If a config item is sought where the host or environment matches then
these limited values take precedence over any values where website_id
or environment are NULL.
Otherwise the values that are stored where website_id and/or environment
act as "wildcards", so that they will match any searched website_id
or environment if there is no closer match.
As an example here are some table entries:
<code>
id site env key value
1 NULL NULL fruit apple
2 NULL prod fruit banana
3 www prod fruit mango
4 NULL test fruit peach
5 test NULL fruit orange
</code>
Given that sample data, this function should return the following
data for these searches:
<code>
env host key data returned
NULL NULL fruit 1, fruit, apple
prod NULL fruit 2, fruit, banana
NULL www fruit 3, fruit, mango
junk junk fruit 1, fruit, apple // NULL/NULL values are used as a fallback
junk www fruit 1, fruit, apple // no match, fallback
prod test fruit 5, fruit, orange // host=test takes precedence
</code>
The data that this function returns is actually a set of key => value
pairs for the configuration found within group $group.
To get the full configuration you need to call this function for each
group returned by fetchAllGroups().
@param string $environment
@param integer $website_id
@param string $group
@return array | [
"Return",
"the",
"configuration",
"data",
"for",
"a",
"specific",
"environment",
"&",
"group",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Config.php#L166-L206 |
13,466 | delatbabel/site-config | src/Models/Config.php | Config.fetchExactSettings | public static function fetchExactSettings($environment = null, $website_id = null, $group = 'config')
{
$model = static::where('group', '=', $group);
// Environment can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($environment) {
if (empty($environment)) {
$query->whereNull('environment');
} else {
$query->where('environment', '=', $environment);
}
});
// Website can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($website_id) {
if (empty($website_id)) {
$query->whereNull('website_id');
} else {
$query->where('website_id', '=', $website_id);
}
});
/*
Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
'Config SQL query: ' . $model->toSql());
*/
/** @var Collection $collection */
$collection = $model->get();
return static::normaliseCollection($collection);
} | php | public static function fetchExactSettings($environment = null, $website_id = null, $group = 'config')
{
$model = static::where('group', '=', $group);
// Environment can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($environment) {
if (empty($environment)) {
$query->whereNull('environment');
} else {
$query->where('environment', '=', $environment);
}
});
// Website can be null, or must match or use the null wildcard.
$model->where(function ($query) use ($website_id) {
if (empty($website_id)) {
$query->whereNull('website_id');
} else {
$query->where('website_id', '=', $website_id);
}
});
/*
Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
'Config SQL query: ' . $model->toSql());
*/
/** @var Collection $collection */
$collection = $model->get();
return static::normaliseCollection($collection);
} | [
"public",
"static",
"function",
"fetchExactSettings",
"(",
"$",
"environment",
"=",
"null",
",",
"$",
"website_id",
"=",
"null",
",",
"$",
"group",
"=",
"'config'",
")",
"{",
"$",
"model",
"=",
"static",
"::",
"where",
"(",
"'group'",
",",
"'='",
",",
"$",
"group",
")",
";",
"// Environment can be null, or must match or use the null wildcard.",
"$",
"model",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"environment",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"environment",
")",
")",
"{",
"$",
"query",
"->",
"whereNull",
"(",
"'environment'",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"where",
"(",
"'environment'",
",",
"'='",
",",
"$",
"environment",
")",
";",
"}",
"}",
")",
";",
"// Website can be null, or must match or use the null wildcard.",
"$",
"model",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"website_id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"website_id",
")",
")",
"{",
"$",
"query",
"->",
"whereNull",
"(",
"'website_id'",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"where",
"(",
"'website_id'",
",",
"'='",
",",
"$",
"website_id",
")",
";",
"}",
"}",
")",
";",
"/*\n Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .\n 'Config SQL query: ' . $model->toSql());\n */",
"/** @var Collection $collection */",
"$",
"collection",
"=",
"$",
"model",
"->",
"get",
"(",
")",
";",
"return",
"static",
"::",
"normaliseCollection",
"(",
"$",
"collection",
")",
";",
"}"
]
| Return the exact configuration data for a specific environment & group.
This function returns the exact configuration data for a specific
environment and group, ignoring any wildcard (NULL) values.
As an example here are some table entries:
<code>
id host env key value
1 NULL NULL fruit apple
2 NULL prod fruit banana
3 www prod fruit mango
4 NULL test fruit peach
5 test NULL fruit orange
</code>
Given that sample data, this function should return the following
data for these searches:
<code>
env host key data returned
NULL NULL fruit 1, fruit, apple
prod NULL fruit 2, fruit, banana
NULL www fruit null
junk junk fruit null
junk www fruit null
prod test fruit null
</code>
The data that this function returns is actually a set of key => value
pairs for the configuration found within group $group.
To get the full configuration you need to call this function for each
group returned by fetchAllGroups().
@param string $environment
@param integer $website_id
@param string $group
@return array | [
"Return",
"the",
"exact",
"configuration",
"data",
"for",
"a",
"specific",
"environment",
"&",
"group",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Config.php#L249-L279 |
13,467 | delatbabel/site-config | src/Models/Config.php | Config.fetchAllGroups | public static function fetchAllGroups()
{
$model = new self;
$result = [];
try {
foreach ($model->select('group')->distinct()->get() as $row) {
$result[] = $row->group;
}
} catch (\Exception $e) {
// Do nothing.
}
return $result;
} | php | public static function fetchAllGroups()
{
$model = new self;
$result = [];
try {
foreach ($model->select('group')->distinct()->get() as $row) {
$result[] = $row->group;
}
} catch (\Exception $e) {
// Do nothing.
}
return $result;
} | [
"public",
"static",
"function",
"fetchAllGroups",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"self",
";",
"$",
"result",
"=",
"[",
"]",
";",
"try",
"{",
"foreach",
"(",
"$",
"model",
"->",
"select",
"(",
"'group'",
")",
"->",
"distinct",
"(",
")",
"->",
"get",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"row",
"->",
"group",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Do nothing.",
"}",
"return",
"$",
"result",
";",
"}"
]
| Return an array of all groups.
@return array | [
"Return",
"an",
"array",
"of",
"all",
"groups",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Config.php#L334-L348 |
13,468 | delatbabel/site-config | src/Models/Config.php | Config.set | public static function set($key, $value, $group = 'config', $environment = null, $website_id = null, $type = 'string')
{
// Let's check if we are doing special array handling
$arrayHandling = false;
$keyExploded = explode('.', $key);
if (count($keyExploded) > 1) {
$arrayHandling = true;
$key = array_shift($keyExploded);
if ($type == 'array') {
// Use the accessor to ensure we always get an array.
$value = static::getValueAttribute($value);
}
}
// First let's try to fetch the model, if it exists then we need to do an
// Update not an insert
$model = static::where('key', '=', $key)->where('group', '=', $group);
// Environment can be null or must match.
if (empty($environment)) {
$model->whereNull('environment');
} else {
$model->where('environment', '=', $environment);
}
// Website can be null or must match.
if (empty($website_id)) {
$model->whereNull('website_id');
} else {
$model->where('website_id', '=', $website_id);
}
$model = $model->first();
if (empty($model)) {
//Check if we need to do special array handling
if ($arrayHandling) {
// we are setting a subset of an array
$array = [];
self::buildArrayPath($keyExploded, $value, $array);
$value = $array;
$type = 'array';
}
return static::create(
[
'website_id' => $website_id,
'environment' => $environment,
'group' => $group,
'key' => $key,
'value' => $value,
'type' => $type,
]);
}
//Check if we need to do special array handling
if ($arrayHandling) {
// we are setting a subset of an array
$array = [];
self::buildArrayPath($keyExploded, $value, $array);
//do we need to merge?
if ($model->type == 'array' && ! empty($model->value)) {
$array = array_replace_recursive($model->value, $array);
}
$value = $array;
$type = 'array';
}
$model->value = $value;
$model->type = $type;
$model->save();
return $model;
} | php | public static function set($key, $value, $group = 'config', $environment = null, $website_id = null, $type = 'string')
{
// Let's check if we are doing special array handling
$arrayHandling = false;
$keyExploded = explode('.', $key);
if (count($keyExploded) > 1) {
$arrayHandling = true;
$key = array_shift($keyExploded);
if ($type == 'array') {
// Use the accessor to ensure we always get an array.
$value = static::getValueAttribute($value);
}
}
// First let's try to fetch the model, if it exists then we need to do an
// Update not an insert
$model = static::where('key', '=', $key)->where('group', '=', $group);
// Environment can be null or must match.
if (empty($environment)) {
$model->whereNull('environment');
} else {
$model->where('environment', '=', $environment);
}
// Website can be null or must match.
if (empty($website_id)) {
$model->whereNull('website_id');
} else {
$model->where('website_id', '=', $website_id);
}
$model = $model->first();
if (empty($model)) {
//Check if we need to do special array handling
if ($arrayHandling) {
// we are setting a subset of an array
$array = [];
self::buildArrayPath($keyExploded, $value, $array);
$value = $array;
$type = 'array';
}
return static::create(
[
'website_id' => $website_id,
'environment' => $environment,
'group' => $group,
'key' => $key,
'value' => $value,
'type' => $type,
]);
}
//Check if we need to do special array handling
if ($arrayHandling) {
// we are setting a subset of an array
$array = [];
self::buildArrayPath($keyExploded, $value, $array);
//do we need to merge?
if ($model->type == 'array' && ! empty($model->value)) {
$array = array_replace_recursive($model->value, $array);
}
$value = $array;
$type = 'array';
}
$model->value = $value;
$model->type = $type;
$model->save();
return $model;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"group",
"=",
"'config'",
",",
"$",
"environment",
"=",
"null",
",",
"$",
"website_id",
"=",
"null",
",",
"$",
"type",
"=",
"'string'",
")",
"{",
"// Let's check if we are doing special array handling",
"$",
"arrayHandling",
"=",
"false",
";",
"$",
"keyExploded",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keyExploded",
")",
">",
"1",
")",
"{",
"$",
"arrayHandling",
"=",
"true",
";",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"keyExploded",
")",
";",
"if",
"(",
"$",
"type",
"==",
"'array'",
")",
"{",
"// Use the accessor to ensure we always get an array.",
"$",
"value",
"=",
"static",
"::",
"getValueAttribute",
"(",
"$",
"value",
")",
";",
"}",
"}",
"// First let's try to fetch the model, if it exists then we need to do an",
"// Update not an insert",
"$",
"model",
"=",
"static",
"::",
"where",
"(",
"'key'",
",",
"'='",
",",
"$",
"key",
")",
"->",
"where",
"(",
"'group'",
",",
"'='",
",",
"$",
"group",
")",
";",
"// Environment can be null or must match.",
"if",
"(",
"empty",
"(",
"$",
"environment",
")",
")",
"{",
"$",
"model",
"->",
"whereNull",
"(",
"'environment'",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"where",
"(",
"'environment'",
",",
"'='",
",",
"$",
"environment",
")",
";",
"}",
"// Website can be null or must match.",
"if",
"(",
"empty",
"(",
"$",
"website_id",
")",
")",
"{",
"$",
"model",
"->",
"whereNull",
"(",
"'website_id'",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"where",
"(",
"'website_id'",
",",
"'='",
",",
"$",
"website_id",
")",
";",
"}",
"$",
"model",
"=",
"$",
"model",
"->",
"first",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"model",
")",
")",
"{",
"//Check if we need to do special array handling",
"if",
"(",
"$",
"arrayHandling",
")",
"{",
"// we are setting a subset of an array",
"$",
"array",
"=",
"[",
"]",
";",
"self",
"::",
"buildArrayPath",
"(",
"$",
"keyExploded",
",",
"$",
"value",
",",
"$",
"array",
")",
";",
"$",
"value",
"=",
"$",
"array",
";",
"$",
"type",
"=",
"'array'",
";",
"}",
"return",
"static",
"::",
"create",
"(",
"[",
"'website_id'",
"=>",
"$",
"website_id",
",",
"'environment'",
"=>",
"$",
"environment",
",",
"'group'",
"=>",
"$",
"group",
",",
"'key'",
"=>",
"$",
"key",
",",
"'value'",
"=>",
"$",
"value",
",",
"'type'",
"=>",
"$",
"type",
",",
"]",
")",
";",
"}",
"//Check if we need to do special array handling",
"if",
"(",
"$",
"arrayHandling",
")",
"{",
"// we are setting a subset of an array",
"$",
"array",
"=",
"[",
"]",
";",
"self",
"::",
"buildArrayPath",
"(",
"$",
"keyExploded",
",",
"$",
"value",
",",
"$",
"array",
")",
";",
"//do we need to merge?",
"if",
"(",
"$",
"model",
"->",
"type",
"==",
"'array'",
"&&",
"!",
"empty",
"(",
"$",
"model",
"->",
"value",
")",
")",
"{",
"$",
"array",
"=",
"array_replace_recursive",
"(",
"$",
"model",
"->",
"value",
",",
"$",
"array",
")",
";",
"}",
"$",
"value",
"=",
"$",
"array",
";",
"$",
"type",
"=",
"'array'",
";",
"}",
"$",
"model",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"model",
"->",
"type",
"=",
"$",
"type",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"return",
"$",
"model",
";",
"}"
]
| Store a group of settings into the database.
@param string $key
@param mixed $value
@param string $group
@param string $environment
@param integer $website_id
@param string $type "array"|"string"|"integer"
@return Config | [
"Store",
"a",
"group",
"of",
"settings",
"into",
"the",
"database",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Config.php#L361-L436 |
13,469 | delatbabel/site-config | src/Models/Config.php | Config.buildArrayPath | protected static function buildArrayPath($map, $value, &$array)
{
$key = array_shift($map);
if (count($map) !== 0) {
$array[$key] = [];
self::buildArrayPath($map, $value, $array[$key]);
} else {
$array[$key] = $value;
}
} | php | protected static function buildArrayPath($map, $value, &$array)
{
$key = array_shift($map);
if (count($map) !== 0) {
$array[$key] = [];
self::buildArrayPath($map, $value, $array[$key]);
} else {
$array[$key] = $value;
}
} | [
"protected",
"static",
"function",
"buildArrayPath",
"(",
"$",
"map",
",",
"$",
"value",
",",
"&",
"$",
"array",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"map",
")",
";",
"if",
"(",
"count",
"(",
"$",
"map",
")",
"!==",
"0",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"self",
"::",
"buildArrayPath",
"(",
"$",
"map",
",",
"$",
"value",
",",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
]
| This inserts a value into an array at a point in the array path.
### Example
<code>
$map = [1, 2];
$value = 'hello';
$array = [];
buildArrayPath($map, $value, $array);
// $array is now [1 => [2 => 'hello']]
</code>
@param array $map
@param mixed $value
@param $array
@return void | [
"This",
"inserts",
"a",
"value",
"into",
"an",
"array",
"at",
"a",
"point",
"in",
"the",
"array",
"path",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Config.php#L457-L466 |
13,470 | webbuilders-group/silverstripe-gridfield-deleted-items | src/Forms/GridFieldDeletedDeleteAction.php | GridFieldDeletedDeleteAction.getColumnContent | public function getColumnContent($gridField, $record, $columnName) {
if(!DataObject::has_extension($gridField->getModelClass(), Versioned::class)) {
user_error($gridField->getModelClass().' does not have the Versioned extension', E_USER_WARNING);
return;
}
$isDeletedFromDraft=(!$record->hasMethod('isOnDraft') ? $record->isOnLiveOnly():!$record->isOnDraft());
if($gridField->State->ListDisplayMode->ShowDeletedItems=='Y' && $isDeletedFromDraft) {
return;
}
return parent::getColumnContent($gridField, $record, $columnName);
} | php | public function getColumnContent($gridField, $record, $columnName) {
if(!DataObject::has_extension($gridField->getModelClass(), Versioned::class)) {
user_error($gridField->getModelClass().' does not have the Versioned extension', E_USER_WARNING);
return;
}
$isDeletedFromDraft=(!$record->hasMethod('isOnDraft') ? $record->isOnLiveOnly():!$record->isOnDraft());
if($gridField->State->ListDisplayMode->ShowDeletedItems=='Y' && $isDeletedFromDraft) {
return;
}
return parent::getColumnContent($gridField, $record, $columnName);
} | [
"public",
"function",
"getColumnContent",
"(",
"$",
"gridField",
",",
"$",
"record",
",",
"$",
"columnName",
")",
"{",
"if",
"(",
"!",
"DataObject",
"::",
"has_extension",
"(",
"$",
"gridField",
"->",
"getModelClass",
"(",
")",
",",
"Versioned",
"::",
"class",
")",
")",
"{",
"user_error",
"(",
"$",
"gridField",
"->",
"getModelClass",
"(",
")",
".",
"' does not have the Versioned extension'",
",",
"E_USER_WARNING",
")",
";",
"return",
";",
"}",
"$",
"isDeletedFromDraft",
"=",
"(",
"!",
"$",
"record",
"->",
"hasMethod",
"(",
"'isOnDraft'",
")",
"?",
"$",
"record",
"->",
"isOnLiveOnly",
"(",
")",
":",
"!",
"$",
"record",
"->",
"isOnDraft",
"(",
")",
")",
";",
"if",
"(",
"$",
"gridField",
"->",
"State",
"->",
"ListDisplayMode",
"->",
"ShowDeletedItems",
"==",
"'Y'",
"&&",
"$",
"isDeletedFromDraft",
")",
"{",
"return",
";",
"}",
"return",
"parent",
"::",
"getColumnContent",
"(",
"$",
"gridField",
",",
"$",
"record",
",",
"$",
"columnName",
")",
";",
"}"
]
| Gets the content for the column, this basically says if it's deleted from the stage you can't delete it
@param GridField $gridField Grid Field Reference
@param DataObject $record Current data object being rendered
@param string $columnName Name of the column
@return string The HTML for the column | [
"Gets",
"the",
"content",
"for",
"the",
"column",
"this",
"basically",
"says",
"if",
"it",
"s",
"deleted",
"from",
"the",
"stage",
"you",
"can",
"t",
"delete",
"it"
]
| fd4e90701357de00acf06f4b820b745817f4ce9c | https://github.com/webbuilders-group/silverstripe-gridfield-deleted-items/blob/fd4e90701357de00acf06f4b820b745817f4ce9c/src/Forms/GridFieldDeletedDeleteAction.php#L16-L29 |
13,471 | ptlis/conneg | src/Parser/FieldTokenizer.php | FieldTokenizer.tokenize | public function tokenize($httpField, $fromField)
{
$quoteSeparators = array('"', "'");
$tokenList = array();
$stringAccumulator = '';
$lastQuote = '';
// Iterate through field, character-by-character
for ($i = 0; $i < strlen($httpField); $i++) {
$chr = substr($httpField, $i, 1);
switch (true) {
// We are at the end of a quoted string
case $chr === $lastQuote:
$tokenList[] = $stringAccumulator;
$stringAccumulator = '';
$lastQuote = '';
break;
// We have found the beginning of a quoted string
case in_array($chr, $quoteSeparators):
$lastQuote = $chr;
break;
// We are already within a quoted string, but not yet at the end
case strlen($lastQuote):
$stringAccumulator .= $chr;
break;
// Separators found, add previously accumulated string & separator to token list
case Tokens::isSeparator($chr, Preference::MIME === $fromField):
if (strlen($stringAccumulator)) {
$tokenList[] = $stringAccumulator;
$stringAccumulator = '';
}
$tokenList[] = $chr;
break;
// Simply accumulate characters
default:
$stringAccumulator .= $chr;
break;
}
}
// Handle final component
if (strlen($stringAccumulator)) {
$tokenList[] = $stringAccumulator;
}
// Remove any padding whitespace from token list
$tokenList = array_map('trim', $tokenList);
return $tokenList;
} | php | public function tokenize($httpField, $fromField)
{
$quoteSeparators = array('"', "'");
$tokenList = array();
$stringAccumulator = '';
$lastQuote = '';
// Iterate through field, character-by-character
for ($i = 0; $i < strlen($httpField); $i++) {
$chr = substr($httpField, $i, 1);
switch (true) {
// We are at the end of a quoted string
case $chr === $lastQuote:
$tokenList[] = $stringAccumulator;
$stringAccumulator = '';
$lastQuote = '';
break;
// We have found the beginning of a quoted string
case in_array($chr, $quoteSeparators):
$lastQuote = $chr;
break;
// We are already within a quoted string, but not yet at the end
case strlen($lastQuote):
$stringAccumulator .= $chr;
break;
// Separators found, add previously accumulated string & separator to token list
case Tokens::isSeparator($chr, Preference::MIME === $fromField):
if (strlen($stringAccumulator)) {
$tokenList[] = $stringAccumulator;
$stringAccumulator = '';
}
$tokenList[] = $chr;
break;
// Simply accumulate characters
default:
$stringAccumulator .= $chr;
break;
}
}
// Handle final component
if (strlen($stringAccumulator)) {
$tokenList[] = $stringAccumulator;
}
// Remove any padding whitespace from token list
$tokenList = array_map('trim', $tokenList);
return $tokenList;
} | [
"public",
"function",
"tokenize",
"(",
"$",
"httpField",
",",
"$",
"fromField",
")",
"{",
"$",
"quoteSeparators",
"=",
"array",
"(",
"'\"'",
",",
"\"'\"",
")",
";",
"$",
"tokenList",
"=",
"array",
"(",
")",
";",
"$",
"stringAccumulator",
"=",
"''",
";",
"$",
"lastQuote",
"=",
"''",
";",
"// Iterate through field, character-by-character",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"httpField",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"chr",
"=",
"substr",
"(",
"$",
"httpField",
",",
"$",
"i",
",",
"1",
")",
";",
"switch",
"(",
"true",
")",
"{",
"// We are at the end of a quoted string",
"case",
"$",
"chr",
"===",
"$",
"lastQuote",
":",
"$",
"tokenList",
"[",
"]",
"=",
"$",
"stringAccumulator",
";",
"$",
"stringAccumulator",
"=",
"''",
";",
"$",
"lastQuote",
"=",
"''",
";",
"break",
";",
"// We have found the beginning of a quoted string",
"case",
"in_array",
"(",
"$",
"chr",
",",
"$",
"quoteSeparators",
")",
":",
"$",
"lastQuote",
"=",
"$",
"chr",
";",
"break",
";",
"// We are already within a quoted string, but not yet at the end",
"case",
"strlen",
"(",
"$",
"lastQuote",
")",
":",
"$",
"stringAccumulator",
".=",
"$",
"chr",
";",
"break",
";",
"// Separators found, add previously accumulated string & separator to token list",
"case",
"Tokens",
"::",
"isSeparator",
"(",
"$",
"chr",
",",
"Preference",
"::",
"MIME",
"===",
"$",
"fromField",
")",
":",
"if",
"(",
"strlen",
"(",
"$",
"stringAccumulator",
")",
")",
"{",
"$",
"tokenList",
"[",
"]",
"=",
"$",
"stringAccumulator",
";",
"$",
"stringAccumulator",
"=",
"''",
";",
"}",
"$",
"tokenList",
"[",
"]",
"=",
"$",
"chr",
";",
"break",
";",
"// Simply accumulate characters",
"default",
":",
"$",
"stringAccumulator",
".=",
"$",
"chr",
";",
"break",
";",
"}",
"}",
"// Handle final component",
"if",
"(",
"strlen",
"(",
"$",
"stringAccumulator",
")",
")",
"{",
"$",
"tokenList",
"[",
"]",
"=",
"$",
"stringAccumulator",
";",
"}",
"// Remove any padding whitespace from token list",
"$",
"tokenList",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"tokenList",
")",
";",
"return",
"$",
"tokenList",
";",
"}"
]
| Tokenize the HTTP field for subsequent processing.
Note: we don't need to worry about multi-byte characters; HTTP fields must be ISO-8859-1 encoded.
@param string $httpField
@param string $fromField
@return array<string> | [
"Tokenize",
"the",
"HTTP",
"field",
"for",
"subsequent",
"processing",
"."
]
| 04afb568f368ecdd81c13277006c4be041ccb58b | https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Parser/FieldTokenizer.php#L28-L84 |
13,472 | sifophp/sifo-common-instance | controllers/manager/templateLauncher.php | ManagerTemplateLauncherController._getRequiredVars | private function _getRequiredVars( $template_identifier )
{
if ( !( isset( $this->_available_templates[$template_identifier] ) ) )
{
trigger_error( "Template identifier not found.", E_USER_ERROR );
}
$template_path = ROOT_PATH.'/'.$this->_available_templates[$template_identifier];
if ( !( $template_source = file_get_contents( $template_path ) ) )
{
trigger_error( "{$template_path} not found.", E_USER_ERROR );
}
if ( !( preg_match_all( '/{.*\$([a-z_\-]*).*}/', $template_source, $matchs) ) )
{
trigger_error( "Not found in use vars in the tpl source.", E_USER_WARNING );
}
$required_vars = array_unique( $matchs[1] );
// Remove url.
unset( $required_vars[array_search( 'url', $required_vars )] );
return $required_vars;
} | php | private function _getRequiredVars( $template_identifier )
{
if ( !( isset( $this->_available_templates[$template_identifier] ) ) )
{
trigger_error( "Template identifier not found.", E_USER_ERROR );
}
$template_path = ROOT_PATH.'/'.$this->_available_templates[$template_identifier];
if ( !( $template_source = file_get_contents( $template_path ) ) )
{
trigger_error( "{$template_path} not found.", E_USER_ERROR );
}
if ( !( preg_match_all( '/{.*\$([a-z_\-]*).*}/', $template_source, $matchs) ) )
{
trigger_error( "Not found in use vars in the tpl source.", E_USER_WARNING );
}
$required_vars = array_unique( $matchs[1] );
// Remove url.
unset( $required_vars[array_search( 'url', $required_vars )] );
return $required_vars;
} | [
"private",
"function",
"_getRequiredVars",
"(",
"$",
"template_identifier",
")",
"{",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"this",
"->",
"_available_templates",
"[",
"$",
"template_identifier",
"]",
")",
")",
")",
"{",
"trigger_error",
"(",
"\"Template identifier not found.\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"$",
"template_path",
"=",
"ROOT_PATH",
".",
"'/'",
".",
"$",
"this",
"->",
"_available_templates",
"[",
"$",
"template_identifier",
"]",
";",
"if",
"(",
"!",
"(",
"$",
"template_source",
"=",
"file_get_contents",
"(",
"$",
"template_path",
")",
")",
")",
"{",
"trigger_error",
"(",
"\"{$template_path} not found.\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"!",
"(",
"preg_match_all",
"(",
"'/{.*\\$([a-z_\\-]*).*}/'",
",",
"$",
"template_source",
",",
"$",
"matchs",
")",
")",
")",
"{",
"trigger_error",
"(",
"\"Not found in use vars in the tpl source.\"",
",",
"E_USER_WARNING",
")",
";",
"}",
"$",
"required_vars",
"=",
"array_unique",
"(",
"$",
"matchs",
"[",
"1",
"]",
")",
";",
"// Remove url.",
"unset",
"(",
"$",
"required_vars",
"[",
"array_search",
"(",
"'url'",
",",
"$",
"required_vars",
")",
"]",
")",
";",
"return",
"$",
"required_vars",
";",
"}"
]
| Return the found in use vars in tpl.
@param $template_identifier
@return array | [
"Return",
"the",
"found",
"in",
"use",
"vars",
"in",
"tpl",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/manager/templateLauncher.php#L17-L42 |
13,473 | joomla-projects/jorobo | src/Tasks/Build/Package.php | Package.createInstaller | private function createInstaller()
{
$this->say("Creating package installer");
// Copy XML and script.php
$sourceFolder = $this->getSourceFolder() . "/administrator/manifests/packages";
$targetFolder = $this->getBuildFolder() . "/administrator/manifests/packages";
$xmlFile = $targetFolder . "/pkg_" . $this->getExtensionName() . ".xml";
$scriptFile = $targetFolder . "/" . $this->getExtensionName() . "/script.php";
$this->_copy($sourceFolder . "/pkg_" . $this->getExtensionName() . ".xml", $xmlFile);
// Version & Date Replace
$this->taskReplaceInFile($xmlFile)
->from(array('##DATE##', '##YEAR##', '##VERSION##'))
->to(array($this->getDate(), date('Y'), $this->getJConfig()->version))
->run();
if (is_file($sourceFolder . "/" . $this->getExtensionName() . "/script.php"))
{
$this->_copy($sourceFolder . "/" . $this->getExtensionName() . "/script.php", $scriptFile);
$this->taskReplaceInFile($scriptFile)
->from(array('##DATE##', '##YEAR##', '##VERSION##'))
->to(array($this->getDate(), date('Y'), $this->getJConfig()->version))
->run();
}
// Language files
$f = $this->generateLanguageFileList($this->getFiles('frontendLanguage'));
$this->taskReplaceInFile($xmlFile)
->from('##LANGUAGE_FILES##')
->to($f)
->run();
} | php | private function createInstaller()
{
$this->say("Creating package installer");
// Copy XML and script.php
$sourceFolder = $this->getSourceFolder() . "/administrator/manifests/packages";
$targetFolder = $this->getBuildFolder() . "/administrator/manifests/packages";
$xmlFile = $targetFolder . "/pkg_" . $this->getExtensionName() . ".xml";
$scriptFile = $targetFolder . "/" . $this->getExtensionName() . "/script.php";
$this->_copy($sourceFolder . "/pkg_" . $this->getExtensionName() . ".xml", $xmlFile);
// Version & Date Replace
$this->taskReplaceInFile($xmlFile)
->from(array('##DATE##', '##YEAR##', '##VERSION##'))
->to(array($this->getDate(), date('Y'), $this->getJConfig()->version))
->run();
if (is_file($sourceFolder . "/" . $this->getExtensionName() . "/script.php"))
{
$this->_copy($sourceFolder . "/" . $this->getExtensionName() . "/script.php", $scriptFile);
$this->taskReplaceInFile($scriptFile)
->from(array('##DATE##', '##YEAR##', '##VERSION##'))
->to(array($this->getDate(), date('Y'), $this->getJConfig()->version))
->run();
}
// Language files
$f = $this->generateLanguageFileList($this->getFiles('frontendLanguage'));
$this->taskReplaceInFile($xmlFile)
->from('##LANGUAGE_FILES##')
->to($f)
->run();
} | [
"private",
"function",
"createInstaller",
"(",
")",
"{",
"$",
"this",
"->",
"say",
"(",
"\"Creating package installer\"",
")",
";",
"// Copy XML and script.php",
"$",
"sourceFolder",
"=",
"$",
"this",
"->",
"getSourceFolder",
"(",
")",
".",
"\"/administrator/manifests/packages\"",
";",
"$",
"targetFolder",
"=",
"$",
"this",
"->",
"getBuildFolder",
"(",
")",
".",
"\"/administrator/manifests/packages\"",
";",
"$",
"xmlFile",
"=",
"$",
"targetFolder",
".",
"\"/pkg_\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
".",
"\".xml\"",
";",
"$",
"scriptFile",
"=",
"$",
"targetFolder",
".",
"\"/\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
".",
"\"/script.php\"",
";",
"$",
"this",
"->",
"_copy",
"(",
"$",
"sourceFolder",
".",
"\"/pkg_\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
".",
"\".xml\"",
",",
"$",
"xmlFile",
")",
";",
"// Version & Date Replace",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"array",
"(",
"'##DATE##'",
",",
"'##YEAR##'",
",",
"'##VERSION##'",
")",
")",
"->",
"to",
"(",
"array",
"(",
"$",
"this",
"->",
"getDate",
"(",
")",
",",
"date",
"(",
"'Y'",
")",
",",
"$",
"this",
"->",
"getJConfig",
"(",
")",
"->",
"version",
")",
")",
"->",
"run",
"(",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"sourceFolder",
".",
"\"/\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
".",
"\"/script.php\"",
")",
")",
"{",
"$",
"this",
"->",
"_copy",
"(",
"$",
"sourceFolder",
".",
"\"/\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
".",
"\"/script.php\"",
",",
"$",
"scriptFile",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"scriptFile",
")",
"->",
"from",
"(",
"array",
"(",
"'##DATE##'",
",",
"'##YEAR##'",
",",
"'##VERSION##'",
")",
")",
"->",
"to",
"(",
"array",
"(",
"$",
"this",
"->",
"getDate",
"(",
")",
",",
"date",
"(",
"'Y'",
")",
",",
"$",
"this",
"->",
"getJConfig",
"(",
")",
"->",
"version",
")",
")",
"->",
"run",
"(",
")",
";",
"}",
"// Language files",
"$",
"f",
"=",
"$",
"this",
"->",
"generateLanguageFileList",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"'frontendLanguage'",
")",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"'##LANGUAGE_FILES##'",
")",
"->",
"to",
"(",
"$",
"f",
")",
"->",
"run",
"(",
")",
";",
"}"
]
| Generate the installer xml file for the package
@return void
@since 1.0 | [
"Generate",
"the",
"installer",
"xml",
"file",
"for",
"the",
"package"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Package.php#L72-L107 |
13,474 | FWidm/dwd-hourly-crawler | src/fwidm/dwdHourlyCrawler/DWDConfiguration.php | DWDConfiguration.getConfiguration | public static function getConfiguration()
{
if (self::$configuration === null && file_exists(self::$configFilePath)) {
// $jsonConfig = file_get_contents(self::$configFilePath_depr);
// self::$configuration = json_decode($jsonConfig);
$settings = include __DIR__ . '/../../config/configuration.php';
self::$configuration = DWDUtil::array_to_object($settings);
if (DWDConfiguration::$configuration === null)
throw new ParseError('Error, configuration file could not be found or contains invalid lines.');
}
return DWDConfiguration::$configuration;
} | php | public static function getConfiguration()
{
if (self::$configuration === null && file_exists(self::$configFilePath)) {
// $jsonConfig = file_get_contents(self::$configFilePath_depr);
// self::$configuration = json_decode($jsonConfig);
$settings = include __DIR__ . '/../../config/configuration.php';
self::$configuration = DWDUtil::array_to_object($settings);
if (DWDConfiguration::$configuration === null)
throw new ParseError('Error, configuration file could not be found or contains invalid lines.');
}
return DWDConfiguration::$configuration;
} | [
"public",
"static",
"function",
"getConfiguration",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"configuration",
"===",
"null",
"&&",
"file_exists",
"(",
"self",
"::",
"$",
"configFilePath",
")",
")",
"{",
"// $jsonConfig = file_get_contents(self::$configFilePath_depr);",
"// self::$configuration = json_decode($jsonConfig);",
"$",
"settings",
"=",
"include",
"__DIR__",
".",
"'/../../config/configuration.php'",
";",
"self",
"::",
"$",
"configuration",
"=",
"DWDUtil",
"::",
"array_to_object",
"(",
"$",
"settings",
")",
";",
"if",
"(",
"DWDConfiguration",
"::",
"$",
"configuration",
"===",
"null",
")",
"throw",
"new",
"ParseError",
"(",
"'Error, configuration file could not be found or contains invalid lines.'",
")",
";",
"}",
"return",
"DWDConfiguration",
"::",
"$",
"configuration",
";",
"}"
]
| Returns the complete configuration file to the callee
@return mixed | [
"Returns",
"the",
"complete",
"configuration",
"file",
"to",
"the",
"callee"
]
| 36dec7d84a85af599e9d4fb6a3bcc302378ce4a8 | https://github.com/FWidm/dwd-hourly-crawler/blob/36dec7d84a85af599e9d4fb6a3bcc302378ce4a8/src/fwidm/dwdHourlyCrawler/DWDConfiguration.php#L48-L63 |
13,475 | sebastiaanluca/laravel-validator | src/Validators/Validator.php | Validator.getValidInput | public function getValidInput($clean = false)
{
$input = array_dot($this->all());
$rules = array_keys($this->rules());
$keys = collect($rules)->map(function (string $rule) use ($input) {
// Transform each rule to a regex string while supporting
// the wildcard (*) character to include sequential arrays too.
$regex = '/^' . str_replace(['.', '*'], ['\.', '(.*)'], $rule) . '$/';
// Match the regex string against our input fields
return preg_grep($regex, array_keys($input));
});
// Match the input attributes against the existing rules
$input = array_only($input, $keys->flatten()->toArray());
// Reverse dot flattening to match original input
$expanded = [];
foreach ($input as $key => $value) {
array_set($expanded, $key, $value);
}
if ($clean) {
$expanded = $this->sanitizeInput($expanded);
}
return $expanded;
} | php | public function getValidInput($clean = false)
{
$input = array_dot($this->all());
$rules = array_keys($this->rules());
$keys = collect($rules)->map(function (string $rule) use ($input) {
// Transform each rule to a regex string while supporting
// the wildcard (*) character to include sequential arrays too.
$regex = '/^' . str_replace(['.', '*'], ['\.', '(.*)'], $rule) . '$/';
// Match the regex string against our input fields
return preg_grep($regex, array_keys($input));
});
// Match the input attributes against the existing rules
$input = array_only($input, $keys->flatten()->toArray());
// Reverse dot flattening to match original input
$expanded = [];
foreach ($input as $key => $value) {
array_set($expanded, $key, $value);
}
if ($clean) {
$expanded = $this->sanitizeInput($expanded);
}
return $expanded;
} | [
"public",
"function",
"getValidInput",
"(",
"$",
"clean",
"=",
"false",
")",
"{",
"$",
"input",
"=",
"array_dot",
"(",
"$",
"this",
"->",
"all",
"(",
")",
")",
";",
"$",
"rules",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"rules",
"(",
")",
")",
";",
"$",
"keys",
"=",
"collect",
"(",
"$",
"rules",
")",
"->",
"map",
"(",
"function",
"(",
"string",
"$",
"rule",
")",
"use",
"(",
"$",
"input",
")",
"{",
"// Transform each rule to a regex string while supporting",
"// the wildcard (*) character to include sequential arrays too.",
"$",
"regex",
"=",
"'/^'",
".",
"str_replace",
"(",
"[",
"'.'",
",",
"'*'",
"]",
",",
"[",
"'\\.'",
",",
"'(.*)'",
"]",
",",
"$",
"rule",
")",
".",
"'$/'",
";",
"// Match the regex string against our input fields",
"return",
"preg_grep",
"(",
"$",
"regex",
",",
"array_keys",
"(",
"$",
"input",
")",
")",
";",
"}",
")",
";",
"// Match the input attributes against the existing rules",
"$",
"input",
"=",
"array_only",
"(",
"$",
"input",
",",
"$",
"keys",
"->",
"flatten",
"(",
")",
"->",
"toArray",
"(",
")",
")",
";",
"// Reverse dot flattening to match original input",
"$",
"expanded",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"array_set",
"(",
"$",
"expanded",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"clean",
")",
"{",
"$",
"expanded",
"=",
"$",
"this",
"->",
"sanitizeInput",
"(",
"$",
"expanded",
")",
";",
"}",
"return",
"$",
"expanded",
";",
"}"
]
| Get validated user input.
Check if input corresponds with fields under validation.
@param bool $clean Remove the input fields whose values are empty.
@return array | [
"Get",
"validated",
"user",
"input",
"."
]
| 931b60cfeb2fd4d93a4525d8575ae72825a73fa9 | https://github.com/sebastiaanluca/laravel-validator/blob/931b60cfeb2fd4d93a4525d8575ae72825a73fa9/src/Validators/Validator.php#L35-L64 |
13,476 | sebastiaanluca/laravel-validator | src/Validators/Validator.php | Validator.sanitizeInput | public function sanitizeInput(array $input)
{
return $input = collect($input)->reject(function ($value) {
return is_null($value) || empty($value);
})->toArray();
} | php | public function sanitizeInput(array $input)
{
return $input = collect($input)->reject(function ($value) {
return is_null($value) || empty($value);
})->toArray();
} | [
"public",
"function",
"sanitizeInput",
"(",
"array",
"$",
"input",
")",
"{",
"return",
"$",
"input",
"=",
"collect",
"(",
"$",
"input",
")",
"->",
"reject",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"is_null",
"(",
"$",
"value",
")",
"||",
"empty",
"(",
"$",
"value",
")",
";",
"}",
")",
"->",
"toArray",
"(",
")",
";",
"}"
]
| Remove null and empty values from the input.
@param array $input
@return array | [
"Remove",
"null",
"and",
"empty",
"values",
"from",
"the",
"input",
"."
]
| 931b60cfeb2fd4d93a4525d8575ae72825a73fa9 | https://github.com/sebastiaanluca/laravel-validator/blob/931b60cfeb2fd4d93a4525d8575ae72825a73fa9/src/Validators/Validator.php#L87-L92 |
13,477 | Im0rtality/Underscore | src/Registry.php | Registry.instance | public function instance($name)
{
if (empty($this->instances[$name])) {
if (empty($this->aliases[$name])) {
$this->aliasDefault($name);
}
$this->instances[$name] = new $this->aliases[$name];
}
return $this->instances[$name];
} | php | public function instance($name)
{
if (empty($this->instances[$name])) {
if (empty($this->aliases[$name])) {
$this->aliasDefault($name);
}
$this->instances[$name] = new $this->aliases[$name];
}
return $this->instances[$name];
} | [
"public",
"function",
"instance",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"aliasDefault",
"(",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
"=",
"new",
"$",
"this",
"->",
"aliases",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
]
| Get the callable for an Underscore method alias.
@param string $name
@return callable | [
"Get",
"the",
"callable",
"for",
"an",
"Underscore",
"method",
"alias",
"."
]
| 2deb95cfd340761d00ecd0f033e67ce600f2b535 | https://github.com/Im0rtality/Underscore/blob/2deb95cfd340761d00ecd0f033e67ce600f2b535/src/Registry.php#L52-L62 |
13,478 | Im0rtality/Underscore | src/Registry.php | Registry.alias | public function alias($name, $spec)
{
if (is_callable($spec)) {
$this->instances[$name] = $spec;
} else {
$this->aliases[$name] = $spec;
// Ensure that the new alias will be used when called.
unset($this->instances[$name]);
}
} | php | public function alias($name, $spec)
{
if (is_callable($spec)) {
$this->instances[$name] = $spec;
} else {
$this->aliases[$name] = $spec;
// Ensure that the new alias will be used when called.
unset($this->instances[$name]);
}
} | [
"public",
"function",
"alias",
"(",
"$",
"name",
",",
"$",
"spec",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
"=",
"$",
"spec",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aliases",
"[",
"$",
"name",
"]",
"=",
"$",
"spec",
";",
"// Ensure that the new alias will be used when called.",
"unset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}"
]
| Alias method name to a callable.
@param string $name
@param callable $spec
@return void | [
"Alias",
"method",
"name",
"to",
"a",
"callable",
"."
]
| 2deb95cfd340761d00ecd0f033e67ce600f2b535 | https://github.com/Im0rtality/Underscore/blob/2deb95cfd340761d00ecd0f033e67ce600f2b535/src/Registry.php#L71-L81 |
13,479 | Im0rtality/Underscore | src/Registry.php | Registry.aliasDefault | private function aliasDefault($name)
{
$spec = sprintf('\Underscore\Mutator\%sMutator', ucfirst($name));
if (!class_exists($spec)) {
$spec = sprintf('\Underscore\Accessor\%sAccessor', ucfirst($name));
}
if (!class_exists($spec)) {
$spec = sprintf('\Underscore\Initializer\%sInitializer', ucfirst($name));
}
if (!class_exists($spec)) {
throw new \BadMethodCallException(sprintf('Unknown method Underscore->%s()', $name));
}
$this->aliases[$name] = $spec;
} | php | private function aliasDefault($name)
{
$spec = sprintf('\Underscore\Mutator\%sMutator', ucfirst($name));
if (!class_exists($spec)) {
$spec = sprintf('\Underscore\Accessor\%sAccessor', ucfirst($name));
}
if (!class_exists($spec)) {
$spec = sprintf('\Underscore\Initializer\%sInitializer', ucfirst($name));
}
if (!class_exists($spec)) {
throw new \BadMethodCallException(sprintf('Unknown method Underscore->%s()', $name));
}
$this->aliases[$name] = $spec;
} | [
"private",
"function",
"aliasDefault",
"(",
"$",
"name",
")",
"{",
"$",
"spec",
"=",
"sprintf",
"(",
"'\\Underscore\\Mutator\\%sMutator'",
",",
"ucfirst",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"sprintf",
"(",
"'\\Underscore\\Accessor\\%sAccessor'",
",",
"ucfirst",
"(",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"sprintf",
"(",
"'\\Underscore\\Initializer\\%sInitializer'",
",",
"ucfirst",
"(",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"spec",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"sprintf",
"(",
"'Unknown method Underscore->%s()'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"aliases",
"[",
"$",
"name",
"]",
"=",
"$",
"spec",
";",
"}"
]
| Define a default mutator, accessor, or initializer for a method name.
@throws \BadMethodCallException If no default can be located.
@param string $name
@return void | [
"Define",
"a",
"default",
"mutator",
"accessor",
"or",
"initializer",
"for",
"a",
"method",
"name",
"."
]
| 2deb95cfd340761d00ecd0f033e67ce600f2b535 | https://github.com/Im0rtality/Underscore/blob/2deb95cfd340761d00ecd0f033e67ce600f2b535/src/Registry.php#L90-L107 |
13,480 | attm2x/m2x-php | src/Command.php | Command.refresh | public function refresh() {
$response = $this->client->get($this->path());
$this->setData($response->json());
} | php | public function refresh() {
$response = $this->client->get($this->path());
$this->setData($response->json());
} | [
"public",
"function",
"refresh",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"path",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"$",
"response",
"->",
"json",
"(",
")",
")",
";",
"}"
]
| Refresh the Command Info | [
"Refresh",
"the",
"Command",
"Info"
]
| 4c2ff6d70af50538818855e648af24bf5cf16ead | https://github.com/attm2x/m2x-php/blob/4c2ff6d70af50538818855e648af24bf5cf16ead/src/Command.php#L41-L44 |
13,481 | psecio/propauth | src/Policy.php | Policy.addCheck | protected function addCheck($name, $type, $args)
{
$func = $type.'Check';
if (method_exists($this, $func)) {
$type = strtolower(str_replace($type, '', $name));
$this->$func($type, $name, $args);
} else {
throw new \InvalidArgumentException('Invalid check type: '.$type);
}
} | php | protected function addCheck($name, $type, $args)
{
$func = $type.'Check';
if (method_exists($this, $func)) {
$type = strtolower(str_replace($type, '', $name));
$this->$func($type, $name, $args);
} else {
throw new \InvalidArgumentException('Invalid check type: '.$type);
}
} | [
"protected",
"function",
"addCheck",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"args",
")",
"{",
"$",
"func",
"=",
"$",
"type",
".",
"'Check'",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"func",
")",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"str_replace",
"(",
"$",
"type",
",",
"''",
",",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"$",
"func",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"args",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid check type: '",
".",
"$",
"type",
")",
";",
"}",
"}"
]
| Add a new check to the set
@param string $name Function name
@param string $type Check type
@param array $args Check arguments
@throws \InvalidArgumentException If check type is invalid | [
"Add",
"a",
"new",
"check",
"to",
"the",
"set"
]
| cb24fcc0a3fa459f2ef40a867c334951aabf7b83 | https://github.com/psecio/propauth/blob/cb24fcc0a3fa459f2ef40a867c334951aabf7b83/src/Policy.php#L94-L104 |
13,482 | psecio/propauth | src/Policy.php | Policy.load | public static function load($dslString)
{
$policy = self::instance();
$parts = explode('||', $dslString);
foreach ($parts as $match) {
$args = [];
list($method, $value) = explode(':', $match);
// if we have data following the ":" inside (), array it
if (preg_match('/:\((.+?)\)/', $match, $matches) > 0) {
if (isset($matches[1])) {
$value = explode(',', $matches[1]);
}
}
$args[] = $value;
// Finally, see if we have a modifier
if (preg_match('/\[(.+?)\]$/', $match, $matches) > 0) {
if (isset($matches[1])) {
$args[] = strtolower($matches[1]);
}
}
call_user_func_array([$policy, $method], $args);
}
return $policy;
} | php | public static function load($dslString)
{
$policy = self::instance();
$parts = explode('||', $dslString);
foreach ($parts as $match) {
$args = [];
list($method, $value) = explode(':', $match);
// if we have data following the ":" inside (), array it
if (preg_match('/:\((.+?)\)/', $match, $matches) > 0) {
if (isset($matches[1])) {
$value = explode(',', $matches[1]);
}
}
$args[] = $value;
// Finally, see if we have a modifier
if (preg_match('/\[(.+?)\]$/', $match, $matches) > 0) {
if (isset($matches[1])) {
$args[] = strtolower($matches[1]);
}
}
call_user_func_array([$policy, $method], $args);
}
return $policy;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"dslString",
")",
"{",
"$",
"policy",
"=",
"self",
"::",
"instance",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'||'",
",",
"$",
"dslString",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"match",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"list",
"(",
"$",
"method",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"match",
")",
";",
"// if we have data following the \":\" inside (), array it",
"if",
"(",
"preg_match",
"(",
"'/:\\((.+?)\\)/'",
",",
"$",
"match",
",",
"$",
"matches",
")",
">",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"','",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"}",
"$",
"args",
"[",
"]",
"=",
"$",
"value",
";",
"// Finally, see if we have a modifier",
"if",
"(",
"preg_match",
"(",
"'/\\[(.+?)\\]$/'",
",",
"$",
"match",
",",
"$",
"matches",
")",
">",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"strtolower",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"}",
"call_user_func_array",
"(",
"[",
"$",
"policy",
",",
"$",
"method",
"]",
",",
"$",
"args",
")",
";",
"}",
"return",
"$",
"policy",
";",
"}"
]
| Load a policy from a string DSL
See the README for formatting
@param string $dslString DSL formatted string | [
"Load",
"a",
"policy",
"from",
"a",
"string",
"DSL",
"See",
"the",
"README",
"for",
"formatting"
]
| cb24fcc0a3fa459f2ef40a867c334951aabf7b83 | https://github.com/psecio/propauth/blob/cb24fcc0a3fa459f2ef40a867c334951aabf7b83/src/Policy.php#L122-L150 |
13,483 | psecio/propauth | src/Policy.php | Policy.check | private function check($matchType, $type, $name, $args)
{
$value = array_shift($args);
if (!isset($args[0])) {
$args[0] = ['rule' => Policy::ANY];
}
// see what other options we've been given
if (is_string($args[0]) && ($args[0] === Policy::ANY || $args[0] === Policy::ALL) ) {
$args['rule'] = $args[0];
unset($args[0]);
} elseif (is_array($args[0])) {
$args = $args[0];
}
$this->checks[$type][] = new Check($matchType, $value, $args);
} | php | private function check($matchType, $type, $name, $args)
{
$value = array_shift($args);
if (!isset($args[0])) {
$args[0] = ['rule' => Policy::ANY];
}
// see what other options we've been given
if (is_string($args[0]) && ($args[0] === Policy::ANY || $args[0] === Policy::ALL) ) {
$args['rule'] = $args[0];
unset($args[0]);
} elseif (is_array($args[0])) {
$args = $args[0];
}
$this->checks[$type][] = new Check($matchType, $value, $args);
} | [
"private",
"function",
"check",
"(",
"$",
"matchType",
",",
"$",
"type",
",",
"$",
"name",
",",
"$",
"args",
")",
"{",
"$",
"value",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"args",
"[",
"0",
"]",
"=",
"[",
"'rule'",
"=>",
"Policy",
"::",
"ANY",
"]",
";",
"}",
"// see what other options we've been given",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"&&",
"(",
"$",
"args",
"[",
"0",
"]",
"===",
"Policy",
"::",
"ANY",
"||",
"$",
"args",
"[",
"0",
"]",
"===",
"Policy",
"::",
"ALL",
")",
")",
"{",
"$",
"args",
"[",
"'rule'",
"]",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"unset",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"args",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"$",
"this",
"->",
"checks",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"new",
"Check",
"(",
"$",
"matchType",
",",
"$",
"value",
",",
"$",
"args",
")",
";",
"}"
]
| Add a new check to the current set for the policy
@param string $matchType Match type
@param string $type Type of check
@param string $name Name for the check
@param array $args Additional arguments for the check | [
"Add",
"a",
"new",
"check",
"to",
"the",
"current",
"set",
"for",
"the",
"policy"
]
| cb24fcc0a3fa459f2ef40a867c334951aabf7b83 | https://github.com/psecio/propauth/blob/cb24fcc0a3fa459f2ef40a867c334951aabf7b83/src/Policy.php#L172-L189 |
13,484 | psecio/propauth | src/Policy.php | Policy.cannotCheck | private function cannotCheck($type, $name, $args)
{
if (isset($args[0]) && (is_object($args[0]) && get_class($args[0]) === 'Closure')) {
$type = 'closure';
$args[1] = $args[0];
} elseif (is_string($args[0]) && strpos($args[0], '::') !== false) {
$type = 'method';
}
$this->check('not-equals', $type, $name, $args);
} | php | private function cannotCheck($type, $name, $args)
{
if (isset($args[0]) && (is_object($args[0]) && get_class($args[0]) === 'Closure')) {
$type = 'closure';
$args[1] = $args[0];
} elseif (is_string($args[0]) && strpos($args[0], '::') !== false) {
$type = 'method';
}
$this->check('not-equals', $type, $name, $args);
} | [
"private",
"function",
"cannotCheck",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"args",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"&&",
"(",
"is_object",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"&&",
"get_class",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"===",
"'Closure'",
")",
")",
"{",
"$",
"type",
"=",
"'closure'",
";",
"$",
"args",
"[",
"1",
"]",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"&&",
"strpos",
"(",
"$",
"args",
"[",
"0",
"]",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"'method'",
";",
"}",
"$",
"this",
"->",
"check",
"(",
"'not-equals'",
",",
"$",
"type",
",",
"$",
"name",
",",
"$",
"args",
")",
";",
"}"
]
| Add a "cannot" check to the set
@param string $type Check type
@param string $name Name for the check
@param array $args Additional arguments | [
"Add",
"a",
"cannot",
"check",
"to",
"the",
"set"
]
| cb24fcc0a3fa459f2ef40a867c334951aabf7b83 | https://github.com/psecio/propauth/blob/cb24fcc0a3fa459f2ef40a867c334951aabf7b83/src/Policy.php#L228-L238 |
13,485 | terdia/legato-framework | src/Routing/Route.php | Route.add | public static function add($method, $target, $handler, $name = null)
{
array_push(static::$prefixRoutes, [
'method' => $method, 'target' => $target,
'handler' => $handler, 'name' => $name,
]);
} | php | public static function add($method, $target, $handler, $name = null)
{
array_push(static::$prefixRoutes, [
'method' => $method, 'target' => $target,
'handler' => $handler, 'name' => $name,
]);
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"method",
",",
"$",
"target",
",",
"$",
"handler",
",",
"$",
"name",
"=",
"null",
")",
"{",
"array_push",
"(",
"static",
"::",
"$",
"prefixRoutes",
",",
"[",
"'method'",
"=>",
"$",
"method",
",",
"'target'",
"=>",
"$",
"target",
",",
"'handler'",
"=>",
"$",
"handler",
",",
"'name'",
"=>",
"$",
"name",
",",
"]",
")",
";",
"}"
]
| Support method to add group of routes.
@param $method, HTTP Request method
@param $target, the route
@param $handler, Closure | Controller@method
@param $name, route name optional | [
"Support",
"method",
"to",
"add",
"group",
"of",
"routes",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Routing/Route.php#L61-L67 |
13,486 | terdia/legato-framework | src/Routing/Route.php | Route.group | public static function group($prefix, Closure $callback)
{
$callback->call(new static());
foreach (static::$prefixRoutes as $key => $prefixRoute) {
$target = $prefix.$prefixRoute['target'];
$handler = $prefixRoute['handler'];
$name = $prefixRoute['name'];
unset(static::$prefixRoutes[$key]);
call_user_func_array(
[new static(), strtolower($prefixRoute['method'])],
[$target, $handler, $name]
);
}
} | php | public static function group($prefix, Closure $callback)
{
$callback->call(new static());
foreach (static::$prefixRoutes as $key => $prefixRoute) {
$target = $prefix.$prefixRoute['target'];
$handler = $prefixRoute['handler'];
$name = $prefixRoute['name'];
unset(static::$prefixRoutes[$key]);
call_user_func_array(
[new static(), strtolower($prefixRoute['method'])],
[$target, $handler, $name]
);
}
} | [
"public",
"static",
"function",
"group",
"(",
"$",
"prefix",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"callback",
"->",
"call",
"(",
"new",
"static",
"(",
")",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"prefixRoutes",
"as",
"$",
"key",
"=>",
"$",
"prefixRoute",
")",
"{",
"$",
"target",
"=",
"$",
"prefix",
".",
"$",
"prefixRoute",
"[",
"'target'",
"]",
";",
"$",
"handler",
"=",
"$",
"prefixRoute",
"[",
"'handler'",
"]",
";",
"$",
"name",
"=",
"$",
"prefixRoute",
"[",
"'name'",
"]",
";",
"unset",
"(",
"static",
"::",
"$",
"prefixRoutes",
"[",
"$",
"key",
"]",
")",
";",
"call_user_func_array",
"(",
"[",
"new",
"static",
"(",
")",
",",
"strtolower",
"(",
"$",
"prefixRoute",
"[",
"'method'",
"]",
")",
"]",
",",
"[",
"$",
"target",
",",
"$",
"handler",
",",
"$",
"name",
"]",
")",
";",
"}",
"}"
]
| Route Group.
@param $prefix
@param \Closure $callback | [
"Route",
"Group",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Routing/Route.php#L75-L90 |
13,487 | terdia/legato-framework | src/Routing/Route.php | Route.resource | public static function resource($target, $handler)
{
$route = $target;
$sanitized = str_replace('/', '', $target);
static::get($route, $handler.'@index', $sanitized.'_index');
static::get($target.'/create', $handler.'@showCreateForm', $sanitized.'_create_form');
static::post($target, $handler.'@save', $sanitized.'_save');
static::get($target.'/[i:id]', $handler.'@show', $sanitized.'_display');
static::get($target.'/[i:id]/edit', $handler.'@showEditForm', $sanitized.'_edit_form');
static::post($target.'/[i:id]', $handler.'@update', $sanitized.'_update');
static::get($target.'/[i:id]/delete', $handler.'@delete', $sanitized.'_delete');
} | php | public static function resource($target, $handler)
{
$route = $target;
$sanitized = str_replace('/', '', $target);
static::get($route, $handler.'@index', $sanitized.'_index');
static::get($target.'/create', $handler.'@showCreateForm', $sanitized.'_create_form');
static::post($target, $handler.'@save', $sanitized.'_save');
static::get($target.'/[i:id]', $handler.'@show', $sanitized.'_display');
static::get($target.'/[i:id]/edit', $handler.'@showEditForm', $sanitized.'_edit_form');
static::post($target.'/[i:id]', $handler.'@update', $sanitized.'_update');
static::get($target.'/[i:id]/delete', $handler.'@delete', $sanitized.'_delete');
} | [
"public",
"static",
"function",
"resource",
"(",
"$",
"target",
",",
"$",
"handler",
")",
"{",
"$",
"route",
"=",
"$",
"target",
";",
"$",
"sanitized",
"=",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"target",
")",
";",
"static",
"::",
"get",
"(",
"$",
"route",
",",
"$",
"handler",
".",
"'@index'",
",",
"$",
"sanitized",
".",
"'_index'",
")",
";",
"static",
"::",
"get",
"(",
"$",
"target",
".",
"'/create'",
",",
"$",
"handler",
".",
"'@showCreateForm'",
",",
"$",
"sanitized",
".",
"'_create_form'",
")",
";",
"static",
"::",
"post",
"(",
"$",
"target",
",",
"$",
"handler",
".",
"'@save'",
",",
"$",
"sanitized",
".",
"'_save'",
")",
";",
"static",
"::",
"get",
"(",
"$",
"target",
".",
"'/[i:id]'",
",",
"$",
"handler",
".",
"'@show'",
",",
"$",
"sanitized",
".",
"'_display'",
")",
";",
"static",
"::",
"get",
"(",
"$",
"target",
".",
"'/[i:id]/edit'",
",",
"$",
"handler",
".",
"'@showEditForm'",
",",
"$",
"sanitized",
".",
"'_edit_form'",
")",
";",
"static",
"::",
"post",
"(",
"$",
"target",
".",
"'/[i:id]'",
",",
"$",
"handler",
".",
"'@update'",
",",
"$",
"sanitized",
".",
"'_update'",
")",
";",
"static",
"::",
"get",
"(",
"$",
"target",
".",
"'/[i:id]/delete'",
",",
"$",
"handler",
".",
"'@delete'",
",",
"$",
"sanitized",
".",
"'_delete'",
")",
";",
"}"
]
| Create a Rest Resource.
@param $target
@param $handler | [
"Create",
"a",
"Rest",
"Resource",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Routing/Route.php#L98-L110 |
13,488 | liip/LiipDrupalConnectorModule | src/Liip/Drupal/Modules/DrupalConnector/File.php | File.file_save_data | function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
return file_save_data($data, $destination, $replace);
} | php | function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
return file_save_data($data, $destination, $replace);
} | [
"function",
"file_save_data",
"(",
"$",
"data",
",",
"$",
"destination",
"=",
"NULL",
",",
"$",
"replace",
"=",
"FILE_EXISTS_RENAME",
")",
"{",
"return",
"file_save_data",
"(",
"$",
"data",
",",
"$",
"destination",
",",
"$",
"replace",
")",
";",
"}"
]
| Saves a file to the specified destination and creates a database entry.
@param $data
A string containing the contents of the file.
@param $destination
A string containing the destination URI. This must be a stream wrapper URI.
If no value is provided, a randomized name will be generated and the file
will be saved using Drupal's default files scheme, usually "public://".
@param $replace
Replace behavior when the destination file already exists:
- FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with
the destination name exists then its database entry will be updated. If
no database entry is found then a new one will be created.
- FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is
unique.
- FILE_EXISTS_ERROR - Do nothing and return FALSE.
@return
A file object, or FALSE on error.
@see file_unmanaged_save_data() | [
"Saves",
"a",
"file",
"to",
"the",
"specified",
"destination",
"and",
"creates",
"a",
"database",
"entry",
"."
]
| 6ba161ef0d3a27c108e533f1adbea22ed73b78ce | https://github.com/liip/LiipDrupalConnectorModule/blob/6ba161ef0d3a27c108e533f1adbea22ed73b78ce/src/Liip/Drupal/Modules/DrupalConnector/File.php#L133-L135 |
13,489 | terdia/legato-framework | src/Console/StartPhpInbuiltServer.php | StartPhpInbuiltServer.execute | public function execute(InputInterface $input, OutputInterface $output)
{
chdir('public');
/*
* check for user supplied hostname option
*/
if ($input->hasOption('hostname') && $input->getOption('hostname') != null) {
$this->hostname = $input->getOption('hostname');
}
/*
* check for user supplied port option
*/
if ($input->hasOption('port') && $input->getOption('port') != null) {
$this->port = $input->getOption('port');
}
/*
* check for user supplied a path option
*/
if ($input->hasOption('path') && $input->getOption('path') != null) {
$this->phpexec = $input->getOption('path');
}
$output->writeln('<info>Legato development server started</info>');
$output->writeln("<info>Open your browser and navigate to: </info> <http://{$this->hostname}:{$this->port}>");
$output->writeln('<info>CTRL C to quit </info>');
passthru($this->startPHP());
} | php | public function execute(InputInterface $input, OutputInterface $output)
{
chdir('public');
/*
* check for user supplied hostname option
*/
if ($input->hasOption('hostname') && $input->getOption('hostname') != null) {
$this->hostname = $input->getOption('hostname');
}
/*
* check for user supplied port option
*/
if ($input->hasOption('port') && $input->getOption('port') != null) {
$this->port = $input->getOption('port');
}
/*
* check for user supplied a path option
*/
if ($input->hasOption('path') && $input->getOption('path') != null) {
$this->phpexec = $input->getOption('path');
}
$output->writeln('<info>Legato development server started</info>');
$output->writeln("<info>Open your browser and navigate to: </info> <http://{$this->hostname}:{$this->port}>");
$output->writeln('<info>CTRL C to quit </info>');
passthru($this->startPHP());
} | [
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"chdir",
"(",
"'public'",
")",
";",
"/*\n * check for user supplied hostname option\n */",
"if",
"(",
"$",
"input",
"->",
"hasOption",
"(",
"'hostname'",
")",
"&&",
"$",
"input",
"->",
"getOption",
"(",
"'hostname'",
")",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"hostname",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'hostname'",
")",
";",
"}",
"/*\n * check for user supplied port option\n */",
"if",
"(",
"$",
"input",
"->",
"hasOption",
"(",
"'port'",
")",
"&&",
"$",
"input",
"->",
"getOption",
"(",
"'port'",
")",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"port",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'port'",
")",
";",
"}",
"/*\n * check for user supplied a path option\n */",
"if",
"(",
"$",
"input",
"->",
"hasOption",
"(",
"'path'",
")",
"&&",
"$",
"input",
"->",
"getOption",
"(",
"'path'",
")",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"phpexec",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'path'",
")",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"'<info>Legato development server started</info>'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"\"<info>Open your browser and navigate to: </info> <http://{$this->hostname}:{$this->port}>\"",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"'<info>CTRL C to quit </info>'",
")",
";",
"passthru",
"(",
"$",
"this",
"->",
"startPHP",
"(",
")",
")",
";",
"}"
]
| You command logic.
@param InputInterface $input
@param OutputInterface $output
@return void | [
"You",
"command",
"logic",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Console/StartPhpInbuiltServer.php#L56-L85 |
13,490 | iP1SMS/ip1-php-sdk | src/Core/ClassValidationArray.php | ClassValidationArray.offsetSet | public function offsetSet($index, $value): void
{
if (!is_object($value)) {
throw new \InvalidArgumentException("Excepcted object, got ". gettype($value));
}
if (!isset($this->class)) {
$this->class = get_class($value);
}
if (get_class($value) === $this->class) {
parent::offsetSet($index, $value);
} else {
throw new \InvalidArgumentException("Excepcted $this->class, got ". get_class($value));
}
} | php | public function offsetSet($index, $value): void
{
if (!is_object($value)) {
throw new \InvalidArgumentException("Excepcted object, got ". gettype($value));
}
if (!isset($this->class)) {
$this->class = get_class($value);
}
if (get_class($value) === $this->class) {
parent::offsetSet($index, $value);
} else {
throw new \InvalidArgumentException("Excepcted $this->class, got ". get_class($value));
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"value",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Excepcted object, got \"",
".",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"class",
")",
")",
"{",
"$",
"this",
"->",
"class",
"=",
"get_class",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"value",
")",
"===",
"$",
"this",
"->",
"class",
")",
"{",
"parent",
"::",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Excepcted $this->class, got \"",
".",
"get_class",
"(",
"$",
"value",
")",
")",
";",
"}",
"}"
]
| Sets the value at the specified index to value if value's class matches the one set.
If a class has not been set it will set the given object's class as the only allowed class.
@param mixed $index The index to put the value in.
@param object $value The object that should be added.
@return void
@throws \InvalidArgumentException When $value is not an object or doesn't match the class that has been set. | [
"Sets",
"the",
"value",
"at",
"the",
"specified",
"index",
"to",
"value",
"if",
"value",
"s",
"class",
"matches",
"the",
"one",
"set",
".",
"If",
"a",
"class",
"has",
"not",
"been",
"set",
"it",
"will",
"set",
"the",
"given",
"object",
"s",
"class",
"as",
"the",
"only",
"allowed",
"class",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Core/ClassValidationArray.php#L79-L92 |
13,491 | venta/framework | src/Container/src/Exception/UnresolvableDependencyException.php | UnresolvableDependencyException.formatParameter | private function formatParameter(ReflectionParameter $parameter): string
{
return $parameter->hasType() ?
sprintf('%s $%s', $parameter->getType(), $parameter->getName()) :
sprintf('$%s', $parameter->getName());
} | php | private function formatParameter(ReflectionParameter $parameter): string
{
return $parameter->hasType() ?
sprintf('%s $%s', $parameter->getType(), $parameter->getName()) :
sprintf('$%s', $parameter->getName());
} | [
"private",
"function",
"formatParameter",
"(",
"ReflectionParameter",
"$",
"parameter",
")",
":",
"string",
"{",
"return",
"$",
"parameter",
"->",
"hasType",
"(",
")",
"?",
"sprintf",
"(",
"'%s $%s'",
",",
"$",
"parameter",
"->",
"getType",
"(",
")",
",",
"$",
"parameter",
"->",
"getName",
"(",
")",
")",
":",
"sprintf",
"(",
"'$%s'",
",",
"$",
"parameter",
"->",
"getName",
"(",
")",
")",
";",
"}"
]
| Formats parameter depending on type
@param ReflectionParameter $parameter
@return string | [
"Formats",
"parameter",
"depending",
"on",
"type"
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/Exception/UnresolvableDependencyException.php#L61-L66 |
13,492 | terdia/legato-framework | src/Console/CommandTemplate.php | CommandTemplate.controller | public function controller()
{
if ($this->restful) {
return filesystem()->exists(realpath(__DIR__.'/../../../../../app/controllers')) ?
realpath(__DIR__.'/../Templates/controller/restful.stub') :
realpath(__DIR__.'/../Templates/controller/restful.core.stub');
}
return filesystem()->exists(realpath(__DIR__.'/../../../../../app/controllers')) ?
realpath(__DIR__.'/../Templates/controller/plain.stub') :
realpath(__DIR__.'/../Templates/controller/core.stub');
} | php | public function controller()
{
if ($this->restful) {
return filesystem()->exists(realpath(__DIR__.'/../../../../../app/controllers')) ?
realpath(__DIR__.'/../Templates/controller/restful.stub') :
realpath(__DIR__.'/../Templates/controller/restful.core.stub');
}
return filesystem()->exists(realpath(__DIR__.'/../../../../../app/controllers')) ?
realpath(__DIR__.'/../Templates/controller/plain.stub') :
realpath(__DIR__.'/../Templates/controller/core.stub');
} | [
"public",
"function",
"controller",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"restful",
")",
"{",
"return",
"filesystem",
"(",
")",
"->",
"exists",
"(",
"realpath",
"(",
"__DIR__",
".",
"'/../../../../../app/controllers'",
")",
")",
"?",
"realpath",
"(",
"__DIR__",
".",
"'/../Templates/controller/restful.stub'",
")",
":",
"realpath",
"(",
"__DIR__",
".",
"'/../Templates/controller/restful.core.stub'",
")",
";",
"}",
"return",
"filesystem",
"(",
")",
"->",
"exists",
"(",
"realpath",
"(",
"__DIR__",
".",
"'/../../../../../app/controllers'",
")",
")",
"?",
"realpath",
"(",
"__DIR__",
".",
"'/../Templates/controller/plain.stub'",
")",
":",
"realpath",
"(",
"__DIR__",
".",
"'/../Templates/controller/core.stub'",
")",
";",
"}"
]
| Get the template for creating a controller.
@return bool|string | [
"Get",
"the",
"template",
"for",
"creating",
"a",
"controller",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Console/CommandTemplate.php#L22-L33 |
13,493 | guillaumemonet/Rad | src/Rad/Utils/StringUtils.php | StringUtils.parseComments | public static function parseComments($comments) {
$ret = [];
//trim(str_replace(array('/', '*', '**'), '', substr($comments, 0, strpos($comments, '@'))));
$comments = str_replace(array('/*', '*', '**'), '', $comments);
$array_comments = explode("\n", $comments);
foreach ($array_comments as $k => $line) {
$line = trim($line);
if (self::startsWith($line, "@")) {
$params = explode(" ", $line);
$c = trim(str_replace("@", "", array_shift($params)));
$ret[$c] = $params;
}
}
return $ret;
} | php | public static function parseComments($comments) {
$ret = [];
//trim(str_replace(array('/', '*', '**'), '', substr($comments, 0, strpos($comments, '@'))));
$comments = str_replace(array('/*', '*', '**'), '', $comments);
$array_comments = explode("\n", $comments);
foreach ($array_comments as $k => $line) {
$line = trim($line);
if (self::startsWith($line, "@")) {
$params = explode(" ", $line);
$c = trim(str_replace("@", "", array_shift($params)));
$ret[$c] = $params;
}
}
return $ret;
} | [
"public",
"static",
"function",
"parseComments",
"(",
"$",
"comments",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"//trim(str_replace(array('/', '*', '**'), '', substr($comments, 0, strpos($comments, '@'))));\r",
"$",
"comments",
"=",
"str_replace",
"(",
"array",
"(",
"'/*'",
",",
"'*'",
",",
"'**'",
")",
",",
"''",
",",
"$",
"comments",
")",
";",
"$",
"array_comments",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"comments",
")",
";",
"foreach",
"(",
"$",
"array_comments",
"as",
"$",
"k",
"=>",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"if",
"(",
"self",
"::",
"startsWith",
"(",
"$",
"line",
",",
"\"@\"",
")",
")",
"{",
"$",
"params",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"line",
")",
";",
"$",
"c",
"=",
"trim",
"(",
"str_replace",
"(",
"\"@\"",
",",
"\"\"",
",",
"array_shift",
"(",
"$",
"params",
")",
")",
")",
";",
"$",
"ret",
"[",
"$",
"c",
"]",
"=",
"$",
"params",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Parse comment, used only when generate php
@param string $comments | [
"Parse",
"comment",
"used",
"only",
"when",
"generate",
"php"
]
| cb9932f570cf3c2a7197f81e1d959c2729989e59 | https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Utils/StringUtils.php#L194-L208 |
13,494 | mimmi20/Wurfl | src/Handlers/CatchAllMozillaHandler.php | CatchAllMozillaHandler.applyConclusiveMatch | public function applyConclusiveMatch($userAgent)
{
//High accuracy mode
$tolerance = Utils::firstCloseParen($userAgent);
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
} | php | public function applyConclusiveMatch($userAgent)
{
//High accuracy mode
$tolerance = Utils::firstCloseParen($userAgent);
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
} | [
"public",
"function",
"applyConclusiveMatch",
"(",
"$",
"userAgent",
")",
"{",
"//High accuracy mode",
"$",
"tolerance",
"=",
"Utils",
"::",
"firstCloseParen",
"(",
"$",
"userAgent",
")",
";",
"return",
"$",
"this",
"->",
"getDeviceIDFromRIS",
"(",
"$",
"userAgent",
",",
"$",
"tolerance",
")",
";",
"}"
]
| If UA starts with Mozilla, apply LD with tollerance 5.
@param string $userAgent
@return string | [
"If",
"UA",
"starts",
"with",
"Mozilla",
"apply",
"LD",
"with",
"tollerance",
"5",
"."
]
| 443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/CatchAllMozillaHandler.php#L50-L56 |
13,495 | rfdy/imagemagick | Image/Url.php | Url.getImageData | public function getImageData() {
if ($this->imageData === null) {
$this->imageData = $this->download($this->url);
}
return $this->imageData;
} | php | public function getImageData() {
if ($this->imageData === null) {
$this->imageData = $this->download($this->url);
}
return $this->imageData;
} | [
"public",
"function",
"getImageData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageData",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"imageData",
"=",
"$",
"this",
"->",
"download",
"(",
"$",
"this",
"->",
"url",
")",
";",
"}",
"return",
"$",
"this",
"->",
"imageData",
";",
"}"
]
| Returns the complete image data, wherever it may have come from.
@return string | [
"Returns",
"the",
"complete",
"image",
"data",
"wherever",
"it",
"may",
"have",
"come",
"from",
"."
]
| dd1e52fbd66093828dd013e64c53dc7d68f1bc91 | https://github.com/rfdy/imagemagick/blob/dd1e52fbd66093828dd013e64c53dc7d68f1bc91/Image/Url.php#L28-L33 |
13,496 | MissAllSunday/Ohara | src/Suki/Db.php | Db.read | public function read($params, $data, $key = false, $single = false)
{
global $smcFunc;
$dataResult = [];
$query = $smcFunc['db_query']('', '
SELECT ' . $params['rows'] .'
FROM {db_prefix}' . $params['table'] .'
'. (!empty($params['join']) ? 'LEFT JOIN '. $params['join'] : '') .'
'. (!empty($params['where']) ? 'WHERE '. $params['where'] : '') .'
'. (!empty($params['and']) ? 'AND '. $params['and'] : '') .'
'. (!empty($params['andTwo']) ? 'AND '. $params['andTwo'] : '') .'
'. (!empty($params['order']) ? 'ORDER BY ' . $params['order'] : '') .'
'. (!empty($params['limit']) ? 'LIMIT '. $params['limit'] : '') . '',
$data
);
if (!empty($single))
while ($row = $smcFunc['db_fetch_assoc']($query))
$dataResult = $row;
elseif (!empty($key) && empty($single))
while ($row = $smcFunc['db_fetch_assoc']($query))
$dataResult[$row[$key]] = $row;
elseif (empty($single) && empty($key))
while ($row = $smcFunc['db_fetch_assoc']($query))
$dataResult[] = $row;
$smcFunc['db_free_result']($query);
return $dataResult;
} | php | public function read($params, $data, $key = false, $single = false)
{
global $smcFunc;
$dataResult = [];
$query = $smcFunc['db_query']('', '
SELECT ' . $params['rows'] .'
FROM {db_prefix}' . $params['table'] .'
'. (!empty($params['join']) ? 'LEFT JOIN '. $params['join'] : '') .'
'. (!empty($params['where']) ? 'WHERE '. $params['where'] : '') .'
'. (!empty($params['and']) ? 'AND '. $params['and'] : '') .'
'. (!empty($params['andTwo']) ? 'AND '. $params['andTwo'] : '') .'
'. (!empty($params['order']) ? 'ORDER BY ' . $params['order'] : '') .'
'. (!empty($params['limit']) ? 'LIMIT '. $params['limit'] : '') . '',
$data
);
if (!empty($single))
while ($row = $smcFunc['db_fetch_assoc']($query))
$dataResult = $row;
elseif (!empty($key) && empty($single))
while ($row = $smcFunc['db_fetch_assoc']($query))
$dataResult[$row[$key]] = $row;
elseif (empty($single) && empty($key))
while ($row = $smcFunc['db_fetch_assoc']($query))
$dataResult[] = $row;
$smcFunc['db_free_result']($query);
return $dataResult;
} | [
"public",
"function",
"read",
"(",
"$",
"params",
",",
"$",
"data",
",",
"$",
"key",
"=",
"false",
",",
"$",
"single",
"=",
"false",
")",
"{",
"global",
"$",
"smcFunc",
";",
"$",
"dataResult",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"$",
"smcFunc",
"[",
"'db_query'",
"]",
"(",
"''",
",",
"'\n\t\t\tSELECT '",
".",
"$",
"params",
"[",
"'rows'",
"]",
".",
"'\n\t\t\tFROM {db_prefix}'",
".",
"$",
"params",
"[",
"'table'",
"]",
".",
"'\n\t\t\t'",
".",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'join'",
"]",
")",
"?",
"'LEFT JOIN '",
".",
"$",
"params",
"[",
"'join'",
"]",
":",
"''",
")",
".",
"'\n\t\t\t'",
".",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'where'",
"]",
")",
"?",
"'WHERE '",
".",
"$",
"params",
"[",
"'where'",
"]",
":",
"''",
")",
".",
"'\n\t\t\t\t'",
".",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'and'",
"]",
")",
"?",
"'AND '",
".",
"$",
"params",
"[",
"'and'",
"]",
":",
"''",
")",
".",
"'\n\t\t\t\t'",
".",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'andTwo'",
"]",
")",
"?",
"'AND '",
".",
"$",
"params",
"[",
"'andTwo'",
"]",
":",
"''",
")",
".",
"'\n\t\t\t'",
".",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'order'",
"]",
")",
"?",
"'ORDER BY '",
".",
"$",
"params",
"[",
"'order'",
"]",
":",
"''",
")",
".",
"'\n\t\t\t'",
".",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'limit'",
"]",
")",
"?",
"'LIMIT '",
".",
"$",
"params",
"[",
"'limit'",
"]",
":",
"''",
")",
".",
"''",
",",
"$",
"data",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"single",
")",
")",
"while",
"(",
"$",
"row",
"=",
"$",
"smcFunc",
"[",
"'db_fetch_assoc'",
"]",
"(",
"$",
"query",
")",
")",
"$",
"dataResult",
"=",
"$",
"row",
";",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"key",
")",
"&&",
"empty",
"(",
"$",
"single",
")",
")",
"while",
"(",
"$",
"row",
"=",
"$",
"smcFunc",
"[",
"'db_fetch_assoc'",
"]",
"(",
"$",
"query",
")",
")",
"$",
"dataResult",
"[",
"$",
"row",
"[",
"$",
"key",
"]",
"]",
"=",
"$",
"row",
";",
"elseif",
"(",
"empty",
"(",
"$",
"single",
")",
"&&",
"empty",
"(",
"$",
"key",
")",
")",
"while",
"(",
"$",
"row",
"=",
"$",
"smcFunc",
"[",
"'db_fetch_assoc'",
"]",
"(",
"$",
"query",
")",
")",
"$",
"dataResult",
"[",
"]",
"=",
"$",
"row",
";",
"$",
"smcFunc",
"[",
"'db_free_result'",
"]",
"(",
"$",
"query",
")",
";",
"return",
"$",
"dataResult",
";",
"}"
]
| Reads data from a table.
@param array $params An array with all the params for the query
@param array $data An array to pass to $smcFunc casting array
@param bool $key A boolean value to asign a row as key on the returning array
@param bool $single A bool to tell the query to return a single value instead of An array
@return mixed either An array or a var with the query result | [
"Reads",
"data",
"from",
"a",
"table",
"."
]
| 7753500cde1d51a0d7b37593aeaf2fc05fefd903 | https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Db.php#L85-L116 |
13,497 | MissAllSunday/Ohara | src/Suki/Db.php | Db.delete | public function delete($value, $table = '', $column = '')
{
global $smcFunc;
if (empty($id) || empty($table) || empty($column))
return false;
// Perform.
return $smcFunc['db_query']('', '
DELETE FROM {db_prefix}' . ($table) . '
WHERE '. ($column) .' = '. ($value) .'', array());
} | php | public function delete($value, $table = '', $column = '')
{
global $smcFunc;
if (empty($id) || empty($table) || empty($column))
return false;
// Perform.
return $smcFunc['db_query']('', '
DELETE FROM {db_prefix}' . ($table) . '
WHERE '. ($column) .' = '. ($value) .'', array());
} | [
"public",
"function",
"delete",
"(",
"$",
"value",
",",
"$",
"table",
"=",
"''",
",",
"$",
"column",
"=",
"''",
")",
"{",
"global",
"$",
"smcFunc",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
"||",
"empty",
"(",
"$",
"table",
")",
"||",
"empty",
"(",
"$",
"column",
")",
")",
"return",
"false",
";",
"// Perform.",
"return",
"$",
"smcFunc",
"[",
"'db_query'",
"]",
"(",
"''",
",",
"'\n\t\t\tDELETE FROM {db_prefix}'",
".",
"(",
"$",
"table",
")",
".",
"'\n\t\t\tWHERE '",
".",
"(",
"$",
"column",
")",
".",
"' = '",
".",
"(",
"$",
"value",
")",
".",
"''",
",",
"array",
"(",
")",
")",
";",
"}"
]
| Deletes an entry from X table.
@access public
@param mixed $value The table name.
@param string $table The table name, if left empty and $this->_schema is defined, it will use the first table on it.
@param string $column The column name, if left empty and $this->_schema[$table] is defined, it will use the first column on it.
@return mixed | [
"Deletes",
"an",
"entry",
"from",
"X",
"table",
"."
]
| 7753500cde1d51a0d7b37593aeaf2fc05fefd903 | https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Db.php#L178-L189 |
13,498 | ionutmilica/laravel-settings | src/Drivers/Json.php | Json.load | public function load()
{
$data = [];
if (is_file($this->filePath)) {
$data = json_decode(file_get_contents($this->filePath), true);
}
return $data;
} | php | public function load()
{
$data = [];
if (is_file($this->filePath)) {
$data = json_decode(file_get_contents($this->filePath), true);
}
return $data;
} | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"filePath",
")",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"filePath",
")",
",",
"true",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Prepare the data for driver operations | [
"Prepare",
"the",
"data",
"for",
"driver",
"operations"
]
| becbd839f8c1c1bcbfde42ea808f1c69e5233dee | https://github.com/ionutmilica/laravel-settings/blob/becbd839f8c1c1bcbfde42ea808f1c69e5233dee/src/Drivers/Json.php#L43-L52 |
13,499 | ronan-gloo/jade-php | src/Jade/Lexer.php | Lexer.setInput | public function setInput($input)
{
$this->input = preg_replace("/\r\n|\r/", "\n", $input);
$this->lineno = 1;
$this->deferred = array();
$this->indentStack = array();
$this->stash = array();
} | php | public function setInput($input)
{
$this->input = preg_replace("/\r\n|\r/", "\n", $input);
$this->lineno = 1;
$this->deferred = array();
$this->indentStack = array();
$this->stash = array();
} | [
"public",
"function",
"setInput",
"(",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"preg_replace",
"(",
"\"/\\r\\n|\\r/\"",
",",
"\"\\n\"",
",",
"$",
"input",
")",
";",
"$",
"this",
"->",
"lineno",
"=",
"1",
";",
"$",
"this",
"->",
"deferred",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"indentStack",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"stash",
"=",
"array",
"(",
")",
";",
"}"
]
| Set lexer input.
@param string $input input string | [
"Set",
"lexer",
"input",
"."
]
| 77230d2eef2f0d4f045292a5906162f0c0499421 | https://github.com/ronan-gloo/jade-php/blob/77230d2eef2f0d4f045292a5906162f0c0499421/src/Jade/Lexer.php#L52-L59 |
Subsets and Splits