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
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
squareproton/Bond | src/Bond/RecordManager/Response.php | Response.isRolledback | public function isRolledback( $transaction = RecordManager::TRANSACTIONS_ALL )
{
$output = false;
foreach( $this->getStatus($transaction) as $transaction => $transactionStatus ) {
foreach( $transactionStatus as $status ) {
$output = ( $output || $status === self::ROLLEDBACK || $status === self::FAILED );
}
}
return $output;
} | php | public function isRolledback( $transaction = RecordManager::TRANSACTIONS_ALL )
{
$output = false;
foreach( $this->getStatus($transaction) as $transaction => $transactionStatus ) {
foreach( $transactionStatus as $status ) {
$output = ( $output || $status === self::ROLLEDBACK || $status === self::FAILED );
}
}
return $output;
} | [
"public",
"function",
"isRolledback",
"(",
"$",
"transaction",
"=",
"RecordManager",
"::",
"TRANSACTIONS_ALL",
")",
"{",
"$",
"output",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"getStatus",
"(",
"$",
"transaction",
")",
"as",
"$",
"transaction",
"=>",
"$",
"transactionStatus",
")",
"{",
"foreach",
"(",
"$",
"transactionStatus",
"as",
"$",
"status",
")",
"{",
"$",
"output",
"=",
"(",
"$",
"output",
"||",
"$",
"status",
"===",
"self",
"::",
"ROLLEDBACK",
"||",
"$",
"status",
"===",
"self",
"::",
"FAILED",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
]
| Has a named transaction been rolledback
@param scalar $transaction
@return bool | [
"Has",
"a",
"named",
"transaction",
"been",
"rolledback"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager/Response.php#L122-L131 | train |
squareproton/Bond | src/Bond/RecordManager/Response.php | Response.doneAnything | public function doneAnything()
{
$output = false;
foreach( $this->status as $transaction => $transactionStatus ) {
foreach( $transactionStatus as $status ) {
$output = ( $output || $status === self::SUCCESS );
}
}
return $output;
} | php | public function doneAnything()
{
$output = false;
foreach( $this->status as $transaction => $transactionStatus ) {
foreach( $transactionStatus as $status ) {
$output = ( $output || $status === self::SUCCESS );
}
}
return $output;
} | [
"public",
"function",
"doneAnything",
"(",
")",
"{",
"$",
"output",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"status",
"as",
"$",
"transaction",
"=>",
"$",
"transactionStatus",
")",
"{",
"foreach",
"(",
"$",
"transactionStatus",
"as",
"$",
"status",
")",
"{",
"$",
"output",
"=",
"(",
"$",
"output",
"||",
"$",
"status",
"===",
"self",
"::",
"SUCCESS",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
]
| Have we actually done anything?
@return bool | [
"Have",
"we",
"actually",
"done",
"anything?"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager/Response.php#L137-L146 | train |
squareproton/Bond | src/Bond/RecordManager/Response.php | Response.filterByObject | public function filterByObject( $objectOrArray )
{
$response = new Response();
if( !is_array($objectOrArray) ) {
$objectOrArray = array( $objectOrArray );
}
foreach( $objectOrArray as $object ) {
if( !is_object($object) ) {
throw new \InvalidArgumentException("can't findTransactionByObject if not object" );
}
// iterate over t
foreach( $this->queue as $transaction => $transactionQueue ) {
foreach( $transactionQueue as $key => $task ) {
if( $object === $task or $object === $task->getObject() ) {
$response->add(
$transaction,
$task,
isset( $this->exceptions[$transaction][$key] )
? $this->exceptions[$transaction][$key]
: $this->status[$transaction][$key]
);
}
}
}
}
return $response;
} | php | public function filterByObject( $objectOrArray )
{
$response = new Response();
if( !is_array($objectOrArray) ) {
$objectOrArray = array( $objectOrArray );
}
foreach( $objectOrArray as $object ) {
if( !is_object($object) ) {
throw new \InvalidArgumentException("can't findTransactionByObject if not object" );
}
// iterate over t
foreach( $this->queue as $transaction => $transactionQueue ) {
foreach( $transactionQueue as $key => $task ) {
if( $object === $task or $object === $task->getObject() ) {
$response->add(
$transaction,
$task,
isset( $this->exceptions[$transaction][$key] )
? $this->exceptions[$transaction][$key]
: $this->status[$transaction][$key]
);
}
}
}
}
return $response;
} | [
"public",
"function",
"filterByObject",
"(",
"$",
"objectOrArray",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"objectOrArray",
")",
")",
"{",
"$",
"objectOrArray",
"=",
"array",
"(",
"$",
"objectOrArray",
")",
";",
"}",
"foreach",
"(",
"$",
"objectOrArray",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"can't findTransactionByObject if not object\"",
")",
";",
"}",
"// iterate over t",
"foreach",
"(",
"$",
"this",
"->",
"queue",
"as",
"$",
"transaction",
"=>",
"$",
"transactionQueue",
")",
"{",
"foreach",
"(",
"$",
"transactionQueue",
"as",
"$",
"key",
"=>",
"$",
"task",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"$",
"task",
"or",
"$",
"object",
"===",
"$",
"task",
"->",
"getObject",
"(",
")",
")",
"{",
"$",
"response",
"->",
"add",
"(",
"$",
"transaction",
",",
"$",
"task",
",",
"isset",
"(",
"$",
"this",
"->",
"exceptions",
"[",
"$",
"transaction",
"]",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"exceptions",
"[",
"$",
"transaction",
"]",
"[",
"$",
"key",
"]",
":",
"$",
"this",
"->",
"status",
"[",
"$",
"transaction",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"response",
";",
"}"
]
| Get transaction response by object
@param object|array $object
@return $response | [
"Get",
"transaction",
"response",
"by",
"object"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager/Response.php#L215-L249 | train |
codeblanche/Web | src/Web/Response/Status.php | Status.getStatusText | public function getStatusText()
{
$statusCode = $this->getStatusCode();
if (!isset($this->defaultStatusTextList[$statusCode])) {
return '';
}
return $this->defaultStatusTextList[$statusCode];
} | php | public function getStatusText()
{
$statusCode = $this->getStatusCode();
if (!isset($this->defaultStatusTextList[$statusCode])) {
return '';
}
return $this->defaultStatusTextList[$statusCode];
} | [
"public",
"function",
"getStatusText",
"(",
")",
"{",
"$",
"statusCode",
"=",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"defaultStatusTextList",
"[",
"$",
"statusCode",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"defaultStatusTextList",
"[",
"$",
"statusCode",
"]",
";",
"}"
]
| Retrieve the status text or empty string if one cannot be found
@return string | [
"Retrieve",
"the",
"status",
"text",
"or",
"empty",
"string",
"if",
"one",
"cannot",
"be",
"found"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Response/Status.php#L170-L179 | train |
crazedsanity/AuthToken | src/authtoken/AuthToken.class.php | AuthToken.lookup_token_type | public function lookup_token_type($findThis) {
$retval = 0;
$sql = "SELECT * FROM cswal_token_type_table WHERE token_type=:type";
try {
$numrows = $this->db->run_query($sql, array('type'=> $findThis));
if($numrows == 1) {
$data = $this->db->get_single_record();
$retval = $data['token_type_id'];
}
} catch (Exception $ex) {
throw new exception(__METHOD__ .": failed to retrieve token type::: ". $ex->getMessage());
}
return $retval;
} | php | public function lookup_token_type($findThis) {
$retval = 0;
$sql = "SELECT * FROM cswal_token_type_table WHERE token_type=:type";
try {
$numrows = $this->db->run_query($sql, array('type'=> $findThis));
if($numrows == 1) {
$data = $this->db->get_single_record();
$retval = $data['token_type_id'];
}
} catch (Exception $ex) {
throw new exception(__METHOD__ .": failed to retrieve token type::: ". $ex->getMessage());
}
return $retval;
} | [
"public",
"function",
"lookup_token_type",
"(",
"$",
"findThis",
")",
"{",
"$",
"retval",
"=",
"0",
";",
"$",
"sql",
"=",
"\"SELECT * FROM cswal_token_type_table WHERE token_type=:type\"",
";",
"try",
"{",
"$",
"numrows",
"=",
"$",
"this",
"->",
"db",
"->",
"run_query",
"(",
"$",
"sql",
",",
"array",
"(",
"'type'",
"=>",
"$",
"findThis",
")",
")",
";",
"if",
"(",
"$",
"numrows",
"==",
"1",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"db",
"->",
"get_single_record",
"(",
")",
";",
"$",
"retval",
"=",
"$",
"data",
"[",
"'token_type_id'",
"]",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"exception",
"(",
"__METHOD__",
".",
"\": failed to retrieve token type::: \"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"retval",
";",
"}"
]
| Lookup a token type.
@param type $findThis (str) searches the "token_type" column for this.
@return int token_type_id that was found; default 0 (unknown)
@throws exception | [
"Lookup",
"a",
"token",
"type",
"."
]
| f6ac0d5575b01ba001b62f2467f27615d58f911c | https://github.com/crazedsanity/AuthToken/blob/f6ac0d5575b01ba001b62f2467f27615d58f911c/src/authtoken/AuthToken.class.php#L131-L147 | train |
crazedsanity/AuthToken | src/authtoken/AuthToken.class.php | AuthToken.update_type | public function update_type($id, $type, $desc) {
$sql = "UPDATE cswal_token_type_table SET token_type=:type,
token_desc=:desc WHERE token_type_id=:id";
$params = array(
'id' => $id,
'type' => $type,
'desc' => $desc,
);
try {
$retval = $this->db->run_update($sql, $params);
} catch (Exception $ex) {
throw new Exception(__METHOD__ .": failed to update type::: ". $ex->getMessage());
}
return $retval;
} | php | public function update_type($id, $type, $desc) {
$sql = "UPDATE cswal_token_type_table SET token_type=:type,
token_desc=:desc WHERE token_type_id=:id";
$params = array(
'id' => $id,
'type' => $type,
'desc' => $desc,
);
try {
$retval = $this->db->run_update($sql, $params);
} catch (Exception $ex) {
throw new Exception(__METHOD__ .": failed to update type::: ". $ex->getMessage());
}
return $retval;
} | [
"public",
"function",
"update_type",
"(",
"$",
"id",
",",
"$",
"type",
",",
"$",
"desc",
")",
"{",
"$",
"sql",
"=",
"\"UPDATE cswal_token_type_table SET token_type=:type, \n\t\t\ttoken_desc=:desc WHERE token_type_id=:id\"",
";",
"$",
"params",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'type'",
"=>",
"$",
"type",
",",
"'desc'",
"=>",
"$",
"desc",
",",
")",
";",
"try",
"{",
"$",
"retval",
"=",
"$",
"this",
"->",
"db",
"->",
"run_update",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__METHOD__",
".",
"\": failed to update type::: \"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"retval",
";",
"}"
]
| Updates the given ID in the token_type table.
@param $id (int) ID to update
@param $type (str) value for token_type
@param $desc (str) value for token_desc
@return int Number of records updated (1)
@throws Exception | [
"Updates",
"the",
"given",
"ID",
"in",
"the",
"token_type",
"table",
"."
]
| f6ac0d5575b01ba001b62f2467f27615d58f911c | https://github.com/crazedsanity/AuthToken/blob/f6ac0d5575b01ba001b62f2467f27615d58f911c/src/authtoken/AuthToken.class.php#L183-L199 | train |
crazedsanity/AuthToken | src/authtoken/AuthToken.class.php | AuthToken.create_token | public function create_token($password, $valueToStore=null, $tokenId=null, $lifetime=null, $maxUses=null, $tokenType=0, $uid=0) {
if(is_null($tokenId) || strlen($tokenId) < 1) {
$tokenId = $this->generate_token_string();
}
$finalHash = password_hash($password, $this->passAlgorithm);
if(!is_numeric($tokenType)) {
$tokenType = $this->lookup_token_type($tokenType);
}
$insertData = array(
'auth_token_id' => $tokenId,
'passwd' => $finalHash,
'stored_value' => serialize($valueToStore),
'token_type_id' => $tokenType,
'uid' => $uid,
);
if(!is_null($maxUses) && is_numeric($maxUses)) {
$insertData['max_uses'] = $maxUses;
}
try {
$fields = "";
$values = "";
foreach($insertData as $k=>$v) {
$fields = ToolBox::create_list($fields, $k);
$values = ToolBox::create_list($values, ':'. $k);
}
if(!is_null($lifetime) && strlen($lifetime) > 0) {
$fields .= ", expiration";
$values .= ", NOW() + :life::interval";
$insertData['life'] = $lifetime;
}
$sql = "INSERT INTO cswal_auth_token_table (". $fields .") VALUES (". $values .")";
$numRows = $this->db->run_query($sql, $insertData);
if($numRows != 1) {
throw new LogicException(__METHOD__ .": unable to create token (". $numRows .")");
}
}
catch(exception $e) {
if(preg_match('/duplicate key value violates unique constraint/', $e->getMessage())) {
throw new ErrorException(__METHOD__ .": attempt to create non-unique token (". $tokenId .")");
}
else {
throw new ErrorException(__METHOD__ .": failed to create token::: ". $e->getMessage());
}
}
return($tokenId);
} | php | public function create_token($password, $valueToStore=null, $tokenId=null, $lifetime=null, $maxUses=null, $tokenType=0, $uid=0) {
if(is_null($tokenId) || strlen($tokenId) < 1) {
$tokenId = $this->generate_token_string();
}
$finalHash = password_hash($password, $this->passAlgorithm);
if(!is_numeric($tokenType)) {
$tokenType = $this->lookup_token_type($tokenType);
}
$insertData = array(
'auth_token_id' => $tokenId,
'passwd' => $finalHash,
'stored_value' => serialize($valueToStore),
'token_type_id' => $tokenType,
'uid' => $uid,
);
if(!is_null($maxUses) && is_numeric($maxUses)) {
$insertData['max_uses'] = $maxUses;
}
try {
$fields = "";
$values = "";
foreach($insertData as $k=>$v) {
$fields = ToolBox::create_list($fields, $k);
$values = ToolBox::create_list($values, ':'. $k);
}
if(!is_null($lifetime) && strlen($lifetime) > 0) {
$fields .= ", expiration";
$values .= ", NOW() + :life::interval";
$insertData['life'] = $lifetime;
}
$sql = "INSERT INTO cswal_auth_token_table (". $fields .") VALUES (". $values .")";
$numRows = $this->db->run_query($sql, $insertData);
if($numRows != 1) {
throw new LogicException(__METHOD__ .": unable to create token (". $numRows .")");
}
}
catch(exception $e) {
if(preg_match('/duplicate key value violates unique constraint/', $e->getMessage())) {
throw new ErrorException(__METHOD__ .": attempt to create non-unique token (". $tokenId .")");
}
else {
throw new ErrorException(__METHOD__ .": failed to create token::: ". $e->getMessage());
}
}
return($tokenId);
} | [
"public",
"function",
"create_token",
"(",
"$",
"password",
",",
"$",
"valueToStore",
"=",
"null",
",",
"$",
"tokenId",
"=",
"null",
",",
"$",
"lifetime",
"=",
"null",
",",
"$",
"maxUses",
"=",
"null",
",",
"$",
"tokenType",
"=",
"0",
",",
"$",
"uid",
"=",
"0",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"tokenId",
")",
"||",
"strlen",
"(",
"$",
"tokenId",
")",
"<",
"1",
")",
"{",
"$",
"tokenId",
"=",
"$",
"this",
"->",
"generate_token_string",
"(",
")",
";",
"}",
"$",
"finalHash",
"=",
"password_hash",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"passAlgorithm",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"tokenType",
")",
")",
"{",
"$",
"tokenType",
"=",
"$",
"this",
"->",
"lookup_token_type",
"(",
"$",
"tokenType",
")",
";",
"}",
"$",
"insertData",
"=",
"array",
"(",
"'auth_token_id'",
"=>",
"$",
"tokenId",
",",
"'passwd'",
"=>",
"$",
"finalHash",
",",
"'stored_value'",
"=>",
"serialize",
"(",
"$",
"valueToStore",
")",
",",
"'token_type_id'",
"=>",
"$",
"tokenType",
",",
"'uid'",
"=>",
"$",
"uid",
",",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"maxUses",
")",
"&&",
"is_numeric",
"(",
"$",
"maxUses",
")",
")",
"{",
"$",
"insertData",
"[",
"'max_uses'",
"]",
"=",
"$",
"maxUses",
";",
"}",
"try",
"{",
"$",
"fields",
"=",
"\"\"",
";",
"$",
"values",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"insertData",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"fields",
"=",
"ToolBox",
"::",
"create_list",
"(",
"$",
"fields",
",",
"$",
"k",
")",
";",
"$",
"values",
"=",
"ToolBox",
"::",
"create_list",
"(",
"$",
"values",
",",
"':'",
".",
"$",
"k",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"lifetime",
")",
"&&",
"strlen",
"(",
"$",
"lifetime",
")",
">",
"0",
")",
"{",
"$",
"fields",
".=",
"\", expiration\"",
";",
"$",
"values",
".=",
"\", NOW() + :life::interval\"",
";",
"$",
"insertData",
"[",
"'life'",
"]",
"=",
"$",
"lifetime",
";",
"}",
"$",
"sql",
"=",
"\"INSERT INTO cswal_auth_token_table (\"",
".",
"$",
"fields",
".",
"\") VALUES (\"",
".",
"$",
"values",
".",
"\")\"",
";",
"$",
"numRows",
"=",
"$",
"this",
"->",
"db",
"->",
"run_query",
"(",
"$",
"sql",
",",
"$",
"insertData",
")",
";",
"if",
"(",
"$",
"numRows",
"!=",
"1",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"__METHOD__",
".",
"\": unable to create token (\"",
".",
"$",
"numRows",
".",
"\")\"",
")",
";",
"}",
"}",
"catch",
"(",
"exception",
"$",
"e",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/duplicate key value violates unique constraint/'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"__METHOD__",
".",
"\": attempt to create non-unique token (\"",
".",
"$",
"tokenId",
".",
"\")\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ErrorException",
"(",
"__METHOD__",
".",
"\": failed to create token::: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"(",
"$",
"tokenId",
")",
";",
"}"
]
| Build a token record in the database that can be authenticated against later.
@param $password (str) matches checksum column...
@param $valueToStore (mixed, optional) item to be stored, will be serialized
@param $tokenId (str, optional) key to match against
@param $lifetime (str,optional) string (interval) representing how
long the token should last
@param $maxUses (int,optional) Number of times it can be authenticated
against before being removed
@param $tokenType (int/string,optional) type of token; can be a string
for looking up the given type
@param $uid (int, optional) value for uid column
@return (string) PASS: contains the token string.
@throws ErrorException
@throws LogicException | [
"Build",
"a",
"token",
"record",
"in",
"the",
"database",
"that",
"can",
"be",
"authenticated",
"against",
"later",
"."
]
| f6ac0d5575b01ba001b62f2467f27615d58f911c | https://github.com/crazedsanity/AuthToken/blob/f6ac0d5575b01ba001b62f2467f27615d58f911c/src/authtoken/AuthToken.class.php#L224-L280 | train |
crazedsanity/AuthToken | src/authtoken/AuthToken.class.php | AuthToken.destroy_token | public function destroy_token($tokenId) {
try {
$sql = "DELETE FROM ". $this->table ." WHERE auth_token_id=:tokenId";
$deleteRes = $this->db->run_update($sql, array('tokenId'=>$tokenId));
}
catch(exception $e) {
throw new exception(__METHOD__ .": failed to destroy token::: ". $e->getMessage());
}
return($deleteRes);
} | php | public function destroy_token($tokenId) {
try {
$sql = "DELETE FROM ". $this->table ." WHERE auth_token_id=:tokenId";
$deleteRes = $this->db->run_update($sql, array('tokenId'=>$tokenId));
}
catch(exception $e) {
throw new exception(__METHOD__ .": failed to destroy token::: ". $e->getMessage());
}
return($deleteRes);
} | [
"public",
"function",
"destroy_token",
"(",
"$",
"tokenId",
")",
"{",
"try",
"{",
"$",
"sql",
"=",
"\"DELETE FROM \"",
".",
"$",
"this",
"->",
"table",
".",
"\" WHERE auth_token_id=:tokenId\"",
";",
"$",
"deleteRes",
"=",
"$",
"this",
"->",
"db",
"->",
"run_update",
"(",
"$",
"sql",
",",
"array",
"(",
"'tokenId'",
"=>",
"$",
"tokenId",
")",
")",
";",
"}",
"catch",
"(",
"exception",
"$",
"e",
")",
"{",
"throw",
"new",
"exception",
"(",
"__METHOD__",
".",
"\": failed to destroy token::: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"(",
"$",
"deleteRes",
")",
";",
"}"
]
| Deletes the given token ID from the database.
@param $tokenId (int) auth_token_id to delete
@return (int) PASS: this many were deleted (should always be 1)
@return (exception) FAIL: exception contains error details | [
"Deletes",
"the",
"given",
"token",
"ID",
"from",
"the",
"database",
"."
]
| f6ac0d5575b01ba001b62f2467f27615d58f911c | https://github.com/crazedsanity/AuthToken/blob/f6ac0d5575b01ba001b62f2467f27615d58f911c/src/authtoken/AuthToken.class.php#L319-L329 | train |
crazedsanity/AuthToken | src/authtoken/AuthToken.class.php | AuthToken.get_token_data | public function get_token_data($tokenId) {
try {
$sql = "SELECT *, (max_uses - total_uses) as remaining_uses, "
. "(NOW() - expiration) as time_remaining "
. "FROM ". $this->table ." AS t1 INNER JOIN
cswal_token_type_table AS t2 ON (t1.token_type_id=t2.token_type_id)
WHERE auth_token_id=:tokenId";
try {
$numrows = $this->db->run_query($sql, array('tokenId'=>$tokenId));
if($numrows == 1) {
$tokenData = $this->db->get_single_record();
}
elseif($numrows < 1) {
$tokenData = false;
}
else {
throw new exception("too many records returned (". count($data) .")");
}
} catch(Exception $e) {
throw new exception(__METHOD__ .": Failed to retrieve token data::: ". $e->getMessage());
}
}
catch(exception $e) {
throw new exception(__METHOD__ .": failed to retrieve tokenId (". $tokenId .")::: ". $e->getMessage());
}
return($tokenData);
} | php | public function get_token_data($tokenId) {
try {
$sql = "SELECT *, (max_uses - total_uses) as remaining_uses, "
. "(NOW() - expiration) as time_remaining "
. "FROM ". $this->table ." AS t1 INNER JOIN
cswal_token_type_table AS t2 ON (t1.token_type_id=t2.token_type_id)
WHERE auth_token_id=:tokenId";
try {
$numrows = $this->db->run_query($sql, array('tokenId'=>$tokenId));
if($numrows == 1) {
$tokenData = $this->db->get_single_record();
}
elseif($numrows < 1) {
$tokenData = false;
}
else {
throw new exception("too many records returned (". count($data) .")");
}
} catch(Exception $e) {
throw new exception(__METHOD__ .": Failed to retrieve token data::: ". $e->getMessage());
}
}
catch(exception $e) {
throw new exception(__METHOD__ .": failed to retrieve tokenId (". $tokenId .")::: ". $e->getMessage());
}
return($tokenData);
} | [
"public",
"function",
"get_token_data",
"(",
"$",
"tokenId",
")",
"{",
"try",
"{",
"$",
"sql",
"=",
"\"SELECT *, (max_uses - total_uses) as remaining_uses, \"",
".",
"\"(NOW() - expiration) as time_remaining \"",
".",
"\"FROM \"",
".",
"$",
"this",
"->",
"table",
".",
"\" AS t1 INNER JOIN \n\t\t\t\t\t\tcswal_token_type_table AS t2 ON (t1.token_type_id=t2.token_type_id)\n\t\t\t\t\t\tWHERE auth_token_id=:tokenId\"",
";",
"try",
"{",
"$",
"numrows",
"=",
"$",
"this",
"->",
"db",
"->",
"run_query",
"(",
"$",
"sql",
",",
"array",
"(",
"'tokenId'",
"=>",
"$",
"tokenId",
")",
")",
";",
"if",
"(",
"$",
"numrows",
"==",
"1",
")",
"{",
"$",
"tokenData",
"=",
"$",
"this",
"->",
"db",
"->",
"get_single_record",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"numrows",
"<",
"1",
")",
"{",
"$",
"tokenData",
"=",
"false",
";",
"}",
"else",
"{",
"throw",
"new",
"exception",
"(",
"\"too many records returned (\"",
".",
"count",
"(",
"$",
"data",
")",
".",
"\")\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"exception",
"(",
"__METHOD__",
".",
"\": Failed to retrieve token data::: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"exception",
"$",
"e",
")",
"{",
"throw",
"new",
"exception",
"(",
"__METHOD__",
".",
"\": failed to retrieve tokenId (\"",
".",
"$",
"tokenId",
".",
"\")::: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"(",
"$",
"tokenData",
")",
";",
"}"
]
| Retrieve data for the given ID.
@param $tokenId (int) auth_token_id to look up.
@return (array) PASS: contains data about the given ID
@return (exception) FAIL: exception contains error details. | [
"Retrieve",
"data",
"for",
"the",
"given",
"ID",
"."
]
| f6ac0d5575b01ba001b62f2467f27615d58f911c | https://github.com/crazedsanity/AuthToken/blob/f6ac0d5575b01ba001b62f2467f27615d58f911c/src/authtoken/AuthToken.class.php#L396-L423 | train |
lasallecms/lasallecms-l5-lasallecmsemail-pkg | src/Validation/Validation.php | Validation.attachmentsHaveApprovedFileExtensions | public function attachmentsHaveApprovedFileExtensions($mappedVars) {
if ($mappedVars['number_of_attachments'] == 0) {
return true;
}
$approvedFileExtensions = config('lasallecmsemail.inbound_attachments_approved_file_extensions');
if (empty($approvedFileExtensions)) {
return true;
}
for ($i = 1; $i <= $mappedVars['number_of_attachments']; $i++) {
$fileExtension = strtolower($mappedVars['attachment-'.$i]->getClientOriginalExtension());
if (!in_array($fileExtension, $approvedFileExtensions)) {
return false;
}
}
return true;
} | php | public function attachmentsHaveApprovedFileExtensions($mappedVars) {
if ($mappedVars['number_of_attachments'] == 0) {
return true;
}
$approvedFileExtensions = config('lasallecmsemail.inbound_attachments_approved_file_extensions');
if (empty($approvedFileExtensions)) {
return true;
}
for ($i = 1; $i <= $mappedVars['number_of_attachments']; $i++) {
$fileExtension = strtolower($mappedVars['attachment-'.$i]->getClientOriginalExtension());
if (!in_array($fileExtension, $approvedFileExtensions)) {
return false;
}
}
return true;
} | [
"public",
"function",
"attachmentsHaveApprovedFileExtensions",
"(",
"$",
"mappedVars",
")",
"{",
"if",
"(",
"$",
"mappedVars",
"[",
"'number_of_attachments'",
"]",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"$",
"approvedFileExtensions",
"=",
"config",
"(",
"'lasallecmsemail.inbound_attachments_approved_file_extensions'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"approvedFileExtensions",
")",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"mappedVars",
"[",
"'number_of_attachments'",
"]",
";",
"$",
"i",
"++",
")",
"{",
"$",
"fileExtension",
"=",
"strtolower",
"(",
"$",
"mappedVars",
"[",
"'attachment-'",
".",
"$",
"i",
"]",
"->",
"getClientOriginalExtension",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"fileExtension",
",",
"$",
"approvedFileExtensions",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| All attachments have approved file extensions?
@param array $mappedVars Inbound POST vars mapped to database fields
@return bool | [
"All",
"attachments",
"have",
"approved",
"file",
"extensions?"
]
| 95db5a59ab322105b9d3681cf9ab1f829c9fdb9f | https://github.com/lasallecms/lasallecms-l5-lasallecmsemail-pkg/blob/95db5a59ab322105b9d3681cf9ab1f829c9fdb9f/src/Validation/Validation.php#L45-L66 | train |
lasallecms/lasallecms-l5-lasallecmsemail-pkg | src/Validation/Validation.php | Validation.emailsComeFromListOfApprovedSenders | public function emailsComeFromListOfApprovedSenders($emailAddress) {
// are we checking that inbound emails come from a pre-approved list of senders?
if (!$this->isInboundEmailsFromAllowedSendersOnly()) {
// we are *not* checking that emails come from a pre-approved list of senders
return true;
}
// yes, we are checking that emails come from a pre-approved list of senders
if ($this->isInboundEmailsFromAllowedSendersOnlyListOfSsenders($emailAddress)) {
// the sender is, indeed, on the list of pre-approved senders
return true;
}
// the sender is not on the list of pre-approved senders
return false;
} | php | public function emailsComeFromListOfApprovedSenders($emailAddress) {
// are we checking that inbound emails come from a pre-approved list of senders?
if (!$this->isInboundEmailsFromAllowedSendersOnly()) {
// we are *not* checking that emails come from a pre-approved list of senders
return true;
}
// yes, we are checking that emails come from a pre-approved list of senders
if ($this->isInboundEmailsFromAllowedSendersOnlyListOfSsenders($emailAddress)) {
// the sender is, indeed, on the list of pre-approved senders
return true;
}
// the sender is not on the list of pre-approved senders
return false;
} | [
"public",
"function",
"emailsComeFromListOfApprovedSenders",
"(",
"$",
"emailAddress",
")",
"{",
"// are we checking that inbound emails come from a pre-approved list of senders?",
"if",
"(",
"!",
"$",
"this",
"->",
"isInboundEmailsFromAllowedSendersOnly",
"(",
")",
")",
"{",
"// we are *not* checking that emails come from a pre-approved list of senders",
"return",
"true",
";",
"}",
"// yes, we are checking that emails come from a pre-approved list of senders",
"if",
"(",
"$",
"this",
"->",
"isInboundEmailsFromAllowedSendersOnlyListOfSsenders",
"(",
"$",
"emailAddress",
")",
")",
"{",
"// the sender is, indeed, on the list of pre-approved senders",
"return",
"true",
";",
"}",
"// the sender is not on the list of pre-approved senders",
"return",
"false",
";",
"}"
]
| Check if emails must come from a list of approved senders. That is, the person sending
the email is allowed to send us inbound emails.
@param string $emailAddress Email address of the person sending the email
@return bool | [
"Check",
"if",
"emails",
"must",
"come",
"from",
"a",
"list",
"of",
"approved",
"senders",
".",
"That",
"is",
"the",
"person",
"sending",
"the",
"email",
"is",
"allowed",
"to",
"send",
"us",
"inbound",
"emails",
"."
]
| 95db5a59ab322105b9d3681cf9ab1f829c9fdb9f | https://github.com/lasallecms/lasallecms-l5-lasallecmsemail-pkg/blob/95db5a59ab322105b9d3681cf9ab1f829c9fdb9f/src/Validation/Validation.php#L75-L93 | train |
Torann/skosh-generator | src/Twig/Extensions/SocialShare.php | SocialShare.generate | public static function generate($network, Content $page)
{
// Get text
$text = self::truncate($page->description, 137);
// Replace template with values
return str_replace([
'{url}',
'{title}',
'{text}',
'{image}'
], [
urlencode($page->url),
urlencode($page->title),
urlencode($text),
urlencode($page->get('image'))
], self::$templates[$network]);
} | php | public static function generate($network, Content $page)
{
// Get text
$text = self::truncate($page->description, 137);
// Replace template with values
return str_replace([
'{url}',
'{title}',
'{text}',
'{image}'
], [
urlencode($page->url),
urlencode($page->title),
urlencode($text),
urlencode($page->get('image'))
], self::$templates[$network]);
} | [
"public",
"static",
"function",
"generate",
"(",
"$",
"network",
",",
"Content",
"$",
"page",
")",
"{",
"// Get text",
"$",
"text",
"=",
"self",
"::",
"truncate",
"(",
"$",
"page",
"->",
"description",
",",
"137",
")",
";",
"// Replace template with values",
"return",
"str_replace",
"(",
"[",
"'{url}'",
",",
"'{title}'",
",",
"'{text}'",
",",
"'{image}'",
"]",
",",
"[",
"urlencode",
"(",
"$",
"page",
"->",
"url",
")",
",",
"urlencode",
"(",
"$",
"page",
"->",
"title",
")",
",",
"urlencode",
"(",
"$",
"text",
")",
",",
"urlencode",
"(",
"$",
"page",
"->",
"get",
"(",
"'image'",
")",
")",
"]",
",",
"self",
"::",
"$",
"templates",
"[",
"$",
"network",
"]",
")",
";",
"}"
]
| Generate social network link.
@param string $network
@param Content $page
@return string | [
"Generate",
"social",
"network",
"link",
"."
]
| ea60e037d92398d7c146eb2349735d5692e3c48c | https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Twig/Extensions/SocialShare.php#L35-L52 | train |
KDF5000/EasyThink | src/ThinkPHP/Library/Vendor/Smarty/sysplugins/smarty_internal_template.php | Smarty_Internal_Template.decodeProperties | public function decodeProperties($properties, $cache = false)
{
$this->has_nocache_code = $properties['has_nocache_code'];
$this->properties['nocache_hash'] = $properties['nocache_hash'];
if (isset($properties['cache_lifetime'])) {
$this->properties['cache_lifetime'] = $properties['cache_lifetime'];
}
if (isset($properties['file_dependency'])) {
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']);
}
if (!empty($properties['function'])) {
$this->properties['function'] = array_merge($this->properties['function'], $properties['function']);
$this->smarty->template_functions = array_merge($this->smarty->template_functions, $properties['function']);
}
$this->properties['version'] = (isset($properties['version'])) ? $properties['version'] : '';
$this->properties['unifunc'] = $properties['unifunc'];
// check file dependencies at compiled code
$is_valid = true;
if ($this->properties['version'] != Smarty::SMARTY_VERSION) {
$is_valid = false;
} else if (((!$cache && $this->smarty->compile_check && empty($this->compiled->_properties) && !$this->compiled->isCompiled) || $cache && ($this->smarty->compile_check === true || $this->smarty->compile_check === Smarty::COMPILECHECK_ON)) && !empty($this->properties['file_dependency'])) {
foreach ($this->properties['file_dependency'] as $_file_to_check) {
if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'php') {
if ($this->source->filepath == $_file_to_check[0] && isset($this->source->timestamp)) {
// do not recheck current template
$mtime = $this->source->timestamp;
} else {
// file and php types can be checked without loading the respective resource handlers
$mtime = filemtime($_file_to_check[0]);
}
} elseif ($_file_to_check[2] == 'string') {
continue;
} else {
$source = Smarty_Resource::source(null, $this->smarty, $_file_to_check[0]);
$mtime = $source->timestamp;
}
if ($mtime > $_file_to_check[1]) {
$is_valid = false;
break;
}
}
}
if ($cache) {
$this->cached->valid = $is_valid;
} else {
$this->mustCompile = !$is_valid;
}
// store data in reusable Smarty_Template_Compiled
if (!$cache) {
$this->compiled->_properties = $properties;
}
return $is_valid;
} | php | public function decodeProperties($properties, $cache = false)
{
$this->has_nocache_code = $properties['has_nocache_code'];
$this->properties['nocache_hash'] = $properties['nocache_hash'];
if (isset($properties['cache_lifetime'])) {
$this->properties['cache_lifetime'] = $properties['cache_lifetime'];
}
if (isset($properties['file_dependency'])) {
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']);
}
if (!empty($properties['function'])) {
$this->properties['function'] = array_merge($this->properties['function'], $properties['function']);
$this->smarty->template_functions = array_merge($this->smarty->template_functions, $properties['function']);
}
$this->properties['version'] = (isset($properties['version'])) ? $properties['version'] : '';
$this->properties['unifunc'] = $properties['unifunc'];
// check file dependencies at compiled code
$is_valid = true;
if ($this->properties['version'] != Smarty::SMARTY_VERSION) {
$is_valid = false;
} else if (((!$cache && $this->smarty->compile_check && empty($this->compiled->_properties) && !$this->compiled->isCompiled) || $cache && ($this->smarty->compile_check === true || $this->smarty->compile_check === Smarty::COMPILECHECK_ON)) && !empty($this->properties['file_dependency'])) {
foreach ($this->properties['file_dependency'] as $_file_to_check) {
if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'php') {
if ($this->source->filepath == $_file_to_check[0] && isset($this->source->timestamp)) {
// do not recheck current template
$mtime = $this->source->timestamp;
} else {
// file and php types can be checked without loading the respective resource handlers
$mtime = filemtime($_file_to_check[0]);
}
} elseif ($_file_to_check[2] == 'string') {
continue;
} else {
$source = Smarty_Resource::source(null, $this->smarty, $_file_to_check[0]);
$mtime = $source->timestamp;
}
if ($mtime > $_file_to_check[1]) {
$is_valid = false;
break;
}
}
}
if ($cache) {
$this->cached->valid = $is_valid;
} else {
$this->mustCompile = !$is_valid;
}
// store data in reusable Smarty_Template_Compiled
if (!$cache) {
$this->compiled->_properties = $properties;
}
return $is_valid;
} | [
"public",
"function",
"decodeProperties",
"(",
"$",
"properties",
",",
"$",
"cache",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"has_nocache_code",
"=",
"$",
"properties",
"[",
"'has_nocache_code'",
"]",
";",
"$",
"this",
"->",
"properties",
"[",
"'nocache_hash'",
"]",
"=",
"$",
"properties",
"[",
"'nocache_hash'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"properties",
"[",
"'cache_lifetime'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"properties",
"[",
"'cache_lifetime'",
"]",
"=",
"$",
"properties",
"[",
"'cache_lifetime'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"properties",
"[",
"'file_dependency'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"properties",
"[",
"'file_dependency'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"properties",
"[",
"'file_dependency'",
"]",
",",
"$",
"properties",
"[",
"'file_dependency'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"properties",
"[",
"'function'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"properties",
"[",
"'function'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"properties",
"[",
"'function'",
"]",
",",
"$",
"properties",
"[",
"'function'",
"]",
")",
";",
"$",
"this",
"->",
"smarty",
"->",
"template_functions",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"smarty",
"->",
"template_functions",
",",
"$",
"properties",
"[",
"'function'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"properties",
"[",
"'version'",
"]",
"=",
"(",
"isset",
"(",
"$",
"properties",
"[",
"'version'",
"]",
")",
")",
"?",
"$",
"properties",
"[",
"'version'",
"]",
":",
"''",
";",
"$",
"this",
"->",
"properties",
"[",
"'unifunc'",
"]",
"=",
"$",
"properties",
"[",
"'unifunc'",
"]",
";",
"// check file dependencies at compiled code",
"$",
"is_valid",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"properties",
"[",
"'version'",
"]",
"!=",
"Smarty",
"::",
"SMARTY_VERSION",
")",
"{",
"$",
"is_valid",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"(",
"(",
"!",
"$",
"cache",
"&&",
"$",
"this",
"->",
"smarty",
"->",
"compile_check",
"&&",
"empty",
"(",
"$",
"this",
"->",
"compiled",
"->",
"_properties",
")",
"&&",
"!",
"$",
"this",
"->",
"compiled",
"->",
"isCompiled",
")",
"||",
"$",
"cache",
"&&",
"(",
"$",
"this",
"->",
"smarty",
"->",
"compile_check",
"===",
"true",
"||",
"$",
"this",
"->",
"smarty",
"->",
"compile_check",
"===",
"Smarty",
"::",
"COMPILECHECK_ON",
")",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"properties",
"[",
"'file_dependency'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"[",
"'file_dependency'",
"]",
"as",
"$",
"_file_to_check",
")",
"{",
"if",
"(",
"$",
"_file_to_check",
"[",
"2",
"]",
"==",
"'file'",
"||",
"$",
"_file_to_check",
"[",
"2",
"]",
"==",
"'php'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"source",
"->",
"filepath",
"==",
"$",
"_file_to_check",
"[",
"0",
"]",
"&&",
"isset",
"(",
"$",
"this",
"->",
"source",
"->",
"timestamp",
")",
")",
"{",
"// do not recheck current template",
"$",
"mtime",
"=",
"$",
"this",
"->",
"source",
"->",
"timestamp",
";",
"}",
"else",
"{",
"// file and php types can be checked without loading the respective resource handlers",
"$",
"mtime",
"=",
"filemtime",
"(",
"$",
"_file_to_check",
"[",
"0",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"_file_to_check",
"[",
"2",
"]",
"==",
"'string'",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"$",
"source",
"=",
"Smarty_Resource",
"::",
"source",
"(",
"null",
",",
"$",
"this",
"->",
"smarty",
",",
"$",
"_file_to_check",
"[",
"0",
"]",
")",
";",
"$",
"mtime",
"=",
"$",
"source",
"->",
"timestamp",
";",
"}",
"if",
"(",
"$",
"mtime",
">",
"$",
"_file_to_check",
"[",
"1",
"]",
")",
"{",
"$",
"is_valid",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"cache",
")",
"{",
"$",
"this",
"->",
"cached",
"->",
"valid",
"=",
"$",
"is_valid",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"mustCompile",
"=",
"!",
"$",
"is_valid",
";",
"}",
"// store data in reusable Smarty_Template_Compiled",
"if",
"(",
"!",
"$",
"cache",
")",
"{",
"$",
"this",
"->",
"compiled",
"->",
"_properties",
"=",
"$",
"properties",
";",
"}",
"return",
"$",
"is_valid",
";",
"}"
]
| This function is executed automatically when a compiled or cached template file is included
- Decode saved properties from compiled template and cache files
- Check if compiled or cache file is valid
@param array $properties special template properties
@param bool $cache flag if called from cache file
@return bool flag if compiled or cache file is valid | [
"This",
"function",
"is",
"executed",
"automatically",
"when",
"a",
"compiled",
"or",
"cached",
"template",
"file",
"is",
"included"
]
| 86efc9c8a0d504e01e2fea55868227fdc8928841 | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/Smarty/sysplugins/smarty_internal_template.php#L419-L471 | train |
gplcart/cli | controllers/commands/Store.php | Store.cmdGetStore | public function cmdGetStore()
{
$result = $this->getListStore();
$this->outputFormat($result);
$this->outputFormatTableStore($result);
$this->output();
} | php | public function cmdGetStore()
{
$result = $this->getListStore();
$this->outputFormat($result);
$this->outputFormatTableStore($result);
$this->output();
} | [
"public",
"function",
"cmdGetStore",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getListStore",
"(",
")",
";",
"$",
"this",
"->",
"outputFormat",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"outputFormatTableStore",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
]
| Callback for "store-get" command | [
"Callback",
"for",
"store",
"-",
"get",
"command"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L58-L64 | train |
gplcart/cli | controllers/commands/Store.php | Store.cmdDeleteStore | public function cmdDeleteStore()
{
$id = $this->getParam(0);
if (empty($id) || !is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
if (!$this->store->delete($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->output();
} | php | public function cmdDeleteStore()
{
$id = $this->getParam(0);
if (empty($id) || !is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
if (!$this->store->delete($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->output();
} | [
"public",
"function",
"cmdDeleteStore",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"store",
"->",
"delete",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
]
| Callback for "store-delete" command | [
"Callback",
"for",
"store",
"-",
"delete",
"command"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L69-L82 | train |
gplcart/cli | controllers/commands/Store.php | Store.cmdUpdateStore | public function cmdUpdateStore()
{
$params = $this->getParam();
if (empty($params[0]) || count($params) < 2) {
$this->errorAndExit($this->text('Invalid command'));
}
if (!is_numeric($params[0])) {
$this->errorAndExit($this->text('Invalid argument'));
}
$this->setSubmitted(null, $params);
$this->setSubmitted('update', $params[0]);
$this->setSubmittedJson('data');
$this->validateComponent('store');
$this->updateStore($params[0]);
$this->output();
} | php | public function cmdUpdateStore()
{
$params = $this->getParam();
if (empty($params[0]) || count($params) < 2) {
$this->errorAndExit($this->text('Invalid command'));
}
if (!is_numeric($params[0])) {
$this->errorAndExit($this->text('Invalid argument'));
}
$this->setSubmitted(null, $params);
$this->setSubmitted('update', $params[0]);
$this->setSubmittedJson('data');
$this->validateComponent('store');
$this->updateStore($params[0]);
$this->output();
} | [
"public",
"function",
"cmdUpdateStore",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getParam",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"0",
"]",
")",
"||",
"count",
"(",
"$",
"params",
")",
"<",
"2",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid command'",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"'update'",
",",
"$",
"params",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"setSubmittedJson",
"(",
"'data'",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'store'",
")",
";",
"$",
"this",
"->",
"updateStore",
"(",
"$",
"params",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
]
| Callback for "store-update" command | [
"Callback",
"for",
"store",
"-",
"update",
"command"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L101-L121 | train |
gplcart/cli | controllers/commands/Store.php | Store.setStatusStore | protected function setStatusStore($status)
{
$id = $this->getParam(0);
$all = $this->getParam('all');
if (!isset($id) && empty($all)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = false;
if (isset($id)) {
if (!is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->store->update($id, array('status' => $status));
} else if (!empty($all)) {
$updated = $count = 0;
foreach ((array) $this->store->getList() as $store) {
$count++;
$updated += (int) $this->store->update($store['store_id'], array('status' => $status));
}
$result = $count && $count == $updated;
}
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
} | php | protected function setStatusStore($status)
{
$id = $this->getParam(0);
$all = $this->getParam('all');
if (!isset($id) && empty($all)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = false;
if (isset($id)) {
if (!is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->store->update($id, array('status' => $status));
} else if (!empty($all)) {
$updated = $count = 0;
foreach ((array) $this->store->getList() as $store) {
$count++;
$updated += (int) $this->store->update($store['store_id'], array('status' => $status));
}
$result = $count && $count == $updated;
}
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
} | [
"protected",
"function",
"setStatusStore",
"(",
"$",
"status",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"$",
"all",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'all'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
"&&",
"empty",
"(",
"$",
"all",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid command'",
")",
")",
";",
"}",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"store",
"->",
"update",
"(",
"$",
"id",
",",
"array",
"(",
"'status'",
"=>",
"$",
"status",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"all",
")",
")",
"{",
"$",
"updated",
"=",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"store",
"->",
"getList",
"(",
")",
"as",
"$",
"store",
")",
"{",
"$",
"count",
"++",
";",
"$",
"updated",
"+=",
"(",
"int",
")",
"$",
"this",
"->",
"store",
"->",
"update",
"(",
"$",
"store",
"[",
"'store_id'",
"]",
",",
"array",
"(",
"'status'",
"=>",
"$",
"status",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"count",
"&&",
"$",
"count",
"==",
"$",
"updated",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"}"
]
| Sets status for one or several stores
@param bool $status | [
"Sets",
"status",
"for",
"one",
"or",
"several",
"stores"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L127-L160 | train |
gplcart/cli | controllers/commands/Store.php | Store.submitAddStore | protected function submitAddStore()
{
$this->setSubmitted(null, $this->getParam());
$this->setSubmittedJson('data');
$this->validateComponent('store');
$this->addStore();
} | php | protected function submitAddStore()
{
$this->setSubmitted(null, $this->getParam());
$this->setSubmittedJson('data');
$this->validateComponent('store');
$this->addStore();
} | [
"protected",
"function",
"submitAddStore",
"(",
")",
"{",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"this",
"->",
"getParam",
"(",
")",
")",
";",
"$",
"this",
"->",
"setSubmittedJson",
"(",
"'data'",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'store'",
")",
";",
"$",
"this",
"->",
"addStore",
"(",
")",
";",
"}"
]
| Add a new store at once | [
"Add",
"a",
"new",
"store",
"at",
"once"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L230-L237 | train |
gplcart/cli | controllers/commands/Store.php | Store.addStore | protected function addStore()
{
if (!$this->isError()) {
$id = $this->store->add($this->getSubmitted());
if (empty($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->line($id);
}
} | php | protected function addStore()
{
if (!$this->isError()) {
$id = $this->store->add($this->getSubmitted());
if (empty($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->line($id);
}
} | [
"protected",
"function",
"addStore",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"store",
"->",
"add",
"(",
"$",
"this",
"->",
"getSubmitted",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"$",
"id",
")",
";",
"}",
"}"
]
| Add a store | [
"Add",
"a",
"store"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L242-L251 | train |
gplcart/cli | controllers/commands/Store.php | Store.wizardAddStore | protected function wizardAddStore()
{
$this->validatePrompt('name', $this->text('Name'), 'store');
$this->validatePrompt('domain', $this->text('Domain or IP'), 'store');
$this->validatePrompt('basepath', $this->text('Path'), 'store', '');
$this->validatePrompt('status', $this->text('Status'), 'store', 0);
$this->setSubmittedJson('data');
$this->validateComponent('store');
$this->addStore();
} | php | protected function wizardAddStore()
{
$this->validatePrompt('name', $this->text('Name'), 'store');
$this->validatePrompt('domain', $this->text('Domain or IP'), 'store');
$this->validatePrompt('basepath', $this->text('Path'), 'store', '');
$this->validatePrompt('status', $this->text('Status'), 'store', 0);
$this->setSubmittedJson('data');
$this->validateComponent('store');
$this->addStore();
} | [
"protected",
"function",
"wizardAddStore",
"(",
")",
"{",
"$",
"this",
"->",
"validatePrompt",
"(",
"'name'",
",",
"$",
"this",
"->",
"text",
"(",
"'Name'",
")",
",",
"'store'",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'domain'",
",",
"$",
"this",
"->",
"text",
"(",
"'Domain or IP'",
")",
",",
"'store'",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'basepath'",
",",
"$",
"this",
"->",
"text",
"(",
"'Path'",
")",
",",
"'store'",
",",
"''",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'status'",
",",
"$",
"this",
"->",
"text",
"(",
"'Status'",
")",
",",
"'store'",
",",
"0",
")",
";",
"$",
"this",
"->",
"setSubmittedJson",
"(",
"'data'",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'store'",
")",
";",
"$",
"this",
"->",
"addStore",
"(",
")",
";",
"}"
]
| Add a new store step by step | [
"Add",
"a",
"new",
"store",
"step",
"by",
"step"
]
| e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Store.php#L256-L266 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/utils/ClassUtils.php | ClassUtils.getQualifiedType | public static function getQualifiedType($value)
{
if (is_null($value))
return 'NULL';
if (is_string($value))
return 'string';
else if (is_array($value)) {
if (!empty ($value)) {
foreach ($value as $val) {
$array_type = self::getQualifiedType($val);
if ($array_type != null)
break;
}
return $array_type . '[]';
} else {
return 'array';
}
} else if (is_int($value))
return 'int';
else if (is_bool($value))
return 'boolean';
else if (is_float($value))
return 'float';
else if (is_object($value))
return get_class($value);
} | php | public static function getQualifiedType($value)
{
if (is_null($value))
return 'NULL';
if (is_string($value))
return 'string';
else if (is_array($value)) {
if (!empty ($value)) {
foreach ($value as $val) {
$array_type = self::getQualifiedType($val);
if ($array_type != null)
break;
}
return $array_type . '[]';
} else {
return 'array';
}
} else if (is_int($value))
return 'int';
else if (is_bool($value))
return 'boolean';
else if (is_float($value))
return 'float';
else if (is_object($value))
return get_class($value);
} | [
"public",
"static",
"function",
"getQualifiedType",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"return",
"'NULL'",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"return",
"'string'",
";",
"else",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"$",
"array_type",
"=",
"self",
"::",
"getQualifiedType",
"(",
"$",
"val",
")",
";",
"if",
"(",
"$",
"array_type",
"!=",
"null",
")",
"break",
";",
"}",
"return",
"$",
"array_type",
".",
"'[]'",
";",
"}",
"else",
"{",
"return",
"'array'",
";",
"}",
"}",
"else",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"return",
"'int'",
";",
"else",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"return",
"'boolean'",
";",
"else",
"if",
"(",
"is_float",
"(",
"$",
"value",
")",
")",
"return",
"'float'",
";",
"else",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"return",
"get_class",
"(",
"$",
"value",
")",
";",
"}"
]
| Determines the type of the specified value
@param mixed $value Any value
@return string The type of the {@link $value} specified | [
"Determines",
"the",
"type",
"of",
"the",
"specified",
"value"
]
| 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/ClassUtils.php#L57-L83 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/utils/ClassUtils.php | ClassUtils.compare | public static function compare($val1, $val2)
{
if(in_array(self::getQualifiedType($val1), array('int','boolean', 'float', 'NULL')) )
return $val1 == $val2 ? 0 : (($val1 < $val2) ? -1 : 1);
// if(self::getQualifiedType($val1) == 'string' )
// return strcmp($val1, $val2);
if(self::isSubclass($val1, 'Date'))
return self::compare($val1->toUnix(), $val2->toUnix());
return strcmp((string)$val1, (string)$val2);
} | php | public static function compare($val1, $val2)
{
if(in_array(self::getQualifiedType($val1), array('int','boolean', 'float', 'NULL')) )
return $val1 == $val2 ? 0 : (($val1 < $val2) ? -1 : 1);
// if(self::getQualifiedType($val1) == 'string' )
// return strcmp($val1, $val2);
if(self::isSubclass($val1, 'Date'))
return self::compare($val1->toUnix(), $val2->toUnix());
return strcmp((string)$val1, (string)$val2);
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"val1",
",",
"$",
"val2",
")",
"{",
"if",
"(",
"in_array",
"(",
"self",
"::",
"getQualifiedType",
"(",
"$",
"val1",
")",
",",
"array",
"(",
"'int'",
",",
"'boolean'",
",",
"'float'",
",",
"'NULL'",
")",
")",
")",
"return",
"$",
"val1",
"==",
"$",
"val2",
"?",
"0",
":",
"(",
"(",
"$",
"val1",
"<",
"$",
"val2",
")",
"?",
"-",
"1",
":",
"1",
")",
";",
"// if(self::getQualifiedType($val1) == 'string' )",
"// return strcmp($val1, $val2);",
"if",
"(",
"self",
"::",
"isSubclass",
"(",
"$",
"val1",
",",
"'Date'",
")",
")",
"return",
"self",
"::",
"compare",
"(",
"$",
"val1",
"->",
"toUnix",
"(",
")",
",",
"$",
"val2",
"->",
"toUnix",
"(",
")",
")",
";",
"return",
"strcmp",
"(",
"(",
"string",
")",
"$",
"val1",
",",
"(",
"string",
")",
"$",
"val2",
")",
";",
"}"
]
| Compare two items for equivalence. Supports Date objects and all native types.
@param mixed $val1 The first value
@param mixed $val2 The second value
@return boolean Will be true if the items are equivalent. | [
"Compare",
"two",
"items",
"for",
"equivalence",
".",
"Supports",
"Date",
"objects",
"and",
"all",
"native",
"types",
"."
]
| 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/ClassUtils.php#L93-L103 | train |
CalderaWP/caldera-interop | src/Attribute.php | Attribute.fromArray | public static function fromArray(array $items = []): Attribute
{
$obj = new static();
$obj->setName($items[ 'name' ])
->setDescription(
isset($items[ 'description' ]) && is_string($items[ 'description' ]) ? $items[ 'description' ] : ''
)
->setSqlDescriptor(isset($items[ 'sqlDescriptor' ]) && is_string($items[ 'sqlDescriptor' ]) ? $items[ 'sqlDescriptor' ] : '')
->setFormat(
isset($items[ 'format' ]) && ($items[ 'format' ]) ? $items[ 'format' ] : '%s'
)
->setDataType(
isset($items[ 'dataType' ]) && is_string($items[ 'dataType' ]) ? $items[ 'dataType' ] : 'string'
);
if (! isset($items[ 'dataType' ]) && isset($items[ 'type' ]) && is_string($items[ 'type' ])) {
$obj->setDataType($items[ 'type' ]);
}
if (isset($items[ 'validateCallback' ]) && is_callable($items[ 'validateCallback' ])) {
$obj->setValidateCallback($items[ 'validateCallback' ]);
}
if (isset($items[ 'sanitizeCallback' ]) && is_callable($items[ 'sanitizeCallback' ])) {
$obj->setSanitizeCallback($items[ 'sanitizeCallback' ]);
}
if (isset($items[ 'required' ])) {
$obj->setRequired((bool)$items[ 'required' ]);
}
return $obj;
} | php | public static function fromArray(array $items = []): Attribute
{
$obj = new static();
$obj->setName($items[ 'name' ])
->setDescription(
isset($items[ 'description' ]) && is_string($items[ 'description' ]) ? $items[ 'description' ] : ''
)
->setSqlDescriptor(isset($items[ 'sqlDescriptor' ]) && is_string($items[ 'sqlDescriptor' ]) ? $items[ 'sqlDescriptor' ] : '')
->setFormat(
isset($items[ 'format' ]) && ($items[ 'format' ]) ? $items[ 'format' ] : '%s'
)
->setDataType(
isset($items[ 'dataType' ]) && is_string($items[ 'dataType' ]) ? $items[ 'dataType' ] : 'string'
);
if (! isset($items[ 'dataType' ]) && isset($items[ 'type' ]) && is_string($items[ 'type' ])) {
$obj->setDataType($items[ 'type' ]);
}
if (isset($items[ 'validateCallback' ]) && is_callable($items[ 'validateCallback' ])) {
$obj->setValidateCallback($items[ 'validateCallback' ]);
}
if (isset($items[ 'sanitizeCallback' ]) && is_callable($items[ 'sanitizeCallback' ])) {
$obj->setSanitizeCallback($items[ 'sanitizeCallback' ]);
}
if (isset($items[ 'required' ])) {
$obj->setRequired((bool)$items[ 'required' ]);
}
return $obj;
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"items",
"=",
"[",
"]",
")",
":",
"Attribute",
"{",
"$",
"obj",
"=",
"new",
"static",
"(",
")",
";",
"$",
"obj",
"->",
"setName",
"(",
"$",
"items",
"[",
"'name'",
"]",
")",
"->",
"setDescription",
"(",
"isset",
"(",
"$",
"items",
"[",
"'description'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"items",
"[",
"'description'",
"]",
")",
"?",
"$",
"items",
"[",
"'description'",
"]",
":",
"''",
")",
"->",
"setSqlDescriptor",
"(",
"isset",
"(",
"$",
"items",
"[",
"'sqlDescriptor'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"items",
"[",
"'sqlDescriptor'",
"]",
")",
"?",
"$",
"items",
"[",
"'sqlDescriptor'",
"]",
":",
"''",
")",
"->",
"setFormat",
"(",
"isset",
"(",
"$",
"items",
"[",
"'format'",
"]",
")",
"&&",
"(",
"$",
"items",
"[",
"'format'",
"]",
")",
"?",
"$",
"items",
"[",
"'format'",
"]",
":",
"'%s'",
")",
"->",
"setDataType",
"(",
"isset",
"(",
"$",
"items",
"[",
"'dataType'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"items",
"[",
"'dataType'",
"]",
")",
"?",
"$",
"items",
"[",
"'dataType'",
"]",
":",
"'string'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"items",
"[",
"'dataType'",
"]",
")",
"&&",
"isset",
"(",
"$",
"items",
"[",
"'type'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"items",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"obj",
"->",
"setDataType",
"(",
"$",
"items",
"[",
"'type'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"items",
"[",
"'validateCallback'",
"]",
")",
"&&",
"is_callable",
"(",
"$",
"items",
"[",
"'validateCallback'",
"]",
")",
")",
"{",
"$",
"obj",
"->",
"setValidateCallback",
"(",
"$",
"items",
"[",
"'validateCallback'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"items",
"[",
"'sanitizeCallback'",
"]",
")",
"&&",
"is_callable",
"(",
"$",
"items",
"[",
"'sanitizeCallback'",
"]",
")",
")",
"{",
"$",
"obj",
"->",
"setSanitizeCallback",
"(",
"$",
"items",
"[",
"'sanitizeCallback'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"items",
"[",
"'required'",
"]",
")",
")",
"{",
"$",
"obj",
"->",
"setRequired",
"(",
"(",
"bool",
")",
"$",
"items",
"[",
"'required'",
"]",
")",
";",
"}",
"return",
"$",
"obj",
";",
"}"
]
| Create item from array
@param array $items
@return Attribute | [
"Create",
"item",
"from",
"array"
]
| d25c4bc930200b314fbd42d084080b5d85261c94 | https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/Attribute.php#L41-L72 | train |
Stillat/Common | src/Stillat/Common/Math/OperationSequenceWriter.php | OperationSequenceWriter.write | public function write(Collection $sequences)
{
$sequences = clone $sequences;
$expression = '';
if ($sequences->count() > 0) {
$sequences = $sequences->reverse();
$length = $sequences->count();
for ($i = 0; $i < $length; $i++) {
$sequence = $sequences[$i];
if (isset($sequences[$i + 1])) {
$next = $sequences[$i + 1];
} else {
$next = null;
}
$expression = $this->getNextPart($sequence[0], $sequence[1], $next) . $expression;
}
}
return $expression;
} | php | public function write(Collection $sequences)
{
$sequences = clone $sequences;
$expression = '';
if ($sequences->count() > 0) {
$sequences = $sequences->reverse();
$length = $sequences->count();
for ($i = 0; $i < $length; $i++) {
$sequence = $sequences[$i];
if (isset($sequences[$i + 1])) {
$next = $sequences[$i + 1];
} else {
$next = null;
}
$expression = $this->getNextPart($sequence[0], $sequence[1], $next) . $expression;
}
}
return $expression;
} | [
"public",
"function",
"write",
"(",
"Collection",
"$",
"sequences",
")",
"{",
"$",
"sequences",
"=",
"clone",
"$",
"sequences",
";",
"$",
"expression",
"=",
"''",
";",
"if",
"(",
"$",
"sequences",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"sequences",
"=",
"$",
"sequences",
"->",
"reverse",
"(",
")",
";",
"$",
"length",
"=",
"$",
"sequences",
"->",
"count",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sequence",
"=",
"$",
"sequences",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"sequences",
"[",
"$",
"i",
"+",
"1",
"]",
")",
")",
"{",
"$",
"next",
"=",
"$",
"sequences",
"[",
"$",
"i",
"+",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"next",
"=",
"null",
";",
"}",
"$",
"expression",
"=",
"$",
"this",
"->",
"getNextPart",
"(",
"$",
"sequence",
"[",
"0",
"]",
",",
"$",
"sequence",
"[",
"1",
"]",
",",
"$",
"next",
")",
".",
"$",
"expression",
";",
"}",
"}",
"return",
"$",
"expression",
";",
"}"
]
| Writes a sequence history to a string representation of the expression.
@param \Collection\Collection $sequences
@return string | [
"Writes",
"a",
"sequence",
"history",
"to",
"a",
"string",
"representation",
"of",
"the",
"expression",
"."
]
| 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/OperationSequenceWriter.php#L54-L74 | train |
modulusphp/http | Middleware/MustHandleCors.php | MustHandleCors.cors | private function cors($request)
{
$origin = $request->server->http_origin;
$allowed = Config::get('cors.allowedOrigins');
if (in_array('*', $allowed) || in_array($origin, $allowed) ) {
$this->withHeaders($request);
}
} | php | private function cors($request)
{
$origin = $request->server->http_origin;
$allowed = Config::get('cors.allowedOrigins');
if (in_array('*', $allowed) || in_array($origin, $allowed) ) {
$this->withHeaders($request);
}
} | [
"private",
"function",
"cors",
"(",
"$",
"request",
")",
"{",
"$",
"origin",
"=",
"$",
"request",
"->",
"server",
"->",
"http_origin",
";",
"$",
"allowed",
"=",
"Config",
"::",
"get",
"(",
"'cors.allowedOrigins'",
")",
";",
"if",
"(",
"in_array",
"(",
"'*'",
",",
"$",
"allowed",
")",
"||",
"in_array",
"(",
"$",
"origin",
",",
"$",
"allowed",
")",
")",
"{",
"$",
"this",
"->",
"withHeaders",
"(",
"$",
"request",
")",
";",
"}",
"}"
]
| Handles cors.
@param \Modulus\Http\Request $requests
@return void | [
"Handles",
"cors",
"."
]
| fc5c0f2b582a04de1685578d3fb790686a0a240c | https://github.com/modulusphp/http/blob/fc5c0f2b582a04de1685578d3fb790686a0a240c/Middleware/MustHandleCors.php#L33-L41 | train |
modulusphp/http | Middleware/MustHandleCors.php | MustHandleCors.withHeaders | private function withHeaders($request)
{
$headers = Config::get('cors.allowedHeaders');
$methods = Config::get('cors.allowedMethods');
$exposed = Config::get('cors.exposedHeaders');
$maxAge = Config::get('cors.maxAge');
$request->headers->addMany([
'Access-Control-Allow-Credentials' => Config::get('cors.supportsCredentials'),
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Headers' => implode(', ', $headers),
'Access-Control-Allow-Methods' => implode(', ', $methods),
]);
if (count($exposed) > 0) {
$request->headers->add('Access-Control-Exposed-Headers', implode(', ', $exposed));
}
if ($maxAge > 0) {
$request->headers->add('Access-Control-Max-Age', $maxAge);
}
} | php | private function withHeaders($request)
{
$headers = Config::get('cors.allowedHeaders');
$methods = Config::get('cors.allowedMethods');
$exposed = Config::get('cors.exposedHeaders');
$maxAge = Config::get('cors.maxAge');
$request->headers->addMany([
'Access-Control-Allow-Credentials' => Config::get('cors.supportsCredentials'),
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Headers' => implode(', ', $headers),
'Access-Control-Allow-Methods' => implode(', ', $methods),
]);
if (count($exposed) > 0) {
$request->headers->add('Access-Control-Exposed-Headers', implode(', ', $exposed));
}
if ($maxAge > 0) {
$request->headers->add('Access-Control-Max-Age', $maxAge);
}
} | [
"private",
"function",
"withHeaders",
"(",
"$",
"request",
")",
"{",
"$",
"headers",
"=",
"Config",
"::",
"get",
"(",
"'cors.allowedHeaders'",
")",
";",
"$",
"methods",
"=",
"Config",
"::",
"get",
"(",
"'cors.allowedMethods'",
")",
";",
"$",
"exposed",
"=",
"Config",
"::",
"get",
"(",
"'cors.exposedHeaders'",
")",
";",
"$",
"maxAge",
"=",
"Config",
"::",
"get",
"(",
"'cors.maxAge'",
")",
";",
"$",
"request",
"->",
"headers",
"->",
"addMany",
"(",
"[",
"'Access-Control-Allow-Credentials'",
"=>",
"Config",
"::",
"get",
"(",
"'cors.supportsCredentials'",
")",
",",
"'Access-Control-Allow-Origin'",
"=>",
"'*'",
",",
"'Access-Control-Allow-Headers'",
"=>",
"implode",
"(",
"', '",
",",
"$",
"headers",
")",
",",
"'Access-Control-Allow-Methods'",
"=>",
"implode",
"(",
"', '",
",",
"$",
"methods",
")",
",",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"exposed",
")",
">",
"0",
")",
"{",
"$",
"request",
"->",
"headers",
"->",
"add",
"(",
"'Access-Control-Exposed-Headers'",
",",
"implode",
"(",
"', '",
",",
"$",
"exposed",
")",
")",
";",
"}",
"if",
"(",
"$",
"maxAge",
">",
"0",
")",
"{",
"$",
"request",
"->",
"headers",
"->",
"add",
"(",
"'Access-Control-Max-Age'",
",",
"$",
"maxAge",
")",
";",
"}",
"}"
]
| Adds cors headers.
@param \Modulus\Http\Request $request
@return void | [
"Adds",
"cors",
"headers",
"."
]
| fc5c0f2b582a04de1685578d3fb790686a0a240c | https://github.com/modulusphp/http/blob/fc5c0f2b582a04de1685578d3fb790686a0a240c/Middleware/MustHandleCors.php#L49-L70 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.get_DateTime | public static function get_DateTime( &$dateTime )
{
if( $dateTime instanceof DateTime ) {
return $dateTime;
}
return !is_null($dateTime)
? new DateTime( $dateTime )
: null
;
} | php | public static function get_DateTime( &$dateTime )
{
if( $dateTime instanceof DateTime ) {
return $dateTime;
}
return !is_null($dateTime)
? new DateTime( $dateTime )
: null
;
} | [
"public",
"static",
"function",
"get_DateTime",
"(",
"&",
"$",
"dateTime",
")",
"{",
"if",
"(",
"$",
"dateTime",
"instanceof",
"DateTime",
")",
"{",
"return",
"$",
"dateTime",
";",
"}",
"return",
"!",
"is_null",
"(",
"$",
"dateTime",
")",
"?",
"new",
"DateTime",
"(",
"$",
"dateTime",
")",
":",
"null",
";",
"}"
]
| Get datetime from Entity
@param DateTime $dateTime
@return DateTime | [
"Get",
"datetime",
"from",
"Entity"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L44-L53 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.get_Inet | public static function get_Inet( &$inet )
{
if( $inet instanceof Inet ) {
return $inet;
}
return !is_null($inet)
? new Inet($inet)
: null
;
} | php | public static function get_Inet( &$inet )
{
if( $inet instanceof Inet ) {
return $inet;
}
return !is_null($inet)
? new Inet($inet)
: null
;
} | [
"public",
"static",
"function",
"get_Inet",
"(",
"&",
"$",
"inet",
")",
"{",
"if",
"(",
"$",
"inet",
"instanceof",
"Inet",
")",
"{",
"return",
"$",
"inet",
";",
"}",
"return",
"!",
"is_null",
"(",
"$",
"inet",
")",
"?",
"new",
"Inet",
"(",
"$",
"inet",
")",
":",
"null",
";",
"}"
]
| Get inet from Entity
@param Inet $dateTime
@return Inet | [
"Get",
"inet",
"from",
"Entity"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L73-L82 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.set_Inet | public static function set_Inet( $inet )
{
if( $inet instanceof Inet ) {
return $inet;
}
try {
$inet = new Inet( $inet );
return $inet;
} catch ( \InvalidArgumentException $e ) {
return null;
}
} | php | public static function set_Inet( $inet )
{
if( $inet instanceof Inet ) {
return $inet;
}
try {
$inet = new Inet( $inet );
return $inet;
} catch ( \InvalidArgumentException $e ) {
return null;
}
} | [
"public",
"static",
"function",
"set_Inet",
"(",
"$",
"inet",
")",
"{",
"if",
"(",
"$",
"inet",
"instanceof",
"Inet",
")",
"{",
"return",
"$",
"inet",
";",
"}",
"try",
"{",
"$",
"inet",
"=",
"new",
"Inet",
"(",
"$",
"inet",
")",
";",
"return",
"$",
"inet",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
]
| Set entity datetime
@param Inet $inet
@return Inet | [
"Set",
"entity",
"datetime"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L89-L100 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.get_Hstore | public static function get_Hstore( &$store )
{
if( $store instanceof Hstore ) {
return $store;
}
return !is_null($store)
? new Hstore($store)
: null
;
} | php | public static function get_Hstore( &$store )
{
if( $store instanceof Hstore ) {
return $store;
}
return !is_null($store)
? new Hstore($store)
: null
;
} | [
"public",
"static",
"function",
"get_Hstore",
"(",
"&",
"$",
"store",
")",
"{",
"if",
"(",
"$",
"store",
"instanceof",
"Hstore",
")",
"{",
"return",
"$",
"store",
";",
"}",
"return",
"!",
"is_null",
"(",
"$",
"store",
")",
"?",
"new",
"Hstore",
"(",
"$",
"store",
")",
":",
"null",
";",
"}"
]
| Get hstore from Entity
@param HStore $dateTime
@return Hstore | [
"Get",
"hstore",
"from",
"Entity"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L107-L116 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.set_Hstore | public static function set_Hstore( $store )
{
if( $store instanceof Hstore ) {
return $store;
}
try {
$store = new Hstore( $store );
return $store;
} catch ( \InvalidArgumentException $e ) {
return null;
}
} | php | public static function set_Hstore( $store )
{
if( $store instanceof Hstore ) {
return $store;
}
try {
$store = new Hstore( $store );
return $store;
} catch ( \InvalidArgumentException $e ) {
return null;
}
} | [
"public",
"static",
"function",
"set_Hstore",
"(",
"$",
"store",
")",
"{",
"if",
"(",
"$",
"store",
"instanceof",
"Hstore",
")",
"{",
"return",
"$",
"store",
";",
"}",
"try",
"{",
"$",
"store",
"=",
"new",
"Hstore",
"(",
"$",
"store",
")",
";",
"return",
"$",
"store",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
]
| Set entity Hstore
@param Hstore $store
@return Hstore | [
"Set",
"entity",
"Hstore"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L123-L134 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.get_Json | public static function get_Json( &$json )
{
if( $json instanceof Json ) {
return $json;
}
return !is_null($json)
? new Json($json)
: null
;
} | php | public static function get_Json( &$json )
{
if( $json instanceof Json ) {
return $json;
}
return !is_null($json)
? new Json($json)
: null
;
} | [
"public",
"static",
"function",
"get_Json",
"(",
"&",
"$",
"json",
")",
"{",
"if",
"(",
"$",
"json",
"instanceof",
"Json",
")",
"{",
"return",
"$",
"json",
";",
"}",
"return",
"!",
"is_null",
"(",
"$",
"json",
")",
"?",
"new",
"Json",
"(",
"$",
"json",
")",
":",
"null",
";",
"}"
]
| Get Json from Entity
@param mixed $json
@return Json | [
"Get",
"Json",
"from",
"Entity"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L141-L150 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.set_Json | public static function set_Json( $json, $inputValidate )
{
if( $json instanceof Json ) {
return $json;
} elseif( null === $json ) {
return null;
} elseif ( !is_string($json) ) {
return Json::makeFromObject( $json );
}
return new Json( $json, $inputValidate );
} | php | public static function set_Json( $json, $inputValidate )
{
if( $json instanceof Json ) {
return $json;
} elseif( null === $json ) {
return null;
} elseif ( !is_string($json) ) {
return Json::makeFromObject( $json );
}
return new Json( $json, $inputValidate );
} | [
"public",
"static",
"function",
"set_Json",
"(",
"$",
"json",
",",
"$",
"inputValidate",
")",
"{",
"if",
"(",
"$",
"json",
"instanceof",
"Json",
")",
"{",
"return",
"$",
"json",
";",
"}",
"elseif",
"(",
"null",
"===",
"$",
"json",
")",
"{",
"return",
"null",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"json",
")",
")",
"{",
"return",
"Json",
"::",
"makeFromObject",
"(",
"$",
"json",
")",
";",
"}",
"return",
"new",
"Json",
"(",
"$",
"json",
",",
"$",
"inputValidate",
")",
";",
"}"
]
| Set entity json property
@param mixed $json
@return Json | [
"Set",
"entity",
"json",
"property"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L157-L168 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.get_StockState | public static function get_StockState( &$state )
{
if( $state instanceof StockState or null === $state ) {
$state = StockState::makeFromString( $state );
}
return $state;
} | php | public static function get_StockState( &$state )
{
if( $state instanceof StockState or null === $state ) {
$state = StockState::makeFromString( $state );
}
return $state;
} | [
"public",
"static",
"function",
"get_StockState",
"(",
"&",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"state",
"instanceof",
"StockState",
"or",
"null",
"===",
"$",
"state",
")",
"{",
"$",
"state",
"=",
"StockState",
"::",
"makeFromString",
"(",
"$",
"state",
")",
";",
"}",
"return",
"$",
"state",
";",
"}"
]
| Get StockState from Entity
@param StockState $state
@return StockState | [
"Get",
"StockState",
"from",
"Entity"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L175-L181 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.set_StockState | public static function set_StockState( $state )
{
if( $state instanceof StockState or null === $state ) {
$state = StockState::makeFromString( $state );
}
return $state;
} | php | public static function set_StockState( $state )
{
if( $state instanceof StockState or null === $state ) {
$state = StockState::makeFromString( $state );
}
return $state;
} | [
"public",
"static",
"function",
"set_StockState",
"(",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"state",
"instanceof",
"StockState",
"or",
"null",
"===",
"$",
"state",
")",
"{",
"$",
"state",
"=",
"StockState",
"::",
"makeFromString",
"(",
"$",
"state",
")",
";",
"}",
"return",
"$",
"state",
";",
"}"
]
| Set entity StockState
@param StockState $state
@return StockState | [
"Set",
"entity",
"StockState"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L188-L194 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.get_PgLargeObject | public static function get_PgLargeObject( &$value, Base $entity )
{
if( $value instanceof PgLargeObject ){
return $value->isDeleted()
? null
: $value;
}
if( is_intish($value) ) {
$value = new Oid( $value, $entity->r()->db );
}
return !is_null($value)
? new PgLargeObject( $value )
: null;
} | php | public static function get_PgLargeObject( &$value, Base $entity )
{
if( $value instanceof PgLargeObject ){
return $value->isDeleted()
? null
: $value;
}
if( is_intish($value) ) {
$value = new Oid( $value, $entity->r()->db );
}
return !is_null($value)
? new PgLargeObject( $value )
: null;
} | [
"public",
"static",
"function",
"get_PgLargeObject",
"(",
"&",
"$",
"value",
",",
"Base",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"PgLargeObject",
")",
"{",
"return",
"$",
"value",
"->",
"isDeleted",
"(",
")",
"?",
"null",
":",
"$",
"value",
";",
"}",
"if",
"(",
"is_intish",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"new",
"Oid",
"(",
"$",
"value",
",",
"$",
"entity",
"->",
"r",
"(",
")",
"->",
"db",
")",
";",
"}",
"return",
"!",
"is_null",
"(",
"$",
"value",
")",
"?",
"new",
"PgLargeObject",
"(",
"$",
"value",
")",
":",
"null",
";",
"}"
]
| Get entity PgLargeObject
@param PgLargeObject $value
@return mixed | [
"Get",
"entity",
"PgLargeObject"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L366-L379 | train |
squareproton/Bond | src/Bond/Entity/StaticMethods.php | StaticMethods.set_PgLargeObject | public static function set_PgLargeObject( $value, $inputValidate, Base $entity )
{
if( $value instanceof PgLargeObject ){
return $value;
}
if( is_intish($value) ) {
$value = new Oid( $value, $entity->r()->db );
}
return is_null( $value )
? null
: new PgLargeObject( $value );
} | php | public static function set_PgLargeObject( $value, $inputValidate, Base $entity )
{
if( $value instanceof PgLargeObject ){
return $value;
}
if( is_intish($value) ) {
$value = new Oid( $value, $entity->r()->db );
}
return is_null( $value )
? null
: new PgLargeObject( $value );
} | [
"public",
"static",
"function",
"set_PgLargeObject",
"(",
"$",
"value",
",",
"$",
"inputValidate",
",",
"Base",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"PgLargeObject",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"is_intish",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"new",
"Oid",
"(",
"$",
"value",
",",
"$",
"entity",
"->",
"r",
"(",
")",
"->",
"db",
")",
";",
"}",
"return",
"is_null",
"(",
"$",
"value",
")",
"?",
"null",
":",
"new",
"PgLargeObject",
"(",
"$",
"value",
")",
";",
"}"
]
| Set PgLargeObject on entity
@param PgLargeObject $value
@return PgLargeObject | [
"Set",
"PgLargeObject",
"on",
"entity"
]
| a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/StaticMethods.php#L386-L397 | train |
mrimann/CacheBreaker | Classes/Service/ResourceService.php | ResourceService.getResourceUri | public function getResourceUri($path, $package = null)
{
if (strpos($path, 'resource://') === 0) {
$matches = array();
if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) === 1) {
$package = $matches[1];
$path = $matches[2];
} else {
throw new \Exception(sprintf('The path "%s" which was given to the ResourceViewHelper must point to a public resource.', $path), 1353512639);
}
}
if ($package === null) {
throw new \Exception('Package argument was not provided and it was not included in "path"', 1353512743);
}
$uri = $this->resourceManager->getPublicPackageResourceUri($package, $path);
$hash = substr(md5_file('resource://' . $package . '/Public/' . $path), 0, 8);
return $uri . '?' . $hash;
} | php | public function getResourceUri($path, $package = null)
{
if (strpos($path, 'resource://') === 0) {
$matches = array();
if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) === 1) {
$package = $matches[1];
$path = $matches[2];
} else {
throw new \Exception(sprintf('The path "%s" which was given to the ResourceViewHelper must point to a public resource.', $path), 1353512639);
}
}
if ($package === null) {
throw new \Exception('Package argument was not provided and it was not included in "path"', 1353512743);
}
$uri = $this->resourceManager->getPublicPackageResourceUri($package, $path);
$hash = substr(md5_file('resource://' . $package . '/Public/' . $path), 0, 8);
return $uri . '?' . $hash;
} | [
"public",
"function",
"getResourceUri",
"(",
"$",
"path",
",",
"$",
"package",
"=",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'resource://'",
")",
"===",
"0",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'#^resource://([^/]+)/Public/(.*)#'",
",",
"$",
"path",
",",
"$",
"matches",
")",
"===",
"1",
")",
"{",
"$",
"package",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"path",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The path \"%s\" which was given to the ResourceViewHelper must point to a public resource.'",
",",
"$",
"path",
")",
",",
"1353512639",
")",
";",
"}",
"}",
"if",
"(",
"$",
"package",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Package argument was not provided and it was not included in \"path\"'",
",",
"1353512743",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"this",
"->",
"resourceManager",
"->",
"getPublicPackageResourceUri",
"(",
"$",
"package",
",",
"$",
"path",
")",
";",
"$",
"hash",
"=",
"substr",
"(",
"md5_file",
"(",
"'resource://'",
".",
"$",
"package",
".",
"'/Public/'",
".",
"$",
"path",
")",
",",
"0",
",",
"8",
")",
";",
"return",
"$",
"uri",
".",
"'?'",
".",
"$",
"hash",
";",
"}"
]
| Appends a shortened md5 of the file.
@param string $path The location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI
@param string $package Target package key. If not set, the current package key will be used
@return string
@throws \Exception | [
"Appends",
"a",
"shortened",
"md5",
"of",
"the",
"file",
"."
]
| 2b195f06bc2f92d1d9dc069fdc67cc28a3bee576 | https://github.com/mrimann/CacheBreaker/blob/2b195f06bc2f92d1d9dc069fdc67cc28a3bee576/Classes/Service/ResourceService.php#L22-L39 | train |
DeimosProject/Helper | src/Helper/Helpers/Arr/StackTrait.php | StackTrait.odd | public function odd(array $storage)
{
return $this->filter($storage, function ($value)
{
return $this->helper->math()->isOdd($value);
});
} | php | public function odd(array $storage)
{
return $this->filter($storage, function ($value)
{
return $this->helper->math()->isOdd($value);
});
} | [
"public",
"function",
"odd",
"(",
"array",
"$",
"storage",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"$",
"storage",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"math",
"(",
")",
"->",
"isOdd",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
]
| 1, 3, 5...
@param array $storage
@return array | [
"1",
"3",
"5",
"..."
]
| 39c67de21a87c7c6391b2f98416063f41c94e26f | https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/StackTrait.php#L81-L87 | train |
DeimosProject/Helper | src/Helper/Helpers/Arr/StackTrait.php | StackTrait.even | public function even(array $storage)
{
return $this->filter($storage, function ($value)
{
return $this->helper->math()->isEven($value);
});
} | php | public function even(array $storage)
{
return $this->filter($storage, function ($value)
{
return $this->helper->math()->isEven($value);
});
} | [
"public",
"function",
"even",
"(",
"array",
"$",
"storage",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"$",
"storage",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"math",
"(",
")",
"->",
"isEven",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
]
| 0, 2, 4...
@param array $storage
@return array | [
"0",
"2",
"4",
"..."
]
| 39c67de21a87c7c6391b2f98416063f41c94e26f | https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/StackTrait.php#L96-L102 | train |
agentmedia/phine-core | src/Core/Logic/Bundle/BundleManifest.php | BundleManifest.LoadToBackend | final function LoadToBackend()
{
foreach ($this->Dependencies() as $depedency)
{
$bundleName = $depedency->BundleName();
if (!in_array($bundleName, self::$_loadedBundles))
{
$depManifest = ClassFinder::Manifest($bundleName);
$depManifest->LoadToBackend();
}
}
$this->LoadBackendTranslations();
$this->LoadBackendCode();
self::$_loadedBundles[] = static::BundleName();
} | php | final function LoadToBackend()
{
foreach ($this->Dependencies() as $depedency)
{
$bundleName = $depedency->BundleName();
if (!in_array($bundleName, self::$_loadedBundles))
{
$depManifest = ClassFinder::Manifest($bundleName);
$depManifest->LoadToBackend();
}
}
$this->LoadBackendTranslations();
$this->LoadBackendCode();
self::$_loadedBundles[] = static::BundleName();
} | [
"final",
"function",
"LoadToBackend",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"Dependencies",
"(",
")",
"as",
"$",
"depedency",
")",
"{",
"$",
"bundleName",
"=",
"$",
"depedency",
"->",
"BundleName",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"bundleName",
",",
"self",
"::",
"$",
"_loadedBundles",
")",
")",
"{",
"$",
"depManifest",
"=",
"ClassFinder",
"::",
"Manifest",
"(",
"$",
"bundleName",
")",
";",
"$",
"depManifest",
"->",
"LoadToBackend",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"LoadBackendTranslations",
"(",
")",
";",
"$",
"this",
"->",
"LoadBackendCode",
"(",
")",
";",
"self",
"::",
"$",
"_loadedBundles",
"[",
"]",
"=",
"static",
"::",
"BundleName",
"(",
")",
";",
"}"
]
| Loads the bundle with all dependencies | [
"Loads",
"the",
"bundle",
"with",
"all",
"dependencies"
]
| 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Bundle/BundleManifest.php#L54-L68 | train |
agentmedia/phine-core | src/Core/Logic/Bundle/BundleManifest.php | BundleManifest.LoadToFrontend | protected function LoadToFrontend(Site $site)
{
foreach ($this->Dependencies() as $depedency)
{
$bundleName = $depedency->BundleName();
if (!in_array($bundleName, self::$_loadedBundles))
{
$depManifest = ClassFinder::Manifest($bundleName);
$depManifest->LoadToFrontend($site);
}
}
$this->LoadFrontendTranslations($site);
$this->LoadFrontendCode();
self::$_loadedBundles[] = static::BundleName();
} | php | protected function LoadToFrontend(Site $site)
{
foreach ($this->Dependencies() as $depedency)
{
$bundleName = $depedency->BundleName();
if (!in_array($bundleName, self::$_loadedBundles))
{
$depManifest = ClassFinder::Manifest($bundleName);
$depManifest->LoadToFrontend($site);
}
}
$this->LoadFrontendTranslations($site);
$this->LoadFrontendCode();
self::$_loadedBundles[] = static::BundleName();
} | [
"protected",
"function",
"LoadToFrontend",
"(",
"Site",
"$",
"site",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"Dependencies",
"(",
")",
"as",
"$",
"depedency",
")",
"{",
"$",
"bundleName",
"=",
"$",
"depedency",
"->",
"BundleName",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"bundleName",
",",
"self",
"::",
"$",
"_loadedBundles",
")",
")",
"{",
"$",
"depManifest",
"=",
"ClassFinder",
"::",
"Manifest",
"(",
"$",
"bundleName",
")",
";",
"$",
"depManifest",
"->",
"LoadToFrontend",
"(",
"$",
"site",
")",
";",
"}",
"}",
"$",
"this",
"->",
"LoadFrontendTranslations",
"(",
"$",
"site",
")",
";",
"$",
"this",
"->",
"LoadFrontendCode",
"(",
")",
";",
"self",
"::",
"$",
"_loadedBundles",
"[",
"]",
"=",
"static",
"::",
"BundleName",
"(",
")",
";",
"}"
]
| Loads the bundle code and translations to the f
@param Site $site | [
"Loads",
"the",
"bundle",
"code",
"and",
"translations",
"to",
"the",
"f"
]
| 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Bundle/BundleManifest.php#L73-L87 | train |
agentmedia/phine-core | src/Core/Logic/Bundle/BundleManifest.php | BundleManifest.LoadInstalledToBackend | static function LoadInstalledToBackend()
{
$bundles = InstalledBundle::Schema()->Fetch();
foreach ($bundles as $bundle)
{
$manifest = ClassFinder::Manifest($bundle->GetBundle());
$manifest->LoadToBackend();
}
} | php | static function LoadInstalledToBackend()
{
$bundles = InstalledBundle::Schema()->Fetch();
foreach ($bundles as $bundle)
{
$manifest = ClassFinder::Manifest($bundle->GetBundle());
$manifest->LoadToBackend();
}
} | [
"static",
"function",
"LoadInstalledToBackend",
"(",
")",
"{",
"$",
"bundles",
"=",
"InstalledBundle",
"::",
"Schema",
"(",
")",
"->",
"Fetch",
"(",
")",
";",
"foreach",
"(",
"$",
"bundles",
"as",
"$",
"bundle",
")",
"{",
"$",
"manifest",
"=",
"ClassFinder",
"::",
"Manifest",
"(",
"$",
"bundle",
"->",
"GetBundle",
"(",
")",
")",
";",
"$",
"manifest",
"->",
"LoadToBackend",
"(",
")",
";",
"}",
"}"
]
| Loads all installed bundles to the backend | [
"Loads",
"all",
"installed",
"bundles",
"to",
"the",
"backend"
]
| 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Bundle/BundleManifest.php#L91-L99 | train |
agentmedia/phine-core | src/Core/Logic/Bundle/BundleManifest.php | BundleManifest.LoadInstalledToFrontend | static function LoadInstalledToFrontend(Site $site)
{
$bundles = InstalledBundle::Schema()->Fetch();
foreach ($bundles as $bundle)
{
$manifest = ClassFinder::Manifest($bundle->GetBundle());
$manifest->LoadToFrontend($site);
}
} | php | static function LoadInstalledToFrontend(Site $site)
{
$bundles = InstalledBundle::Schema()->Fetch();
foreach ($bundles as $bundle)
{
$manifest = ClassFinder::Manifest($bundle->GetBundle());
$manifest->LoadToFrontend($site);
}
} | [
"static",
"function",
"LoadInstalledToFrontend",
"(",
"Site",
"$",
"site",
")",
"{",
"$",
"bundles",
"=",
"InstalledBundle",
"::",
"Schema",
"(",
")",
"->",
"Fetch",
"(",
")",
";",
"foreach",
"(",
"$",
"bundles",
"as",
"$",
"bundle",
")",
"{",
"$",
"manifest",
"=",
"ClassFinder",
"::",
"Manifest",
"(",
"$",
"bundle",
"->",
"GetBundle",
"(",
")",
")",
";",
"$",
"manifest",
"->",
"LoadToFrontend",
"(",
"$",
"site",
")",
";",
"}",
"}"
]
| Loads installed bundles to the frontend
@param Site $site | [
"Loads",
"installed",
"bundles",
"to",
"the",
"frontend"
]
| 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Bundle/BundleManifest.php#L105-L113 | train |
Wedeto/HTTP | src/RequestBody.php | RequestBody.getRawContent | public function getRawContent(int $max_length = -1)
{
// Set maximum length based on parameter or provided content_length
$max_length = $max_length < 0 ? $this->content_length : $max_length;
// Limit to a maximum of 4MiB
$max_length = min(4096 * 1024, $max_length, $this->content_length);
$str = $this->getContentStream();
$data = stream_get_contents($str, $this->content_length);
$size = strlen($data);
if ($size < $max_length)
{
self::getLogger()->warning(
"Less data was posted than promised. Content-length was {} but only {} bytes were received",
[$this->content_length, $size]
);
}
return $data;
} | php | public function getRawContent(int $max_length = -1)
{
// Set maximum length based on parameter or provided content_length
$max_length = $max_length < 0 ? $this->content_length : $max_length;
// Limit to a maximum of 4MiB
$max_length = min(4096 * 1024, $max_length, $this->content_length);
$str = $this->getContentStream();
$data = stream_get_contents($str, $this->content_length);
$size = strlen($data);
if ($size < $max_length)
{
self::getLogger()->warning(
"Less data was posted than promised. Content-length was {} but only {} bytes were received",
[$this->content_length, $size]
);
}
return $data;
} | [
"public",
"function",
"getRawContent",
"(",
"int",
"$",
"max_length",
"=",
"-",
"1",
")",
"{",
"// Set maximum length based on parameter or provided content_length",
"$",
"max_length",
"=",
"$",
"max_length",
"<",
"0",
"?",
"$",
"this",
"->",
"content_length",
":",
"$",
"max_length",
";",
"// Limit to a maximum of 4MiB",
"$",
"max_length",
"=",
"min",
"(",
"4096",
"*",
"1024",
",",
"$",
"max_length",
",",
"$",
"this",
"->",
"content_length",
")",
";",
"$",
"str",
"=",
"$",
"this",
"->",
"getContentStream",
"(",
")",
";",
"$",
"data",
"=",
"stream_get_contents",
"(",
"$",
"str",
",",
"$",
"this",
"->",
"content_length",
")",
";",
"$",
"size",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"size",
"<",
"$",
"max_length",
")",
"{",
"self",
"::",
"getLogger",
"(",
")",
"->",
"warning",
"(",
"\"Less data was posted than promised. Content-length was {} but only {} bytes were received\"",
",",
"[",
"$",
"this",
"->",
"content_length",
",",
"$",
"size",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Get the raw content as a string
@param int $max_length The maximum amount of bytes to read.
@return string The read data | [
"Get",
"the",
"raw",
"content",
"as",
"a",
"string"
]
| 7318eff1b81a3c103c4263466d09b7f3593b70b9 | https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/RequestBody.php#L132-L150 | train |
Wedeto/HTTP | src/RequestBody.php | RequestBody.getParsedContent | public function getParsedContent()
{
$filetype = FileType::getExtension($this->content_type);
if (empty($filetype))
throw new ParseException("Unknown content type");
$filename = "content." . $filetype;
$reader = ReaderFactory::factory($filename);
$parsed = $reader->readFileHandle($this->getContentStream());
return new Dictionary($parsed);
} | php | public function getParsedContent()
{
$filetype = FileType::getExtension($this->content_type);
if (empty($filetype))
throw new ParseException("Unknown content type");
$filename = "content." . $filetype;
$reader = ReaderFactory::factory($filename);
$parsed = $reader->readFileHandle($this->getContentStream());
return new Dictionary($parsed);
} | [
"public",
"function",
"getParsedContent",
"(",
")",
"{",
"$",
"filetype",
"=",
"FileType",
"::",
"getExtension",
"(",
"$",
"this",
"->",
"content_type",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"filetype",
")",
")",
"throw",
"new",
"ParseException",
"(",
"\"Unknown content type\"",
")",
";",
"$",
"filename",
"=",
"\"content.\"",
".",
"$",
"filetype",
";",
"$",
"reader",
"=",
"ReaderFactory",
"::",
"factory",
"(",
"$",
"filename",
")",
";",
"$",
"parsed",
"=",
"$",
"reader",
"->",
"readFileHandle",
"(",
"$",
"this",
"->",
"getContentStream",
"(",
")",
")",
";",
"return",
"new",
"Dictionary",
"(",
"$",
"parsed",
")",
";",
"}"
]
| Return the parsed content. The FileFormats readers will be used to
parse the data and store it in a dictionary.
@return Dictionary The parsed data | [
"Return",
"the",
"parsed",
"content",
".",
"The",
"FileFormats",
"readers",
"will",
"be",
"used",
"to",
"parse",
"the",
"data",
"and",
"store",
"it",
"in",
"a",
"dictionary",
"."
]
| 7318eff1b81a3c103c4263466d09b7f3593b70b9 | https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/RequestBody.php#L158-L169 | train |
romm/configuration_object | Classes/Service/Items/Parents/ParentsService.php | ParentsService.configurationObjectAfter | public function configurationObjectAfter(GetConfigurationObjectDTO $serviceDataTransferObject)
{
// Will save the paths of the properties which need their parent objects.
$this->delay(
self::PRIORITY_SAVE_OBJECTS_WITH_PARENTS_PATHS,
function (GetConfigurationObjectDTO $serviceDataTransferObject) {
if (false === empty($this->objectsWithParentsPaths)) {
$serviceDataTransferObject->getResult()
->setInternalVar('objectsWithParentsPaths', $this->objectsWithParentsPaths);
$this->objectsWithParentsPaths = [];
}
}
);
// Will fill all the parents.
$this->delay(
self::PRIORITY_FILL_PARENTS,
function (GetConfigurationObjectDTO $serviceDataTransferObject) {
$objectsWithParentsPaths = $serviceDataTransferObject->getResult()->getInternalVar('objectsWithParentsPaths');
if (false === empty($objectsWithParentsPaths)) {
$object = $serviceDataTransferObject->getResult()->getObject(true);
foreach ($objectsWithParentsPaths as $path) {
$this->insertParents($object, explode('.', $path), [$object]);
}
}
}
);
} | php | public function configurationObjectAfter(GetConfigurationObjectDTO $serviceDataTransferObject)
{
// Will save the paths of the properties which need their parent objects.
$this->delay(
self::PRIORITY_SAVE_OBJECTS_WITH_PARENTS_PATHS,
function (GetConfigurationObjectDTO $serviceDataTransferObject) {
if (false === empty($this->objectsWithParentsPaths)) {
$serviceDataTransferObject->getResult()
->setInternalVar('objectsWithParentsPaths', $this->objectsWithParentsPaths);
$this->objectsWithParentsPaths = [];
}
}
);
// Will fill all the parents.
$this->delay(
self::PRIORITY_FILL_PARENTS,
function (GetConfigurationObjectDTO $serviceDataTransferObject) {
$objectsWithParentsPaths = $serviceDataTransferObject->getResult()->getInternalVar('objectsWithParentsPaths');
if (false === empty($objectsWithParentsPaths)) {
$object = $serviceDataTransferObject->getResult()->getObject(true);
foreach ($objectsWithParentsPaths as $path) {
$this->insertParents($object, explode('.', $path), [$object]);
}
}
}
);
} | [
"public",
"function",
"configurationObjectAfter",
"(",
"GetConfigurationObjectDTO",
"$",
"serviceDataTransferObject",
")",
"{",
"// Will save the paths of the properties which need their parent objects.",
"$",
"this",
"->",
"delay",
"(",
"self",
"::",
"PRIORITY_SAVE_OBJECTS_WITH_PARENTS_PATHS",
",",
"function",
"(",
"GetConfigurationObjectDTO",
"$",
"serviceDataTransferObject",
")",
"{",
"if",
"(",
"false",
"===",
"empty",
"(",
"$",
"this",
"->",
"objectsWithParentsPaths",
")",
")",
"{",
"$",
"serviceDataTransferObject",
"->",
"getResult",
"(",
")",
"->",
"setInternalVar",
"(",
"'objectsWithParentsPaths'",
",",
"$",
"this",
"->",
"objectsWithParentsPaths",
")",
";",
"$",
"this",
"->",
"objectsWithParentsPaths",
"=",
"[",
"]",
";",
"}",
"}",
")",
";",
"// Will fill all the parents.",
"$",
"this",
"->",
"delay",
"(",
"self",
"::",
"PRIORITY_FILL_PARENTS",
",",
"function",
"(",
"GetConfigurationObjectDTO",
"$",
"serviceDataTransferObject",
")",
"{",
"$",
"objectsWithParentsPaths",
"=",
"$",
"serviceDataTransferObject",
"->",
"getResult",
"(",
")",
"->",
"getInternalVar",
"(",
"'objectsWithParentsPaths'",
")",
";",
"if",
"(",
"false",
"===",
"empty",
"(",
"$",
"objectsWithParentsPaths",
")",
")",
"{",
"$",
"object",
"=",
"$",
"serviceDataTransferObject",
"->",
"getResult",
"(",
")",
"->",
"getObject",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"objectsWithParentsPaths",
"as",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"insertParents",
"(",
"$",
"object",
",",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
",",
"[",
"$",
"object",
"]",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
]
| This function will first save the entire storage of properties paths set
in the function `objectConversionAfter`.
Then, each of the properties above will be processed to fill their parent
objects.
@param GetConfigurationObjectDTO $serviceDataTransferObject | [
"This",
"function",
"will",
"first",
"save",
"the",
"entire",
"storage",
"of",
"properties",
"paths",
"set",
"in",
"the",
"function",
"objectConversionAfter",
"."
]
| d3a40903386c2e0766bd8279337fe6da45cf5ce3 | https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/Parents/ParentsService.php#L119-L149 | train |
romm/configuration_object | Classes/Service/Items/Parents/ParentsService.php | ParentsService.insertParents | protected function insertParents($entity, array $path, array $parents)
{
$propertyName = reset($path);
$propertyValue = Core::get()->getObjectService()->getObjectProperty($entity, $propertyName);
if (1 === count($path)) {
if (is_object($propertyValue)
&& Core::get()->getParentsUtility()->classUsesParentsTrait($propertyValue)
) {
/** @var ParentsTrait $propertyValue */
$propertyValue->attachParents($this->filterParents($parents));
}
} else {
if (is_object($propertyValue)) {
$parents[] = $propertyValue;
}
array_shift($path);
$this->insertParents($propertyValue, $path, $parents);
}
} | php | protected function insertParents($entity, array $path, array $parents)
{
$propertyName = reset($path);
$propertyValue = Core::get()->getObjectService()->getObjectProperty($entity, $propertyName);
if (1 === count($path)) {
if (is_object($propertyValue)
&& Core::get()->getParentsUtility()->classUsesParentsTrait($propertyValue)
) {
/** @var ParentsTrait $propertyValue */
$propertyValue->attachParents($this->filterParents($parents));
}
} else {
if (is_object($propertyValue)) {
$parents[] = $propertyValue;
}
array_shift($path);
$this->insertParents($propertyValue, $path, $parents);
}
} | [
"protected",
"function",
"insertParents",
"(",
"$",
"entity",
",",
"array",
"$",
"path",
",",
"array",
"$",
"parents",
")",
"{",
"$",
"propertyName",
"=",
"reset",
"(",
"$",
"path",
")",
";",
"$",
"propertyValue",
"=",
"Core",
"::",
"get",
"(",
")",
"->",
"getObjectService",
"(",
")",
"->",
"getObjectProperty",
"(",
"$",
"entity",
",",
"$",
"propertyName",
")",
";",
"if",
"(",
"1",
"===",
"count",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"propertyValue",
")",
"&&",
"Core",
"::",
"get",
"(",
")",
"->",
"getParentsUtility",
"(",
")",
"->",
"classUsesParentsTrait",
"(",
"$",
"propertyValue",
")",
")",
"{",
"/** @var ParentsTrait $propertyValue */",
"$",
"propertyValue",
"->",
"attachParents",
"(",
"$",
"this",
"->",
"filterParents",
"(",
"$",
"parents",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_object",
"(",
"$",
"propertyValue",
")",
")",
"{",
"$",
"parents",
"[",
"]",
"=",
"$",
"propertyValue",
";",
"}",
"array_shift",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"insertParents",
"(",
"$",
"propertyValue",
",",
"$",
"path",
",",
"$",
"parents",
")",
";",
"}",
"}"
]
| Internal function to fill the parents.
@param mixed $entity
@param array $path
@param object[] $parents | [
"Internal",
"function",
"to",
"fill",
"the",
"parents",
"."
]
| d3a40903386c2e0766bd8279337fe6da45cf5ce3 | https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/Parents/ParentsService.php#L158-L178 | train |
codeblanche/Web | src/Web/Uri.php | Uri.import | public function import($input)
{
if (is_array($input)) {
$this->fromArray($input);
}
else {
$this->fromString($input);
}
return $this;
} | php | public function import($input)
{
if (is_array($input)) {
$this->fromArray($input);
}
else {
$this->fromString($input);
}
return $this;
} | [
"public",
"function",
"import",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"$",
"this",
"->",
"fromArray",
"(",
"$",
"input",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"fromString",
"(",
"$",
"input",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Import the given input
@param string|array $input
@return Uri | [
"Import",
"the",
"given",
"input"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L205-L215 | train |
codeblanche/Web | src/Web/Uri.php | Uri.toArray | public function toArray()
{
$qs = $this->query instanceof QueryString
? $this->query->toString()
: '';
return array(
'scheme' => $this->scheme,
'host' => $this->host,
'port' => $this->port,
'user' => $this->user,
'pass' => $this->pass,
'path' => $this->path,
'basename' => $this->basename,
'dirname' => $this->dirname,
'extension' => $this->extension,
'filename' => $this->filename,
'query' => $qs,
'fragment' => $this->fragment,
);
} | php | public function toArray()
{
$qs = $this->query instanceof QueryString
? $this->query->toString()
: '';
return array(
'scheme' => $this->scheme,
'host' => $this->host,
'port' => $this->port,
'user' => $this->user,
'pass' => $this->pass,
'path' => $this->path,
'basename' => $this->basename,
'dirname' => $this->dirname,
'extension' => $this->extension,
'filename' => $this->filename,
'query' => $qs,
'fragment' => $this->fragment,
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"qs",
"=",
"$",
"this",
"->",
"query",
"instanceof",
"QueryString",
"?",
"$",
"this",
"->",
"query",
"->",
"toString",
"(",
")",
":",
"''",
";",
"return",
"array",
"(",
"'scheme'",
"=>",
"$",
"this",
"->",
"scheme",
",",
"'host'",
"=>",
"$",
"this",
"->",
"host",
",",
"'port'",
"=>",
"$",
"this",
"->",
"port",
",",
"'user'",
"=>",
"$",
"this",
"->",
"user",
",",
"'pass'",
"=>",
"$",
"this",
"->",
"pass",
",",
"'path'",
"=>",
"$",
"this",
"->",
"path",
",",
"'basename'",
"=>",
"$",
"this",
"->",
"basename",
",",
"'dirname'",
"=>",
"$",
"this",
"->",
"dirname",
",",
"'extension'",
"=>",
"$",
"this",
"->",
"extension",
",",
"'filename'",
"=>",
"$",
"this",
"->",
"filename",
",",
"'query'",
"=>",
"$",
"qs",
",",
"'fragment'",
"=>",
"$",
"this",
"->",
"fragment",
",",
")",
";",
"}"
]
| Convert to an array
@return array | [
"Convert",
"to",
"an",
"array"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L383-L403 | train |
codeblanche/Web | src/Web/Uri.php | Uri.toString | public function toString()
{
$result = "";
if (!empty($this->scheme)) {
$result .= "{$this->scheme}://";
}
if (!empty($this->user)) {
$result .= !empty($this->pass)
? "{$this->user}:{$this->pass}@"
: "{$this->user}@";
}
$result .= $this->host;
if (!empty($this->port) && (isset($this->portMap[$this->scheme]) && $this->port != $this->portMap[$this->scheme])) {
$result .= ":{$this->port}";
}
$result .= $this->path;
$qs = $this->query->toString();
if (!empty($qs)) {
$result .= "?{$qs}";
}
if (!empty($this->fragment)) {
$result .= "#{$this->fragment}";
}
return $result;
} | php | public function toString()
{
$result = "";
if (!empty($this->scheme)) {
$result .= "{$this->scheme}://";
}
if (!empty($this->user)) {
$result .= !empty($this->pass)
? "{$this->user}:{$this->pass}@"
: "{$this->user}@";
}
$result .= $this->host;
if (!empty($this->port) && (isset($this->portMap[$this->scheme]) && $this->port != $this->portMap[$this->scheme])) {
$result .= ":{$this->port}";
}
$result .= $this->path;
$qs = $this->query->toString();
if (!empty($qs)) {
$result .= "?{$qs}";
}
if (!empty($this->fragment)) {
$result .= "#{$this->fragment}";
}
return $result;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"scheme",
")",
")",
"{",
"$",
"result",
".=",
"\"{$this->scheme}://\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"user",
")",
")",
"{",
"$",
"result",
".=",
"!",
"empty",
"(",
"$",
"this",
"->",
"pass",
")",
"?",
"\"{$this->user}:{$this->pass}@\"",
":",
"\"{$this->user}@\"",
";",
"}",
"$",
"result",
".=",
"$",
"this",
"->",
"host",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"port",
")",
"&&",
"(",
"isset",
"(",
"$",
"this",
"->",
"portMap",
"[",
"$",
"this",
"->",
"scheme",
"]",
")",
"&&",
"$",
"this",
"->",
"port",
"!=",
"$",
"this",
"->",
"portMap",
"[",
"$",
"this",
"->",
"scheme",
"]",
")",
")",
"{",
"$",
"result",
".=",
"\":{$this->port}\"",
";",
"}",
"$",
"result",
".=",
"$",
"this",
"->",
"path",
";",
"$",
"qs",
"=",
"$",
"this",
"->",
"query",
"->",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"qs",
")",
")",
"{",
"$",
"result",
".=",
"\"?{$qs}\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"fragment",
")",
")",
"{",
"$",
"result",
".=",
"\"#{$this->fragment}\"",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Convert to a string.
@return string | [
"Convert",
"to",
"a",
"string",
"."
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L410-L442 | train |
codeblanche/Web | src/Web/Uri.php | Uri.buildPath | protected function buildPath()
{
$this->basename = $this->filename;
if (!empty($this->extension)) {
$this->basename .= '.' . $this->extension;
}
$this->path = $this->dirname;
if (!empty($this->basename)) {
$this->path .= '/' . $this->basename;
}
return $this;
} | php | protected function buildPath()
{
$this->basename = $this->filename;
if (!empty($this->extension)) {
$this->basename .= '.' . $this->extension;
}
$this->path = $this->dirname;
if (!empty($this->basename)) {
$this->path .= '/' . $this->basename;
}
return $this;
} | [
"protected",
"function",
"buildPath",
"(",
")",
"{",
"$",
"this",
"->",
"basename",
"=",
"$",
"this",
"->",
"filename",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"extension",
")",
")",
"{",
"$",
"this",
"->",
"basename",
".=",
"'.'",
".",
"$",
"this",
"->",
"extension",
";",
"}",
"$",
"this",
"->",
"path",
"=",
"$",
"this",
"->",
"dirname",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"basename",
")",
")",
"{",
"$",
"this",
"->",
"path",
".=",
"'/'",
".",
"$",
"this",
"->",
"basename",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Rebuild the path using the path components
@return Uri | [
"Rebuild",
"the",
"path",
"using",
"the",
"path",
"components"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L449-L464 | train |
codeblanche/Web | src/Web/Uri.php | Uri.fromArray | protected function fromArray($array)
{
if (empty($array)) {
return $this;
}
$this->query = new QueryString();
if (!empty($array['query'])) {
$this->query->import($array['query']);
}
$keys = array(
'scheme',
'host',
'port',
'user',
'pass',
'path',
'fragment',
'dirname',
'basename',
'extension',
'filename',
);
foreach ($keys as $key) {
if (!isset($array[$key])) {
continue;
}
$this->$key = $array[$key];
if ($key === 'path') {
$this->parsePath($this->path);
}
}
$this->buildPath();
return $this;
} | php | protected function fromArray($array)
{
if (empty($array)) {
return $this;
}
$this->query = new QueryString();
if (!empty($array['query'])) {
$this->query->import($array['query']);
}
$keys = array(
'scheme',
'host',
'port',
'user',
'pass',
'path',
'fragment',
'dirname',
'basename',
'extension',
'filename',
);
foreach ($keys as $key) {
if (!isset($array[$key])) {
continue;
}
$this->$key = $array[$key];
if ($key === 'path') {
$this->parsePath($this->path);
}
}
$this->buildPath();
return $this;
} | [
"protected",
"function",
"fromArray",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"array",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"query",
"=",
"new",
"QueryString",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"import",
"(",
"$",
"array",
"[",
"'query'",
"]",
")",
";",
"}",
"$",
"keys",
"=",
"array",
"(",
"'scheme'",
",",
"'host'",
",",
"'port'",
",",
"'user'",
",",
"'pass'",
",",
"'path'",
",",
"'fragment'",
",",
"'dirname'",
",",
"'basename'",
",",
"'extension'",
",",
"'filename'",
",",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"$",
"key",
"===",
"'path'",
")",
"{",
"$",
"this",
"->",
"parsePath",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}",
"}",
"$",
"this",
"->",
"buildPath",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Import from an array
@param array $array
@return Uri | [
"Import",
"from",
"an",
"array"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L473-L514 | train |
codeblanche/Web | src/Web/Uri.php | Uri.fromString | protected function fromString($uri)
{
if (empty($uri)) {
return $this;
}
$this->fromArray(parse_url($uri));
return $this;
} | php | protected function fromString($uri)
{
if (empty($uri)) {
return $this;
}
$this->fromArray(parse_url($uri));
return $this;
} | [
"protected",
"function",
"fromString",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"uri",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"fromArray",
"(",
"parse_url",
"(",
"$",
"uri",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Import from a string
@param string $uri
@return Uri | [
"Import",
"from",
"a",
"string"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L523-L532 | train |
codeblanche/Web | src/Web/Uri.php | Uri.parsePath | protected function parsePath($path = null)
{
$this->dirname = '';
$this->basename = '';
$this->extension = '';
$this->filename = '';
if (empty($path)) {
return $this;
}
$parts = pathinfo($path);
if (isset($parts['dirname'])) {
$this->dirname = rtrim($parts['dirname'], '/');
}
if (isset($parts['basename'])) {
$this->basename = $parts['basename'];
}
if (isset($parts['extension'])) {
$this->extension = $parts['extension'];
}
if (isset($parts['filename'])) {
$this->filename = $parts['filename'];
}
return $this;
} | php | protected function parsePath($path = null)
{
$this->dirname = '';
$this->basename = '';
$this->extension = '';
$this->filename = '';
if (empty($path)) {
return $this;
}
$parts = pathinfo($path);
if (isset($parts['dirname'])) {
$this->dirname = rtrim($parts['dirname'], '/');
}
if (isset($parts['basename'])) {
$this->basename = $parts['basename'];
}
if (isset($parts['extension'])) {
$this->extension = $parts['extension'];
}
if (isset($parts['filename'])) {
$this->filename = $parts['filename'];
}
return $this;
} | [
"protected",
"function",
"parsePath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"dirname",
"=",
"''",
";",
"$",
"this",
"->",
"basename",
"=",
"''",
";",
"$",
"this",
"->",
"extension",
"=",
"''",
";",
"$",
"this",
"->",
"filename",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"parts",
"=",
"pathinfo",
"(",
"$",
"path",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'dirname'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"dirname",
"=",
"rtrim",
"(",
"$",
"parts",
"[",
"'dirname'",
"]",
",",
"'/'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'basename'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"basename",
"=",
"$",
"parts",
"[",
"'basename'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"extension",
"=",
"$",
"parts",
"[",
"'extension'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'filename'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"filename",
"=",
"$",
"parts",
"[",
"'filename'",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Extract the path components from the current path
@param string $path
@return Uri | [
"Extract",
"the",
"path",
"components",
"from",
"the",
"current",
"path"
]
| 3e9ebf1943d3ea468f619ba99f7cc10714cb16e9 | https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Uri.php#L541-L571 | train |
raframework/rapkg | src/Rapkg/Log/Logger.php | Logger.withLevel | public function withLevel($level)
{
if (!isset(self::$levels[$level])) {
throw new InvalidArgumentException('Unsupported log level "' . $level . '"');
}
$this->level = $level;
} | php | public function withLevel($level)
{
if (!isset(self::$levels[$level])) {
throw new InvalidArgumentException('Unsupported log level "' . $level . '"');
}
$this->level = $level;
} | [
"public",
"function",
"withLevel",
"(",
"$",
"level",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"levels",
"[",
"$",
"level",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unsupported log level \"'",
".",
"$",
"level",
".",
"'\"'",
")",
";",
"}",
"$",
"this",
"->",
"level",
"=",
"$",
"level",
";",
"}"
]
| Set log level for logger
@param $level
@throws InvalidArgumentException | [
"Set",
"log",
"level",
"for",
"logger"
]
| 7c4371911369d7c9d4463127bcd285144d7347ee | https://github.com/raframework/rapkg/blob/7c4371911369d7c9d4463127bcd285144d7347ee/src/Rapkg/Log/Logger.php#L45-L52 | train |
AdamB7586/menu-builder | src/Helpers/Validate.php | Validate.validateURI | public static function validateURI($uri) {
if(!empty(trim($uri))){
return filter_var(trim($uri), FILTER_VALIDATE_URL);
}
return false;
} | php | public static function validateURI($uri) {
if(!empty(trim($uri))){
return filter_var(trim($uri), FILTER_VALIDATE_URL);
}
return false;
} | [
"public",
"static",
"function",
"validateURI",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"trim",
"(",
"$",
"uri",
")",
")",
")",
"{",
"return",
"filter_var",
"(",
"trim",
"(",
"$",
"uri",
")",
",",
"FILTER_VALIDATE_URL",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Validates that a URI is valid
@param string $uri This should be the URI you are checking
@return boolean If the URI is valid will return true else returns false | [
"Validates",
"that",
"a",
"URI",
"is",
"valid"
]
| dbc192bca7d59475068c19d1a07a039e5f997ee4 | https://github.com/AdamB7586/menu-builder/blob/dbc192bca7d59475068c19d1a07a039e5f997ee4/src/Helpers/Validate.php#L11-L16 | train |
alphalemon/BootstrapBundle | Core/Script/Base/BaseScript.php | BaseScript.doExecuteActions | protected function doExecuteActions($method, array $actionManagers)
{
$actions = array('post' => array(), 'notExecuted' => array());
$this->executeFailedActions($method);
if (0 !== count($actionManagers)){
$actions = $this->execute($method, $actionManagers);
if(!empty($actions['notExecuted'])) $this->writeFailedActions('.' . $method, $actions['notExecuted']);
}
return $actions;
} | php | protected function doExecuteActions($method, array $actionManagers)
{
$actions = array('post' => array(), 'notExecuted' => array());
$this->executeFailedActions($method);
if (0 !== count($actionManagers)){
$actions = $this->execute($method, $actionManagers);
if(!empty($actions['notExecuted'])) $this->writeFailedActions('.' . $method, $actions['notExecuted']);
}
return $actions;
} | [
"protected",
"function",
"doExecuteActions",
"(",
"$",
"method",
",",
"array",
"$",
"actionManagers",
")",
"{",
"$",
"actions",
"=",
"array",
"(",
"'post'",
"=>",
"array",
"(",
")",
",",
"'notExecuted'",
"=>",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"executeFailedActions",
"(",
"$",
"method",
")",
";",
"if",
"(",
"0",
"!==",
"count",
"(",
"$",
"actionManagers",
")",
")",
"{",
"$",
"actions",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"method",
",",
"$",
"actionManagers",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"actions",
"[",
"'notExecuted'",
"]",
")",
")",
"$",
"this",
"->",
"writeFailedActions",
"(",
"'.'",
".",
"$",
"method",
",",
"$",
"actions",
"[",
"'notExecuted'",
"]",
")",
";",
"}",
"return",
"$",
"actions",
";",
"}"
]
| Executes the given method defined by the given ActionsManager
@param string $method
@param array $actionManagers
@return array An array that contains the post actions and the not execution action | [
"Executes",
"the",
"given",
"method",
"defined",
"by",
"the",
"given",
"ActionsManager"
]
| 27ff5cbc58d58149ec72a974f2a9d765a6fd37a6 | https://github.com/alphalemon/BootstrapBundle/blob/27ff5cbc58d58149ec72a974f2a9d765a6fd37a6/Core/Script/Base/BaseScript.php#L57-L67 | train |
alphalemon/BootstrapBundle | Core/Script/Base/BaseScript.php | BaseScript.executeFailedActions | protected function executeFailedActions($action)
{
$fileName = $this->basePath . '/.' . $action;
if (file_exists($fileName)) {
$actionManagers = $this->decode($fileName);
$actions = $this->execute($action, $actionManagers);
$this->writeFailedActions('.' . $action, $actions['notExecuted']);
}
} | php | protected function executeFailedActions($action)
{
$fileName = $this->basePath . '/.' . $action;
if (file_exists($fileName)) {
$actionManagers = $this->decode($fileName);
$actions = $this->execute($action, $actionManagers);
$this->writeFailedActions('.' . $action, $actions['notExecuted']);
}
} | [
"protected",
"function",
"executeFailedActions",
"(",
"$",
"action",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"basePath",
".",
"'/.'",
".",
"$",
"action",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"actionManagers",
"=",
"$",
"this",
"->",
"decode",
"(",
"$",
"fileName",
")",
";",
"$",
"actions",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"action",
",",
"$",
"actionManagers",
")",
";",
"$",
"this",
"->",
"writeFailedActions",
"(",
"'.'",
".",
"$",
"action",
",",
"$",
"actions",
"[",
"'notExecuted'",
"]",
")",
";",
"}",
"}"
]
| Executes the failed action
@param string $action | [
"Executes",
"the",
"failed",
"action"
]
| 27ff5cbc58d58149ec72a974f2a9d765a6fd37a6 | https://github.com/alphalemon/BootstrapBundle/blob/27ff5cbc58d58149ec72a974f2a9d765a6fd37a6/Core/Script/Base/BaseScript.php#L74-L82 | train |
alphalemon/BootstrapBundle | Core/Script/Base/BaseScript.php | BaseScript.execute | protected function execute($method, array $actionManagers)
{
$actions = array('post' => array(), 'notExecuted' => array());
foreach ($actionManagers as $bundleName => $actionManager) {
$this->actionManagerGenerator->generate($actionManager);
$actionManagerClass = $this->actionManagerGenerator->getActionManagerClass();
$actionManager = $this->actionManagerGenerator->getActionManager();
if (null !== $actionManager && false === $actionManager->$method()) $actions['notExecuted'][$bundleName] = $actionManagerClass;
$actions['post'][$bundleName] = $actionManagerClass;
}
return $actions;
} | php | protected function execute($method, array $actionManagers)
{
$actions = array('post' => array(), 'notExecuted' => array());
foreach ($actionManagers as $bundleName => $actionManager) {
$this->actionManagerGenerator->generate($actionManager);
$actionManagerClass = $this->actionManagerGenerator->getActionManagerClass();
$actionManager = $this->actionManagerGenerator->getActionManager();
if (null !== $actionManager && false === $actionManager->$method()) $actions['notExecuted'][$bundleName] = $actionManagerClass;
$actions['post'][$bundleName] = $actionManagerClass;
}
return $actions;
} | [
"protected",
"function",
"execute",
"(",
"$",
"method",
",",
"array",
"$",
"actionManagers",
")",
"{",
"$",
"actions",
"=",
"array",
"(",
"'post'",
"=>",
"array",
"(",
")",
",",
"'notExecuted'",
"=>",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"actionManagers",
"as",
"$",
"bundleName",
"=>",
"$",
"actionManager",
")",
"{",
"$",
"this",
"->",
"actionManagerGenerator",
"->",
"generate",
"(",
"$",
"actionManager",
")",
";",
"$",
"actionManagerClass",
"=",
"$",
"this",
"->",
"actionManagerGenerator",
"->",
"getActionManagerClass",
"(",
")",
";",
"$",
"actionManager",
"=",
"$",
"this",
"->",
"actionManagerGenerator",
"->",
"getActionManager",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"actionManager",
"&&",
"false",
"===",
"$",
"actionManager",
"->",
"$",
"method",
"(",
")",
")",
"$",
"actions",
"[",
"'notExecuted'",
"]",
"[",
"$",
"bundleName",
"]",
"=",
"$",
"actionManagerClass",
";",
"$",
"actions",
"[",
"'post'",
"]",
"[",
"$",
"bundleName",
"]",
"=",
"$",
"actionManagerClass",
";",
"}",
"return",
"$",
"actions",
";",
"}"
]
| Executes the actions
@param type $method
@param array $actionManagers
@return type
@throws MissingDependencyException | [
"Executes",
"the",
"actions"
]
| 27ff5cbc58d58149ec72a974f2a9d765a6fd37a6 | https://github.com/alphalemon/BootstrapBundle/blob/27ff5cbc58d58149ec72a974f2a9d765a6fd37a6/Core/Script/Base/BaseScript.php#L92-L104 | train |
alphalemon/BootstrapBundle | Core/Script/Base/BaseScript.php | BaseScript.writePostActions | protected function writePostActions($fileName, array $actions)
{
$fileName = $this->basePath . '/' . $fileName;
$this->encode($fileName, $actions);
} | php | protected function writePostActions($fileName, array $actions)
{
$fileName = $this->basePath . '/' . $fileName;
$this->encode($fileName, $actions);
} | [
"protected",
"function",
"writePostActions",
"(",
"$",
"fileName",
",",
"array",
"$",
"actions",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"$",
"fileName",
";",
"$",
"this",
"->",
"encode",
"(",
"$",
"fileName",
",",
"$",
"actions",
")",
";",
"}"
]
| Writes the post actions file
@param string $fileName
@param array $actions | [
"Writes",
"the",
"post",
"actions",
"file"
]
| 27ff5cbc58d58149ec72a974f2a9d765a6fd37a6 | https://github.com/alphalemon/BootstrapBundle/blob/27ff5cbc58d58149ec72a974f2a9d765a6fd37a6/Core/Script/Base/BaseScript.php#L112-L116 | train |
alphalemon/BootstrapBundle | Core/Script/Base/BaseScript.php | BaseScript.writeFailedActions | protected function writeFailedActions($fileName, $actions)
{
$fileName = $this->basePath . '/' . $fileName;
$this->filesystem->remove($fileName);
if (!empty($actions)) $this->encode($fileName, $actions);
} | php | protected function writeFailedActions($fileName, $actions)
{
$fileName = $this->basePath . '/' . $fileName;
$this->filesystem->remove($fileName);
if (!empty($actions)) $this->encode($fileName, $actions);
} | [
"protected",
"function",
"writeFailedActions",
"(",
"$",
"fileName",
",",
"$",
"actions",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"$",
"fileName",
";",
"$",
"this",
"->",
"filesystem",
"->",
"remove",
"(",
"$",
"fileName",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"actions",
")",
")",
"$",
"this",
"->",
"encode",
"(",
"$",
"fileName",
",",
"$",
"actions",
")",
";",
"}"
]
| Writes the failed actions file
@param string $fileName
@param type $actions | [
"Writes",
"the",
"failed",
"actions",
"file"
]
| 27ff5cbc58d58149ec72a974f2a9d765a6fd37a6 | https://github.com/alphalemon/BootstrapBundle/blob/27ff5cbc58d58149ec72a974f2a9d765a6fd37a6/Core/Script/Base/BaseScript.php#L124-L129 | train |
Soneritics/Buckaroo | Soneritics/Buckaroo/Response/TransactionStatusResponse.php | TransactionStatusResponse.validateSignature | protected function validateSignature()
{
$check = [];
foreach ($this->data as $key => $value) {
if ($key !== 'brq_signature') {
$check[$key] = $value;
}
}
$signature = new Signature($check, $this->secretKey);
if (empty($this->data['brq_signature']) || (string)$signature !== $this->data['brq_signature']) {
throw new InvalidSignatureException;
}
} | php | protected function validateSignature()
{
$check = [];
foreach ($this->data as $key => $value) {
if ($key !== 'brq_signature') {
$check[$key] = $value;
}
}
$signature = new Signature($check, $this->secretKey);
if (empty($this->data['brq_signature']) || (string)$signature !== $this->data['brq_signature']) {
throw new InvalidSignatureException;
}
} | [
"protected",
"function",
"validateSignature",
"(",
")",
"{",
"$",
"check",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"'brq_signature'",
")",
"{",
"$",
"check",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"signature",
"=",
"new",
"Signature",
"(",
"$",
"check",
",",
"$",
"this",
"->",
"secretKey",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'brq_signature'",
"]",
")",
"||",
"(",
"string",
")",
"$",
"signature",
"!==",
"$",
"this",
"->",
"data",
"[",
"'brq_signature'",
"]",
")",
"{",
"throw",
"new",
"InvalidSignatureException",
";",
"}",
"}"
]
| Validate the transaction.
@throws InvalidSignatureException | [
"Validate",
"the",
"transaction",
"."
]
| cb345dce9b96c996e47121d6145a7e314943c8f1 | https://github.com/Soneritics/Buckaroo/blob/cb345dce9b96c996e47121d6145a7e314943c8f1/Soneritics/Buckaroo/Response/TransactionStatusResponse.php#L109-L122 | train |
ScaraMVC/Framework | src/Scara/Input/FormInput.php | FormInput.input | public function input($key = null, $default = null)
{
$input = $this->getInputSource();
return $this->inputSift($input, $key, $default);
} | php | public function input($key = null, $default = null)
{
$input = $this->getInputSource();
return $this->inputSift($input, $key, $default);
} | [
"public",
"function",
"input",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"getInputSource",
"(",
")",
";",
"return",
"$",
"this",
"->",
"inputSift",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"}"
]
| Retrieves an input.
@param null $key - The input's key
@param null $default - The input $key's default value
@return mixed | [
"Retrieves",
"an",
"input",
"."
]
| 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Input/FormInput.php#L60-L65 | train |
rutger-speksnijder/restphp | src/RestPHP/Response/Types/JSON.php | JSON.transform | protected function transform($data, $hypertextRoutes = [])
{
$links = $this->getHypertextJson($hypertextRoutes);
if ($links && is_array($data)) {
$data['_links'] = $links;
} elseif ($links && !is_array($data)) {
$data = [$data, '_links' => $links];
}
return json_encode($data);
} | php | protected function transform($data, $hypertextRoutes = [])
{
$links = $this->getHypertextJson($hypertextRoutes);
if ($links && is_array($data)) {
$data['_links'] = $links;
} elseif ($links && !is_array($data)) {
$data = [$data, '_links' => $links];
}
return json_encode($data);
} | [
"protected",
"function",
"transform",
"(",
"$",
"data",
",",
"$",
"hypertextRoutes",
"=",
"[",
"]",
")",
"{",
"$",
"links",
"=",
"$",
"this",
"->",
"getHypertextJson",
"(",
"$",
"hypertextRoutes",
")",
";",
"if",
"(",
"$",
"links",
"&&",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"[",
"'_links'",
"]",
"=",
"$",
"links",
";",
"}",
"elseif",
"(",
"$",
"links",
"&&",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"$",
"data",
",",
"'_links'",
"=>",
"$",
"links",
"]",
";",
"}",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"}"
]
| Transforms the data into a json response.
@param mixed $data The data to transform.
@param optional array $hypertextRoutes An array with hypertext routes.
@return string The transformed response. | [
"Transforms",
"the",
"data",
"into",
"a",
"json",
"response",
"."
]
| 326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d | https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/JSON.php#L35-L44 | train |
rutger-speksnijder/restphp | src/RestPHP/Response/Types/JSON.php | JSON.getHypertextJson | private function getHypertextJson($routes = [])
{
if (!$routes) {
return false;
}
$links = [];
foreach ($routes as $name => $route) {
$links[] = ['rel' => $name, 'href' => $route];
}
return $links;
} | php | private function getHypertextJson($routes = [])
{
if (!$routes) {
return false;
}
$links = [];
foreach ($routes as $name => $route) {
$links[] = ['rel' => $name, 'href' => $route];
}
return $links;
} | [
"private",
"function",
"getHypertextJson",
"(",
"$",
"routes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"routes",
")",
"{",
"return",
"false",
";",
"}",
"$",
"links",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"name",
"=>",
"$",
"route",
")",
"{",
"$",
"links",
"[",
"]",
"=",
"[",
"'rel'",
"=>",
"$",
"name",
",",
"'href'",
"=>",
"$",
"route",
"]",
";",
"}",
"return",
"$",
"links",
";",
"}"
]
| Transforms the hypertext routes into an array for the json string.
@param array $routes The hypertext routes.
@return array An array of links for the json string. | [
"Transforms",
"the",
"hypertext",
"routes",
"into",
"an",
"array",
"for",
"the",
"json",
"string",
"."
]
| 326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d | https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/JSON.php#L53-L63 | train |
SuPa86000/ZF2Assetic | src/Assetic/Filter/SprocketsFilter.php | SprocketsFilter.filterLoad | public function filterLoad(AssetInterface $asset)
{
static $format = <<<'EOF'
#!/usr/bin/env ruby
require %s
%s
options = { :load_path => [],
:source_files => [%s],
:expand_paths => false }
%ssecretary = Sprockets::Secretary.new(options)
secretary.install_assets if options[:asset_root]
print secretary.concatenation
EOF;
$more = '';
foreach ($this->includeDirs as $directory) {
$more .= 'options[:load_path] << '.var_export($directory, true)."\n";
}
if (null !== $this->assetRoot) {
$more .= 'options[:asset_root] = '.var_export($this->assetRoot, true)."\n";
}
if ($more) {
$more .= "\n";
}
$tmpAsset = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
file_put_contents($tmpAsset, $asset->getContent());
$input = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
file_put_contents($input, sprintf($format,
$this->sprocketsLib
? sprintf('File.join(%s, \'sprockets\')', var_export($this->sprocketsLib, true))
: '\'sprockets\'',
$this->getHack($asset),
var_export($tmpAsset, true),
$more
));
$pb = $this->createProcessBuilder(array(
$this->rubyBin,
$input,
));
$proc = $pb->getProcess();
$code = $proc->run();
unlink($tmpAsset);
unlink($input);
if (0 !== $code) {
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
}
$asset->setContent($proc->getOutput());
} | php | public function filterLoad(AssetInterface $asset)
{
static $format = <<<'EOF'
#!/usr/bin/env ruby
require %s
%s
options = { :load_path => [],
:source_files => [%s],
:expand_paths => false }
%ssecretary = Sprockets::Secretary.new(options)
secretary.install_assets if options[:asset_root]
print secretary.concatenation
EOF;
$more = '';
foreach ($this->includeDirs as $directory) {
$more .= 'options[:load_path] << '.var_export($directory, true)."\n";
}
if (null !== $this->assetRoot) {
$more .= 'options[:asset_root] = '.var_export($this->assetRoot, true)."\n";
}
if ($more) {
$more .= "\n";
}
$tmpAsset = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
file_put_contents($tmpAsset, $asset->getContent());
$input = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
file_put_contents($input, sprintf($format,
$this->sprocketsLib
? sprintf('File.join(%s, \'sprockets\')', var_export($this->sprocketsLib, true))
: '\'sprockets\'',
$this->getHack($asset),
var_export($tmpAsset, true),
$more
));
$pb = $this->createProcessBuilder(array(
$this->rubyBin,
$input,
));
$proc = $pb->getProcess();
$code = $proc->run();
unlink($tmpAsset);
unlink($input);
if (0 !== $code) {
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
}
$asset->setContent($proc->getOutput());
} | [
"public",
"function",
"filterLoad",
"(",
"AssetInterface",
"$",
"asset",
")",
"{",
"static",
"$",
"format",
"=",
" <<<'EOF'\n#!/usr/bin/env ruby\n\nrequire %s\n%s\noptions = { :load_path => [],\n :source_files => [%s],\n :expand_paths => false }\n\n%ssecretary = Sprockets::Secretary.new(options)\nsecretary.install_assets if options[:asset_root]\nprint secretary.concatenation\n\nEOF",
";",
"$",
"more",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"includeDirs",
"as",
"$",
"directory",
")",
"{",
"$",
"more",
".=",
"'options[:load_path] << '",
".",
"var_export",
"(",
"$",
"directory",
",",
"true",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"assetRoot",
")",
"{",
"$",
"more",
".=",
"'options[:asset_root] = '",
".",
"var_export",
"(",
"$",
"this",
"->",
"assetRoot",
",",
"true",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"more",
")",
"{",
"$",
"more",
".=",
"\"\\n\"",
";",
"}",
"$",
"tmpAsset",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'assetic_sprockets'",
")",
";",
"file_put_contents",
"(",
"$",
"tmpAsset",
",",
"$",
"asset",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"input",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'assetic_sprockets'",
")",
";",
"file_put_contents",
"(",
"$",
"input",
",",
"sprintf",
"(",
"$",
"format",
",",
"$",
"this",
"->",
"sprocketsLib",
"?",
"sprintf",
"(",
"'File.join(%s, \\'sprockets\\')'",
",",
"var_export",
"(",
"$",
"this",
"->",
"sprocketsLib",
",",
"true",
")",
")",
":",
"'\\'sprockets\\''",
",",
"$",
"this",
"->",
"getHack",
"(",
"$",
"asset",
")",
",",
"var_export",
"(",
"$",
"tmpAsset",
",",
"true",
")",
",",
"$",
"more",
")",
")",
";",
"$",
"pb",
"=",
"$",
"this",
"->",
"createProcessBuilder",
"(",
"array",
"(",
"$",
"this",
"->",
"rubyBin",
",",
"$",
"input",
",",
")",
")",
";",
"$",
"proc",
"=",
"$",
"pb",
"->",
"getProcess",
"(",
")",
";",
"$",
"code",
"=",
"$",
"proc",
"->",
"run",
"(",
")",
";",
"unlink",
"(",
"$",
"tmpAsset",
")",
";",
"unlink",
"(",
"$",
"input",
")",
";",
"if",
"(",
"0",
"!==",
"$",
"code",
")",
"{",
"throw",
"FilterException",
"::",
"fromProcess",
"(",
"$",
"proc",
")",
"->",
"setInput",
"(",
"$",
"asset",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"$",
"asset",
"->",
"setContent",
"(",
"$",
"proc",
"->",
"getOutput",
"(",
")",
")",
";",
"}"
]
| Hack around a bit, get the job done. | [
"Hack",
"around",
"a",
"bit",
"get",
"the",
"job",
"done",
"."
]
| 3c432f321b5acdc9649f7d2cc80ce4ed98351f93 | https://github.com/SuPa86000/ZF2Assetic/blob/3c432f321b5acdc9649f7d2cc80ce4ed98351f93/src/Assetic/Filter/SprocketsFilter.php#L61-L120 | train |
battis/mysql-schema-loader | src/Loader.php | Loader.strposArray | private function strposArray($haystack, $needles)
{
if (is_array($needles)) {
foreach ($needles as $needle) {
if (($strpos = strpos($haystack, $needle)) !== false) {
return $strpos;
}
}
}
return false;
} | php | private function strposArray($haystack, $needles)
{
if (is_array($needles)) {
foreach ($needles as $needle) {
if (($strpos = strpos($haystack, $needle)) !== false) {
return $strpos;
}
}
}
return false;
} | [
"private",
"function",
"strposArray",
"(",
"$",
"haystack",
",",
"$",
"needles",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"needles",
")",
")",
"{",
"foreach",
"(",
"$",
"needles",
"as",
"$",
"needle",
")",
"{",
"if",
"(",
"(",
"$",
"strpos",
"=",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"strpos",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Find the position of the first occurrence of any of several substrings
in a string
@param string $haystack The string to search in.
@param mixed $needles Array of strings to search for. If a needle is
not a string, it is converted to an integer and applied as the
ordinal value of a character.
@return int|boolean Returns the position of where the first found needle
exists relative to the beginning of the haystack string (independent
of offset). Also note that string positions start at 0, and not 1.
Returns `false` if the needle was not found. | [
"Find",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"any",
"of",
"several",
"substrings",
"in",
"a",
"string"
]
| 9a499470b9799bab8eee3deb21113826d882afbd | https://github.com/battis/mysql-schema-loader/blob/9a499470b9799bab8eee3deb21113826d882afbd/src/Loader.php#L85-L95 | train |
battis/mysql-schema-loader | src/Loader.php | Loader.load | public function load($test = true)
{
$missingTables = false;
if ($test) {
$missingTables = $this->test();
}
if (!$test || ($test && $missingTables !== false)) {
foreach (explode(';', $this->schema) as $query) {
if (!empty(trim($query))) {
if (!$test || $this->strposArray($query, $missingTables) !== false) {
if ($this->mysql->query($query) === false) {
throw new LoaderException(
"Error {$this->mysql->errno}: {$this->mysql->error}",
LoaderException::MYSQL
);
}
}
}
}
}
return ($test ? $missingTables : true);
} | php | public function load($test = true)
{
$missingTables = false;
if ($test) {
$missingTables = $this->test();
}
if (!$test || ($test && $missingTables !== false)) {
foreach (explode(';', $this->schema) as $query) {
if (!empty(trim($query))) {
if (!$test || $this->strposArray($query, $missingTables) !== false) {
if ($this->mysql->query($query) === false) {
throw new LoaderException(
"Error {$this->mysql->errno}: {$this->mysql->error}",
LoaderException::MYSQL
);
}
}
}
}
}
return ($test ? $missingTables : true);
} | [
"public",
"function",
"load",
"(",
"$",
"test",
"=",
"true",
")",
"{",
"$",
"missingTables",
"=",
"false",
";",
"if",
"(",
"$",
"test",
")",
"{",
"$",
"missingTables",
"=",
"$",
"this",
"->",
"test",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"test",
"||",
"(",
"$",
"test",
"&&",
"$",
"missingTables",
"!==",
"false",
")",
")",
"{",
"foreach",
"(",
"explode",
"(",
"';'",
",",
"$",
"this",
"->",
"schema",
")",
"as",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"trim",
"(",
"$",
"query",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"test",
"||",
"$",
"this",
"->",
"strposArray",
"(",
"$",
"query",
",",
"$",
"missingTables",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mysql",
"->",
"query",
"(",
"$",
"query",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"LoaderException",
"(",
"\"Error {$this->mysql->errno}: {$this->mysql->error}\"",
",",
"LoaderException",
"::",
"MYSQL",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"(",
"$",
"test",
"?",
"$",
"missingTables",
":",
"true",
")",
";",
"}"
]
| Load the schema into the database
If `$test` is set to `true`, this method will test to see if any tables
created by the schema are missing. If any tables are missing, then only
the queries affecting those tables will be run. Otherwise, if `$test` is
`false`, all queries in the schema will be run blindly, potentially
throwing `LoaderException` if an already-created table is recreated.
@param boolean $test Whether or not to test for missing tables
@return boolean|string[] (Optional, defaults to `true`) If `$test` is
`true`, returns either a list of missing tables or `false` if no
tables were missing, otherwise returns `true` on success.
@throws LoaderException `LoaderException::MYSQL` on MySQL query error | [
"Load",
"the",
"schema",
"into",
"the",
"database"
]
| 9a499470b9799bab8eee3deb21113826d882afbd | https://github.com/battis/mysql-schema-loader/blob/9a499470b9799bab8eee3deb21113826d882afbd/src/Loader.php#L112-L135 | train |
cogentParadigm/behat-starbug-extension | src/Context/MailContext.php | MailContext.assertEmail | public function assertEmail($subject, $address) {
$message = $this->getMailCatcherClient()->searchOne([
Message::SUBJECT_CRITERIA => $subject,
Message::TO_CRITERIA => $address
]);
if (is_null($message)) {
throw new Exception("Message not found.");
}
} | php | public function assertEmail($subject, $address) {
$message = $this->getMailCatcherClient()->searchOne([
Message::SUBJECT_CRITERIA => $subject,
Message::TO_CRITERIA => $address
]);
if (is_null($message)) {
throw new Exception("Message not found.");
}
} | [
"public",
"function",
"assertEmail",
"(",
"$",
"subject",
",",
"$",
"address",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"getMailCatcherClient",
"(",
")",
"->",
"searchOne",
"(",
"[",
"Message",
"::",
"SUBJECT_CRITERIA",
"=>",
"$",
"subject",
",",
"Message",
"::",
"TO_CRITERIA",
"=>",
"$",
"address",
"]",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"message",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Message not found.\"",
")",
";",
"}",
"}"
]
| Check for email.
@Then :subject should be emailed to :address
@throws Exception When no matching message is found. | [
"Check",
"for",
"email",
"."
]
| 76da5d943773857ad2388a7cccb6632176b452a9 | https://github.com/cogentParadigm/behat-starbug-extension/blob/76da5d943773857ad2388a7cccb6632176b452a9/src/Context/MailContext.php#L17-L25 | train |
ekyna/Resource | Doctrine/ORM/Util/TranslatableResourceRepositoryTrait.php | TranslatableResourceRepositoryTrait.getQueryBuilder | protected function getQueryBuilder($alias = null, $indexBy = null)
{
$qb = $this->traitGetQueryBuilder($alias, $indexBy);
$alias = $alias ?: $this->getAlias();
return $qb
->addSelect('translation')
->leftJoin($alias . '.translations', 'translation');
} | php | protected function getQueryBuilder($alias = null, $indexBy = null)
{
$qb = $this->traitGetQueryBuilder($alias, $indexBy);
$alias = $alias ?: $this->getAlias();
return $qb
->addSelect('translation')
->leftJoin($alias . '.translations', 'translation');
} | [
"protected",
"function",
"getQueryBuilder",
"(",
"$",
"alias",
"=",
"null",
",",
"$",
"indexBy",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"traitGetQueryBuilder",
"(",
"$",
"alias",
",",
"$",
"indexBy",
")",
";",
"$",
"alias",
"=",
"$",
"alias",
"?",
":",
"$",
"this",
"->",
"getAlias",
"(",
")",
";",
"return",
"$",
"qb",
"->",
"addSelect",
"(",
"'translation'",
")",
"->",
"leftJoin",
"(",
"$",
"alias",
".",
"'.translations'",
",",
"'translation'",
")",
";",
"}"
]
| Returns the singe result query builder.
@param string $alias
@param string $indexBy
@return \Doctrine\ORM\QueryBuilder | [
"Returns",
"the",
"singe",
"result",
"query",
"builder",
"."
]
| 96ee3d28e02bd9513705408e3bb7f88a76e52f56 | https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/Doctrine/ORM/Util/TranslatableResourceRepositoryTrait.php#L43-L52 | train |
ekyna/Resource | Doctrine/ORM/Util/TranslatableResourceRepositoryTrait.php | TranslatableResourceRepositoryTrait.getCollectionQueryBuilder | protected function getCollectionQueryBuilder($alias = null, $indexBy = null)
{
$qb = $this->traitGetCollectionQueryBuilder($alias, $indexBy);
$alias = $alias ?: $this->getAlias();
return $qb
->addSelect('translation')
->leftJoin($alias . '.translations', 'translation');
} | php | protected function getCollectionQueryBuilder($alias = null, $indexBy = null)
{
$qb = $this->traitGetCollectionQueryBuilder($alias, $indexBy);
$alias = $alias ?: $this->getAlias();
return $qb
->addSelect('translation')
->leftJoin($alias . '.translations', 'translation');
} | [
"protected",
"function",
"getCollectionQueryBuilder",
"(",
"$",
"alias",
"=",
"null",
",",
"$",
"indexBy",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"traitGetCollectionQueryBuilder",
"(",
"$",
"alias",
",",
"$",
"indexBy",
")",
";",
"$",
"alias",
"=",
"$",
"alias",
"?",
":",
"$",
"this",
"->",
"getAlias",
"(",
")",
";",
"return",
"$",
"qb",
"->",
"addSelect",
"(",
"'translation'",
")",
"->",
"leftJoin",
"(",
"$",
"alias",
".",
"'.translations'",
",",
"'translation'",
")",
";",
"}"
]
| Returns the collection query builder.
@param string $alias
@param string $indexBy
@return \Doctrine\ORM\QueryBuilder | [
"Returns",
"the",
"collection",
"query",
"builder",
"."
]
| 96ee3d28e02bd9513705408e3bb7f88a76e52f56 | https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/Doctrine/ORM/Util/TranslatableResourceRepositoryTrait.php#L62-L71 | train |
ekyna/Resource | Doctrine/ORM/Util/TranslatableResourceRepositoryTrait.php | TranslatableResourceRepositoryTrait.createNew | public function createNew()
{
$resource = $this->traitCreateNew();
if (!$resource instanceof TranslatableInterface) {
throw new \InvalidArgumentException('Resource must implement TranslatableInterface.');
}
$resource->setCurrentLocale($this->localeProvider->getCurrentLocale());
$resource->setFallbackLocale($this->localeProvider->getFallbackLocale());
return $resource;
} | php | public function createNew()
{
$resource = $this->traitCreateNew();
if (!$resource instanceof TranslatableInterface) {
throw new \InvalidArgumentException('Resource must implement TranslatableInterface.');
}
$resource->setCurrentLocale($this->localeProvider->getCurrentLocale());
$resource->setFallbackLocale($this->localeProvider->getFallbackLocale());
return $resource;
} | [
"public",
"function",
"createNew",
"(",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"traitCreateNew",
"(",
")",
";",
"if",
"(",
"!",
"$",
"resource",
"instanceof",
"TranslatableInterface",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Resource must implement TranslatableInterface.'",
")",
";",
"}",
"$",
"resource",
"->",
"setCurrentLocale",
"(",
"$",
"this",
"->",
"localeProvider",
"->",
"getCurrentLocale",
"(",
")",
")",
";",
"$",
"resource",
"->",
"setFallbackLocale",
"(",
"$",
"this",
"->",
"localeProvider",
"->",
"getFallbackLocale",
"(",
")",
")",
";",
"return",
"$",
"resource",
";",
"}"
]
| Returns a new resource instance.
@throws \InvalidArgumentException
@return object | [
"Returns",
"a",
"new",
"resource",
"instance",
"."
]
| 96ee3d28e02bd9513705408e3bb7f88a76e52f56 | https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/Doctrine/ORM/Util/TranslatableResourceRepositoryTrait.php#L80-L92 | train |
devlabmtl/haven-cms | Entity/Comment.php | Comment.getUserEndorsement | public function getUserEndorsement($user) {
return $this->endorsements->filter(function($e) use ($user) {
return $e->getUser() == $user;
})->first();
} | php | public function getUserEndorsement($user) {
return $this->endorsements->filter(function($e) use ($user) {
return $e->getUser() == $user;
})->first();
} | [
"public",
"function",
"getUserEndorsement",
"(",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"endorsements",
"->",
"filter",
"(",
"function",
"(",
"$",
"e",
")",
"use",
"(",
"$",
"user",
")",
"{",
"return",
"$",
"e",
"->",
"getUser",
"(",
")",
"==",
"$",
"user",
";",
"}",
")",
"->",
"first",
"(",
")",
";",
"}"
]
| Get the current endorsement for a specific user_id
@return \Doctrine\Common\Collections\Collection | [
"Get",
"the",
"current",
"endorsement",
"for",
"a",
"specific",
"user_id"
]
| c20761a07c201a966dbda1f3eae33617f80e1ece | https://github.com/devlabmtl/haven-cms/blob/c20761a07c201a966dbda1f3eae33617f80e1ece/Entity/Comment.php#L249-L253 | train |
PenoaksDev/Milky-Framework | src/Milky/Account/Guards/TokenGuard.php | TokenGuard.validate | public function validate( array $credentials = [] )
{
$credentials = [$this->storageKey => $credentials[$this->inputKey]];
if ( $this->auth->retrieveByCredentials( $credentials ) )
return true;
return false;
} | php | public function validate( array $credentials = [] )
{
$credentials = [$this->storageKey => $credentials[$this->inputKey]];
if ( $this->auth->retrieveByCredentials( $credentials ) )
return true;
return false;
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"credentials",
"=",
"[",
"]",
")",
"{",
"$",
"credentials",
"=",
"[",
"$",
"this",
"->",
"storageKey",
"=>",
"$",
"credentials",
"[",
"$",
"this",
"->",
"inputKey",
"]",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"auth",
"->",
"retrieveByCredentials",
"(",
"$",
"credentials",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
]
| Validate a acct's credentials.
@param array $credentials
@return bool | [
"Validate",
"a",
"acct",
"s",
"credentials",
"."
]
| 8afd7156610a70371aa5b1df50b8a212bf7b142c | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/TokenGuard.php#L93-L101 | train |
Dhii/exception-helper-base | src/CreateInternalExceptionCapableTrait.php | CreateInternalExceptionCapableTrait._createInternalException | protected function _createInternalException($message = null, $code = null, $previous = null)
{
return new InternalException($message, $code, $previous);
} | php | protected function _createInternalException($message = null, $code = null, $previous = null)
{
return new InternalException($message, $code, $previous);
} | [
"protected",
"function",
"_createInternalException",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"code",
"=",
"null",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"return",
"new",
"InternalException",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"previous",
")",
";",
"}"
]
| Creates a new Internal exception.
@since [*next-version*]
@param string|Stringable|int|float|bool|null $message The message, if any.
@param int|float|string|Stringable|null $code The numeric error code, if any.
@param RootException|null $previous The inner exception, if any.
@return InternalException The new exception. | [
"Creates",
"a",
"new",
"Internal",
"exception",
"."
]
| e97bfa6c0f79ea079e36b2f1d8f84d7566a3ccf5 | https://github.com/Dhii/exception-helper-base/blob/e97bfa6c0f79ea079e36b2f1d8f84d7566a3ccf5/src/CreateInternalExceptionCapableTrait.php#L26-L29 | train |
dms-org/common.structure | src/DateTime/DateTimeRange.php | DateTimeRange.encompasses | public function encompasses(DateTimeRange $otherRange) : bool
{
return $this->start->comesBeforeOrEqual($otherRange->start) && $this->end->comesAfterOrEqual($otherRange->end);
} | php | public function encompasses(DateTimeRange $otherRange) : bool
{
return $this->start->comesBeforeOrEqual($otherRange->start) && $this->end->comesAfterOrEqual($otherRange->end);
} | [
"public",
"function",
"encompasses",
"(",
"DateTimeRange",
"$",
"otherRange",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"start",
"->",
"comesBeforeOrEqual",
"(",
"$",
"otherRange",
"->",
"start",
")",
"&&",
"$",
"this",
"->",
"end",
"->",
"comesAfterOrEqual",
"(",
"$",
"otherRange",
"->",
"end",
")",
";",
"}"
]
| Returns whether the supplied date time range is encompassed by this
date time range.
@param DateTimeRange $otherRange
@return bool | [
"Returns",
"whether",
"the",
"supplied",
"date",
"time",
"range",
"is",
"encompassed",
"by",
"this",
"date",
"time",
"range",
"."
]
| 23f122182f60df5ec847047a81a39c8aab019ff1 | https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/DateTimeRange.php#L93-L96 | train |
nicodevs/laito | src/Laito/Http/Request.php | Request.method | public function method()
{
// Return the emulated method from GET
$emulated = filter_input(INPUT_GET, '_method', FILTER_SANITIZE_STRING);
// Return the emulated method from POST
if (!$emulated) {
$emulated = filter_input(INPUT_POST, '_method', FILTER_SANITIZE_STRING);
}
// Set the emulated method
if ($this->app->config('request.emulate') && $emulated) {
return $emulated;
}
// Or the real method
return $_SERVER['REQUEST_METHOD'];
} | php | public function method()
{
// Return the emulated method from GET
$emulated = filter_input(INPUT_GET, '_method', FILTER_SANITIZE_STRING);
// Return the emulated method from POST
if (!$emulated) {
$emulated = filter_input(INPUT_POST, '_method', FILTER_SANITIZE_STRING);
}
// Set the emulated method
if ($this->app->config('request.emulate') && $emulated) {
return $emulated;
}
// Or the real method
return $_SERVER['REQUEST_METHOD'];
} | [
"public",
"function",
"method",
"(",
")",
"{",
"// Return the emulated method from GET",
"$",
"emulated",
"=",
"filter_input",
"(",
"INPUT_GET",
",",
"'_method'",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"// Return the emulated method from POST",
"if",
"(",
"!",
"$",
"emulated",
")",
"{",
"$",
"emulated",
"=",
"filter_input",
"(",
"INPUT_POST",
",",
"'_method'",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"}",
"// Set the emulated method",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"config",
"(",
"'request.emulate'",
")",
"&&",
"$",
"emulated",
")",
"{",
"return",
"$",
"emulated",
";",
"}",
"// Or the real method",
"return",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
";",
"}"
]
| Retrieves the request method
@return string Method | [
"Retrieves",
"the",
"request",
"method"
]
| d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Http/Request.php#L32-L49 | train |
nicodevs/laito | src/Laito/Http/Request.php | Request.token | public function token()
{
$inputs = $this->getInputs();
$headers = $this->headers();
// Read token from request custom header
if (isset($headers['X-Auth-Token'])) {
return $headers['X-Auth-Token'];
}
// Read token from request input
if (isset($inputs['token'])) {
return $inputs['token'];
}
// Otherwise, return false
return false;
} | php | public function token()
{
$inputs = $this->getInputs();
$headers = $this->headers();
// Read token from request custom header
if (isset($headers['X-Auth-Token'])) {
return $headers['X-Auth-Token'];
}
// Read token from request input
if (isset($inputs['token'])) {
return $inputs['token'];
}
// Otherwise, return false
return false;
} | [
"public",
"function",
"token",
"(",
")",
"{",
"$",
"inputs",
"=",
"$",
"this",
"->",
"getInputs",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"headers",
"(",
")",
";",
"// Read token from request custom header",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'X-Auth-Token'",
"]",
")",
")",
"{",
"return",
"$",
"headers",
"[",
"'X-Auth-Token'",
"]",
";",
"}",
"// Read token from request input",
"if",
"(",
"isset",
"(",
"$",
"inputs",
"[",
"'token'",
"]",
")",
")",
"{",
"return",
"$",
"inputs",
"[",
"'token'",
"]",
";",
"}",
"// Otherwise, return false",
"return",
"false",
";",
"}"
]
| Retrieves the token
@return mixed Token or false | [
"Retrieves",
"the",
"token"
]
| d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Http/Request.php#L67-L84 | train |
nicodevs/laito | src/Laito/Http/Request.php | Request.input | public function input($input = null, $default = null)
{
// Get all inputs
$inputs = array_merge($this->getInputs(), $this->additionalInputs);
// Exclude reserved inputs
foreach ($inputs as $key => $value) {
if (in_array($key, $this->reserved)) {
unset($inputs[$key]);
}
}
// Return one input
if ($input) {
return isset($inputs[$input])? $inputs[$input] : $default;
}
// Or the complete array of inputs
return $inputs;
} | php | public function input($input = null, $default = null)
{
// Get all inputs
$inputs = array_merge($this->getInputs(), $this->additionalInputs);
// Exclude reserved inputs
foreach ($inputs as $key => $value) {
if (in_array($key, $this->reserved)) {
unset($inputs[$key]);
}
}
// Return one input
if ($input) {
return isset($inputs[$input])? $inputs[$input] : $default;
}
// Or the complete array of inputs
return $inputs;
} | [
"public",
"function",
"input",
"(",
"$",
"input",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// Get all inputs",
"$",
"inputs",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getInputs",
"(",
")",
",",
"$",
"this",
"->",
"additionalInputs",
")",
";",
"// Exclude reserved inputs",
"foreach",
"(",
"$",
"inputs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"reserved",
")",
")",
"{",
"unset",
"(",
"$",
"inputs",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"// Return one input",
"if",
"(",
"$",
"input",
")",
"{",
"return",
"isset",
"(",
"$",
"inputs",
"[",
"$",
"input",
"]",
")",
"?",
"$",
"inputs",
"[",
"$",
"input",
"]",
":",
"$",
"default",
";",
"}",
"// Or the complete array of inputs",
"return",
"$",
"inputs",
";",
"}"
]
| Returns a request input
@param string $input Input key
@param string $default Default value to return
@return mixed Array of inputs, or single input if a key is specified | [
"Returns",
"a",
"request",
"input"
]
| d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Http/Request.php#L120-L139 | train |
nicodevs/laito | src/Laito/Http/Request.php | Request.file | public function file($input = null)
{
// The input name must be defined
if (!isset($input) || !isset($_FILES[$input])) {
throw new \InvalidArgumentException('Invalid file', 400);
}
// Return the file info
return $_FILES[$input];
} | php | public function file($input = null)
{
// The input name must be defined
if (!isset($input) || !isset($_FILES[$input])) {
throw new \InvalidArgumentException('Invalid file', 400);
}
// Return the file info
return $_FILES[$input];
} | [
"public",
"function",
"file",
"(",
"$",
"input",
"=",
"null",
")",
"{",
"// The input name must be defined",
"if",
"(",
"!",
"isset",
"(",
"$",
"input",
")",
"||",
"!",
"isset",
"(",
"$",
"_FILES",
"[",
"$",
"input",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid file'",
",",
"400",
")",
";",
"}",
"// Return the file info",
"return",
"$",
"_FILES",
"[",
"$",
"input",
"]",
";",
"}"
]
| Gets a request file
@param string $input Input key
@return mixed File info, or false | [
"Gets",
"a",
"request",
"file"
]
| d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Http/Request.php#L184-L193 | train |
nicodevs/laito | src/Laito/Http/Request.php | Request.storeFile | public function storeFile($input = null, $target)
{
// The input name and target path must be defined
if (!isset($input) || !isset($target)) {
throw new \InvalidArgumentException('Undefined input name or target', 400);
}
// Move the uploaded file
$result = move_uploaded_file($_FILES[$input]['tmp_name'], $target);
// Check if the file was stored
if (!$result) {
throw new \InvalidArgumentException('The file could not be stored', 500);
}
// Return the file info
return $result;
} | php | public function storeFile($input = null, $target)
{
// The input name and target path must be defined
if (!isset($input) || !isset($target)) {
throw new \InvalidArgumentException('Undefined input name or target', 400);
}
// Move the uploaded file
$result = move_uploaded_file($_FILES[$input]['tmp_name'], $target);
// Check if the file was stored
if (!$result) {
throw new \InvalidArgumentException('The file could not be stored', 500);
}
// Return the file info
return $result;
} | [
"public",
"function",
"storeFile",
"(",
"$",
"input",
"=",
"null",
",",
"$",
"target",
")",
"{",
"// The input name and target path must be defined",
"if",
"(",
"!",
"isset",
"(",
"$",
"input",
")",
"||",
"!",
"isset",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Undefined input name or target'",
",",
"400",
")",
";",
"}",
"// Move the uploaded file",
"$",
"result",
"=",
"move_uploaded_file",
"(",
"$",
"_FILES",
"[",
"$",
"input",
"]",
"[",
"'tmp_name'",
"]",
",",
"$",
"target",
")",
";",
"// Check if the file was stored",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The file could not be stored'",
",",
"500",
")",
";",
"}",
"// Return the file info",
"return",
"$",
"result",
";",
"}"
]
| Stores a request file
@param string $input Input key
@param string $target Target path
@return boolean Success or fail of the store operation | [
"Stores",
"a",
"request",
"file"
]
| d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Http/Request.php#L220-L237 | train |
nicodevs/laito | src/Laito/Http/Request.php | Request.getInputs | private function getInputs()
{
// If defined, return the inputs array
if ($this->inputs) {
return $this->inputs;
}
// Check for JSON data
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) {
$input = file_get_contents('php://input');
$decoded = json_decode($input, true);
if ($decoded) {
$this->inputs = $decoded;
return $this->inputs;
}
}
// Check by request method
switch ($_SERVER['REQUEST_METHOD']) {
// Get PUT inputs
case 'PUT':
parse_str(file_get_contents("php://input"), $this->inputs);
break;
// Get POST inputs
case 'POST':
$this->inputs = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
break;
// Get GET inputs
default:
$this->inputs = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
break;
}
// Return array of inputs
return $this->inputs ? : [];
} | php | private function getInputs()
{
// If defined, return the inputs array
if ($this->inputs) {
return $this->inputs;
}
// Check for JSON data
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) {
$input = file_get_contents('php://input');
$decoded = json_decode($input, true);
if ($decoded) {
$this->inputs = $decoded;
return $this->inputs;
}
}
// Check by request method
switch ($_SERVER['REQUEST_METHOD']) {
// Get PUT inputs
case 'PUT':
parse_str(file_get_contents("php://input"), $this->inputs);
break;
// Get POST inputs
case 'POST':
$this->inputs = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
break;
// Get GET inputs
default:
$this->inputs = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
break;
}
// Return array of inputs
return $this->inputs ? : [];
} | [
"private",
"function",
"getInputs",
"(",
")",
"{",
"// If defined, return the inputs array",
"if",
"(",
"$",
"this",
"->",
"inputs",
")",
"{",
"return",
"$",
"this",
"->",
"inputs",
";",
"}",
"// Check for JSON data",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'CONTENT_TYPE'",
"]",
")",
"&&",
"strpos",
"(",
"$",
"_SERVER",
"[",
"'CONTENT_TYPE'",
"]",
",",
"'application/json'",
")",
"===",
"0",
")",
"{",
"$",
"input",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"input",
",",
"true",
")",
";",
"if",
"(",
"$",
"decoded",
")",
"{",
"$",
"this",
"->",
"inputs",
"=",
"$",
"decoded",
";",
"return",
"$",
"this",
"->",
"inputs",
";",
"}",
"}",
"// Check by request method",
"switch",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
"{",
"// Get PUT inputs",
"case",
"'PUT'",
":",
"parse_str",
"(",
"file_get_contents",
"(",
"\"php://input\"",
")",
",",
"$",
"this",
"->",
"inputs",
")",
";",
"break",
";",
"// Get POST inputs",
"case",
"'POST'",
":",
"$",
"this",
"->",
"inputs",
"=",
"filter_input_array",
"(",
"INPUT_POST",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"break",
";",
"// Get GET inputs",
"default",
":",
"$",
"this",
"->",
"inputs",
"=",
"filter_input_array",
"(",
"INPUT_GET",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"break",
";",
"}",
"// Return array of inputs",
"return",
"$",
"this",
"->",
"inputs",
"?",
":",
"[",
"]",
";",
"}"
]
| Stores the parameters from the request in the inputs array
@return array Array of inputs | [
"Stores",
"the",
"parameters",
"from",
"the",
"request",
"in",
"the",
"inputs",
"array"
]
| d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Http/Request.php#L244-L282 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Client/Command.php | Command.getSdkCommand | public function getSdkCommand($parameters = [])
{
return $this->injectMiddleware(
$this->dm->getClient()->getCommand(
static::$sdkName,
array_merge($this->parameters, $parameters)
)
);
} | php | public function getSdkCommand($parameters = [])
{
return $this->injectMiddleware(
$this->dm->getClient()->getCommand(
static::$sdkName,
array_merge($this->parameters, $parameters)
)
);
} | [
"public",
"function",
"getSdkCommand",
"(",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"injectMiddleware",
"(",
"$",
"this",
"->",
"dm",
"->",
"getClient",
"(",
")",
"->",
"getCommand",
"(",
"static",
"::",
"$",
"sdkName",
",",
"array_merge",
"(",
"$",
"this",
"->",
"parameters",
",",
"$",
"parameters",
")",
")",
")",
";",
"}"
]
| Return the prepared AWS SDK Command object to be executed.
@param array $parameters Additional parameters to add to the Command object
before returning. Any existing parameters with the
same name will be overridden.
@return \Aws\CommandInterface | [
"Return",
"the",
"prepared",
"AWS",
"SDK",
"Command",
"object",
"to",
"be",
"executed",
"."
]
| 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Client/Command.php#L124-L132 | train |
praxigento/mobi_mod_downline | Service/Customer/Add.php | Add.getReferredParentId | private function getReferredParentId($customerId)
{
/* use customer ID as parent ID if parent ID cannot be defined */
$result = $customerId;
$area = $this->state->getAreaCode();
if ($area == \Magento\Framework\App\Area::AREA_ADMINHTML) {
/* use default MLM ID from config */
$defRootMlmId = $this->hlpConfig->getReferralsRootAnonymous();
$parent = $this->daoDwnlCust->getByMlmId($defRootMlmId);
if ($parent) {
$result = $parent->getCustomerRef();
$this->logger->info("Default root parent #$result is used for customer #$customerId (admin mode).");
}
} else {
/* try to extract referral code from Mage registry */
$code = $this->hlpReferral->getReferralCode();
if ($code) {
/* this is a referral customer, use parent from referral code */
$parent = $this->daoDwnlCust->getByReferralCode($code);
if ($parent) {
$result = $parent->getCustomerRef();
$this->logger->info("Referral parent #$result is used for customer #$customerId.");
}
} else {
/* this is anonymous customer, use parent from config */
$anonRootMlmId = $this->hlpConfig->getReferralsRootAnonymous();
$parent = $this->daoDwnlCust->getByMlmId($anonRootMlmId);
if ($parent) {
$result = $parent->getCustomerRef();
$this->logger->info("Anonymous root parent #$result is used for customer #$customerId.");
}
}
}
return $result;
} | php | private function getReferredParentId($customerId)
{
/* use customer ID as parent ID if parent ID cannot be defined */
$result = $customerId;
$area = $this->state->getAreaCode();
if ($area == \Magento\Framework\App\Area::AREA_ADMINHTML) {
/* use default MLM ID from config */
$defRootMlmId = $this->hlpConfig->getReferralsRootAnonymous();
$parent = $this->daoDwnlCust->getByMlmId($defRootMlmId);
if ($parent) {
$result = $parent->getCustomerRef();
$this->logger->info("Default root parent #$result is used for customer #$customerId (admin mode).");
}
} else {
/* try to extract referral code from Mage registry */
$code = $this->hlpReferral->getReferralCode();
if ($code) {
/* this is a referral customer, use parent from referral code */
$parent = $this->daoDwnlCust->getByReferralCode($code);
if ($parent) {
$result = $parent->getCustomerRef();
$this->logger->info("Referral parent #$result is used for customer #$customerId.");
}
} else {
/* this is anonymous customer, use parent from config */
$anonRootMlmId = $this->hlpConfig->getReferralsRootAnonymous();
$parent = $this->daoDwnlCust->getByMlmId($anonRootMlmId);
if ($parent) {
$result = $parent->getCustomerRef();
$this->logger->info("Anonymous root parent #$result is used for customer #$customerId.");
}
}
}
return $result;
} | [
"private",
"function",
"getReferredParentId",
"(",
"$",
"customerId",
")",
"{",
"/* use customer ID as parent ID if parent ID cannot be defined */",
"$",
"result",
"=",
"$",
"customerId",
";",
"$",
"area",
"=",
"$",
"this",
"->",
"state",
"->",
"getAreaCode",
"(",
")",
";",
"if",
"(",
"$",
"area",
"==",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"App",
"\\",
"Area",
"::",
"AREA_ADMINHTML",
")",
"{",
"/* use default MLM ID from config */",
"$",
"defRootMlmId",
"=",
"$",
"this",
"->",
"hlpConfig",
"->",
"getReferralsRootAnonymous",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"daoDwnlCust",
"->",
"getByMlmId",
"(",
"$",
"defRootMlmId",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"result",
"=",
"$",
"parent",
"->",
"getCustomerRef",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Default root parent #$result is used for customer #$customerId (admin mode).\"",
")",
";",
"}",
"}",
"else",
"{",
"/* try to extract referral code from Mage registry */",
"$",
"code",
"=",
"$",
"this",
"->",
"hlpReferral",
"->",
"getReferralCode",
"(",
")",
";",
"if",
"(",
"$",
"code",
")",
"{",
"/* this is a referral customer, use parent from referral code */",
"$",
"parent",
"=",
"$",
"this",
"->",
"daoDwnlCust",
"->",
"getByReferralCode",
"(",
"$",
"code",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"result",
"=",
"$",
"parent",
"->",
"getCustomerRef",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Referral parent #$result is used for customer #$customerId.\"",
")",
";",
"}",
"}",
"else",
"{",
"/* this is anonymous customer, use parent from config */",
"$",
"anonRootMlmId",
"=",
"$",
"this",
"->",
"hlpConfig",
"->",
"getReferralsRootAnonymous",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"daoDwnlCust",
"->",
"getByMlmId",
"(",
"$",
"anonRootMlmId",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"result",
"=",
"$",
"parent",
"->",
"getCustomerRef",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Anonymous root parent #$result is used for customer #$customerId.\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Analyze referral code and get parent for the customer if parent ID was missed in request.
@param int $customerId
@return int
@throws \Magento\Framework\Exception\LocalizedException | [
"Analyze",
"referral",
"code",
"and",
"get",
"parent",
"for",
"the",
"customer",
"if",
"parent",
"ID",
"was",
"missed",
"in",
"request",
"."
]
| 0f3c276dfff1aa029f9fd205ccfc56f207a2e75b | https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Service/Customer/Add.php#L123-L157 | train |
koolkode/context | src/Bind/ContainerBuilder.php | ContainerBuilder.getParameter | public function getParameter($name)
{
if(array_key_exists($name, $this->parameters))
{
return $this->parameters[$name];
}
if(func_num_args() > 1)
{
return func_get_arg(1);
}
throw new ContextParamNotFoundException(sprintf('Container parameter "%s" was not found', $name));
} | php | public function getParameter($name)
{
if(array_key_exists($name, $this->parameters))
{
return $this->parameters[$name];
}
if(func_num_args() > 1)
{
return func_get_arg(1);
}
throw new ContextParamNotFoundException(sprintf('Container parameter "%s" was not found', $name));
} | [
"public",
"function",
"getParameter",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"parameters",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parameters",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"return",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"throw",
"new",
"ContextParamNotFoundException",
"(",
"sprintf",
"(",
"'Container parameter \"%s\" was not found'",
",",
"$",
"name",
")",
")",
";",
"}"
]
| Get the value of the given parameter.
@param string $name
@param mixed $default
@return mixed
@throws ContextParamNotFoundException When the parameter has not been registered and no default value is given. | [
"Get",
"the",
"value",
"of",
"the",
"given",
"parameter",
"."
]
| f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Bind/ContainerBuilder.php#L93-L106 | train |
koolkode/context | src/Bind/ContainerBuilder.php | ContainerBuilder.bind | public function bind($typeName)
{
if($this->proxyTypes !== NULL)
{
$this->proxyTypes = NULL;
}
$key = strtolower($typeName);
switch($key)
{
case 'koolkode\config\configuration':
case 'koolkode\context\containerinterface':
case 'koolkode\context\exposedcontainerinterface':
case 'koolkode\context\scope\scopedcontainerinterface':
throw new \InvalidArgumentException(sprintf('Binding %s is forbidden', $typeName));
}
if(isset($this->bindings[$key]))
{
return $this->bindings[$key];
}
return $this->bindings[$key] = new Binding($typeName);
} | php | public function bind($typeName)
{
if($this->proxyTypes !== NULL)
{
$this->proxyTypes = NULL;
}
$key = strtolower($typeName);
switch($key)
{
case 'koolkode\config\configuration':
case 'koolkode\context\containerinterface':
case 'koolkode\context\exposedcontainerinterface':
case 'koolkode\context\scope\scopedcontainerinterface':
throw new \InvalidArgumentException(sprintf('Binding %s is forbidden', $typeName));
}
if(isset($this->bindings[$key]))
{
return $this->bindings[$key];
}
return $this->bindings[$key] = new Binding($typeName);
} | [
"public",
"function",
"bind",
"(",
"$",
"typeName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyTypes",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"proxyTypes",
"=",
"NULL",
";",
"}",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"typeName",
")",
";",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'koolkode\\config\\configuration'",
":",
"case",
"'koolkode\\context\\containerinterface'",
":",
"case",
"'koolkode\\context\\exposedcontainerinterface'",
":",
"case",
"'koolkode\\context\\scope\\scopedcontainerinterface'",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Binding %s is forbidden'",
",",
"$",
"typeName",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"bindings",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"bindings",
"[",
"$",
"key",
"]",
"=",
"new",
"Binding",
"(",
"$",
"typeName",
")",
";",
"}"
]
| Create a binding for the given type, the binding is registered in the builder
and will be bound by the created DI container, binding multiple times to the same type
will modify the existing binding instead of creating a new binding!
@return Binding | [
"Create",
"a",
"binding",
"for",
"the",
"given",
"type",
"the",
"binding",
"is",
"registered",
"in",
"the",
"builder",
"and",
"will",
"be",
"bound",
"by",
"the",
"created",
"DI",
"container",
"binding",
"multiple",
"times",
"to",
"the",
"same",
"type",
"will",
"modify",
"the",
"existing",
"binding",
"instead",
"of",
"creating",
"a",
"new",
"binding!"
]
| f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Bind/ContainerBuilder.php#L163-L187 | train |
koolkode/context | src/Bind/ContainerBuilder.php | ContainerBuilder.getProxyBindings | public function getProxyBindings()
{
if($this->proxyTypes === NULL)
{
$this->proxyTypes = [];
foreach($this->bindings as $binding)
{
$scope = $binding->getScope();
if($scope === NULL)
{
continue;
}
if(Singleton::class == $scope)
{
continue;
}
$this->proxyTypes[strtolower($binding->getTypeName())] = $binding;
}
}
return $this->proxyTypes;
} | php | public function getProxyBindings()
{
if($this->proxyTypes === NULL)
{
$this->proxyTypes = [];
foreach($this->bindings as $binding)
{
$scope = $binding->getScope();
if($scope === NULL)
{
continue;
}
if(Singleton::class == $scope)
{
continue;
}
$this->proxyTypes[strtolower($binding->getTypeName())] = $binding;
}
}
return $this->proxyTypes;
} | [
"public",
"function",
"getProxyBindings",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyTypes",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"proxyTypes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"bindings",
"as",
"$",
"binding",
")",
"{",
"$",
"scope",
"=",
"$",
"binding",
"->",
"getScope",
"(",
")",
";",
"if",
"(",
"$",
"scope",
"===",
"NULL",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"Singleton",
"::",
"class",
"==",
"$",
"scope",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"proxyTypes",
"[",
"strtolower",
"(",
"$",
"binding",
"->",
"getTypeName",
"(",
")",
")",
"]",
"=",
"$",
"binding",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"proxyTypes",
";",
"}"
]
| Get all bindings that require a scope proxy.
@return \array<string, BindingInterface> | [
"Get",
"all",
"bindings",
"that",
"require",
"a",
"scope",
"proxy",
"."
]
| f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Bind/ContainerBuilder.php#L215-L240 | train |
asaokamei/ScoreSql | src/Sql/Sql.php | Sql.subQuery | public function subQuery( $table, $alias=null )
{
$sub = new self();
if( !$alias ) $alias = 'sub_' . $this->subQueryCount ++;
$sub->table( $table, $alias );
$sub->setParentTable( $this->getAliasOrTable() );
return $sub;
} | php | public function subQuery( $table, $alias=null )
{
$sub = new self();
if( !$alias ) $alias = 'sub_' . $this->subQueryCount ++;
$sub->table( $table, $alias );
$sub->setParentTable( $this->getAliasOrTable() );
return $sub;
} | [
"public",
"function",
"subQuery",
"(",
"$",
"table",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"sub",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"!",
"$",
"alias",
")",
"$",
"alias",
"=",
"'sub_'",
".",
"$",
"this",
"->",
"subQueryCount",
"++",
";",
"$",
"sub",
"->",
"table",
"(",
"$",
"table",
",",
"$",
"alias",
")",
";",
"$",
"sub",
"->",
"setParentTable",
"(",
"$",
"this",
"->",
"getAliasOrTable",
"(",
")",
")",
";",
"return",
"$",
"sub",
";",
"}"
]
| return a new Sql|Query object as sub-query.
@param string $table
@param string $alias
@return $this | [
"return",
"a",
"new",
"Sql|Query",
"object",
"as",
"sub",
"-",
"query",
"."
]
| f1fce28476629e98b3c4c1216859c7f5309de7a1 | https://github.com/asaokamei/ScoreSql/blob/f1fce28476629e98b3c4c1216859c7f5309de7a1/src/Sql/Sql.php#L160-L167 | train |
asaokamei/ScoreSql | src/Sql/Sql.php | Sql.value | public function value( $name, $value = null )
{
if ( is_array( $name ) ) {
$this->values += $name;
} elseif ( func_num_args() > 1 ) {
$this->values[ $name ] = $value;
}
return $this;
} | php | public function value( $name, $value = null )
{
if ( is_array( $name ) ) {
$this->values += $name;
} elseif ( func_num_args() > 1 ) {
$this->values[ $name ] = $value;
}
return $this;
} | [
"public",
"function",
"value",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"values",
"+=",
"$",
"name",
";",
"}",
"elseif",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| set values for insert or update.
@param string|array $name
@param string|null $value
@return $this | [
"set",
"values",
"for",
"insert",
"or",
"update",
"."
]
| f1fce28476629e98b3c4c1216859c7f5309de7a1 | https://github.com/asaokamei/ScoreSql/blob/f1fce28476629e98b3c4c1216859c7f5309de7a1/src/Sql/Sql.php#L348-L356 | train |
geniv/nette-identity-authorizator | src/AuthorizatorTrait.php | AuthorizatorTrait.handleAddAcl | public function handleAddAcl(string $role, string $resource = null, string $privilege = null)
{
$idRole = $this->identityAuthorizator->getIdRoleByName($role);
$idResource = null;
if ($resource) {
$idResource = $this->identityAuthorizator->getIdResourceByName($resource);
}
$idPrivilege = null;
if ($privilege) {
$idPrivilege = $this->identityAuthorizator->getIdPrivilegeByName($privilege);
if (!$idPrivilege) {
$this->identityAuthorizator->savePrivilege(['id' => null, 'privilege' => $privilege]);
$idPrivilege = $this->identityAuthorizator->getIdPrivilegeByName($privilege);
}
} else {
$idPrivilege = 'all';
}
if ($idResource && $idPrivilege) {
// save acl by one
if ($this->identityAuthorizator->saveAcl($idRole, [$idResource => [$idPrivilege]], false)) {
$this->flashMessage('Save ACL');
}
}
$this->redirect('this');
} | php | public function handleAddAcl(string $role, string $resource = null, string $privilege = null)
{
$idRole = $this->identityAuthorizator->getIdRoleByName($role);
$idResource = null;
if ($resource) {
$idResource = $this->identityAuthorizator->getIdResourceByName($resource);
}
$idPrivilege = null;
if ($privilege) {
$idPrivilege = $this->identityAuthorizator->getIdPrivilegeByName($privilege);
if (!$idPrivilege) {
$this->identityAuthorizator->savePrivilege(['id' => null, 'privilege' => $privilege]);
$idPrivilege = $this->identityAuthorizator->getIdPrivilegeByName($privilege);
}
} else {
$idPrivilege = 'all';
}
if ($idResource && $idPrivilege) {
// save acl by one
if ($this->identityAuthorizator->saveAcl($idRole, [$idResource => [$idPrivilege]], false)) {
$this->flashMessage('Save ACL');
}
}
$this->redirect('this');
} | [
"public",
"function",
"handleAddAcl",
"(",
"string",
"$",
"role",
",",
"string",
"$",
"resource",
"=",
"null",
",",
"string",
"$",
"privilege",
"=",
"null",
")",
"{",
"$",
"idRole",
"=",
"$",
"this",
"->",
"identityAuthorizator",
"->",
"getIdRoleByName",
"(",
"$",
"role",
")",
";",
"$",
"idResource",
"=",
"null",
";",
"if",
"(",
"$",
"resource",
")",
"{",
"$",
"idResource",
"=",
"$",
"this",
"->",
"identityAuthorizator",
"->",
"getIdResourceByName",
"(",
"$",
"resource",
")",
";",
"}",
"$",
"idPrivilege",
"=",
"null",
";",
"if",
"(",
"$",
"privilege",
")",
"{",
"$",
"idPrivilege",
"=",
"$",
"this",
"->",
"identityAuthorizator",
"->",
"getIdPrivilegeByName",
"(",
"$",
"privilege",
")",
";",
"if",
"(",
"!",
"$",
"idPrivilege",
")",
"{",
"$",
"this",
"->",
"identityAuthorizator",
"->",
"savePrivilege",
"(",
"[",
"'id'",
"=>",
"null",
",",
"'privilege'",
"=>",
"$",
"privilege",
"]",
")",
";",
"$",
"idPrivilege",
"=",
"$",
"this",
"->",
"identityAuthorizator",
"->",
"getIdPrivilegeByName",
"(",
"$",
"privilege",
")",
";",
"}",
"}",
"else",
"{",
"$",
"idPrivilege",
"=",
"'all'",
";",
"}",
"if",
"(",
"$",
"idResource",
"&&",
"$",
"idPrivilege",
")",
"{",
"// save acl by one",
"if",
"(",
"$",
"this",
"->",
"identityAuthorizator",
"->",
"saveAcl",
"(",
"$",
"idRole",
",",
"[",
"$",
"idResource",
"=>",
"[",
"$",
"idPrivilege",
"]",
"]",
",",
"false",
")",
")",
"{",
"$",
"this",
"->",
"flashMessage",
"(",
"'Save ACL'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"redirect",
"(",
"'this'",
")",
";",
"}"
]
| Handle add acl.
@param string $role
@param string|null $resource
@param string|null $privilege | [
"Handle",
"add",
"acl",
"."
]
| f7db1cd589d022b6443f24a59432098a343d4639 | https://github.com/geniv/nette-identity-authorizator/blob/f7db1cd589d022b6443f24a59432098a343d4639/src/AuthorizatorTrait.php#L25-L52 | train |
ARCANESOFT/Blog | src/Entities/PostStatus.php | PostStatus.all | public static function all($locale = null)
{
return static::keys()->mapWithKeys(function ($key) use ($locale) {
return [$key => trans("blog::posts.statuses.{$key}", [], $locale)];
});
} | php | public static function all($locale = null)
{
return static::keys()->mapWithKeys(function ($key) use ($locale) {
return [$key => trans("blog::posts.statuses.{$key}", [], $locale)];
});
} | [
"public",
"static",
"function",
"all",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"keys",
"(",
")",
"->",
"mapWithKeys",
"(",
"function",
"(",
"$",
"key",
")",
"use",
"(",
"$",
"locale",
")",
"{",
"return",
"[",
"$",
"key",
"=>",
"trans",
"(",
"\"blog::posts.statuses.{$key}\"",
",",
"[",
"]",
",",
"$",
"locale",
")",
"]",
";",
"}",
")",
";",
"}"
]
| Get all posts status
@param string|null $locale
@return \Illuminate\Support\Collection | [
"Get",
"all",
"posts",
"status"
]
| 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Entities/PostStatus.php#L46-L51 | train |
ARCANESOFT/Blog | src/Entities/PostStatus.php | PostStatus.get | public static function get($key, $default = null, $locale = null)
{
return self::all($locale)->get($key, $default);
} | php | public static function get($key, $default = null, $locale = null)
{
return self::all($locale)->get($key, $default);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"all",
"(",
"$",
"locale",
")",
"->",
"get",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"}"
]
| Get a post status.
@param string $key
@param mixed $default
@param string|null $locale
@return string|null | [
"Get",
"a",
"post",
"status",
"."
]
| 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Entities/PostStatus.php#L62-L65 | train |
ekyna/MediaBundle | Twig/PlayerExtension.php | PlayerExtension.renderMedia | public function renderMedia(MediaInterface $media, array $params = [])
{
switch ($media->getType()) {
case MediaTypes::VIDEO :
return $this->renderVideo($media, $params);
case MediaTypes::FLASH :
return $this->renderFlash($media, $params);
case MediaTypes::AUDIO :
return $this->renderAudio($media, $params);
case MediaTypes::IMAGE :
return $this->renderImage($media, $params);
default:
return $this->renderFile($media, $params);
}
} | php | public function renderMedia(MediaInterface $media, array $params = [])
{
switch ($media->getType()) {
case MediaTypes::VIDEO :
return $this->renderVideo($media, $params);
case MediaTypes::FLASH :
return $this->renderFlash($media, $params);
case MediaTypes::AUDIO :
return $this->renderAudio($media, $params);
case MediaTypes::IMAGE :
return $this->renderImage($media, $params);
default:
return $this->renderFile($media, $params);
}
} | [
"public",
"function",
"renderMedia",
"(",
"MediaInterface",
"$",
"media",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"switch",
"(",
"$",
"media",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"MediaTypes",
"::",
"VIDEO",
":",
"return",
"$",
"this",
"->",
"renderVideo",
"(",
"$",
"media",
",",
"$",
"params",
")",
";",
"case",
"MediaTypes",
"::",
"FLASH",
":",
"return",
"$",
"this",
"->",
"renderFlash",
"(",
"$",
"media",
",",
"$",
"params",
")",
";",
"case",
"MediaTypes",
"::",
"AUDIO",
":",
"return",
"$",
"this",
"->",
"renderAudio",
"(",
"$",
"media",
",",
"$",
"params",
")",
";",
"case",
"MediaTypes",
"::",
"IMAGE",
":",
"return",
"$",
"this",
"->",
"renderImage",
"(",
"$",
"media",
",",
"$",
"params",
")",
";",
"default",
":",
"return",
"$",
"this",
"->",
"renderFile",
"(",
"$",
"media",
",",
"$",
"params",
")",
";",
"}",
"}"
]
| Renders the media.
@param MediaInterface $media
@param array $params
@return string
@throws \InvalidArgumentException | [
"Renders",
"the",
"media",
"."
]
| 512cf86c801a130a9f17eba8b48d646d23acdbab | https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Twig/PlayerExtension.php#L87-L101 | train |
ekyna/MediaBundle | Twig/PlayerExtension.php | PlayerExtension.renderVideo | public function renderVideo(MediaInterface $video, array $params = [])
{
if ($video->getType() !== MediaTypes::VIDEO) {
throw new \InvalidArgumentException('Expected media with "video" type.');
}
$params = array_merge([
'responsive' => false,
'aspect_ratio' => '16by9',
'attr' => [
'id' => 'media-video-' . $video->getId(),
'class' => 'video-js vjs-default-skin vjs-big-play-centered',
'height' => '100%',
'width' => '100%',
],
], $params);
return $this->elementTemplate->renderBlock('video', [
'responsive' => $params['responsive'],
'aspect_ratio' => $params['aspect_ratio'],
'src' => $this->getDownloadUrl($video),
'mime_type' => $this->getMimeType($video),
'attr' => $params['attr'],
]);
} | php | public function renderVideo(MediaInterface $video, array $params = [])
{
if ($video->getType() !== MediaTypes::VIDEO) {
throw new \InvalidArgumentException('Expected media with "video" type.');
}
$params = array_merge([
'responsive' => false,
'aspect_ratio' => '16by9',
'attr' => [
'id' => 'media-video-' . $video->getId(),
'class' => 'video-js vjs-default-skin vjs-big-play-centered',
'height' => '100%',
'width' => '100%',
],
], $params);
return $this->elementTemplate->renderBlock('video', [
'responsive' => $params['responsive'],
'aspect_ratio' => $params['aspect_ratio'],
'src' => $this->getDownloadUrl($video),
'mime_type' => $this->getMimeType($video),
'attr' => $params['attr'],
]);
} | [
"public",
"function",
"renderVideo",
"(",
"MediaInterface",
"$",
"video",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"video",
"->",
"getType",
"(",
")",
"!==",
"MediaTypes",
"::",
"VIDEO",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected media with \"video\" type.'",
")",
";",
"}",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"'responsive'",
"=>",
"false",
",",
"'aspect_ratio'",
"=>",
"'16by9'",
",",
"'attr'",
"=>",
"[",
"'id'",
"=>",
"'media-video-'",
".",
"$",
"video",
"->",
"getId",
"(",
")",
",",
"'class'",
"=>",
"'video-js vjs-default-skin vjs-big-play-centered'",
",",
"'height'",
"=>",
"'100%'",
",",
"'width'",
"=>",
"'100%'",
",",
"]",
",",
"]",
",",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"elementTemplate",
"->",
"renderBlock",
"(",
"'video'",
",",
"[",
"'responsive'",
"=>",
"$",
"params",
"[",
"'responsive'",
"]",
",",
"'aspect_ratio'",
"=>",
"$",
"params",
"[",
"'aspect_ratio'",
"]",
",",
"'src'",
"=>",
"$",
"this",
"->",
"getDownloadUrl",
"(",
"$",
"video",
")",
",",
"'mime_type'",
"=>",
"$",
"this",
"->",
"getMimeType",
"(",
"$",
"video",
")",
",",
"'attr'",
"=>",
"$",
"params",
"[",
"'attr'",
"]",
",",
"]",
")",
";",
"}"
]
| Renders the video.
@param MediaInterface $video
@param array $params
@return string
@throws \InvalidArgumentException | [
"Renders",
"the",
"video",
"."
]
| 512cf86c801a130a9f17eba8b48d646d23acdbab | https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Twig/PlayerExtension.php#L111-L135 | train |
ekyna/MediaBundle | Twig/PlayerExtension.php | PlayerExtension.renderFlash | public function renderFlash(MediaInterface $flash, array $params = [])
{
if ($flash->getType() !== MediaTypes::FLASH) {
throw new \InvalidArgumentException('Expected media with "flash" type.');
}
$params = array_merge([
//'responsive' => false,
'attr' => [
'id' => 'media-flash-' . $flash->getId(),
'class' => 'swf-object',
//'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
'height' => '100%',
'width' => '100%',
],
], $params);
return $this->elementTemplate->renderBlock('flash', [
'src' => $this->getDownloadUrl($flash),
'attr' => $params['attr'],
]);
} | php | public function renderFlash(MediaInterface $flash, array $params = [])
{
if ($flash->getType() !== MediaTypes::FLASH) {
throw new \InvalidArgumentException('Expected media with "flash" type.');
}
$params = array_merge([
//'responsive' => false,
'attr' => [
'id' => 'media-flash-' . $flash->getId(),
'class' => 'swf-object',
//'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
'height' => '100%',
'width' => '100%',
],
], $params);
return $this->elementTemplate->renderBlock('flash', [
'src' => $this->getDownloadUrl($flash),
'attr' => $params['attr'],
]);
} | [
"public",
"function",
"renderFlash",
"(",
"MediaInterface",
"$",
"flash",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"flash",
"->",
"getType",
"(",
")",
"!==",
"MediaTypes",
"::",
"FLASH",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected media with \"flash\" type.'",
")",
";",
"}",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"//'responsive' => false,",
"'attr'",
"=>",
"[",
"'id'",
"=>",
"'media-flash-'",
".",
"$",
"flash",
"->",
"getId",
"(",
")",
",",
"'class'",
"=>",
"'swf-object'",
",",
"//'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',",
"'height'",
"=>",
"'100%'",
",",
"'width'",
"=>",
"'100%'",
",",
"]",
",",
"]",
",",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"elementTemplate",
"->",
"renderBlock",
"(",
"'flash'",
",",
"[",
"'src'",
"=>",
"$",
"this",
"->",
"getDownloadUrl",
"(",
"$",
"flash",
")",
",",
"'attr'",
"=>",
"$",
"params",
"[",
"'attr'",
"]",
",",
"]",
")",
";",
"}"
]
| Renders the flash swf.
@param MediaInterface $flash
@param array $params
@return string
@throws \InvalidArgumentException | [
"Renders",
"the",
"flash",
"swf",
"."
]
| 512cf86c801a130a9f17eba8b48d646d23acdbab | https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Twig/PlayerExtension.php#L145-L166 | train |
ekyna/MediaBundle | Twig/PlayerExtension.php | PlayerExtension.renderAudio | public function renderAudio(MediaInterface $audio, array $params = [])
{
if ($audio->getType() !== MediaTypes::AUDIO) {
throw new \InvalidArgumentException('Expected media with "audio" type.');
}
$params = array_merge([
'attr' => [
'id' => 'media-audio-' . $audio->getId(),
],
], $params);
return $this->elementTemplate->renderBlock('audio', [
'src' => $this->getDownloadUrl($audio),
'attr' => $params['attr'],
]);
} | php | public function renderAudio(MediaInterface $audio, array $params = [])
{
if ($audio->getType() !== MediaTypes::AUDIO) {
throw new \InvalidArgumentException('Expected media with "audio" type.');
}
$params = array_merge([
'attr' => [
'id' => 'media-audio-' . $audio->getId(),
],
], $params);
return $this->elementTemplate->renderBlock('audio', [
'src' => $this->getDownloadUrl($audio),
'attr' => $params['attr'],
]);
} | [
"public",
"function",
"renderAudio",
"(",
"MediaInterface",
"$",
"audio",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"audio",
"->",
"getType",
"(",
")",
"!==",
"MediaTypes",
"::",
"AUDIO",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected media with \"audio\" type.'",
")",
";",
"}",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"'attr'",
"=>",
"[",
"'id'",
"=>",
"'media-audio-'",
".",
"$",
"audio",
"->",
"getId",
"(",
")",
",",
"]",
",",
"]",
",",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"elementTemplate",
"->",
"renderBlock",
"(",
"'audio'",
",",
"[",
"'src'",
"=>",
"$",
"this",
"->",
"getDownloadUrl",
"(",
"$",
"audio",
")",
",",
"'attr'",
"=>",
"$",
"params",
"[",
"'attr'",
"]",
",",
"]",
")",
";",
"}"
]
| Renders the audio.
@param MediaInterface $audio
@param array $params
@return string
@throws \InvalidArgumentException | [
"Renders",
"the",
"audio",
"."
]
| 512cf86c801a130a9f17eba8b48d646d23acdbab | https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Twig/PlayerExtension.php#L176-L192 | train |
bseddon/XPath20 | XPath2NodeIterator.php | XPath2NodeIterator.getIsSingleIterator | public function getIsSingleIterator()
{
/**
* @var XPath2NodeIterator $iter
*/
$iter = $this->CloneInstance();
// $iter->named = "Original";
$part1 = $iter->MoveNext();
if ( $part1 )
{
$part2 = ! $iter->MoveNext();
if ( $part2 ) return true;
}
return false;
} | php | public function getIsSingleIterator()
{
/**
* @var XPath2NodeIterator $iter
*/
$iter = $this->CloneInstance();
// $iter->named = "Original";
$part1 = $iter->MoveNext();
if ( $part1 )
{
$part2 = ! $iter->MoveNext();
if ( $part2 ) return true;
}
return false;
} | [
"public",
"function",
"getIsSingleIterator",
"(",
")",
"{",
"/**\r\n\t\t * @var XPath2NodeIterator $iter\r\n\t\t */",
"$",
"iter",
"=",
"$",
"this",
"->",
"CloneInstance",
"(",
")",
";",
"// $iter->named = \"Original\";\r",
"$",
"part1",
"=",
"$",
"iter",
"->",
"MoveNext",
"(",
")",
";",
"if",
"(",
"$",
"part1",
")",
"{",
"$",
"part2",
"=",
"!",
"$",
"iter",
"->",
"MoveNext",
"(",
")",
";",
"if",
"(",
"$",
"part2",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Check to see if the iterator has just one item
@return bool | [
"Check",
"to",
"see",
"if",
"the",
"iterator",
"has",
"just",
"one",
"item"
]
| 69882b6efffaa5470a819d5fdd2f6473ddeb046d | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/XPath2NodeIterator.php#L160-L175 | train |
Polosa/shade-framework-core | app/App.php | App.init | public function init()
{
if (
!$this->serviceContainer->isRegistered(ServiceContainer::SERVICE_LOGGER)
|| !($this->getLogger() instanceof LoggerInterface)
) {
$this->setService(ServiceContainer::SERVICE_LOGGER, new NullLogger());
}
$this->getControllerDispatcher()->setLogger($this->getLogger());
} | php | public function init()
{
if (
!$this->serviceContainer->isRegistered(ServiceContainer::SERVICE_LOGGER)
|| !($this->getLogger() instanceof LoggerInterface)
) {
$this->setService(ServiceContainer::SERVICE_LOGGER, new NullLogger());
}
$this->getControllerDispatcher()->setLogger($this->getLogger());
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"serviceContainer",
"->",
"isRegistered",
"(",
"ServiceContainer",
"::",
"SERVICE_LOGGER",
")",
"||",
"!",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
"instanceof",
"LoggerInterface",
")",
")",
"{",
"$",
"this",
"->",
"setService",
"(",
"ServiceContainer",
"::",
"SERVICE_LOGGER",
",",
"new",
"NullLogger",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"getControllerDispatcher",
"(",
")",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
";",
"}"
]
| Initialize application before execution | [
"Initialize",
"application",
"before",
"execution"
]
| d735d3e8e0616fb9cf4ffc25b8425762ed07940f | https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/App.php#L111-L120 | train |
Polosa/shade-framework-core | app/App.php | App.run | public function run(Request $request = null)
{
$this->init();
$this->getLogger()->debug('Application launched');
if (!($request instanceof Request)) {
$appMode = $this->detectRunMode();
if ($appMode == self::MODE_WEB) {
$request = Request\Web::makeFromGlobals();
} else {
$request = Request\Cli::makeFromGlobals();
}
}
$this->setupRouter($request);
$response = $this->execute($request);
$this->output($response);
$this->getLogger()->debug('Application execution completed');
} | php | public function run(Request $request = null)
{
$this->init();
$this->getLogger()->debug('Application launched');
if (!($request instanceof Request)) {
$appMode = $this->detectRunMode();
if ($appMode == self::MODE_WEB) {
$request = Request\Web::makeFromGlobals();
} else {
$request = Request\Cli::makeFromGlobals();
}
}
$this->setupRouter($request);
$response = $this->execute($request);
$this->output($response);
$this->getLogger()->debug('Application execution completed');
} | [
"public",
"function",
"run",
"(",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Application launched'",
")",
";",
"if",
"(",
"!",
"(",
"$",
"request",
"instanceof",
"Request",
")",
")",
"{",
"$",
"appMode",
"=",
"$",
"this",
"->",
"detectRunMode",
"(",
")",
";",
"if",
"(",
"$",
"appMode",
"==",
"self",
"::",
"MODE_WEB",
")",
"{",
"$",
"request",
"=",
"Request",
"\\",
"Web",
"::",
"makeFromGlobals",
"(",
")",
";",
"}",
"else",
"{",
"$",
"request",
"=",
"Request",
"\\",
"Cli",
"::",
"makeFromGlobals",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setupRouter",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"output",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Application execution completed'",
")",
";",
"}"
]
| Run Application and output content
@param \Shade\Request|null $request Request
@throws \Shade\Exception | [
"Run",
"Application",
"and",
"output",
"content"
]
| d735d3e8e0616fb9cf4ffc25b8425762ed07940f | https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/App.php#L129-L145 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.