repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.getAllSubscriptions | public function getAllSubscriptions()
{
$limit = RequestInterface::MAX_LIST_LIMIT;
$offset = 0;
$subscriptions = [[]];
while (true) {
$subscriptionBatch = $this->getSubscriptionsResponse($offset);
$subscriptions[] = $subscriptionBatch;
$offset += $limit;
if (\count($subscriptionBatch) < $limit) {
break;
}
}
return \array_merge(...$subscriptions);
} | php | public function getAllSubscriptions()
{
$limit = RequestInterface::MAX_LIST_LIMIT;
$offset = 0;
$subscriptions = [[]];
while (true) {
$subscriptionBatch = $this->getSubscriptionsResponse($offset);
$subscriptions[] = $subscriptionBatch;
$offset += $limit;
if (\count($subscriptionBatch) < $limit) {
break;
}
}
return \array_merge(...$subscriptions);
} | [
"public",
"function",
"getAllSubscriptions",
"(",
")",
"{",
"$",
"limit",
"=",
"RequestInterface",
"::",
"MAX_LIST_LIMIT",
";",
"$",
"offset",
"=",
"0",
";",
"$",
"subscriptions",
"=",
"[",
"[",
"]",
"]",
";",
"while",
"(",
"true",
")",
"{",
"$",
"subscriptionBatch",
"=",
"$",
"this",
"->",
"getSubscriptionsResponse",
"(",
"$",
"offset",
")",
";",
"$",
"subscriptions",
"[",
"]",
"=",
"$",
"subscriptionBatch",
";",
"$",
"offset",
"+=",
"$",
"limit",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"subscriptionBatch",
")",
"<",
"$",
"limit",
")",
"{",
"break",
";",
"}",
"}",
"return",
"\\",
"array_merge",
"(",
"...",
"$",
"subscriptions",
")",
";",
"}"
] | Get all subscriptions.
@return Subscription[] | [
"Get",
"all",
"subscriptions",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L62-L78 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.createSubscription | public function createSubscription(Create\RequestData $requestData)
{
$request = new Create\Request($requestData);
return $this->sendRequest($request, Create\ApiResponse::class);
} | php | public function createSubscription(Create\RequestData $requestData)
{
$request = new Create\Request($requestData);
return $this->sendRequest($request, Create\ApiResponse::class);
} | [
"public",
"function",
"createSubscription",
"(",
"Create",
"\\",
"RequestData",
"$",
"requestData",
")",
"{",
"$",
"request",
"=",
"new",
"Create",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Create",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Create a subscription.
@param Create\RequestData $requestData The request data.
@return Create\ApiResponse | [
"Create",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L86-L91 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.updateSubscription | public function updateSubscription(
$subscriptionId,
$nextEvent = null,
$subscriptionExternalId = null,
$status = null,
array $xAttributes = [],
array $features = []
) {
$requestData = new Update\RequestData($subscriptionId);
$requestData->setSubscriptionId($subscriptionId);
$requestData->setNextEvent($nextEvent);
$requestData->setSubscriptionExternalId($subscriptionExternalId);
$requestData->setStatus($status);
$requestData->setXAttributes($xAttributes);
$requestData->setFeatures($features);
$request = new Update\Request($requestData);
return $this->sendRequest($request, Update\ApiResponse::class);
} | php | public function updateSubscription(
$subscriptionId,
$nextEvent = null,
$subscriptionExternalId = null,
$status = null,
array $xAttributes = [],
array $features = []
) {
$requestData = new Update\RequestData($subscriptionId);
$requestData->setSubscriptionId($subscriptionId);
$requestData->setNextEvent($nextEvent);
$requestData->setSubscriptionExternalId($subscriptionExternalId);
$requestData->setStatus($status);
$requestData->setXAttributes($xAttributes);
$requestData->setFeatures($features);
$request = new Update\Request($requestData);
return $this->sendRequest($request, Update\ApiResponse::class);
} | [
"public",
"function",
"updateSubscription",
"(",
"$",
"subscriptionId",
",",
"$",
"nextEvent",
"=",
"null",
",",
"$",
"subscriptionExternalId",
"=",
"null",
",",
"$",
"status",
"=",
"null",
",",
"array",
"$",
"xAttributes",
"=",
"[",
"]",
",",
"array",
"$",
"features",
"=",
"[",
"]",
")",
"{",
"$",
"requestData",
"=",
"new",
"Update",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"requestData",
"->",
"setSubscriptionId",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"requestData",
"->",
"setNextEvent",
"(",
"$",
"nextEvent",
")",
";",
"$",
"requestData",
"->",
"setSubscriptionExternalId",
"(",
"$",
"subscriptionExternalId",
")",
";",
"$",
"requestData",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"$",
"requestData",
"->",
"setXAttributes",
"(",
"$",
"xAttributes",
")",
";",
"$",
"requestData",
"->",
"setFeatures",
"(",
"$",
"features",
")",
";",
"$",
"request",
"=",
"new",
"Update",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Update",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Update a subscription.
@param integer $subscriptionId The subscription ID.
@param \DateTime $nextEvent The next event date and time.
@param string $subscriptionExternalId The external subscription ID.
@param string $status The subscription status.
@param array $xAttributes The subscription x attributes.
@param Feature[] $features The features.
@return Update\ApiResponse | [
"Update",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L104-L124 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.changeSubscriptionArticle | public function changeSubscriptionArticle(ChangeArticle\RequestData $requestData)
{
$request = new ChangeArticle\Request($requestData);
return $this->sendRequest($request, ChangeArticle\ApiResponse::class);
} | php | public function changeSubscriptionArticle(ChangeArticle\RequestData $requestData)
{
$request = new ChangeArticle\Request($requestData);
return $this->sendRequest($request, ChangeArticle\ApiResponse::class);
} | [
"public",
"function",
"changeSubscriptionArticle",
"(",
"ChangeArticle",
"\\",
"RequestData",
"$",
"requestData",
")",
"{",
"$",
"request",
"=",
"new",
"ChangeArticle",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"ChangeArticle",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Change article of a subscription.
@param ChangeArticle\RequestData $requestData The request data.
@return ChangeArticle\ApiResponse | [
"Change",
"article",
"of",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L132-L137 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.setSubscriptionAddon | public function setSubscriptionAddon(SetAddon\RequestData $requestData)
{
$request = new SetAddon\Request($requestData);
return $this->sendRequest($request, SetAddon\ApiResponse::class);
} | php | public function setSubscriptionAddon(SetAddon\RequestData $requestData)
{
$request = new SetAddon\Request($requestData);
return $this->sendRequest($request, SetAddon\ApiResponse::class);
} | [
"public",
"function",
"setSubscriptionAddon",
"(",
"SetAddon",
"\\",
"RequestData",
"$",
"requestData",
")",
"{",
"$",
"request",
"=",
"new",
"SetAddon",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"SetAddon",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Set the addon for a subscription.
@param SetAddon\RequestData $requestData The request data.
@return SetAddon\ApiResponse | [
"Set",
"the",
"addon",
"for",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L145-L150 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.setSubscriptionUsageData | public function setSubscriptionUsageData(SetUsageData\RequestData $requestData)
{
$request = new SetUsageData\Request($requestData);
return $this->sendRequest($request, SetUsageData\ApiResponse::class);
} | php | public function setSubscriptionUsageData(SetUsageData\RequestData $requestData)
{
$request = new SetUsageData\Request($requestData);
return $this->sendRequest($request, SetUsageData\ApiResponse::class);
} | [
"public",
"function",
"setSubscriptionUsageData",
"(",
"SetUsageData",
"\\",
"RequestData",
"$",
"requestData",
")",
"{",
"$",
"request",
"=",
"new",
"SetUsageData",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"SetUsageData",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Set the usage data of a subscription.
@param SetUsageData\RequestData $requestData The request data.
@return SetUsageData\ApiResponse | [
"Set",
"the",
"usage",
"data",
"of",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L158-L163 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.getSubscriptionUsageData | public function getSubscriptionUsageData(
$subscriptionId,
\DateTime $subscriptionStart = null,
\DateTime $subscriptionEnd = null
) {
$requestData = new GetUsageData\RequestData($subscriptionId);
$requestData->setSubscriptionId($subscriptionId);
$requestData->setSubscriptionStart($subscriptionStart);
$requestData->setSubscriptionEnd($subscriptionEnd);
$request = new GetUsageData\Request($requestData);
return $this->sendRequest($request, GetUsageData\ApiResponse::class);
} | php | public function getSubscriptionUsageData(
$subscriptionId,
\DateTime $subscriptionStart = null,
\DateTime $subscriptionEnd = null
) {
$requestData = new GetUsageData\RequestData($subscriptionId);
$requestData->setSubscriptionId($subscriptionId);
$requestData->setSubscriptionStart($subscriptionStart);
$requestData->setSubscriptionEnd($subscriptionEnd);
$request = new GetUsageData\Request($requestData);
return $this->sendRequest($request, GetUsageData\ApiResponse::class);
} | [
"public",
"function",
"getSubscriptionUsageData",
"(",
"$",
"subscriptionId",
",",
"\\",
"DateTime",
"$",
"subscriptionStart",
"=",
"null",
",",
"\\",
"DateTime",
"$",
"subscriptionEnd",
"=",
"null",
")",
"{",
"$",
"requestData",
"=",
"new",
"GetUsageData",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"requestData",
"->",
"setSubscriptionId",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"requestData",
"->",
"setSubscriptionStart",
"(",
"$",
"subscriptionStart",
")",
";",
"$",
"requestData",
"->",
"setSubscriptionEnd",
"(",
"$",
"subscriptionEnd",
")",
";",
"$",
"request",
"=",
"new",
"GetUsageData",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"GetUsageData",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Get the usage data of a subscription.
@param integer $subscriptionId The subscription ID.
@param \DateTime $subscriptionStart The subscription start.
@param \DateTime $subscriptionEnd The subscription end.
@return GetUsageData\ApiResponse | [
"Get",
"the",
"usage",
"data",
"of",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L173-L187 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.deleteSubscriptionUsageData | public function deleteSubscriptionUsageData($usageDataId)
{
$requestData = new DeleteUsageData\RequestData($usageDataId);
$request = new DeleteUsageData\Request($requestData);
return $this->sendRequest($request, DeleteUsageData\ApiResponse::class);
} | php | public function deleteSubscriptionUsageData($usageDataId)
{
$requestData = new DeleteUsageData\RequestData($usageDataId);
$request = new DeleteUsageData\Request($requestData);
return $this->sendRequest($request, DeleteUsageData\ApiResponse::class);
} | [
"public",
"function",
"deleteSubscriptionUsageData",
"(",
"$",
"usageDataId",
")",
"{",
"$",
"requestData",
"=",
"new",
"DeleteUsageData",
"\\",
"RequestData",
"(",
"$",
"usageDataId",
")",
";",
"$",
"request",
"=",
"new",
"DeleteUsageData",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"DeleteUsageData",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Get the usage data of a subscription.
@param string $usageDataId The usage data ID.
@return DeleteUsageData\ApiResponse | [
"Get",
"the",
"usage",
"data",
"of",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L195-L201 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.getUpcomingAmount | public function getUpcomingAmount(GetUpcomingAmount\RequestData $requestData = null)
{
if ($requestData === null) {
$requestData = new GetUpcomingAmount\RequestData();
}
$request = new GetUpcomingAmount\Request($requestData);
return $this->sendRequest($request, GetUpcomingAmount\ApiResponse::class);
} | php | public function getUpcomingAmount(GetUpcomingAmount\RequestData $requestData = null)
{
if ($requestData === null) {
$requestData = new GetUpcomingAmount\RequestData();
}
$request = new GetUpcomingAmount\Request($requestData);
return $this->sendRequest($request, GetUpcomingAmount\ApiResponse::class);
} | [
"public",
"function",
"getUpcomingAmount",
"(",
"GetUpcomingAmount",
"\\",
"RequestData",
"$",
"requestData",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"requestData",
"===",
"null",
")",
"{",
"$",
"requestData",
"=",
"new",
"GetUpcomingAmount",
"\\",
"RequestData",
"(",
")",
";",
"}",
"$",
"request",
"=",
"new",
"GetUpcomingAmount",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"GetUpcomingAmount",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Get the upcoming amount.
@param GetUpcomingAmount\RequestData $requestData The request data filter.
@return GetUpcomingAmount\ApiResponse | [
"Get",
"the",
"upcoming",
"amount",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L209-L218 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.postponeSubscription | public function postponeSubscription($subscriptionId, $month)
{
$requestData = new Postpone\RequestData($subscriptionId, $month);
$request = new Postpone\Request($requestData);
return $this->sendRequest($request, Postpone\ApiResponse::class);
} | php | public function postponeSubscription($subscriptionId, $month)
{
$requestData = new Postpone\RequestData($subscriptionId, $month);
$request = new Postpone\Request($requestData);
return $this->sendRequest($request, Postpone\ApiResponse::class);
} | [
"public",
"function",
"postponeSubscription",
"(",
"$",
"subscriptionId",
",",
"$",
"month",
")",
"{",
"$",
"requestData",
"=",
"new",
"Postpone",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
",",
"$",
"month",
")",
";",
"$",
"request",
"=",
"new",
"Postpone",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Postpone",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Postpone a subscription shipping.
@param integer $subscriptionId
@param integer $month The month to postpone.
@return Postpone\ApiResponse | [
"Postpone",
"a",
"subscription",
"shipping",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L227-L233 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.renewSubscription | public function renewSubscription($subscriptionId)
{
$requestData = new Renew\RequestData($subscriptionId);
$request = new Renew\Request($requestData);
return $this->sendRequest($request, Renew\ApiResponse::class);
} | php | public function renewSubscription($subscriptionId)
{
$requestData = new Renew\RequestData($subscriptionId);
$request = new Renew\Request($requestData);
return $this->sendRequest($request, Renew\ApiResponse::class);
} | [
"public",
"function",
"renewSubscription",
"(",
"$",
"subscriptionId",
")",
"{",
"$",
"requestData",
"=",
"new",
"Renew",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"request",
"=",
"new",
"Renew",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Renew",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Renew a subscription.
@param integer $subscriptionId The subscription ID to renew.
@return Renew\ApiResponse | [
"Renew",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L241-L247 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.createSecureLink | public function createSecureLink($subscriptionId)
{
$requestData = new CreateSecureLink\RequestData($subscriptionId);
$request = new CreateSecureLink\Request($requestData);
return $this->sendRequest($request, CreateSecureLink\ApiResponse::class);
} | php | public function createSecureLink($subscriptionId)
{
$requestData = new CreateSecureLink\RequestData($subscriptionId);
$request = new CreateSecureLink\Request($requestData);
return $this->sendRequest($request, CreateSecureLink\ApiResponse::class);
} | [
"public",
"function",
"createSecureLink",
"(",
"$",
"subscriptionId",
")",
"{",
"$",
"requestData",
"=",
"new",
"CreateSecureLink",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"request",
"=",
"new",
"CreateSecureLink",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"CreateSecureLink",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Create a secure link for a subscription.
@param integer $subscriptionId The subscription ID for which to create the secure link.
@return CreateSecureLink\ApiResponse | [
"Create",
"a",
"secure",
"link",
"for",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L255-L261 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.cancelSubscription | public function cancelSubscription($subscriptionId, \DateTime $cancellationDate = null, $cancellationNote = null)
{
$requestData = new Cancel\RequestData($subscriptionId);
$requestData->setCancellationDate($cancellationDate);
$requestData->setCancellationNote($cancellationNote);
$request = new Cancel\Request($requestData);
return $this->sendRequest($request, Cancel\ApiResponse::class);
} | php | public function cancelSubscription($subscriptionId, \DateTime $cancellationDate = null, $cancellationNote = null)
{
$requestData = new Cancel\RequestData($subscriptionId);
$requestData->setCancellationDate($cancellationDate);
$requestData->setCancellationNote($cancellationNote);
$request = new Cancel\Request($requestData);
return $this->sendRequest($request, Cancel\ApiResponse::class);
} | [
"public",
"function",
"cancelSubscription",
"(",
"$",
"subscriptionId",
",",
"\\",
"DateTime",
"$",
"cancellationDate",
"=",
"null",
",",
"$",
"cancellationNote",
"=",
"null",
")",
"{",
"$",
"requestData",
"=",
"new",
"Cancel",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"requestData",
"->",
"setCancellationDate",
"(",
"$",
"cancellationDate",
")",
";",
"$",
"requestData",
"->",
"setCancellationNote",
"(",
"$",
"cancellationNote",
")",
";",
"$",
"request",
"=",
"new",
"Cancel",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Cancel",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Cancel a subscription.
@param integer $subscriptionId The subscription ID.
@param \DateTime $cancellationDate The cancellation date and time.
@param string $cancellationNote The cancellation note.
@return Cancel\ApiResponse | [
"Cancel",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L271-L280 |
Speicher210/monsum-api | src/Service/Subscription/SubscriptionService.php | SubscriptionService.reactivateSubscription | public function reactivateSubscription($subscriptionId)
{
$requestData = new Reactivate\RequestData($subscriptionId);
$request = new Reactivate\Request($requestData);
return $this->sendRequest($request, Reactivate\ApiResponse::class);
} | php | public function reactivateSubscription($subscriptionId)
{
$requestData = new Reactivate\RequestData($subscriptionId);
$request = new Reactivate\Request($requestData);
return $this->sendRequest($request, Reactivate\ApiResponse::class);
} | [
"public",
"function",
"reactivateSubscription",
"(",
"$",
"subscriptionId",
")",
"{",
"$",
"requestData",
"=",
"new",
"Reactivate",
"\\",
"RequestData",
"(",
"$",
"subscriptionId",
")",
";",
"$",
"request",
"=",
"new",
"Reactivate",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Reactivate",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] | Reactivate a subscription.
@param integer $subscriptionId The subscription ID to reactivate.
@return Reactivate\ApiResponse | [
"Reactivate",
"a",
"subscription",
"."
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L288-L294 |
ekuiter/feature-php | FeaturePhp/Helper/Path.php | Path.stripBase | public static function stripBase($path, $base = null) {
if ($base === null)
$base = getcwd();
if (substr($path, 0, strlen($base)) === $base)
return ltrim(substr($path, strlen($base) + 1), "/");
else
throw new PathException("\"$path\" does not contain base path \"$base\"");
} | php | public static function stripBase($path, $base = null) {
if ($base === null)
$base = getcwd();
if (substr($path, 0, strlen($base)) === $base)
return ltrim(substr($path, strlen($base) + 1), "/");
else
throw new PathException("\"$path\" does not contain base path \"$base\"");
} | [
"public",
"static",
"function",
"stripBase",
"(",
"$",
"path",
",",
"$",
"base",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"base",
"===",
"null",
")",
"$",
"base",
"=",
"getcwd",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"strlen",
"(",
"$",
"base",
")",
")",
"===",
"$",
"base",
")",
"return",
"ltrim",
"(",
"substr",
"(",
"$",
"path",
",",
"strlen",
"(",
"$",
"base",
")",
"+",
"1",
")",
",",
"\"/\"",
")",
";",
"else",
"throw",
"new",
"PathException",
"(",
"\"\\\"$path\\\" does not contain base path \\\"$base\\\"\"",
")",
";",
"}"
] | Strips a base from a file or directory path.
If no base is supplied, the working directory is used.
@param string $path
@param string $base
@return string | [
"Strips",
"a",
"base",
"from",
"a",
"file",
"or",
"directory",
"path",
".",
"If",
"no",
"base",
"is",
"supplied",
"the",
"working",
"directory",
"is",
"used",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L26-L33 |
ekuiter/feature-php | FeaturePhp/Helper/Path.php | Path.join | public static function join($lhs, $rhs) {
if ($lhs === null)
return $rhs;
return rtrim($lhs, '/') . '/' . ltrim($rhs, '/');
} | php | public static function join($lhs, $rhs) {
if ($lhs === null)
return $rhs;
return rtrim($lhs, '/') . '/' . ltrim($rhs, '/');
} | [
"public",
"static",
"function",
"join",
"(",
"$",
"lhs",
",",
"$",
"rhs",
")",
"{",
"if",
"(",
"$",
"lhs",
"===",
"null",
")",
"return",
"$",
"rhs",
";",
"return",
"rtrim",
"(",
"$",
"lhs",
",",
"'/'",
")",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"rhs",
",",
"'/'",
")",
";",
"}"
] | Joins two file or directory paths.
If the left path is null, returns the right path, making the
left path optional (see {@see https://stackoverflow.com/q/1091107}).
@param string|null $lhs
@param string $rhs
@return string | [
"Joins",
"two",
"file",
"or",
"directory",
"paths",
".",
"If",
"the",
"left",
"path",
"is",
"null",
"returns",
"the",
"right",
"path",
"making",
"the",
"left",
"path",
"optional",
"(",
"see",
"{"
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L43-L47 |
ekuiter/feature-php | FeaturePhp/Helper/Path.php | Path.resolve | public static function resolve($fileName) {
$path = array();
foreach(explode('/', $fileName) as $part) {
if (empty($part) || $part === '.') continue;
if ($part !== '..')
array_push($path, $part);
else if (count($path) > 0)
array_pop($path);
else
throw new PathException("can not resolve path \"$fileName\"");
}
return implode('/', $path);
} | php | public static function resolve($fileName) {
$path = array();
foreach(explode('/', $fileName) as $part) {
if (empty($part) || $part === '.') continue;
if ($part !== '..')
array_push($path, $part);
else if (count($path) > 0)
array_pop($path);
else
throw new PathException("can not resolve path \"$fileName\"");
}
return implode('/', $path);
} | [
"public",
"static",
"function",
"resolve",
"(",
"$",
"fileName",
")",
"{",
"$",
"path",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"'/'",
",",
"$",
"fileName",
")",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"part",
")",
"||",
"$",
"part",
"===",
"'.'",
")",
"continue",
";",
"if",
"(",
"$",
"part",
"!==",
"'..'",
")",
"array_push",
"(",
"$",
"path",
",",
"$",
"part",
")",
";",
"else",
"if",
"(",
"count",
"(",
"$",
"path",
")",
">",
"0",
")",
"array_pop",
"(",
"$",
"path",
")",
";",
"else",
"throw",
"new",
"PathException",
"(",
"\"can not resolve path \\\"$fileName\\\"\"",
")",
";",
"}",
"return",
"implode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"}"
] | Resolves a relative file or directory path.
This only works for unambiguous paths not depending on the
working directory (e.g. ../test can not be resolved)
(see {@see https://stackoverflow.com/q/20522605}).
@param string $fileName
@return string | [
"Resolves",
"a",
"relative",
"file",
"or",
"directory",
"path",
".",
"This",
"only",
"works",
"for",
"unambiguous",
"paths",
"not",
"depending",
"on",
"the",
"working",
"directory",
"(",
"e",
".",
"g",
".",
"..",
"/",
"test",
"can",
"not",
"be",
"resolved",
")",
"(",
"see",
"{"
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L57-L69 |
ekuiter/feature-php | FeaturePhp/Helper/Path.php | Path.removeDirectory | public static function removeDirectory($path) {
if (is_dir($path))
$dir = opendir($path);
if (!$dir)
return false;
while ($file = readdir($dir))
if (!self::isDot($file)) {
if (!is_dir("$path/$file"))
unlink("$path/$file");
else
self::removeDirectory("$path/$file");
}
closedir($dir);
rmdir($path);
return true;
} | php | public static function removeDirectory($path) {
if (is_dir($path))
$dir = opendir($path);
if (!$dir)
return false;
while ($file = readdir($dir))
if (!self::isDot($file)) {
if (!is_dir("$path/$file"))
unlink("$path/$file");
else
self::removeDirectory("$path/$file");
}
closedir($dir);
rmdir($path);
return true;
} | [
"public",
"static",
"function",
"removeDirectory",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"$",
"dir",
"=",
"opendir",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"return",
"false",
";",
"while",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
"dir",
")",
")",
"if",
"(",
"!",
"self",
"::",
"isDot",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"\"$path/$file\"",
")",
")",
"unlink",
"(",
"\"$path/$file\"",
")",
";",
"else",
"self",
"::",
"removeDirectory",
"(",
"\"$path/$file\"",
")",
";",
"}",
"closedir",
"(",
"$",
"dir",
")",
";",
"rmdir",
"(",
"$",
"path",
")",
";",
"return",
"true",
";",
"}"
] | Removes a directory recursively.
(see {@see https://paulund.co.uk/php-delete-directory-and-files-in-directory})
@param string $path
@return bool | [
"Removes",
"a",
"directory",
"recursively",
".",
"(",
"see",
"{"
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L88-L103 |
ekuiter/feature-php | FeaturePhp/Helper/Path.php | Path.rootPath | public static function rootPath($directory) {
$num = count(explode("/", $directory));
$path = "";
for ($i = 0; $i < $num; $i++)
$path = self::join("..", $path);
return $path;
} | php | public static function rootPath($directory) {
$num = count(explode("/", $directory));
$path = "";
for ($i = 0; $i < $num; $i++)
$path = self::join("..", $path);
return $path;
} | [
"public",
"static",
"function",
"rootPath",
"(",
"$",
"directory",
")",
"{",
"$",
"num",
"=",
"count",
"(",
"explode",
"(",
"\"/\"",
",",
"$",
"directory",
")",
")",
";",
"$",
"path",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"num",
";",
"$",
"i",
"++",
")",
"$",
"path",
"=",
"self",
"::",
"join",
"(",
"\"..\"",
",",
"$",
"path",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Builds a path referring to the root directory from a relative path.
@param string $directory
return string | [
"Builds",
"a",
"path",
"referring",
"to",
"the",
"root",
"directory",
"from",
"a",
"relative",
"path",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L110-L116 |
artscorestudio/document-bundle | Form/Type/PostType.php | PostType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title', TextType::class, array(
'label' => 'Post title',
'required' => true,
'attr' => array('class' => 'doc-title')
))
->add('slug', TextType::class, array(
'label' => 'Slug',
'required' => true,
'attr' => array('class' => 'doc-slug')
))
->add('state', ChoiceType::class, array(
'label' => 'State',
'required' => true,
'choices' => array(
'Draft' => DocumentModel::STATE_DRAFT,
'Waiting' => DocumentModel::STATE_WAITING,
'Published' => DocumentModel::STATE_PUBLISHED
),
'preferred_choices' => array(DocumentModel::STATE_DRAFT)
))
->add('content', TextareaType::class, array(
'label' => 'Content',
'required' => false,
'attr' => array('class' => 'tinymce-content doc-content')
));
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title', TextType::class, array(
'label' => 'Post title',
'required' => true,
'attr' => array('class' => 'doc-title')
))
->add('slug', TextType::class, array(
'label' => 'Slug',
'required' => true,
'attr' => array('class' => 'doc-slug')
))
->add('state', ChoiceType::class, array(
'label' => 'State',
'required' => true,
'choices' => array(
'Draft' => DocumentModel::STATE_DRAFT,
'Waiting' => DocumentModel::STATE_WAITING,
'Published' => DocumentModel::STATE_PUBLISHED
),
'preferred_choices' => array(DocumentModel::STATE_DRAFT)
))
->add('content', TextareaType::class, array(
'label' => 'Content',
'required' => false,
'attr' => array('class' => 'tinymce-content doc-content')
));
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'title'",
",",
"TextType",
"::",
"class",
",",
"array",
"(",
"'label'",
"=>",
"'Post title'",
",",
"'required'",
"=>",
"true",
",",
"'attr'",
"=>",
"array",
"(",
"'class'",
"=>",
"'doc-title'",
")",
")",
")",
"->",
"add",
"(",
"'slug'",
",",
"TextType",
"::",
"class",
",",
"array",
"(",
"'label'",
"=>",
"'Slug'",
",",
"'required'",
"=>",
"true",
",",
"'attr'",
"=>",
"array",
"(",
"'class'",
"=>",
"'doc-slug'",
")",
")",
")",
"->",
"add",
"(",
"'state'",
",",
"ChoiceType",
"::",
"class",
",",
"array",
"(",
"'label'",
"=>",
"'State'",
",",
"'required'",
"=>",
"true",
",",
"'choices'",
"=>",
"array",
"(",
"'Draft'",
"=>",
"DocumentModel",
"::",
"STATE_DRAFT",
",",
"'Waiting'",
"=>",
"DocumentModel",
"::",
"STATE_WAITING",
",",
"'Published'",
"=>",
"DocumentModel",
"::",
"STATE_PUBLISHED",
")",
",",
"'preferred_choices'",
"=>",
"array",
"(",
"DocumentModel",
"::",
"STATE_DRAFT",
")",
")",
")",
"->",
"add",
"(",
"'content'",
",",
"TextareaType",
"::",
"class",
",",
"array",
"(",
"'label'",
"=>",
"'Content'",
",",
"'required'",
"=>",
"false",
",",
"'attr'",
"=>",
"array",
"(",
"'class'",
"=>",
"'tinymce-content doc-content'",
")",
")",
")",
";",
"}"
] | (non-PHPdoc)
@see \Symfony\Component\Form\AbstractType::buildForm() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/artscorestudio/document-bundle/blob/3aceab0f75de8f7dd0fad0d0db83d7940bf565c8/Form/Type/PostType.php#L49-L76 |
zicht/z | src/Zicht/Tool/Packager/Node/StaticStub.php | StaticStub.compileInitialization | protected function compileInitialization(Buffer $buffer)
{
$configurationLoader = new Configuration\ConfigurationLoader(
$this->staticConfig,
new FileLocator(array(getcwd())),
new Configuration\FileLoader(
new Configuration\PathDefaultFileLocator(
'ZPLUGINPATH',
$this->staticPluginPaths
)
)
);
$compiler = new ContainerCompiler($configurationLoader->processConfiguration(), array());
$this->phar['container.php'] = $compiler->compileContainerCode();
$buffer->writeln('$container = require_once \'phar://z.phar/container.php\';');
foreach ($configurationLoader->getPlugins() as $name => $plugin) {
$className = get_class($plugin);
$embeddedFilename = 'plugins/' . $name . '.php';
$class = new \ReflectionClass($className);
$this->phar[$embeddedFilename] = file_get_contents($class->getFileName());
$buffer->write('require_once ')->asPhp('phar://z.phar/' . $embeddedFilename)->raw(';')->eol();
$buffer->write('$p = new ')->write($className)->raw('();')->eol();
$buffer->writeln('$p->setContainer($container);');
}
$buffer
->writeln('Zicht\Tool\Application::$HEADER = \'\';')
->write('$app = new Zicht\Tool\Application(')
->asPhp($this->appName)
->raw(', Zicht\Version\Version::fromString(')
->asPhp($this->appVersion)
->raw(') ?: new Zicht\Version\Version());')
->eol()
;
$buffer->writeln('$app->setContainer($container);');
} | php | protected function compileInitialization(Buffer $buffer)
{
$configurationLoader = new Configuration\ConfigurationLoader(
$this->staticConfig,
new FileLocator(array(getcwd())),
new Configuration\FileLoader(
new Configuration\PathDefaultFileLocator(
'ZPLUGINPATH',
$this->staticPluginPaths
)
)
);
$compiler = new ContainerCompiler($configurationLoader->processConfiguration(), array());
$this->phar['container.php'] = $compiler->compileContainerCode();
$buffer->writeln('$container = require_once \'phar://z.phar/container.php\';');
foreach ($configurationLoader->getPlugins() as $name => $plugin) {
$className = get_class($plugin);
$embeddedFilename = 'plugins/' . $name . '.php';
$class = new \ReflectionClass($className);
$this->phar[$embeddedFilename] = file_get_contents($class->getFileName());
$buffer->write('require_once ')->asPhp('phar://z.phar/' . $embeddedFilename)->raw(';')->eol();
$buffer->write('$p = new ')->write($className)->raw('();')->eol();
$buffer->writeln('$p->setContainer($container);');
}
$buffer
->writeln('Zicht\Tool\Application::$HEADER = \'\';')
->write('$app = new Zicht\Tool\Application(')
->asPhp($this->appName)
->raw(', Zicht\Version\Version::fromString(')
->asPhp($this->appVersion)
->raw(') ?: new Zicht\Version\Version());')
->eol()
;
$buffer->writeln('$app->setContainer($container);');
} | [
"protected",
"function",
"compileInitialization",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"configurationLoader",
"=",
"new",
"Configuration",
"\\",
"ConfigurationLoader",
"(",
"$",
"this",
"->",
"staticConfig",
",",
"new",
"FileLocator",
"(",
"array",
"(",
"getcwd",
"(",
")",
")",
")",
",",
"new",
"Configuration",
"\\",
"FileLoader",
"(",
"new",
"Configuration",
"\\",
"PathDefaultFileLocator",
"(",
"'ZPLUGINPATH'",
",",
"$",
"this",
"->",
"staticPluginPaths",
")",
")",
")",
";",
"$",
"compiler",
"=",
"new",
"ContainerCompiler",
"(",
"$",
"configurationLoader",
"->",
"processConfiguration",
"(",
")",
",",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"phar",
"[",
"'container.php'",
"]",
"=",
"$",
"compiler",
"->",
"compileContainerCode",
"(",
")",
";",
"$",
"buffer",
"->",
"writeln",
"(",
"'$container = require_once \\'phar://z.phar/container.php\\';'",
")",
";",
"foreach",
"(",
"$",
"configurationLoader",
"->",
"getPlugins",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"plugin",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"plugin",
")",
";",
"$",
"embeddedFilename",
"=",
"'plugins/'",
".",
"$",
"name",
".",
"'.php'",
";",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"this",
"->",
"phar",
"[",
"$",
"embeddedFilename",
"]",
"=",
"file_get_contents",
"(",
"$",
"class",
"->",
"getFileName",
"(",
")",
")",
";",
"$",
"buffer",
"->",
"write",
"(",
"'require_once '",
")",
"->",
"asPhp",
"(",
"'phar://z.phar/'",
".",
"$",
"embeddedFilename",
")",
"->",
"raw",
"(",
"';'",
")",
"->",
"eol",
"(",
")",
";",
"$",
"buffer",
"->",
"write",
"(",
"'$p = new '",
")",
"->",
"write",
"(",
"$",
"className",
")",
"->",
"raw",
"(",
"'();'",
")",
"->",
"eol",
"(",
")",
";",
"$",
"buffer",
"->",
"writeln",
"(",
"'$p->setContainer($container);'",
")",
";",
"}",
"$",
"buffer",
"->",
"writeln",
"(",
"'Zicht\\Tool\\Application::$HEADER = \\'\\';'",
")",
"->",
"write",
"(",
"'$app = new Zicht\\Tool\\Application('",
")",
"->",
"asPhp",
"(",
"$",
"this",
"->",
"appName",
")",
"->",
"raw",
"(",
"', Zicht\\Version\\Version::fromString('",
")",
"->",
"asPhp",
"(",
"$",
"this",
"->",
"appVersion",
")",
"->",
"raw",
"(",
"') ?: new Zicht\\Version\\Version());'",
")",
"->",
"eol",
"(",
")",
";",
"$",
"buffer",
"->",
"writeln",
"(",
"'$app->setContainer($container);'",
")",
";",
"}"
] | Writes the initialization code for a static build of Z.
@param \Zicht\Tool\Script\Buffer $buffer
@return mixed|void | [
"Writes",
"the",
"initialization",
"code",
"for",
"a",
"static",
"build",
"of",
"Z",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Packager/Node/StaticStub.php#L45-L83 |
zhouyl/mellivora | Mellivora/Translation/TranslatorServiceProvider.php | TranslatorServiceProvider.register | public function register()
{
$this->container['translator'] = function ($container) {
$config = $container['config']->get('translator');
$translator = new Translator($config->get('paths', [])->toArray());
// 别名设置
foreach ($config->get('aliases', []) as $key => $value) {
$translator->alias($key, $value->toArray());
}
// 默认语言类型
$translator->default(value($config->default));
// 导入必须的语言包
$translator->import($config->get('required', [])->toArray());
return $translator;
};
} | php | public function register()
{
$this->container['translator'] = function ($container) {
$config = $container['config']->get('translator');
$translator = new Translator($config->get('paths', [])->toArray());
// 别名设置
foreach ($config->get('aliases', []) as $key => $value) {
$translator->alias($key, $value->toArray());
}
// 默认语言类型
$translator->default(value($config->default));
// 导入必须的语言包
$translator->import($config->get('required', [])->toArray());
return $translator;
};
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'translator'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"$",
"config",
"=",
"$",
"container",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"translator",
"=",
"new",
"Translator",
"(",
"$",
"config",
"->",
"get",
"(",
"'paths'",
",",
"[",
"]",
")",
"->",
"toArray",
"(",
")",
")",
";",
"// 别名设置",
"foreach",
"(",
"$",
"config",
"->",
"get",
"(",
"'aliases'",
",",
"[",
"]",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"translator",
"->",
"alias",
"(",
"$",
"key",
",",
"$",
"value",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"// 默认语言类型",
"$",
"translator",
"->",
"default",
"(",
"value",
"(",
"$",
"config",
"->",
"default",
")",
")",
";",
"// 导入必须的语言包",
"$",
"translator",
"->",
"import",
"(",
"$",
"config",
"->",
"get",
"(",
"'required'",
",",
"[",
"]",
")",
"->",
"toArray",
"(",
")",
")",
";",
"return",
"$",
"translator",
";",
"}",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/TranslatorServiceProvider.php#L14-L34 |
InfiniteSoftware/ISEcommpayPayum | Action/Api/Signer.php | Signer.sign | public static function sign(array $params, string $secretKey, array $ignoreParamKeys = [], bool $doNotHash = false): string
{
$paramsPrepared = self::getParamsToSign($params, $ignoreParamKeys, 1);
$stringToSign = implode(self::ITEMS_DELIMITER, $paramsPrepared);
return $doNotHash
? $stringToSign
: base64_encode(hash_hmac('sha512', $stringToSign, $secretKey, true))
;
} | php | public static function sign(array $params, string $secretKey, array $ignoreParamKeys = [], bool $doNotHash = false): string
{
$paramsPrepared = self::getParamsToSign($params, $ignoreParamKeys, 1);
$stringToSign = implode(self::ITEMS_DELIMITER, $paramsPrepared);
return $doNotHash
? $stringToSign
: base64_encode(hash_hmac('sha512', $stringToSign, $secretKey, true))
;
} | [
"public",
"static",
"function",
"sign",
"(",
"array",
"$",
"params",
",",
"string",
"$",
"secretKey",
",",
"array",
"$",
"ignoreParamKeys",
"=",
"[",
"]",
",",
"bool",
"$",
"doNotHash",
"=",
"false",
")",
":",
"string",
"{",
"$",
"paramsPrepared",
"=",
"self",
"::",
"getParamsToSign",
"(",
"$",
"params",
",",
"$",
"ignoreParamKeys",
",",
"1",
")",
";",
"$",
"stringToSign",
"=",
"implode",
"(",
"self",
"::",
"ITEMS_DELIMITER",
",",
"$",
"paramsPrepared",
")",
";",
"return",
"$",
"doNotHash",
"?",
"$",
"stringToSign",
":",
"base64_encode",
"(",
"hash_hmac",
"(",
"'sha512'",
",",
"$",
"stringToSign",
",",
"$",
"secretKey",
",",
"true",
")",
")",
";",
"}"
] | Generate signature
@param array $params
@param string $secretKey
@param array $ignoreParamKeys
@param bool $doNotHash
@return string | [
"Generate",
"signature"
] | train | https://github.com/InfiniteSoftware/ISEcommpayPayum/blob/44a073e3d885d9007aa54d6ff13aea93a9e52e7c/Action/Api/Signer.php#L21-L29 |
InfiniteSoftware/ISEcommpayPayum | Action/Api/Signer.php | Signer.getParamsToSign | private static function getParamsToSign(
array $params,
array $ignoreParamKeys = [],
int $currentLevel = 1,
string $prefix = ''
): array
{
$paramsToSign = [];
foreach ($params as $key => $value) {
if ((in_array($key, $ignoreParamKeys) && $currentLevel == 1)) {
continue;
}
$paramKey = ($prefix ? $prefix . ':' : '') . $key;
if (is_array($value)) {
if ($currentLevel >= self::MAXIMUM_RECURSION_DEPTH) {
$paramsToSign[$paramKey] = (string)$paramKey.':';
} else {
$subArray = self::getParamsToSign($value, $ignoreParamKeys, $currentLevel + 1, $paramKey);
$paramsToSign = array_merge($paramsToSign, $subArray);
}
} else {
if (is_bool($value)) {
$value = $value ? '1' : '0';
} else {
$value = (string)$value;
}
$paramsToSign[$paramKey] = (string)$paramKey.':'.$value;
}
}
if ($currentLevel == 1) {
ksort($paramsToSign, SORT_NATURAL);
}
return $paramsToSign;
} | php | private static function getParamsToSign(
array $params,
array $ignoreParamKeys = [],
int $currentLevel = 1,
string $prefix = ''
): array
{
$paramsToSign = [];
foreach ($params as $key => $value) {
if ((in_array($key, $ignoreParamKeys) && $currentLevel == 1)) {
continue;
}
$paramKey = ($prefix ? $prefix . ':' : '') . $key;
if (is_array($value)) {
if ($currentLevel >= self::MAXIMUM_RECURSION_DEPTH) {
$paramsToSign[$paramKey] = (string)$paramKey.':';
} else {
$subArray = self::getParamsToSign($value, $ignoreParamKeys, $currentLevel + 1, $paramKey);
$paramsToSign = array_merge($paramsToSign, $subArray);
}
} else {
if (is_bool($value)) {
$value = $value ? '1' : '0';
} else {
$value = (string)$value;
}
$paramsToSign[$paramKey] = (string)$paramKey.':'.$value;
}
}
if ($currentLevel == 1) {
ksort($paramsToSign, SORT_NATURAL);
}
return $paramsToSign;
} | [
"private",
"static",
"function",
"getParamsToSign",
"(",
"array",
"$",
"params",
",",
"array",
"$",
"ignoreParamKeys",
"=",
"[",
"]",
",",
"int",
"$",
"currentLevel",
"=",
"1",
",",
"string",
"$",
"prefix",
"=",
"''",
")",
":",
"array",
"{",
"$",
"paramsToSign",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"ignoreParamKeys",
")",
"&&",
"$",
"currentLevel",
"==",
"1",
")",
")",
"{",
"continue",
";",
"}",
"$",
"paramKey",
"=",
"(",
"$",
"prefix",
"?",
"$",
"prefix",
".",
"':'",
":",
"''",
")",
".",
"$",
"key",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"currentLevel",
">=",
"self",
"::",
"MAXIMUM_RECURSION_DEPTH",
")",
"{",
"$",
"paramsToSign",
"[",
"$",
"paramKey",
"]",
"=",
"(",
"string",
")",
"$",
"paramKey",
".",
"':'",
";",
"}",
"else",
"{",
"$",
"subArray",
"=",
"self",
"::",
"getParamsToSign",
"(",
"$",
"value",
",",
"$",
"ignoreParamKeys",
",",
"$",
"currentLevel",
"+",
"1",
",",
"$",
"paramKey",
")",
";",
"$",
"paramsToSign",
"=",
"array_merge",
"(",
"$",
"paramsToSign",
",",
"$",
"subArray",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
"'1'",
":",
"'0'",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"$",
"paramsToSign",
"[",
"$",
"paramKey",
"]",
"=",
"(",
"string",
")",
"$",
"paramKey",
".",
"':'",
".",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"$",
"currentLevel",
"==",
"1",
")",
"{",
"ksort",
"(",
"$",
"paramsToSign",
",",
"SORT_NATURAL",
")",
";",
"}",
"return",
"$",
"paramsToSign",
";",
"}"
] | Get parameters to sign
@param array $params
@param array $ignoreParamKeys
@param int $currentLevel
@param string $prefix
@return array | [
"Get",
"parameters",
"to",
"sign"
] | train | https://github.com/InfiniteSoftware/ISEcommpayPayum/blob/44a073e3d885d9007aa54d6ff13aea93a9e52e7c/Action/Api/Signer.php#L39-L72 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.create | public function create($data)
{
$fileDescriptor = new FileDescriptor($data->getHash());
$fileDescriptor->setPackage(
$this->extractPackageFromDocBlock($data->getDocBlock()) ?: $data->getDefaultPackageName()
);
$fileDescriptor->setName(basename($data->getFilename()));
$fileDescriptor->setPath($data->getFilename());
$fileDescriptor->setSource($data->getContents());
$fileDescriptor->setIncludes(new Collection($data->getIncludes()));
$fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaceAliases()));
$this->assembleDocBlock($data->getDocBlock(), $fileDescriptor);
$this->overridePackageTag($data, $fileDescriptor);
$this->addMarkers($data->getMarkers(), $fileDescriptor);
$this->addConstants($data->getConstants(), $fileDescriptor);
$this->addFunctions($data->getFunctions(), $fileDescriptor);
$this->addClasses($data->getClasses(), $fileDescriptor);
$this->addInterfaces($data->getInterfaces(), $fileDescriptor);
$this->addTraits($data->getTraits(), $fileDescriptor);
return $fileDescriptor;
} | php | public function create($data)
{
$fileDescriptor = new FileDescriptor($data->getHash());
$fileDescriptor->setPackage(
$this->extractPackageFromDocBlock($data->getDocBlock()) ?: $data->getDefaultPackageName()
);
$fileDescriptor->setName(basename($data->getFilename()));
$fileDescriptor->setPath($data->getFilename());
$fileDescriptor->setSource($data->getContents());
$fileDescriptor->setIncludes(new Collection($data->getIncludes()));
$fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaceAliases()));
$this->assembleDocBlock($data->getDocBlock(), $fileDescriptor);
$this->overridePackageTag($data, $fileDescriptor);
$this->addMarkers($data->getMarkers(), $fileDescriptor);
$this->addConstants($data->getConstants(), $fileDescriptor);
$this->addFunctions($data->getFunctions(), $fileDescriptor);
$this->addClasses($data->getClasses(), $fileDescriptor);
$this->addInterfaces($data->getInterfaces(), $fileDescriptor);
$this->addTraits($data->getTraits(), $fileDescriptor);
return $fileDescriptor;
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"fileDescriptor",
"=",
"new",
"FileDescriptor",
"(",
"$",
"data",
"->",
"getHash",
"(",
")",
")",
";",
"$",
"fileDescriptor",
"->",
"setPackage",
"(",
"$",
"this",
"->",
"extractPackageFromDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
")",
"?",
":",
"$",
"data",
"->",
"getDefaultPackageName",
"(",
")",
")",
";",
"$",
"fileDescriptor",
"->",
"setName",
"(",
"basename",
"(",
"$",
"data",
"->",
"getFilename",
"(",
")",
")",
")",
";",
"$",
"fileDescriptor",
"->",
"setPath",
"(",
"$",
"data",
"->",
"getFilename",
"(",
")",
")",
";",
"$",
"fileDescriptor",
"->",
"setSource",
"(",
"$",
"data",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"fileDescriptor",
"->",
"setIncludes",
"(",
"new",
"Collection",
"(",
"$",
"data",
"->",
"getIncludes",
"(",
")",
")",
")",
";",
"$",
"fileDescriptor",
"->",
"setNamespaceAliases",
"(",
"new",
"Collection",
"(",
"$",
"data",
"->",
"getNamespaceAliases",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"assembleDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"overridePackageTag",
"(",
"$",
"data",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"addMarkers",
"(",
"$",
"data",
"->",
"getMarkers",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"addConstants",
"(",
"$",
"data",
"->",
"getConstants",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"addFunctions",
"(",
"$",
"data",
"->",
"getFunctions",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"addClasses",
"(",
"$",
"data",
"->",
"getClasses",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"addInterfaces",
"(",
"$",
"data",
"->",
"getInterfaces",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"$",
"this",
"->",
"addTraits",
"(",
"$",
"data",
"->",
"getTraits",
"(",
")",
",",
"$",
"fileDescriptor",
")",
";",
"return",
"$",
"fileDescriptor",
";",
"}"
] | Creates a Descriptor from the provided data.
@param FileReflector $data
@return FileDescriptor | [
"Creates",
"a",
"Descriptor",
"from",
"the",
"provided",
"data",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L36-L61 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.addConstants | protected function addConstants($constants, $fileDescriptor)
{
foreach ($constants as $constant) {
$constantDescriptor = $this->getBuilder()->buildDescriptor($constant);
if ($constantDescriptor) {
$constantDescriptor->setLocation($fileDescriptor, $constant->getLineNumber());
if (count($constantDescriptor->getTags()->get('package', new Collection())) == 0) {
$constantDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getConstants()->set(
$constantDescriptor->getFullyQualifiedStructuralElementName(),
$constantDescriptor
);
}
}
} | php | protected function addConstants($constants, $fileDescriptor)
{
foreach ($constants as $constant) {
$constantDescriptor = $this->getBuilder()->buildDescriptor($constant);
if ($constantDescriptor) {
$constantDescriptor->setLocation($fileDescriptor, $constant->getLineNumber());
if (count($constantDescriptor->getTags()->get('package', new Collection())) == 0) {
$constantDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getConstants()->set(
$constantDescriptor->getFullyQualifiedStructuralElementName(),
$constantDescriptor
);
}
}
} | [
"protected",
"function",
"addConstants",
"(",
"$",
"constants",
",",
"$",
"fileDescriptor",
")",
"{",
"foreach",
"(",
"$",
"constants",
"as",
"$",
"constant",
")",
"{",
"$",
"constantDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"constant",
")",
";",
"if",
"(",
"$",
"constantDescriptor",
")",
"{",
"$",
"constantDescriptor",
"->",
"setLocation",
"(",
"$",
"fileDescriptor",
",",
"$",
"constant",
"->",
"getLineNumber",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"constantDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
"==",
"0",
")",
"{",
"$",
"constantDescriptor",
"->",
"getTags",
"(",
")",
"->",
"set",
"(",
"'package'",
",",
"$",
"fileDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
";",
"}",
"$",
"fileDescriptor",
"->",
"getConstants",
"(",
")",
"->",
"set",
"(",
"$",
"constantDescriptor",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
",",
"$",
"constantDescriptor",
")",
";",
"}",
"}",
"}"
] | Registers the child constants with the generated File Descriptor.
@param ConstantReflector[] $constants
@param FileDescriptor $fileDescriptor
@return void | [
"Registers",
"the",
"child",
"constants",
"with",
"the",
"generated",
"File",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L71-L88 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.addFunctions | protected function addFunctions($functions, $fileDescriptor)
{
foreach ($functions as $function) {
$functionDescriptor = $this->getBuilder()->buildDescriptor($function);
if ($functionDescriptor) {
$functionDescriptor->setLocation($fileDescriptor, $function->getLineNumber());
if (count($functionDescriptor->getTags()->get('package', new Collection())) == 0) {
$functionDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getFunctions()->set(
$functionDescriptor->getFullyQualifiedStructuralElementName(),
$functionDescriptor
);
}
}
} | php | protected function addFunctions($functions, $fileDescriptor)
{
foreach ($functions as $function) {
$functionDescriptor = $this->getBuilder()->buildDescriptor($function);
if ($functionDescriptor) {
$functionDescriptor->setLocation($fileDescriptor, $function->getLineNumber());
if (count($functionDescriptor->getTags()->get('package', new Collection())) == 0) {
$functionDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getFunctions()->set(
$functionDescriptor->getFullyQualifiedStructuralElementName(),
$functionDescriptor
);
}
}
} | [
"protected",
"function",
"addFunctions",
"(",
"$",
"functions",
",",
"$",
"fileDescriptor",
")",
"{",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"function",
")",
"{",
"$",
"functionDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"function",
")",
";",
"if",
"(",
"$",
"functionDescriptor",
")",
"{",
"$",
"functionDescriptor",
"->",
"setLocation",
"(",
"$",
"fileDescriptor",
",",
"$",
"function",
"->",
"getLineNumber",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"functionDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
"==",
"0",
")",
"{",
"$",
"functionDescriptor",
"->",
"getTags",
"(",
")",
"->",
"set",
"(",
"'package'",
",",
"$",
"fileDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
";",
"}",
"$",
"fileDescriptor",
"->",
"getFunctions",
"(",
")",
"->",
"set",
"(",
"$",
"functionDescriptor",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
",",
"$",
"functionDescriptor",
")",
";",
"}",
"}",
"}"
] | Registers the child functions with the generated File Descriptor.
@param FunctionReflector[] $functions
@param FileDescriptor $fileDescriptor
@return void | [
"Registers",
"the",
"child",
"functions",
"with",
"the",
"generated",
"File",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L98-L115 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.addInterfaces | protected function addInterfaces($interfaces, $fileDescriptor)
{
foreach ($interfaces as $interface) {
$interfaceDescriptor = $this->getBuilder()->buildDescriptor($interface);
if ($interfaceDescriptor) {
$interfaceDescriptor->setLocation($fileDescriptor, $interface->getLineNumber());
if (count($interfaceDescriptor->getTags()->get('package', new Collection())) == 0) {
$interfaceDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getInterfaces()->set(
$interfaceDescriptor->getFullyQualifiedStructuralElementName(),
$interfaceDescriptor
);
}
}
} | php | protected function addInterfaces($interfaces, $fileDescriptor)
{
foreach ($interfaces as $interface) {
$interfaceDescriptor = $this->getBuilder()->buildDescriptor($interface);
if ($interfaceDescriptor) {
$interfaceDescriptor->setLocation($fileDescriptor, $interface->getLineNumber());
if (count($interfaceDescriptor->getTags()->get('package', new Collection())) == 0) {
$interfaceDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getInterfaces()->set(
$interfaceDescriptor->getFullyQualifiedStructuralElementName(),
$interfaceDescriptor
);
}
}
} | [
"protected",
"function",
"addInterfaces",
"(",
"$",
"interfaces",
",",
"$",
"fileDescriptor",
")",
"{",
"foreach",
"(",
"$",
"interfaces",
"as",
"$",
"interface",
")",
"{",
"$",
"interfaceDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"interface",
")",
";",
"if",
"(",
"$",
"interfaceDescriptor",
")",
"{",
"$",
"interfaceDescriptor",
"->",
"setLocation",
"(",
"$",
"fileDescriptor",
",",
"$",
"interface",
"->",
"getLineNumber",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"interfaceDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
"==",
"0",
")",
"{",
"$",
"interfaceDescriptor",
"->",
"getTags",
"(",
")",
"->",
"set",
"(",
"'package'",
",",
"$",
"fileDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
";",
"}",
"$",
"fileDescriptor",
"->",
"getInterfaces",
"(",
")",
"->",
"set",
"(",
"$",
"interfaceDescriptor",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
",",
"$",
"interfaceDescriptor",
")",
";",
"}",
"}",
"}"
] | Registers the child interfaces with the generated File Descriptor.
@param InterfaceReflector[] $interfaces
@param FileDescriptor $fileDescriptor
@return void | [
"Registers",
"the",
"child",
"interfaces",
"with",
"the",
"generated",
"File",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L154-L171 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.addTraits | protected function addTraits($traits, $fileDescriptor)
{
foreach ($traits as $trait) {
$traitDescriptor = $this->getBuilder()->buildDescriptor($trait);
if ($traitDescriptor) {
$traitDescriptor->setLocation($fileDescriptor, $trait->getLineNumber());
if (count($traitDescriptor->getTags()->get('package', new Collection())) == 0) {
$traitDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getTraits()->set(
$traitDescriptor->getFullyQualifiedStructuralElementName(),
$traitDescriptor
);
}
}
} | php | protected function addTraits($traits, $fileDescriptor)
{
foreach ($traits as $trait) {
$traitDescriptor = $this->getBuilder()->buildDescriptor($trait);
if ($traitDescriptor) {
$traitDescriptor->setLocation($fileDescriptor, $trait->getLineNumber());
if (count($traitDescriptor->getTags()->get('package', new Collection())) == 0) {
$traitDescriptor->getTags()
->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
}
$fileDescriptor->getTraits()->set(
$traitDescriptor->getFullyQualifiedStructuralElementName(),
$traitDescriptor
);
}
}
} | [
"protected",
"function",
"addTraits",
"(",
"$",
"traits",
",",
"$",
"fileDescriptor",
")",
"{",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"$",
"traitDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"trait",
")",
";",
"if",
"(",
"$",
"traitDescriptor",
")",
"{",
"$",
"traitDescriptor",
"->",
"setLocation",
"(",
"$",
"fileDescriptor",
",",
"$",
"trait",
"->",
"getLineNumber",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"traitDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
"==",
"0",
")",
"{",
"$",
"traitDescriptor",
"->",
"getTags",
"(",
")",
"->",
"set",
"(",
"'package'",
",",
"$",
"fileDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
";",
"}",
"$",
"fileDescriptor",
"->",
"getTraits",
"(",
")",
"->",
"set",
"(",
"$",
"traitDescriptor",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
",",
"$",
"traitDescriptor",
")",
";",
"}",
"}",
"}"
] | Registers the child traits with the generated File Descriptor.
@param TraitReflector[] $traits
@param FileDescriptor $fileDescriptor
@return void | [
"Registers",
"the",
"child",
"traits",
"with",
"the",
"generated",
"File",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L181-L198 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.addMarkers | protected function addMarkers($markers, $fileDescriptor)
{
foreach ($markers as $marker) {
list($type, $message, $line) = $marker;
$fileDescriptor->getMarkers()->add(
array(
'type' => $type,
'message' => $message,
'line' => $line,
)
);
}
} | php | protected function addMarkers($markers, $fileDescriptor)
{
foreach ($markers as $marker) {
list($type, $message, $line) = $marker;
$fileDescriptor->getMarkers()->add(
array(
'type' => $type,
'message' => $message,
'line' => $line,
)
);
}
} | [
"protected",
"function",
"addMarkers",
"(",
"$",
"markers",
",",
"$",
"fileDescriptor",
")",
"{",
"foreach",
"(",
"$",
"markers",
"as",
"$",
"marker",
")",
"{",
"list",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"line",
")",
"=",
"$",
"marker",
";",
"$",
"fileDescriptor",
"->",
"getMarkers",
"(",
")",
"->",
"add",
"(",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'message'",
"=>",
"$",
"message",
",",
"'line'",
"=>",
"$",
"line",
",",
")",
")",
";",
"}",
"}"
] | Registers the markers that were found in a File with the File Descriptor.
@param string[] $markers
@param FileDescriptor $fileDescriptor
@return void | [
"Registers",
"the",
"markers",
"that",
"were",
"found",
"in",
"a",
"File",
"with",
"the",
"File",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L208-L220 |
php-lug/lug | src/Bundle/ResourceBundle/Form/Type/CsrfProtectionType.php | CsrfProtectionType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('submit', SubmitType::class, ['label' => $options['label']])
->addEventSubscriber($this->flashCsrfProtectionSubscriber);
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('submit', SubmitType::class, ['label' => $options['label']])
->addEventSubscriber($this->flashCsrfProtectionSubscriber);
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'submit'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"$",
"options",
"[",
"'label'",
"]",
"]",
")",
"->",
"addEventSubscriber",
"(",
"$",
"this",
"->",
"flashCsrfProtectionSubscriber",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Form/Type/CsrfProtectionType.php#L42-L47 |
php-lug/lug | src/Bundle/ResourceBundle/Form/Type/CsrfProtectionType.php | CsrfProtectionType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['id'] .= '_'.str_replace('.', '', uniqid(null, true));
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['id'] .= '_'.str_replace('.', '', uniqid(null, true));
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'id'",
"]",
".=",
"'_'",
".",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"uniqid",
"(",
"null",
",",
"true",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Form/Type/CsrfProtectionType.php#L52-L55 |
HedronDev/hedron | src/Filter/ProjectTypeFilter.php | ProjectTypeFilter.filter | public function filter(PluginDefinitionInterface $definition): bool {
/** @var \Hedron\Annotation\Parser $definition */
$project_type = $definition->getProjectType();
if (in_array($this->projectType, $definition->getExclusions())) {
return FALSE;
}
if ($project_type == $this->projectType || $project_type == 'all') {
return TRUE;
}
return FALSE;
} | php | public function filter(PluginDefinitionInterface $definition): bool {
/** @var \Hedron\Annotation\Parser $definition */
$project_type = $definition->getProjectType();
if (in_array($this->projectType, $definition->getExclusions())) {
return FALSE;
}
if ($project_type == $this->projectType || $project_type == 'all') {
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"filter",
"(",
"PluginDefinitionInterface",
"$",
"definition",
")",
":",
"bool",
"{",
"/** @var \\Hedron\\Annotation\\Parser $definition */",
"$",
"project_type",
"=",
"$",
"definition",
"->",
"getProjectType",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"projectType",
",",
"$",
"definition",
"->",
"getExclusions",
"(",
")",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"if",
"(",
"$",
"project_type",
"==",
"$",
"this",
"->",
"projectType",
"||",
"$",
"project_type",
"==",
"'all'",
")",
"{",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Filter/ProjectTypeFilter.php#L27-L37 |
asbamboo/database | Manager.php | Manager.preBindDoctrineEvent | private function preBindDoctrineEvent() : void
{
if(EventScheduler::instance()->has(Event::DATA_CHANGED)){
$this->getEventManager()->addEventListener([Events::postPersist, Events::postUpdate, Events::postRemove], new Class{
public function postPersist(LifecycleEventArgs $args) : void
{
EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['created', $args->getEntityManager(), $args->getEntity()]);
}
public function postUpdate(LifecycleEventArgs $args) : void
{
EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['updated', $args->getEntityManager(), $args->getEntity()]);
}
public function postRemove(LifecycleEventArgs $args) : void
{
EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['deleted', $args->getEntityManager(), $args->getEntity()]);
}
});
}
} | php | private function preBindDoctrineEvent() : void
{
if(EventScheduler::instance()->has(Event::DATA_CHANGED)){
$this->getEventManager()->addEventListener([Events::postPersist, Events::postUpdate, Events::postRemove], new Class{
public function postPersist(LifecycleEventArgs $args) : void
{
EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['created', $args->getEntityManager(), $args->getEntity()]);
}
public function postUpdate(LifecycleEventArgs $args) : void
{
EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['updated', $args->getEntityManager(), $args->getEntity()]);
}
public function postRemove(LifecycleEventArgs $args) : void
{
EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['deleted', $args->getEntityManager(), $args->getEntity()]);
}
});
}
} | [
"private",
"function",
"preBindDoctrineEvent",
"(",
")",
":",
"void",
"{",
"if",
"(",
"EventScheduler",
"::",
"instance",
"(",
")",
"->",
"has",
"(",
"Event",
"::",
"DATA_CHANGED",
")",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"addEventListener",
"(",
"[",
"Events",
"::",
"postPersist",
",",
"Events",
"::",
"postUpdate",
",",
"Events",
"::",
"postRemove",
"]",
",",
"new",
"Class",
"",
"{",
"public",
"function",
"postPersist",
"(",
"LifecycleEventArgs",
"$",
"args",
")",
":",
"void",
"{",
"EventScheduler",
"::",
"instance",
"(",
")",
"->",
"trigger",
"(",
"Event",
"::",
"DATA_CHANGED",
",",
"[",
"'created'",
",",
"$",
"args",
"->",
"getEntityManager",
"(",
")",
",",
"$",
"args",
"->",
"getEntity",
"(",
")",
"]",
")",
";",
"}",
"public",
"",
"function",
"postUpdate",
"(",
"LifecycleEventArgs",
"$",
"args",
")",
":",
"void",
"{",
"EventScheduler",
"::",
"instance",
"(",
")",
"->",
"trigger",
"(",
"Event",
"::",
"DATA_CHANGED",
",",
"[",
"'updated'",
",",
"$",
"args",
"->",
"getEntityManager",
"(",
")",
",",
"$",
"args",
"->",
"getEntity",
"(",
")",
"]",
")",
";",
"}",
"public",
"",
"function",
"postRemove",
"(",
"LifecycleEventArgs",
"$",
"args",
")",
":",
"void",
"{",
"EventScheduler",
"::",
"instance",
"(",
")",
"->",
"trigger",
"(",
"Event",
"::",
"DATA_CHANGED",
",",
"[",
"'deleted'",
",",
"$",
"args",
"->",
"getEntityManager",
"(",
")",
",",
"$",
"args",
"->",
"getEntity",
"(",
")",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | 绑定doctine orm 相关联的事件
postUpdate, postRemove, postPersist == Event::DATA_CHANGED | [
"绑定doctine",
"orm",
"相关联的事件",
"postUpdate",
"postRemove",
"postPersist",
"==",
"Event",
"::",
"DATA_CHANGED"
] | train | https://github.com/asbamboo/database/blob/cb3260b0b267def7257d728ec639b6776d1b5a10/Manager.php#L41-L61 |
bpolaszek/simple-dbal | src/Model/Adapter/PDO/Statement.php | Statement.bindNamedParameters | protected function bindNamedParameters(): void
{
foreach ($this->getValues() as $key => $value) {
$value = $this->toScalar($value);
$this->getWrappedStatement()->bindValue(sprintf(':%s', $key), $value, $this->getPdoType($value));
}
} | php | protected function bindNamedParameters(): void
{
foreach ($this->getValues() as $key => $value) {
$value = $this->toScalar($value);
$this->getWrappedStatement()->bindValue(sprintf(':%s', $key), $value, $this->getPdoType($value));
}
} | [
"protected",
"function",
"bindNamedParameters",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getValues",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"toScalar",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"getWrappedStatement",
"(",
")",
"->",
"bindValue",
"(",
"sprintf",
"(",
"':%s'",
",",
"$",
"key",
")",
",",
"$",
"value",
",",
"$",
"this",
"->",
"getPdoType",
"(",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Bind :named parameters | [
"Bind",
":",
"named",
"parameters"
] | train | https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/PDO/Statement.php#L81-L87 |
bpolaszek/simple-dbal | src/Model/Adapter/PDO/Statement.php | Statement.bindNumericParameters | protected function bindNumericParameters(): void
{
$values = $this->getValues();
$cnt = count($values);
for ($index0 = 0, $index1 = 1; $index0 < $cnt; $index0++, $index1++) {
$value = $this->toScalar($values[$index0]);
$this->getWrappedStatement()->bindValue($index1, $value, $this->getPdoType($value));
}
} | php | protected function bindNumericParameters(): void
{
$values = $this->getValues();
$cnt = count($values);
for ($index0 = 0, $index1 = 1; $index0 < $cnt; $index0++, $index1++) {
$value = $this->toScalar($values[$index0]);
$this->getWrappedStatement()->bindValue($index1, $value, $this->getPdoType($value));
}
} | [
"protected",
"function",
"bindNumericParameters",
"(",
")",
":",
"void",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"$",
"cnt",
"=",
"count",
"(",
"$",
"values",
")",
";",
"for",
"(",
"$",
"index0",
"=",
"0",
",",
"$",
"index1",
"=",
"1",
";",
"$",
"index0",
"<",
"$",
"cnt",
";",
"$",
"index0",
"++",
",",
"$",
"index1",
"++",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"toScalar",
"(",
"$",
"values",
"[",
"$",
"index0",
"]",
")",
";",
"$",
"this",
"->",
"getWrappedStatement",
"(",
")",
"->",
"bindValue",
"(",
"$",
"index1",
",",
"$",
"value",
",",
"$",
"this",
"->",
"getPdoType",
"(",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Bind ? parameters | [
"Bind",
"?",
"parameters"
] | train | https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/PDO/Statement.php#L92-L100 |
thupan/framework | src/Service/Minifier.php | Minifier.minify | public static function minify($js, $options = array())
{
try {
ob_start();
$jshrink = new Minifier();
$js = $jshrink->lock($js);
$jshrink->minifyDirectToOutput($js, $options);
// Sometimes there's a leading new line, so we trim that out here.
$js = ltrim(ob_get_clean());
$js = $jshrink->unlock($js);
unset($jshrink);
return $js;
} catch (\Exception $e) {
if (isset($jshrink)) {
// Since the breakdownScript function probably wasn't finished
// we clean it out before discarding it.
$jshrink->clean();
unset($jshrink);
}
// without this call things get weird, with partially outputted js.
ob_end_clean();
throw $e;
}
} | php | public static function minify($js, $options = array())
{
try {
ob_start();
$jshrink = new Minifier();
$js = $jshrink->lock($js);
$jshrink->minifyDirectToOutput($js, $options);
// Sometimes there's a leading new line, so we trim that out here.
$js = ltrim(ob_get_clean());
$js = $jshrink->unlock($js);
unset($jshrink);
return $js;
} catch (\Exception $e) {
if (isset($jshrink)) {
// Since the breakdownScript function probably wasn't finished
// we clean it out before discarding it.
$jshrink->clean();
unset($jshrink);
}
// without this call things get weird, with partially outputted js.
ob_end_clean();
throw $e;
}
} | [
"public",
"static",
"function",
"minify",
"(",
"$",
"js",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"ob_start",
"(",
")",
";",
"$",
"jshrink",
"=",
"new",
"Minifier",
"(",
")",
";",
"$",
"js",
"=",
"$",
"jshrink",
"->",
"lock",
"(",
"$",
"js",
")",
";",
"$",
"jshrink",
"->",
"minifyDirectToOutput",
"(",
"$",
"js",
",",
"$",
"options",
")",
";",
"// Sometimes there's a leading new line, so we trim that out here.",
"$",
"js",
"=",
"ltrim",
"(",
"ob_get_clean",
"(",
")",
")",
";",
"$",
"js",
"=",
"$",
"jshrink",
"->",
"unlock",
"(",
"$",
"js",
")",
";",
"unset",
"(",
"$",
"jshrink",
")",
";",
"return",
"$",
"js",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"jshrink",
")",
")",
"{",
"// Since the breakdownScript function probably wasn't finished",
"// we clean it out before discarding it.",
"$",
"jshrink",
"->",
"clean",
"(",
")",
";",
"unset",
"(",
"$",
"jshrink",
")",
";",
"}",
"// without this call things get weird, with partially outputted js.",
"ob_end_clean",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Takes a string containing javascript and removes unneeded characters in
order to shrink the code without altering it's functionality.
@param string $js The raw javascript to be minified
@param array $options Various runtime options in an associative array
@throws \Exception
@return bool|string | [
"Takes",
"a",
"string",
"containing",
"javascript",
"and",
"removes",
"unneeded",
"characters",
"in",
"order",
"to",
"shrink",
"the",
"code",
"without",
"altering",
"it",
"s",
"functionality",
"."
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Minifier.php#L103-L132 |
thupan/framework | src/Service/Minifier.php | Minifier.loop | protected function loop()
{
while ($this->a !== false && !is_null($this->a) && $this->a !== '') {
switch ($this->a) {
// new lines
case "\n":
// if the next line is something that can't stand alone preserve the newline
if (strpos('(-+{[@', $this->b) !== false) {
echo $this->a;
$this->saveString();
break;
}
// if B is a space we skip the rest of the switch block and go down to the
// string/regex check below, resetting $this->b with getReal
if($this->b === ' ')
break;
// otherwise we treat the newline like a space
case ' ':
if(static::isAlphaNumeric($this->b))
echo $this->a;
$this->saveString();
break;
default:
switch ($this->b) {
case "\n":
if (strpos('}])+-"\'', $this->a) !== false) {
echo $this->a;
$this->saveString();
break;
} else {
if (static::isAlphaNumeric($this->a)) {
echo $this->a;
$this->saveString();
}
}
break;
case ' ':
if(!static::isAlphaNumeric($this->a))
break;
default:
// check for some regex that breaks stuff
if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) {
$this->saveRegex();
continue;
}
echo $this->a;
$this->saveString();
break;
}
}
// do reg check of doom
$this->b = $this->getReal();
if(($this->b == '/' && strpos('(,=:[!&|?', $this->a) !== false))
$this->saveRegex();
}
} | php | protected function loop()
{
while ($this->a !== false && !is_null($this->a) && $this->a !== '') {
switch ($this->a) {
// new lines
case "\n":
// if the next line is something that can't stand alone preserve the newline
if (strpos('(-+{[@', $this->b) !== false) {
echo $this->a;
$this->saveString();
break;
}
// if B is a space we skip the rest of the switch block and go down to the
// string/regex check below, resetting $this->b with getReal
if($this->b === ' ')
break;
// otherwise we treat the newline like a space
case ' ':
if(static::isAlphaNumeric($this->b))
echo $this->a;
$this->saveString();
break;
default:
switch ($this->b) {
case "\n":
if (strpos('}])+-"\'', $this->a) !== false) {
echo $this->a;
$this->saveString();
break;
} else {
if (static::isAlphaNumeric($this->a)) {
echo $this->a;
$this->saveString();
}
}
break;
case ' ':
if(!static::isAlphaNumeric($this->a))
break;
default:
// check for some regex that breaks stuff
if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) {
$this->saveRegex();
continue;
}
echo $this->a;
$this->saveString();
break;
}
}
// do reg check of doom
$this->b = $this->getReal();
if(($this->b == '/' && strpos('(,=:[!&|?', $this->a) !== false))
$this->saveRegex();
}
} | [
"protected",
"function",
"loop",
"(",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"a",
"!==",
"false",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"a",
")",
"&&",
"$",
"this",
"->",
"a",
"!==",
"''",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"a",
")",
"{",
"// new lines",
"case",
"\"\\n\"",
":",
"// if the next line is something that can't stand alone preserve the newline",
"if",
"(",
"strpos",
"(",
"'(-+{[@'",
",",
"$",
"this",
"->",
"b",
")",
"!==",
"false",
")",
"{",
"echo",
"$",
"this",
"->",
"a",
";",
"$",
"this",
"->",
"saveString",
"(",
")",
";",
"break",
";",
"}",
"// if B is a space we skip the rest of the switch block and go down to the",
"// string/regex check below, resetting $this->b with getReal",
"if",
"(",
"$",
"this",
"->",
"b",
"===",
"' '",
")",
"break",
";",
"// otherwise we treat the newline like a space",
"case",
"' '",
":",
"if",
"(",
"static",
"::",
"isAlphaNumeric",
"(",
"$",
"this",
"->",
"b",
")",
")",
"echo",
"$",
"this",
"->",
"a",
";",
"$",
"this",
"->",
"saveString",
"(",
")",
";",
"break",
";",
"default",
":",
"switch",
"(",
"$",
"this",
"->",
"b",
")",
"{",
"case",
"\"\\n\"",
":",
"if",
"(",
"strpos",
"(",
"'}])+-\"\\''",
",",
"$",
"this",
"->",
"a",
")",
"!==",
"false",
")",
"{",
"echo",
"$",
"this",
"->",
"a",
";",
"$",
"this",
"->",
"saveString",
"(",
")",
";",
"break",
";",
"}",
"else",
"{",
"if",
"(",
"static",
"::",
"isAlphaNumeric",
"(",
"$",
"this",
"->",
"a",
")",
")",
"{",
"echo",
"$",
"this",
"->",
"a",
";",
"$",
"this",
"->",
"saveString",
"(",
")",
";",
"}",
"}",
"break",
";",
"case",
"' '",
":",
"if",
"(",
"!",
"static",
"::",
"isAlphaNumeric",
"(",
"$",
"this",
"->",
"a",
")",
")",
"break",
";",
"default",
":",
"// check for some regex that breaks stuff",
"if",
"(",
"$",
"this",
"->",
"a",
"===",
"'/'",
"&&",
"(",
"$",
"this",
"->",
"b",
"===",
"'\\''",
"||",
"$",
"this",
"->",
"b",
"===",
"'\"'",
")",
")",
"{",
"$",
"this",
"->",
"saveRegex",
"(",
")",
";",
"continue",
";",
"}",
"echo",
"$",
"this",
"->",
"a",
";",
"$",
"this",
"->",
"saveString",
"(",
")",
";",
"break",
";",
"}",
"}",
"// do reg check of doom",
"$",
"this",
"->",
"b",
"=",
"$",
"this",
"->",
"getReal",
"(",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"b",
"==",
"'/'",
"&&",
"strpos",
"(",
"'(,=:[!&|?'",
",",
"$",
"this",
"->",
"a",
")",
"!==",
"false",
")",
")",
"$",
"this",
"->",
"saveRegex",
"(",
")",
";",
"}",
"}"
] | The primary action occurs here. This function loops through the input string,
outputting anything that's relevant and discarding anything that is not. | [
"The",
"primary",
"action",
"occurs",
"here",
".",
"This",
"function",
"loops",
"through",
"the",
"input",
"string",
"outputting",
"anything",
"that",
"s",
"relevant",
"and",
"discarding",
"anything",
"that",
"is",
"not",
"."
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Minifier.php#L176-L242 |
thupan/framework | src/Service/Minifier.php | Minifier.getChar | protected function getChar()
{
// Check to see if we had anything in the look ahead buffer and use that.
if (isset($this->c)) {
$char = $this->c;
unset($this->c);
// Otherwise we start pulling from the input.
} else {
$char = substr($this->input, $this->index, 1);
// If the next character doesn't exist return false.
if (isset($char) && $char === false) {
return false;
}
// Otherwise increment the pointer and use this char.
$this->index++;
}
// Normalize all whitespace except for the newline character into a
// standard space.
if($char !== "\n" && ord($char) < 32)
return ' ';
return $char;
} | php | protected function getChar()
{
// Check to see if we had anything in the look ahead buffer and use that.
if (isset($this->c)) {
$char = $this->c;
unset($this->c);
// Otherwise we start pulling from the input.
} else {
$char = substr($this->input, $this->index, 1);
// If the next character doesn't exist return false.
if (isset($char) && $char === false) {
return false;
}
// Otherwise increment the pointer and use this char.
$this->index++;
}
// Normalize all whitespace except for the newline character into a
// standard space.
if($char !== "\n" && ord($char) < 32)
return ' ';
return $char;
} | [
"protected",
"function",
"getChar",
"(",
")",
"{",
"// Check to see if we had anything in the look ahead buffer and use that.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"c",
")",
")",
"{",
"$",
"char",
"=",
"$",
"this",
"->",
"c",
";",
"unset",
"(",
"$",
"this",
"->",
"c",
")",
";",
"// Otherwise we start pulling from the input.",
"}",
"else",
"{",
"$",
"char",
"=",
"substr",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"index",
",",
"1",
")",
";",
"// If the next character doesn't exist return false.",
"if",
"(",
"isset",
"(",
"$",
"char",
")",
"&&",
"$",
"char",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"// Otherwise increment the pointer and use this char.",
"$",
"this",
"->",
"index",
"++",
";",
"}",
"// Normalize all whitespace except for the newline character into a",
"// standard space.",
"if",
"(",
"$",
"char",
"!==",
"\"\\n\"",
"&&",
"ord",
"(",
"$",
"char",
")",
"<",
"32",
")",
"return",
"' '",
";",
"return",
"$",
"char",
";",
"}"
] | Returns the next string for processing based off of the current index.
@return string | [
"Returns",
"the",
"next",
"string",
"for",
"processing",
"based",
"off",
"of",
"the",
"current",
"index",
"."
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Minifier.php#L263-L290 |
jasny/controller | src/Controller/Session/Flash.php | Flash.get | public function get()
{
if (!isset($this->data) && isset($this->session[$this->key])) {
$this->data = $this->session[$this->key];
unset($this->session[$this->key]);
}
return $this->data ? (object)$this->data : null;
} | php | public function get()
{
if (!isset($this->data) && isset($this->session[$this->key])) {
$this->data = $this->session[$this->key];
unset($this->session[$this->key]);
}
return $this->data ? (object)$this->data : null;
} | [
"public",
"function",
"get",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"session",
"[",
"$",
"this",
"->",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"session",
"[",
"$",
"this",
"->",
"key",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"session",
"[",
"$",
"this",
"->",
"key",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"?",
"(",
"object",
")",
"$",
"this",
"->",
"data",
":",
"null",
";",
"}"
] | Get the flash.
@return object | [
"Get",
"the",
"flash",
"."
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session/Flash.php#L63-L71 |
jasny/controller | src/Controller/Session/Flash.php | Flash.reissue | public function reissue()
{
if (!isset($this->data) && isset($this->session[$this->key])) {
$this->data = $this->session[$this->key];
} else {
$this->session[$this->key] = $this->data;
}
} | php | public function reissue()
{
if (!isset($this->data) && isset($this->session[$this->key])) {
$this->data = $this->session[$this->key];
} else {
$this->session[$this->key] = $this->data;
}
} | [
"public",
"function",
"reissue",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"session",
"[",
"$",
"this",
"->",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"session",
"[",
"$",
"this",
"->",
"key",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"session",
"[",
"$",
"this",
"->",
"key",
"]",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"}"
] | Reissue the flash. | [
"Reissue",
"the",
"flash",
"."
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session/Flash.php#L76-L83 |
simbiosis-group/yii2-helper | widgets/CalHeatmap.php | CalHeatmap.init | public function init()
{
parent::init();
CalHeatmapAsset::register($this->getView());
$this->url = Url::to($this->url);
} | php | public function init()
{
parent::init();
CalHeatmapAsset::register($this->getView());
$this->url = Url::to($this->url);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"CalHeatmapAsset",
"::",
"register",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
")",
";",
"$",
"this",
"->",
"url",
"=",
"Url",
"::",
"to",
"(",
"$",
"this",
"->",
"url",
")",
";",
"}"
] | Initializes the widget. | [
"Initializes",
"the",
"widget",
"."
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/widgets/CalHeatmap.php#L54-L60 |
simbiosis-group/yii2-helper | widgets/CalHeatmap.php | CalHeatmap.run | public function run()
{
echo Html::tag('div', '', ['id' => $this->id, 'align' => 'center']);
$this->getView()->registerJs($this->js);
} | php | public function run()
{
echo Html::tag('div', '', ['id' => $this->id, 'align' => 'center']);
$this->getView()->registerJs($this->js);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"echo",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"''",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'align'",
"=>",
"'center'",
"]",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"$",
"this",
"->",
"js",
")",
";",
"}"
] | Renders the widget. | [
"Renders",
"the",
"widget",
"."
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/widgets/CalHeatmap.php#L65-L69 |
skeeks-cms/cms-dadata-suggest | src/widgets/suggest/DadataSuggestInputWidget.php | DadataSuggestInputWidget.init | public function init()
{
parent::init();
//$this->options['id'] = $this->id;
Html::addCssClass($this->options, ['form-control']);
$this->clientOptions['id'] = $this->options['id'];
$this->clientOptions['backend'] = Url::to('/dadataSuggest/backend/save-address');
if ($this->hint)
{
$this->clientOptions['suggestOptions']['hint'] = $this->hint;
}
if ($this->addon)
{
$this->clientOptions['suggestOptions']['addon'] = $this->addon;
}
$this->clientOptions = ArrayHelper::merge([
'suggestOptions' =>
[
'serviceUrl' => \Yii::$app->dadataSuggestApi->baseUrl . "/rs",
'token' => \Yii::$app->dadataSuggestApi->authorization_token,
'type' => $this->type,
'count' => $this->count,
]
], $this->clientOptions);
} | php | public function init()
{
parent::init();
//$this->options['id'] = $this->id;
Html::addCssClass($this->options, ['form-control']);
$this->clientOptions['id'] = $this->options['id'];
$this->clientOptions['backend'] = Url::to('/dadataSuggest/backend/save-address');
if ($this->hint)
{
$this->clientOptions['suggestOptions']['hint'] = $this->hint;
}
if ($this->addon)
{
$this->clientOptions['suggestOptions']['addon'] = $this->addon;
}
$this->clientOptions = ArrayHelper::merge([
'suggestOptions' =>
[
'serviceUrl' => \Yii::$app->dadataSuggestApi->baseUrl . "/rs",
'token' => \Yii::$app->dadataSuggestApi->authorization_token,
'type' => $this->type,
'count' => $this->count,
]
], $this->clientOptions);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"//$this->options['id'] = $this->id;",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"options",
",",
"[",
"'form-control'",
"]",
")",
";",
"$",
"this",
"->",
"clientOptions",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
";",
"$",
"this",
"->",
"clientOptions",
"[",
"'backend'",
"]",
"=",
"Url",
"::",
"to",
"(",
"'/dadataSuggest/backend/save-address'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hint",
")",
"{",
"$",
"this",
"->",
"clientOptions",
"[",
"'suggestOptions'",
"]",
"[",
"'hint'",
"]",
"=",
"$",
"this",
"->",
"hint",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"addon",
")",
"{",
"$",
"this",
"->",
"clientOptions",
"[",
"'suggestOptions'",
"]",
"[",
"'addon'",
"]",
"=",
"$",
"this",
"->",
"addon",
";",
"}",
"$",
"this",
"->",
"clientOptions",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"[",
"'suggestOptions'",
"=>",
"[",
"'serviceUrl'",
"=>",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"dadataSuggestApi",
"->",
"baseUrl",
".",
"\"/rs\"",
",",
"'token'",
"=>",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"dadataSuggestApi",
"->",
"authorization_token",
",",
"'type'",
"=>",
"$",
"this",
"->",
"type",
",",
"'count'",
"=>",
"$",
"this",
"->",
"count",
",",
"]",
"]",
",",
"$",
"this",
"->",
"clientOptions",
")",
";",
"}"
] | clear | [
"clear"
] | train | https://github.com/skeeks-cms/cms-dadata-suggest/blob/966b4a3a6e3824deb54fa09b7bfe82494760571e/src/widgets/suggest/DadataSuggestInputWidget.php#L33-L63 |
PayBreak/foundation | src/Decision/Condition/IsDefaultCondition.php | IsDefaultCondition.checkCondition | public function checkCondition(Value $value)
{
if ($this->getValue() instanceof Value) {
if ($value->getType() != Value::VALUE_DEFAULT) {
throw new ProcessingException('Value is not default type');
}
if ($value->getValue() == $this->getValue()->getValue()) {
return true;
}
return false;
}
throw new ProcessingException('Internal value not set. Could not perform any checks.');
} | php | public function checkCondition(Value $value)
{
if ($this->getValue() instanceof Value) {
if ($value->getType() != Value::VALUE_DEFAULT) {
throw new ProcessingException('Value is not default type');
}
if ($value->getValue() == $this->getValue()->getValue()) {
return true;
}
return false;
}
throw new ProcessingException('Internal value not set. Could not perform any checks.');
} | [
"public",
"function",
"checkCondition",
"(",
"Value",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
"instanceof",
"Value",
")",
"{",
"if",
"(",
"$",
"value",
"->",
"getType",
"(",
")",
"!=",
"Value",
"::",
"VALUE_DEFAULT",
")",
"{",
"throw",
"new",
"ProcessingException",
"(",
"'Value is not default type'",
")",
";",
"}",
"if",
"(",
"$",
"value",
"->",
"getValue",
"(",
")",
"==",
"$",
"this",
"->",
"getValue",
"(",
")",
"->",
"getValue",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"throw",
"new",
"ProcessingException",
"(",
"'Internal value not set. Could not perform any checks.'",
")",
";",
"}"
] | Test Value against Condition
@author WN
@param Value $value
@return bool
@throws ProcessingException | [
"Test",
"Value",
"against",
"Condition"
] | train | https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Decision/Condition/IsDefaultCondition.php#L41-L56 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.build_query | final protected function build_query(){
$select = empty($this->_select) ? $this->default_select() : implode(', ', $this->_select);
$calc = $this->_calc_rows ? ' SQL_CALC_FOUND_ROWS' : '';
$distinct = $this->_distinct ? sprintf('DISTINCT(%s)', $this->escape_column_name($this->_distinct)) : '';
$from = empty($this->_from) ? $this->table : $this->_from;
// Build query
$sql = <<<SQL
SELECT{$calc} {$distinct} {$select} FROM {$from}
SQL;
// Add join
$join = [];
if( !empty($this->_join) ){
$join = $this->_join;
}else{
$default_join = $this->default_join();
if( !empty($default_join) ){
$join = $default_join;
}
}
foreach($join as list($table, $on, $method)){
$method = 'INNER' === strtoupper($method) ? 'INNER' : 'LEFT';
$sql .= <<<SQL
{$method} JOIN {$table}
ON {$on}
SQL;
}
// Add where
if( !empty($this->_wheres) ){
$where_clause = $this->build_where($this->_wheres);
$sql .= <<<SQL
WHERE {$where_clause}
SQL;
}
// Add group by
if( !empty($this->_group_by) ){
$group_by = implode(', ', $this->_group_by);
$sql .= <<<SQL
GROUP BY {$group_by}
SQL;
}
// Add order by
if( !empty($this->_order_by) ){
$order_by = implode(', ', $this->_order_by);
$sql .= <<<SQL
ORDER BY {$order_by}
SQL;
}
// Add limit
if( !empty($this->_limit) ){
list($per_page, $offset) = $this->_limit;
$limit = <<<SQL
LIMIT %d, %d
SQL;
$sql .= sprintf($limit, $offset, $per_page);
}
return $sql;
} | php | final protected function build_query(){
$select = empty($this->_select) ? $this->default_select() : implode(', ', $this->_select);
$calc = $this->_calc_rows ? ' SQL_CALC_FOUND_ROWS' : '';
$distinct = $this->_distinct ? sprintf('DISTINCT(%s)', $this->escape_column_name($this->_distinct)) : '';
$from = empty($this->_from) ? $this->table : $this->_from;
// Build query
$sql = <<<SQL
SELECT{$calc} {$distinct} {$select} FROM {$from}
SQL;
// Add join
$join = [];
if( !empty($this->_join) ){
$join = $this->_join;
}else{
$default_join = $this->default_join();
if( !empty($default_join) ){
$join = $default_join;
}
}
foreach($join as list($table, $on, $method)){
$method = 'INNER' === strtoupper($method) ? 'INNER' : 'LEFT';
$sql .= <<<SQL
{$method} JOIN {$table}
ON {$on}
SQL;
}
// Add where
if( !empty($this->_wheres) ){
$where_clause = $this->build_where($this->_wheres);
$sql .= <<<SQL
WHERE {$where_clause}
SQL;
}
// Add group by
if( !empty($this->_group_by) ){
$group_by = implode(', ', $this->_group_by);
$sql .= <<<SQL
GROUP BY {$group_by}
SQL;
}
// Add order by
if( !empty($this->_order_by) ){
$order_by = implode(', ', $this->_order_by);
$sql .= <<<SQL
ORDER BY {$order_by}
SQL;
}
// Add limit
if( !empty($this->_limit) ){
list($per_page, $offset) = $this->_limit;
$limit = <<<SQL
LIMIT %d, %d
SQL;
$sql .= sprintf($limit, $offset, $per_page);
}
return $sql;
} | [
"final",
"protected",
"function",
"build_query",
"(",
")",
"{",
"$",
"select",
"=",
"empty",
"(",
"$",
"this",
"->",
"_select",
")",
"?",
"$",
"this",
"->",
"default_select",
"(",
")",
":",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"_select",
")",
";",
"$",
"calc",
"=",
"$",
"this",
"->",
"_calc_rows",
"?",
"' SQL_CALC_FOUND_ROWS'",
":",
"''",
";",
"$",
"distinct",
"=",
"$",
"this",
"->",
"_distinct",
"?",
"sprintf",
"(",
"'DISTINCT(%s)'",
",",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"this",
"->",
"_distinct",
")",
")",
":",
"''",
";",
"$",
"from",
"=",
"empty",
"(",
"$",
"this",
"->",
"_from",
")",
"?",
"$",
"this",
"->",
"table",
":",
"$",
"this",
"->",
"_from",
";",
"// Build query",
"$",
"sql",
"=",
" <<<SQL\n SELECT{$calc} {$distinct} {$select} FROM {$from}\nSQL",
";",
"// Add join",
"$",
"join",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_join",
")",
")",
"{",
"$",
"join",
"=",
"$",
"this",
"->",
"_join",
";",
"}",
"else",
"{",
"$",
"default_join",
"=",
"$",
"this",
"->",
"default_join",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"default_join",
")",
")",
"{",
"$",
"join",
"=",
"$",
"default_join",
";",
"}",
"}",
"foreach",
"(",
"$",
"join",
"as",
"list",
"(",
"$",
"table",
",",
"$",
"on",
",",
"$",
"method",
")",
")",
"{",
"$",
"method",
"=",
"'INNER'",
"===",
"strtoupper",
"(",
"$",
"method",
")",
"?",
"'INNER'",
":",
"'LEFT'",
";",
"$",
"sql",
".=",
" <<<SQL\n {$method} JOIN {$table}\n ON {$on}\nSQL",
";",
"}",
"// Add where",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_wheres",
")",
")",
"{",
"$",
"where_clause",
"=",
"$",
"this",
"->",
"build_where",
"(",
"$",
"this",
"->",
"_wheres",
")",
";",
"$",
"sql",
".=",
" <<<SQL\n WHERE {$where_clause}\nSQL",
";",
"}",
"// Add group by",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_group_by",
")",
")",
"{",
"$",
"group_by",
"=",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"_group_by",
")",
";",
"$",
"sql",
".=",
" <<<SQL\n GROUP BY {$group_by}\nSQL",
";",
"}",
"// Add order by",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_order_by",
")",
")",
"{",
"$",
"order_by",
"=",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"_order_by",
")",
";",
"$",
"sql",
".=",
" <<<SQL\n ORDER BY {$order_by}\nSQL",
";",
"}",
"// Add limit",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_limit",
")",
")",
"{",
"list",
"(",
"$",
"per_page",
",",
"$",
"offset",
")",
"=",
"$",
"this",
"->",
"_limit",
";",
"$",
"limit",
"=",
" <<<SQL\n LIMIT %d, %d\nSQL",
";",
"$",
"sql",
".=",
"sprintf",
"(",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"per_page",
")",
";",
"}",
"return",
"$",
"sql",
";",
"}"
] | Build query with current setting
@return string | [
"Build",
"query",
"with",
"current",
"setting"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L118-L174 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.build_where | private function build_where(array $where_array){
$where_clause = [];
$counter = 0;
foreach( $where_array as list($glue, $where) ){
if( $counter ){
$where_clause[] = $glue;
}
if( is_array($where) ){
$where_clause[] = $this->build_where($where_array);
}else{
$where_clause[] = sprintf('(%s)', $where);
}
$counter++;
}
return sprintf('(%s)', implode(' ', $where_clause));
} | php | private function build_where(array $where_array){
$where_clause = [];
$counter = 0;
foreach( $where_array as list($glue, $where) ){
if( $counter ){
$where_clause[] = $glue;
}
if( is_array($where) ){
$where_clause[] = $this->build_where($where_array);
}else{
$where_clause[] = sprintf('(%s)', $where);
}
$counter++;
}
return sprintf('(%s)', implode(' ', $where_clause));
} | [
"private",
"function",
"build_where",
"(",
"array",
"$",
"where_array",
")",
"{",
"$",
"where_clause",
"=",
"[",
"]",
";",
"$",
"counter",
"=",
"0",
";",
"foreach",
"(",
"$",
"where_array",
"as",
"list",
"(",
"$",
"glue",
",",
"$",
"where",
")",
")",
"{",
"if",
"(",
"$",
"counter",
")",
"{",
"$",
"where_clause",
"[",
"]",
"=",
"$",
"glue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"where",
")",
")",
"{",
"$",
"where_clause",
"[",
"]",
"=",
"$",
"this",
"->",
"build_where",
"(",
"$",
"where_array",
")",
";",
"}",
"else",
"{",
"$",
"where_clause",
"[",
"]",
"=",
"sprintf",
"(",
"'(%s)'",
",",
"$",
"where",
")",
";",
"}",
"$",
"counter",
"++",
";",
"}",
"return",
"sprintf",
"(",
"'(%s)'",
",",
"implode",
"(",
"' '",
",",
"$",
"where_clause",
")",
")",
";",
"}"
] | Build where clause
@param array $where_array
@return string | [
"Build",
"where",
"clause"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L182-L197 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.select | final protected function select($name, $escape = true){
$this->_select[] = $escape
? $this->escape_column_name($name)
: $name;
return $this;
} | php | final protected function select($name, $escape = true){
$this->_select[] = $escape
? $this->escape_column_name($name)
: $name;
return $this;
} | [
"final",
"protected",
"function",
"select",
"(",
"$",
"name",
",",
"$",
"escape",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"_select",
"[",
"]",
"=",
"$",
"escape",
"?",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"name",
")",
":",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Set select param
@param string $name
@param bool $escape Default true
@return $this | [
"Set",
"select",
"param"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L206-L211 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.join | final protected function join($table, $on, $method = 'left'){
$this->_join[] = [$table, $on, $method];
return $this;
} | php | final protected function join($table, $on, $method = 'left'){
$this->_join[] = [$table, $on, $method];
return $this;
} | [
"final",
"protected",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"on",
",",
"$",
"method",
"=",
"'left'",
")",
"{",
"$",
"this",
"->",
"_join",
"[",
"]",
"=",
"[",
"$",
"table",
",",
"$",
"on",
",",
"$",
"method",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Set join
@param string $table
@param $on
@param string $method
@return $this | [
"Set",
"join"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L254-L257 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.where | final protected function where($where, $replace, $or = false){
if( is_array($replace) ){
array_unshift($replace, $where);
$query = call_user_func_array([$this->db, 'prepare'], $replace);
}else{
$query = $this->db->prepare($where, $replace);
}
$this->_wheres[] = [$this->and_or($or), $query];
return $this;
} | php | final protected function where($where, $replace, $or = false){
if( is_array($replace) ){
array_unshift($replace, $where);
$query = call_user_func_array([$this->db, 'prepare'], $replace);
}else{
$query = $this->db->prepare($where, $replace);
}
$this->_wheres[] = [$this->and_or($or), $query];
return $this;
} | [
"final",
"protected",
"function",
"where",
"(",
"$",
"where",
",",
"$",
"replace",
",",
"$",
"or",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"replace",
")",
")",
"{",
"array_unshift",
"(",
"$",
"replace",
",",
"$",
"where",
")",
";",
"$",
"query",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"db",
",",
"'prepare'",
"]",
",",
"$",
"replace",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"$",
"where",
",",
"$",
"replace",
")",
";",
"}",
"$",
"this",
"->",
"_wheres",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"and_or",
"(",
"$",
"or",
")",
",",
"$",
"query",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add where group
@param string $where
@param array|mixed $replace
@param bool $or
@return $this | [
"Add",
"where",
"group"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L267-L276 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.where_not_null | final protected function where_not_null($column, $or = false){
$this->_wheres[] = [$this->and_or($or), sprintf("%s IS NOT NULL", $this->escape_column_name($column))];
return $this;
} | php | final protected function where_not_null($column, $or = false){
$this->_wheres[] = [$this->and_or($or), sprintf("%s IS NOT NULL", $this->escape_column_name($column))];
return $this;
} | [
"final",
"protected",
"function",
"where_not_null",
"(",
"$",
"column",
",",
"$",
"or",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_wheres",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"and_or",
"(",
"$",
"or",
")",
",",
"sprintf",
"(",
"\"%s IS NOT NULL\"",
",",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"column",
")",
")",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add where not null clause
@param string $column
@param bool $or Default false
@return $this | [
"Add",
"where",
"not",
"null",
"clause"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L285-L288 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.where_like | final protected function where_like($column, $replace, $position = 'both', $or = false){
switch( strtolower($position) ){
case 'left':
$replace = '%'.$replace;
break;
case 'right':
$replace = $replace.'%';
break;
default:
$replace = '%'.$replace.'%';
break;
}
$column = $this->escape_column_name($column);
$this->_wheres[] = [$this->and_or($or), $this->db->prepare("{$column} LIKE %s", $replace)];
return $this;
} | php | final protected function where_like($column, $replace, $position = 'both', $or = false){
switch( strtolower($position) ){
case 'left':
$replace = '%'.$replace;
break;
case 'right':
$replace = $replace.'%';
break;
default:
$replace = '%'.$replace.'%';
break;
}
$column = $this->escape_column_name($column);
$this->_wheres[] = [$this->and_or($or), $this->db->prepare("{$column} LIKE %s", $replace)];
return $this;
} | [
"final",
"protected",
"function",
"where_like",
"(",
"$",
"column",
",",
"$",
"replace",
",",
"$",
"position",
"=",
"'both'",
",",
"$",
"or",
"=",
"false",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"position",
")",
")",
"{",
"case",
"'left'",
":",
"$",
"replace",
"=",
"'%'",
".",
"$",
"replace",
";",
"break",
";",
"case",
"'right'",
":",
"$",
"replace",
"=",
"$",
"replace",
".",
"'%'",
";",
"break",
";",
"default",
":",
"$",
"replace",
"=",
"'%'",
".",
"$",
"replace",
".",
"'%'",
";",
"break",
";",
"}",
"$",
"column",
"=",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"column",
")",
";",
"$",
"this",
"->",
"_wheres",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"and_or",
"(",
"$",
"or",
")",
",",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"\"{$column} LIKE %s\"",
",",
"$",
"replace",
")",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add Where LIKE
@param string $column
@param string $replace
@param string $position Position of %. 'left', 'right' or 'both'
@param bool $or
@return $this | [
"Add",
"Where",
"LIKE"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L299-L314 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.wheres | final protected function wheres(array $wheres, $or = false){
foreach($wheres as $where => $replace){
$this->where($where, $replace, $or);
}
return $this;
} | php | final protected function wheres(array $wheres, $or = false){
foreach($wheres as $where => $replace){
$this->where($where, $replace, $or);
}
return $this;
} | [
"final",
"protected",
"function",
"wheres",
"(",
"array",
"$",
"wheres",
",",
"$",
"or",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"wheres",
"as",
"$",
"where",
"=>",
"$",
"replace",
")",
"{",
"$",
"this",
"->",
"where",
"(",
"$",
"where",
",",
"$",
"replace",
",",
"$",
"or",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add where in one shot
@param array $wheres
@param bool $or
@return $this | [
"Add",
"where",
"in",
"one",
"shot"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L323-L328 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.where_group | final protected function where_group(array $wheres, $or = false, $each_or = false){
$where_segments = [];
foreach( $wheres as $where => $format ){
$where_segments[] = [$this->and_or($each_or), $this->db->prepare($where, $format)];
}
$this->_wheres[] = [$this->and_or($or), $where_segments];
return $this;
} | php | final protected function where_group(array $wheres, $or = false, $each_or = false){
$where_segments = [];
foreach( $wheres as $where => $format ){
$where_segments[] = [$this->and_or($each_or), $this->db->prepare($where, $format)];
}
$this->_wheres[] = [$this->and_or($or), $where_segments];
return $this;
} | [
"final",
"protected",
"function",
"where_group",
"(",
"array",
"$",
"wheres",
",",
"$",
"or",
"=",
"false",
",",
"$",
"each_or",
"=",
"false",
")",
"{",
"$",
"where_segments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"wheres",
"as",
"$",
"where",
"=>",
"$",
"format",
")",
"{",
"$",
"where_segments",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"and_or",
"(",
"$",
"each_or",
")",
",",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"$",
"where",
",",
"$",
"format",
")",
"]",
";",
"}",
"$",
"this",
"->",
"_wheres",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"and_or",
"(",
"$",
"or",
")",
",",
"$",
"where_segments",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add where group
@param array $wheres
@param bool $or
@param bool $each_or
@return $this | [
"Add",
"where",
"group"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L338-L345 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.group_by | final protected function group_by($column, $order = 'ASC'){
$order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC';
$this->_group_by[] = sprintf('%s %s', $this->escape_column_name($column), $order);
return $this;
} | php | final protected function group_by($column, $order = 'ASC'){
$order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC';
$this->_group_by[] = sprintf('%s %s', $this->escape_column_name($column), $order);
return $this;
} | [
"final",
"protected",
"function",
"group_by",
"(",
"$",
"column",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"$",
"order",
"=",
"'DESC'",
"===",
"strtoupper",
"(",
"$",
"order",
")",
"?",
"'DESC'",
":",
"'ASC'",
";",
"$",
"this",
"->",
"_group_by",
"[",
"]",
"=",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"column",
")",
",",
"$",
"order",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add group by
@param string $column
@param string $order
@return $this | [
"Add",
"group",
"by"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L367-L371 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.order_by | final protected function order_by($column, $order = 'ASC'){
$order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC';
$this->_order_by[] = sprintf('%s %s', $this->escape_column_name($column), $order);
return $this;
} | php | final protected function order_by($column, $order = 'ASC'){
$order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC';
$this->_order_by[] = sprintf('%s %s', $this->escape_column_name($column), $order);
return $this;
} | [
"final",
"protected",
"function",
"order_by",
"(",
"$",
"column",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"$",
"order",
"=",
"'DESC'",
"===",
"strtoupper",
"(",
"$",
"order",
")",
"?",
"'DESC'",
":",
"'ASC'",
";",
"$",
"this",
"->",
"_order_by",
"[",
"]",
"=",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"column",
")",
",",
"$",
"order",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add order by
@param string $column
@param string $order
@return $this | [
"Add",
"order",
"by"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L380-L384 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.where_in | final protected function where_in($column, array $values, $format = '%s', $or = false){
$replace_values = [];
foreach( $values as $val ){
$replace_values[] = $this->db->prepare($format, $val);
}
$this->_wheres[] = [$this->and_or($or), sprintf('%s IN (%s)', $this->escape_column_name($column), implode(', ', $replace_values))];
return $this;
} | php | final protected function where_in($column, array $values, $format = '%s', $or = false){
$replace_values = [];
foreach( $values as $val ){
$replace_values[] = $this->db->prepare($format, $val);
}
$this->_wheres[] = [$this->and_or($or), sprintf('%s IN (%s)', $this->escape_column_name($column), implode(', ', $replace_values))];
return $this;
} | [
"final",
"protected",
"function",
"where_in",
"(",
"$",
"column",
",",
"array",
"$",
"values",
",",
"$",
"format",
"=",
"'%s'",
",",
"$",
"or",
"=",
"false",
")",
"{",
"$",
"replace_values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"val",
")",
"{",
"$",
"replace_values",
"[",
"]",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"$",
"format",
",",
"$",
"val",
")",
";",
"}",
"$",
"this",
"->",
"_wheres",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"and_or",
"(",
"$",
"or",
")",
",",
"sprintf",
"(",
"'%s IN (%s)'",
",",
"$",
"this",
"->",
"escape_column_name",
"(",
"$",
"column",
")",
",",
"implode",
"(",
"', '",
",",
"$",
"replace_values",
")",
")",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Where in
@param $column
@param array $values
@param string $format %s as string, %d as integer, %f as float
@param bool $or
@return $this | [
"Where",
"in"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L403-L410 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.escape_column_name | private function escape_column_name($column_names){
$columns = [];
foreach( explode(',', $column_names) as $column_name ){
// trim
$column_name = trim($column_name);
// Remove special chars
$columns[] = preg_replace('/[`\'";\n\r\\\\\\0]/u', '', $column_name);
}
return implode(', ', $columns);
} | php | private function escape_column_name($column_names){
$columns = [];
foreach( explode(',', $column_names) as $column_name ){
// trim
$column_name = trim($column_name);
// Remove special chars
$columns[] = preg_replace('/[`\'";\n\r\\\\\\0]/u', '', $column_name);
}
return implode(', ', $columns);
} | [
"private",
"function",
"escape_column_name",
"(",
"$",
"column_names",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"column_names",
")",
"as",
"$",
"column_name",
")",
"{",
"// trim",
"$",
"column_name",
"=",
"trim",
"(",
"$",
"column_name",
")",
";",
"// Remove special chars",
"$",
"columns",
"[",
"]",
"=",
"preg_replace",
"(",
"'/[`\\'\";\\n\\r\\\\\\\\\\\\0]/u'",
",",
"''",
",",
"$",
"column_name",
")",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"columns",
")",
";",
"}"
] | Wrap table name with backtick
@param string $column_names
@return string | [
"Wrap",
"table",
"name",
"with",
"backtick"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L440-L449 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.execute | final protected function execute($query, $ignore_cache = false){
if( $this->cache_exist($query) && !$ignore_cache ){
return $this->get_cache($query);
}else{
$result = $this->db->query($query);
$this->clear();
$this->cache_query($query, $result);
return $result;
}
} | php | final protected function execute($query, $ignore_cache = false){
if( $this->cache_exist($query) && !$ignore_cache ){
return $this->get_cache($query);
}else{
$result = $this->db->query($query);
$this->clear();
$this->cache_query($query, $result);
return $result;
}
} | [
"final",
"protected",
"function",
"execute",
"(",
"$",
"query",
",",
"$",
"ignore_cache",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache_exist",
"(",
"$",
"query",
")",
"&&",
"!",
"$",
"ignore_cache",
")",
"{",
"return",
"$",
"this",
"->",
"get_cache",
"(",
"$",
"query",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"cache_query",
"(",
"$",
"query",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}",
"}"
] | Execute query
@param string $query
@param bool $ignore_cache Default false. If true, always return fresh result.
@return false|int False on failure, Affected row count on success. | [
"Execute",
"query"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L458-L467 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.get_cache | protected function get_cache($query){
return isset($this->query_cache[$query]) ? $this->query_cache[$query] : null;
} | php | protected function get_cache($query){
return isset($this->query_cache[$query]) ? $this->query_cache[$query] : null;
} | [
"protected",
"function",
"get_cache",
"(",
"$",
"query",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"query_cache",
"[",
"$",
"query",
"]",
")",
"?",
"$",
"this",
"->",
"query_cache",
"[",
"$",
"query",
"]",
":",
"null",
";",
"}"
] | Return cache
@param string $query
@return null|mixed | [
"Return",
"cache"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L475-L477 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.clear | final protected function clear(){
$this->_distinct = false;
$this->_select = [];
$this->_from = '';
$this->_join = [];
$this->_wheres = [];
$this->_group_by = [];
$this->_order_by = [];
$this->_limit = [];
} | php | final protected function clear(){
$this->_distinct = false;
$this->_select = [];
$this->_from = '';
$this->_join = [];
$this->_wheres = [];
$this->_group_by = [];
$this->_order_by = [];
$this->_limit = [];
} | [
"final",
"protected",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"_distinct",
"=",
"false",
";",
"$",
"this",
"->",
"_select",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_from",
"=",
"''",
";",
"$",
"this",
"->",
"_join",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_wheres",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_group_by",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_order_by",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_limit",
"=",
"[",
"]",
";",
"}"
] | Clear all result | [
"Clear",
"all",
"result"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L491-L500 |
hametuha/wpametu | src/WPametu/DB/QueryBuilder.php | QueryBuilder.cache_query | final protected function cache_query($sql, $result){
if( isset($this->query_cache[$sql]) ){
$this->query_cache[$sql] = $result;
}elseif( count($this->query_cache) >= $this->cache_limit ){
// Remove oldest cache
array_shift($this->query_cache);
// save query
$this->query_cache[$sql] = $result;
}
} | php | final protected function cache_query($sql, $result){
if( isset($this->query_cache[$sql]) ){
$this->query_cache[$sql] = $result;
}elseif( count($this->query_cache) >= $this->cache_limit ){
// Remove oldest cache
array_shift($this->query_cache);
// save query
$this->query_cache[$sql] = $result;
}
} | [
"final",
"protected",
"function",
"cache_query",
"(",
"$",
"sql",
",",
"$",
"result",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"query_cache",
"[",
"$",
"sql",
"]",
")",
")",
"{",
"$",
"this",
"->",
"query_cache",
"[",
"$",
"sql",
"]",
"=",
"$",
"result",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"this",
"->",
"query_cache",
")",
">=",
"$",
"this",
"->",
"cache_limit",
")",
"{",
"// Remove oldest cache",
"array_shift",
"(",
"$",
"this",
"->",
"query_cache",
")",
";",
"// save query",
"$",
"this",
"->",
"query_cache",
"[",
"$",
"sql",
"]",
"=",
"$",
"result",
";",
"}",
"}"
] | Save query cache
@param string $sql
@param mixed $result | [
"Save",
"query",
"cache"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L508-L517 |
php-lug/lug | src/Component/Grid/Filter/Type/TextType.php | TextType.process | protected function process($field, $data, array $options)
{
$builder = $options['builder'];
switch ($data['type']) {
case self::TYPE_CONTAINS:
return $builder->getExpressionBuilder()->like(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'].'%')
);
case self::TYPE_NOT_CONTAINS:
return $builder->getExpressionBuilder()->notLike(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'].'%')
);
case self::TYPE_EMPTY:
return $builder->getExpressionBuilder()->isNull($builder->getProperty($field));
case self::TYPE_NOT_EMPTY:
return $builder->getExpressionBuilder()->isNotNull($builder->getProperty($field));
case self::TYPE_NOT_EQUALS:
return $builder->getExpressionBuilder()->neq(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'])
);
case self::TYPE_STARTS_WITH:
return $builder->getExpressionBuilder()->like(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'].'%')
);
case self::TYPE_NOT_STARTS_WITH:
return $builder->getExpressionBuilder()->notLike(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'].'%')
);
case self::TYPE_ENDS_WITH:
return $builder->getExpressionBuilder()->like(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'])
);
case self::TYPE_NOT_ENDS_WITH:
return $builder->getExpressionBuilder()->notLike(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'])
);
}
return $builder->getExpressionBuilder()->eq(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'])
);
} | php | protected function process($field, $data, array $options)
{
$builder = $options['builder'];
switch ($data['type']) {
case self::TYPE_CONTAINS:
return $builder->getExpressionBuilder()->like(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'].'%')
);
case self::TYPE_NOT_CONTAINS:
return $builder->getExpressionBuilder()->notLike(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'].'%')
);
case self::TYPE_EMPTY:
return $builder->getExpressionBuilder()->isNull($builder->getProperty($field));
case self::TYPE_NOT_EMPTY:
return $builder->getExpressionBuilder()->isNotNull($builder->getProperty($field));
case self::TYPE_NOT_EQUALS:
return $builder->getExpressionBuilder()->neq(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'])
);
case self::TYPE_STARTS_WITH:
return $builder->getExpressionBuilder()->like(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'].'%')
);
case self::TYPE_NOT_STARTS_WITH:
return $builder->getExpressionBuilder()->notLike(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'].'%')
);
case self::TYPE_ENDS_WITH:
return $builder->getExpressionBuilder()->like(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'])
);
case self::TYPE_NOT_ENDS_WITH:
return $builder->getExpressionBuilder()->notLike(
$builder->getProperty($field),
$builder->createPlaceholder($field, '%'.$data['value'])
);
}
return $builder->getExpressionBuilder()->eq(
$builder->getProperty($field),
$builder->createPlaceholder($field, $data['value'])
);
} | [
"protected",
"function",
"process",
"(",
"$",
"field",
",",
"$",
"data",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"=",
"$",
"options",
"[",
"'builder'",
"]",
";",
"switch",
"(",
"$",
"data",
"[",
"'type'",
"]",
")",
"{",
"case",
"self",
"::",
"TYPE_CONTAINS",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"like",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"'%'",
".",
"$",
"data",
"[",
"'value'",
"]",
".",
"'%'",
")",
")",
";",
"case",
"self",
"::",
"TYPE_NOT_CONTAINS",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"notLike",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"'%'",
".",
"$",
"data",
"[",
"'value'",
"]",
".",
"'%'",
")",
")",
";",
"case",
"self",
"::",
"TYPE_EMPTY",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"isNull",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
")",
";",
"case",
"self",
"::",
"TYPE_NOT_EMPTY",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"isNotNull",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
")",
";",
"case",
"self",
"::",
"TYPE_NOT_EQUALS",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"neq",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
";",
"case",
"self",
"::",
"TYPE_STARTS_WITH",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"like",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"$",
"data",
"[",
"'value'",
"]",
".",
"'%'",
")",
")",
";",
"case",
"self",
"::",
"TYPE_NOT_STARTS_WITH",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"notLike",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"$",
"data",
"[",
"'value'",
"]",
".",
"'%'",
")",
")",
";",
"case",
"self",
"::",
"TYPE_ENDS_WITH",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"like",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"'%'",
".",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
";",
"case",
"self",
"::",
"TYPE_NOT_ENDS_WITH",
":",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"notLike",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"'%'",
".",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
";",
"}",
"return",
"$",
"builder",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"eq",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"field",
")",
",",
"$",
"builder",
"->",
"createPlaceholder",
"(",
"$",
"field",
",",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Filter/Type/TextType.php#L77-L135 |
php-lug/lug | src/Component/Grid/Filter/Type/TextType.php | TextType.validate | protected function validate($data, array $options)
{
return parent::validate($data, $options)
&& is_array($data)
&& isset($data['type'])
&& ((
in_array($data['type'], self::getSimpleTypes(), true)
&& isset($data['value'])
&& is_string($data['value'])
) || in_array($data['type'], self::getEmptyTypes(), true));
} | php | protected function validate($data, array $options)
{
return parent::validate($data, $options)
&& is_array($data)
&& isset($data['type'])
&& ((
in_array($data['type'], self::getSimpleTypes(), true)
&& isset($data['value'])
&& is_string($data['value'])
) || in_array($data['type'], self::getEmptyTypes(), true));
} | [
"protected",
"function",
"validate",
"(",
"$",
"data",
",",
"array",
"$",
"options",
")",
"{",
"return",
"parent",
"::",
"validate",
"(",
"$",
"data",
",",
"$",
"options",
")",
"&&",
"is_array",
"(",
"$",
"data",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'type'",
"]",
")",
"&&",
"(",
"(",
"in_array",
"(",
"$",
"data",
"[",
"'type'",
"]",
",",
"self",
"::",
"getSimpleTypes",
"(",
")",
",",
"true",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'value'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"data",
"[",
"'value'",
"]",
")",
")",
"||",
"in_array",
"(",
"$",
"data",
"[",
"'type'",
"]",
",",
"self",
"::",
"getEmptyTypes",
"(",
")",
",",
"true",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Filter/Type/TextType.php#L140-L150 |
weew/http | src/Weew/Http/CookieBuilder.php | CookieBuilder.build | public function build(ICookie $cookie) {
$string = '';
$this->writeValue($string, $cookie);
$this->writeExpires($string, $cookie);
$this->writePath($string, $cookie);
$this->writeDomain($string, $cookie);
$this->writeSecure($string, $cookie);
$this->writeHttpOnly($string, $cookie);
return $string;
} | php | public function build(ICookie $cookie) {
$string = '';
$this->writeValue($string, $cookie);
$this->writeExpires($string, $cookie);
$this->writePath($string, $cookie);
$this->writeDomain($string, $cookie);
$this->writeSecure($string, $cookie);
$this->writeHttpOnly($string, $cookie);
return $string;
} | [
"public",
"function",
"build",
"(",
"ICookie",
"$",
"cookie",
")",
"{",
"$",
"string",
"=",
"''",
";",
"$",
"this",
"->",
"writeValue",
"(",
"$",
"string",
",",
"$",
"cookie",
")",
";",
"$",
"this",
"->",
"writeExpires",
"(",
"$",
"string",
",",
"$",
"cookie",
")",
";",
"$",
"this",
"->",
"writePath",
"(",
"$",
"string",
",",
"$",
"cookie",
")",
";",
"$",
"this",
"->",
"writeDomain",
"(",
"$",
"string",
",",
"$",
"cookie",
")",
";",
"$",
"this",
"->",
"writeSecure",
"(",
"$",
"string",
",",
"$",
"cookie",
")",
";",
"$",
"this",
"->",
"writeHttpOnly",
"(",
"$",
"string",
",",
"$",
"cookie",
")",
";",
"return",
"$",
"string",
";",
"}"
] | @param ICookie $cookie
@return string | [
"@param",
"ICookie",
"$cookie"
] | train | https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/CookieBuilder.php#L11-L21 |
video-games-records/TeamBundle | Repository/TeamRepository.php | TeamRepository.majRankPointChart | public function majRankPointChart()
{
$teams = $this->findBy(array(), array('pointChart' => 'DESC'));
$list = array();
foreach ($teams as $team) {
$list[] = $team;
}
Ranking::addObjectRank($list, 'rankPointChart', array('pointChart'));
$this->getEntityManager()->flush();
} | php | public function majRankPointChart()
{
$teams = $this->findBy(array(), array('pointChart' => 'DESC'));
$list = array();
foreach ($teams as $team) {
$list[] = $team;
}
Ranking::addObjectRank($list, 'rankPointChart', array('pointChart'));
$this->getEntityManager()->flush();
} | [
"public",
"function",
"majRankPointChart",
"(",
")",
"{",
"$",
"teams",
"=",
"$",
"this",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
"'pointChart'",
"=>",
"'DESC'",
")",
")",
";",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"teams",
"as",
"$",
"team",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"team",
";",
"}",
"Ranking",
"::",
"addObjectRank",
"(",
"$",
"list",
",",
"'rankPointChart'",
",",
"array",
"(",
"'pointChart'",
")",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}"
] | Update column rankPointChart | [
"Update",
"column",
"rankPointChart"
] | train | https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Repository/TeamRepository.php#L145-L156 |
video-games-records/TeamBundle | Repository/TeamRepository.php | TeamRepository.majRankCup | public function majRankCup()
{
$this->majGameRank();
$teams = $this->findBy(array(), array('gameRank0' => 'DESC', 'gameRank1' => 'DESC', 'gameRank2' => 'DESC', 'gameRank3' => 'DESC'));
$list = array();
foreach ($teams as $team) {
$list[] = $team;
}
Ranking::addObjectRank($list, 'rankCup', array('gameRank0', 'gameRank1', 'gameRank2', 'gameRank3'));
$this->getEntityManager()->flush();
} | php | public function majRankCup()
{
$this->majGameRank();
$teams = $this->findBy(array(), array('gameRank0' => 'DESC', 'gameRank1' => 'DESC', 'gameRank2' => 'DESC', 'gameRank3' => 'DESC'));
$list = array();
foreach ($teams as $team) {
$list[] = $team;
}
Ranking::addObjectRank($list, 'rankCup', array('gameRank0', 'gameRank1', 'gameRank2', 'gameRank3'));
$this->getEntityManager()->flush();
} | [
"public",
"function",
"majRankCup",
"(",
")",
"{",
"$",
"this",
"->",
"majGameRank",
"(",
")",
";",
"$",
"teams",
"=",
"$",
"this",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
"'gameRank0'",
"=>",
"'DESC'",
",",
"'gameRank1'",
"=>",
"'DESC'",
",",
"'gameRank2'",
"=>",
"'DESC'",
",",
"'gameRank3'",
"=>",
"'DESC'",
")",
")",
";",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"teams",
"as",
"$",
"team",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"team",
";",
"}",
"Ranking",
"::",
"addObjectRank",
"(",
"$",
"list",
",",
"'rankCup'",
",",
"array",
"(",
"'gameRank0'",
",",
"'gameRank1'",
",",
"'gameRank2'",
",",
"'gameRank3'",
")",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}"
] | Update column rankCup | [
"Update",
"column",
"rankCup"
] | train | https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Repository/TeamRepository.php#L193-L205 |
nabab/bbn | src/bbn/appui/chat.php | chat.create | public function create(array $users, int $public = 0): ?string
{
if ( $this->check() ){
$join = '';
$where = '';
$values = [$this->user->get_id(), $public];
foreach ( $users as $i => $u ){
$join .= "JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id".PHP_EOL;
$where .= "AND u$i.id_user = ?".PHP_EOL;
$values[] = $u;
}
$sql = <<<SQL
SELECT id
FROM bbn_chats
$join
WHERE creator = ?
AND public = ?
$where
SQL;
if ( ($id_chat = $this->db->get_one($sql, $values)) && (count($users) === $this->db->count('bbn_chat_users', ['id_chat' => $id_chat])) ){
return $id_chat;
}
if ( $this->db->insert('bbn_chats', [
'creator' => $this->user->get_id(),
'creation' => date('Y-m-d H:i:s'),
'public' => $public ? 1 : 0
]) ){
$id_chat = $this->db->last_id();
$this->db->insert('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $this->user->get_id(),
'entrance' => microtime(true),
'admin' => 1
]);
foreach ( $users as $user ){
$this->db->insert_ignore('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $user,
'entrance' => microtime(true),
'admin' => 0
]);
}
return $id_chat;
}
}
return null;
} | php | public function create(array $users, int $public = 0): ?string
{
if ( $this->check() ){
$join = '';
$where = '';
$values = [$this->user->get_id(), $public];
foreach ( $users as $i => $u ){
$join .= "JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id".PHP_EOL;
$where .= "AND u$i.id_user = ?".PHP_EOL;
$values[] = $u;
}
$sql = <<<SQL
SELECT id
FROM bbn_chats
$join
WHERE creator = ?
AND public = ?
$where
SQL;
if ( ($id_chat = $this->db->get_one($sql, $values)) && (count($users) === $this->db->count('bbn_chat_users', ['id_chat' => $id_chat])) ){
return $id_chat;
}
if ( $this->db->insert('bbn_chats', [
'creator' => $this->user->get_id(),
'creation' => date('Y-m-d H:i:s'),
'public' => $public ? 1 : 0
]) ){
$id_chat = $this->db->last_id();
$this->db->insert('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $this->user->get_id(),
'entrance' => microtime(true),
'admin' => 1
]);
foreach ( $users as $user ){
$this->db->insert_ignore('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $user,
'entrance' => microtime(true),
'admin' => 0
]);
}
return $id_chat;
}
}
return null;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"users",
",",
"int",
"$",
"public",
"=",
"0",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
")",
"{",
"$",
"join",
"=",
"''",
";",
"$",
"where",
"=",
"''",
";",
"$",
"values",
"=",
"[",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
",",
"$",
"public",
"]",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"i",
"=>",
"$",
"u",
")",
"{",
"$",
"join",
".=",
"\"JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id\"",
".",
"PHP_EOL",
";",
"$",
"where",
".=",
"\"AND u$i.id_user = ?\"",
".",
"PHP_EOL",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"u",
";",
"}",
"$",
"sql",
"=",
" <<<SQL\nSELECT id\nFROM bbn_chats\n $join\nWHERE creator = ?\nAND public = ? \n$where\nSQL",
";",
"if",
"(",
"(",
"$",
"id_chat",
"=",
"$",
"this",
"->",
"db",
"->",
"get_one",
"(",
"$",
"sql",
",",
"$",
"values",
")",
")",
"&&",
"(",
"count",
"(",
"$",
"users",
")",
"===",
"$",
"this",
"->",
"db",
"->",
"count",
"(",
"'bbn_chat_users'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
"]",
")",
")",
")",
"{",
"return",
"$",
"id_chat",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"'bbn_chats'",
",",
"[",
"'creator'",
"=>",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
",",
"'creation'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"'public'",
"=>",
"$",
"public",
"?",
"1",
":",
"0",
"]",
")",
")",
"{",
"$",
"id_chat",
"=",
"$",
"this",
"->",
"db",
"->",
"last_id",
"(",
")",
";",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"'bbn_chats_users'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
",",
"'id_user'",
"=>",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
",",
"'entrance'",
"=>",
"microtime",
"(",
"true",
")",
",",
"'admin'",
"=>",
"1",
"]",
")",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"insert_ignore",
"(",
"'bbn_chats_users'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
",",
"'id_user'",
"=>",
"$",
"user",
",",
"'entrance'",
"=>",
"microtime",
"(",
"true",
")",
",",
"'admin'",
"=>",
"0",
"]",
")",
";",
"}",
"return",
"$",
"id_chat",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Creates a new chat with the current userr and another participant.
@param array $users
@param int $public
@return null|string | [
"Creates",
"a",
"new",
"chat",
"with",
"the",
"current",
"userr",
"and",
"another",
"participant",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L58-L104 |
nabab/bbn | src/bbn/appui/chat.php | chat.add_user | public function add_user(string $id_chat, string $id_user): bool
{
if ( $this->is_admin($id_chat) ){
return (bool)$this->db->insert_ignore('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $id_user,
'entrance' => microtime(true),
'admin' => 0
]);
}
return false;
} | php | public function add_user(string $id_chat, string $id_user): bool
{
if ( $this->is_admin($id_chat) ){
return (bool)$this->db->insert_ignore('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $id_user,
'entrance' => microtime(true),
'admin' => 0
]);
}
return false;
} | [
"public",
"function",
"add_user",
"(",
"string",
"$",
"id_chat",
",",
"string",
"$",
"id_user",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"is_admin",
"(",
"$",
"id_chat",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"insert_ignore",
"(",
"'bbn_chats_users'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
",",
"'id_user'",
"=>",
"$",
"id_user",
",",
"'entrance'",
"=>",
"microtime",
"(",
"true",
")",
",",
"'admin'",
"=>",
"0",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Adds the given user to the given chat (if the current user is admin of this chat).
@param string $id_chat
@param string $id_user
@return bool | [
"Adds",
"the",
"given",
"user",
"to",
"the",
"given",
"chat",
"(",
"if",
"the",
"current",
"user",
"is",
"admin",
"of",
"this",
"chat",
")",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L113-L124 |
nabab/bbn | src/bbn/appui/chat.php | chat.make_admin | public function make_admin(string $id_chat, string $id_user): bool
{
if ( $this->is_admin($id_chat) ){
return (bool)$this->db->update_ignore('bbn_chats_users', [
'admin' => 1
], [
'id_chat' => $id_chat,
'id_user' => $id_user,
]);
}
return false;
} | php | public function make_admin(string $id_chat, string $id_user): bool
{
if ( $this->is_admin($id_chat) ){
return (bool)$this->db->update_ignore('bbn_chats_users', [
'admin' => 1
], [
'id_chat' => $id_chat,
'id_user' => $id_user,
]);
}
return false;
} | [
"public",
"function",
"make_admin",
"(",
"string",
"$",
"id_chat",
",",
"string",
"$",
"id_user",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"is_admin",
"(",
"$",
"id_chat",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"update_ignore",
"(",
"'bbn_chats_users'",
",",
"[",
"'admin'",
"=>",
"1",
"]",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
",",
"'id_user'",
"=>",
"$",
"id_user",
",",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Makes the given participant an admin of the given chat provided the current user is admin of this chat.
@param string $id_chat
@param string $id_user
@return bool | [
"Makes",
"the",
"given",
"participant",
"an",
"admin",
"of",
"the",
"given",
"chat",
"provided",
"the",
"current",
"user",
"is",
"admin",
"of",
"this",
"chat",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L133-L144 |
nabab/bbn | src/bbn/appui/chat.php | chat.is_participant | public function is_participant(string $id_chat, string $id_user = null): ?bool
{
if ( $this->check() ){
return (bool)$this->db->count('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $id_user ?: $this->user->get_id()
]);
}
return null;
} | php | public function is_participant(string $id_chat, string $id_user = null): ?bool
{
if ( $this->check() ){
return (bool)$this->db->count('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $id_user ?: $this->user->get_id()
]);
}
return null;
} | [
"public",
"function",
"is_participant",
"(",
"string",
"$",
"id_chat",
",",
"string",
"$",
"id_user",
"=",
"null",
")",
":",
"?",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"count",
"(",
"'bbn_chats_users'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
",",
"'id_user'",
"=>",
"$",
"id_user",
"?",
":",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks whether the given user is participant of the given chat.
@param string $id_chat
@param string $id_user
@return bool|null | [
"Checks",
"whether",
"the",
"given",
"user",
"is",
"participant",
"of",
"the",
"given",
"chat",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L153-L162 |
nabab/bbn | src/bbn/appui/chat.php | chat.info | public function info($id_chat): ?array
{
if ( $this->check() ){
return $this->db->rselect('bbn_chats', [], ['id' => $id_chat]) ?: null;
}
return null;
} | php | public function info($id_chat): ?array
{
if ( $this->check() ){
return $this->db->rselect('bbn_chats', [], ['id' => $id_chat]) ?: null;
}
return null;
} | [
"public",
"function",
"info",
"(",
"$",
"id_chat",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"rselect",
"(",
"'bbn_chats'",
",",
"[",
"]",
",",
"[",
"'id'",
"=>",
"$",
"id_chat",
"]",
")",
"?",
":",
"null",
";",
"}",
"return",
"null",
";",
"}"
] | Gets information about the given chat.
@param $id_chat
@return array|null | [
"Gets",
"information",
"about",
"the",
"given",
"chat",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L170-L176 |
nabab/bbn | src/bbn/appui/chat.php | chat.get_participants | public function get_participants(string $id_chat): ?array
{
if ( $this->check() ){
return $this->db->get_field_values('bbn_chats_users', 'id_user', ['id_chat' => $id_chat]);
}
return null;
} | php | public function get_participants(string $id_chat): ?array
{
if ( $this->check() ){
return $this->db->get_field_values('bbn_chats_users', 'id_user', ['id_chat' => $id_chat]);
}
return null;
} | [
"public",
"function",
"get_participants",
"(",
"string",
"$",
"id_chat",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"get_field_values",
"(",
"'bbn_chats_users'",
",",
"'id_user'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the participants of the given chat as an array of id_user.
@param string $id_chat
@return array|null | [
"Returns",
"the",
"participants",
"of",
"the",
"given",
"chat",
"as",
"an",
"array",
"of",
"id_user",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L184-L190 |
nabab/bbn | src/bbn/appui/chat.php | chat.talk | public function talk(string $id_chat, string $message): ?int
{
if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){
$users = $this->get_participants($id_chat);
if ( \in_array($this->user->get_id(), $users, true) ){
$time = microtime(true);
$st = bbn\util\enc::crypt(json_encode(['time' => $time, 'user' => $this->user->get_id(), 'message' => $message]));
$day = date('Y-m-d');
foreach ( $users as $user ){
$dir = BBN_DATA_PATH.'users/'.$user.'/chat/'.$id_chat.'/'.$day;
if ( bbn\file\dir::create_path($dir) ){
file_put_contents($dir.'/'.$time.'.msg', $st);
}
}
return $this->db->update('bbn_chats', ['last_message' => $time], ['id' => $id_chat]);
}
}
return null;
} | php | public function talk(string $id_chat, string $message): ?int
{
if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){
$users = $this->get_participants($id_chat);
if ( \in_array($this->user->get_id(), $users, true) ){
$time = microtime(true);
$st = bbn\util\enc::crypt(json_encode(['time' => $time, 'user' => $this->user->get_id(), 'message' => $message]));
$day = date('Y-m-d');
foreach ( $users as $user ){
$dir = BBN_DATA_PATH.'users/'.$user.'/chat/'.$id_chat.'/'.$day;
if ( bbn\file\dir::create_path($dir) ){
file_put_contents($dir.'/'.$time.'.msg', $st);
}
}
return $this->db->update('bbn_chats', ['last_message' => $time], ['id' => $id_chat]);
}
}
return null;
} | [
"public",
"function",
"talk",
"(",
"string",
"$",
"id_chat",
",",
"string",
"$",
"message",
")",
":",
"?",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
"&&",
"(",
"$",
"chat",
"=",
"$",
"this",
"->",
"info",
"(",
"$",
"id_chat",
")",
")",
"&&",
"!",
"$",
"chat",
"[",
"'blocked'",
"]",
")",
"{",
"$",
"users",
"=",
"$",
"this",
"->",
"get_participants",
"(",
"$",
"id_chat",
")",
";",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
",",
"$",
"users",
",",
"true",
")",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"st",
"=",
"bbn",
"\\",
"util",
"\\",
"enc",
"::",
"crypt",
"(",
"json_encode",
"(",
"[",
"'time'",
"=>",
"$",
"time",
",",
"'user'",
"=>",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
",",
"'message'",
"=>",
"$",
"message",
"]",
")",
")",
";",
"$",
"day",
"=",
"date",
"(",
"'Y-m-d'",
")",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"dir",
"=",
"BBN_DATA_PATH",
".",
"'users/'",
".",
"$",
"user",
".",
"'/chat/'",
".",
"$",
"id_chat",
".",
"'/'",
".",
"$",
"day",
";",
"if",
"(",
"bbn",
"\\",
"file",
"\\",
"dir",
"::",
"create_path",
"(",
"$",
"dir",
")",
")",
"{",
"file_put_contents",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"time",
".",
"'.msg'",
",",
"$",
"st",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"db",
"->",
"update",
"(",
"'bbn_chats'",
",",
"[",
"'last_message'",
"=>",
"$",
"time",
"]",
",",
"[",
"'id'",
"=>",
"$",
"id_chat",
"]",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Sends a new message from the current user in the given chat.
@param string $id_chat
@param string $message
@return int|null | [
"Sends",
"a",
"new",
"message",
"from",
"the",
"current",
"user",
"in",
"the",
"given",
"chat",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L199-L217 |
nabab/bbn | src/bbn/appui/chat.php | chat.is_admin | public function is_admin($id_chat): ?bool
{
if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){
return (bool)$this->db->count('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $this->user->get_id(),
'admin' => 1
]);
}
return null;
} | php | public function is_admin($id_chat): ?bool
{
if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){
return (bool)$this->db->count('bbn_chats_users', [
'id_chat' => $id_chat,
'id_user' => $this->user->get_id(),
'admin' => 1
]);
}
return null;
} | [
"public",
"function",
"is_admin",
"(",
"$",
"id_chat",
")",
":",
"?",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
"&&",
"(",
"$",
"chat",
"=",
"$",
"this",
"->",
"info",
"(",
"$",
"id_chat",
")",
")",
"&&",
"!",
"$",
"chat",
"[",
"'blocked'",
"]",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"count",
"(",
"'bbn_chats_users'",
",",
"[",
"'id_chat'",
"=>",
"$",
"id_chat",
",",
"'id_user'",
"=>",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
",",
"'admin'",
"=>",
"1",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks whether the current user is an admin of the given chat or not.
@param $id_chat
@return bool|null | [
"Checks",
"whether",
"the",
"current",
"user",
"is",
"an",
"admin",
"of",
"the",
"given",
"chat",
"or",
"not",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L225-L235 |
nabab/bbn | src/bbn/appui/chat.php | chat.block | public function block($id_chat): bool
{
if ( $this->is_admin($id_chat) ){
return (bool)$this->db->update('bbn_chats', ['blocked' => 1], ['id' => $id_chat]);
}
return false;
} | php | public function block($id_chat): bool
{
if ( $this->is_admin($id_chat) ){
return (bool)$this->db->update('bbn_chats', ['blocked' => 1], ['id' => $id_chat]);
}
return false;
} | [
"public",
"function",
"block",
"(",
"$",
"id_chat",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"is_admin",
"(",
"$",
"id_chat",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"update",
"(",
"'bbn_chats'",
",",
"[",
"'blocked'",
"=>",
"1",
"]",
",",
"[",
"'id'",
"=>",
"$",
"id_chat",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Close a chat by setting blocked to 1.
@param $id_chat
@return bool | [
"Close",
"a",
"chat",
"by",
"setting",
"blocked",
"to",
"1",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L243-L249 |
nabab/bbn | src/bbn/appui/chat.php | chat.get_messages | public function get_messages($id_chat, $last = null, $day = null): array
{
$res = ['success' => false, 'last' => null, 'messages' => []];
if ( $this->check() ){
$dir = BBN_DATA_PATH.'users/'.$this->user->get_id().'/chat/'.$id_chat.'/'.($day ?: date('Y-m-d'));
if ( $this->is_participant($id_chat) && is_dir($dir) ){
$res['success'] = true;
$files = bbn\file\dir::get_files($dir);
foreach ( $files as $file ){
$time = (float)basename($file, '.msg');
if ( (!$last || \bbn\x::compare_floats($time, $last, '>')) && ($st = file_get_contents($file)) ){
$enc = bbn\util\enc::crypt('test');
$res['messages'][] = json_decode(bbn\util\enc::decrypt($st), true);
}
}
if ( isset($time) ){
$res['last'] = $time;
}
}
}
return $res;
} | php | public function get_messages($id_chat, $last = null, $day = null): array
{
$res = ['success' => false, 'last' => null, 'messages' => []];
if ( $this->check() ){
$dir = BBN_DATA_PATH.'users/'.$this->user->get_id().'/chat/'.$id_chat.'/'.($day ?: date('Y-m-d'));
if ( $this->is_participant($id_chat) && is_dir($dir) ){
$res['success'] = true;
$files = bbn\file\dir::get_files($dir);
foreach ( $files as $file ){
$time = (float)basename($file, '.msg');
if ( (!$last || \bbn\x::compare_floats($time, $last, '>')) && ($st = file_get_contents($file)) ){
$enc = bbn\util\enc::crypt('test');
$res['messages'][] = json_decode(bbn\util\enc::decrypt($st), true);
}
}
if ( isset($time) ){
$res['last'] = $time;
}
}
}
return $res;
} | [
"public",
"function",
"get_messages",
"(",
"$",
"id_chat",
",",
"$",
"last",
"=",
"null",
",",
"$",
"day",
"=",
"null",
")",
":",
"array",
"{",
"$",
"res",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'last'",
"=>",
"null",
",",
"'messages'",
"=>",
"[",
"]",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
")",
"{",
"$",
"dir",
"=",
"BBN_DATA_PATH",
".",
"'users/'",
".",
"$",
"this",
"->",
"user",
"->",
"get_id",
"(",
")",
".",
"'/chat/'",
".",
"$",
"id_chat",
".",
"'/'",
".",
"(",
"$",
"day",
"?",
":",
"date",
"(",
"'Y-m-d'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"is_participant",
"(",
"$",
"id_chat",
")",
"&&",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"res",
"[",
"'success'",
"]",
"=",
"true",
";",
"$",
"files",
"=",
"bbn",
"\\",
"file",
"\\",
"dir",
"::",
"get_files",
"(",
"$",
"dir",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"time",
"=",
"(",
"float",
")",
"basename",
"(",
"$",
"file",
",",
"'.msg'",
")",
";",
"if",
"(",
"(",
"!",
"$",
"last",
"||",
"\\",
"bbn",
"\\",
"x",
"::",
"compare_floats",
"(",
"$",
"time",
",",
"$",
"last",
",",
"'>'",
")",
")",
"&&",
"(",
"$",
"st",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
")",
")",
"{",
"$",
"enc",
"=",
"bbn",
"\\",
"util",
"\\",
"enc",
"::",
"crypt",
"(",
"'test'",
")",
";",
"$",
"res",
"[",
"'messages'",
"]",
"[",
"]",
"=",
"json_decode",
"(",
"bbn",
"\\",
"util",
"\\",
"enc",
"::",
"decrypt",
"(",
"$",
"st",
")",
",",
"true",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"time",
")",
")",
"{",
"$",
"res",
"[",
"'last'",
"]",
"=",
"$",
"time",
";",
"}",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] | Returns messages from the given chat sent after $last.
@param $id_chat
@param null $last
@param null $day
@return array | [
"Returns",
"messages",
"from",
"the",
"given",
"chat",
"sent",
"after",
"$last",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L308-L329 |
ArrowSphere/Client | src/xAC.php | xAC.setApiVersion | public static function setApiVersion($version)
{
if (! in_array($version, [1,2])) {
throw new \Exception(sprintf("The %d version is not supported", $version));
}
self::$apiVersion = $version;
// Refresh services if version is changed and base url is defined
if (self::$url) {
self::initServices();
}
} | php | public static function setApiVersion($version)
{
if (! in_array($version, [1,2])) {
throw new \Exception(sprintf("The %d version is not supported", $version));
}
self::$apiVersion = $version;
// Refresh services if version is changed and base url is defined
if (self::$url) {
self::initServices();
}
} | [
"public",
"static",
"function",
"setApiVersion",
"(",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"version",
",",
"[",
"1",
",",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"The %d version is not supported\"",
",",
"$",
"version",
")",
")",
";",
"}",
"self",
"::",
"$",
"apiVersion",
"=",
"$",
"version",
";",
"// Refresh services if version is changed and base url is defined",
"if",
"(",
"self",
"::",
"$",
"url",
")",
"{",
"self",
"::",
"initServices",
"(",
")",
";",
"}",
"}"
] | Define which API version to use
@param integer $version | [
"Define",
"which",
"API",
"version",
"to",
"use"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L137-L148 |
ArrowSphere/Client | src/xAC.php | xAC.initServices | public static function initServices($refresh = false)
{
// Define full definition file path
$path = sprintf('%s%sxac-services-v%d.conf'
, ! empty(self::$logPath) ? self::$logPath : sys_get_temp_dir()
, DIRECTORY_SEPARATOR
, self::$apiVersion
);
if ($refresh === true || ! file_exists($path)) {
self::log(sprintf("Refresh services definition on-demand for v%d API", self::$apiVersion));
$res = self::getInstance()->call('endpoints');
$res['_timestamp'] = time();
file_put_contents($path, serialize($res));
chmod($path, 0777);
self::$services = $res;
} else {
self::$services = unserialize(file_get_contents($path));
// Check that content is not expired
if (time() - self::$services['_timestamp'] > self::$ttl) {
self::log(sprintf("Refresh outdated services definition for v%d API", self::$apiVersion));
self::initServices(true);
}
}
} | php | public static function initServices($refresh = false)
{
// Define full definition file path
$path = sprintf('%s%sxac-services-v%d.conf'
, ! empty(self::$logPath) ? self::$logPath : sys_get_temp_dir()
, DIRECTORY_SEPARATOR
, self::$apiVersion
);
if ($refresh === true || ! file_exists($path)) {
self::log(sprintf("Refresh services definition on-demand for v%d API", self::$apiVersion));
$res = self::getInstance()->call('endpoints');
$res['_timestamp'] = time();
file_put_contents($path, serialize($res));
chmod($path, 0777);
self::$services = $res;
} else {
self::$services = unserialize(file_get_contents($path));
// Check that content is not expired
if (time() - self::$services['_timestamp'] > self::$ttl) {
self::log(sprintf("Refresh outdated services definition for v%d API", self::$apiVersion));
self::initServices(true);
}
}
} | [
"public",
"static",
"function",
"initServices",
"(",
"$",
"refresh",
"=",
"false",
")",
"{",
"// Define full definition file path",
"$",
"path",
"=",
"sprintf",
"(",
"'%s%sxac-services-v%d.conf'",
",",
"!",
"empty",
"(",
"self",
"::",
"$",
"logPath",
")",
"?",
"self",
"::",
"$",
"logPath",
":",
"sys_get_temp_dir",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"self",
"::",
"$",
"apiVersion",
")",
";",
"if",
"(",
"$",
"refresh",
"===",
"true",
"||",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"self",
"::",
"log",
"(",
"sprintf",
"(",
"\"Refresh services definition on-demand for v%d API\"",
",",
"self",
"::",
"$",
"apiVersion",
")",
")",
";",
"$",
"res",
"=",
"self",
"::",
"getInstance",
"(",
")",
"->",
"call",
"(",
"'endpoints'",
")",
";",
"$",
"res",
"[",
"'_timestamp'",
"]",
"=",
"time",
"(",
")",
";",
"file_put_contents",
"(",
"$",
"path",
",",
"serialize",
"(",
"$",
"res",
")",
")",
";",
"chmod",
"(",
"$",
"path",
",",
"0777",
")",
";",
"self",
"::",
"$",
"services",
"=",
"$",
"res",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"services",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
")",
";",
"// Check that content is not expired",
"if",
"(",
"time",
"(",
")",
"-",
"self",
"::",
"$",
"services",
"[",
"'_timestamp'",
"]",
">",
"self",
"::",
"$",
"ttl",
")",
"{",
"self",
"::",
"log",
"(",
"sprintf",
"(",
"\"Refresh outdated services definition for v%d API\"",
",",
"self",
"::",
"$",
"apiVersion",
")",
")",
";",
"self",
"::",
"initServices",
"(",
"true",
")",
";",
"}",
"}",
"}"
] | Retrieve definition of available API services
@param boolean $refresh | [
"Retrieve",
"definition",
"of",
"available",
"API",
"services"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L172-L196 |
ArrowSphere/Client | src/xAC.php | xAC.getServices | public static function getServices(xAC\Entity $entity = null)
{
if ($entity) {
return $entity->getServices();
}
if (count(self::$services) == 0) {
self::initServices();
}
unset(self::$services['_timestamp']);
return self::$services;
} | php | public static function getServices(xAC\Entity $entity = null)
{
if ($entity) {
return $entity->getServices();
}
if (count(self::$services) == 0) {
self::initServices();
}
unset(self::$services['_timestamp']);
return self::$services;
} | [
"public",
"static",
"function",
"getServices",
"(",
"xAC",
"\\",
"Entity",
"$",
"entity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"entity",
")",
"{",
"return",
"$",
"entity",
"->",
"getServices",
"(",
")",
";",
"}",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"services",
")",
"==",
"0",
")",
"{",
"self",
"::",
"initServices",
"(",
")",
";",
"}",
"unset",
"(",
"self",
"::",
"$",
"services",
"[",
"'_timestamp'",
"]",
")",
";",
"return",
"self",
"::",
"$",
"services",
";",
"}"
] | Return the available services as array (or actions if the $entity param is filled)
@param xAC\Entity $entity
@return array | [
"Return",
"the",
"available",
"services",
"as",
"array",
"(",
"or",
"actions",
"if",
"the",
"$entity",
"param",
"is",
"filled",
")"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L203-L216 |
ArrowSphere/Client | src/xAC.php | xAC.call | public function call($endpoint, $method = 'GET', array $data = [])
{
if (substr($endpoint, -1) == '/') {
$endpoint = substr($endpoint, 0, strlen($endpoint)-1);
}
self::log("Calling $method /api/$endpoint");
$params = [
'headers'=> [
'Accept' => sprintf('application/vnd.xac.v%d+json', self::$apiVersion),
'AC-API-KEY' => self::$apiKey,
],
];
if (count($data) > 0) {
$params['json'] = $data;
}
try {
$this->initTransport();
$res = $this->transport->request($method, $endpoint, $params);
} catch (ConnectException $e) {
self::log($e->getMessage(), Logger::ERROR);
throw new \Exception($e->getMessage());
} catch (ServerException $e) {
$response = json_decode((string) $e->getResponse()->getBody(), true);
self::$lastResponse = $response['ACResponse'];
self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode();
self::log($e->getMessage(), Logger::ERROR);
throw new \Exception(self::$lastResponse['message']);
} catch (ClientException $e) {
$response = json_decode((string) $e->getResponse()->getBody(), true);
self::$lastResponse = $response['ACResponse'];
self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode();
self::log($e->getMessage(), Logger::ERROR);
throw new \Exception(self::$lastResponse['message']);
} finally {
if (isset($res)) {
$response = json_decode((string) $res->getBody(), !self::$returnObject);
$response = $response['ACResponse'];
}
}
self::$lastResponse = $response;
return $response['body']['data'];
} | php | public function call($endpoint, $method = 'GET', array $data = [])
{
if (substr($endpoint, -1) == '/') {
$endpoint = substr($endpoint, 0, strlen($endpoint)-1);
}
self::log("Calling $method /api/$endpoint");
$params = [
'headers'=> [
'Accept' => sprintf('application/vnd.xac.v%d+json', self::$apiVersion),
'AC-API-KEY' => self::$apiKey,
],
];
if (count($data) > 0) {
$params['json'] = $data;
}
try {
$this->initTransport();
$res = $this->transport->request($method, $endpoint, $params);
} catch (ConnectException $e) {
self::log($e->getMessage(), Logger::ERROR);
throw new \Exception($e->getMessage());
} catch (ServerException $e) {
$response = json_decode((string) $e->getResponse()->getBody(), true);
self::$lastResponse = $response['ACResponse'];
self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode();
self::log($e->getMessage(), Logger::ERROR);
throw new \Exception(self::$lastResponse['message']);
} catch (ClientException $e) {
$response = json_decode((string) $e->getResponse()->getBody(), true);
self::$lastResponse = $response['ACResponse'];
self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode();
self::log($e->getMessage(), Logger::ERROR);
throw new \Exception(self::$lastResponse['message']);
} finally {
if (isset($res)) {
$response = json_decode((string) $res->getBody(), !self::$returnObject);
$response = $response['ACResponse'];
}
}
self::$lastResponse = $response;
return $response['body']['data'];
} | [
"public",
"function",
"call",
"(",
"$",
"endpoint",
",",
"$",
"method",
"=",
"'GET'",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"endpoint",
",",
"-",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"endpoint",
"=",
"substr",
"(",
"$",
"endpoint",
",",
"0",
",",
"strlen",
"(",
"$",
"endpoint",
")",
"-",
"1",
")",
";",
"}",
"self",
"::",
"log",
"(",
"\"Calling $method /api/$endpoint\"",
")",
";",
"$",
"params",
"=",
"[",
"'headers'",
"=>",
"[",
"'Accept'",
"=>",
"sprintf",
"(",
"'application/vnd.xac.v%d+json'",
",",
"self",
"::",
"$",
"apiVersion",
")",
",",
"'AC-API-KEY'",
"=>",
"self",
"::",
"$",
"apiKey",
",",
"]",
",",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"data",
")",
">",
"0",
")",
"{",
"$",
"params",
"[",
"'json'",
"]",
"=",
"$",
"data",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"initTransport",
"(",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"transport",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"endpoint",
",",
"$",
"params",
")",
";",
"}",
"catch",
"(",
"ConnectException",
"$",
"e",
")",
"{",
"self",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Logger",
"::",
"ERROR",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ServerException",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"(",
"string",
")",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"self",
"::",
"$",
"lastResponse",
"=",
"$",
"response",
"[",
"'ACResponse'",
"]",
";",
"self",
"::",
"$",
"lastResponse",
"[",
"'httpCode'",
"]",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
";",
"self",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Logger",
"::",
"ERROR",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"self",
"::",
"$",
"lastResponse",
"[",
"'message'",
"]",
")",
";",
"}",
"catch",
"(",
"ClientException",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"(",
"string",
")",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"self",
"::",
"$",
"lastResponse",
"=",
"$",
"response",
"[",
"'ACResponse'",
"]",
";",
"self",
"::",
"$",
"lastResponse",
"[",
"'httpCode'",
"]",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
";",
"self",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Logger",
"::",
"ERROR",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"self",
"::",
"$",
"lastResponse",
"[",
"'message'",
"]",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"isset",
"(",
"$",
"res",
")",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"(",
"string",
")",
"$",
"res",
"->",
"getBody",
"(",
")",
",",
"!",
"self",
"::",
"$",
"returnObject",
")",
";",
"$",
"response",
"=",
"$",
"response",
"[",
"'ACResponse'",
"]",
";",
"}",
"}",
"self",
"::",
"$",
"lastResponse",
"=",
"$",
"response",
";",
"return",
"$",
"response",
"[",
"'body'",
"]",
"[",
"'data'",
"]",
";",
"}"
] | Make a HTTP Request and return response
@param string $endpoint
@param string $method
@param array $data
@throws \Exception
@return array | [
"Make",
"a",
"HTTP",
"Request",
"and",
"return",
"response"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L227-L278 |
ArrowSphere/Client | src/xAC.php | xAC.log | public static function log($message, $level = Logger::INFO)
{
if (! self::$logger) {
$logfile = sprintf('%s%sarrowsphere-client.log', sys_get_temp_dir(), DIRECTORY_SEPARATOR);
// create a log channel
self::$logger = new Logger('xAC');
self::$logger->pushHandler(new StreamHandler($logfile, Logger::INFO));
}
return self::$logger->addRecord($level, $message);
} | php | public static function log($message, $level = Logger::INFO)
{
if (! self::$logger) {
$logfile = sprintf('%s%sarrowsphere-client.log', sys_get_temp_dir(), DIRECTORY_SEPARATOR);
// create a log channel
self::$logger = new Logger('xAC');
self::$logger->pushHandler(new StreamHandler($logfile, Logger::INFO));
}
return self::$logger->addRecord($level, $message);
} | [
"public",
"static",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"level",
"=",
"Logger",
"::",
"INFO",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"logger",
")",
"{",
"$",
"logfile",
"=",
"sprintf",
"(",
"'%s%sarrowsphere-client.log'",
",",
"sys_get_temp_dir",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"// create a log channel",
"self",
"::",
"$",
"logger",
"=",
"new",
"Logger",
"(",
"'xAC'",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"pushHandler",
"(",
"new",
"StreamHandler",
"(",
"$",
"logfile",
",",
"Logger",
"::",
"INFO",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"logger",
"->",
"addRecord",
"(",
"$",
"level",
",",
"$",
"message",
")",
";",
"}"
] | Log messages to client log file
@param string $message
@param integer $level
@return boolean | [
"Log",
"messages",
"to",
"client",
"log",
"file"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L295-L306 |
ArrowSphere/Client | src/xAC.php | xAC.getInstance | public static function getInstance(HttpClient $transport = null)
{
if (is_null(self::$client)) {
self::$client = new self();
if (! is_null($transport)) {
self::$client->setTransport($transport);
}
}
return self::$client;
} | php | public static function getInstance(HttpClient $transport = null)
{
if (is_null(self::$client)) {
self::$client = new self();
if (! is_null($transport)) {
self::$client->setTransport($transport);
}
}
return self::$client;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"HttpClient",
"$",
"transport",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"client",
")",
")",
"{",
"self",
"::",
"$",
"client",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"transport",
")",
")",
"{",
"self",
"::",
"$",
"client",
"->",
"setTransport",
"(",
"$",
"transport",
")",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"client",
";",
"}"
] | Return a singleton instance of the class
@param GuzzleHttp\Client $transport
@return Arrowsphere\Client\xAC | [
"Return",
"a",
"singleton",
"instance",
"of",
"the",
"class"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L314-L325 |
ArrowSphere/Client | src/xAC.php | xAC.getServicesList | public static function getServicesList()
{
$map = [
'GET' => 'get',
'POST' => 'create',
'PUT' => 'update',
'DELETE' => 'delete',
];
$table = new \Console_Table();
$table->setHeaders(['Method', 'Type', 'Description', 'Parameters']);
foreach (self::getServices() as $key => $service) {
if ($service['type'] == 'entity') {
foreach ($service['actions'] as $action) {
$table->addRow([
sprintf('xAC::%s()->%s()'
, $service['endpoint']
, $action['endpoint'] == 'default' ? $map[$action['method']] : $action['endpoint']
),
'entity/' . $action['type'],
$action['description']
]);
}
} else {
$table->addRow(['xAC::' . $service['endpoint'] . '()->get()', $service['type'], $service['description']]);
}
}
echo $table->getTable();
} | php | public static function getServicesList()
{
$map = [
'GET' => 'get',
'POST' => 'create',
'PUT' => 'update',
'DELETE' => 'delete',
];
$table = new \Console_Table();
$table->setHeaders(['Method', 'Type', 'Description', 'Parameters']);
foreach (self::getServices() as $key => $service) {
if ($service['type'] == 'entity') {
foreach ($service['actions'] as $action) {
$table->addRow([
sprintf('xAC::%s()->%s()'
, $service['endpoint']
, $action['endpoint'] == 'default' ? $map[$action['method']] : $action['endpoint']
),
'entity/' . $action['type'],
$action['description']
]);
}
} else {
$table->addRow(['xAC::' . $service['endpoint'] . '()->get()', $service['type'], $service['description']]);
}
}
echo $table->getTable();
} | [
"public",
"static",
"function",
"getServicesList",
"(",
")",
"{",
"$",
"map",
"=",
"[",
"'GET'",
"=>",
"'get'",
",",
"'POST'",
"=>",
"'create'",
",",
"'PUT'",
"=>",
"'update'",
",",
"'DELETE'",
"=>",
"'delete'",
",",
"]",
";",
"$",
"table",
"=",
"new",
"\\",
"Console_Table",
"(",
")",
";",
"$",
"table",
"->",
"setHeaders",
"(",
"[",
"'Method'",
",",
"'Type'",
",",
"'Description'",
",",
"'Parameters'",
"]",
")",
";",
"foreach",
"(",
"self",
"::",
"getServices",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"service",
")",
"{",
"if",
"(",
"$",
"service",
"[",
"'type'",
"]",
"==",
"'entity'",
")",
"{",
"foreach",
"(",
"$",
"service",
"[",
"'actions'",
"]",
"as",
"$",
"action",
")",
"{",
"$",
"table",
"->",
"addRow",
"(",
"[",
"sprintf",
"(",
"'xAC::%s()->%s()'",
",",
"$",
"service",
"[",
"'endpoint'",
"]",
",",
"$",
"action",
"[",
"'endpoint'",
"]",
"==",
"'default'",
"?",
"$",
"map",
"[",
"$",
"action",
"[",
"'method'",
"]",
"]",
":",
"$",
"action",
"[",
"'endpoint'",
"]",
")",
",",
"'entity/'",
".",
"$",
"action",
"[",
"'type'",
"]",
",",
"$",
"action",
"[",
"'description'",
"]",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"table",
"->",
"addRow",
"(",
"[",
"'xAC::'",
".",
"$",
"service",
"[",
"'endpoint'",
"]",
".",
"'()->get()'",
",",
"$",
"service",
"[",
"'type'",
"]",
",",
"$",
"service",
"[",
"'description'",
"]",
"]",
")",
";",
"}",
"}",
"echo",
"$",
"table",
"->",
"getTable",
"(",
")",
";",
"}"
] | Display a list of available service on console
execute from the application folder:
php -r "require 'vendor/autoload.php'; Arrowsphere\Client\xAC::getServicesList();" | [
"Display",
"a",
"list",
"of",
"available",
"service",
"on",
"console"
] | train | https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L352-L381 |
CalderaWP/metaplate-core | src/file_load.php | file_load.load | public static function load( $file ) {
add_filter( 'calderawp_file_locator_allow_extensions', function( $allowed, $context ) {
if ( self::$context === $context ) {
$allowed = array( 'html', 'htm' );
}
return $allowed;
}, 10, 2 );
$file = file_locator::locate( $file, self::$context, true );
if ( is_string( $file ) ) {
return array( 'html' => array( 'code' => file_get_contents( $file ) ) );
}
} | php | public static function load( $file ) {
add_filter( 'calderawp_file_locator_allow_extensions', function( $allowed, $context ) {
if ( self::$context === $context ) {
$allowed = array( 'html', 'htm' );
}
return $allowed;
}, 10, 2 );
$file = file_locator::locate( $file, self::$context, true );
if ( is_string( $file ) ) {
return array( 'html' => array( 'code' => file_get_contents( $file ) ) );
}
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"add_filter",
"(",
"'calderawp_file_locator_allow_extensions'",
",",
"function",
"(",
"$",
"allowed",
",",
"$",
"context",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"context",
"===",
"$",
"context",
")",
"{",
"$",
"allowed",
"=",
"array",
"(",
"'html'",
",",
"'htm'",
")",
";",
"}",
"return",
"$",
"allowed",
";",
"}",
",",
"10",
",",
"2",
")",
";",
"$",
"file",
"=",
"file_locator",
"::",
"locate",
"(",
"$",
"file",
",",
"self",
"::",
"$",
"context",
",",
"true",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"file",
")",
")",
"{",
"return",
"array",
"(",
"'html'",
"=>",
"array",
"(",
"'code'",
"=>",
"file_get_contents",
"(",
"$",
"file",
")",
")",
")",
";",
"}",
"}"
] | Attempts to load a file and if so, puts its contents in an array as expected by Metaplate
@param string $file File path. Can be relative to current theme or absolute. Must be .html or .htm
@return array|void Returns an array 'html' => file contents if possible. | [
"Attempts",
"to",
"load",
"a",
"file",
"and",
"if",
"so",
"puts",
"its",
"contents",
"in",
"an",
"array",
"as",
"expected",
"by",
"Metaplate"
] | train | https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/file_load.php#L38-L57 |
Yurunsoft/YurunEvent | Src/Event.php | Event.register | public static function register($event, $callback, $first = false, $once = false)
{
return call_user_func_array([EventClass::getInstance(), 'register'], func_get_args());
} | php | public static function register($event, $callback, $first = false, $once = false)
{
return call_user_func_array([EventClass::getInstance(), 'register'], func_get_args());
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"event",
",",
"$",
"callback",
",",
"$",
"first",
"=",
"false",
",",
"$",
"once",
"=",
"false",
")",
"{",
"return",
"call_user_func_array",
"(",
"[",
"EventClass",
"::",
"getInstance",
"(",
")",
",",
"'register'",
"]",
",",
"func_get_args",
"(",
")",
")",
";",
"}"
] | 注册事件(监听)
@param string $event 事件名称
@param mixed $callback 回调
@param bool $first 是否优先执行,以靠后设置的为准
@param bool $once 是否只执行一次 | [
"注册事件",
"(",
"监听",
")"
] | train | https://github.com/Yurunsoft/YurunEvent/blob/7957f7d048ac0614f45e279e2b54d72ced67867c/Src/Event.php#L13-L16 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/options.php | ezcBaseOptions.merge | public function merge( array $newOptions )
{
foreach ( $newOptions as $key => $value )
{
$this->__set( $key, $value );
}
} | php | public function merge( array $newOptions )
{
foreach ( $newOptions as $key => $value )
{
$this->__set( $key, $value );
}
} | [
"public",
"function",
"merge",
"(",
"array",
"$",
"newOptions",
")",
"{",
"foreach",
"(",
"$",
"newOptions",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"__set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Merge an array into the actual options object.
This method merges an array of new options into the actual options object.
@throws ezcBasePropertyNotFoundException
If trying to access a non existent property.
@throws ezcBaseValueException
If the value for a property is out of range.
@param array(string=>mixed) $newOptions The new options. | [
"Merge",
"an",
"array",
"into",
"the",
"actual",
"options",
"object",
".",
"This",
"method",
"merges",
"an",
"array",
"of",
"new",
"options",
"into",
"the",
"actual",
"options",
"object",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/options.php#L56-L62 |
brick/di | src/Injector.php | Injector.invoke | public function invoke(callable $function, array $parameters = [])
{
$reflection = $this->reflectionTools->getReflectionFunction($function);
$parameters = $this->getFunctionParameters($reflection, $parameters);
return call_user_func_array($function, $parameters);
} | php | public function invoke(callable $function, array $parameters = [])
{
$reflection = $this->reflectionTools->getReflectionFunction($function);
$parameters = $this->getFunctionParameters($reflection, $parameters);
return call_user_func_array($function, $parameters);
} | [
"public",
"function",
"invoke",
"(",
"callable",
"$",
"function",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"reflection",
"=",
"$",
"this",
"->",
"reflectionTools",
"->",
"getReflectionFunction",
"(",
"$",
"function",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getFunctionParameters",
"(",
"$",
"reflection",
",",
"$",
"parameters",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"function",
",",
"$",
"parameters",
")",
";",
"}"
] | Invokes a function after resolving its parameters.
If the given parameters match the function parameter names, the given values are used.
Otherwise, the function parameters are resolved using the ValueResolver.
@param callable $function The function to invoke.
@param array $parameters An associative array of values for the function parameters.
@return mixed The result of the function call.
@throws UnresolvedValueException If a function parameter could not be resolved. | [
"Invokes",
"a",
"function",
"after",
"resolving",
"its",
"parameters",
"."
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Injector.php#L53-L59 |
brick/di | src/Injector.php | Injector.instantiate | public function instantiate(string $class, array $parameters = [])
{
$class = new \ReflectionClass($class);
$instance = $class->newInstanceWithoutConstructor();
$this->inject($instance);
$constructor = $class->getConstructor();
if ($constructor) {
$parameters = $this->getFunctionParameters($constructor, $parameters);
$constructor->setAccessible(true);
$constructor->invokeArgs($instance, $parameters);
}
return $instance;
} | php | public function instantiate(string $class, array $parameters = [])
{
$class = new \ReflectionClass($class);
$instance = $class->newInstanceWithoutConstructor();
$this->inject($instance);
$constructor = $class->getConstructor();
if ($constructor) {
$parameters = $this->getFunctionParameters($constructor, $parameters);
$constructor->setAccessible(true);
$constructor->invokeArgs($instance, $parameters);
}
return $instance;
} | [
"public",
"function",
"instantiate",
"(",
"string",
"$",
"class",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"instance",
"=",
"$",
"class",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"$",
"this",
"->",
"inject",
"(",
"$",
"instance",
")",
";",
"$",
"constructor",
"=",
"$",
"class",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"$",
"constructor",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getFunctionParameters",
"(",
"$",
"constructor",
",",
"$",
"parameters",
")",
";",
"$",
"constructor",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"constructor",
"->",
"invokeArgs",
"(",
"$",
"instance",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] | Instantiates a class by resolving its constructor parameters, and injects dependencies in the resulting object.
If the given parameters match the constructor parameter names, the given values are used.
Otherwise, the constructor parameters are resolved using the ValueResolver.
@param string $class The name of the class to instantiate.
@param array $parameters An associative array of values for the constructor parameters.
@return object The instantiated object.
@throws UnresolvedValueException If a function parameter could not be resolved. | [
"Instantiates",
"a",
"class",
"by",
"resolving",
"its",
"constructor",
"parameters",
"and",
"injects",
"dependencies",
"in",
"the",
"resulting",
"object",
"."
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Injector.php#L74-L90 |
brick/di | src/Injector.php | Injector.inject | public function inject($object) : void
{
$reflection = new \ReflectionObject($object);
$this->injectProperties($reflection, $object);
$this->injectMethods($reflection, $object);
} | php | public function inject($object) : void
{
$reflection = new \ReflectionObject($object);
$this->injectProperties($reflection, $object);
$this->injectMethods($reflection, $object);
} | [
"public",
"function",
"inject",
"(",
"$",
"object",
")",
":",
"void",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"injectProperties",
"(",
"$",
"reflection",
",",
"$",
"object",
")",
";",
"$",
"this",
"->",
"injectMethods",
"(",
"$",
"reflection",
",",
"$",
"object",
")",
";",
"}"
] | Injects dependencies in an object.
Properties are injected first, then methods.
@param object $object The object to inject dependencies in.
@return void | [
"Injects",
"dependencies",
"in",
"an",
"object",
"."
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Injector.php#L101-L107 |
brick/di | src/Injector.php | Injector.injectMethods | private function injectMethods(\ReflectionClass $class, $object) : void
{
foreach ($this->reflectionTools->getClassMethods($class) as $method) {
if ($this->policy->isMethodInjected($method)) {
$parameters = $this->getFunctionParameters($method);
$method->setAccessible(true);
$method->invokeArgs($object, $parameters);
}
}
} | php | private function injectMethods(\ReflectionClass $class, $object) : void
{
foreach ($this->reflectionTools->getClassMethods($class) as $method) {
if ($this->policy->isMethodInjected($method)) {
$parameters = $this->getFunctionParameters($method);
$method->setAccessible(true);
$method->invokeArgs($object, $parameters);
}
}
} | [
"private",
"function",
"injectMethods",
"(",
"\\",
"ReflectionClass",
"$",
"class",
",",
"$",
"object",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"reflectionTools",
"->",
"getClassMethods",
"(",
"$",
"class",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"policy",
"->",
"isMethodInjected",
"(",
"$",
"method",
")",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getFunctionParameters",
"(",
"$",
"method",
")",
";",
"$",
"method",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"method",
"->",
"invokeArgs",
"(",
"$",
"object",
",",
"$",
"parameters",
")",
";",
"}",
"}",
"}"
] | @param \ReflectionClass $class
@param object $object
@return void | [
"@param",
"\\",
"ReflectionClass",
"$class",
"@param",
"object",
"$object"
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Injector.php#L115-L124 |
brick/di | src/Injector.php | Injector.injectProperties | private function injectProperties(\ReflectionClass $class, $object) : void
{
foreach ($this->reflectionTools->getClassProperties($class) as $property) {
if ($this->policy->isPropertyInjected($property)) {
$value = $this->resolver->getPropertyValue($property);
$property->setAccessible(true);
$property->setValue($object, $value);
}
}
} | php | private function injectProperties(\ReflectionClass $class, $object) : void
{
foreach ($this->reflectionTools->getClassProperties($class) as $property) {
if ($this->policy->isPropertyInjected($property)) {
$value = $this->resolver->getPropertyValue($property);
$property->setAccessible(true);
$property->setValue($object, $value);
}
}
} | [
"private",
"function",
"injectProperties",
"(",
"\\",
"ReflectionClass",
"$",
"class",
",",
"$",
"object",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"reflectionTools",
"->",
"getClassProperties",
"(",
"$",
"class",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"policy",
"->",
"isPropertyInjected",
"(",
"$",
"property",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"resolver",
"->",
"getPropertyValue",
"(",
"$",
"property",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"property",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | @param \ReflectionClass $class
@param object $object
@return void | [
"@param",
"\\",
"ReflectionClass",
"$class",
"@param",
"object",
"$object"
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Injector.php#L132-L141 |
brick/di | src/Injector.php | Injector.getFunctionParameters | private function getFunctionParameters(\ReflectionFunctionAbstract $function, array $parameters = []) : array
{
$result = [];
foreach ($function->getParameters() as $parameter) {
$name = $parameter->getName();
if (array_key_exists($name, $parameters)) {
$value = $parameters[$name];
} else {
$value = $this->resolver->getParameterValue($parameter);
}
if ($parameter->isVariadic()) {
$result = array_merge($result, $value);
} else {
$result[] = $value;
}
}
return $result;
} | php | private function getFunctionParameters(\ReflectionFunctionAbstract $function, array $parameters = []) : array
{
$result = [];
foreach ($function->getParameters() as $parameter) {
$name = $parameter->getName();
if (array_key_exists($name, $parameters)) {
$value = $parameters[$name];
} else {
$value = $this->resolver->getParameterValue($parameter);
}
if ($parameter->isVariadic()) {
$result = array_merge($result, $value);
} else {
$result[] = $value;
}
}
return $result;
} | [
"private",
"function",
"getFunctionParameters",
"(",
"\\",
"ReflectionFunctionAbstract",
"$",
"function",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"function",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"$",
"name",
"=",
"$",
"parameter",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"parameters",
")",
")",
"{",
"$",
"value",
"=",
"$",
"parameters",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"resolver",
"->",
"getParameterValue",
"(",
"$",
"parameter",
")",
";",
"}",
"if",
"(",
"$",
"parameter",
"->",
"isVariadic",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns an associative array of parameters to call a given function.
The parameters are indexed by name, and returned in the same order as they are defined.
@param \ReflectionFunctionAbstract $function The reflection of the function.
@param array $parameters An optional array of parameters indexed by name.
@return array The parameters to call the function with.
@throws UnresolvedValueException If a function parameter could not be resolved. | [
"Returns",
"an",
"associative",
"array",
"of",
"parameters",
"to",
"call",
"a",
"given",
"function",
"."
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Injector.php#L155-L176 |
graze/data-structure | src/Container/ImmutableContainer.php | ImmutableContainer.set | public function set($key, $value)
{
$cont = clone $this;
$cont->setParameter($key, $value);
return $cont;
} | php | public function set($key, $value)
{
$cont = clone $this;
$cont->setParameter($key, $value);
return $cont;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"cont",
"=",
"clone",
"$",
"this",
";",
"$",
"cont",
"->",
"setParameter",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"return",
"$",
"cont",
";",
"}"
] | @param string $key
@param mixed $value
@return ContainerInterface | [
"@param",
"string",
"$key",
"@param",
"mixed",
"$value"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/ImmutableContainer.php#L36-L42 |
graze/data-structure | src/Container/ImmutableContainer.php | ImmutableContainer.remove | public function remove($key)
{
if ($this->has($key)) {
$cont = clone $this;
$cont->removeParameter($key);
return $cont;
}
return $this;
} | php | public function remove($key)
{
if ($this->has($key)) {
$cont = clone $this;
$cont->removeParameter($key);
return $cont;
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"cont",
"=",
"clone",
"$",
"this",
";",
"$",
"cont",
"->",
"removeParameter",
"(",
"$",
"key",
")",
";",
"return",
"$",
"cont",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | @param string $key
@return ContainerInterface | [
"@param",
"string",
"$key"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/ImmutableContainer.php#L61-L71 |
phpzm/route | src/Router.php | Router.group | public function group($method, $start, $context, $options = [])
{
$type = '';
switch (gettype($context)) {
case TYPE_ARRAY:
$context = $this->fixGroupArray($context);
$type = 'files';
break;
case TYPE_STRING:
$path = path(true, $context);
$isFile = file_exists($path);
if ($isFile) {
$type = 'file';
}
if ($isFile && is_dir($path)) {
$type = 'dir';
}
break;
}
if (is_callable($context)) {
$type = 'callable';
}
$start = (substr($start, 0, 1) === '/' ? $start : '/' . $start);
$start = (substr($start, -1) === '/' ? substr($start, 0, -1) : $start);
$options['group'] = ['start' => $this->pattern($start)['pattern'] . '/', 'type' => $type];
$uri = $start . '*';
$this->on($method, $uri, $context, $options);
return $this;
} | php | public function group($method, $start, $context, $options = [])
{
$type = '';
switch (gettype($context)) {
case TYPE_ARRAY:
$context = $this->fixGroupArray($context);
$type = 'files';
break;
case TYPE_STRING:
$path = path(true, $context);
$isFile = file_exists($path);
if ($isFile) {
$type = 'file';
}
if ($isFile && is_dir($path)) {
$type = 'dir';
}
break;
}
if (is_callable($context)) {
$type = 'callable';
}
$start = (substr($start, 0, 1) === '/' ? $start : '/' . $start);
$start = (substr($start, -1) === '/' ? substr($start, 0, -1) : $start);
$options['group'] = ['start' => $this->pattern($start)['pattern'] . '/', 'type' => $type];
$uri = $start . '*';
$this->on($method, $uri, $context, $options);
return $this;
} | [
"public",
"function",
"group",
"(",
"$",
"method",
",",
"$",
"start",
",",
"$",
"context",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"type",
"=",
"''",
";",
"switch",
"(",
"gettype",
"(",
"$",
"context",
")",
")",
"{",
"case",
"TYPE_ARRAY",
":",
"$",
"context",
"=",
"$",
"this",
"->",
"fixGroupArray",
"(",
"$",
"context",
")",
";",
"$",
"type",
"=",
"'files'",
";",
"break",
";",
"case",
"TYPE_STRING",
":",
"$",
"path",
"=",
"path",
"(",
"true",
",",
"$",
"context",
")",
";",
"$",
"isFile",
"=",
"file_exists",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"isFile",
")",
"{",
"$",
"type",
"=",
"'file'",
";",
"}",
"if",
"(",
"$",
"isFile",
"&&",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"type",
"=",
"'dir'",
";",
"}",
"break",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"context",
")",
")",
"{",
"$",
"type",
"=",
"'callable'",
";",
"}",
"$",
"start",
"=",
"(",
"substr",
"(",
"$",
"start",
",",
"0",
",",
"1",
")",
"===",
"'/'",
"?",
"$",
"start",
":",
"'/'",
".",
"$",
"start",
")",
";",
"$",
"start",
"=",
"(",
"substr",
"(",
"$",
"start",
",",
"-",
"1",
")",
"===",
"'/'",
"?",
"substr",
"(",
"$",
"start",
",",
"0",
",",
"-",
"1",
")",
":",
"$",
"start",
")",
";",
"$",
"options",
"[",
"'group'",
"]",
"=",
"[",
"'start'",
"=>",
"$",
"this",
"->",
"pattern",
"(",
"$",
"start",
")",
"[",
"'pattern'",
"]",
".",
"'/'",
",",
"'type'",
"=>",
"$",
"type",
"]",
";",
"$",
"uri",
"=",
"$",
"start",
".",
"'*'",
";",
"$",
"this",
"->",
"on",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"context",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
";",
"}"
] | TODO: exceptions to error input parameters
@param $method
@param $start
@param $context
@param array $options
@return $this | [
"TODO",
":",
"exceptions",
"to",
"error",
"input",
"parameters"
] | train | https://github.com/phpzm/route/blob/e7d6309cfc3eedaf93c15c5cc4c5017483ed9d9b/src/Router.php#L40-L74 |
ajant/SimpleArrayLibrary | src/Categories/Checkers.php | Checkers.allElementsEqual | public static function allElementsEqual(array $haystack, $needle = null)
{
$return = true;
// if both arguments have been passed, use value argument (regardless of whether it is null or not
if (func_num_args() == 2) {
$compareAgainst = $needle;
} // only one argument has been passed, so compare elements only to each other
else {
$compareAgainst = reset($haystack);
}
foreach ($haystack as $element) {
if ($compareAgainst != $element) {
$return = false;
break;
}
}
return $return;
} | php | public static function allElementsEqual(array $haystack, $needle = null)
{
$return = true;
// if both arguments have been passed, use value argument (regardless of whether it is null or not
if (func_num_args() == 2) {
$compareAgainst = $needle;
} // only one argument has been passed, so compare elements only to each other
else {
$compareAgainst = reset($haystack);
}
foreach ($haystack as $element) {
if ($compareAgainst != $element) {
$return = false;
break;
}
}
return $return;
} | [
"public",
"static",
"function",
"allElementsEqual",
"(",
"array",
"$",
"haystack",
",",
"$",
"needle",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"true",
";",
"// if both arguments have been passed, use value argument (regardless of whether it is null or not",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"2",
")",
"{",
"$",
"compareAgainst",
"=",
"$",
"needle",
";",
"}",
"// only one argument has been passed, so compare elements only to each other",
"else",
"{",
"$",
"compareAgainst",
"=",
"reset",
"(",
"$",
"haystack",
")",
";",
"}",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"compareAgainst",
"!=",
"$",
"element",
")",
"{",
"$",
"return",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Checks if all elements of the array have same value
@param array $haystack
@param mixed $needle
@return boolean | [
"Checks",
"if",
"all",
"elements",
"of",
"the",
"array",
"have",
"same",
"value"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Checkers.php#L17-L35 |
ajant/SimpleArrayLibrary | src/Categories/Checkers.php | Checkers.isStructureSame | public static function isStructureSame($input1, $input2)
{
$return = true;
if (is_array($input1) && is_array($input2)) {
if (!self::compareArrays($input1, $input2) || !self::compareArrays($input2, $input1)) {
$return = false;
}
} else {
$return = !is_array($input1) && !is_array($input2);
}
return $return;
} | php | public static function isStructureSame($input1, $input2)
{
$return = true;
if (is_array($input1) && is_array($input2)) {
if (!self::compareArrays($input1, $input2) || !self::compareArrays($input2, $input1)) {
$return = false;
}
} else {
$return = !is_array($input1) && !is_array($input2);
}
return $return;
} | [
"public",
"static",
"function",
"isStructureSame",
"(",
"$",
"input1",
",",
"$",
"input2",
")",
"{",
"$",
"return",
"=",
"true",
";",
"if",
"(",
"is_array",
"(",
"$",
"input1",
")",
"&&",
"is_array",
"(",
"$",
"input2",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"compareArrays",
"(",
"$",
"input1",
",",
"$",
"input2",
")",
"||",
"!",
"self",
"::",
"compareArrays",
"(",
"$",
"input2",
",",
"$",
"input1",
")",
")",
"{",
"$",
"return",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"!",
"is_array",
"(",
"$",
"input1",
")",
"&&",
"!",
"is_array",
"(",
"$",
"input2",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | @param mixed $input1
@param mixed $input2
@return bool | [
"@param",
"mixed",
"$input1",
"@param",
"mixed",
"$input2"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Checkers.php#L67-L79 |
ajant/SimpleArrayLibrary | src/Categories/Checkers.php | Checkers.compareArrays | private static function compareArrays(array $input1, array $input2)
{
foreach ($input1 as $key => $value) {
if (!array_key_exists($key, $input2)) {
return false;
} else {
if (!self::isStructureSame($value, $input2[$key])) {
return false;
}
}
}
return true;
} | php | private static function compareArrays(array $input1, array $input2)
{
foreach ($input1 as $key => $value) {
if (!array_key_exists($key, $input2)) {
return false;
} else {
if (!self::isStructureSame($value, $input2[$key])) {
return false;
}
}
}
return true;
} | [
"private",
"static",
"function",
"compareArrays",
"(",
"array",
"$",
"input1",
",",
"array",
"$",
"input2",
")",
"{",
"foreach",
"(",
"$",
"input1",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"input2",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"self",
"::",
"isStructureSame",
"(",
"$",
"value",
",",
"$",
"input2",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | @param array $input1
@param array $input2
@return bool | [
"@param",
"array",
"$input1",
"@param",
"array",
"$input2"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Checkers.php#L87-L100 |
ajant/SimpleArrayLibrary | src/Categories/Checkers.php | Checkers.isSubArray | public static function isSubArray(array $array, array $subArray, $strictComparison = true)
{
if (!is_bool($strictComparison)) {
throw new InvalidArgumentException('Strict comparison parameter must be a boolean');
}
$return = true;
foreach ($subArray as $key => $value) {
if (isset($array[$key]) || array_key_exists($key, $array)) {
$check = $strictComparison ? $array[$key] !== $subArray[$key] : $array[$key] != $subArray[$key];
if ($check) {
$return = false;
break;
}
} else {
$return = false;
break;
}
}
return $return;
} | php | public static function isSubArray(array $array, array $subArray, $strictComparison = true)
{
if (!is_bool($strictComparison)) {
throw new InvalidArgumentException('Strict comparison parameter must be a boolean');
}
$return = true;
foreach ($subArray as $key => $value) {
if (isset($array[$key]) || array_key_exists($key, $array)) {
$check = $strictComparison ? $array[$key] !== $subArray[$key] : $array[$key] != $subArray[$key];
if ($check) {
$return = false;
break;
}
} else {
$return = false;
break;
}
}
return $return;
} | [
"public",
"static",
"function",
"isSubArray",
"(",
"array",
"$",
"array",
",",
"array",
"$",
"subArray",
",",
"$",
"strictComparison",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"strictComparison",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Strict comparison parameter must be a boolean'",
")",
";",
"}",
"$",
"return",
"=",
"true",
";",
"foreach",
"(",
"$",
"subArray",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
"||",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
")",
"{",
"$",
"check",
"=",
"$",
"strictComparison",
"?",
"$",
"array",
"[",
"$",
"key",
"]",
"!==",
"$",
"subArray",
"[",
"$",
"key",
"]",
":",
"$",
"array",
"[",
"$",
"key",
"]",
"!=",
"$",
"subArray",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"$",
"check",
")",
"{",
"$",
"return",
"=",
"false",
";",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Checks whether $subArray is contained in $array
@param array $array
@param array $subArray
@param bool $strictComparison
@return bool
@throws InvalidArgumentException | [
"Checks",
"whether",
"$subArray",
"is",
"contained",
"in",
"$array"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Checkers.php#L112-L133 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.