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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mako-framework/framework | src/mako/gatekeeper/entities/user/User.php | User.validatePassword | public function validatePassword(string $password, $autoSave = true): bool
{
$hasher = $this->getHasher();
$isValid = $hasher->verify($password, $this->password);
// Check if the password needs to be rehashed IF the provided password is valid
if($isValid && $hasher->needsRehash($this->password))
{
$this->password = $password;
if($autoSave)
{
$this->save();
}
}
// Return validation result
return $isValid;
} | php | public function validatePassword(string $password, $autoSave = true): bool
{
$hasher = $this->getHasher();
$isValid = $hasher->verify($password, $this->password);
// Check if the password needs to be rehashed IF the provided password is valid
if($isValid && $hasher->needsRehash($this->password))
{
$this->password = $password;
if($autoSave)
{
$this->save();
}
}
// Return validation result
return $isValid;
} | [
"public",
"function",
"validatePassword",
"(",
"string",
"$",
"password",
",",
"$",
"autoSave",
"=",
"true",
")",
":",
"bool",
"{",
"$",
"hasher",
"=",
"$",
"this",
"->",
"getHasher",
"(",
")",
";",
"$",
"isValid",
"=",
"$",
"hasher",
"->",
"verify",
... | Returns true if the provided password is correct and false if not.
@param string $password Privided password
@param bool $autoSave Autosave rehashed password?
@return bool | [
"Returns",
"true",
"if",
"the",
"provided",
"password",
"is",
"correct",
"and",
"false",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/entities/user/User.php#L293-L314 | train |
mako-framework/framework | src/mako/gatekeeper/entities/user/User.php | User.isLocked | public function isLocked(): bool
{
return $this->locked_until !== null && $this->locked_until->getTimestamp() >= Time::now()->getTimestamp();
} | php | public function isLocked(): bool
{
return $this->locked_until !== null && $this->locked_until->getTimestamp() >= Time::now()->getTimestamp();
} | [
"public",
"function",
"isLocked",
"(",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"locked_until",
"!==",
"null",
"&&",
"$",
"this",
"->",
"locked_until",
"->",
"getTimestamp",
"(",
")",
">=",
"Time",
"::",
"now",
"(",
")",
"->",
"getTimestamp",
... | Returns TRUE if the account is locked and FALSE if not.
@return bool | [
"Returns",
"TRUE",
"if",
"the",
"account",
"is",
"locked",
"and",
"FALSE",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/entities/user/User.php#L373-L376 | train |
mako-framework/framework | src/mako/gatekeeper/entities/user/User.php | User.throttle | public function throttle(int $maxLoginAttempts, int $lockTime, bool $autoSave = true): bool
{
$now = Time::now();
// Reset the failed attempt count if the last failed attempt was more than $lockTime seconds ago
if($this->last_fail_at !== null)
{
if(($now->getTimestamp() - $this->last_fail_at->getTimestamp()) > $lockTime)
{
$this->failed_attempts = 0;
}
}
// Increment the failed attempt count and update the last fail time
$this->failed_attempts++;
$this->last_fail_at = $now;
// Lock the account for $lockTime seconds if we have exeeded the maximum number of login attempts
if($this->failed_attempts >= $maxLoginAttempts)
{
$this->locked_until = (clone $now)->forward($lockTime);
}
// Save the changes to the user if autosave is enabled
return $autoSave ? $this->save() : true;
} | php | public function throttle(int $maxLoginAttempts, int $lockTime, bool $autoSave = true): bool
{
$now = Time::now();
// Reset the failed attempt count if the last failed attempt was more than $lockTime seconds ago
if($this->last_fail_at !== null)
{
if(($now->getTimestamp() - $this->last_fail_at->getTimestamp()) > $lockTime)
{
$this->failed_attempts = 0;
}
}
// Increment the failed attempt count and update the last fail time
$this->failed_attempts++;
$this->last_fail_at = $now;
// Lock the account for $lockTime seconds if we have exeeded the maximum number of login attempts
if($this->failed_attempts >= $maxLoginAttempts)
{
$this->locked_until = (clone $now)->forward($lockTime);
}
// Save the changes to the user if autosave is enabled
return $autoSave ? $this->save() : true;
} | [
"public",
"function",
"throttle",
"(",
"int",
"$",
"maxLoginAttempts",
",",
"int",
"$",
"lockTime",
",",
"bool",
"$",
"autoSave",
"=",
"true",
")",
":",
"bool",
"{",
"$",
"now",
"=",
"Time",
"::",
"now",
"(",
")",
";",
"// Reset the failed attempt count if... | Throttles login attempts.
@param int $maxLoginAttempts Maximum number of failed login attempts
@param int $lockTime Number of seconds for which the account gets locked after reaching the maximum number of login attempts
@param bool $autoSave Autosave changes?
@return bool | [
"Throttles",
"login",
"attempts",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/entities/user/User.php#L406-L436 | train |
mako-framework/framework | src/mako/gatekeeper/entities/user/User.php | User.resetThrottle | public function resetThrottle(bool $autoSave = true): bool
{
if($this->failed_attempts > 0)
{
$this->failed_attempts = 0;
$this->last_fail_at = null;
$this->locked_until = null;
return $autoSave ? $this->save() : true;
}
return true;
} | php | public function resetThrottle(bool $autoSave = true): bool
{
if($this->failed_attempts > 0)
{
$this->failed_attempts = 0;
$this->last_fail_at = null;
$this->locked_until = null;
return $autoSave ? $this->save() : true;
}
return true;
} | [
"public",
"function",
"resetThrottle",
"(",
"bool",
"$",
"autoSave",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"failed_attempts",
">",
"0",
")",
"{",
"$",
"this",
"->",
"failed_attempts",
"=",
"0",
";",
"$",
"this",
"->",
"las... | Resets the login throttling.
@param bool $autoSave Autosave changes?
@return bool | [
"Resets",
"the",
"login",
"throttling",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/gatekeeper/entities/user/User.php#L444-L458 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.get_access_token | public function get_access_token() {
if (isset ($this->ll_access_token) && !is_null($this->ll_access_token)) {
return $this->ll_access_token;
}
$app_client_values = array(
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'grant_type' => 'client_credentials'
);
$access_data = MPRestClient::post(array(
"uri" => "/oauth/token",
"data" => $app_client_values,
"headers" => array(
"content-type" => "application/x-www-form-urlencoded"
)
));
if ($access_data["status"] != 200) {
throw new MercadoPagoException ($access_data['response']['message'], $access_data['status']);
}
$this->access_data = $access_data['response'];
return $this->access_data['access_token'];
} | php | public function get_access_token() {
if (isset ($this->ll_access_token) && !is_null($this->ll_access_token)) {
return $this->ll_access_token;
}
$app_client_values = array(
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'grant_type' => 'client_credentials'
);
$access_data = MPRestClient::post(array(
"uri" => "/oauth/token",
"data" => $app_client_values,
"headers" => array(
"content-type" => "application/x-www-form-urlencoded"
)
));
if ($access_data["status"] != 200) {
throw new MercadoPagoException ($access_data['response']['message'], $access_data['status']);
}
$this->access_data = $access_data['response'];
return $this->access_data['access_token'];
} | [
"public",
"function",
"get_access_token",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ll_access_token",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"ll_access_token",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ll_access_token",
"... | Get Access Token for API use | [
"Get",
"Access",
"Token",
"for",
"API",
"use"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L50-L76 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.get_payment | public function get_payment($id) {
$uri_prefix = $this->sandbox ? "/sandbox" : "";
$request = array(
"uri" => "/v1/payments/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$payment_info = MPRestClient::get($request);
return $payment_info;
} | php | public function get_payment($id) {
$uri_prefix = $this->sandbox ? "/sandbox" : "";
$request = array(
"uri" => "/v1/payments/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$payment_info = MPRestClient::get($request);
return $payment_info;
} | [
"public",
"function",
"get_payment",
"(",
"$",
"id",
")",
"{",
"$",
"uri_prefix",
"=",
"$",
"this",
"->",
"sandbox",
"?",
"\"/sandbox\"",
":",
"\"\"",
";",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/v1/payments/{$id}\"",
",",
"\"params\"",
"=>... | Get information for specific payment
@param int $id
@return array(json) | [
"Get",
"information",
"for",
"specific",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L83-L95 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.get_authorized_payment | public function get_authorized_payment($id) {
$request = array(
"uri" => "/authorized_payments/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$authorized_payment_info = MPRestClient::get($request);
return $authorized_payment_info;
} | php | public function get_authorized_payment($id) {
$request = array(
"uri" => "/authorized_payments/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$authorized_payment_info = MPRestClient::get($request);
return $authorized_payment_info;
} | [
"public",
"function",
"get_authorized_payment",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/authorized_payments/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
... | Get information for specific authorized payment
@param id
@return array(json) | [
"Get",
"information",
"for",
"specific",
"authorized",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L105-L115 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.refund_payment | public function refund_payment($id) {
$request = array(
"uri" => "/v1/payments/{$id}/refunds",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$response = MPRestClient::post($request);
return $response;
} | php | public function refund_payment($id) {
$request = array(
"uri" => "/v1/payments/{$id}/refunds",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$response = MPRestClient::post($request);
return $response;
} | [
"public",
"function",
"refund_payment",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/v1/payments/{$id}/refunds\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
"(",
... | Refund accredited payment
@param int $id
@return array(json) | [
"Refund",
"accredited",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L122-L132 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.cancel_payment | public function cancel_payment($id) {
$request = array(
"uri" => "/v1/payments/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => array(
"status" => "cancelled"
)
);
$response = MPRestClient::put($request);
return $response;
} | php | public function cancel_payment($id) {
$request = array(
"uri" => "/v1/payments/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => array(
"status" => "cancelled"
)
);
$response = MPRestClient::put($request);
return $response;
} | [
"public",
"function",
"cancel_payment",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/v1/payments/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
"(",
")",
... | Cancel pending payment
@param int $id
@return array(json) | [
"Cancel",
"pending",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L139-L152 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.cancel_preapproval_payment | public function cancel_preapproval_payment($id) {
$request = array(
"uri" => "/preapproval/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => array(
"status" => "cancelled"
)
);
$response = MPRestClient::put($request);
return $response;
} | php | public function cancel_preapproval_payment($id) {
$request = array(
"uri" => "/preapproval/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => array(
"status" => "cancelled"
)
);
$response = MPRestClient::put($request);
return $response;
} | [
"public",
"function",
"cancel_preapproval_payment",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/preapproval/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
"(... | Cancel preapproval payment
@param int $id
@return array(json) | [
"Cancel",
"preapproval",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L159-L172 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.search_payment | public function search_payment($filters, $offset = 0, $limit = 0) {
$filters["offset"] = $offset;
$filters["limit"] = $limit;
$uri_prefix = $this->sandbox ? "/sandbox" : "";
$request = array(
"uri" => "/v1/payments/search",
"params" => array_merge ($filters, array(
"access_token" => $this->get_access_token()
))
);
$collection_result = MPRestClient::get($request);
return $collection_result;
} | php | public function search_payment($filters, $offset = 0, $limit = 0) {
$filters["offset"] = $offset;
$filters["limit"] = $limit;
$uri_prefix = $this->sandbox ? "/sandbox" : "";
$request = array(
"uri" => "/v1/payments/search",
"params" => array_merge ($filters, array(
"access_token" => $this->get_access_token()
))
);
$collection_result = MPRestClient::get($request);
return $collection_result;
} | [
"public",
"function",
"search_payment",
"(",
"$",
"filters",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"$",
"filters",
"[",
"\"offset\"",
"]",
"=",
"$",
"offset",
";",
"$",
"filters",
"[",
"\"limit\"",
"]",
"=",
"$",
"lim... | Search payments according to filters, with pagination
@param array $filters
@param int $offset
@param int $limit
@return array(json) | [
"Search",
"payments",
"according",
"to",
"filters",
"with",
"pagination"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L181-L196 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.create_preference | public function create_preference($preference) {
$request = array(
"uri" => "/checkout/preferences",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preference
);
$preference_result = MPRestClient::post($request);
return $preference_result;
} | php | public function create_preference($preference) {
$request = array(
"uri" => "/checkout/preferences",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preference
);
$preference_result = MPRestClient::post($request);
return $preference_result;
} | [
"public",
"function",
"create_preference",
"(",
"$",
"preference",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/checkout/preferences\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
... | Create a checkout preference
@param array $preference
@return array(json) | [
"Create",
"a",
"checkout",
"preference"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L203-L214 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.update_preference | public function update_preference($id, $preference) {
$request = array(
"uri" => "/checkout/preferences/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preference
);
$preference_result = MPRestClient::put($request);
return $preference_result;
} | php | public function update_preference($id, $preference) {
$request = array(
"uri" => "/checkout/preferences/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preference
);
$preference_result = MPRestClient::put($request);
return $preference_result;
} | [
"public",
"function",
"update_preference",
"(",
"$",
"id",
",",
"$",
"preference",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/checkout/preferences/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"-... | Update a checkout preference
@param string $id
@param array $preference
@return array(json) | [
"Update",
"a",
"checkout",
"preference"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L222-L233 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.get_preference | public function get_preference($id) {
$request = array(
"uri" => "/checkout/preferences/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$preference_result = MPRestClient::get($request);
return $preference_result;
} | php | public function get_preference($id) {
$request = array(
"uri" => "/checkout/preferences/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$preference_result = MPRestClient::get($request);
return $preference_result;
} | [
"public",
"function",
"get_preference",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/checkout/preferences/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
"(",
... | Get a checkout preference
@param string $id
@return array(json) | [
"Get",
"a",
"checkout",
"preference"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L240-L250 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.create_preapproval_payment | public function create_preapproval_payment($preapproval_payment) {
$request = array(
"uri" => "/preapproval",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preapproval_payment
);
$preapproval_payment_result = MPRestClient::post($request);
return $preapproval_payment_result;
} | php | public function create_preapproval_payment($preapproval_payment) {
$request = array(
"uri" => "/preapproval",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preapproval_payment
);
$preapproval_payment_result = MPRestClient::post($request);
return $preapproval_payment_result;
} | [
"public",
"function",
"create_preapproval_payment",
"(",
"$",
"preapproval_payment",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/preapproval\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_t... | Create a preapproval payment
@param array $preapproval_payment
@return array(json) | [
"Create",
"a",
"preapproval",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L257-L268 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.get_preapproval_payment | public function get_preapproval_payment($id) {
$request = array(
"uri" => "/preapproval/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$preapproval_payment_result = MPRestClient::get($request);
return $preapproval_payment_result;
} | php | public function get_preapproval_payment($id) {
$request = array(
"uri" => "/preapproval/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
)
);
$preapproval_payment_result = MPRestClient::get($request);
return $preapproval_payment_result;
} | [
"public",
"function",
"get_preapproval_payment",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/preapproval/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"this",
"->",
"get_access_token",
"(",
... | Get a preapproval payment
@param string $id
@return array(json) | [
"Get",
"a",
"preapproval",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L275-L285 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.update_preapproval_payment | public function update_preapproval_payment($id, $preapproval_payment) {
$request = array(
"uri" => "/preapproval/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preapproval_payment
);
$preapproval_payment_result = MPRestClient::put($request);
return $preapproval_payment_result;
} | php | public function update_preapproval_payment($id, $preapproval_payment) {
$request = array(
"uri" => "/preapproval/{$id}",
"params" => array(
"access_token" => $this->get_access_token()
),
"data" => $preapproval_payment
);
$preapproval_payment_result = MPRestClient::put($request);
return $preapproval_payment_result;
} | [
"public",
"function",
"update_preapproval_payment",
"(",
"$",
"id",
",",
"$",
"preapproval_payment",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"\"/preapproval/{$id}\"",
",",
"\"params\"",
"=>",
"array",
"(",
"\"access_token\"",
"=>",
"$",
"th... | Update a preapproval payment
@param string $preapproval_payment, $id
@return array(json) | [
"Update",
"a",
"preapproval",
"payment"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L293-L304 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.get | public function get($request, $params = null, $authenticate = true) {
if (is_string ($request)) {
$request = array(
"uri" => $request,
"params" => $params,
"authenticate" => $authenticate
);
}
$request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();
if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
$request["params"]["access_token"] = $this->get_access_token();
}
$result = MPRestClient::get($request);
return $result;
} | php | public function get($request, $params = null, $authenticate = true) {
if (is_string ($request)) {
$request = array(
"uri" => $request,
"params" => $params,
"authenticate" => $authenticate
);
}
$request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();
if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
$request["params"]["access_token"] = $this->get_access_token();
}
$result = MPRestClient::get($request);
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"request",
",",
"$",
"params",
"=",
"null",
",",
"$",
"authenticate",
"=",
"true",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"request",
")",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"$",... | Generic resource get
@param request
@param params (deprecated)
@param authenticate = true (deprecated) | [
"Generic",
"resource",
"get"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L314-L331 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.post | public function post($request, $data = null, $params = null) {
if (is_string ($request)) {
$request = array(
"uri" => $request,
"data" => $data,
"params" => $params
);
}
$request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();
if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
$request["params"]["access_token"] = $this->get_access_token();
}
$result = MPRestClient::post($request);
return $result;
} | php | public function post($request, $data = null, $params = null) {
if (is_string ($request)) {
$request = array(
"uri" => $request,
"data" => $data,
"params" => $params
);
}
$request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();
if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
$request["params"]["access_token"] = $this->get_access_token();
}
$result = MPRestClient::post($request);
return $result;
} | [
"public",
"function",
"post",
"(",
"$",
"request",
",",
"$",
"data",
"=",
"null",
",",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"request",
")",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"$",
"req... | Generic resource post
@param request
@param data (deprecated)
@param params (deprecated) | [
"Generic",
"resource",
"post"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L339-L356 | train |
mercadopago/sdk-php | lib/mercadopago.php | MP.delete | public function delete($request, $params = null) {
if (is_string ($request)) {
$request = array(
"uri" => $request,
"params" => $params
);
}
$request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();
if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
$request["params"]["access_token"] = $this->get_access_token();
}
$result = MPRestClient::delete($request);
return $result;
} | php | public function delete($request, $params = null) {
if (is_string ($request)) {
$request = array(
"uri" => $request,
"params" => $params
);
}
$request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();
if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
$request["params"]["access_token"] = $this->get_access_token();
}
$result = MPRestClient::delete($request);
return $result;
} | [
"public",
"function",
"delete",
"(",
"$",
"request",
",",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"request",
")",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"\"uri\"",
"=>",
"$",
"request",
",",
"\"params\"",
"=>",
... | Generic resource delete
@param request
@param data (deprecated)
@param params (deprecated) | [
"Generic",
"resource",
"delete"
] | 67f65735d5d720a7fc2569163f5c7d150adc613d | https://github.com/mercadopago/sdk-php/blob/67f65735d5d720a7fc2569163f5c7d150adc613d/lib/mercadopago.php#L389-L405 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFDictionary.php | CFDictionary.add | public function add($key, CFType $value = null)
{
// anything but CFType is null, null is an empty string - sad but true
if (!$value) {
$value = new CFString();
}
$this->value[$key] = $value;
} | php | public function add($key, CFType $value = null)
{
// anything but CFType is null, null is an empty string - sad but true
if (!$value) {
$value = new CFString();
}
$this->value[$key] = $value;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"CFType",
"$",
"value",
"=",
"null",
")",
"{",
"// anything but CFType is null, null is an empty string - sad but true",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"new",
"CFString",
"(",
")",
... | Add CFType to collection.
@param string $key Key to add to collection
@param CFType $value CFType to add to collection, defaults to null which results in an empty {@link CFString}
@return void
@uses $value for adding $key $value pair | [
"Add",
"CFType",
"to",
"collection",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFDictionary.php#L89-L96 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFDictionary.php | CFDictionary.toArray | public function toArray()
{
$a = array();
foreach ($this->value as $key => $value) {
$a[$key] = $value->toArray();
}
return $a;
} | php | public function toArray()
{
$a = array();
foreach ($this->value as $key => $value) {
$a[$key] = $value->toArray();
}
return $a;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"a",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"value",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"a",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"->",
"toArr... | Get CFType's value.
@return array primitive value
@uses $value for retrieving primitive of CFType | [
"Get",
"CFType",
"s",
"value",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFDictionary.php#L166-L173 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.loadXMLStream | public function loadXMLStream($stream)
{
if (($contents = stream_get_contents($stream)) === false) {
throw IOException::notReadable('<stream>');
}
$this->parse($contents, CFPropertyList::FORMAT_XML);
} | php | public function loadXMLStream($stream)
{
if (($contents = stream_get_contents($stream)) === false) {
throw IOException::notReadable('<stream>');
}
$this->parse($contents, CFPropertyList::FORMAT_XML);
} | [
"public",
"function",
"loadXMLStream",
"(",
"$",
"stream",
")",
"{",
"if",
"(",
"(",
"$",
"contents",
"=",
"stream_get_contents",
"(",
"$",
"stream",
")",
")",
"===",
"false",
")",
"{",
"throw",
"IOException",
"::",
"notReadable",
"(",
"'<stream>'",
")",
... | Load an XML PropertyList.
@param resource $stream A stream containing the xml document.
@return void
@throws IOException if stream could not be read
@throws DOMException if XML-stream could not be read properly | [
"Load",
"an",
"XML",
"PropertyList",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L176-L182 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.loadBinaryStream | public function loadBinaryStream($stream)
{
if (($contents = stream_get_contents($stream)) === false) {
throw IOException::notReadable('<stream>');
}
$this->parse($contents, CFPropertyList::FORMAT_BINARY);
} | php | public function loadBinaryStream($stream)
{
if (($contents = stream_get_contents($stream)) === false) {
throw IOException::notReadable('<stream>');
}
$this->parse($contents, CFPropertyList::FORMAT_BINARY);
} | [
"public",
"function",
"loadBinaryStream",
"(",
"$",
"stream",
")",
"{",
"if",
"(",
"(",
"$",
"contents",
"=",
"stream_get_contents",
"(",
"$",
"stream",
")",
")",
"===",
"false",
")",
"{",
"throw",
"IOException",
"::",
"notReadable",
"(",
"'<stream>'",
")"... | Load an binary PropertyList.
@param stream $stream Stream containing the PropertyList
@return void
@throws IOException if file could not be read
@throws PListException if binary plist-file could not be read properly
@uses parse() to actually load the file | [
"Load",
"an",
"binary",
"PropertyList",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L205-L211 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.load | public function load($file = null, $format = null)
{
$file = $file ? $file : $this->file;
$format = $format !== null ? $format : $this->format;
$this->value = array();
if (!is_readable($file)) {
throw IOException::notReadable($file);
}
switch ($format) {
case CFPropertyList::FORMAT_BINARY:
$this->readBinary($file);
break;
case CFPropertyList::FORMAT_AUTO: // what we now do is ugly, but neccessary to recognize the file format
$fd = fopen($file, "rb");
if (($magic_number = fread($fd, 8)) === false) {
throw IOException::notReadable($file);
}
fclose($fd);
$filetype = substr($magic_number, 0, 6);
$version = substr($magic_number, -2);
if ($filetype == "bplist") {
if ($version != "00") {
throw new PListException("Wrong file format version! Expected 00, got $version!");
}
$this->detectedFormat = CFPropertyList::FORMAT_BINARY;
$this->readBinary($file);
break;
}
$this->detectedFormat = CFPropertyList::FORMAT_XML;
// else: xml format, break not neccessary
case CFPropertyList::FORMAT_XML:
$doc = new DOMDocument();
$prevXmlErrors = libxml_use_internal_errors(true);
libxml_clear_errors();
if (!$doc->load($file)) {
$message = $this->getLibxmlErrors();
libxml_clear_errors();
libxml_use_internal_errors($prevXmlErrors);
throw new DOMException($message);
}
libxml_use_internal_errors($prevXmlErrors);
$this->import($doc->documentElement, $this);
break;
}
} | php | public function load($file = null, $format = null)
{
$file = $file ? $file : $this->file;
$format = $format !== null ? $format : $this->format;
$this->value = array();
if (!is_readable($file)) {
throw IOException::notReadable($file);
}
switch ($format) {
case CFPropertyList::FORMAT_BINARY:
$this->readBinary($file);
break;
case CFPropertyList::FORMAT_AUTO: // what we now do is ugly, but neccessary to recognize the file format
$fd = fopen($file, "rb");
if (($magic_number = fread($fd, 8)) === false) {
throw IOException::notReadable($file);
}
fclose($fd);
$filetype = substr($magic_number, 0, 6);
$version = substr($magic_number, -2);
if ($filetype == "bplist") {
if ($version != "00") {
throw new PListException("Wrong file format version! Expected 00, got $version!");
}
$this->detectedFormat = CFPropertyList::FORMAT_BINARY;
$this->readBinary($file);
break;
}
$this->detectedFormat = CFPropertyList::FORMAT_XML;
// else: xml format, break not neccessary
case CFPropertyList::FORMAT_XML:
$doc = new DOMDocument();
$prevXmlErrors = libxml_use_internal_errors(true);
libxml_clear_errors();
if (!$doc->load($file)) {
$message = $this->getLibxmlErrors();
libxml_clear_errors();
libxml_use_internal_errors($prevXmlErrors);
throw new DOMException($message);
}
libxml_use_internal_errors($prevXmlErrors);
$this->import($doc->documentElement, $this);
break;
}
} | [
"public",
"function",
"load",
"(",
"$",
"file",
"=",
"null",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"file",
"=",
"$",
"file",
"?",
"$",
"file",
":",
"$",
"this",
"->",
"file",
";",
"$",
"format",
"=",
"$",
"format",
"!==",
"null",
"?",... | Load a plist file.
Load and import a plist file.
@param string $file Path of PropertyList, defaults to {@link $file}
@param integer $format The format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link $format}
@return void
@throws PListException if file format version is not 00
@throws IOException if file could not be read
@throws DOMException if plist file could not be parsed properly
@uses $file if argument $file was not specified
@uses $value reset to empty array
@uses import() for importing the values | [
"Load",
"a",
"plist",
"file",
".",
"Load",
"and",
"import",
"a",
"plist",
"file",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L226-L274 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.parse | public function parse($str = null, $format = null)
{
$format = $format !== null ? $format : $this->format;
$str = $str !== null ? $str : $this->content;
if ($str === null || strlen($str) === 0) {
throw IOException::readError('');
}
$this->value = array();
switch ($format) {
case CFPropertyList::FORMAT_BINARY:
$this->parseBinary($str);
break;
case CFPropertyList::FORMAT_AUTO: // what we now do is ugly, but neccessary to recognize the file format
if (($magic_number = substr($str, 0, 8)) === false) {
throw IOException::notReadable("<string>");
}
$filetype = substr($magic_number, 0, 6);
$version = substr($magic_number, -2);
if ($filetype == "bplist") {
if ($version != "00") {
throw new PListException("Wrong file format version! Expected 00, got $version!");
}
$this->detectedFormat = CFPropertyList::FORMAT_BINARY;
$this->parseBinary($str);
break;
}
$this->detectedFormat = CFPropertyList::FORMAT_XML;
// else: xml format, break not neccessary
case CFPropertyList::FORMAT_XML:
$doc = new DOMDocument();
$prevXmlErrors = libxml_use_internal_errors(true);
libxml_clear_errors();
if (!$doc->loadXML($str)) {
$message = $this->getLibxmlErrors();
libxml_clear_errors();
libxml_use_internal_errors($prevXmlErrors);
throw new DOMException($message);
}
libxml_use_internal_errors($prevXmlErrors);
$this->import($doc->documentElement, $this);
break;
}
} | php | public function parse($str = null, $format = null)
{
$format = $format !== null ? $format : $this->format;
$str = $str !== null ? $str : $this->content;
if ($str === null || strlen($str) === 0) {
throw IOException::readError('');
}
$this->value = array();
switch ($format) {
case CFPropertyList::FORMAT_BINARY:
$this->parseBinary($str);
break;
case CFPropertyList::FORMAT_AUTO: // what we now do is ugly, but neccessary to recognize the file format
if (($magic_number = substr($str, 0, 8)) === false) {
throw IOException::notReadable("<string>");
}
$filetype = substr($magic_number, 0, 6);
$version = substr($magic_number, -2);
if ($filetype == "bplist") {
if ($version != "00") {
throw new PListException("Wrong file format version! Expected 00, got $version!");
}
$this->detectedFormat = CFPropertyList::FORMAT_BINARY;
$this->parseBinary($str);
break;
}
$this->detectedFormat = CFPropertyList::FORMAT_XML;
// else: xml format, break not neccessary
case CFPropertyList::FORMAT_XML:
$doc = new DOMDocument();
$prevXmlErrors = libxml_use_internal_errors(true);
libxml_clear_errors();
if (!$doc->loadXML($str)) {
$message = $this->getLibxmlErrors();
libxml_clear_errors();
libxml_use_internal_errors($prevXmlErrors);
throw new DOMException($message);
}
libxml_use_internal_errors($prevXmlErrors);
$this->import($doc->documentElement, $this);
break;
}
} | [
"public",
"function",
"parse",
"(",
"$",
"str",
"=",
"null",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"format",
"=",
"$",
"format",
"!==",
"null",
"?",
"$",
"format",
":",
"$",
"this",
"->",
"format",
";",
"$",
"str",
"=",
"$",
"str",
"!... | Parse a plist string.
Parse and import a plist string.
@param string $str String containing the PropertyList, defaults to {@link $content}
@param integer $format The format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link $format}
@return void
@throws PListException if file format version is not 00
@throws IOException if file could not be read
@throws DOMException if plist file could not be parsed properly
@uses $content if argument $str was not specified
@uses $value reset to empty array
@uses import() for importing the values | [
"Parse",
"a",
"plist",
"string",
".",
"Parse",
"and",
"import",
"a",
"plist",
"string",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L289-L334 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.import | protected function import(DOMNode $node, $parent)
{
// abort if there are no children
if (!$node->childNodes->length) {
return;
}
foreach ($node->childNodes as $n) {
// skip if we can't handle the element
if (!isset(self::$types[$n->nodeName])) {
continue;
}
$class = __NAMESPACE__ . '\\'.self::$types[$n->nodeName];
$key = null;
// find previous <key> if possible
$ps = $n->previousSibling;
while ($ps && $ps->nodeName == '#text' && $ps->previousSibling) {
$ps = $ps->previousSibling;
}
// read <key> if possible
if ($ps && $ps->nodeName == 'key') {
$key = $ps->firstChild->nodeValue;
}
switch ($n->nodeName) {
case 'date':
$value = new $class(CFDate::dateValue($n->nodeValue));
break;
case 'data':
$value = new $class($n->nodeValue, true);
break;
case 'string':
$value = new $class($n->nodeValue);
break;
case 'real':
case 'integer':
$value = new $class($n->nodeName == 'real' ? floatval($n->nodeValue) : intval($n->nodeValue));
break;
case 'true':
case 'false':
$value = new $class($n->nodeName == 'true');
break;
case 'array':
case 'dict':
$value = new $class();
$this->import($n, $value);
if ($value instanceof CFDictionary) {
$hsh = $value->getValue();
if (isset($hsh['CF$UID']) && count($hsh) == 1) {
$value = new CFUid($hsh['CF$UID']->getValue());
}
}
break;
}
// Dictionaries need a key
if ($parent instanceof CFDictionary) {
$parent->add($key, $value);
} // others don't
else {
$parent->add($value);
}
}
} | php | protected function import(DOMNode $node, $parent)
{
// abort if there are no children
if (!$node->childNodes->length) {
return;
}
foreach ($node->childNodes as $n) {
// skip if we can't handle the element
if (!isset(self::$types[$n->nodeName])) {
continue;
}
$class = __NAMESPACE__ . '\\'.self::$types[$n->nodeName];
$key = null;
// find previous <key> if possible
$ps = $n->previousSibling;
while ($ps && $ps->nodeName == '#text' && $ps->previousSibling) {
$ps = $ps->previousSibling;
}
// read <key> if possible
if ($ps && $ps->nodeName == 'key') {
$key = $ps->firstChild->nodeValue;
}
switch ($n->nodeName) {
case 'date':
$value = new $class(CFDate::dateValue($n->nodeValue));
break;
case 'data':
$value = new $class($n->nodeValue, true);
break;
case 'string':
$value = new $class($n->nodeValue);
break;
case 'real':
case 'integer':
$value = new $class($n->nodeName == 'real' ? floatval($n->nodeValue) : intval($n->nodeValue));
break;
case 'true':
case 'false':
$value = new $class($n->nodeName == 'true');
break;
case 'array':
case 'dict':
$value = new $class();
$this->import($n, $value);
if ($value instanceof CFDictionary) {
$hsh = $value->getValue();
if (isset($hsh['CF$UID']) && count($hsh) == 1) {
$value = new CFUid($hsh['CF$UID']->getValue());
}
}
break;
}
// Dictionaries need a key
if ($parent instanceof CFDictionary) {
$parent->add($key, $value);
} // others don't
else {
$parent->add($value);
}
}
} | [
"protected",
"function",
"import",
"(",
"DOMNode",
"$",
"node",
",",
"$",
"parent",
")",
"{",
"// abort if there are no children",
"if",
"(",
"!",
"$",
"node",
"->",
"childNodes",
"->",
"length",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"node",
... | Convert a DOMNode into a CFType.
@param DOMNode $node Node to import children of
@param CFDictionary|CFArray|CFPropertyList $parent
@return void | [
"Convert",
"a",
"DOMNode",
"into",
"a",
"CFType",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L349-L420 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.saveXML | public function saveXML($file, $formatted = false)
{
$this->save($file, CFPropertyList::FORMAT_XML, $formatted);
} | php | public function saveXML($file, $formatted = false)
{
$this->save($file, CFPropertyList::FORMAT_XML, $formatted);
} | [
"public",
"function",
"saveXML",
"(",
"$",
"file",
",",
"$",
"formatted",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"save",
"(",
"$",
"file",
",",
"CFPropertyList",
"::",
"FORMAT_XML",
",",
"$",
"formatted",
")",
";",
"}"
] | Convert CFPropertyList to XML and save to file.
@param string $file Path of PropertyList, defaults to {@link $file}
@param bool $formatted Print plist formatted (i.e. with newlines and whitespace indention) if true; defaults to false
@return void
@throws IOException if file could not be read
@uses $file if $file was not specified | [
"Convert",
"CFPropertyList",
"to",
"XML",
"and",
"save",
"to",
"file",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L430-L433 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.save | public function save($file = null, $format = null, $formatted_xml = false)
{
$file = $file ? $file : $this->file;
$format = $format ? $format : $this->format;
if ($format == self::FORMAT_AUTO) {
$format = $this->detectedFormat;
}
if (!in_array($format, array( self::FORMAT_BINARY, self::FORMAT_XML ))) {
throw new PListException("format {$format} is not supported, use CFPropertyList::FORMAT_BINARY or CFPropertyList::FORMAT_XML");
}
if (!file_exists($file)) {
// dirname("file.xml") == "" and is treated as the current working directory
if (!is_writable(dirname($file))) {
throw IOException::notWritable($file);
}
} elseif (!is_writable($file)) {
throw IOException::notWritable($file);
}
$content = $format == self::FORMAT_BINARY ? $this->toBinary() : $this->toXML($formatted_xml);
$fh = fopen($file, 'wb');
fwrite($fh, $content);
fclose($fh);
} | php | public function save($file = null, $format = null, $formatted_xml = false)
{
$file = $file ? $file : $this->file;
$format = $format ? $format : $this->format;
if ($format == self::FORMAT_AUTO) {
$format = $this->detectedFormat;
}
if (!in_array($format, array( self::FORMAT_BINARY, self::FORMAT_XML ))) {
throw new PListException("format {$format} is not supported, use CFPropertyList::FORMAT_BINARY or CFPropertyList::FORMAT_XML");
}
if (!file_exists($file)) {
// dirname("file.xml") == "" and is treated as the current working directory
if (!is_writable(dirname($file))) {
throw IOException::notWritable($file);
}
} elseif (!is_writable($file)) {
throw IOException::notWritable($file);
}
$content = $format == self::FORMAT_BINARY ? $this->toBinary() : $this->toXML($formatted_xml);
$fh = fopen($file, 'wb');
fwrite($fh, $content);
fclose($fh);
} | [
"public",
"function",
"save",
"(",
"$",
"file",
"=",
"null",
",",
"$",
"format",
"=",
"null",
",",
"$",
"formatted_xml",
"=",
"false",
")",
"{",
"$",
"file",
"=",
"$",
"file",
"?",
"$",
"file",
":",
"$",
"this",
"->",
"file",
";",
"$",
"format",
... | Convert CFPropertyList to XML or binary and save to file.
@param string $file Path of PropertyList, defaults to {@link $file}
@param string $format Format of PropertyList, defaults to {@link $format}
@param bool $formatted_xml Print XML plist formatted (i.e. with newlines and whitespace indention) if true; defaults to false
@return void
@throws IOException if file could not be read
@throws PListException if evaluated $format is neither {@link FORMAT_XML} nor {@link FORMAL_BINARY}
@uses $file if $file was not specified
@uses $format if $format was not specified | [
"Convert",
"CFPropertyList",
"to",
"XML",
"or",
"binary",
"and",
"save",
"to",
"file",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L458-L484 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.toXML | public function toXML($formatted = false)
{
$domimpl = new DOMImplementation();
// <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
$dtd = $domimpl->createDocumentType('plist', '-//Apple//DTD PLIST 1.0//EN', 'http://www.apple.com/DTDs/PropertyList-1.0.dtd');
$doc = $domimpl->createDocument(null, "plist", $dtd);
$doc->encoding = "UTF-8";
// format output
if ($formatted) {
$doc->formatOutput = true;
$doc->preserveWhiteSpace = true;
}
// get documentElement and set attribs
$plist = $doc->documentElement;
$plist->setAttribute('version', '1.0');
// add PropertyList's children
$plist->appendChild($this->getValue(true)->toXML($doc));
return $doc->saveXML();
} | php | public function toXML($formatted = false)
{
$domimpl = new DOMImplementation();
// <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
$dtd = $domimpl->createDocumentType('plist', '-//Apple//DTD PLIST 1.0//EN', 'http://www.apple.com/DTDs/PropertyList-1.0.dtd');
$doc = $domimpl->createDocument(null, "plist", $dtd);
$doc->encoding = "UTF-8";
// format output
if ($formatted) {
$doc->formatOutput = true;
$doc->preserveWhiteSpace = true;
}
// get documentElement and set attribs
$plist = $doc->documentElement;
$plist->setAttribute('version', '1.0');
// add PropertyList's children
$plist->appendChild($this->getValue(true)->toXML($doc));
return $doc->saveXML();
} | [
"public",
"function",
"toXML",
"(",
"$",
"formatted",
"=",
"false",
")",
"{",
"$",
"domimpl",
"=",
"new",
"DOMImplementation",
"(",
")",
";",
"// <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">",
"$",
"dtd",
... | Convert CFPropertyList to XML
@param bool $formatted Print plist formatted (i.e. with newlines and whitespace indention) if true; defaults to false
@return string The XML content | [
"Convert",
"CFPropertyList",
"to",
"XML"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L491-L513 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFPropertyList.php | CFPropertyList.del | public function del($key)
{
if (isset($this->value[$key])) {
$t = $this->value[$key];
unset($this->value[$key]);
return $t;
}
return null;
} | php | public function del($key)
{
if (isset($this->value[$key])) {
$t = $this->value[$key];
unset($this->value[$key]);
return $t;
}
return null;
} | [
"public",
"function",
"del",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"value",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"value",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"this... | Remove CFType from collection.
@param integer $key Key of CFType to removes from collection
@return CFType removed CFType, null else
@uses $value for removing CFType of $key | [
"Remove",
"CFType",
"from",
"collection",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFPropertyList.php#L569-L578 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFTypeDetector.php | CFTypeDetector.isAssociativeArray | protected function isAssociativeArray($value)
{
$numericKeys = true;
$i = 0;
foreach ($value as $key => $v) {
if ($i !== $key) {
$numericKeys = false;
break;
}
$i++;
}
return !$numericKeys;
} | php | protected function isAssociativeArray($value)
{
$numericKeys = true;
$i = 0;
foreach ($value as $key => $v) {
if ($i !== $key) {
$numericKeys = false;
break;
}
$i++;
}
return !$numericKeys;
} | [
"protected",
"function",
"isAssociativeArray",
"(",
"$",
"value",
")",
"{",
"$",
"numericKeys",
"=",
"true",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"i",
"!==",
"$",
... | Determine if an array is associative or numerical.
Numerical Arrays have incrementing index-numbers that don't contain gaps.
@param array $value Array to check indexes of
@return boolean true if array is associative, false if array has numeric indexes | [
"Determine",
"if",
"an",
"array",
"is",
"associative",
"or",
"numerical",
".",
"Numerical",
"Arrays",
"have",
"incrementing",
"index",
"-",
"numbers",
"that",
"don",
"t",
"contain",
"gaps",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFTypeDetector.php#L110-L122 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.make64Int | protected static function make64Int($hi, $lo)
{
// on x64, we can just use int
if (PHP_INT_SIZE > 4) {
return (((int)$hi)<<32) | ((int)$lo);
}
// lower word has to be unsigned since we don't use bitwise or, we use bcadd/gmp_add
$lo = sprintf("%u", $lo);
// use GMP or bcmath if possible
if (function_exists("gmp_mul")) {
return gmp_strval(gmp_add(gmp_mul($hi, "4294967296"), $lo));
}
if (function_exists("bcmul")) {
return bcadd(bcmul($hi, "4294967296"), $lo);
}
if (class_exists('Math_BigInteger')) {
$bi = new \Math_BigInteger($hi);
return $bi->multiply(new \Math_BigInteger("4294967296"))->add(new \Math_BigInteger($lo))->toString();
}
throw new PListException("either gmp or bc has to be installed, or the Math_BigInteger has to be available!");
} | php | protected static function make64Int($hi, $lo)
{
// on x64, we can just use int
if (PHP_INT_SIZE > 4) {
return (((int)$hi)<<32) | ((int)$lo);
}
// lower word has to be unsigned since we don't use bitwise or, we use bcadd/gmp_add
$lo = sprintf("%u", $lo);
// use GMP or bcmath if possible
if (function_exists("gmp_mul")) {
return gmp_strval(gmp_add(gmp_mul($hi, "4294967296"), $lo));
}
if (function_exists("bcmul")) {
return bcadd(bcmul($hi, "4294967296"), $lo);
}
if (class_exists('Math_BigInteger')) {
$bi = new \Math_BigInteger($hi);
return $bi->multiply(new \Math_BigInteger("4294967296"))->add(new \Math_BigInteger($lo))->toString();
}
throw new PListException("either gmp or bc has to be installed, or the Math_BigInteger has to be available!");
} | [
"protected",
"static",
"function",
"make64Int",
"(",
"$",
"hi",
",",
"$",
"lo",
")",
"{",
"// on x64, we can just use int",
"if",
"(",
"PHP_INT_SIZE",
">",
"4",
")",
"{",
"return",
"(",
"(",
"(",
"int",
")",
"$",
"hi",
")",
"<<",
"32",
")",
"|",
"(",... | Create an 64 bit integer using bcmath or gmp
@param int $hi The higher word
@param int $lo The lower word
@return mixed The integer (as int if possible, as string if not possible)
@throws PListException if neither gmp nor bc available | [
"Create",
"an",
"64",
"bit",
"integer",
"using",
"bcmath",
"or",
"gmp"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L152-L177 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryInt | protected function readBinaryInt($length)
{
if ($length > 3) {
throw new PListException("Integer greater than 8 bytes: $length");
}
$nbytes = 1 << $length;
$val = null;
if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
throw IOException::readError("");
}
$this->pos += $nbytes;
switch ($length) {
case 0:
$val = unpack("C", $buff);
$val = $val[1];
break;
case 1:
$val = unpack("n", $buff);
$val = $val[1];
break;
case 2:
$val = unpack("N", $buff);
$val = $val[1];
break;
case 3:
$words = unpack("Nhighword/Nlowword", $buff);
//$val = $words['highword'] << 32 | $words['lowword'];
$val = self::make64Int($words['highword'], $words['lowword']);
break;
}
return new CFNumber($val);
} | php | protected function readBinaryInt($length)
{
if ($length > 3) {
throw new PListException("Integer greater than 8 bytes: $length");
}
$nbytes = 1 << $length;
$val = null;
if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
throw IOException::readError("");
}
$this->pos += $nbytes;
switch ($length) {
case 0:
$val = unpack("C", $buff);
$val = $val[1];
break;
case 1:
$val = unpack("n", $buff);
$val = $val[1];
break;
case 2:
$val = unpack("N", $buff);
$val = $val[1];
break;
case 3:
$words = unpack("Nhighword/Nlowword", $buff);
//$val = $words['highword'] << 32 | $words['lowword'];
$val = self::make64Int($words['highword'], $words['lowword']);
break;
}
return new CFNumber($val);
} | [
"protected",
"function",
"readBinaryInt",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"length",
">",
"3",
")",
"{",
"throw",
"new",
"PListException",
"(",
"\"Integer greater than 8 bytes: $length\"",
")",
";",
"}",
"$",
"nbytes",
"=",
"1",
"<<",
"$",
"le... | Read an integer value
@param integer $length The length (in bytes) of the integer value, coded as „set bit $length to 1”
@return CFNumber The integer value
@throws PListException if integer val is invalid
@throws IOException if read error occurs
@uses make64Int() to overcome PHP's big integer problems | [
"Read",
"an",
"integer",
"value"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L187-L222 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryReal | protected function readBinaryReal($length)
{
if ($length > 3) {
throw new PListException("Real greater than 8 bytes: $length");
}
$nbytes = 1 << $length;
$val = null;
if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
throw IOException::readError("");
}
$this->pos += $nbytes;
switch ($length) {
case 0: // 1 byte float? must be an error
case 1: // 2 byte float? must be an error
$x = $length + 1;
throw new PListException("got {$x} byte float, must be an error!");
case 2:
$val = unpack("f", strrev($buff));
$val = $val[1];
break;
case 3:
$val = unpack("d", strrev($buff));
$val = $val[1];
break;
}
return new CFNumber($val);
} | php | protected function readBinaryReal($length)
{
if ($length > 3) {
throw new PListException("Real greater than 8 bytes: $length");
}
$nbytes = 1 << $length;
$val = null;
if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
throw IOException::readError("");
}
$this->pos += $nbytes;
switch ($length) {
case 0: // 1 byte float? must be an error
case 1: // 2 byte float? must be an error
$x = $length + 1;
throw new PListException("got {$x} byte float, must be an error!");
case 2:
$val = unpack("f", strrev($buff));
$val = $val[1];
break;
case 3:
$val = unpack("d", strrev($buff));
$val = $val[1];
break;
}
return new CFNumber($val);
} | [
"protected",
"function",
"readBinaryReal",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"length",
">",
"3",
")",
"{",
"throw",
"new",
"PListException",
"(",
"\"Real greater than 8 bytes: $length\"",
")",
";",
"}",
"$",
"nbytes",
"=",
"1",
"<<",
"$",
"leng... | Read a real value
@param integer $length The length (in bytes) of the integer value, coded as „set bit $length to 1”
@return CFNumber The real value
@throws PListException if real val is invalid
@throws IOException if read error occurs | [
"Read",
"a",
"real",
"value"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L231-L260 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryDate | protected function readBinaryDate($length)
{
if ($length > 3) {
throw new PListException("Date greater than 8 bytes: $length");
}
$nbytes = 1 << $length;
$val = null;
if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
throw IOException::readError("");
}
$this->pos += $nbytes;
switch ($length) {
case 0: // 1 byte CFDate is an error
case 1: // 2 byte CFDate is an error
$x = $length + 1;
throw new PListException("{$x} byte CFdate, error");
case 2:
$val = unpack("f", strrev($buff));
$val = $val[1];
break;
case 3:
$val = unpack("d", strrev($buff));
$val = $val[1];
break;
}
return new CFDate($val, CFDate::TIMESTAMP_APPLE);
} | php | protected function readBinaryDate($length)
{
if ($length > 3) {
throw new PListException("Date greater than 8 bytes: $length");
}
$nbytes = 1 << $length;
$val = null;
if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
throw IOException::readError("");
}
$this->pos += $nbytes;
switch ($length) {
case 0: // 1 byte CFDate is an error
case 1: // 2 byte CFDate is an error
$x = $length + 1;
throw new PListException("{$x} byte CFdate, error");
case 2:
$val = unpack("f", strrev($buff));
$val = $val[1];
break;
case 3:
$val = unpack("d", strrev($buff));
$val = $val[1];
break;
}
return new CFDate($val, CFDate::TIMESTAMP_APPLE);
} | [
"protected",
"function",
"readBinaryDate",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"length",
">",
"3",
")",
"{",
"throw",
"new",
"PListException",
"(",
"\"Date greater than 8 bytes: $length\"",
")",
";",
"}",
"$",
"nbytes",
"=",
"1",
"<<",
"$",
"leng... | Read a date value
@param integer $length The length (in bytes) of the integer value, coded as „set bit $length to 1”
@return CFDate The date value
@throws PListException if date val is invalid
@throws IOException if read error occurs | [
"Read",
"a",
"date",
"value"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L269-L299 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryData | protected function readBinaryData($length)
{
if ($length == 0) {
$buff = "";
} else {
$buff = substr($this->content, $this->pos, $length);
if (strlen($buff) != $length) {
throw IOException::readError("");
}
$this->pos += $length;
}
return new CFData($buff, false);
} | php | protected function readBinaryData($length)
{
if ($length == 0) {
$buff = "";
} else {
$buff = substr($this->content, $this->pos, $length);
if (strlen($buff) != $length) {
throw IOException::readError("");
}
$this->pos += $length;
}
return new CFData($buff, false);
} | [
"protected",
"function",
"readBinaryData",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"length",
"==",
"0",
")",
"{",
"$",
"buff",
"=",
"\"\"",
";",
"}",
"else",
"{",
"$",
"buff",
"=",
"substr",
"(",
"$",
"this",
"->",
"content",
",",
"$",
"thi... | Read a data value
@param integer $length The length (in bytes) of the integer value, coded as „set bit $length to 1”
@return CFData The data value
@throws IOException if read error occurs | [
"Read",
"a",
"data",
"value"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L307-L320 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryString | protected function readBinaryString($length)
{
if ($length == 0) {
$buff = "";
} else {
if (strlen($buff = substr($this->content, $this->pos, $length)) != $length) {
throw IOException::readError("");
}
$this->pos += $length;
}
if (!isset($this->uniqueTable[$buff])) {
$this->uniqueTable[$buff] = true;
}
return new CFString($buff);
} | php | protected function readBinaryString($length)
{
if ($length == 0) {
$buff = "";
} else {
if (strlen($buff = substr($this->content, $this->pos, $length)) != $length) {
throw IOException::readError("");
}
$this->pos += $length;
}
if (!isset($this->uniqueTable[$buff])) {
$this->uniqueTable[$buff] = true;
}
return new CFString($buff);
} | [
"protected",
"function",
"readBinaryString",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"length",
"==",
"0",
")",
"{",
"$",
"buff",
"=",
"\"\"",
";",
"}",
"else",
"{",
"if",
"(",
"strlen",
"(",
"$",
"buff",
"=",
"substr",
"(",
"$",
"this",
"->... | Read a string value, usually coded as utf8
@param integer $length The length (in bytes) of the string value
@return CFString The string value, utf8 encoded
@throws IOException if read error occurs | [
"Read",
"a",
"string",
"value",
"usually",
"coded",
"as",
"utf8"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L328-L343 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.convertCharset | public static function convertCharset($string, $fromCharset, $toCharset = 'UTF-8')
{
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($string, $toCharset, $fromCharset);
}
if (function_exists('iconv')) {
return iconv($fromCharset, $toCharset, $string);
}
if (function_exists('recode_string')) {
return recode_string($fromCharset .'..'. $toCharset, $string);
}
throw new PListException('neither iconv nor mbstring supported. how are we supposed to work on strings here?');
} | php | public static function convertCharset($string, $fromCharset, $toCharset = 'UTF-8')
{
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($string, $toCharset, $fromCharset);
}
if (function_exists('iconv')) {
return iconv($fromCharset, $toCharset, $string);
}
if (function_exists('recode_string')) {
return recode_string($fromCharset .'..'. $toCharset, $string);
}
throw new PListException('neither iconv nor mbstring supported. how are we supposed to work on strings here?');
} | [
"public",
"static",
"function",
"convertCharset",
"(",
"$",
"string",
",",
"$",
"fromCharset",
",",
"$",
"toCharset",
"=",
"'UTF-8'",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_convert_encoding'",
")",
")",
"{",
"return",
"mb_convert_encoding",
"(",
"$"... | Convert the given string from one charset to another.
Trying to use MBString, Iconv, Recode - in that particular order.
@param string $string the string to convert
@param string $fromCharset the charset the given string is currently encoded in
@param string $toCharset the charset to convert to, defaults to UTF-8
@return string the converted string
@throws PListException on neither MBString, Iconv, Recode being available | [
"Convert",
"the",
"given",
"string",
"from",
"one",
"charset",
"to",
"another",
".",
"Trying",
"to",
"use",
"MBString",
"Iconv",
"Recode",
"-",
"in",
"that",
"particular",
"order",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L354-L367 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.charsetStrlen | public static function charsetStrlen($string, $charset = "UTF-8")
{
if (function_exists('mb_strlen')) {
return mb_strlen($string, $charset);
}
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, $charset);
}
throw new PListException('neither iconv nor mbstring supported. how are we supposed to work on strings here?');
} | php | public static function charsetStrlen($string, $charset = "UTF-8")
{
if (function_exists('mb_strlen')) {
return mb_strlen($string, $charset);
}
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, $charset);
}
throw new PListException('neither iconv nor mbstring supported. how are we supposed to work on strings here?');
} | [
"public",
"static",
"function",
"charsetStrlen",
"(",
"$",
"string",
",",
"$",
"charset",
"=",
"\"UTF-8\"",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_strlen'",
")",
")",
"{",
"return",
"mb_strlen",
"(",
"$",
"string",
",",
"$",
"charset",
")",
";... | Count characters considering character set
Trying to use MBString, Iconv - in that particular order.
@param string $string the string to convert
@param string $charset the charset the given string is currently encoded in
@return integer The number of characters in that string
@throws PListException on neither MBString, Iconv being available | [
"Count",
"characters",
"considering",
"character",
"set",
"Trying",
"to",
"use",
"MBString",
"Iconv",
"-",
"in",
"that",
"particular",
"order",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L377-L387 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryUnicodeString | protected function readBinaryUnicodeString($length)
{
/* The problem is: we get the length of the string IN CHARACTERS;
since a char in UTF-16 can be 16 or 32 bit long, we don't really know
how long the string is in bytes */
if (strlen($buff = substr($this->content, $this->pos, 2*$length)) != 2*$length) {
throw IOException::readError("");
}
$this->pos += 2 * $length;
if (!isset($this->uniqueTable[$buff])) {
$this->uniqueTable[$buff] = true;
}
return new CFString(self::convertCharset($buff, "UTF-16BE", "UTF-8"));
} | php | protected function readBinaryUnicodeString($length)
{
/* The problem is: we get the length of the string IN CHARACTERS;
since a char in UTF-16 can be 16 or 32 bit long, we don't really know
how long the string is in bytes */
if (strlen($buff = substr($this->content, $this->pos, 2*$length)) != 2*$length) {
throw IOException::readError("");
}
$this->pos += 2 * $length;
if (!isset($this->uniqueTable[$buff])) {
$this->uniqueTable[$buff] = true;
}
return new CFString(self::convertCharset($buff, "UTF-16BE", "UTF-8"));
} | [
"protected",
"function",
"readBinaryUnicodeString",
"(",
"$",
"length",
")",
"{",
"/* The problem is: we get the length of the string IN CHARACTERS;\n since a char in UTF-16 can be 16 or 32 bit long, we don't really know\n how long the string is in bytes */",
"if",
"(",
"strlen... | Read a unicode string value, coded as UTF-16BE
@param integer $length The length (in bytes) of the string value
@return CFString The string value, utf8 encoded
@throws IOException if read error occurs | [
"Read",
"a",
"unicode",
"string",
"value",
"coded",
"as",
"UTF",
"-",
"16BE"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L395-L409 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryArray | protected function readBinaryArray($length)
{
$ary = new CFArray();
// first: read object refs
if ($length != 0) {
if (strlen($buff = substr($this->content, $this->pos, $length * $this->objectRefSize)) != $length * $this->objectRefSize) {
throw IOException::readError("");
}
$this->pos += $length * $this->objectRefSize;
$objects = self::unpackWithSize($this->objectRefSize, $buff);
// now: read objects
for ($i=0; $i<$length; ++$i) {
$object = $this->readBinaryObjectAt($objects[$i+1]+1);
$ary->add($object);
}
}
return $ary;
} | php | protected function readBinaryArray($length)
{
$ary = new CFArray();
// first: read object refs
if ($length != 0) {
if (strlen($buff = substr($this->content, $this->pos, $length * $this->objectRefSize)) != $length * $this->objectRefSize) {
throw IOException::readError("");
}
$this->pos += $length * $this->objectRefSize;
$objects = self::unpackWithSize($this->objectRefSize, $buff);
// now: read objects
for ($i=0; $i<$length; ++$i) {
$object = $this->readBinaryObjectAt($objects[$i+1]+1);
$ary->add($object);
}
}
return $ary;
} | [
"protected",
"function",
"readBinaryArray",
"(",
"$",
"length",
")",
"{",
"$",
"ary",
"=",
"new",
"CFArray",
"(",
")",
";",
"// first: read object refs",
"if",
"(",
"$",
"length",
"!=",
"0",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"buff",
"=",
"substr... | Read an array value, including contained objects
@param integer $length The number of contained objects
@return CFArray The array value, including the objects
@throws IOException if read error occurs | [
"Read",
"an",
"array",
"value",
"including",
"contained",
"objects"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L417-L438 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryDict | protected function readBinaryDict($length)
{
$dict = new CFDictionary();
// first: read keys
if ($length != 0) {
if (strlen($buff = substr($this->content, $this->pos, $length * $this->objectRefSize)) != $length * $this->objectRefSize) {
throw IOException::readError("");
}
$this->pos += $length * $this->objectRefSize;
$keys = self::unpackWithSize($this->objectRefSize, $buff);
// second: read object refs
if (strlen($buff = substr($this->content, $this->pos, $length * $this->objectRefSize)) != $length * $this->objectRefSize) {
throw IOException::readError("");
}
$this->pos += $length * $this->objectRefSize;
$objects = self::unpackWithSize($this->objectRefSize, $buff);
// read real keys and objects
for ($i=0; $i<$length; ++$i) {
$key = $this->readBinaryObjectAt($keys[$i+1]+1);
$object = $this->readBinaryObjectAt($objects[$i+1]+1);
$dict->add($key->getValue(), $object);
}
}
return $dict;
} | php | protected function readBinaryDict($length)
{
$dict = new CFDictionary();
// first: read keys
if ($length != 0) {
if (strlen($buff = substr($this->content, $this->pos, $length * $this->objectRefSize)) != $length * $this->objectRefSize) {
throw IOException::readError("");
}
$this->pos += $length * $this->objectRefSize;
$keys = self::unpackWithSize($this->objectRefSize, $buff);
// second: read object refs
if (strlen($buff = substr($this->content, $this->pos, $length * $this->objectRefSize)) != $length * $this->objectRefSize) {
throw IOException::readError("");
}
$this->pos += $length * $this->objectRefSize;
$objects = self::unpackWithSize($this->objectRefSize, $buff);
// read real keys and objects
for ($i=0; $i<$length; ++$i) {
$key = $this->readBinaryObjectAt($keys[$i+1]+1);
$object = $this->readBinaryObjectAt($objects[$i+1]+1);
$dict->add($key->getValue(), $object);
}
}
return $dict;
} | [
"protected",
"function",
"readBinaryDict",
"(",
"$",
"length",
")",
"{",
"$",
"dict",
"=",
"new",
"CFDictionary",
"(",
")",
";",
"// first: read keys",
"if",
"(",
"$",
"length",
"!=",
"0",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"buff",
"=",
"substr",... | Read a dictionary value, including contained objects
@param integer $length The number of contained objects
@return CFDictionary The dictionary value, including the objects
@throws IOException if read error occurs | [
"Read",
"a",
"dictionary",
"value",
"including",
"contained",
"objects"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L446-L474 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryObject | public function readBinaryObject()
{
// first: read the marker byte
if (strlen($buff = substr($this->content, $this->pos, 1)) != 1) {
throw IOException::readError("");
}
$this->pos++;
$object_length = unpack("C*", $buff);
$object_length = $object_length[1] & 0xF;
$buff = unpack("H*", $buff);
$buff = $buff[1];
$object_type = substr($buff, 0, 1);
if ($object_type != "0" && $object_length == 15) {
$object_length = $this->readBinaryObject();
$object_length = $object_length->getValue();
}
$retval = null;
switch ($object_type) {
case '0': // null, false, true, fillbyte
$retval = $this->readBinaryNullType($object_length);
break;
case '1': // integer
$retval = $this->readBinaryInt($object_length);
break;
case '2': // real
$retval = $this->readBinaryReal($object_length);
break;
case '3': // date
$retval = $this->readBinaryDate($object_length);
break;
case '4': // data
$retval = $this->readBinaryData($object_length);
break;
case '5': // byte string, usually utf8 encoded
$retval = $this->readBinaryString($object_length);
break;
case '6': // unicode string (utf16be)
$retval = $this->readBinaryUnicodeString($object_length);
break;
case '8':
$num = $this->readBinaryInt($object_length);
$retval = new CFUid($num->getValue());
break;
case 'a': // array
$retval = $this->readBinaryArray($object_length);
break;
case 'd': // dictionary
$retval = $this->readBinaryDict($object_length);
break;
}
return $retval;
} | php | public function readBinaryObject()
{
// first: read the marker byte
if (strlen($buff = substr($this->content, $this->pos, 1)) != 1) {
throw IOException::readError("");
}
$this->pos++;
$object_length = unpack("C*", $buff);
$object_length = $object_length[1] & 0xF;
$buff = unpack("H*", $buff);
$buff = $buff[1];
$object_type = substr($buff, 0, 1);
if ($object_type != "0" && $object_length == 15) {
$object_length = $this->readBinaryObject();
$object_length = $object_length->getValue();
}
$retval = null;
switch ($object_type) {
case '0': // null, false, true, fillbyte
$retval = $this->readBinaryNullType($object_length);
break;
case '1': // integer
$retval = $this->readBinaryInt($object_length);
break;
case '2': // real
$retval = $this->readBinaryReal($object_length);
break;
case '3': // date
$retval = $this->readBinaryDate($object_length);
break;
case '4': // data
$retval = $this->readBinaryData($object_length);
break;
case '5': // byte string, usually utf8 encoded
$retval = $this->readBinaryString($object_length);
break;
case '6': // unicode string (utf16be)
$retval = $this->readBinaryUnicodeString($object_length);
break;
case '8':
$num = $this->readBinaryInt($object_length);
$retval = new CFUid($num->getValue());
break;
case 'a': // array
$retval = $this->readBinaryArray($object_length);
break;
case 'd': // dictionary
$retval = $this->readBinaryDict($object_length);
break;
}
return $retval;
} | [
"public",
"function",
"readBinaryObject",
"(",
")",
"{",
"// first: read the marker byte",
"if",
"(",
"strlen",
"(",
"$",
"buff",
"=",
"substr",
"(",
"$",
"this",
"->",
"content",
",",
"$",
"this",
"->",
"pos",
",",
"1",
")",
")",
"!=",
"1",
")",
"{",
... | Read an object type byte, decode it and delegate to the correct reader function
@return mixed The value of the delegate reader, so any of the CFType subclasses
@throws IOException if read error occurs | [
"Read",
"an",
"object",
"type",
"byte",
"decode",
"it",
"and",
"delegate",
"to",
"the",
"correct",
"reader",
"function"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L481-L536 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.parseBinaryString | public function parseBinaryString()
{
$this->uniqueTable = array();
$this->countObjects = 0;
$this->stringSize = 0;
$this->intSize = 0;
$this->miscSize = 0;
$this->objectRefs = 0;
$this->writtenObjectCount = 0;
$this->objectTable = array();
$this->objectRefSize = 0;
$this->offsets = array();
// first, we read the trailer: 32 byte from the end
$buff = substr($this->content, -32);
if (strlen($buff) < 32) {
throw new PListException('Error in PList format: content is less than at least necessary 32 bytes!');
}
$infos = unpack("x6/Coffset_size/Cobject_ref_size/x4/Nnumber_of_objects/x4/Ntop_object/x4/Ntable_offset", $buff);
// after that, get the offset table
$coded_offset_table = substr($this->content, $infos['table_offset'], $infos['number_of_objects'] * $infos['offset_size']);
if (strlen($coded_offset_table) != $infos['number_of_objects'] * $infos['offset_size']) {
throw IOException::readError("");
}
$this->countObjects = $infos['number_of_objects'];
// decode offset table
$formats = array("","C*","n*",null,"N*");
if ($infos['offset_size'] == 3) {
/* since PHP does not support parenthesis in pack/unpack expressions,
"(H6)*" does not work and we have to work round this by repeating the
expression as often as it fits in the string
*/
$this->offsets = array(null);
while ($coded_offset_table) {
$str = unpack("H6", $coded_offset_table);
$this->offsets[] = hexdec($str[1]);
$coded_offset_table = substr($coded_offset_table, 3);
}
} else {
$this->offsets = unpack($formats[$infos['offset_size']], $coded_offset_table);
}
$this->uniqueTable = array();
$this->objectRefSize = $infos['object_ref_size'];
$top = $this->readBinaryObjectAt($infos['top_object']+1);
$this->add($top);
} | php | public function parseBinaryString()
{
$this->uniqueTable = array();
$this->countObjects = 0;
$this->stringSize = 0;
$this->intSize = 0;
$this->miscSize = 0;
$this->objectRefs = 0;
$this->writtenObjectCount = 0;
$this->objectTable = array();
$this->objectRefSize = 0;
$this->offsets = array();
// first, we read the trailer: 32 byte from the end
$buff = substr($this->content, -32);
if (strlen($buff) < 32) {
throw new PListException('Error in PList format: content is less than at least necessary 32 bytes!');
}
$infos = unpack("x6/Coffset_size/Cobject_ref_size/x4/Nnumber_of_objects/x4/Ntop_object/x4/Ntable_offset", $buff);
// after that, get the offset table
$coded_offset_table = substr($this->content, $infos['table_offset'], $infos['number_of_objects'] * $infos['offset_size']);
if (strlen($coded_offset_table) != $infos['number_of_objects'] * $infos['offset_size']) {
throw IOException::readError("");
}
$this->countObjects = $infos['number_of_objects'];
// decode offset table
$formats = array("","C*","n*",null,"N*");
if ($infos['offset_size'] == 3) {
/* since PHP does not support parenthesis in pack/unpack expressions,
"(H6)*" does not work and we have to work round this by repeating the
expression as often as it fits in the string
*/
$this->offsets = array(null);
while ($coded_offset_table) {
$str = unpack("H6", $coded_offset_table);
$this->offsets[] = hexdec($str[1]);
$coded_offset_table = substr($coded_offset_table, 3);
}
} else {
$this->offsets = unpack($formats[$infos['offset_size']], $coded_offset_table);
}
$this->uniqueTable = array();
$this->objectRefSize = $infos['object_ref_size'];
$top = $this->readBinaryObjectAt($infos['top_object']+1);
$this->add($top);
} | [
"public",
"function",
"parseBinaryString",
"(",
")",
"{",
"$",
"this",
"->",
"uniqueTable",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"countObjects",
"=",
"0",
";",
"$",
"this",
"->",
"stringSize",
"=",
"0",
";",
"$",
"this",
"->",
"intSize",
"... | Parse a binary plist string
@return void
@throws IOException if read error occurs | [
"Parse",
"a",
"binary",
"plist",
"string"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L554-L607 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinaryStream | public function readBinaryStream($stream)
{
if (($str = stream_get_contents($stream)) === false || empty($str)) {
throw new PListException("Error reading stream!");
}
$this->parseBinary($str);
} | php | public function readBinaryStream($stream)
{
if (($str = stream_get_contents($stream)) === false || empty($str)) {
throw new PListException("Error reading stream!");
}
$this->parseBinary($str);
} | [
"public",
"function",
"readBinaryStream",
"(",
"$",
"stream",
")",
"{",
"if",
"(",
"(",
"$",
"str",
"=",
"stream_get_contents",
"(",
"$",
"stream",
")",
")",
"===",
"false",
"||",
"empty",
"(",
"$",
"str",
")",
")",
"{",
"throw",
"new",
"PListException... | Read a binary plist stream
@param resource $stream The stream to read
@return void
@throws IOException if read error occurs | [
"Read",
"a",
"binary",
"plist",
"stream"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L615-L622 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.parseBinary | public function parseBinary($content = null)
{
if ($content !== null) {
$this->content = $content;
}
if (empty($this->content)) {
throw new PListException("Content may not be empty!");
}
if (substr($this->content, 0, 8) != 'bplist00') {
throw new PListException("Invalid binary string!");
}
$this->pos = 0;
$this->parseBinaryString();
} | php | public function parseBinary($content = null)
{
if ($content !== null) {
$this->content = $content;
}
if (empty($this->content)) {
throw new PListException("Content may not be empty!");
}
if (substr($this->content, 0, 8) != 'bplist00') {
throw new PListException("Invalid binary string!");
}
$this->pos = 0;
$this->parseBinaryString();
} | [
"public",
"function",
"parseBinary",
"(",
"$",
"content",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"content",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"$",
"content",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"content",... | parse a binary plist string
@param string $content The stream to read, defaults to {@link $this->content}
@return void
@throws IOException if read error occurs | [
"parse",
"a",
"binary",
"plist",
"string"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L630-L647 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.readBinary | public function readBinary($file)
{
if (!($fd = fopen($file, "rb"))) {
throw new IOException("Could not open file {$file}!");
}
$this->readBinaryStream($fd);
fclose($fd);
} | php | public function readBinary($file)
{
if (!($fd = fopen($file, "rb"))) {
throw new IOException("Could not open file {$file}!");
}
$this->readBinaryStream($fd);
fclose($fd);
} | [
"public",
"function",
"readBinary",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"fd",
"=",
"fopen",
"(",
"$",
"file",
",",
"\"rb\"",
")",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not open file {$file}!\"",
")",
";",
"}",
... | Read a binary plist file
@param string $file The file to read
@return void
@throws IOException if read error occurs | [
"Read",
"a",
"binary",
"plist",
"file"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L655-L663 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.bytesSizeInt | public static function bytesSizeInt($int)
{
$nbytes = 0;
if ($int > 0xE) {
$nbytes += 2; // 2 size-bytes
}
if ($int > 0xFF) {
$nbytes += 1; // 3 size-bytes
}
if ($int > 0xFFFF) {
$nbytes += 2; // 5 size-bytes
}
return $nbytes;
} | php | public static function bytesSizeInt($int)
{
$nbytes = 0;
if ($int > 0xE) {
$nbytes += 2; // 2 size-bytes
}
if ($int > 0xFF) {
$nbytes += 1; // 3 size-bytes
}
if ($int > 0xFFFF) {
$nbytes += 2; // 5 size-bytes
}
return $nbytes;
} | [
"public",
"static",
"function",
"bytesSizeInt",
"(",
"$",
"int",
")",
"{",
"$",
"nbytes",
"=",
"0",
";",
"if",
"(",
"$",
"int",
">",
"0xE",
")",
"{",
"$",
"nbytes",
"+=",
"2",
";",
"// 2 size-bytes",
"}",
"if",
"(",
"$",
"int",
">",
"0xFF",
")",
... | calculate the bytes needed for a size integer value
@param integer $int The integer value to calculate
@return integer The number of bytes needed | [
"calculate",
"the",
"bytes",
"needed",
"for",
"a",
"size",
"integer",
"value"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L670-L685 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.intBytes | public static function intBytes($int)
{
$intbytes = "";
if ($int > 0xFFFF) {
$intbytes = "\x12".pack("N", $int); // 4 byte integer
} elseif ($int > 0xFF) {
$intbytes = "\x11".pack("n", $int); // 2 byte integer
} else {
$intbytes = "\x10".pack("C", $int); // 8 byte integer
}
return $intbytes;
} | php | public static function intBytes($int)
{
$intbytes = "";
if ($int > 0xFFFF) {
$intbytes = "\x12".pack("N", $int); // 4 byte integer
} elseif ($int > 0xFF) {
$intbytes = "\x11".pack("n", $int); // 2 byte integer
} else {
$intbytes = "\x10".pack("C", $int); // 8 byte integer
}
return $intbytes;
} | [
"public",
"static",
"function",
"intBytes",
"(",
"$",
"int",
")",
"{",
"$",
"intbytes",
"=",
"\"\"",
";",
"if",
"(",
"$",
"int",
">",
"0xFFFF",
")",
"{",
"$",
"intbytes",
"=",
"\"\\x12\"",
".",
"pack",
"(",
"\"N\"",
",",
"$",
"int",
")",
";",
"//... | Code an integer to byte representation
@param integer $int The integer value
@return string The packed byte value | [
"Code",
"an",
"integer",
"to",
"byte",
"representation"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L768-L781 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.typeBytes | public static function typeBytes($type, $type_len)
{
$optional_int = "";
if ($type_len < 15) {
$type .= sprintf("%x", $type_len);
} else {
$type .= "f";
$optional_int = self::intBytes($type_len);
}
return pack("H*", $type).$optional_int;
} | php | public static function typeBytes($type, $type_len)
{
$optional_int = "";
if ($type_len < 15) {
$type .= sprintf("%x", $type_len);
} else {
$type .= "f";
$optional_int = self::intBytes($type_len);
}
return pack("H*", $type).$optional_int;
} | [
"public",
"static",
"function",
"typeBytes",
"(",
"$",
"type",
",",
"$",
"type_len",
")",
"{",
"$",
"optional_int",
"=",
"\"\"",
";",
"if",
"(",
"$",
"type_len",
"<",
"15",
")",
"{",
"$",
"type",
".=",
"sprintf",
"(",
"\"%x\"",
",",
"$",
"type_len",
... | Code an type byte, consisting of the type marker and the length of the type
@param string $type The type byte value (i.e. "d" for dictionaries)
@param integer $type_len The length of the type
@return string The packed type byte value | [
"Code",
"an",
"type",
"byte",
"consisting",
"of",
"the",
"type",
"marker",
"and",
"the",
"length",
"of",
"the",
"type"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L789-L801 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.uniqueAndCountValues | protected function uniqueAndCountValues($value)
{
// no uniquing for other types than CFString and CFData
if ($value instanceof CFNumber) {
$val = $value->getValue();
if (intval($val) == $val && !is_float($val) && strpos($val, '.') === false) {
$this->intSize += self::bytesInt($val);
} else {
$this->miscSize += 9; // 9 bytes (8 + marker byte) for real
}
$this->countObjects++;
return;
} elseif ($value instanceof CFDate) {
$this->miscSize += 9; // since date in plist is real, we need 9 byte (8 + marker byte)
$this->countObjects++;
return;
} elseif ($value instanceof CFBoolean) {
$this->countObjects++;
$this->miscSize += 1;
return;
} elseif ($value instanceof CFArray) {
$cnt = 0;
foreach ($value as $v) {
++$cnt;
$this->uniqueAndCountValues($v);
$this->objectRefs++; // each array member is a ref
}
$this->countObjects++;
$this->intSize += self::bytesSizeInt($cnt);
$this->miscSize++; // marker byte for array
return;
} elseif ($value instanceof CFDictionary) {
$cnt = 0;
foreach ($value as $k => $v) {
++$cnt;
if (!isset($this->uniqueTable[$k])) {
$this->uniqueTable[$k] = 0;
$len = self::binaryStrlen($k);
$this->stringSize += $len + 1;
$this->intSize += self::bytesSizeInt(self::charsetStrlen($k, 'UTF-8'));
}
$this->objectRefs += 2; // both, key and value, are refs
$this->uniqueTable[$k]++;
$this->uniqueAndCountValues($v);
}
$this->countObjects++;
$this->miscSize++; // marker byte for dict
$this->intSize += self::bytesSizeInt($cnt);
return;
} elseif ($value instanceof CFData) {
$val = $value->getValue();
$len = strlen($val);
$this->intSize += self::bytesSizeInt($len);
$this->miscSize += $len + 1;
$this->countObjects++;
return;
} else {
$val = $value->getValue();
}
if (!isset($this->uniqueTable[$val])) {
$this->uniqueTable[$val] = 0;
$len = self::binaryStrlen($val);
$this->stringSize += $len + 1;
$this->intSize += self::bytesSizeInt(self::charsetStrlen($val, 'UTF-8'));
}
$this->uniqueTable[$val]++;
} | php | protected function uniqueAndCountValues($value)
{
// no uniquing for other types than CFString and CFData
if ($value instanceof CFNumber) {
$val = $value->getValue();
if (intval($val) == $val && !is_float($val) && strpos($val, '.') === false) {
$this->intSize += self::bytesInt($val);
} else {
$this->miscSize += 9; // 9 bytes (8 + marker byte) for real
}
$this->countObjects++;
return;
} elseif ($value instanceof CFDate) {
$this->miscSize += 9; // since date in plist is real, we need 9 byte (8 + marker byte)
$this->countObjects++;
return;
} elseif ($value instanceof CFBoolean) {
$this->countObjects++;
$this->miscSize += 1;
return;
} elseif ($value instanceof CFArray) {
$cnt = 0;
foreach ($value as $v) {
++$cnt;
$this->uniqueAndCountValues($v);
$this->objectRefs++; // each array member is a ref
}
$this->countObjects++;
$this->intSize += self::bytesSizeInt($cnt);
$this->miscSize++; // marker byte for array
return;
} elseif ($value instanceof CFDictionary) {
$cnt = 0;
foreach ($value as $k => $v) {
++$cnt;
if (!isset($this->uniqueTable[$k])) {
$this->uniqueTable[$k] = 0;
$len = self::binaryStrlen($k);
$this->stringSize += $len + 1;
$this->intSize += self::bytesSizeInt(self::charsetStrlen($k, 'UTF-8'));
}
$this->objectRefs += 2; // both, key and value, are refs
$this->uniqueTable[$k]++;
$this->uniqueAndCountValues($v);
}
$this->countObjects++;
$this->miscSize++; // marker byte for dict
$this->intSize += self::bytesSizeInt($cnt);
return;
} elseif ($value instanceof CFData) {
$val = $value->getValue();
$len = strlen($val);
$this->intSize += self::bytesSizeInt($len);
$this->miscSize += $len + 1;
$this->countObjects++;
return;
} else {
$val = $value->getValue();
}
if (!isset($this->uniqueTable[$val])) {
$this->uniqueTable[$val] = 0;
$len = self::binaryStrlen($val);
$this->stringSize += $len + 1;
$this->intSize += self::bytesSizeInt(self::charsetStrlen($val, 'UTF-8'));
}
$this->uniqueTable[$val]++;
} | [
"protected",
"function",
"uniqueAndCountValues",
"(",
"$",
"value",
")",
"{",
"// no uniquing for other types than CFString and CFData",
"if",
"(",
"$",
"value",
"instanceof",
"CFNumber",
")",
"{",
"$",
"val",
"=",
"$",
"value",
"->",
"getValue",
"(",
")",
";",
... | Count number of objects and create a unique table for strings
@param $value The value to count and unique
@return void | [
"Count",
"number",
"of",
"objects",
"and",
"create",
"a",
"unique",
"table",
"for",
"strings"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L808-L878 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.toBinary | public function toBinary()
{
$this->uniqueTable = array();
$this->countObjects = 0;
$this->stringSize = 0;
$this->intSize = 0;
$this->miscSize = 0;
$this->objectRefs = 0;
$this->writtenObjectCount = 0;
$this->objectTable = array();
$this->objectRefSize = 0;
$this->offsets = array();
$binary_str = "bplist00";
$value = $this->getValue(true);
$this->uniqueAndCountValues($value);
$this->countObjects += count($this->uniqueTable);
$this->objectRefSize = self::bytesNeeded($this->countObjects);
$file_size = $this->stringSize + $this->intSize + $this->miscSize + $this->objectRefs * $this->objectRefSize + 40;
$offset_size = self::bytesNeeded($file_size);
$table_offset = $file_size - 32;
$this->objectTable = array();
$this->writtenObjectCount = 0;
$this->uniqueTable = array(); // we needed it to calculate several values
$value->toBinary($this);
$object_offset = 8;
$offsets = array();
for ($i=0; $i<count($this->objectTable); ++$i) {
$binary_str .= $this->objectTable[$i];
$offsets[$i] = $object_offset;
$object_offset += strlen($this->objectTable[$i]);
}
for ($i=0; $i<count($offsets); ++$i) {
$binary_str .= self::packItWithSize($offset_size, $offsets[$i]);
}
$binary_str .= pack("x6CC", $offset_size, $this->objectRefSize);
$binary_str .= pack("x4N", $this->countObjects);
$binary_str .= pack("x4N", 0);
$binary_str .= pack("x4N", $table_offset);
return $binary_str;
} | php | public function toBinary()
{
$this->uniqueTable = array();
$this->countObjects = 0;
$this->stringSize = 0;
$this->intSize = 0;
$this->miscSize = 0;
$this->objectRefs = 0;
$this->writtenObjectCount = 0;
$this->objectTable = array();
$this->objectRefSize = 0;
$this->offsets = array();
$binary_str = "bplist00";
$value = $this->getValue(true);
$this->uniqueAndCountValues($value);
$this->countObjects += count($this->uniqueTable);
$this->objectRefSize = self::bytesNeeded($this->countObjects);
$file_size = $this->stringSize + $this->intSize + $this->miscSize + $this->objectRefs * $this->objectRefSize + 40;
$offset_size = self::bytesNeeded($file_size);
$table_offset = $file_size - 32;
$this->objectTable = array();
$this->writtenObjectCount = 0;
$this->uniqueTable = array(); // we needed it to calculate several values
$value->toBinary($this);
$object_offset = 8;
$offsets = array();
for ($i=0; $i<count($this->objectTable); ++$i) {
$binary_str .= $this->objectTable[$i];
$offsets[$i] = $object_offset;
$object_offset += strlen($this->objectTable[$i]);
}
for ($i=0; $i<count($offsets); ++$i) {
$binary_str .= self::packItWithSize($offset_size, $offsets[$i]);
}
$binary_str .= pack("x6CC", $offset_size, $this->objectRefSize);
$binary_str .= pack("x4N", $this->countObjects);
$binary_str .= pack("x4N", 0);
$binary_str .= pack("x4N", $table_offset);
return $binary_str;
} | [
"public",
"function",
"toBinary",
"(",
")",
"{",
"$",
"this",
"->",
"uniqueTable",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"countObjects",
"=",
"0",
";",
"$",
"this",
"->",
"stringSize",
"=",
"0",
";",
"$",
"this",
"->",
"intSize",
"=",
"0"... | Convert CFPropertyList to binary format; since we have to count our objects we simply unique CFDictionary and CFArray
@return string The binary plist content | [
"Convert",
"CFPropertyList",
"to",
"binary",
"format",
";",
"since",
"we",
"have",
"to",
"count",
"our",
"objects",
"we",
"simply",
"unique",
"CFDictionary",
"and",
"CFArray"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L884-L934 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.binaryStrlen | protected static function binaryStrlen($val)
{
for ($i=0; $i<strlen($val); ++$i) {
if (ord($val{$i}) >= 128) {
$val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
return strlen($val);
}
}
return strlen($val);
} | php | protected static function binaryStrlen($val)
{
for ($i=0; $i<strlen($val); ++$i) {
if (ord($val{$i}) >= 128) {
$val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
return strlen($val);
}
}
return strlen($val);
} | [
"protected",
"static",
"function",
"binaryStrlen",
"(",
"$",
"val",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"val",
")",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"ord",
"(",
"$",
"val",
"{",
"$",
"i... | Counts the number of bytes the string will have when coded; utf-16be if non-ascii characters are present.
@param string $val The string value
@return integer The length of the coded string in bytes | [
"Counts",
"the",
"number",
"of",
"bytes",
"the",
"string",
"will",
"have",
"when",
"coded",
";",
"utf",
"-",
"16be",
"if",
"non",
"-",
"ascii",
"characters",
"are",
"present",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L941-L951 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.stringToBinary | public function stringToBinary($val)
{
$saved_object_count = -1;
if (!isset($this->uniqueTable[$val])) {
$saved_object_count = $this->writtenObjectCount++;
$this->uniqueTable[$val] = $saved_object_count;
$utf16 = false;
for ($i=0; $i<strlen($val); ++$i) {
if (ord($val{$i}) >= 128) {
$utf16 = true;
break;
}
}
if ($utf16) {
$bdata = self::typeBytes("6", mb_strlen($val, 'UTF-8')); // 6 is 0110, unicode string (utf16be)
$val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
$this->objectTable[$saved_object_count] = $bdata.$val;
} else {
$bdata = self::typeBytes("5", strlen($val)); // 5 is 0101 which is an ASCII string (seems to be ASCII encoded)
$this->objectTable[$saved_object_count] = $bdata.$val;
}
} else {
$saved_object_count = $this->uniqueTable[$val];
}
return $saved_object_count;
} | php | public function stringToBinary($val)
{
$saved_object_count = -1;
if (!isset($this->uniqueTable[$val])) {
$saved_object_count = $this->writtenObjectCount++;
$this->uniqueTable[$val] = $saved_object_count;
$utf16 = false;
for ($i=0; $i<strlen($val); ++$i) {
if (ord($val{$i}) >= 128) {
$utf16 = true;
break;
}
}
if ($utf16) {
$bdata = self::typeBytes("6", mb_strlen($val, 'UTF-8')); // 6 is 0110, unicode string (utf16be)
$val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
$this->objectTable[$saved_object_count] = $bdata.$val;
} else {
$bdata = self::typeBytes("5", strlen($val)); // 5 is 0101 which is an ASCII string (seems to be ASCII encoded)
$this->objectTable[$saved_object_count] = $bdata.$val;
}
} else {
$saved_object_count = $this->uniqueTable[$val];
}
return $saved_object_count;
} | [
"public",
"function",
"stringToBinary",
"(",
"$",
"val",
")",
"{",
"$",
"saved_object_count",
"=",
"-",
"1",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"uniqueTable",
"[",
"$",
"val",
"]",
")",
")",
"{",
"$",
"saved_object_count",
"=",
"$"... | Uniques and transforms a string value to binary format and adds it to the object table
@param string $val The string value
@return integer The position in the object table | [
"Uniques",
"and",
"transforms",
"a",
"string",
"value",
"to",
"binary",
"format",
"and",
"adds",
"it",
"to",
"the",
"object",
"table"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L958-L987 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.intToBinary | protected function intToBinary($value)
{
$nbytes = 0;
if ($value > 0xFF) {
$nbytes = 1; // 1 byte integer
}
if ($value > 0xFFFF) {
$nbytes += 1; // 4 byte integer
}
if ($value > 0xFFFFFFFF) {
$nbytes += 1; // 8 byte integer
}
if ($value < 0) {
$nbytes = 3; // 8 byte integer, since signed
}
$bdata = self::typeBytes("1", $nbytes); // 1 is 0001, type indicator for integer
$buff = "";
if ($nbytes < 3) {
if ($nbytes == 0) {
$fmt = "C";
} elseif ($nbytes == 1) {
$fmt = "n";
} else {
$fmt = "N";
}
$buff = pack($fmt, $value);
} else {
if (PHP_INT_SIZE > 4) {
// 64 bit signed integer; we need the higher and the lower 32 bit of the value
$high_word = $value >> 32;
$low_word = $value & 0xFFFFFFFF;
} else {
// since PHP can only handle 32bit signed, we can only get 32bit signed values at this point - values above 0x7FFFFFFF are
// floats. So we ignore the existance of 64bit on non-64bit-machines
if ($value < 0) {
$high_word = 0xFFFFFFFF;
} else {
$high_word = 0;
}
$low_word = $value;
}
$buff = pack("N", $high_word).pack("N", $low_word);
}
return $bdata.$buff;
} | php | protected function intToBinary($value)
{
$nbytes = 0;
if ($value > 0xFF) {
$nbytes = 1; // 1 byte integer
}
if ($value > 0xFFFF) {
$nbytes += 1; // 4 byte integer
}
if ($value > 0xFFFFFFFF) {
$nbytes += 1; // 8 byte integer
}
if ($value < 0) {
$nbytes = 3; // 8 byte integer, since signed
}
$bdata = self::typeBytes("1", $nbytes); // 1 is 0001, type indicator for integer
$buff = "";
if ($nbytes < 3) {
if ($nbytes == 0) {
$fmt = "C";
} elseif ($nbytes == 1) {
$fmt = "n";
} else {
$fmt = "N";
}
$buff = pack($fmt, $value);
} else {
if (PHP_INT_SIZE > 4) {
// 64 bit signed integer; we need the higher and the lower 32 bit of the value
$high_word = $value >> 32;
$low_word = $value & 0xFFFFFFFF;
} else {
// since PHP can only handle 32bit signed, we can only get 32bit signed values at this point - values above 0x7FFFFFFF are
// floats. So we ignore the existance of 64bit on non-64bit-machines
if ($value < 0) {
$high_word = 0xFFFFFFFF;
} else {
$high_word = 0;
}
$low_word = $value;
}
$buff = pack("N", $high_word).pack("N", $low_word);
}
return $bdata.$buff;
} | [
"protected",
"function",
"intToBinary",
"(",
"$",
"value",
")",
"{",
"$",
"nbytes",
"=",
"0",
";",
"if",
"(",
"$",
"value",
">",
"0xFF",
")",
"{",
"$",
"nbytes",
"=",
"1",
";",
"// 1 byte integer",
"}",
"if",
"(",
"$",
"value",
">",
"0xFFFF",
")",
... | Codes an integer to binary format
@param integer $value The integer value
@return string the coded integer | [
"Codes",
"an",
"integer",
"to",
"binary",
"format"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L994-L1042 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.realToBinary | protected function realToBinary($val)
{
$bdata = self::typeBytes("2", 3); // 2 is 0010, type indicator for reals
return $bdata.strrev(pack("d", (float)$val));
} | php | protected function realToBinary($val)
{
$bdata = self::typeBytes("2", 3); // 2 is 0010, type indicator for reals
return $bdata.strrev(pack("d", (float)$val));
} | [
"protected",
"function",
"realToBinary",
"(",
"$",
"val",
")",
"{",
"$",
"bdata",
"=",
"self",
"::",
"typeBytes",
"(",
"\"2\"",
",",
"3",
")",
";",
"// 2 is 0010, type indicator for reals",
"return",
"$",
"bdata",
".",
"strrev",
"(",
"pack",
"(",
"\"d\"",
... | Codes a real value to binary format
@param float $val The real value
@return string The coded real | [
"Codes",
"a",
"real",
"value",
"to",
"binary",
"format"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L1049-L1053 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.numToBinary | public function numToBinary($value)
{
$saved_object_count = $this->writtenObjectCount++;
$val = "";
if (intval($value) == $value && !is_float($value) && strpos($value, '.') === false) {
$val = $this->intToBinary($value);
} else {
$val = $this->realToBinary($value);
}
$this->objectTable[$saved_object_count] = $val;
return $saved_object_count;
} | php | public function numToBinary($value)
{
$saved_object_count = $this->writtenObjectCount++;
$val = "";
if (intval($value) == $value && !is_float($value) && strpos($value, '.') === false) {
$val = $this->intToBinary($value);
} else {
$val = $this->realToBinary($value);
}
$this->objectTable[$saved_object_count] = $val;
return $saved_object_count;
} | [
"public",
"function",
"numToBinary",
"(",
"$",
"value",
")",
"{",
"$",
"saved_object_count",
"=",
"$",
"this",
"->",
"writtenObjectCount",
"++",
";",
"$",
"val",
"=",
"\"\"",
";",
"if",
"(",
"intval",
"(",
"$",
"value",
")",
"==",
"$",
"value",
"&&",
... | Converts a numeric value to binary and adds it to the object table
@param numeric $value The numeric value
@return integer The position in the object table | [
"Converts",
"a",
"numeric",
"value",
"to",
"binary",
"and",
"adds",
"it",
"to",
"the",
"object",
"table"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L1117-L1130 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.boolToBinary | public function boolToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$this->objectTable[$saved_object_count] = $val ? "\x9" : "\x8"; // 0x9 is 1001, type indicator for true; 0x8 is 1000, type indicator for false
return $saved_object_count;
} | php | public function boolToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$this->objectTable[$saved_object_count] = $val ? "\x9" : "\x8"; // 0x9 is 1001, type indicator for true; 0x8 is 1000, type indicator for false
return $saved_object_count;
} | [
"public",
"function",
"boolToBinary",
"(",
"$",
"val",
")",
"{",
"$",
"saved_object_count",
"=",
"$",
"this",
"->",
"writtenObjectCount",
"++",
";",
"$",
"this",
"->",
"objectTable",
"[",
"$",
"saved_object_count",
"]",
"=",
"$",
"val",
"?",
"\"\\x9\"",
":... | Convert a bool value to binary and add it to the object table
@param bool $val The boolean value
@return integer The position in the object table | [
"Convert",
"a",
"bool",
"value",
"to",
"binary",
"and",
"add",
"it",
"to",
"the",
"object",
"table"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L1161-L1166 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.dataToBinary | public function dataToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$bdata = self::typeBytes("4", strlen($val)); // a is 1000, type indicator for data
$this->objectTable[$saved_object_count] = $bdata.$val;
return $saved_object_count;
} | php | public function dataToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$bdata = self::typeBytes("4", strlen($val)); // a is 1000, type indicator for data
$this->objectTable[$saved_object_count] = $bdata.$val;
return $saved_object_count;
} | [
"public",
"function",
"dataToBinary",
"(",
"$",
"val",
")",
"{",
"$",
"saved_object_count",
"=",
"$",
"this",
"->",
"writtenObjectCount",
"++",
";",
"$",
"bdata",
"=",
"self",
"::",
"typeBytes",
"(",
"\"4\"",
",",
"strlen",
"(",
"$",
"val",
")",
")",
"... | Convert data value to binary format and add it to the object table
@param string $val The data value
@return integer The position in the object table | [
"Convert",
"data",
"value",
"to",
"binary",
"format",
"and",
"add",
"it",
"to",
"the",
"object",
"table"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L1173-L1181 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.arrayToBinary | public function arrayToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$bdata = self::typeBytes("a", count($val->getValue())); // a is 1010, type indicator for arrays
foreach ($val as $v) {
$bval = $v->toBinary($this);
$bdata .= self::packItWithSize($this->objectRefSize, $bval);
}
$this->objectTable[$saved_object_count] = $bdata;
return $saved_object_count;
} | php | public function arrayToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$bdata = self::typeBytes("a", count($val->getValue())); // a is 1010, type indicator for arrays
foreach ($val as $v) {
$bval = $v->toBinary($this);
$bdata .= self::packItWithSize($this->objectRefSize, $bval);
}
$this->objectTable[$saved_object_count] = $bdata;
return $saved_object_count;
} | [
"public",
"function",
"arrayToBinary",
"(",
"$",
"val",
")",
"{",
"$",
"saved_object_count",
"=",
"$",
"this",
"->",
"writtenObjectCount",
"++",
";",
"$",
"bdata",
"=",
"self",
"::",
"typeBytes",
"(",
"\"a\"",
",",
"count",
"(",
"$",
"val",
"->",
"getVal... | Convert array to binary format and add it to the object table
@param CFArray $val The array to convert
@return integer The position in the object table | [
"Convert",
"array",
"to",
"binary",
"format",
"and",
"add",
"it",
"to",
"the",
"object",
"table"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L1188-L1201 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFBinaryPropertyList.php | CFBinaryPropertyList.dictToBinary | public function dictToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$bdata = self::typeBytes("d", count($val->getValue())); // d=1101, type indicator for dictionary
foreach ($val as $k => $v) {
$str = new CFString($k);
$key = $str->toBinary($this);
$bdata .= self::packItWithSize($this->objectRefSize, $key);
}
foreach ($val as $k => $v) {
$bval = $v->toBinary($this);
$bdata .= self::packItWithSize($this->objectRefSize, $bval);
}
$this->objectTable[$saved_object_count] = $bdata;
return $saved_object_count;
} | php | public function dictToBinary($val)
{
$saved_object_count = $this->writtenObjectCount++;
$bdata = self::typeBytes("d", count($val->getValue())); // d=1101, type indicator for dictionary
foreach ($val as $k => $v) {
$str = new CFString($k);
$key = $str->toBinary($this);
$bdata .= self::packItWithSize($this->objectRefSize, $key);
}
foreach ($val as $k => $v) {
$bval = $v->toBinary($this);
$bdata .= self::packItWithSize($this->objectRefSize, $bval);
}
$this->objectTable[$saved_object_count] = $bdata;
return $saved_object_count;
} | [
"public",
"function",
"dictToBinary",
"(",
"$",
"val",
")",
"{",
"$",
"saved_object_count",
"=",
"$",
"this",
"->",
"writtenObjectCount",
"++",
";",
"$",
"bdata",
"=",
"self",
"::",
"typeBytes",
"(",
"\"d\"",
",",
"count",
"(",
"$",
"val",
"->",
"getValu... | Convert dictionary to binary format and add it to the object table
@param CFDictionary $val The dict to convert
@return integer The position in the object table | [
"Convert",
"dictionary",
"to",
"binary",
"format",
"and",
"add",
"it",
"to",
"the",
"object",
"table"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFBinaryPropertyList.php#L1208-L1226 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFDate.php | CFDate.setValue | public function setValue($value, $format = CFDate::TIMESTAMP_UNIX)
{
if ($format == CFDate::TIMESTAMP_UNIX) {
$this->value = $value;
} else {
$this->value = $value + CFDate::DATE_DIFF_APPLE_UNIX;
}
} | php | public function setValue($value, $format = CFDate::TIMESTAMP_UNIX)
{
if ($format == CFDate::TIMESTAMP_UNIX) {
$this->value = $value;
} else {
$this->value = $value + CFDate::DATE_DIFF_APPLE_UNIX;
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"format",
"=",
"CFDate",
"::",
"TIMESTAMP_UNIX",
")",
"{",
"if",
"(",
"$",
"format",
"==",
"CFDate",
"::",
"TIMESTAMP_UNIX",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
... | Set the Date CFType's value.
@param integer $value timestamp to set
@param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_UNIX}
@return void
@uses TIMESTAMP_APPLE to determine timestamp type
@uses TIMESTAMP_UNIX to determine timestamp type
@uses DATE_DIFF_APPLE_UNIX to convert Apple-timestamp to Unix-timestamp | [
"Set",
"the",
"Date",
"CFType",
"s",
"value",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFDate.php#L81-L88 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFDate.php | CFDate.getValue | public function getValue($format = CFDate::TIMESTAMP_UNIX)
{
if ($format == CFDate::TIMESTAMP_UNIX) {
return $this->value;
} else {
return $this->value - CFDate::DATE_DIFF_APPLE_UNIX;
}
} | php | public function getValue($format = CFDate::TIMESTAMP_UNIX)
{
if ($format == CFDate::TIMESTAMP_UNIX) {
return $this->value;
} else {
return $this->value - CFDate::DATE_DIFF_APPLE_UNIX;
}
} | [
"public",
"function",
"getValue",
"(",
"$",
"format",
"=",
"CFDate",
"::",
"TIMESTAMP_UNIX",
")",
"{",
"if",
"(",
"$",
"format",
"==",
"CFDate",
"::",
"TIMESTAMP_UNIX",
")",
"{",
"return",
"$",
"this",
"->",
"value",
";",
"}",
"else",
"{",
"return",
"$... | Get the Date CFType's value.
@param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_UNIX}
@return integer Unix timestamp
@uses TIMESTAMP_APPLE to determine timestamp type
@uses TIMESTAMP_UNIX to determine timestamp type
@uses DATE_DIFF_APPLE_UNIX to convert Unix-timestamp to Apple-timestamp | [
"Get",
"the",
"Date",
"CFType",
"s",
"value",
"."
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFDate.php#L98-L105 | train |
TECLIB/CFPropertyList | src/CFPropertyList/CFDate.php | CFDate.dateValue | public static function dateValue($val)
{
//2009-05-13T20:23:43Z
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/', $val, $matches)) {
throw new PListException("Unknown date format: $val");
}
return gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
} | php | public static function dateValue($val)
{
//2009-05-13T20:23:43Z
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/', $val, $matches)) {
throw new PListException("Unknown date format: $val");
}
return gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
} | [
"public",
"static",
"function",
"dateValue",
"(",
"$",
"val",
")",
"{",
"//2009-05-13T20:23:43Z",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})Z/'",
",",
"$",
"val",
",",
"$",
"matches",
")",
")",
"{",
"throw",
"new",... | Create a UNIX timestamp from a PList date string
@param string $val The date string (e.g. "2009-05-13T20:23:43Z")
@return integer The UNIX timestamp
@throws PListException when encountering an unknown date string format | [
"Create",
"a",
"UNIX",
"timestamp",
"from",
"a",
"PList",
"date",
"string"
] | 4da03c276479e20905e57837d53ba6912bab7394 | https://github.com/TECLIB/CFPropertyList/blob/4da03c276479e20905e57837d53ba6912bab7394/src/CFPropertyList/CFDate.php#L137-L144 | train |
FriendsOfCake/cakephp-csvview | src/View/CsvView.php | CsvView._setupViewVars | protected function _setupViewVars()
{
foreach ($this->_specialVars as $viewVar) {
if (!isset($this->viewVars[$viewVar])) {
$this->viewVars[$viewVar] = null;
}
}
if ($this->viewVars['_delimiter'] === null) {
$this->viewVars['_delimiter'] = ',';
}
if ($this->viewVars['_enclosure'] === null) {
$this->viewVars['_enclosure'] = '"';
}
if ($this->viewVars['_newline'] === null) {
$this->viewVars['_newline'] = "\n";
}
if ($this->viewVars['_eol'] === null) {
$this->viewVars['_eol'] = PHP_EOL;
}
if ($this->viewVars['_null'] === null) {
$this->viewVars['_null'] = '';
}
if ($this->viewVars['_bom'] === null) {
$this->viewVars['_bom'] = false;
}
if ($this->viewVars['_setSeparator'] === null) {
$this->viewVars['_setSeparator'] = false;
}
if ($this->viewVars['_dataEncoding'] === null) {
$this->viewVars['_dataEncoding'] = 'UTF-8';
}
if ($this->viewVars['_csvEncoding'] === null) {
$this->viewVars['_csvEncoding'] = 'UTF-8';
}
if ($this->viewVars['_extension'] === null) {
$this->viewVars['_extension'] = self::EXTENSION_ICONV;
}
if ($this->viewVars['_extract'] !== null) {
$this->viewVars['_extract'] = (array)$this->viewVars['_extract'];
}
} | php | protected function _setupViewVars()
{
foreach ($this->_specialVars as $viewVar) {
if (!isset($this->viewVars[$viewVar])) {
$this->viewVars[$viewVar] = null;
}
}
if ($this->viewVars['_delimiter'] === null) {
$this->viewVars['_delimiter'] = ',';
}
if ($this->viewVars['_enclosure'] === null) {
$this->viewVars['_enclosure'] = '"';
}
if ($this->viewVars['_newline'] === null) {
$this->viewVars['_newline'] = "\n";
}
if ($this->viewVars['_eol'] === null) {
$this->viewVars['_eol'] = PHP_EOL;
}
if ($this->viewVars['_null'] === null) {
$this->viewVars['_null'] = '';
}
if ($this->viewVars['_bom'] === null) {
$this->viewVars['_bom'] = false;
}
if ($this->viewVars['_setSeparator'] === null) {
$this->viewVars['_setSeparator'] = false;
}
if ($this->viewVars['_dataEncoding'] === null) {
$this->viewVars['_dataEncoding'] = 'UTF-8';
}
if ($this->viewVars['_csvEncoding'] === null) {
$this->viewVars['_csvEncoding'] = 'UTF-8';
}
if ($this->viewVars['_extension'] === null) {
$this->viewVars['_extension'] = self::EXTENSION_ICONV;
}
if ($this->viewVars['_extract'] !== null) {
$this->viewVars['_extract'] = (array)$this->viewVars['_extract'];
}
} | [
"protected",
"function",
"_setupViewVars",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_specialVars",
"as",
"$",
"viewVar",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"viewVars",
"[",
"$",
"viewVar",
"]",
")",
")",
"{",
"$",
... | Setup defaults for CsvView view variables
The following variables can be retrieved from '$this->viewVars'
for use in configuring this view:
- array '_header': (default null) A flat array of header column names
- array '_footer': (default null) A flat array of footer column names
- array '_extract': (default null) An array of Hash-compatible paths or
callable with matching 'sprintf'
$format as follows:
$_extract = [
[$path, $format],
[$path],
$path,
function () { ... } // Callable
];
If a string or unspecified, the format
default is '%s'.
- '_delimiter': (default ',') CSV Delimiter, defaults to comma
- '_enclosure': (default '"') CSV Enclosure for use with fputcsv()
- '_newline': (default '\n') CSV Newline replacement for use with fputcsv()
- '_eol': (default '\n') End-of-line character the csv
- '_bom': (default false) Adds BOM (byte order mark) header
- '_setSeparator: (default false) Adds sep=[_delimiter] in the first line
@return void | [
"Setup",
"defaults",
"for",
"CsvView",
"view",
"variables"
] | 3e17aea72fd3bf45260f7ca9c9c1c18956b4280e | https://github.com/FriendsOfCake/cakephp-csvview/blob/3e17aea72fd3bf45260f7ca9c9c1c18956b4280e/src/View/CsvView.php#L254-L305 | train |
FriendsOfCake/cakephp-csvview | src/View/CsvView.php | CsvView._renderContent | protected function _renderContent()
{
$extract = $this->viewVars['_extract'];
$serialize = $this->viewVars['_serialize'];
if ($serialize === true) {
$serialize = array_diff(
array_keys($this->viewVars),
$this->_specialVars
);
}
foreach ((array)$serialize as $viewVar) {
if (is_scalar($this->viewVars[$viewVar])) {
throw new Exception("'" . $viewVar . "' is not an array or iteratable object.");
}
foreach ($this->viewVars[$viewVar] as $_data) {
if ($_data instanceof EntityInterface) {
$_data = $_data->toArray();
}
if ($extract === null) {
$this->_renderRow($_data);
continue;
}
$values = [];
foreach ($extract as $formatter) {
if (!is_string($formatter) && is_callable($formatter)) {
$value = $formatter($_data);
} else {
$path = $formatter;
$format = null;
if (is_array($formatter)) {
list($path, $format) = $formatter;
}
if (strpos($path, '.') === false) {
$value = $_data[$path];
} else {
$value = Hash::get($_data, $path);
}
if ($format) {
$value = sprintf($format, $value);
}
}
$values[] = $value;
}
$this->_renderRow($values);
}
}
} | php | protected function _renderContent()
{
$extract = $this->viewVars['_extract'];
$serialize = $this->viewVars['_serialize'];
if ($serialize === true) {
$serialize = array_diff(
array_keys($this->viewVars),
$this->_specialVars
);
}
foreach ((array)$serialize as $viewVar) {
if (is_scalar($this->viewVars[$viewVar])) {
throw new Exception("'" . $viewVar . "' is not an array or iteratable object.");
}
foreach ($this->viewVars[$viewVar] as $_data) {
if ($_data instanceof EntityInterface) {
$_data = $_data->toArray();
}
if ($extract === null) {
$this->_renderRow($_data);
continue;
}
$values = [];
foreach ($extract as $formatter) {
if (!is_string($formatter) && is_callable($formatter)) {
$value = $formatter($_data);
} else {
$path = $formatter;
$format = null;
if (is_array($formatter)) {
list($path, $format) = $formatter;
}
if (strpos($path, '.') === false) {
$value = $_data[$path];
} else {
$value = Hash::get($_data, $path);
}
if ($format) {
$value = sprintf($format, $value);
}
}
$values[] = $value;
}
$this->_renderRow($values);
}
}
} | [
"protected",
"function",
"_renderContent",
"(",
")",
"{",
"$",
"extract",
"=",
"$",
"this",
"->",
"viewVars",
"[",
"'_extract'",
"]",
";",
"$",
"serialize",
"=",
"$",
"this",
"->",
"viewVars",
"[",
"'_serialize'",
"]",
";",
"if",
"(",
"$",
"serialize",
... | Renders the body of the data to the csv
@return void
@throws \Exception | [
"Renders",
"the",
"body",
"of",
"the",
"data",
"to",
"the",
"csv"
] | 3e17aea72fd3bf45260f7ca9c9c1c18956b4280e | https://github.com/FriendsOfCake/cakephp-csvview/blob/3e17aea72fd3bf45260f7ca9c9c1c18956b4280e/src/View/CsvView.php#L313-L367 | train |
FriendsOfCake/cakephp-csvview | src/View/CsvView.php | CsvView._renderRow | protected function _renderRow($row = null)
{
static $csv = '';
if ($this->_resetStaticVariables) {
$csv = '';
$this->_resetStaticVariables = false;
return null;
}
$csv .= (string)$this->_generateRow($row);
return $csv;
} | php | protected function _renderRow($row = null)
{
static $csv = '';
if ($this->_resetStaticVariables) {
$csv = '';
$this->_resetStaticVariables = false;
return null;
}
$csv .= (string)$this->_generateRow($row);
return $csv;
} | [
"protected",
"function",
"_renderRow",
"(",
"$",
"row",
"=",
"null",
")",
"{",
"static",
"$",
"csv",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"_resetStaticVariables",
")",
"{",
"$",
"csv",
"=",
"''",
";",
"$",
"this",
"->",
"_resetStaticVariables"... | Aggregates the rows into a single csv
@param array|null $row Row data
@return null|string CSV with all data to date | [
"Aggregates",
"the",
"rows",
"into",
"a",
"single",
"csv"
] | 3e17aea72fd3bf45260f7ca9c9c1c18956b4280e | https://github.com/FriendsOfCake/cakephp-csvview/blob/3e17aea72fd3bf45260f7ca9c9c1c18956b4280e/src/View/CsvView.php#L376-L390 | train |
FriendsOfCake/cakephp-csvview | src/View/CsvView.php | CsvView._generateRow | protected function _generateRow($row = null)
{
static $fp = false;
if (empty($row)) {
return '';
}
if ($fp === false) {
$fp = fopen('php://temp', 'r+');
if ($this->viewVars['_setSeparator']) {
fwrite($fp, "sep=" . $this->viewVars['_delimiter'] . "\n");
}
} else {
ftruncate($fp, 0);
}
if ($this->viewVars['_null'] !== '') {
foreach ($row as &$field) {
if ($field === null) {
$field = $this->viewVars['_null'];
}
}
}
$delimiter = $this->viewVars['_delimiter'];
$enclosure = $this->viewVars['_enclosure'];
$newline = $this->viewVars['_newline'];
$row = str_replace(["\r\n", "\n", "\r"], $newline, $row);
if ($enclosure === '') {
// fputcsv does not supports empty enclosure
if (fputs($fp, implode($delimiter, $row) . "\n") === false) {
return false;
}
} else {
if (fputcsv($fp, $row, $delimiter, $enclosure) === false) {
return false;
}
}
rewind($fp);
$csv = '';
while (($buffer = fgets($fp, 4096)) !== false) {
$csv .= $buffer;
}
$eol = $this->viewVars['_eol'];
if ($eol !== "\n") {
$csv = str_replace("\n", $eol, $csv);
}
$dataEncoding = $this->viewVars['_dataEncoding'];
$csvEncoding = $this->viewVars['_csvEncoding'];
if ($dataEncoding !== $csvEncoding) {
$extension = $this->viewVars['_extension'];
if ($extension === self::EXTENSION_ICONV) {
$csv = iconv($dataEncoding, $csvEncoding, $csv);
} elseif ($extension === self::EXTENSION_MBSTRING) {
$csv = mb_convert_encoding($csv, $csvEncoding, $dataEncoding);
}
}
//bom must be added after encoding
if ($this->viewVars['_bom'] && $this->isFirstBom) {
$csv = $this->getBom($this->viewVars['_csvEncoding']) . $csv;
$this->isFirstBom = false;
}
return $csv;
} | php | protected function _generateRow($row = null)
{
static $fp = false;
if (empty($row)) {
return '';
}
if ($fp === false) {
$fp = fopen('php://temp', 'r+');
if ($this->viewVars['_setSeparator']) {
fwrite($fp, "sep=" . $this->viewVars['_delimiter'] . "\n");
}
} else {
ftruncate($fp, 0);
}
if ($this->viewVars['_null'] !== '') {
foreach ($row as &$field) {
if ($field === null) {
$field = $this->viewVars['_null'];
}
}
}
$delimiter = $this->viewVars['_delimiter'];
$enclosure = $this->viewVars['_enclosure'];
$newline = $this->viewVars['_newline'];
$row = str_replace(["\r\n", "\n", "\r"], $newline, $row);
if ($enclosure === '') {
// fputcsv does not supports empty enclosure
if (fputs($fp, implode($delimiter, $row) . "\n") === false) {
return false;
}
} else {
if (fputcsv($fp, $row, $delimiter, $enclosure) === false) {
return false;
}
}
rewind($fp);
$csv = '';
while (($buffer = fgets($fp, 4096)) !== false) {
$csv .= $buffer;
}
$eol = $this->viewVars['_eol'];
if ($eol !== "\n") {
$csv = str_replace("\n", $eol, $csv);
}
$dataEncoding = $this->viewVars['_dataEncoding'];
$csvEncoding = $this->viewVars['_csvEncoding'];
if ($dataEncoding !== $csvEncoding) {
$extension = $this->viewVars['_extension'];
if ($extension === self::EXTENSION_ICONV) {
$csv = iconv($dataEncoding, $csvEncoding, $csv);
} elseif ($extension === self::EXTENSION_MBSTRING) {
$csv = mb_convert_encoding($csv, $csvEncoding, $dataEncoding);
}
}
//bom must be added after encoding
if ($this->viewVars['_bom'] && $this->isFirstBom) {
$csv = $this->getBom($this->viewVars['_csvEncoding']) . $csv;
$this->isFirstBom = false;
}
return $csv;
} | [
"protected",
"function",
"_generateRow",
"(",
"$",
"row",
"=",
"null",
")",
"{",
"static",
"$",
"fp",
"=",
"false",
";",
"if",
"(",
"empty",
"(",
"$",
"row",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"fp",
"===",
"false",
")",
"{... | Generates a single row in a csv from an array of
data by writing the array to a temporary file and
returning it's contents
@param array|null $row Row data
@return string|false String with the row in csv-syntax, false on fputscv failure | [
"Generates",
"a",
"single",
"row",
"in",
"a",
"csv",
"from",
"an",
"array",
"of",
"data",
"by",
"writing",
"the",
"array",
"to",
"a",
"temporary",
"file",
"and",
"returning",
"it",
"s",
"contents"
] | 3e17aea72fd3bf45260f7ca9c9c1c18956b4280e | https://github.com/FriendsOfCake/cakephp-csvview/blob/3e17aea72fd3bf45260f7ca9c9c1c18956b4280e/src/View/CsvView.php#L401-L473 | train |
FriendsOfCake/cakephp-csvview | src/View/CsvView.php | CsvView.getBom | protected function getBom($csvEncoding)
{
$csvEncoding = strtoupper($csvEncoding);
return isset($this->bomMap[$csvEncoding]) ? $this->bomMap[$csvEncoding] : '';
} | php | protected function getBom($csvEncoding)
{
$csvEncoding = strtoupper($csvEncoding);
return isset($this->bomMap[$csvEncoding]) ? $this->bomMap[$csvEncoding] : '';
} | [
"protected",
"function",
"getBom",
"(",
"$",
"csvEncoding",
")",
"{",
"$",
"csvEncoding",
"=",
"strtoupper",
"(",
"$",
"csvEncoding",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"bomMap",
"[",
"$",
"csvEncoding",
"]",
")",
"?",
"$",
"this",
"-... | Returns the BOM for the encoding given.
@param string $csvEncoding The encoding you want the BOM for
@return string | [
"Returns",
"the",
"BOM",
"for",
"the",
"encoding",
"given",
"."
] | 3e17aea72fd3bf45260f7ca9c9c1c18956b4280e | https://github.com/FriendsOfCake/cakephp-csvview/blob/3e17aea72fd3bf45260f7ca9c9c1c18956b4280e/src/View/CsvView.php#L481-L486 | train |
avored/framework | src/Menu/Builder.php | Builder.make | public function make($key, callable $callable)
{
$menu = new Menu($callable);
$menu->key($key);
$this->collection->put($key, $menu);
return $this;
} | php | public function make($key, callable $callable)
{
$menu = new Menu($callable);
$menu->key($key);
$this->collection->put($key, $menu);
return $this;
} | [
"public",
"function",
"make",
"(",
"$",
"key",
",",
"callable",
"$",
"callable",
")",
"{",
"$",
"menu",
"=",
"new",
"Menu",
"(",
"$",
"callable",
")",
";",
"$",
"menu",
"->",
"key",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"collection",
"->"... | Make a Front End Menu an Object.
@param string $key
@param callable $callable
@return void | [
"Make",
"a",
"Front",
"End",
"Menu",
"an",
"Object",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Menu/Builder.php#L28-L36 | train |
avored/framework | src/AdminMenu/Builder.php | Builder.add | public function add($key, $callable)
{
$menu = new AdminMenu($callable);
$this->adminMenu->put($key, $menu);
return $this;
} | php | public function add($key, $callable)
{
$menu = new AdminMenu($callable);
$this->adminMenu->put($key, $menu);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"callable",
")",
"{",
"$",
"menu",
"=",
"new",
"AdminMenu",
"(",
"$",
"callable",
")",
";",
"$",
"this",
"->",
"adminMenu",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"menu",
")",
";",
"return"... | Add Menu to a Collection
@param string
@param callable $callable
@return \AvoRed\Framework\AdminMenu\Builder | [
"Add",
"Menu",
"to",
"a",
"Collection"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/AdminMenu/Builder.php#L28-L35 | train |
avored/framework | src/Models/Database/Property.php | Property.getProductValueModel | public function getProductValueModel($productId)
{
$dataType = ucfirst(strtolower($this->data_type));
$method = 'productProperty' . $dataType . 'Value';
$productPropertyModel = $this
->$method()
->whereProductId($productId)
->get();
if ($productPropertyModel->count() == 0) {
$valueClass = __NAMESPACE__ . '\\' . ucfirst($method);
$valueModel = new $valueClass([
'property_id' => $this->id,
'product_id' => $productId
]);
} else {
$valueModel = $this->$method()->whereProductId($productId)->first();
}
return $valueModel;
} | php | public function getProductValueModel($productId)
{
$dataType = ucfirst(strtolower($this->data_type));
$method = 'productProperty' . $dataType . 'Value';
$productPropertyModel = $this
->$method()
->whereProductId($productId)
->get();
if ($productPropertyModel->count() == 0) {
$valueClass = __NAMESPACE__ . '\\' . ucfirst($method);
$valueModel = new $valueClass([
'property_id' => $this->id,
'product_id' => $productId
]);
} else {
$valueModel = $this->$method()->whereProductId($productId)->first();
}
return $valueModel;
} | [
"public",
"function",
"getProductValueModel",
"(",
"$",
"productId",
")",
"{",
"$",
"dataType",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"data_type",
")",
")",
";",
"$",
"method",
"=",
"'productProperty'",
".",
"$",
"dataType",
".",
"'Val... | Get Product Property Value Model based by ProductID.
@param integer $productId
@return \Illuminate\Database\Eloquent\Model | [
"Get",
"Product",
"Property",
"Value",
"Model",
"based",
"by",
"ProductID",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Property.php#L130-L153 | train |
avored/framework | src/Models/Database/Property.php | Property.getDropdownOptions | public function getDropdownOptions()
{
$options = Collection::make([]);
$dropdowns = $this->propertyDropdownOptions;
if (null !== $dropdowns && $dropdowns->count() > 0) {
foreach ($dropdowns as $dropdown) {
$dropdown->display_text = $dropdown->getDisplayText();
$options->push($dropdown);
}
}
return $options;
} | php | public function getDropdownOptions()
{
$options = Collection::make([]);
$dropdowns = $this->propertyDropdownOptions;
if (null !== $dropdowns && $dropdowns->count() > 0) {
foreach ($dropdowns as $dropdown) {
$dropdown->display_text = $dropdown->getDisplayText();
$options->push($dropdown);
}
}
return $options;
} | [
"public",
"function",
"getDropdownOptions",
"(",
")",
"{",
"$",
"options",
"=",
"Collection",
"::",
"make",
"(",
"[",
"]",
")",
";",
"$",
"dropdowns",
"=",
"$",
"this",
"->",
"propertyDropdownOptions",
";",
"if",
"(",
"null",
"!==",
"$",
"dropdowns",
"&&... | Get dropdown options with language transted
@return \Illuminate\Support\Collection $options | [
"Get",
"dropdown",
"options",
"with",
"language",
"transted"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Property.php#L187-L200 | train |
avored/framework | src/Breadcrumb/Builder.php | Builder.make | public function make($name, callable $callable)
{
$breadcrumb = new Breadcrumb($callable);
$breadcrumb->route($name);
$this->collection->put($name, $breadcrumb);
} | php | public function make($name, callable $callable)
{
$breadcrumb = new Breadcrumb($callable);
$breadcrumb->route($name);
$this->collection->put($name, $breadcrumb);
} | [
"public",
"function",
"make",
"(",
"$",
"name",
",",
"callable",
"$",
"callable",
")",
"{",
"$",
"breadcrumb",
"=",
"new",
"Breadcrumb",
"(",
"$",
"callable",
")",
";",
"$",
"breadcrumb",
"->",
"route",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
... | Breadcrumb Make an Object.
@param string $name
@param callable $callable
@return void | [
"Breadcrumb",
"Make",
"an",
"Object",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Breadcrumb/Builder.php#L36-L42 | train |
avored/framework | src/Breadcrumb/Builder.php | Builder.render | public function render($routeName)
{
$breadcrumb = $this->collection->get($routeName);
if (null === $breadcrumb) {
return '';
}
return view('avored-framework::breadcrumb.index')
->with('breadcrumb', $breadcrumb);
} | php | public function render($routeName)
{
$breadcrumb = $this->collection->get($routeName);
if (null === $breadcrumb) {
return '';
}
return view('avored-framework::breadcrumb.index')
->with('breadcrumb', $breadcrumb);
} | [
"public",
"function",
"render",
"(",
"$",
"routeName",
")",
"{",
"$",
"breadcrumb",
"=",
"$",
"this",
"->",
"collection",
"->",
"get",
"(",
"$",
"routeName",
")",
";",
"if",
"(",
"null",
"===",
"$",
"breadcrumb",
")",
"{",
"return",
"''",
";",
"}",
... | Render BreakCrumb for the Route Name.
@param string $routeName
@return string|\Illuminate\View\View | [
"Render",
"BreakCrumb",
"for",
"the",
"Route",
"Name",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Breadcrumb/Builder.php#L50-L60 | train |
avored/framework | src/Image/Driver/Gd.php | Gd.make | public function make()
{
$ext = strtolower(strrchr($this->path, '.'));
$path = storage_path('app/public/') . $this->path;
switch ($ext) {
case '.jpg':
case '.jpeg':
$this->image = @imagecreatefromjpeg($path);
break;
case '.gif':
$this->image = @imagecreatefromgif($path);
break;
case '.png':
$this->image = @imagecreatefrompng($path);
break;
default:
$this->image = false;
break;
}
if (false === $this->image) {
throw new ImageNotFoundException('Image extension not supported!');
}
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
return $this;
} | php | public function make()
{
$ext = strtolower(strrchr($this->path, '.'));
$path = storage_path('app/public/') . $this->path;
switch ($ext) {
case '.jpg':
case '.jpeg':
$this->image = @imagecreatefromjpeg($path);
break;
case '.gif':
$this->image = @imagecreatefromgif($path);
break;
case '.png':
$this->image = @imagecreatefrompng($path);
break;
default:
$this->image = false;
break;
}
if (false === $this->image) {
throw new ImageNotFoundException('Image extension not supported!');
}
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
return $this;
} | [
"public",
"function",
"make",
"(",
")",
"{",
"$",
"ext",
"=",
"strtolower",
"(",
"strrchr",
"(",
"$",
"this",
"->",
"path",
",",
"'.'",
")",
")",
";",
"$",
"path",
"=",
"storage_path",
"(",
"'app/public/'",
")",
".",
"$",
"this",
"->",
"path",
";",... | Make the Image as GD Resource and return self
@return self $this | [
"Make",
"the",
"Image",
"as",
"GD",
"Resource",
"and",
"return",
"self"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Image/Driver/Gd.php#L47-L74 | train |
avored/framework | src/Image/Driver/Gd.php | Gd.saveImage | public function saveImage($savePath, $imageQuality = '100')
{
$extension = strrchr($savePath, '.');
$extension = strtolower($extension);
switch ($extension) {
case '.jpg':
case '.jpeg':
if (imagetypes() & IMG_JPG) {
imagejpeg($this->imageResized, $savePath, $imageQuality);
}
break;
case '.gif':
if (imagetypes() & IMG_GIF) {
imagegif($this->imageResized, $savePath);
}
break;
case '.png':
$scaleQuality = round(($imageQuality / 100) * 9);
$invertScaleQuality = 9 - $scaleQuality;
if (imagetypes() & IMG_PNG) {
imagepng($this->imageResized, $savePath, $invertScaleQuality);
}
break;
default:
break;
}
imagedestroy($this->imageResized);
return $this;
} | php | public function saveImage($savePath, $imageQuality = '100')
{
$extension = strrchr($savePath, '.');
$extension = strtolower($extension);
switch ($extension) {
case '.jpg':
case '.jpeg':
if (imagetypes() & IMG_JPG) {
imagejpeg($this->imageResized, $savePath, $imageQuality);
}
break;
case '.gif':
if (imagetypes() & IMG_GIF) {
imagegif($this->imageResized, $savePath);
}
break;
case '.png':
$scaleQuality = round(($imageQuality / 100) * 9);
$invertScaleQuality = 9 - $scaleQuality;
if (imagetypes() & IMG_PNG) {
imagepng($this->imageResized, $savePath, $invertScaleQuality);
}
break;
default:
break;
}
imagedestroy($this->imageResized);
return $this;
} | [
"public",
"function",
"saveImage",
"(",
"$",
"savePath",
",",
"$",
"imageQuality",
"=",
"'100'",
")",
"{",
"$",
"extension",
"=",
"strrchr",
"(",
"$",
"savePath",
",",
"'.'",
")",
";",
"$",
"extension",
"=",
"strtolower",
"(",
"$",
"extension",
")",
";... | Save the Image
@param string $savePath
@param int $ImageQuality
@return self $this | [
"Save",
"the",
"Image"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Image/Driver/Gd.php#L119-L154 | train |
avored/framework | src/Image/Driver/Gd.php | Gd.getDimensions | protected function getDimensions($newWidth, $newHeight)
{
$usedRatio = $widthRatio = $this->width / $newWidth;
$heightRatio = $this->height / $newHeight;
if ($heightRatio < $widthRatio) {
$usedRatio = $heightRatio;
}
$height = $this->height / $usedRatio;
$width = $this->width / $usedRatio;
return [$width, $height];
} | php | protected function getDimensions($newWidth, $newHeight)
{
$usedRatio = $widthRatio = $this->width / $newWidth;
$heightRatio = $this->height / $newHeight;
if ($heightRatio < $widthRatio) {
$usedRatio = $heightRatio;
}
$height = $this->height / $usedRatio;
$width = $this->width / $usedRatio;
return [$width, $height];
} | [
"protected",
"function",
"getDimensions",
"(",
"$",
"newWidth",
",",
"$",
"newHeight",
")",
"{",
"$",
"usedRatio",
"=",
"$",
"widthRatio",
"=",
"$",
"this",
"->",
"width",
"/",
"$",
"newWidth",
";",
"$",
"heightRatio",
"=",
"$",
"this",
"->",
"height",
... | Get the Width & height of the Image
@param int $newWith
@param int $newHeight
@return array | [
"Get",
"the",
"Width",
"&",
"height",
"of",
"the",
"Image"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Image/Driver/Gd.php#L162-L175 | train |
avored/framework | src/Image/Driver/Gd.php | Gd.crop | protected function crop($with, $height, $newWidth, $newHeight)
{
$cropStartX = ($with / 2) - ($newWidth / 2);
$cropStartY = ($height / 2) - ($newHeight / 2);
$crop = $this->imageResized;
$this->imageResized = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled(
$this->imageResized,
$crop,
0,
0,
$cropStartX,
$cropStartY,
$newWidth,
$newHeight,
$newWidth,
$newHeight
);
return $this;
} | php | protected function crop($with, $height, $newWidth, $newHeight)
{
$cropStartX = ($with / 2) - ($newWidth / 2);
$cropStartY = ($height / 2) - ($newHeight / 2);
$crop = $this->imageResized;
$this->imageResized = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled(
$this->imageResized,
$crop,
0,
0,
$cropStartX,
$cropStartY,
$newWidth,
$newHeight,
$newWidth,
$newHeight
);
return $this;
} | [
"protected",
"function",
"crop",
"(",
"$",
"with",
",",
"$",
"height",
",",
"$",
"newWidth",
",",
"$",
"newHeight",
")",
"{",
"$",
"cropStartX",
"=",
"(",
"$",
"with",
"/",
"2",
")",
"-",
"(",
"$",
"newWidth",
"/",
"2",
")",
";",
"$",
"cropStartY... | Crop the Image
@param int $with
@param int $height
@param int $newWidth
@param int $newHeight
@return self $this | [
"Crop",
"the",
"Image"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Image/Driver/Gd.php#L186-L206 | train |
avored/framework | src/Cart/Product.php | Product.attributes | public function attributes($attributes = null)
{
if (null === $attributes) {
return $this->attributes;
}
$this->attributes = $attributes;
return $this;
} | php | public function attributes($attributes = null)
{
if (null === $attributes) {
return $this->attributes;
}
$this->attributes = $attributes;
return $this;
} | [
"public",
"function",
"attributes",
"(",
"$",
"attributes",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"attributes",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
";",
"}",
"$",
"this",
"->",
"attributes",
"=",
"$",
"attributes",
";",... | To Check if Cart Product Has Attributes.
@param array $attributes
@return self|array | [
"To",
"Check",
"if",
"Cart",
"Product",
"Has",
"Attributes",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Cart/Product.php#L204-L213 | train |
avored/framework | src/AdminConfiguration/Manager.php | Manager.add | public function add($key)
{
$configuration = new AdminConfigurationGroup();
$configuration->key($key);
$this->configurations->put($key, $configuration);
return $configuration;
} | php | public function add($key)
{
$configuration = new AdminConfigurationGroup();
$configuration->key($key);
$this->configurations->put($key, $configuration);
return $configuration;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
")",
"{",
"$",
"configuration",
"=",
"new",
"AdminConfigurationGroup",
"(",
")",
";",
"$",
"configuration",
"->",
"key",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"configurations",
"->",
"put",
"(",
"$"... | Add Admin Configuration into Collection.
@param string $key
@return \AvoRed\Framework\AdminConfiguration\AdminConfigurationGroup | [
"Add",
"Admin",
"Configuration",
"into",
"Collection",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/AdminConfiguration/Manager.php#L37-L45 | train |
avored/framework | src/AdminConfiguration/Manager.php | Manager.get | public function get($key)
{
if ($this->configurations->has($key)) {
return $this->configurations->get($key);
}
return Collection::make([]);
} | php | public function get($key)
{
if ($this->configurations->has($key)) {
return $this->configurations->get($key);
}
return Collection::make([]);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configurations",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configurations",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"retu... | Get Admin Configuration Collection if exists or Return Empty Collection.
@param array $item
@return mixed \AvoRed\Framework\AdminConfiguration\AdminConfigurationGroup|\Illuminate\Support\Collection | [
"Get",
"Admin",
"Configuration",
"Collection",
"if",
"exists",
"or",
"Return",
"Empty",
"Collection",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/AdminConfiguration/Manager.php#L53-L60 | train |
avored/framework | src/Models/Repository/CategoryRepository.php | CategoryRepository.findTranslated | public function findTranslated($category, $languageId)
{
return CategoryTranslation::whereCategoryId($category->id)
->whereLanguageId($languageId)
->first();
} | php | public function findTranslated($category, $languageId)
{
return CategoryTranslation::whereCategoryId($category->id)
->whereLanguageId($languageId)
->first();
} | [
"public",
"function",
"findTranslated",
"(",
"$",
"category",
",",
"$",
"languageId",
")",
"{",
"return",
"CategoryTranslation",
"::",
"whereCategoryId",
"(",
"$",
"category",
"->",
"id",
")",
"->",
"whereLanguageId",
"(",
"$",
"languageId",
")",
"->",
"first"... | Find an Translated Category by given CategoryModel and Language Id
@param \AvoRed\Framework\Models\Database\Category $id
@param integer $languageId
@return \AvoRed\Framework\Models\Database\CategoryTranslation | [
"Find",
"an",
"Translated",
"Category",
"by",
"given",
"CategoryModel",
"and",
"Language",
"Id"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/CategoryRepository.php#L38-L43 | train |
avored/framework | src/Models/Repository/CategoryRepository.php | CategoryRepository.create | public function create($data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return Category::create($data);
} else {
return CategoryTranslation::create($data);
}
} else {
return Category::create($data);
}
} | php | public function create($data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return Category::create($data);
} else {
return CategoryTranslation::create($data);
}
} else {
return Category::create($data);
}
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"Session",
"::",
"has",
"(",
"'multi_language_enabled'",
")",
")",
"{",
"$",
"languageId",
"=",
"$",
"data",
"[",
"'language_id'",
"]",
";",
"$",
"languaModel",
"=",
"Language",
"::",... | Create a Category
@return \AvoRed\Framework\Models\Database\Categoy | [
"Create",
"a",
"Category"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/CategoryRepository.php#L92-L106 | train |
avored/framework | src/Models/Repository/CategoryRepository.php | CategoryRepository.update | public function update(Category $category, array $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $category->update($data);
} else {
$category->update(Arr::only($data, ['parent_id']));
$translatedModel = $category
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return CategoryTranslation::create(
array_merge($data, ['category_id' => $category->id])
);
} else {
$translatedModel->update(
$data,
$category->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $category->update($data);
}
} | php | public function update(Category $category, array $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $category->update($data);
} else {
$category->update(Arr::only($data, ['parent_id']));
$translatedModel = $category
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return CategoryTranslation::create(
array_merge($data, ['category_id' => $category->id])
);
} else {
$translatedModel->update(
$data,
$category->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $category->update($data);
}
} | [
"public",
"function",
"update",
"(",
"Category",
"$",
"category",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"Session",
"::",
"has",
"(",
"'multi_language_enabled'",
")",
")",
"{",
"$",
"languageId",
"=",
"$",
"data",
"[",
"'language_id'",
"]",
";",... | Update a Category
@param \AvoRed\Framework\Models\Database\Categoy $category
@param array $data
@return \AvoRed\Framework\Models\Database\Categoy | [
"Update",
"a",
"Category"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/CategoryRepository.php#L115-L147 | train |
avored/framework | src/Models/Repository/CategoryRepository.php | CategoryRepository.options | public function options($empty = true)
{
if (true === $empty) {
$empty = new Category();
$empty->name = 'Please Select';
return Category::all()->prepend($empty);
}
return Category::all();
} | php | public function options($empty = true)
{
if (true === $empty) {
$empty = new Category();
$empty->name = 'Please Select';
return Category::all()->prepend($empty);
}
return Category::all();
} | [
"public",
"function",
"options",
"(",
"$",
"empty",
"=",
"true",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"empty",
")",
"{",
"$",
"empty",
"=",
"new",
"Category",
"(",
")",
";",
"$",
"empty",
"->",
"name",
"=",
"'Please Select'",
";",
"return",
"Ca... | Get an Category Options for Vue Components
@return \Illuminate\Database\Eloquent\Collection | [
"Get",
"an",
"Category",
"Options",
"for",
"Vue",
"Components"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/CategoryRepository.php#L261-L269 | train |
avored/framework | src/Cart/Manager.php | Manager.add | public function add($slug, $qty, $attribute = null): Manager
{
$cartProducts = $this->getSession();
$product = Product::whereSlug($slug)->first();
$price = $product->price;
$attributes = null;
if (null !== $attribute && count($attribute)) {
foreach ($attribute as $attributeId => $attributeValueId) {
if ('variation_id' == $attributeId) {
continue;
}
$variableProduct = Product::find($attribute['variation_id']);
$attributeModel = Attribute::find($attributeId);
$productAttributeIntValModel = ProductAttributeIntegerValue::
whereAttributeId($attributeId)
->whereProductId($variableProduct->id)
->first();
$optionModel = $attributeModel
->AttributeDropdownOptions()
->whereId($productAttributeIntValModel->value)
->first();
$price = $variableProduct->price;
$attributes[] = [
'attribute_id' => $attributeId,
'variation_id' => $variableProduct->id,
'attribute_dropdown_option_id' => $optionModel->id,
'variation_display_text' => $attributeModel->name . ': ' . $optionModel->display_text
];
}
}
$cartProduct = new CartFacadeProduct();
$cartProduct->name($product->name)
->qty($qty)
->slug($slug)
->price($price)
->image($product->image)
->lineTotal($qty * $price)
->attributes($attributes);
$cartProducts->put($slug, $cartProduct);
$this->sessionManager->put($this->getSessionKey(), $cartProducts);
return $this;
} | php | public function add($slug, $qty, $attribute = null): Manager
{
$cartProducts = $this->getSession();
$product = Product::whereSlug($slug)->first();
$price = $product->price;
$attributes = null;
if (null !== $attribute && count($attribute)) {
foreach ($attribute as $attributeId => $attributeValueId) {
if ('variation_id' == $attributeId) {
continue;
}
$variableProduct = Product::find($attribute['variation_id']);
$attributeModel = Attribute::find($attributeId);
$productAttributeIntValModel = ProductAttributeIntegerValue::
whereAttributeId($attributeId)
->whereProductId($variableProduct->id)
->first();
$optionModel = $attributeModel
->AttributeDropdownOptions()
->whereId($productAttributeIntValModel->value)
->first();
$price = $variableProduct->price;
$attributes[] = [
'attribute_id' => $attributeId,
'variation_id' => $variableProduct->id,
'attribute_dropdown_option_id' => $optionModel->id,
'variation_display_text' => $attributeModel->name . ': ' . $optionModel->display_text
];
}
}
$cartProduct = new CartFacadeProduct();
$cartProduct->name($product->name)
->qty($qty)
->slug($slug)
->price($price)
->image($product->image)
->lineTotal($qty * $price)
->attributes($attributes);
$cartProducts->put($slug, $cartProduct);
$this->sessionManager->put($this->getSessionKey(), $cartProducts);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"slug",
",",
"$",
"qty",
",",
"$",
"attribute",
"=",
"null",
")",
":",
"Manager",
"{",
"$",
"cartProducts",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"product",
"=",
"Product",
"::",
"whereSlug",... | Add Product into cart using Slug and Qty.
@param string $slug
@param int $qty
@param array $attributes
@return \AvoRed\Framework\Cart\Manager $this | [
"Add",
"Product",
"into",
"cart",
"using",
"Slug",
"and",
"Qty",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Cart/Manager.php#L40-L90 | train |
avored/framework | src/Cart/Manager.php | Manager.destroy | public function destroy($slug):Manager
{
$cartProducts = $this->getSession();
$cartProducts->pull($slug);
return $this;
} | php | public function destroy($slug):Manager
{
$cartProducts = $this->getSession();
$cartProducts->pull($slug);
return $this;
} | [
"public",
"function",
"destroy",
"(",
"$",
"slug",
")",
":",
"Manager",
"{",
"$",
"cartProducts",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"cartProducts",
"->",
"pull",
"(",
"$",
"slug",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove an Item from Cart Products by Slug.
@param string $slug
@return self $this | [
"Remove",
"an",
"Item",
"from",
"Cart",
"Products",
"by",
"Slug",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Cart/Manager.php#L188-L194 | train |
avored/framework | src/Cart/Manager.php | Manager.getSession | public function getSession()
{
$sessionKey = $this->getSessionKey();
return $this->sessionManager->has($sessionKey) ? $this->sessionManager->get($sessionKey) : new Collection;
} | php | public function getSession()
{
$sessionKey = $this->getSessionKey();
return $this->sessionManager->has($sessionKey) ? $this->sessionManager->get($sessionKey) : new Collection;
} | [
"public",
"function",
"getSession",
"(",
")",
"{",
"$",
"sessionKey",
"=",
"$",
"this",
"->",
"getSessionKey",
"(",
")",
";",
"return",
"$",
"this",
"->",
"sessionManager",
"->",
"has",
"(",
"$",
"sessionKey",
")",
"?",
"$",
"this",
"->",
"sessionManager... | Get the Current Collection for the Prophetoducts.
@return \Illuminate\Support\Collection | [
"Get",
"the",
"Current",
"Collection",
"for",
"the",
"Prophetoducts",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Cart/Manager.php#L215-L220 | train |
avored/framework | src/Cart/Manager.php | Manager.total | public function total($formatted = true)
{
$total = 0.00;
$cartProducts = $this->getSession();
foreach ($cartProducts as $product) {
$total += $product->lineTotal();
}
if ($formatted == true) {
$symbol = Session::get('currency_symbol');
return $symbol . number_format($total, 2);
}
return $total;
} | php | public function total($formatted = true)
{
$total = 0.00;
$cartProducts = $this->getSession();
foreach ($cartProducts as $product) {
$total += $product->lineTotal();
}
if ($formatted == true) {
$symbol = Session::get('currency_symbol');
return $symbol . number_format($total, 2);
}
return $total;
} | [
"public",
"function",
"total",
"(",
"$",
"formatted",
"=",
"true",
")",
"{",
"$",
"total",
"=",
"0.00",
";",
"$",
"cartProducts",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"foreach",
"(",
"$",
"cartProducts",
"as",
"$",
"product",
")",
"{"... | Get the Current Cart Total
@return double $total | [
"Get",
"the",
"Current",
"Cart",
"Total"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Cart/Manager.php#L227-L242 | train |
avored/framework | src/Cart/Manager.php | Manager.taxTotal | public function taxTotal($formatted = true)
{
$taxTotal = 0.00;
$cartProducts = $this->getSession();
foreach ($cartProducts as $product) {
$taxTotal += $product->tax();
}
if ($formatted == true) {
$symbol = Session::get('currency_symbol');
return $symbol . number_format($taxTotal, 2);
}
return $taxTotal;
} | php | public function taxTotal($formatted = true)
{
$taxTotal = 0.00;
$cartProducts = $this->getSession();
foreach ($cartProducts as $product) {
$taxTotal += $product->tax();
}
if ($formatted == true) {
$symbol = Session::get('currency_symbol');
return $symbol . number_format($taxTotal, 2);
}
return $taxTotal;
} | [
"public",
"function",
"taxTotal",
"(",
"$",
"formatted",
"=",
"true",
")",
"{",
"$",
"taxTotal",
"=",
"0.00",
";",
"$",
"cartProducts",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"foreach",
"(",
"$",
"cartProducts",
"as",
"$",
"product",
")",... | Get the Current Cart Tax Total
@return double $taxTotal | [
"Get",
"the",
"Current",
"Cart",
"Tax",
"Total"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Cart/Manager.php#L249-L263 | train |
avored/framework | src/Models/Repository/PageRepository.php | PageRepository.update | public function update(Page $page, array $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $page->update($data);
} else {
$translatedModel = $page
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return PageTranslation::create(
array_merge($data, ['page_id' => $page->id])
);
} else {
$translatedModel->update(
$data,
$page->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $page->update($data);
}
} | php | public function update(Page $page, array $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $page->update($data);
} else {
$translatedModel = $page
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return PageTranslation::create(
array_merge($data, ['page_id' => $page->id])
);
} else {
$translatedModel->update(
$data,
$page->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $page->update($data);
}
} | [
"public",
"function",
"update",
"(",
"Page",
"$",
"page",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"Session",
"::",
"has",
"(",
"'multi_language_enabled'",
")",
")",
"{",
"$",
"languageId",
"=",
"$",
"data",
"[",
"'language_id'",
"]",
";",
"$",
... | Update a Page
@param \AvoRed\Framework\Models\Database\Page $page
@param array $data
@return \AvoRed\Framework\Models\Database\Page | [
"Update",
"a",
"Page"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/PageRepository.php#L72-L103 | train |
avored/framework | src/Breadcrumb/Breadcrumb.php | Breadcrumb.parent | public function parent($key):self
{
$breadcrumb = BreadcrumbFacade::get($key);
$this->parents->put($key, $breadcrumb);
return $this;
} | php | public function parent($key):self
{
$breadcrumb = BreadcrumbFacade::get($key);
$this->parents->put($key, $breadcrumb);
return $this;
} | [
"public",
"function",
"parent",
"(",
"$",
"key",
")",
":",
"self",
"{",
"$",
"breadcrumb",
"=",
"BreadcrumbFacade",
"::",
"get",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"parents",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"breadcrumb",
")",
";"... | Set AvoRed BreakCrumb Parents.
@var string
@return \AvoRed\Framework\Breadcrumb\Breadcrumb | [
"Set",
"AvoRed",
"BreakCrumb",
"Parents",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Breadcrumb/Breadcrumb.php#L85-L91 | train |
avored/framework | src/Order/Controllers/OrderController.php | OrderController.editStatus | public function editStatus(Model $order)
{
$orderStatus = OrderStatus::all()->pluck('name', 'id');
$view = view('avored-framework::order.view')
->with('order', $order)
->with('orderStatus', $orderStatus)
->with('changeStatus', true);
return $view;
} | php | public function editStatus(Model $order)
{
$orderStatus = OrderStatus::all()->pluck('name', 'id');
$view = view('avored-framework::order.view')
->with('order', $order)
->with('orderStatus', $orderStatus)
->with('changeStatus', true);
return $view;
} | [
"public",
"function",
"editStatus",
"(",
"Model",
"$",
"order",
")",
"{",
"$",
"orderStatus",
"=",
"OrderStatus",
"::",
"all",
"(",
")",
"->",
"pluck",
"(",
"'name'",
",",
"'id'",
")",
";",
"$",
"view",
"=",
"view",
"(",
"'avored-framework::order.view'",
... | Edit the Order Status View
@param \AvoRed\Framework\Models\Database\Order $order
@return \Illuminate\Http\Response | [
"Edit",
"the",
"Order",
"Status",
"View"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Order/Controllers/OrderController.php#L86-L96 | train |
avored/framework | src/Product/Controllers/AttributeController.php | AttributeController.store | public function store(AttributeRequest $request)
{
$attribute = $this->attributeRepository->create($request->all());
$this->saveDropdownOptions($attribute, $request);
return redirect()->route('admin.attribute.index');
} | php | public function store(AttributeRequest $request)
{
$attribute = $this->attributeRepository->create($request->all());
$this->saveDropdownOptions($attribute, $request);
return redirect()->route('admin.attribute.index');
} | [
"public",
"function",
"store",
"(",
"AttributeRequest",
"$",
"request",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"attributeRepository",
"->",
"create",
"(",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"$",
"this",
"->",
"saveDropdownOptions... | Store an Atttibute into Database and Redirect to List Route
@param \AvoRed\Framework\Product\Requests\AttributeRequest $request
@return \Illuminate\Http\RedirectResponse | [
"Store",
"an",
"Atttibute",
"into",
"Database",
"and",
"Redirect",
"to",
"List",
"Route"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Product/Controllers/AttributeController.php#L57-L63 | train |
avored/framework | src/Models/Repository/AttributeRepository.php | AttributeRepository.update | public function update(Attribute $attribute, array $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $attribute->update($data);
} else {
$translatedModel = $attribute
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return AttributeTranslation::create(
array_merge($data, ['attribute_id' => $attribute->id])
);
} else {
$translatedModel->update(
$data,
$attribute->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $attribute->update($data);
}
} | php | public function update(Attribute $attribute, array $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $attribute->update($data);
} else {
$translatedModel = $attribute
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return AttributeTranslation::create(
array_merge($data, ['attribute_id' => $attribute->id])
);
} else {
$translatedModel->update(
$data,
$attribute->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $attribute->update($data);
}
} | [
"public",
"function",
"update",
"(",
"Attribute",
"$",
"attribute",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"Session",
"::",
"has",
"(",
"'multi_language_enabled'",
")",
")",
"{",
"$",
"languageId",
"=",
"$",
"data",
"[",
"'language_id'",
"]",
";... | Update an attribute
@param \AvoRed\Framework\Models\Database\Attribute $attribute
@param array $data
@return mixed | [
"Update",
"an",
"attribute"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/AttributeRepository.php#L84-L114 | train |
avored/framework | src/Models/Repository/AttributeRepository.php | AttributeRepository.syncDropdownOptions | public function syncDropdownOptions($attribute, $data)
{
$dropdownOptionsData = $data['dropdown_options'] ?? [];
if (count($dropdownOptionsData)) {
$defaultLanguage = Session::get('default_language');
$languageId = $data['language_id'] ?? $defaultLanguage->id;
if ($defaultLanguage->id != $languageId) {
foreach ($dropdownOptionsData as $key => $val) {
if (empty($val['display_text'])) {
continue;
}
if (is_int($key)) {
$optionModel = AttributeDropdownOption::find($key);
$translatedModel = $optionModel
->translations()
->whereLanguageId($languageId)
->first();
if (null !== $translatedModel) {
$translatedModel->update($val);
} else {
$optionModel
->translations()
->create(
array_merge($val, ['language_id' => $languageId])
);
}
}
}
} else {
if ($attribute->attributeDropdownOptions()->get() != null
&& $attribute->attributeDropdownOptions()->get()->count() >= 0
) {
$attribute->attributeDropdownOptions()->delete();
}
foreach ($dropdownOptionsData as $key => $val) {
if (empty($val['display_text'])) {
continue;
}
$option = $attribute
->attributeDropdownOptions()
->create($val);
}
}
}
} | php | public function syncDropdownOptions($attribute, $data)
{
$dropdownOptionsData = $data['dropdown_options'] ?? [];
if (count($dropdownOptionsData)) {
$defaultLanguage = Session::get('default_language');
$languageId = $data['language_id'] ?? $defaultLanguage->id;
if ($defaultLanguage->id != $languageId) {
foreach ($dropdownOptionsData as $key => $val) {
if (empty($val['display_text'])) {
continue;
}
if (is_int($key)) {
$optionModel = AttributeDropdownOption::find($key);
$translatedModel = $optionModel
->translations()
->whereLanguageId($languageId)
->first();
if (null !== $translatedModel) {
$translatedModel->update($val);
} else {
$optionModel
->translations()
->create(
array_merge($val, ['language_id' => $languageId])
);
}
}
}
} else {
if ($attribute->attributeDropdownOptions()->get() != null
&& $attribute->attributeDropdownOptions()->get()->count() >= 0
) {
$attribute->attributeDropdownOptions()->delete();
}
foreach ($dropdownOptionsData as $key => $val) {
if (empty($val['display_text'])) {
continue;
}
$option = $attribute
->attributeDropdownOptions()
->create($val);
}
}
}
} | [
"public",
"function",
"syncDropdownOptions",
"(",
"$",
"attribute",
",",
"$",
"data",
")",
"{",
"$",
"dropdownOptionsData",
"=",
"$",
"data",
"[",
"'dropdown_options'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"dropdownOptionsData",
")",
")"... | Sync Attribute Dropdown Options
@param \AvoRed\Framework\Models\Database\Attribute $attribute
@param array $data | [
"Sync",
"Attribute",
"Dropdown",
"Options"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/AttributeRepository.php#L121-L172 | train |
avored/framework | src/Permission/PermissionGroup.php | PermissionGroup.label | public function label($label = null)
{
if (null !== $label) {
$this->label = $label;
return $this;
}
if (Lang::has($this->label)) {
return __($this->label);
}
return $this->label;
} | php | public function label($label = null)
{
if (null !== $label) {
$this->label = $label;
return $this;
}
if (Lang::has($this->label)) {
return __($this->label);
}
return $this->label;
} | [
"public",
"function",
"label",
"(",
"$",
"label",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"label",
")",
"{",
"$",
"this",
"->",
"label",
"=",
"$",
"label",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"Lang",
"::",
"has",
"(",... | Specify a label for permission group
@param string $label
@return mixed $this|$label | [
"Specify",
"a",
"label",
"for",
"permission",
"group"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Permission/PermissionGroup.php#L45-L57 | train |
avored/framework | src/Permission/PermissionGroup.php | PermissionGroup.addPermission | public function addPermission($key, $callable = null)
{
if (null !== $callable) {
$permission = new Permission($callable);
$permission->key($key);
$this->permissionList->put($key, $permission);
} else {
$permission = new Permission();
$permission->key($key);
$this->permissionList->put($key, $permission);
}
return $permission;
} | php | public function addPermission($key, $callable = null)
{
if (null !== $callable) {
$permission = new Permission($callable);
$permission->key($key);
$this->permissionList->put($key, $permission);
} else {
$permission = new Permission();
$permission->key($key);
$this->permissionList->put($key, $permission);
}
return $permission;
} | [
"public",
"function",
"addPermission",
"(",
"$",
"key",
",",
"$",
"callable",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"callable",
")",
"{",
"$",
"permission",
"=",
"new",
"Permission",
"(",
"$",
"callable",
")",
";",
"$",
"permission",
... | Add Permission to a group
@param string $key
@param callable $callable
@return \AvoRed\Framework\Permission\Permission $permission | [
"Add",
"Permission",
"to",
"a",
"group"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Permission/PermissionGroup.php#L84-L99 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.