id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,600 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.updateLanguage | public function updateLanguage(
string $slug,
string $langCode,
array $coordinators,
array $options = []
): ResponseInterface {
// Make sure the $coordinators array is not empty
if (!\count($coordinators)) {
throw new \InvalidArgumentException('The coordinators array must contain at least one username.');
}
// Build the required request data.
$data = ['coordinators' => $coordinators];
// Set the translators if present
if (isset($options['translators'])) {
$data['translators'] = $options['translators'];
}
// Set the reviewers if present
if (isset($options['reviewers'])) {
$data['reviewers'] = $options['reviewers'];
}
$request = $this->createRequest('PUT', $this->createUri("/api/2/project/$slug/language/$langCode/"));
$request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));
$request = $request->withHeader('Content-Type', 'application/json');
return $this->client->sendRequest($request);
} | php | public function updateLanguage(
string $slug,
string $langCode,
array $coordinators,
array $options = []
): ResponseInterface {
// Make sure the $coordinators array is not empty
if (!\count($coordinators)) {
throw new \InvalidArgumentException('The coordinators array must contain at least one username.');
}
// Build the required request data.
$data = ['coordinators' => $coordinators];
// Set the translators if present
if (isset($options['translators'])) {
$data['translators'] = $options['translators'];
}
// Set the reviewers if present
if (isset($options['reviewers'])) {
$data['reviewers'] = $options['reviewers'];
}
$request = $this->createRequest('PUT', $this->createUri("/api/2/project/$slug/language/$langCode/"));
$request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));
$request = $request->withHeader('Content-Type', 'application/json');
return $this->client->sendRequest($request);
} | [
"public",
"function",
"updateLanguage",
"(",
"string",
"$",
"slug",
",",
"string",
"$",
"langCode",
",",
"array",
"$",
"coordinators",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"// Make sure the $coordinators array is not empty",
"if",
"(",
"!",
"\\",
"count",
"(",
"$",
"coordinators",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The coordinators array must contain at least one username.'",
")",
";",
"}",
"// Build the required request data.",
"$",
"data",
"=",
"[",
"'coordinators'",
"=>",
"$",
"coordinators",
"]",
";",
"// Set the translators if present",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'translators'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'translators'",
"]",
"=",
"$",
"options",
"[",
"'translators'",
"]",
";",
"}",
"// Set the reviewers if present",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'reviewers'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'reviewers'",
"]",
"=",
"$",
"options",
"[",
"'reviewers'",
"]",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'PUT'",
",",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$slug/language/$langCode/\"",
")",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withBody",
"(",
"$",
"this",
"->",
"streamFactory",
"->",
"createStream",
"(",
"\\",
"json_encode",
"(",
"$",
"data",
")",
")",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"request",
")",
";",
"}"
] | Update a language within a project.
@param string $slug The slug for the project
@param string $langCode The language code for the new language
@param string[] $coordinators An array of coordinators for the language
@param array $options Optional additional params to send with the request
@return ResponseInterface
@throws \InvalidArgumentException | [
"Update",
"a",
"language",
"within",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L183-L212 |
28,601 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.updateReviewers | public function updateReviewers(string $project, string $langCode, array $reviewers, bool $skipInvalidUsername = false): ResponseInterface
{
return $this->updateTeam($project, $langCode, $reviewers, $skipInvalidUsername, 'reviewers');
} | php | public function updateReviewers(string $project, string $langCode, array $reviewers, bool $skipInvalidUsername = false): ResponseInterface
{
return $this->updateTeam($project, $langCode, $reviewers, $skipInvalidUsername, 'reviewers');
} | [
"public",
"function",
"updateReviewers",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"langCode",
",",
"array",
"$",
"reviewers",
",",
"bool",
"$",
"skipInvalidUsername",
"=",
"false",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"updateTeam",
"(",
"$",
"project",
",",
"$",
"langCode",
",",
"$",
"reviewers",
",",
"$",
"skipInvalidUsername",
",",
"'reviewers'",
")",
";",
"}"
] | Update the reviewers for a language team in a project.
@param string $project The project to retrieve details for
@param string $langCode The language code to retrieve details for
@param string[] $reviewers An array of reviewers for the language
@param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames
@return ResponseInterface | [
"Update",
"the",
"reviewers",
"for",
"a",
"language",
"team",
"in",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L224-L227 |
28,602 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.updateTeam | protected function updateTeam(
string $project,
string $langCode,
array $members,
bool $skipInvalidUsername,
string $team
): ResponseInterface {
// Make sure the $members array is not empty
if (!\count($members)) {
throw new \InvalidArgumentException("The $team array must contain at least one username.");
}
$uri = $this->createUri("/api/2/project/$project/language/$langCode/$team/");
if ($skipInvalidUsername) {
$uri = $uri->withQuery('skip_invalid_username');
}
$request = $this->createRequest('PUT', $uri);
$request = $request->withBody($this->streamFactory->createStream(\json_encode($members)));
$request = $request->withHeader('Content-Type', 'application/json');
return $this->client->sendRequest($request);
} | php | protected function updateTeam(
string $project,
string $langCode,
array $members,
bool $skipInvalidUsername,
string $team
): ResponseInterface {
// Make sure the $members array is not empty
if (!\count($members)) {
throw new \InvalidArgumentException("The $team array must contain at least one username.");
}
$uri = $this->createUri("/api/2/project/$project/language/$langCode/$team/");
if ($skipInvalidUsername) {
$uri = $uri->withQuery('skip_invalid_username');
}
$request = $this->createRequest('PUT', $uri);
$request = $request->withBody($this->streamFactory->createStream(\json_encode($members)));
$request = $request->withHeader('Content-Type', 'application/json');
return $this->client->sendRequest($request);
} | [
"protected",
"function",
"updateTeam",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"langCode",
",",
"array",
"$",
"members",
",",
"bool",
"$",
"skipInvalidUsername",
",",
"string",
"$",
"team",
")",
":",
"ResponseInterface",
"{",
"// Make sure the $members array is not empty",
"if",
"(",
"!",
"\\",
"count",
"(",
"$",
"members",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The $team array must contain at least one username.\"",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$project/language/$langCode/$team/\"",
")",
";",
"if",
"(",
"$",
"skipInvalidUsername",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"'skip_invalid_username'",
")",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'PUT'",
",",
"$",
"uri",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withBody",
"(",
"$",
"this",
"->",
"streamFactory",
"->",
"createStream",
"(",
"\\",
"json_encode",
"(",
"$",
"members",
")",
")",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"request",
")",
";",
"}"
] | Base method to update a given language team in a project.
@param string $project The project to retrieve details for
@param string $langCode The language code to retrieve details for
@param string[] $members An array of the team members for the language
@param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames
@param string $team The team to update
@return ResponseInterface
@throws \InvalidArgumentException | [
"Base",
"method",
"to",
"update",
"a",
"given",
"language",
"team",
"in",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L242-L265 |
28,603 | BabDev/Transifex-API | src/Connector/Languages.php | Languages.updateTranslators | public function updateTranslators(
string $project,
string $langCode,
array $translators,
bool $skipInvalidUsername = false
): ResponseInterface {
return $this->updateTeam($project, $langCode, $translators, $skipInvalidUsername, 'translators');
} | php | public function updateTranslators(
string $project,
string $langCode,
array $translators,
bool $skipInvalidUsername = false
): ResponseInterface {
return $this->updateTeam($project, $langCode, $translators, $skipInvalidUsername, 'translators');
} | [
"public",
"function",
"updateTranslators",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"langCode",
",",
"array",
"$",
"translators",
",",
"bool",
"$",
"skipInvalidUsername",
"=",
"false",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"updateTeam",
"(",
"$",
"project",
",",
"$",
"langCode",
",",
"$",
"translators",
",",
"$",
"skipInvalidUsername",
",",
"'translators'",
")",
";",
"}"
] | Update the translators for a language team in a project.
@param string $project The project to retrieve details for
@param string $langCode The language code to retrieve details for
@param string[] $translators An array of translators for the language
@param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames
@return ResponseInterface | [
"Update",
"the",
"translators",
"for",
"a",
"language",
"team",
"in",
"a",
"project",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L277-L284 |
28,604 | BabDev/Transifex-API | src/Connector/Statistics.php | Statistics.getStatistics | public function getStatistics(string $project, string $resource, string $lang = ''): ResponseInterface
{
return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/resource/$resource/stats/$lang")));
} | php | public function getStatistics(string $project, string $resource, string $lang = ''): ResponseInterface
{
return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/resource/$resource/stats/$lang")));
} | [
"public",
"function",
"getStatistics",
"(",
"string",
"$",
"project",
",",
"string",
"$",
"resource",
",",
"string",
"$",
"lang",
"=",
"''",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"createRequest",
"(",
"'GET'",
",",
"$",
"this",
"->",
"createUri",
"(",
"\"/api/2/project/$project/resource/$resource/stats/$lang\"",
")",
")",
")",
";",
"}"
] | Get statistics on a specified resource.
@param string $project The slug for the project to pull from
@param string $resource The slug for the resource to pull from
@param string $lang An optional language code to return data only for a specified language
@return ResponseInterface | [
"Get",
"statistics",
"on",
"a",
"specified",
"resource",
"."
] | 9e0ccd7980127db88f7c55a36afbd2a49d9e8436 | https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Statistics.php#L24-L27 |
28,605 | TYPO3-CMS/redirects | Classes/Controller/ManagementController.php | ManagementController.handleRequest | public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$this->request = $request;
$action = $request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview';
$this->initializeView($action);
$result = call_user_func_array([$this, $action . 'Action'], [$request]);
if ($result instanceof ResponseInterface) {
return $result;
}
$this->moduleTemplate->setContent($this->view->render());
return new HtmlResponse($this->moduleTemplate->renderContent());
} | php | public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$this->request = $request;
$action = $request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview';
$this->initializeView($action);
$result = call_user_func_array([$this, $action . 'Action'], [$request]);
if ($result instanceof ResponseInterface) {
return $result;
}
$this->moduleTemplate->setContent($this->view->render());
return new HtmlResponse($this->moduleTemplate->renderContent());
} | [
"public",
"function",
"handleRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"action",
"=",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
"[",
"'action'",
"]",
"??",
"$",
"request",
"->",
"getParsedBody",
"(",
")",
"[",
"'action'",
"]",
"??",
"'overview'",
";",
"$",
"this",
"->",
"initializeView",
"(",
"$",
"action",
")",
";",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"action",
".",
"'Action'",
"]",
",",
"[",
"$",
"request",
"]",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"ResponseInterface",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"this",
"->",
"moduleTemplate",
"->",
"setContent",
"(",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
")",
")",
";",
"return",
"new",
"HtmlResponse",
"(",
"$",
"this",
"->",
"moduleTemplate",
"->",
"renderContent",
"(",
")",
")",
";",
"}"
] | Injects the request object for the current request, and renders the overview of all redirects
@param ServerRequestInterface $request the current request
@return ResponseInterface the response with the content | [
"Injects",
"the",
"request",
"object",
"for",
"the",
"current",
"request",
"and",
"renders",
"the",
"overview",
"of",
"all",
"redirects"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L81-L93 |
28,606 | TYPO3-CMS/redirects | Classes/Controller/ManagementController.php | ManagementController.overviewAction | protected function overviewAction(ServerRequestInterface $request)
{
$this->getButtons();
$demand = Demand::createFromRequest($request);
$redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class, $demand);
$count = $redirectRepository->countRedirectsByByDemand();
$this->view->assignMultiple([
'redirects' => $redirectRepository->findRedirectsByDemand(),
'hosts' => $redirectRepository->findHostsOfRedirects(),
'statusCodes' => $redirectRepository->findStatusCodesOfRedirects(),
'demand' => $demand,
'defaultUrl' => GeneralUtility::makeInstance(UrlService::class)->getDefaultUrl(),
'showHitCounter' => GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount'),
'pagination' => $this->preparePagination($demand, $count),
]);
} | php | protected function overviewAction(ServerRequestInterface $request)
{
$this->getButtons();
$demand = Demand::createFromRequest($request);
$redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class, $demand);
$count = $redirectRepository->countRedirectsByByDemand();
$this->view->assignMultiple([
'redirects' => $redirectRepository->findRedirectsByDemand(),
'hosts' => $redirectRepository->findHostsOfRedirects(),
'statusCodes' => $redirectRepository->findStatusCodesOfRedirects(),
'demand' => $demand,
'defaultUrl' => GeneralUtility::makeInstance(UrlService::class)->getDefaultUrl(),
'showHitCounter' => GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount'),
'pagination' => $this->preparePagination($demand, $count),
]);
} | [
"protected",
"function",
"overviewAction",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"getButtons",
"(",
")",
";",
"$",
"demand",
"=",
"Demand",
"::",
"createFromRequest",
"(",
"$",
"request",
")",
";",
"$",
"redirectRepository",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"RedirectRepository",
"::",
"class",
",",
"$",
"demand",
")",
";",
"$",
"count",
"=",
"$",
"redirectRepository",
"->",
"countRedirectsByByDemand",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"assignMultiple",
"(",
"[",
"'redirects'",
"=>",
"$",
"redirectRepository",
"->",
"findRedirectsByDemand",
"(",
")",
",",
"'hosts'",
"=>",
"$",
"redirectRepository",
"->",
"findHostsOfRedirects",
"(",
")",
",",
"'statusCodes'",
"=>",
"$",
"redirectRepository",
"->",
"findStatusCodesOfRedirects",
"(",
")",
",",
"'demand'",
"=>",
"$",
"demand",
",",
"'defaultUrl'",
"=>",
"GeneralUtility",
"::",
"makeInstance",
"(",
"UrlService",
"::",
"class",
")",
"->",
"getDefaultUrl",
"(",
")",
",",
"'showHitCounter'",
"=>",
"GeneralUtility",
"::",
"makeInstance",
"(",
"Features",
"::",
"class",
")",
"->",
"isFeatureEnabled",
"(",
"'redirects.hitCount'",
")",
",",
"'pagination'",
"=>",
"$",
"this",
"->",
"preparePagination",
"(",
"$",
"demand",
",",
"$",
"count",
")",
",",
"]",
")",
";",
"}"
] | Show all redirects, and add a button to create a new redirect
@param ServerRequestInterface $request | [
"Show",
"all",
"redirects",
"and",
"add",
"a",
"button",
"to",
"create",
"a",
"new",
"redirect"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L99-L115 |
28,607 | TYPO3-CMS/redirects | Classes/Controller/ManagementController.php | ManagementController.preparePagination | protected function preparePagination(Demand $demand, int $count): array
{
$numberOfPages = ceil($count / $demand->getLimit());
$endRecord = $demand->getOffset() + $demand->getLimit();
if ($endRecord > $count) {
$endRecord = $count;
}
$pagination = [
'current' => $demand->getPage(),
'numberOfPages' => $numberOfPages,
'hasLessPages' => $demand->getPage() > 1,
'hasMorePages' => $demand->getPage() < $numberOfPages,
'startRecord' => $demand->getOffset() + 1,
'endRecord' => $endRecord
];
if ($pagination['current'] < $pagination['numberOfPages']) {
$pagination['nextPage'] = $pagination['current'] + 1;
}
if ($pagination['current'] > 1) {
$pagination['previousPage'] = $pagination['current'] - 1;
}
return $pagination;
} | php | protected function preparePagination(Demand $demand, int $count): array
{
$numberOfPages = ceil($count / $demand->getLimit());
$endRecord = $demand->getOffset() + $demand->getLimit();
if ($endRecord > $count) {
$endRecord = $count;
}
$pagination = [
'current' => $demand->getPage(),
'numberOfPages' => $numberOfPages,
'hasLessPages' => $demand->getPage() > 1,
'hasMorePages' => $demand->getPage() < $numberOfPages,
'startRecord' => $demand->getOffset() + 1,
'endRecord' => $endRecord
];
if ($pagination['current'] < $pagination['numberOfPages']) {
$pagination['nextPage'] = $pagination['current'] + 1;
}
if ($pagination['current'] > 1) {
$pagination['previousPage'] = $pagination['current'] - 1;
}
return $pagination;
} | [
"protected",
"function",
"preparePagination",
"(",
"Demand",
"$",
"demand",
",",
"int",
"$",
"count",
")",
":",
"array",
"{",
"$",
"numberOfPages",
"=",
"ceil",
"(",
"$",
"count",
"/",
"$",
"demand",
"->",
"getLimit",
"(",
")",
")",
";",
"$",
"endRecord",
"=",
"$",
"demand",
"->",
"getOffset",
"(",
")",
"+",
"$",
"demand",
"->",
"getLimit",
"(",
")",
";",
"if",
"(",
"$",
"endRecord",
">",
"$",
"count",
")",
"{",
"$",
"endRecord",
"=",
"$",
"count",
";",
"}",
"$",
"pagination",
"=",
"[",
"'current'",
"=>",
"$",
"demand",
"->",
"getPage",
"(",
")",
",",
"'numberOfPages'",
"=>",
"$",
"numberOfPages",
",",
"'hasLessPages'",
"=>",
"$",
"demand",
"->",
"getPage",
"(",
")",
">",
"1",
",",
"'hasMorePages'",
"=>",
"$",
"demand",
"->",
"getPage",
"(",
")",
"<",
"$",
"numberOfPages",
",",
"'startRecord'",
"=>",
"$",
"demand",
"->",
"getOffset",
"(",
")",
"+",
"1",
",",
"'endRecord'",
"=>",
"$",
"endRecord",
"]",
";",
"if",
"(",
"$",
"pagination",
"[",
"'current'",
"]",
"<",
"$",
"pagination",
"[",
"'numberOfPages'",
"]",
")",
"{",
"$",
"pagination",
"[",
"'nextPage'",
"]",
"=",
"$",
"pagination",
"[",
"'current'",
"]",
"+",
"1",
";",
"}",
"if",
"(",
"$",
"pagination",
"[",
"'current'",
"]",
">",
"1",
")",
"{",
"$",
"pagination",
"[",
"'previousPage'",
"]",
"=",
"$",
"pagination",
"[",
"'current'",
"]",
"-",
"1",
";",
"}",
"return",
"$",
"pagination",
";",
"}"
] | Prepares information for the pagination of the module
@param Demand $demand
@param int $count
@return array | [
"Prepares",
"information",
"for",
"the",
"pagination",
"of",
"the",
"module"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L124-L147 |
28,608 | TYPO3-CMS/redirects | Classes/Controller/ManagementController.php | ManagementController.getButtons | protected function getButtons()
{
/** @var UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
// Create new
$newRecordButton = $buttonBar->makeLinkButton()
->setHref((string)$uriBuilder->buildUriFromRoute(
'record_edit',
[
'edit' => ['sys_redirect' => ['new'],
],
'returnUrl' => (string)$uriBuilder->buildUriFromRoute('site_redirects'),
]
))
->setTitle($this->getLanguageService()->getLL('redirect_add_text'))
->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
$buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
// Reload
$reloadButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
// Shortcut
$mayMakeShortcut = $this->getBackendUserAuthentication()->mayMakeShortcut();
if ($mayMakeShortcut) {
$getVars = ['id', 'route'];
$shortcutButton = $buttonBar->makeShortcutButton()
->setModuleName('site_redirects')
->setGetVariables($getVars);
$buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
}
} | php | protected function getButtons()
{
/** @var UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
// Create new
$newRecordButton = $buttonBar->makeLinkButton()
->setHref((string)$uriBuilder->buildUriFromRoute(
'record_edit',
[
'edit' => ['sys_redirect' => ['new'],
],
'returnUrl' => (string)$uriBuilder->buildUriFromRoute('site_redirects'),
]
))
->setTitle($this->getLanguageService()->getLL('redirect_add_text'))
->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
$buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
// Reload
$reloadButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
// Shortcut
$mayMakeShortcut = $this->getBackendUserAuthentication()->mayMakeShortcut();
if ($mayMakeShortcut) {
$getVars = ['id', 'route'];
$shortcutButton = $buttonBar->makeShortcutButton()
->setModuleName('site_redirects')
->setGetVariables($getVars);
$buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
}
} | [
"protected",
"function",
"getButtons",
"(",
")",
"{",
"/** @var UriBuilder $uriBuilder */",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"UriBuilder",
"::",
"class",
")",
";",
"$",
"buttonBar",
"=",
"$",
"this",
"->",
"moduleTemplate",
"->",
"getDocHeaderComponent",
"(",
")",
"->",
"getButtonBar",
"(",
")",
";",
"// Create new",
"$",
"newRecordButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'record_edit'",
",",
"[",
"'edit'",
"=>",
"[",
"'sys_redirect'",
"=>",
"[",
"'new'",
"]",
",",
"]",
",",
"'returnUrl'",
"=>",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'site_redirects'",
")",
",",
"]",
")",
")",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'redirect_add_text'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-add'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"newRecordButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"10",
")",
";",
"// Reload",
"$",
"reloadButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"GeneralUtility",
"::",
"getIndpEnv",
"(",
"'REQUEST_URI'",
")",
")",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-refresh'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"reloadButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_RIGHT",
")",
";",
"// Shortcut",
"$",
"mayMakeShortcut",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"mayMakeShortcut",
"(",
")",
";",
"if",
"(",
"$",
"mayMakeShortcut",
")",
"{",
"$",
"getVars",
"=",
"[",
"'id'",
",",
"'route'",
"]",
";",
"$",
"shortcutButton",
"=",
"$",
"buttonBar",
"->",
"makeShortcutButton",
"(",
")",
"->",
"setModuleName",
"(",
"'site_redirects'",
")",
"->",
"setGetVariables",
"(",
"$",
"getVars",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"shortcutButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_RIGHT",
")",
";",
"}",
"}"
] | Create document header buttons | [
"Create",
"document",
"header",
"buttons"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L164-L202 |
28,609 | rinvex/cortex-pages | src/Http/Controllers/Managerarea/PagesController.php | PagesController.import | public function import(Page $page, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $page,
'tabs' => 'managerarea.pages.tabs',
'url' => route('managerarea.pages.stash'),
'id' => "managerarea-pages-{$page->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
} | php | public function import(Page $page, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $page,
'tabs' => 'managerarea.pages.tabs',
'url' => route('managerarea.pages.stash'),
'id' => "managerarea-pages-{$page->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
} | [
"public",
"function",
"import",
"(",
"Page",
"$",
"page",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"page",
",",
"'tabs'",
"=>",
"'managerarea.pages.tabs'",
",",
"'url'",
"=>",
"route",
"(",
"'managerarea.pages.stash'",
")",
",",
"'id'",
"=>",
"\"managerarea-pages-{$page->getRouteKey()}-import-table\"",
",",
"]",
")",
"->",
"render",
"(",
"'cortex/foundation::managerarea.pages.datatable-dropzone'",
")",
";",
"}"
] | Import pages.
@param \Cortex\Pages\Models\Page $page
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View | [
"Import",
"pages",
"."
] | 7229fedb34d352fda0e721f950c55074f0fb0dce | https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Managerarea/PagesController.php#L65-L73 |
28,610 | rinvex/cortex-pages | src/Http/Controllers/Managerarea/PagesController.php | PagesController.destroy | public function destroy(Page $page)
{
$page->delete();
return intend([
'url' => route('managerarea.pages.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/pages::common.page'), 'identifier' => $page->name])],
]);
} | php | public function destroy(Page $page)
{
$page->delete();
return intend([
'url' => route('managerarea.pages.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/pages::common.page'), 'identifier' => $page->name])],
]);
} | [
"public",
"function",
"destroy",
"(",
"Page",
"$",
"page",
")",
"{",
"$",
"page",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'managerarea.pages.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/pages::common.page'",
")",
",",
"'identifier'",
"=>",
"$",
"page",
"->",
"name",
"]",
")",
"]",
",",
"]",
")",
";",
"}"
] | Destroy given page.
@param \Cortex\Pages\Models\Page $page
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"page",
"."
] | 7229fedb34d352fda0e721f950c55074f0fb0dce | https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Managerarea/PagesController.php#L217-L225 |
28,611 | mmoreram/ControllerExtraBundle | Resolver/EntityAnnotationResolver.php | EntityAnnotationResolver.evaluateMapping | private function evaluateMapping(
LoadEntity $annotation,
string $entityNamespace
) {
if (!empty($annotation->getMapping())) {
$mapping = $annotation->getMapping();
$mappingFallback = !is_null($annotation->getMappingFallback())
? $annotation->getMappingFallback()
: $this->mappingFallback;
/**
* Each value of the mapping array is computed and analyzed.
*
* If the format is something like %value%, this service will
* look for the real request attribute value
*/
foreach ($mapping as $mappingKey => $mappingValue) {
$parameterValue = $this
->providerCollector
->provide($mappingValue);
/**
* Defined field is not found in current route, and we have
* enabled the "mapping fallback" setting. In that case we
* assume that the mapping definition is wrong, and we return
* the entity itself.
*/
if ($mappingFallback && ($parameterValue === $mappingValue)) {
return null;
}
$mapping[$mappingKey] = $parameterValue;
}
$instance = $this
->resolveRepositoryLookup(
$annotation,
$entityNamespace,
$mapping
);
if (!$instance instanceof $entityNamespace) {
throw new EntityNotFoundException(
'Entity of type ' . $entityNamespace . ' with mapping ' .
json_encode($mapping) . ' was not found.'
);
}
return $instance;
}
return null;
} | php | private function evaluateMapping(
LoadEntity $annotation,
string $entityNamespace
) {
if (!empty($annotation->getMapping())) {
$mapping = $annotation->getMapping();
$mappingFallback = !is_null($annotation->getMappingFallback())
? $annotation->getMappingFallback()
: $this->mappingFallback;
/**
* Each value of the mapping array is computed and analyzed.
*
* If the format is something like %value%, this service will
* look for the real request attribute value
*/
foreach ($mapping as $mappingKey => $mappingValue) {
$parameterValue = $this
->providerCollector
->provide($mappingValue);
/**
* Defined field is not found in current route, and we have
* enabled the "mapping fallback" setting. In that case we
* assume that the mapping definition is wrong, and we return
* the entity itself.
*/
if ($mappingFallback && ($parameterValue === $mappingValue)) {
return null;
}
$mapping[$mappingKey] = $parameterValue;
}
$instance = $this
->resolveRepositoryLookup(
$annotation,
$entityNamespace,
$mapping
);
if (!$instance instanceof $entityNamespace) {
throw new EntityNotFoundException(
'Entity of type ' . $entityNamespace . ' with mapping ' .
json_encode($mapping) . ' was not found.'
);
}
return $instance;
}
return null;
} | [
"private",
"function",
"evaluateMapping",
"(",
"LoadEntity",
"$",
"annotation",
",",
"string",
"$",
"entityNamespace",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"annotation",
"->",
"getMapping",
"(",
")",
")",
")",
"{",
"$",
"mapping",
"=",
"$",
"annotation",
"->",
"getMapping",
"(",
")",
";",
"$",
"mappingFallback",
"=",
"!",
"is_null",
"(",
"$",
"annotation",
"->",
"getMappingFallback",
"(",
")",
")",
"?",
"$",
"annotation",
"->",
"getMappingFallback",
"(",
")",
":",
"$",
"this",
"->",
"mappingFallback",
";",
"/**\n * Each value of the mapping array is computed and analyzed.\n *\n * If the format is something like %value%, this service will\n * look for the real request attribute value\n */",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"mappingKey",
"=>",
"$",
"mappingValue",
")",
"{",
"$",
"parameterValue",
"=",
"$",
"this",
"->",
"providerCollector",
"->",
"provide",
"(",
"$",
"mappingValue",
")",
";",
"/**\n * Defined field is not found in current route, and we have\n * enabled the \"mapping fallback\" setting. In that case we\n * assume that the mapping definition is wrong, and we return\n * the entity itself.\n */",
"if",
"(",
"$",
"mappingFallback",
"&&",
"(",
"$",
"parameterValue",
"===",
"$",
"mappingValue",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"mapping",
"[",
"$",
"mappingKey",
"]",
"=",
"$",
"parameterValue",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"resolveRepositoryLookup",
"(",
"$",
"annotation",
",",
"$",
"entityNamespace",
",",
"$",
"mapping",
")",
";",
"if",
"(",
"!",
"$",
"instance",
"instanceof",
"$",
"entityNamespace",
")",
"{",
"throw",
"new",
"EntityNotFoundException",
"(",
"'Entity of type '",
".",
"$",
"entityNamespace",
".",
"' with mapping '",
".",
"json_encode",
"(",
"$",
"mapping",
")",
".",
"' was not found.'",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}",
"return",
"null",
";",
"}"
] | Resolve doctrine mapping and return entity given or mapped instance.
@param LoadEntity $annotation
@param string $entityNamespace
@return null|object
@throws EntityNotFoundException | [
"Resolve",
"doctrine",
"mapping",
"and",
"return",
"entity",
"given",
"or",
"mapped",
"instance",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L189-L241 |
28,612 | mmoreram/ControllerExtraBundle | Resolver/EntityAnnotationResolver.php | EntityAnnotationResolver.evaluateSetters | private function evaluateSetters(
ParameterBag $attributes,
$entity,
array $setters
) {
foreach ($setters as $method => $value) {
$entity->$method($attributes->get($value));
}
} | php | private function evaluateSetters(
ParameterBag $attributes,
$entity,
array $setters
) {
foreach ($setters as $method => $value) {
$entity->$method($attributes->get($value));
}
} | [
"private",
"function",
"evaluateSetters",
"(",
"ParameterBag",
"$",
"attributes",
",",
"$",
"entity",
",",
"array",
"$",
"setters",
")",
"{",
"foreach",
"(",
"$",
"setters",
"as",
"$",
"method",
"=>",
"$",
"value",
")",
"{",
"$",
"entity",
"->",
"$",
"method",
"(",
"$",
"attributes",
"->",
"get",
"(",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Evaluate setters.
@param ParameterBag $attributes
@param object $entity
@param array $setters | [
"Evaluate",
"setters",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L250-L258 |
28,613 | mmoreram/ControllerExtraBundle | Resolver/EntityAnnotationResolver.php | EntityAnnotationResolver.resolveRepositoryLookup | private function resolveRepositoryLookup(
LoadEntity $annotation,
string $entityClass,
array $mapping
) {
$annotationRepository = $annotation->getRepository();
$annotationHasRepository = !is_null($annotationRepository) && is_array($annotationRepository);
if ($annotationHasRepository) {
$class = $annotation->getRepository()['class'];
$repository = $this
->container
->has($class)
? $this
->container
->get($class)
: new $class();
} else {
$repository = $this
->doctrine
->getManagerForClass($entityClass)
->getRepository($entityClass);
}
$method = $annotationHasRepository && isset($annotationRepository['method'])
? $annotationRepository['method']
: 'findOneBy';
return $repository->$method($mapping);
} | php | private function resolveRepositoryLookup(
LoadEntity $annotation,
string $entityClass,
array $mapping
) {
$annotationRepository = $annotation->getRepository();
$annotationHasRepository = !is_null($annotationRepository) && is_array($annotationRepository);
if ($annotationHasRepository) {
$class = $annotation->getRepository()['class'];
$repository = $this
->container
->has($class)
? $this
->container
->get($class)
: new $class();
} else {
$repository = $this
->doctrine
->getManagerForClass($entityClass)
->getRepository($entityClass);
}
$method = $annotationHasRepository && isset($annotationRepository['method'])
? $annotationRepository['method']
: 'findOneBy';
return $repository->$method($mapping);
} | [
"private",
"function",
"resolveRepositoryLookup",
"(",
"LoadEntity",
"$",
"annotation",
",",
"string",
"$",
"entityClass",
",",
"array",
"$",
"mapping",
")",
"{",
"$",
"annotationRepository",
"=",
"$",
"annotation",
"->",
"getRepository",
"(",
")",
";",
"$",
"annotationHasRepository",
"=",
"!",
"is_null",
"(",
"$",
"annotationRepository",
")",
"&&",
"is_array",
"(",
"$",
"annotationRepository",
")",
";",
"if",
"(",
"$",
"annotationHasRepository",
")",
"{",
"$",
"class",
"=",
"$",
"annotation",
"->",
"getRepository",
"(",
")",
"[",
"'class'",
"]",
";",
"$",
"repository",
"=",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"class",
")",
"?",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"class",
")",
":",
"new",
"$",
"class",
"(",
")",
";",
"}",
"else",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"doctrine",
"->",
"getManagerForClass",
"(",
"$",
"entityClass",
")",
"->",
"getRepository",
"(",
"$",
"entityClass",
")",
";",
"}",
"$",
"method",
"=",
"$",
"annotationHasRepository",
"&&",
"isset",
"(",
"$",
"annotationRepository",
"[",
"'method'",
"]",
")",
"?",
"$",
"annotationRepository",
"[",
"'method'",
"]",
":",
"'findOneBy'",
";",
"return",
"$",
"repository",
"->",
"$",
"method",
"(",
"$",
"mapping",
")",
";",
"}"
] | Resolve repository lookup.
@param LoadEntity $annotation
@param string $entityClass
@param array $mapping
@return object|null | [
"Resolve",
"repository",
"lookup",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L269-L297 |
28,614 | mmoreram/ControllerExtraBundle | Resolver/EntityAnnotationResolver.php | EntityAnnotationResolver.resolvePersist | private function resolvePersist(LoadEntity $annotation, $entity)
{
/**
* Persist block.
*
* This block defines if entity must be persisted using desired
* manager.
*
* Given the entity we can find which manager manages it
*
* Same logic in perisist option. This variable is defined in bundle
* parameters and can be overwritten there. Can also be defined in
* every single annotation
*/
/**
* Get the persist variable. If not defined, is set as defined in
* parameters.
*/
$persist = !is_null($annotation->getPersist())
? $annotation->getPersist()
: $this->defaultPersist;
if ($persist) {
/**
* Loading locally desired Doctrine manager.
*/
$this
->doctrine
->getManagerForClass(get_class($entity))
->persist($entity);
}
} | php | private function resolvePersist(LoadEntity $annotation, $entity)
{
/**
* Persist block.
*
* This block defines if entity must be persisted using desired
* manager.
*
* Given the entity we can find which manager manages it
*
* Same logic in perisist option. This variable is defined in bundle
* parameters and can be overwritten there. Can also be defined in
* every single annotation
*/
/**
* Get the persist variable. If not defined, is set as defined in
* parameters.
*/
$persist = !is_null($annotation->getPersist())
? $annotation->getPersist()
: $this->defaultPersist;
if ($persist) {
/**
* Loading locally desired Doctrine manager.
*/
$this
->doctrine
->getManagerForClass(get_class($entity))
->persist($entity);
}
} | [
"private",
"function",
"resolvePersist",
"(",
"LoadEntity",
"$",
"annotation",
",",
"$",
"entity",
")",
"{",
"/**\n * Persist block.\n *\n * This block defines if entity must be persisted using desired\n * manager.\n *\n * Given the entity we can find which manager manages it\n *\n * Same logic in perisist option. This variable is defined in bundle\n * parameters and can be overwritten there. Can also be defined in\n * every single annotation\n */",
"/**\n * Get the persist variable. If not defined, is set as defined in\n * parameters.\n */",
"$",
"persist",
"=",
"!",
"is_null",
"(",
"$",
"annotation",
"->",
"getPersist",
"(",
")",
")",
"?",
"$",
"annotation",
"->",
"getPersist",
"(",
")",
":",
"$",
"this",
"->",
"defaultPersist",
";",
"if",
"(",
"$",
"persist",
")",
"{",
"/**\n * Loading locally desired Doctrine manager.\n */",
"$",
"this",
"->",
"doctrine",
"->",
"getManagerForClass",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"}",
"}"
] | Persist block.
This block defines if entity must be persisted using desired
manager.
This manager is defined as default in bundle parameters, but can
be overwritten in each annotation
Same logic in perisist option. This variable is defined in bundle
parameters and can be overwritten there. Can also be defined in
every single annotation
@param LoadEntity $annotation
@param object $entity | [
"Persist",
"block",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L315-L348 |
28,615 | QoboLtd/cakephp-search | src/Utility/Export.php | Export.execute | public function execute(int $page, int $limit): void
{
$page = $page <= 1 ? 1 : $page;
$rows = $this->getRows($page, $limit);
$headers = [];
$mode = 'a';
if (1 === $page) {
$headers = $this->getHeaders();
$mode = 'w';
}
// Prepend columns to result
if (!empty($headers)) {
array_unshift($rows, $headers);
}
$this->create($rows, $mode);
} | php | public function execute(int $page, int $limit): void
{
$page = $page <= 1 ? 1 : $page;
$rows = $this->getRows($page, $limit);
$headers = [];
$mode = 'a';
if (1 === $page) {
$headers = $this->getHeaders();
$mode = 'w';
}
// Prepend columns to result
if (!empty($headers)) {
array_unshift($rows, $headers);
}
$this->create($rows, $mode);
} | [
"public",
"function",
"execute",
"(",
"int",
"$",
"page",
",",
"int",
"$",
"limit",
")",
":",
"void",
"{",
"$",
"page",
"=",
"$",
"page",
"<=",
"1",
"?",
"1",
":",
"$",
"page",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"getRows",
"(",
"$",
"page",
",",
"$",
"limit",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"mode",
"=",
"'a'",
";",
"if",
"(",
"1",
"===",
"$",
"page",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHeaders",
"(",
")",
";",
"$",
"mode",
"=",
"'w'",
";",
"}",
"// Prepend columns to result",
"if",
"(",
"!",
"empty",
"(",
"$",
"headers",
")",
")",
"{",
"array_unshift",
"(",
"$",
"rows",
",",
"$",
"headers",
")",
";",
"}",
"$",
"this",
"->",
"create",
"(",
"$",
"rows",
",",
"$",
"mode",
")",
";",
"}"
] | Execute export.
@param int $page Pagination page
@param int $limit Pagination limit
@return void | [
"Execute",
"export",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L123-L141 |
28,616 | QoboLtd/cakephp-search | src/Utility/Export.php | Export.getRows | protected function getRows(int $page, int $limit): array
{
$displayColumns = $this->getDisplayColumns();
if (empty($displayColumns)) {
return [];
}
$query = $this->query->page($page, $limit);
$entities = $query->all();
if ($entities->isEmpty()) {
return [];
}
$table = TableRegistry::get($this->search->get('model'));
$event = new Event((string)EventName::MODEL_SEARCH_AFTER_FIND(), $this, [
'entities' => $entities,
'table' => $table
]);
EventManager::instance()->dispatch($event);
if ($event->result) {
$entities = $event->result;
}
$displayColumns = array_map('strval', $displayColumns);
$entities = $entities ? Utility::instance()->toCsv($entities, $displayColumns, $table) : [];
if (empty($entities)) {
return [];
}
$result = [];
foreach ($entities as $k => $entity) {
$result[$k] = [];
foreach ($displayColumns as $column) {
$value = trim(strip_tags(html_entity_decode($entity[$column], ENT_QUOTES)), " \t\n\r\0\x0B\xC2\xA0");
$result[$k][] = $value;
}
}
return $result;
} | php | protected function getRows(int $page, int $limit): array
{
$displayColumns = $this->getDisplayColumns();
if (empty($displayColumns)) {
return [];
}
$query = $this->query->page($page, $limit);
$entities = $query->all();
if ($entities->isEmpty()) {
return [];
}
$table = TableRegistry::get($this->search->get('model'));
$event = new Event((string)EventName::MODEL_SEARCH_AFTER_FIND(), $this, [
'entities' => $entities,
'table' => $table
]);
EventManager::instance()->dispatch($event);
if ($event->result) {
$entities = $event->result;
}
$displayColumns = array_map('strval', $displayColumns);
$entities = $entities ? Utility::instance()->toCsv($entities, $displayColumns, $table) : [];
if (empty($entities)) {
return [];
}
$result = [];
foreach ($entities as $k => $entity) {
$result[$k] = [];
foreach ($displayColumns as $column) {
$value = trim(strip_tags(html_entity_decode($entity[$column], ENT_QUOTES)), " \t\n\r\0\x0B\xC2\xA0");
$result[$k][] = $value;
}
}
return $result;
} | [
"protected",
"function",
"getRows",
"(",
"int",
"$",
"page",
",",
"int",
"$",
"limit",
")",
":",
"array",
"{",
"$",
"displayColumns",
"=",
"$",
"this",
"->",
"getDisplayColumns",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"displayColumns",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"query",
"->",
"page",
"(",
"$",
"page",
",",
"$",
"limit",
")",
";",
"$",
"entities",
"=",
"$",
"query",
"->",
"all",
"(",
")",
";",
"if",
"(",
"$",
"entities",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"table",
"=",
"TableRegistry",
"::",
"get",
"(",
"$",
"this",
"->",
"search",
"->",
"get",
"(",
"'model'",
")",
")",
";",
"$",
"event",
"=",
"new",
"Event",
"(",
"(",
"string",
")",
"EventName",
"::",
"MODEL_SEARCH_AFTER_FIND",
"(",
")",
",",
"$",
"this",
",",
"[",
"'entities'",
"=>",
"$",
"entities",
",",
"'table'",
"=>",
"$",
"table",
"]",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"result",
")",
"{",
"$",
"entities",
"=",
"$",
"event",
"->",
"result",
";",
"}",
"$",
"displayColumns",
"=",
"array_map",
"(",
"'strval'",
",",
"$",
"displayColumns",
")",
";",
"$",
"entities",
"=",
"$",
"entities",
"?",
"Utility",
"::",
"instance",
"(",
")",
"->",
"toCsv",
"(",
"$",
"entities",
",",
"$",
"displayColumns",
",",
"$",
"table",
")",
":",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"entities",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"k",
"=>",
"$",
"entity",
")",
"{",
"$",
"result",
"[",
"$",
"k",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"displayColumns",
"as",
"$",
"column",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"strip_tags",
"(",
"html_entity_decode",
"(",
"$",
"entity",
"[",
"$",
"column",
"]",
",",
"ENT_QUOTES",
")",
")",
",",
"\" \\t\\n\\r\\0\\x0B\\xC2\\xA0\"",
")",
";",
"$",
"result",
"[",
"$",
"k",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get export rows.
@param int $page Pagination page
@param int $limit Pagination limit
@return mixed[] | [
"Get",
"export",
"rows",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L160-L201 |
28,617 | QoboLtd/cakephp-search | src/Utility/Export.php | Export.getHeaders | protected function getHeaders(): array
{
$displayColumns = $this->getDisplayColumns();
if (empty($displayColumns)) {
return [];
}
$table = TableRegistry::get($this->search->get('model'));
$associationLabels = Utility::instance()->getAssociationLabels($table);
$searchableFields = Utility::instance()->getSearchableFields($table, $this->user);
$result = [];
foreach ($displayColumns as $column) {
$label = $column;
if (array_key_exists($label, $searchableFields)) {
$label = $searchableFields[$label]['label'];
}
list($fieldModel, ) = pluginSplit($column);
if (array_key_exists($fieldModel, $associationLabels)) {
$label .= ' (' . $associationLabels[$fieldModel] . ')';
}
$result[] = $label;
}
return $result;
} | php | protected function getHeaders(): array
{
$displayColumns = $this->getDisplayColumns();
if (empty($displayColumns)) {
return [];
}
$table = TableRegistry::get($this->search->get('model'));
$associationLabels = Utility::instance()->getAssociationLabels($table);
$searchableFields = Utility::instance()->getSearchableFields($table, $this->user);
$result = [];
foreach ($displayColumns as $column) {
$label = $column;
if (array_key_exists($label, $searchableFields)) {
$label = $searchableFields[$label]['label'];
}
list($fieldModel, ) = pluginSplit($column);
if (array_key_exists($fieldModel, $associationLabels)) {
$label .= ' (' . $associationLabels[$fieldModel] . ')';
}
$result[] = $label;
}
return $result;
} | [
"protected",
"function",
"getHeaders",
"(",
")",
":",
"array",
"{",
"$",
"displayColumns",
"=",
"$",
"this",
"->",
"getDisplayColumns",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"displayColumns",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"table",
"=",
"TableRegistry",
"::",
"get",
"(",
"$",
"this",
"->",
"search",
"->",
"get",
"(",
"'model'",
")",
")",
";",
"$",
"associationLabels",
"=",
"Utility",
"::",
"instance",
"(",
")",
"->",
"getAssociationLabels",
"(",
"$",
"table",
")",
";",
"$",
"searchableFields",
"=",
"Utility",
"::",
"instance",
"(",
")",
"->",
"getSearchableFields",
"(",
"$",
"table",
",",
"$",
"this",
"->",
"user",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"displayColumns",
"as",
"$",
"column",
")",
"{",
"$",
"label",
"=",
"$",
"column",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"label",
",",
"$",
"searchableFields",
")",
")",
"{",
"$",
"label",
"=",
"$",
"searchableFields",
"[",
"$",
"label",
"]",
"[",
"'label'",
"]",
";",
"}",
"list",
"(",
"$",
"fieldModel",
",",
")",
"=",
"pluginSplit",
"(",
"$",
"column",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"fieldModel",
",",
"$",
"associationLabels",
")",
")",
"{",
"$",
"label",
".=",
"' ('",
".",
"$",
"associationLabels",
"[",
"$",
"fieldModel",
"]",
".",
"')'",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"label",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get export headers.
@return mixed[] | [
"Get",
"export",
"headers",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L208-L237 |
28,618 | QoboLtd/cakephp-search | src/Utility/Export.php | Export.create | protected function create(array $data, string $mode = 'a'): void
{
// create file path
$file = new File($this->path, true);
// skip if file is not writable
if (! $file->writable()) {
$this->log(sprintf('Export file is not writable: %s', $file->pwd()), LogLevel::ERROR);
return;
}
/**
* @var resource
*/
$handler = fopen($file->pwd(), $mode);
if (! is_resource($handler)) {
$this->log(sprintf('Export interrupted: failed to bind resource to a stream'), LogLevel::ERROR);
}
foreach ($data as $row) {
if (false === fputcsv($handler, $row)) {
$this->log(sprintf('Export interrupted: failed to write data into the file'), LogLevel::ERROR);
return;
}
}
fclose($handler);
} | php | protected function create(array $data, string $mode = 'a'): void
{
// create file path
$file = new File($this->path, true);
// skip if file is not writable
if (! $file->writable()) {
$this->log(sprintf('Export file is not writable: %s', $file->pwd()), LogLevel::ERROR);
return;
}
/**
* @var resource
*/
$handler = fopen($file->pwd(), $mode);
if (! is_resource($handler)) {
$this->log(sprintf('Export interrupted: failed to bind resource to a stream'), LogLevel::ERROR);
}
foreach ($data as $row) {
if (false === fputcsv($handler, $row)) {
$this->log(sprintf('Export interrupted: failed to write data into the file'), LogLevel::ERROR);
return;
}
}
fclose($handler);
} | [
"protected",
"function",
"create",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"mode",
"=",
"'a'",
")",
":",
"void",
"{",
"// create file path",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"this",
"->",
"path",
",",
"true",
")",
";",
"// skip if file is not writable",
"if",
"(",
"!",
"$",
"file",
"->",
"writable",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Export file is not writable: %s'",
",",
"$",
"file",
"->",
"pwd",
"(",
")",
")",
",",
"LogLevel",
"::",
"ERROR",
")",
";",
"return",
";",
"}",
"/**\n * @var resource\n */",
"$",
"handler",
"=",
"fopen",
"(",
"$",
"file",
"->",
"pwd",
"(",
")",
",",
"$",
"mode",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"handler",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Export interrupted: failed to bind resource to a stream'",
")",
",",
"LogLevel",
"::",
"ERROR",
")",
";",
"}",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"false",
"===",
"fputcsv",
"(",
"$",
"handler",
",",
"$",
"row",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Export interrupted: failed to write data into the file'",
")",
",",
"LogLevel",
"::",
"ERROR",
")",
";",
"return",
";",
"}",
"}",
"fclose",
"(",
"$",
"handler",
")",
";",
"}"
] | Create export file.
@param mixed[] $data CSV data
@param string $mode File mode
@return void | [
"Create",
"export",
"file",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L271-L300 |
28,619 | mmoreram/ControllerExtraBundle | Provider/EntityProvider.php | EntityProvider.create | public function create(AnnotationWithEntityReference $annotation)
{
return null !== $annotation->getFactory()
? $this->evaluateEntityInstanceFactory($annotation->getFactory())
: $this->evaluateEntityInstanceNamespace($annotation->getNamespace());
} | php | public function create(AnnotationWithEntityReference $annotation)
{
return null !== $annotation->getFactory()
? $this->evaluateEntityInstanceFactory($annotation->getFactory())
: $this->evaluateEntityInstanceNamespace($annotation->getNamespace());
} | [
"public",
"function",
"create",
"(",
"AnnotationWithEntityReference",
"$",
"annotation",
")",
"{",
"return",
"null",
"!==",
"$",
"annotation",
"->",
"getFactory",
"(",
")",
"?",
"$",
"this",
"->",
"evaluateEntityInstanceFactory",
"(",
"$",
"annotation",
"->",
"getFactory",
"(",
")",
")",
":",
"$",
"this",
"->",
"evaluateEntityInstanceNamespace",
"(",
"$",
"annotation",
"->",
"getNamespace",
"(",
")",
")",
";",
"}"
] | Class provider, given several formats.
Accepted formats:
class = "my.class.parameter",
class = "\My\Class\Namespace",
class = "MmoreramCustomBundle:User",
factory = {
"factory": "Mmoreram\ControllerExtraBundle\Factory\EntityFactory",
"factory": "my_factory_service",
"method": "create",
"static": true
}
@param AnnotationWithEntityReference $annotation
@return object|null | [
"Class",
"provider",
"given",
"several",
"formats",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/EntityProvider.php#L101-L106 |
28,620 | mmoreram/ControllerExtraBundle | Provider/EntityProvider.php | EntityProvider.evaluateEntityInstanceFactory | public function evaluateEntityInstanceFactory(array $factory)
{
if (!isset($factory['class'])) {
throw new InvalidArgumentException();
}
$factoryReference = $factory['class'];
$factoryMethod = isset($factory['method'])
? $factory['method']
: $this->defaultFactoryMethod;
$factoryStatic = isset($factory['static'])
? (bool) $factory['static']
: (bool) $this->defaultFactoryStatic;
$factory = class_exists($factoryReference)
? (
$factoryStatic
? $factoryReference
: new $factoryReference()
)
: $this
->container
->get($factoryReference);
return $factoryStatic
? $factory::$factoryMethod()
: $factory->$factoryMethod();
} | php | public function evaluateEntityInstanceFactory(array $factory)
{
if (!isset($factory['class'])) {
throw new InvalidArgumentException();
}
$factoryReference = $factory['class'];
$factoryMethod = isset($factory['method'])
? $factory['method']
: $this->defaultFactoryMethod;
$factoryStatic = isset($factory['static'])
? (bool) $factory['static']
: (bool) $this->defaultFactoryStatic;
$factory = class_exists($factoryReference)
? (
$factoryStatic
? $factoryReference
: new $factoryReference()
)
: $this
->container
->get($factoryReference);
return $factoryStatic
? $factory::$factoryMethod()
: $factory->$factoryMethod();
} | [
"public",
"function",
"evaluateEntityInstanceFactory",
"(",
"array",
"$",
"factory",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"factory",
"[",
"'class'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
")",
";",
"}",
"$",
"factoryReference",
"=",
"$",
"factory",
"[",
"'class'",
"]",
";",
"$",
"factoryMethod",
"=",
"isset",
"(",
"$",
"factory",
"[",
"'method'",
"]",
")",
"?",
"$",
"factory",
"[",
"'method'",
"]",
":",
"$",
"this",
"->",
"defaultFactoryMethod",
";",
"$",
"factoryStatic",
"=",
"isset",
"(",
"$",
"factory",
"[",
"'static'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"factory",
"[",
"'static'",
"]",
":",
"(",
"bool",
")",
"$",
"this",
"->",
"defaultFactoryStatic",
";",
"$",
"factory",
"=",
"class_exists",
"(",
"$",
"factoryReference",
")",
"?",
"(",
"$",
"factoryStatic",
"?",
"$",
"factoryReference",
":",
"new",
"$",
"factoryReference",
"(",
")",
")",
":",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"factoryReference",
")",
";",
"return",
"$",
"factoryStatic",
"?",
"$",
"factory",
"::",
"$",
"factoryMethod",
"(",
")",
":",
"$",
"factory",
"->",
"$",
"factoryMethod",
"(",
")",
";",
"}"
] | Evaluates entity instance using a factory.
@param array $factory
@return object Entity instance
@throws InvalidArgumentException if the service is not defined
@throws ServiceCircularReferenceException When a circular reference is detected
@throws ServiceNotFoundException When the service is not found | [
"Evaluates",
"entity",
"instance",
"using",
"a",
"factory",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/EntityProvider.php#L119-L148 |
28,621 | mmoreram/ControllerExtraBundle | Provider/EntityProvider.php | EntityProvider.evaluateEntityNamespace | public function evaluateEntityNamespace(string $namespace)
{
/**
* Trying to generate new entity given that the class is the entity
* namespace.
*/
if (class_exists($namespace)) {
return $namespace;
}
/**
* Trying to generate new entity given that the namespace is defined in
* as a Container parameter.
*/
$container = $this->container;
if (
$container->hasParameter($namespace) &&
class_exists($container->getParameter($namespace))
) {
$namespaceParameter = $container->getParameter($namespace);
return $namespaceParameter;
}
$resolvedNamespace = explode(':', $namespace, 2);
$bundles = $this->kernel->getBundles();
/**
* Trying to get entity using Doctrine short format.
*
* MyBundle:MyEntity
*
* To accept this format, entities must be at Entity/ folder in the
* bundle root dir
*
* /MyBundle/Entity/MyEntity
*
* If entity definition is wrong, throw exception
* If bundle not exists or is not actived, throw Exception
*/
if (
!(
isset($resolvedNamespace[0]) &&
isset($bundles[$resolvedNamespace[0]]) &&
$bundles[$resolvedNamespace[0]] instanceof Bundle &&
isset($resolvedNamespace[1])
)
) {
throw new ClassNotFoundException(
$namespace,
new ErrorException()
);
}
/**
* @var Bundle $bundle
*/
$bundle = $bundles[$resolvedNamespace[0]];
$bundleNamespace = $bundle->getNamespace();
$namespace = $bundleNamespace . '\\Entity\\' . $resolvedNamespace[1];
if (!class_exists($namespace)) {
throw new ClassNotFoundException(
$namespace,
new ErrorException()
);
}
/**
* Otherwise, assume that class is namespace of class.
*/
return $namespace;
} | php | public function evaluateEntityNamespace(string $namespace)
{
/**
* Trying to generate new entity given that the class is the entity
* namespace.
*/
if (class_exists($namespace)) {
return $namespace;
}
/**
* Trying to generate new entity given that the namespace is defined in
* as a Container parameter.
*/
$container = $this->container;
if (
$container->hasParameter($namespace) &&
class_exists($container->getParameter($namespace))
) {
$namespaceParameter = $container->getParameter($namespace);
return $namespaceParameter;
}
$resolvedNamespace = explode(':', $namespace, 2);
$bundles = $this->kernel->getBundles();
/**
* Trying to get entity using Doctrine short format.
*
* MyBundle:MyEntity
*
* To accept this format, entities must be at Entity/ folder in the
* bundle root dir
*
* /MyBundle/Entity/MyEntity
*
* If entity definition is wrong, throw exception
* If bundle not exists or is not actived, throw Exception
*/
if (
!(
isset($resolvedNamespace[0]) &&
isset($bundles[$resolvedNamespace[0]]) &&
$bundles[$resolvedNamespace[0]] instanceof Bundle &&
isset($resolvedNamespace[1])
)
) {
throw new ClassNotFoundException(
$namespace,
new ErrorException()
);
}
/**
* @var Bundle $bundle
*/
$bundle = $bundles[$resolvedNamespace[0]];
$bundleNamespace = $bundle->getNamespace();
$namespace = $bundleNamespace . '\\Entity\\' . $resolvedNamespace[1];
if (!class_exists($namespace)) {
throw new ClassNotFoundException(
$namespace,
new ErrorException()
);
}
/**
* Otherwise, assume that class is namespace of class.
*/
return $namespace;
} | [
"public",
"function",
"evaluateEntityNamespace",
"(",
"string",
"$",
"namespace",
")",
"{",
"/**\n * Trying to generate new entity given that the class is the entity\n * namespace.\n */",
"if",
"(",
"class_exists",
"(",
"$",
"namespace",
")",
")",
"{",
"return",
"$",
"namespace",
";",
"}",
"/**\n * Trying to generate new entity given that the namespace is defined in\n * as a Container parameter.\n */",
"$",
"container",
"=",
"$",
"this",
"->",
"container",
";",
"if",
"(",
"$",
"container",
"->",
"hasParameter",
"(",
"$",
"namespace",
")",
"&&",
"class_exists",
"(",
"$",
"container",
"->",
"getParameter",
"(",
"$",
"namespace",
")",
")",
")",
"{",
"$",
"namespaceParameter",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"$",
"namespace",
")",
";",
"return",
"$",
"namespaceParameter",
";",
"}",
"$",
"resolvedNamespace",
"=",
"explode",
"(",
"':'",
",",
"$",
"namespace",
",",
"2",
")",
";",
"$",
"bundles",
"=",
"$",
"this",
"->",
"kernel",
"->",
"getBundles",
"(",
")",
";",
"/**\n * Trying to get entity using Doctrine short format.\n *\n * MyBundle:MyEntity\n *\n * To accept this format, entities must be at Entity/ folder in the\n * bundle root dir\n *\n * /MyBundle/Entity/MyEntity\n *\n * If entity definition is wrong, throw exception\n * If bundle not exists or is not actived, throw Exception\n */",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"resolvedNamespace",
"[",
"0",
"]",
")",
"&&",
"isset",
"(",
"$",
"bundles",
"[",
"$",
"resolvedNamespace",
"[",
"0",
"]",
"]",
")",
"&&",
"$",
"bundles",
"[",
"$",
"resolvedNamespace",
"[",
"0",
"]",
"]",
"instanceof",
"Bundle",
"&&",
"isset",
"(",
"$",
"resolvedNamespace",
"[",
"1",
"]",
")",
")",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"$",
"namespace",
",",
"new",
"ErrorException",
"(",
")",
")",
";",
"}",
"/**\n * @var Bundle $bundle\n */",
"$",
"bundle",
"=",
"$",
"bundles",
"[",
"$",
"resolvedNamespace",
"[",
"0",
"]",
"]",
";",
"$",
"bundleNamespace",
"=",
"$",
"bundle",
"->",
"getNamespace",
"(",
")",
";",
"$",
"namespace",
"=",
"$",
"bundleNamespace",
".",
"'\\\\Entity\\\\'",
".",
"$",
"resolvedNamespace",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"namespace",
")",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"$",
"namespace",
",",
"new",
"ErrorException",
"(",
")",
")",
";",
"}",
"/**\n * Otherwise, assume that class is namespace of class.\n */",
"return",
"$",
"namespace",
";",
"}"
] | Evaluates entity instance using the namespace.
@param string $namespace
@return string
@throws ClassNotFoundException if class is not found | [
"Evaluates",
"entity",
"instance",
"using",
"the",
"namespace",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/EntityProvider.php#L175-L248 |
28,622 | hiqdev/hipanel-module-finance | src/cart/AbstractPurchase.php | AbstractPurchase.execute | public function execute()
{
if ($this->validate()) {
$this->_result = static::perform(static::operation(), $this->getAttributes());
return true;
}
return false;
} | php | public function execute()
{
if ($this->validate()) {
$this->_result = static::perform(static::operation(), $this->getAttributes());
return true;
}
return false;
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_result",
"=",
"static",
"::",
"perform",
"(",
"static",
"::",
"operation",
"(",
")",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Executes the purchase.
Calls proper API commands to purchase the product.
@throws ErrorPurchaseException in case of failed purchase
@return true if the item was purchased successfully | [
"Executes",
"the",
"purchase",
".",
"Calls",
"proper",
"API",
"commands",
"to",
"purchase",
"the",
"product",
"."
] | fa027420ddc1d6de22a6d830e14dde587c837220 | https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/cart/AbstractPurchase.php#L76-L85 |
28,623 | TYPO3-CMS/redirects | Classes/Evaluation/SourceHost.php | SourceHost.evaluateFieldValue | public function evaluateFieldValue(string $value): string
{
// 1) Special case: * means any domain
if ($value === '*') {
return $value;
}
// 2) Check if value contains a protocol like http:// https:// etc...
if (strpos($value, '://') !== false) {
$tmp = $this->parseUrl($value);
if (!empty($tmp)) {
return $tmp;
}
}
// 3) Check domain name
// remove anything after the first "/"
$checkValue = $value;
if (strpos($value, '/') !== false) {
$checkValue = substr($value, 0, strpos($value, '/'));
}
$validHostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/';
if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) {
if (!empty($matches)) {
return $checkValue;
}
}
// 4) IPv4 or IPv6
$isIP = filter_var($value, FILTER_VALIDATE_IP) === $value;
if ($isIP) {
return $value;
}
return '';
} | php | public function evaluateFieldValue(string $value): string
{
// 1) Special case: * means any domain
if ($value === '*') {
return $value;
}
// 2) Check if value contains a protocol like http:// https:// etc...
if (strpos($value, '://') !== false) {
$tmp = $this->parseUrl($value);
if (!empty($tmp)) {
return $tmp;
}
}
// 3) Check domain name
// remove anything after the first "/"
$checkValue = $value;
if (strpos($value, '/') !== false) {
$checkValue = substr($value, 0, strpos($value, '/'));
}
$validHostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/';
if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) {
if (!empty($matches)) {
return $checkValue;
}
}
// 4) IPv4 or IPv6
$isIP = filter_var($value, FILTER_VALIDATE_IP) === $value;
if ($isIP) {
return $value;
}
return '';
} | [
"public",
"function",
"evaluateFieldValue",
"(",
"string",
"$",
"value",
")",
":",
"string",
"{",
"// 1) Special case: * means any domain",
"if",
"(",
"$",
"value",
"===",
"'*'",
")",
"{",
"return",
"$",
"value",
";",
"}",
"// 2) Check if value contains a protocol like http:// https:// etc...",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'://'",
")",
"!==",
"false",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"parseUrl",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tmp",
")",
")",
"{",
"return",
"$",
"tmp",
";",
"}",
"}",
"// 3) Check domain name",
"// remove anything after the first \"/\"",
"$",
"checkValue",
"=",
"$",
"value",
";",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"$",
"checkValue",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"strpos",
"(",
"$",
"value",
",",
"'/'",
")",
")",
";",
"}",
"$",
"validHostnameRegex",
"=",
"'/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$/'",
";",
"if",
"(",
"preg_match_all",
"(",
"$",
"validHostnameRegex",
",",
"$",
"checkValue",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"checkValue",
";",
"}",
"}",
"// 4) IPv4 or IPv6",
"$",
"isIP",
"=",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_IP",
")",
"===",
"$",
"value",
";",
"if",
"(",
"$",
"isIP",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"''",
";",
"}"
] | Server-side removing of protocol on save
@param string $value The field value to be evaluated
@return string Evaluated field value | [
"Server",
"-",
"side",
"removing",
"of",
"protocol",
"on",
"save"
] | c617ec21dac92873bf9890fa0bfc1576afc86b5a | https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Evaluation/SourceHost.php#L47-L82 |
28,624 | mmoreram/ControllerExtraBundle | Resolver/JsonResponseAnnotationResolver.php | JsonResponseAnnotationResolver.createJsonResponseIfNeeded | private function createJsonResponseIfNeeded(
GetResponseEvent $event,
$result
) {
/**
* Only flushes if exists AnnotationFlush as a controller annotations.
*/
if ($this->returnJson) {
if ($result instanceof Exception) {
$this->status = $result instanceof HttpExceptionInterface
? $result->getStatusCode()
: $this->defaultErrorStatus;
$result = [
'code' => $result->getCode(),
'namespace' => get_class($result),
'message' => $result->getMessage(),
];
}
$response = JsonResponse::create(
$result,
$this->status,
$this->headers
);
$event->setResponse($response);
}
} | php | private function createJsonResponseIfNeeded(
GetResponseEvent $event,
$result
) {
/**
* Only flushes if exists AnnotationFlush as a controller annotations.
*/
if ($this->returnJson) {
if ($result instanceof Exception) {
$this->status = $result instanceof HttpExceptionInterface
? $result->getStatusCode()
: $this->defaultErrorStatus;
$result = [
'code' => $result->getCode(),
'namespace' => get_class($result),
'message' => $result->getMessage(),
];
}
$response = JsonResponse::create(
$result,
$this->status,
$this->headers
);
$event->setResponse($response);
}
} | [
"private",
"function",
"createJsonResponseIfNeeded",
"(",
"GetResponseEvent",
"$",
"event",
",",
"$",
"result",
")",
"{",
"/**\n * Only flushes if exists AnnotationFlush as a controller annotations.\n */",
"if",
"(",
"$",
"this",
"->",
"returnJson",
")",
"{",
"if",
"(",
"$",
"result",
"instanceof",
"Exception",
")",
"{",
"$",
"this",
"->",
"status",
"=",
"$",
"result",
"instanceof",
"HttpExceptionInterface",
"?",
"$",
"result",
"->",
"getStatusCode",
"(",
")",
":",
"$",
"this",
"->",
"defaultErrorStatus",
";",
"$",
"result",
"=",
"[",
"'code'",
"=>",
"$",
"result",
"->",
"getCode",
"(",
")",
",",
"'namespace'",
"=>",
"get_class",
"(",
"$",
"result",
")",
",",
"'message'",
"=>",
"$",
"result",
"->",
"getMessage",
"(",
")",
",",
"]",
";",
"}",
"$",
"response",
"=",
"JsonResponse",
"::",
"create",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"status",
",",
"$",
"this",
"->",
"headers",
")",
";",
"$",
"event",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"}",
"}"
] | Create new Json Response if needed.
@param GetResponseEvent $event
@param mixed $result | [
"Create",
"new",
"Json",
"Response",
"if",
"needed",
"."
] | b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3 | https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/JsonResponseAnnotationResolver.php#L154-L182 |
28,625 | MetaModels/filter_perimetersearch | src/EventListener/DcGeneral/Table/FilterSetting/Base.php | Base.isAllowedProperty | protected function isAllowedProperty($event, $dataDefinitionName, $properties)
{
if ($event->getEnvironment()->getDataDefinition()->getName() !== $dataDefinitionName) {
return false;
}
if (!\in_array($event->getPropertyName(), $properties)) {
return false;
}
return true;
} | php | protected function isAllowedProperty($event, $dataDefinitionName, $properties)
{
if ($event->getEnvironment()->getDataDefinition()->getName() !== $dataDefinitionName) {
return false;
}
if (!\in_array($event->getPropertyName(), $properties)) {
return false;
}
return true;
} | [
"protected",
"function",
"isAllowedProperty",
"(",
"$",
"event",
",",
"$",
"dataDefinitionName",
",",
"$",
"properties",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getEnvironment",
"(",
")",
"->",
"getDataDefinition",
"(",
")",
"->",
"getName",
"(",
")",
"!==",
"$",
"dataDefinitionName",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"event",
"->",
"getPropertyName",
"(",
")",
",",
"$",
"properties",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check if the current context is valid.
@param GetPropertyOptionsEvent|GetOptionsEvent $event The event.
@param string $dataDefinitionName The allowed name of the data definition.
@param array $properties A list of allowed properties.
@return bool | [
"Check",
"if",
"the",
"current",
"context",
"is",
"valid",
"."
] | 953d55881a1855972c5f47a7552863986702163c | https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/EventListener/DcGeneral/Table/FilterSetting/Base.php#L59-L70 |
28,626 | QoboLtd/cakephp-search | src/Utility/Options.php | Options.getDefaults | public static function getDefaults(RepositoryInterface $table): array
{
$result['display_columns'] = static::getListingFields($table);
$result['sort_by_field'] = current($result['display_columns']);
$result['sort_by_order'] = static::DEFAULT_SORT_BY_ORDER;
$result['aggregator'] = static::DEFAULT_AGGREGATOR;
return $result;
} | php | public static function getDefaults(RepositoryInterface $table): array
{
$result['display_columns'] = static::getListingFields($table);
$result['sort_by_field'] = current($result['display_columns']);
$result['sort_by_order'] = static::DEFAULT_SORT_BY_ORDER;
$result['aggregator'] = static::DEFAULT_AGGREGATOR;
return $result;
} | [
"public",
"static",
"function",
"getDefaults",
"(",
"RepositoryInterface",
"$",
"table",
")",
":",
"array",
"{",
"$",
"result",
"[",
"'display_columns'",
"]",
"=",
"static",
"::",
"getListingFields",
"(",
"$",
"table",
")",
";",
"$",
"result",
"[",
"'sort_by_field'",
"]",
"=",
"current",
"(",
"$",
"result",
"[",
"'display_columns'",
"]",
")",
";",
"$",
"result",
"[",
"'sort_by_order'",
"]",
"=",
"static",
"::",
"DEFAULT_SORT_BY_ORDER",
";",
"$",
"result",
"[",
"'aggregator'",
"]",
"=",
"static",
"::",
"DEFAULT_AGGREGATOR",
";",
"return",
"$",
"result",
";",
"}"
] | Default search options.
@param \Cake\Datasource\RepositoryInterface $table Table instance
@return mixed[] | [
"Default",
"search",
"options",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Options.php#L146-L154 |
28,627 | QoboLtd/cakephp-search | src/Utility/Options.php | Options.getListingFields | public static function getListingFields(RepositoryInterface $table): array
{
// broadcast event to fetch display fields
$event = new Event((string)EventName::MODEL_SEARCH_DISPLAY_FIELDS(), null, [
'table' => $table
]);
EventManager::instance()->dispatch($event);
$result = (array)$event->result;
if (empty($result)) {
$result = static::getDefaultDisplayFields($table);
}
$result = array_diff($result, static::getSkippedDisplayFields($table, true));
// reset numeric indexes
return array_values($result);
} | php | public static function getListingFields(RepositoryInterface $table): array
{
// broadcast event to fetch display fields
$event = new Event((string)EventName::MODEL_SEARCH_DISPLAY_FIELDS(), null, [
'table' => $table
]);
EventManager::instance()->dispatch($event);
$result = (array)$event->result;
if (empty($result)) {
$result = static::getDefaultDisplayFields($table);
}
$result = array_diff($result, static::getSkippedDisplayFields($table, true));
// reset numeric indexes
return array_values($result);
} | [
"public",
"static",
"function",
"getListingFields",
"(",
"RepositoryInterface",
"$",
"table",
")",
":",
"array",
"{",
"// broadcast event to fetch display fields",
"$",
"event",
"=",
"new",
"Event",
"(",
"(",
"string",
")",
"EventName",
"::",
"MODEL_SEARCH_DISPLAY_FIELDS",
"(",
")",
",",
"null",
",",
"[",
"'table'",
"=>",
"$",
"table",
"]",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"result",
"=",
"(",
"array",
")",
"$",
"event",
"->",
"result",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"static",
"::",
"getDefaultDisplayFields",
"(",
"$",
"table",
")",
";",
"}",
"$",
"result",
"=",
"array_diff",
"(",
"$",
"result",
",",
"static",
"::",
"getSkippedDisplayFields",
"(",
"$",
"table",
",",
"true",
")",
")",
";",
"// reset numeric indexes",
"return",
"array_values",
"(",
"$",
"result",
")",
";",
"}"
] | Current table display fields getter.
@param \Cake\Datasource\RepositoryInterface $table Table instance
@return mixed[] | [
"Current",
"table",
"display",
"fields",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Options.php#L162-L180 |
28,628 | QoboLtd/cakephp-search | src/Utility/Options.php | Options.getDefaultDisplayFields | protected static function getDefaultDisplayFields(RepositoryInterface $table): array
{
/** @var \Cake\ORM\Table */
$table = $table;
$result = (array)$table->getPrimaryKey();
array_push($result, $table->getDisplayField());
$result = array_merge($result, static::$defaultDisplayFields);
// remove virtual fields
foreach ($result as $k => $field) {
if (!$table->hasField($field)) {
unset($result[$k]);
}
}
// alias fields
foreach ($result as $k => $field) {
$result[$k] = $table->aliasField($field);
}
return $result;
} | php | protected static function getDefaultDisplayFields(RepositoryInterface $table): array
{
/** @var \Cake\ORM\Table */
$table = $table;
$result = (array)$table->getPrimaryKey();
array_push($result, $table->getDisplayField());
$result = array_merge($result, static::$defaultDisplayFields);
// remove virtual fields
foreach ($result as $k => $field) {
if (!$table->hasField($field)) {
unset($result[$k]);
}
}
// alias fields
foreach ($result as $k => $field) {
$result[$k] = $table->aliasField($field);
}
return $result;
} | [
"protected",
"static",
"function",
"getDefaultDisplayFields",
"(",
"RepositoryInterface",
"$",
"table",
")",
":",
"array",
"{",
"/** @var \\Cake\\ORM\\Table */",
"$",
"table",
"=",
"$",
"table",
";",
"$",
"result",
"=",
"(",
"array",
")",
"$",
"table",
"->",
"getPrimaryKey",
"(",
")",
";",
"array_push",
"(",
"$",
"result",
",",
"$",
"table",
"->",
"getDisplayField",
"(",
")",
")",
";",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"static",
"::",
"$",
"defaultDisplayFields",
")",
";",
"// remove virtual fields",
"foreach",
"(",
"$",
"result",
"as",
"$",
"k",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"$",
"table",
"->",
"hasField",
"(",
"$",
"field",
")",
")",
"{",
"unset",
"(",
"$",
"result",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"// alias fields",
"foreach",
"(",
"$",
"result",
"as",
"$",
"k",
"=>",
"$",
"field",
")",
"{",
"$",
"result",
"[",
"$",
"k",
"]",
"=",
"$",
"table",
"->",
"aliasField",
"(",
"$",
"field",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Default display fields getter.
@param \Cake\Datasource\RepositoryInterface $table Table instance
@return mixed[] | [
"Default",
"display",
"fields",
"getter",
"."
] | 095a0e822781ac11eade0c03c7729b693daa1ba8 | https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Options.php#L188-L211 |
28,629 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.icon | public function icon() {
$url = $this->_stub['website'];
if (!$url) {
return null;
}
$pieces = parse_url($url);
$url = $pieces['host'];
$icon = 'http://www.google.com/s2/favicons?domain=';
$icon .= $url;
$context = stream_context_create(
['http' => ['header' => 'Connection: close']]);
// E.g. http://www.google.com/s2/favicons?domain=xyz.com
$file = file_get_contents($icon, false, $context);
if ($file === false) {
return null;
}
// TODO: transform into 16x16 png
return $file;
} | php | public function icon() {
$url = $this->_stub['website'];
if (!$url) {
return null;
}
$pieces = parse_url($url);
$url = $pieces['host'];
$icon = 'http://www.google.com/s2/favicons?domain=';
$icon .= $url;
$context = stream_context_create(
['http' => ['header' => 'Connection: close']]);
// E.g. http://www.google.com/s2/favicons?domain=xyz.com
$file = file_get_contents($icon, false, $context);
if ($file === false) {
return null;
}
// TODO: transform into 16x16 png
return $file;
} | [
"public",
"function",
"icon",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_stub",
"[",
"'website'",
"]",
";",
"if",
"(",
"!",
"$",
"url",
")",
"{",
"return",
"null",
";",
"}",
"$",
"pieces",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"url",
"=",
"$",
"pieces",
"[",
"'host'",
"]",
";",
"$",
"icon",
"=",
"'http://www.google.com/s2/favicons?domain='",
";",
"$",
"icon",
".=",
"$",
"url",
";",
"$",
"context",
"=",
"stream_context_create",
"(",
"[",
"'http'",
"=>",
"[",
"'header'",
"=>",
"'Connection: close'",
"]",
"]",
")",
";",
"// E.g. http://www.google.com/s2/favicons?domain=xyz.com",
"$",
"file",
"=",
"file_get_contents",
"(",
"$",
"icon",
",",
"false",
",",
"$",
"context",
")",
";",
"if",
"(",
"$",
"file",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"// TODO: transform into 16x16 png",
"return",
"$",
"file",
";",
"}"
] | Returns a png img
@return string|null Resource content or null if not available | [
"Returns",
"a",
"png",
"img"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L187-L208 |
28,630 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.setParam | public function setParam($param, $value = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_iframeParams[$p] = $v;
}
} else {
$this->_iframeParams[$param] = $value;
}
} else {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_objectParams[$p] = $v;
}
} else {
$this->_objectParams[$param] = $value;
}
}
return $this;
} | php | public function setParam($param, $value = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_iframeParams[$p] = $v;
}
} else {
$this->_iframeParams[$param] = $value;
}
} else {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_objectParams[$p] = $v;
}
} else {
$this->_objectParams[$param] = $value;
}
}
return $this;
} | [
"public",
"function",
"setParam",
"(",
"$",
"param",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'iframe-player'",
"]",
")",
"&&",
"$",
"this",
"->",
"config",
"[",
"'prefer'",
"]",
"===",
"'iframe'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"p",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_iframeParams",
"[",
"$",
"p",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_iframeParams",
"[",
"$",
"param",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"p",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_objectParams",
"[",
"$",
"p",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_objectParams",
"[",
"$",
"param",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Override a default object param value
@param mixed $param The name of the param to be set
or an array of multiple params to set
@param string|null $value (optional) the value to set the param to
if only one param is being set
@return $this | [
"Override",
"a",
"default",
"object",
"param",
"value"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L243-L264 |
28,631 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.setAttribute | public function setAttribute($param, $value = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_iframeAttributes[$p] = $v;
}
} else {
$this->_iframeAttributes[$param] = $value;
}
} else {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_objectAttributes[$p] = $v;
}
} else {
$this->_objectAttributes[$param] = $value;
}
}
return $this;
} | php | public function setAttribute($param, $value = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_iframeAttributes[$p] = $v;
}
} else {
$this->_iframeAttributes[$param] = $value;
}
} else {
if (is_array($param)) {
foreach ($param as $p => $v) {
$this->_objectAttributes[$p] = $v;
}
} else {
$this->_objectAttributes[$param] = $value;
}
}
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"param",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'iframe-player'",
"]",
")",
"&&",
"$",
"this",
"->",
"config",
"[",
"'prefer'",
"]",
"===",
"'iframe'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"p",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_iframeAttributes",
"[",
"$",
"p",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_iframeAttributes",
"[",
"$",
"param",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"p",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_objectAttributes",
"[",
"$",
"p",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_objectAttributes",
"[",
"$",
"param",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Override a default object attribute value
@param mixed $param The name of the attribute to be set
or an array of multiple attribs to be set
@param string|int|null $value (optional) the value to set the param to
if only one param is being set
@return $this | [
"Override",
"a",
"default",
"object",
"attribute",
"value"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L275-L296 |
28,632 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.setHeight | public function setHeight($height, $adjustWidth = false) {
if ($adjustWidth && is_numeric($height)) {
$this->_adjustDimensions('width', 'height', $height);
}
return $this->setAttribute('height', $height);
} | php | public function setHeight($height, $adjustWidth = false) {
if ($adjustWidth && is_numeric($height)) {
$this->_adjustDimensions('width', 'height', $height);
}
return $this->setAttribute('height', $height);
} | [
"public",
"function",
"setHeight",
"(",
"$",
"height",
",",
"$",
"adjustWidth",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"adjustWidth",
"&&",
"is_numeric",
"(",
"$",
"height",
")",
")",
"{",
"$",
"this",
"->",
"_adjustDimensions",
"(",
"'width'",
",",
"'height'",
",",
"$",
"height",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setAttribute",
"(",
"'height'",
",",
"$",
"height",
")",
";",
"}"
] | Set the height of the object
@param mixed $height Height to set the object to
@param bool $adjustWidth
@return $this | [
"Set",
"the",
"height",
"of",
"the",
"object"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L305-L310 |
28,633 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.setWidth | public function setWidth($width, $adjustHeight = false) {
if ($adjustHeight && is_numeric($width)) {
$this->_adjustDimensions('height', 'width', $width);
}
return $this->setAttribute('width', $width);
} | php | public function setWidth($width, $adjustHeight = false) {
if ($adjustHeight && is_numeric($width)) {
$this->_adjustDimensions('height', 'width', $width);
}
return $this->setAttribute('width', $width);
} | [
"public",
"function",
"setWidth",
"(",
"$",
"width",
",",
"$",
"adjustHeight",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"adjustHeight",
"&&",
"is_numeric",
"(",
"$",
"width",
")",
")",
"{",
"$",
"this",
"->",
"_adjustDimensions",
"(",
"'height'",
",",
"'width'",
",",
"$",
"width",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setAttribute",
"(",
"'width'",
",",
"$",
"width",
")",
";",
"}"
] | Set the width of the object
@param mixed $width Width to set the object to
@param bool $adjustHeight
@return $this | [
"Set",
"the",
"width",
"of",
"the",
"object"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L319-L324 |
28,634 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject._adjustDimensions | protected function _adjustDimensions($type, $fromType, $fromLength) {
$currentLength = $this->getAttributes($type);
$currentFromLength = $this->getAttributes($fromType);
$ratio = $fromLength / $currentFromLength;
$newLength = $currentLength * $ratio;
$this->setAttribute($type, (int)$newLength);
} | php | protected function _adjustDimensions($type, $fromType, $fromLength) {
$currentLength = $this->getAttributes($type);
$currentFromLength = $this->getAttributes($fromType);
$ratio = $fromLength / $currentFromLength;
$newLength = $currentLength * $ratio;
$this->setAttribute($type, (int)$newLength);
} | [
"protected",
"function",
"_adjustDimensions",
"(",
"$",
"type",
",",
"$",
"fromType",
",",
"$",
"fromLength",
")",
"{",
"$",
"currentLength",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"$",
"type",
")",
";",
"$",
"currentFromLength",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"$",
"fromType",
")",
";",
"$",
"ratio",
"=",
"$",
"fromLength",
"/",
"$",
"currentFromLength",
";",
"$",
"newLength",
"=",
"$",
"currentLength",
"*",
"$",
"ratio",
";",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"type",
",",
"(",
"int",
")",
"$",
"newLength",
")",
";",
"}"
] | Auto-adjusts one dimension from the other to keep the current ratio.
@param string $type
@param string $fromType
@param int $fromLength
@return void | [
"Auto",
"-",
"adjusts",
"one",
"dimension",
"from",
"the",
"other",
"to",
"keep",
"the",
"current",
"ratio",
"."
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L334-L342 |
28,635 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.getParams | public function getParams($key = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if ($key === null) {
return $this->_iframeParams;
}
if (!isset($this->_iframeParams[$key])) {
return null;
}
return $this->_iframeParams[$key];
}
if ($key === null) {
return $this->_objectParams;
}
if (!isset($this->_objectParams[$key])) {
return null;
}
return $this->_objectParams[$key];
} | php | public function getParams($key = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if ($key === null) {
return $this->_iframeParams;
}
if (!isset($this->_iframeParams[$key])) {
return null;
}
return $this->_iframeParams[$key];
}
if ($key === null) {
return $this->_objectParams;
}
if (!isset($this->_objectParams[$key])) {
return null;
}
return $this->_objectParams[$key];
} | [
"public",
"function",
"getParams",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'iframe-player'",
"]",
")",
"&&",
"$",
"this",
"->",
"config",
"[",
"'prefer'",
"]",
"===",
"'iframe'",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_iframeParams",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_iframeParams",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_iframeParams",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_objectParams",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_objectParams",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_objectParams",
"[",
"$",
"key",
"]",
";",
"}"
] | Return object params about the video metadata
@param string|null $key
@return array|string|null Object params | [
"Return",
"object",
"params",
"about",
"the",
"video",
"metadata"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L350-L368 |
28,636 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.getAttributes | public function getAttributes($key = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if ($key === null) {
return $this->_iframeAttributes;
}
if (!isset($this->_iframeAttributes[$key])) {
return null;
}
return $this->_iframeAttributes[$key];
}
if ($key === null) {
return $this->_objectAttributes;
}
if (!isset($this->_objectAttributes[$key])) {
return null;
}
return $this->_objectAttributes[$key];
} | php | public function getAttributes($key = null) {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
if ($key === null) {
return $this->_iframeAttributes;
}
if (!isset($this->_iframeAttributes[$key])) {
return null;
}
return $this->_iframeAttributes[$key];
}
if ($key === null) {
return $this->_objectAttributes;
}
if (!isset($this->_objectAttributes[$key])) {
return null;
}
return $this->_objectAttributes[$key];
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'iframe-player'",
"]",
")",
"&&",
"$",
"this",
"->",
"config",
"[",
"'prefer'",
"]",
"===",
"'iframe'",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_iframeAttributes",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_iframeAttributes",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_iframeAttributes",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_objectAttributes",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_objectAttributes",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_objectAttributes",
"[",
"$",
"key",
"]",
";",
"}"
] | Return object attribute
@param string|null $key
@return mixed Object attribute | [
"Return",
"object",
"attribute"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L376-L394 |
28,637 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.getEmbedCode | public function getEmbedCode() {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
return $this->_buildIframe();
}
return $this->_buildObject();
} | php | public function getEmbedCode() {
if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') {
return $this->_buildIframe();
}
return $this->_buildObject();
} | [
"public",
"function",
"getEmbedCode",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'iframe-player'",
"]",
")",
"&&",
"$",
"this",
"->",
"config",
"[",
"'prefer'",
"]",
"===",
"'iframe'",
")",
"{",
"return",
"$",
"this",
"->",
"_buildIframe",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_buildObject",
"(",
")",
";",
"}"
] | Convert the url to an embeddable tag
@return string The embed HTML | [
"Convert",
"the",
"url",
"to",
"an",
"embeddable",
"tag"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L401-L406 |
28,638 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject._getObjectSrc | protected function _getObjectSrc($type = 'embed-src') {
if (empty($this->_stub['id']) || empty($this->_stub['slug'])) {
return null;
}
$stubSrc = $this->_stub[$type];
if (strpos($stubSrc, '$r2') !== false) {
$src = str_replace('$r2', $this->_stub['id'], $stubSrc);
} else {
$src = str_replace('$2', $this->_stub['id'], $stubSrc);
}
if (!empty($host['replace'])) {
foreach ($host['replace'] as $placeholder => $replacement) {
$src = str_replace($placeholder, $replacement, $src);
}
}
return $src;
} | php | protected function _getObjectSrc($type = 'embed-src') {
if (empty($this->_stub['id']) || empty($this->_stub['slug'])) {
return null;
}
$stubSrc = $this->_stub[$type];
if (strpos($stubSrc, '$r2') !== false) {
$src = str_replace('$r2', $this->_stub['id'], $stubSrc);
} else {
$src = str_replace('$2', $this->_stub['id'], $stubSrc);
}
if (!empty($host['replace'])) {
foreach ($host['replace'] as $placeholder => $replacement) {
$src = str_replace($placeholder, $replacement, $src);
}
}
return $src;
} | [
"protected",
"function",
"_getObjectSrc",
"(",
"$",
"type",
"=",
"'embed-src'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'id'",
"]",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'slug'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"stubSrc",
"=",
"$",
"this",
"->",
"_stub",
"[",
"$",
"type",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"stubSrc",
",",
"'$r2'",
")",
"!==",
"false",
")",
"{",
"$",
"src",
"=",
"str_replace",
"(",
"'$r2'",
",",
"$",
"this",
"->",
"_stub",
"[",
"'id'",
"]",
",",
"$",
"stubSrc",
")",
";",
"}",
"else",
"{",
"$",
"src",
"=",
"str_replace",
"(",
"'$2'",
",",
"$",
"this",
"->",
"_stub",
"[",
"'id'",
"]",
",",
"$",
"stubSrc",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"host",
"[",
"'replace'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"host",
"[",
"'replace'",
"]",
"as",
"$",
"placeholder",
"=>",
"$",
"replacement",
")",
"{",
"$",
"src",
"=",
"str_replace",
"(",
"$",
"placeholder",
",",
"$",
"replacement",
",",
"$",
"src",
")",
";",
"}",
"}",
"return",
"$",
"src",
";",
"}"
] | Get final src
@param string $type
@return string|null | [
"Get",
"final",
"src"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L432-L449 |
28,639 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject.image | public function image() {
if (empty($this->_stub['image-src'])) {
return '';
}
$thumb = $this->_stub['image-src'];
$count = count($this->_match);
for ($i = 1; $i <= $count; $i++) {
$thumb = str_ireplace('$' . $i, $this->_match[$i - 1], $thumb);
}
return $thumb;
} | php | public function image() {
if (empty($this->_stub['image-src'])) {
return '';
}
$thumb = $this->_stub['image-src'];
$count = count($this->_match);
for ($i = 1; $i <= $count; $i++) {
$thumb = str_ireplace('$' . $i, $this->_match[$i - 1], $thumb);
}
return $thumb;
} | [
"public",
"function",
"image",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_stub",
"[",
"'image-src'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"thumb",
"=",
"$",
"this",
"->",
"_stub",
"[",
"'image-src'",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"_match",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"thumb",
"=",
"str_ireplace",
"(",
"'$'",
".",
"$",
"i",
",",
"$",
"this",
"->",
"_match",
"[",
"$",
"i",
"-",
"1",
"]",
",",
"$",
"thumb",
")",
";",
"}",
"return",
"$",
"thumb",
";",
"}"
] | Return a thumbnail for the embeded video
@return string - the thumbnail href | [
"Return",
"a",
"thumbnail",
"for",
"the",
"embeded",
"video"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L477-L489 |
28,640 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject._buildObject | protected function _buildObject() {
$objectAttributes = $objectParams = '';
foreach ($this->_objectAttributes as $param => $value) {
$objectAttributes .= ' ' . $param . '="' . $value . '"';
}
foreach ($this->_objectParams as $param => $value) {
$objectParams .= '<param name="' . $param . '" value="' . $value . '" />';
}
if (!$objectAttributes && !$objectParams) {
return '';
}
return sprintf('<object %s> %s</object>', $objectAttributes, $objectParams);
} | php | protected function _buildObject() {
$objectAttributes = $objectParams = '';
foreach ($this->_objectAttributes as $param => $value) {
$objectAttributes .= ' ' . $param . '="' . $value . '"';
}
foreach ($this->_objectParams as $param => $value) {
$objectParams .= '<param name="' . $param . '" value="' . $value . '" />';
}
if (!$objectAttributes && !$objectParams) {
return '';
}
return sprintf('<object %s> %s</object>', $objectAttributes, $objectParams);
} | [
"protected",
"function",
"_buildObject",
"(",
")",
"{",
"$",
"objectAttributes",
"=",
"$",
"objectParams",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"_objectAttributes",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"$",
"objectAttributes",
".=",
"' '",
".",
"$",
"param",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_objectParams",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"$",
"objectParams",
".=",
"'<param name=\"'",
".",
"$",
"param",
".",
"'\" value=\"'",
".",
"$",
"value",
".",
"'\" />'",
";",
"}",
"if",
"(",
"!",
"$",
"objectAttributes",
"&&",
"!",
"$",
"objectParams",
")",
"{",
"return",
"''",
";",
"}",
"return",
"sprintf",
"(",
"'<object %s> %s</object>'",
",",
"$",
"objectAttributes",
",",
"$",
"objectParams",
")",
";",
"}"
] | Build a generic object skeleton
@return string | [
"Build",
"a",
"generic",
"object",
"skeleton"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L505-L520 |
28,641 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject._buildIframe | protected function _buildIframe() {
$source = $this->_stub['iframe-player'];
$count = count($this->_match);
for ($i = 1; $i <= $count; $i++) {
$source = str_ireplace('$' . $i, $this->_match[$i - 1], $source);
}
//add custom params
if ($this->_iframeParams) {
$c = '?';
if (strpos($source, '?') !== false) {
$c = '&';
}
$source .= $c . http_build_query($this->_iframeParams, '', '&');
}
$attributes = '';
//add custom attributes
foreach ($this->_iframeAttributes as $key => $val) {
//if === true, is an attribute without value
//if === false, remove the attribute
if ($val !== false) {
$attributes .= ' ' . $key . ($val !== true ? '="' . $this->_esc($val) . '"' : '');
}
}
// Transparent hack (http://groups.google.com/group/autoembed/browse_thread/thread/0ecdd9b898e12183)
return sprintf('<iframe src="%s"%s></iframe>', $source, $attributes);
} | php | protected function _buildIframe() {
$source = $this->_stub['iframe-player'];
$count = count($this->_match);
for ($i = 1; $i <= $count; $i++) {
$source = str_ireplace('$' . $i, $this->_match[$i - 1], $source);
}
//add custom params
if ($this->_iframeParams) {
$c = '?';
if (strpos($source, '?') !== false) {
$c = '&';
}
$source .= $c . http_build_query($this->_iframeParams, '', '&');
}
$attributes = '';
//add custom attributes
foreach ($this->_iframeAttributes as $key => $val) {
//if === true, is an attribute without value
//if === false, remove the attribute
if ($val !== false) {
$attributes .= ' ' . $key . ($val !== true ? '="' . $this->_esc($val) . '"' : '');
}
}
// Transparent hack (http://groups.google.com/group/autoembed/browse_thread/thread/0ecdd9b898e12183)
return sprintf('<iframe src="%s"%s></iframe>', $source, $attributes);
} | [
"protected",
"function",
"_buildIframe",
"(",
")",
"{",
"$",
"source",
"=",
"$",
"this",
"->",
"_stub",
"[",
"'iframe-player'",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"_match",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"source",
"=",
"str_ireplace",
"(",
"'$'",
".",
"$",
"i",
",",
"$",
"this",
"->",
"_match",
"[",
"$",
"i",
"-",
"1",
"]",
",",
"$",
"source",
")",
";",
"}",
"//add custom params",
"if",
"(",
"$",
"this",
"->",
"_iframeParams",
")",
"{",
"$",
"c",
"=",
"'?'",
";",
"if",
"(",
"strpos",
"(",
"$",
"source",
",",
"'?'",
")",
"!==",
"false",
")",
"{",
"$",
"c",
"=",
"'&'",
";",
"}",
"$",
"source",
".=",
"$",
"c",
".",
"http_build_query",
"(",
"$",
"this",
"->",
"_iframeParams",
",",
"''",
",",
"'&'",
")",
";",
"}",
"$",
"attributes",
"=",
"''",
";",
"//add custom attributes",
"foreach",
"(",
"$",
"this",
"->",
"_iframeAttributes",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"//if === true, is an attribute without value",
"//if === false, remove the attribute",
"if",
"(",
"$",
"val",
"!==",
"false",
")",
"{",
"$",
"attributes",
".=",
"' '",
".",
"$",
"key",
".",
"(",
"$",
"val",
"!==",
"true",
"?",
"'=\"'",
".",
"$",
"this",
"->",
"_esc",
"(",
"$",
"val",
")",
".",
"'\"'",
":",
"''",
")",
";",
"}",
"}",
"// Transparent hack (http://groups.google.com/group/autoembed/browse_thread/thread/0ecdd9b898e12183)",
"return",
"sprintf",
"(",
"'<iframe src=\"%s\"%s></iframe>'",
",",
"$",
"source",
",",
"$",
"attributes",
")",
";",
"}"
] | Build an iFrame player
@return string | [
"Build",
"an",
"iFrame",
"player"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L527-L556 |
28,642 | dereuromark/media-embed | src/Object/MediaObject.php | MediaObject._setDefaultParams | protected function _setDefaultParams($stub) {
$source = $stub['embed-src'];
$flashvars = (isset($stub['flashvars'])) ? $stub['flashvars'] : null;
$count = count($this->_match);
for ($i = 1; $i <= $count; $i++) {
$source = str_ireplace('$' . $i, $this->_match[$i - 1], $source);
$flashvars = str_ireplace('$' . $i, $this->_match[$i - 1], $flashvars);
}
$source = $this->_esc($source);
$flashvars = $this->_esc($flashvars);
$this->_objectParams = [
'movie' => $source,
'quality' => 'high',
'allowFullScreen' => 'true',
'allowScriptAccess' => 'always',
'pluginspage' => 'http://www.macromedia.com/go/getflashplayer',
'autoplay' => 'false',
'autostart' => 'false',
'flashvars' => $flashvars,
];
$this->_objectAttributes = [
'type' => 'application/x-shockwave-flash',
'data' => $source,
'width' => $stub['embed-width'],
'height' => $stub['embed-height'],
];
//separate iframe params and attributes
$this->_iframeParams = [
'wmode' => 'transparent'
];
$this->_iframeAttributes = [
'type' => 'text/html',
'width' => $stub['embed-width'],
'height' => $stub['embed-height'],
'frameborder' => '0',
'allowfullscreen' => true
];
} | php | protected function _setDefaultParams($stub) {
$source = $stub['embed-src'];
$flashvars = (isset($stub['flashvars'])) ? $stub['flashvars'] : null;
$count = count($this->_match);
for ($i = 1; $i <= $count; $i++) {
$source = str_ireplace('$' . $i, $this->_match[$i - 1], $source);
$flashvars = str_ireplace('$' . $i, $this->_match[$i - 1], $flashvars);
}
$source = $this->_esc($source);
$flashvars = $this->_esc($flashvars);
$this->_objectParams = [
'movie' => $source,
'quality' => 'high',
'allowFullScreen' => 'true',
'allowScriptAccess' => 'always',
'pluginspage' => 'http://www.macromedia.com/go/getflashplayer',
'autoplay' => 'false',
'autostart' => 'false',
'flashvars' => $flashvars,
];
$this->_objectAttributes = [
'type' => 'application/x-shockwave-flash',
'data' => $source,
'width' => $stub['embed-width'],
'height' => $stub['embed-height'],
];
//separate iframe params and attributes
$this->_iframeParams = [
'wmode' => 'transparent'
];
$this->_iframeAttributes = [
'type' => 'text/html',
'width' => $stub['embed-width'],
'height' => $stub['embed-height'],
'frameborder' => '0',
'allowfullscreen' => true
];
} | [
"protected",
"function",
"_setDefaultParams",
"(",
"$",
"stub",
")",
"{",
"$",
"source",
"=",
"$",
"stub",
"[",
"'embed-src'",
"]",
";",
"$",
"flashvars",
"=",
"(",
"isset",
"(",
"$",
"stub",
"[",
"'flashvars'",
"]",
")",
")",
"?",
"$",
"stub",
"[",
"'flashvars'",
"]",
":",
"null",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"_match",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"source",
"=",
"str_ireplace",
"(",
"'$'",
".",
"$",
"i",
",",
"$",
"this",
"->",
"_match",
"[",
"$",
"i",
"-",
"1",
"]",
",",
"$",
"source",
")",
";",
"$",
"flashvars",
"=",
"str_ireplace",
"(",
"'$'",
".",
"$",
"i",
",",
"$",
"this",
"->",
"_match",
"[",
"$",
"i",
"-",
"1",
"]",
",",
"$",
"flashvars",
")",
";",
"}",
"$",
"source",
"=",
"$",
"this",
"->",
"_esc",
"(",
"$",
"source",
")",
";",
"$",
"flashvars",
"=",
"$",
"this",
"->",
"_esc",
"(",
"$",
"flashvars",
")",
";",
"$",
"this",
"->",
"_objectParams",
"=",
"[",
"'movie'",
"=>",
"$",
"source",
",",
"'quality'",
"=>",
"'high'",
",",
"'allowFullScreen'",
"=>",
"'true'",
",",
"'allowScriptAccess'",
"=>",
"'always'",
",",
"'pluginspage'",
"=>",
"'http://www.macromedia.com/go/getflashplayer'",
",",
"'autoplay'",
"=>",
"'false'",
",",
"'autostart'",
"=>",
"'false'",
",",
"'flashvars'",
"=>",
"$",
"flashvars",
",",
"]",
";",
"$",
"this",
"->",
"_objectAttributes",
"=",
"[",
"'type'",
"=>",
"'application/x-shockwave-flash'",
",",
"'data'",
"=>",
"$",
"source",
",",
"'width'",
"=>",
"$",
"stub",
"[",
"'embed-width'",
"]",
",",
"'height'",
"=>",
"$",
"stub",
"[",
"'embed-height'",
"]",
",",
"]",
";",
"//separate iframe params and attributes",
"$",
"this",
"->",
"_iframeParams",
"=",
"[",
"'wmode'",
"=>",
"'transparent'",
"]",
";",
"$",
"this",
"->",
"_iframeAttributes",
"=",
"[",
"'type'",
"=>",
"'text/html'",
",",
"'width'",
"=>",
"$",
"stub",
"[",
"'embed-width'",
"]",
",",
"'height'",
"=>",
"$",
"stub",
"[",
"'embed-height'",
"]",
",",
"'frameborder'",
"=>",
"'0'",
",",
"'allowfullscreen'",
"=>",
"true",
"]",
";",
"}"
] | Set the default params for the type of
stub we are working with
@param array $stub
@return void | [
"Set",
"the",
"default",
"params",
"for",
"the",
"type",
"of",
"stub",
"we",
"are",
"working",
"with"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L565-L607 |
28,643 | dereuromark/media-embed | src/MediaEmbed.php | MediaEmbed.parseId | public function parseId($id, $host, $config = []) {
if (empty($id) || empty($host)) {
return null;
}
// local files?
if ($host === 'local') {
$res = $this->embedLocal($id);
if (!$res) {
$stub = [];
$Object = $this->object($stub, $config);
return $Object;
}
//TODO
return null;
}
// all other hosts
$host = $this->getHost($host);
if (!$host) {
return null;
}
$stub = $host;
$config += $this->config;
$stub['id'] = $id;
$stub['reverse'] = true;
$Object = $this->object($stub, $config);
return $Object;
} | php | public function parseId($id, $host, $config = []) {
if (empty($id) || empty($host)) {
return null;
}
// local files?
if ($host === 'local') {
$res = $this->embedLocal($id);
if (!$res) {
$stub = [];
$Object = $this->object($stub, $config);
return $Object;
}
//TODO
return null;
}
// all other hosts
$host = $this->getHost($host);
if (!$host) {
return null;
}
$stub = $host;
$config += $this->config;
$stub['id'] = $id;
$stub['reverse'] = true;
$Object = $this->object($stub, $config);
return $Object;
} | [
"public",
"function",
"parseId",
"(",
"$",
"id",
",",
"$",
"host",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
"||",
"empty",
"(",
"$",
"host",
")",
")",
"{",
"return",
"null",
";",
"}",
"// local files?",
"if",
"(",
"$",
"host",
"===",
"'local'",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"embedLocal",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"res",
")",
"{",
"$",
"stub",
"=",
"[",
"]",
";",
"$",
"Object",
"=",
"$",
"this",
"->",
"object",
"(",
"$",
"stub",
",",
"$",
"config",
")",
";",
"return",
"$",
"Object",
";",
"}",
"//TODO",
"return",
"null",
";",
"}",
"// all other hosts",
"$",
"host",
"=",
"$",
"this",
"->",
"getHost",
"(",
"$",
"host",
")",
";",
"if",
"(",
"!",
"$",
"host",
")",
"{",
"return",
"null",
";",
"}",
"$",
"stub",
"=",
"$",
"host",
";",
"$",
"config",
"+=",
"$",
"this",
"->",
"config",
";",
"$",
"stub",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"$",
"stub",
"[",
"'reverse'",
"]",
"=",
"true",
";",
"$",
"Object",
"=",
"$",
"this",
"->",
"object",
"(",
"$",
"stub",
",",
"$",
"config",
")",
";",
"return",
"$",
"Object",
";",
"}"
] | Prepare embed video from different video hosts.
@param string $id
@param string $host
@param array $config
@return \MediaEmbed\Object\MediaObject|null | [
"Prepare",
"embed",
"video",
"from",
"different",
"video",
"hosts",
"."
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/MediaEmbed.php#L57-L87 |
28,644 | dereuromark/media-embed | src/MediaEmbed.php | MediaEmbed.parseUrl | public function parseUrl($url, $config = []) {
foreach ($this->_hosts as $stub) {
$match = $this->_matchUrl($url, (array)$stub['url-match']);
if (!$match) {
continue;
}
$this->_match = $match;
if (!empty($stub['fetch-match'])) {
if (!$this->_parseLink($url, $stub['fetch-match'])) {
return null;
}
}
$stub['match'] = $this->_match;
$Object = $this->object($stub, $config + $this->config);
return $Object;
}
} | php | public function parseUrl($url, $config = []) {
foreach ($this->_hosts as $stub) {
$match = $this->_matchUrl($url, (array)$stub['url-match']);
if (!$match) {
continue;
}
$this->_match = $match;
if (!empty($stub['fetch-match'])) {
if (!$this->_parseLink($url, $stub['fetch-match'])) {
return null;
}
}
$stub['match'] = $this->_match;
$Object = $this->object($stub, $config + $this->config);
return $Object;
}
} | [
"public",
"function",
"parseUrl",
"(",
"$",
"url",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_hosts",
"as",
"$",
"stub",
")",
"{",
"$",
"match",
"=",
"$",
"this",
"->",
"_matchUrl",
"(",
"$",
"url",
",",
"(",
"array",
")",
"$",
"stub",
"[",
"'url-match'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"match",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"_match",
"=",
"$",
"match",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"stub",
"[",
"'fetch-match'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_parseLink",
"(",
"$",
"url",
",",
"$",
"stub",
"[",
"'fetch-match'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"}",
"$",
"stub",
"[",
"'match'",
"]",
"=",
"$",
"this",
"->",
"_match",
";",
"$",
"Object",
"=",
"$",
"this",
"->",
"object",
"(",
"$",
"stub",
",",
"$",
"config",
"+",
"$",
"this",
"->",
"config",
")",
";",
"return",
"$",
"Object",
";",
"}",
"}"
] | Parse given URL.
It will return an object if the url contains valid/supported video.
@param string $url Href to check for embedded video
@param array $config
@return \MediaEmbed\Object\MediaObject|null | [
"Parse",
"given",
"URL",
"."
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/MediaEmbed.php#L98-L117 |
28,645 | dereuromark/media-embed | src/MediaEmbed.php | MediaEmbed._parseLink | protected function _parseLink($url, $regex) {
$context = stream_context_create(
['http' => ['header' => 'Connection: close']]);
$content = file_get_contents($url, false, $context);
if (!$content) {
return false;
}
$source = preg_replace('/[^(\x20-\x7F)]*/', '', $content);
if (preg_match('~' . $regex . '~imu', $source, $match)) {
$this->_match = $match;
return true;
}
return false;
} | php | protected function _parseLink($url, $regex) {
$context = stream_context_create(
['http' => ['header' => 'Connection: close']]);
$content = file_get_contents($url, false, $context);
if (!$content) {
return false;
}
$source = preg_replace('/[^(\x20-\x7F)]*/', '', $content);
if (preg_match('~' . $regex . '~imu', $source, $match)) {
$this->_match = $match;
return true;
}
return false;
} | [
"protected",
"function",
"_parseLink",
"(",
"$",
"url",
",",
"$",
"regex",
")",
"{",
"$",
"context",
"=",
"stream_context_create",
"(",
"[",
"'http'",
"=>",
"[",
"'header'",
"=>",
"'Connection: close'",
"]",
"]",
")",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"url",
",",
"false",
",",
"$",
"context",
")",
";",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"return",
"false",
";",
"}",
"$",
"source",
"=",
"preg_replace",
"(",
"'/[^(\\x20-\\x7F)]*/'",
",",
"''",
",",
"$",
"content",
")",
";",
"if",
"(",
"preg_match",
"(",
"'~'",
".",
"$",
"regex",
".",
"'~imu'",
",",
"$",
"source",
",",
"$",
"match",
")",
")",
"{",
"$",
"this",
"->",
"_match",
"=",
"$",
"match",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Attempt to parse the embed id from a given URL
@param string $url
@param string $regex
@return bool | [
"Attempt",
"to",
"parse",
"the",
"embed",
"id",
"from",
"a",
"given",
"URL"
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/MediaEmbed.php#L142-L158 |
28,646 | dereuromark/media-embed | src/MediaEmbed.php | MediaEmbed.setHosts | public function setHosts(array $stubs, $reset = false) {
if ($reset) {
$this->_hosts = [];
}
foreach ($stubs as $stub) {
$slug = $this->_slug($stub['name']);
$this->_hosts[$slug] = $stub;
}
return $this;
} | php | public function setHosts(array $stubs, $reset = false) {
if ($reset) {
$this->_hosts = [];
}
foreach ($stubs as $stub) {
$slug = $this->_slug($stub['name']);
$this->_hosts[$slug] = $stub;
}
return $this;
} | [
"public",
"function",
"setHosts",
"(",
"array",
"$",
"stubs",
",",
"$",
"reset",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"this",
"->",
"_hosts",
"=",
"[",
"]",
";",
"}",
"foreach",
"(",
"$",
"stubs",
"as",
"$",
"stub",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"_slug",
"(",
"$",
"stub",
"[",
"'name'",
"]",
")",
";",
"$",
"this",
"->",
"_hosts",
"[",
"$",
"slug",
"]",
"=",
"$",
"stub",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set custom stubs overwriting the default ones.
@param array $stubs Same format as in the stubs.php file.
@param bool $reset If default ones should be resetted/removed.
@return $this | [
"Set",
"custom",
"stubs",
"overwriting",
"the",
"default",
"ones",
"."
] | bd940aafbaf4577a5dd61879e0601f278593f523 | https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/MediaEmbed.php#L167-L176 |
28,647 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.select | public function select( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'SELECT' );
$this->addExpressions( $expressions );
return $this;
} | php | public function select( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'SELECT' );
$this->addExpressions( $expressions );
return $this;
} | [
"public",
"function",
"select",
"(",
"$",
"expressions",
"/* expressions ... */",
")",
"{",
"$",
"expressions",
"=",
"is_array",
"(",
"$",
"expressions",
")",
"?",
"$",
"expressions",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"setQueryForm",
"(",
"'SELECT'",
")",
";",
"$",
"this",
"->",
"addExpressions",
"(",
"$",
"expressions",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Specifies the expressions to select.
@param string|string[] $expressions
@return self
@throws InvalidArgumentException
@throws RuntimeException | [
"Specifies",
"the",
"expressions",
"to",
"select",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L91-L98 |
28,648 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.selectDistinct | public function selectDistinct( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'SELECT' );
$this->uniqueness = 'DISTINCT ';
$this->addExpressions( $expressions );
return $this;
} | php | public function selectDistinct( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'SELECT' );
$this->uniqueness = 'DISTINCT ';
$this->addExpressions( $expressions );
return $this;
} | [
"public",
"function",
"selectDistinct",
"(",
"$",
"expressions",
"/* expressions ... */",
")",
"{",
"$",
"expressions",
"=",
"is_array",
"(",
"$",
"expressions",
")",
"?",
"$",
"expressions",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"setQueryForm",
"(",
"'SELECT'",
")",
";",
"$",
"this",
"->",
"uniqueness",
"=",
"'DISTINCT '",
";",
"$",
"this",
"->",
"addExpressions",
"(",
"$",
"expressions",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Specifies the expressions to select. Duplicate results are eliminated.
@since 0.3
@param string|string[] $expressions
@return self
@throws InvalidArgumentException
@throws RuntimeException | [
"Specifies",
"the",
"expressions",
"to",
"select",
".",
"Duplicate",
"results",
"are",
"eliminated",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L110-L118 |
28,649 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.selectReduced | public function selectReduced( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'SELECT' );
$this->uniqueness = 'REDUCED ';
$this->addExpressions( $expressions );
return $this;
} | php | public function selectReduced( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'SELECT' );
$this->uniqueness = 'REDUCED ';
$this->addExpressions( $expressions );
return $this;
} | [
"public",
"function",
"selectReduced",
"(",
"$",
"expressions",
"/* expressions ... */",
")",
"{",
"$",
"expressions",
"=",
"is_array",
"(",
"$",
"expressions",
")",
"?",
"$",
"expressions",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"setQueryForm",
"(",
"'SELECT'",
")",
";",
"$",
"this",
"->",
"uniqueness",
"=",
"'REDUCED '",
";",
"$",
"this",
"->",
"addExpressions",
"(",
"$",
"expressions",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Specifies the expressions to select. Duplicate results may be eliminated.
@since 0.3
@param string|string[] $expressions
@return self
@throws InvalidArgumentException
@throws RuntimeException | [
"Specifies",
"the",
"expressions",
"to",
"select",
".",
"Duplicate",
"results",
"may",
"be",
"eliminated",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L130-L138 |
28,650 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.describe | public function describe( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'DESCRIBE' );
$this->addExpressions(
$expressions,
ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS
| ExpressionValidator::VALIDATE_IRI | ExpressionValidator::VALIDATE_PREFIXED_IRI
);
return $this;
} | php | public function describe( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->setQueryForm( 'DESCRIBE' );
$this->addExpressions(
$expressions,
ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS
| ExpressionValidator::VALIDATE_IRI | ExpressionValidator::VALIDATE_PREFIXED_IRI
);
return $this;
} | [
"public",
"function",
"describe",
"(",
"$",
"expressions",
"/* expressions ... */",
")",
"{",
"$",
"expressions",
"=",
"is_array",
"(",
"$",
"expressions",
")",
"?",
"$",
"expressions",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"setQueryForm",
"(",
"'DESCRIBE'",
")",
";",
"$",
"this",
"->",
"addExpressions",
"(",
"$",
"expressions",
",",
"ExpressionValidator",
"::",
"VALIDATE_VARIABLE",
"|",
"ExpressionValidator",
"::",
"VALIDATE_FUNCTION_AS",
"|",
"ExpressionValidator",
"::",
"VALIDATE_IRI",
"|",
"ExpressionValidator",
"::",
"VALIDATE_PREFIXED_IRI",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Specifies the expressions to describe.
@since 0.4
@param string|string[] $expressions
@return self
@throws InvalidArgumentException
@throws RuntimeException | [
"Specifies",
"the",
"expressions",
"to",
"describe",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L150-L161 |
28,651 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.filterNotExists | public function filterNotExists( $subject, $predicate = null, $object = null ) {
$this->graphBuilder->filterNotExists( $subject, $predicate, $object );
return $this;
} | php | public function filterNotExists( $subject, $predicate = null, $object = null ) {
$this->graphBuilder->filterNotExists( $subject, $predicate, $object );
return $this;
} | [
"public",
"function",
"filterNotExists",
"(",
"$",
"subject",
",",
"$",
"predicate",
"=",
"null",
",",
"$",
"object",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"graphBuilder",
"->",
"filterNotExists",
"(",
"$",
"subject",
",",
"$",
"predicate",
",",
"$",
"object",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a filter that the given graph or triple does not exist.
@since 0.3
@param string|GraphBuilder $subject
@param string|null $predicate
@param string|null $object
@return self
@throws InvalidArgumentException | [
"Adds",
"a",
"filter",
"that",
"the",
"given",
"graph",
"or",
"triple",
"does",
"not",
"exist",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L276-L279 |
28,652 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.groupBy | public function groupBy( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->modifierBuilder->groupBy( $expressions );
return $this;
} | php | public function groupBy( $expressions /* expressions ... */ ) {
$expressions = is_array( $expressions ) ? $expressions : func_get_args();
$this->modifierBuilder->groupBy( $expressions );
return $this;
} | [
"public",
"function",
"groupBy",
"(",
"$",
"expressions",
"/* expressions ... */",
")",
"{",
"$",
"expressions",
"=",
"is_array",
"(",
"$",
"expressions",
")",
"?",
"$",
"expressions",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"modifierBuilder",
"->",
"groupBy",
"(",
"$",
"expressions",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the GROUP BY modifier.
@param string|string[] $expressions
@return self
@throws InvalidArgumentException | [
"Sets",
"the",
"GROUP",
"BY",
"modifier",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L334-L339 |
28,653 | Benestar/asparagus | src/QueryBuilder.php | QueryBuilder.getSPARQL | public function getSPARQL( $includePrefixes = true ) {
if ( !is_bool( $includePrefixes ) ) {
throw new InvalidArgumentException( '$includePrefixes has to be a bool' );
}
$this->usageValidator->validate();
$sparql = $includePrefixes ? $this->prefixBuilder->getSPARQL() : '';
// @todo throw an exception instead of defaulting to SELECT?
$sparql .= $this->queryForm ?: 'SELECT';
$sparql .= ' ' . $this->uniqueness . $this->formatSelects() . ' WHERE';
$sparql .= ' {' . $this->graphBuilder->getSPARQL() . ' }';
$sparql .= $this->modifierBuilder->getSPARQL();
return $sparql;
} | php | public function getSPARQL( $includePrefixes = true ) {
if ( !is_bool( $includePrefixes ) ) {
throw new InvalidArgumentException( '$includePrefixes has to be a bool' );
}
$this->usageValidator->validate();
$sparql = $includePrefixes ? $this->prefixBuilder->getSPARQL() : '';
// @todo throw an exception instead of defaulting to SELECT?
$sparql .= $this->queryForm ?: 'SELECT';
$sparql .= ' ' . $this->uniqueness . $this->formatSelects() . ' WHERE';
$sparql .= ' {' . $this->graphBuilder->getSPARQL() . ' }';
$sparql .= $this->modifierBuilder->getSPARQL();
return $sparql;
} | [
"public",
"function",
"getSPARQL",
"(",
"$",
"includePrefixes",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"includePrefixes",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$includePrefixes has to be a bool'",
")",
";",
"}",
"$",
"this",
"->",
"usageValidator",
"->",
"validate",
"(",
")",
";",
"$",
"sparql",
"=",
"$",
"includePrefixes",
"?",
"$",
"this",
"->",
"prefixBuilder",
"->",
"getSPARQL",
"(",
")",
":",
"''",
";",
"// @todo throw an exception instead of defaulting to SELECT?",
"$",
"sparql",
".=",
"$",
"this",
"->",
"queryForm",
"?",
":",
"'SELECT'",
";",
"$",
"sparql",
".=",
"' '",
".",
"$",
"this",
"->",
"uniqueness",
".",
"$",
"this",
"->",
"formatSelects",
"(",
")",
".",
"' WHERE'",
";",
"$",
"sparql",
".=",
"' {'",
".",
"$",
"this",
"->",
"graphBuilder",
"->",
"getSPARQL",
"(",
")",
".",
"' }'",
";",
"$",
"sparql",
".=",
"$",
"this",
"->",
"modifierBuilder",
"->",
"getSPARQL",
"(",
")",
";",
"return",
"$",
"sparql",
";",
"}"
] | Returns the plain SPARQL string of this query.
@param bool $includePrefixes
@return string
@throws InvalidArgumentException
@throws RangeException | [
"Returns",
"the",
"plain",
"SPARQL",
"string",
"of",
"this",
"query",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryBuilder.php#L398-L413 |
28,654 | Benestar/asparagus | src/GraphBuilder.php | GraphBuilder.filter | public function filter( $expression ) {
$this->expressionValidator->validate( $expression, ExpressionValidator::VALIDATE_FUNCTION );
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->filters[] = '(' . $expression . ')';
return $this;
} | php | public function filter( $expression ) {
$this->expressionValidator->validate( $expression, ExpressionValidator::VALIDATE_FUNCTION );
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->filters[] = '(' . $expression . ')';
return $this;
} | [
"public",
"function",
"filter",
"(",
"$",
"expression",
")",
"{",
"$",
"this",
"->",
"expressionValidator",
"->",
"validate",
"(",
"$",
"expression",
",",
"ExpressionValidator",
"::",
"VALIDATE_FUNCTION",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedPrefixes",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedVariables",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"filters",
"[",
"]",
"=",
"'('",
".",
"$",
"expression",
".",
"')'",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the given expression as a filter to this query.
@param string $expression
@return self
@throws InvalidArgumentException | [
"Adds",
"the",
"given",
"expression",
"as",
"a",
"filter",
"to",
"this",
"query",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/GraphBuilder.php#L134-L143 |
28,655 | Benestar/asparagus | src/GraphBuilder.php | GraphBuilder.union | public function union( $graphs /* graphs ... */ ) {
$graphs = is_array( $graphs ) ? $graphs : func_get_args();
$this->unions[] = implode( ' UNION', array_map( function( GraphBuilder $graph ) {
return ' {' . $graph->getSPARQL() . ' }';
}, $graphs ) );
return $this;
} | php | public function union( $graphs /* graphs ... */ ) {
$graphs = is_array( $graphs ) ? $graphs : func_get_args();
$this->unions[] = implode( ' UNION', array_map( function( GraphBuilder $graph ) {
return ' {' . $graph->getSPARQL() . ' }';
}, $graphs ) );
return $this;
} | [
"public",
"function",
"union",
"(",
"$",
"graphs",
"/* graphs ... */",
")",
"{",
"$",
"graphs",
"=",
"is_array",
"(",
"$",
"graphs",
")",
"?",
"$",
"graphs",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"unions",
"[",
"]",
"=",
"implode",
"(",
"' UNION'",
",",
"array_map",
"(",
"function",
"(",
"GraphBuilder",
"$",
"graph",
")",
"{",
"return",
"' {'",
".",
"$",
"graph",
"->",
"getSPARQL",
"(",
")",
".",
"' }'",
";",
"}",
",",
"$",
"graphs",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the given graphs as alternative conditions.
@param GraphBuilder|GraphBuilder[] $graphs
@return self
@throws InvalidArgumentException | [
"Adds",
"the",
"given",
"graphs",
"as",
"alternative",
"conditions",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/GraphBuilder.php#L208-L216 |
28,656 | Benestar/asparagus | src/GraphBuilder.php | GraphBuilder.subquery | public function subquery( QueryBuilder $queryBuilder ) {
$this->subqueries[] = $queryBuilder->getSPARQL( false );
$this->usageValidator->trackDefinedVariables( implode( ' ', $queryBuilder->getSelects() ) );
// @todo temp hack to add AS definitions to defined variables
$regexHelper = new RegexHelper();
$matches = $regexHelper->getMatches( 'AS \{variable}', implode( ' ', $queryBuilder->getSelects() ) );
$this->usageValidator->trackDefinedVariables( $matches );
return $this;
} | php | public function subquery( QueryBuilder $queryBuilder ) {
$this->subqueries[] = $queryBuilder->getSPARQL( false );
$this->usageValidator->trackDefinedVariables( implode( ' ', $queryBuilder->getSelects() ) );
// @todo temp hack to add AS definitions to defined variables
$regexHelper = new RegexHelper();
$matches = $regexHelper->getMatches( 'AS \{variable}', implode( ' ', $queryBuilder->getSelects() ) );
$this->usageValidator->trackDefinedVariables( $matches );
return $this;
} | [
"public",
"function",
"subquery",
"(",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"$",
"this",
"->",
"subqueries",
"[",
"]",
"=",
"$",
"queryBuilder",
"->",
"getSPARQL",
"(",
"false",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackDefinedVariables",
"(",
"implode",
"(",
"' '",
",",
"$",
"queryBuilder",
"->",
"getSelects",
"(",
")",
")",
")",
";",
"// @todo temp hack to add AS definitions to defined variables",
"$",
"regexHelper",
"=",
"new",
"RegexHelper",
"(",
")",
";",
"$",
"matches",
"=",
"$",
"regexHelper",
"->",
"getMatches",
"(",
"'AS \\{variable}'",
",",
"implode",
"(",
"' '",
",",
"$",
"queryBuilder",
"->",
"getSelects",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackDefinedVariables",
"(",
"$",
"matches",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the given subquery.
@param QueryBuilder $queryBuilder
@return self
@throws InvalidArgumentException | [
"Adds",
"the",
"given",
"subquery",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/GraphBuilder.php#L225-L235 |
28,657 | Benestar/asparagus | src/GraphBuilder.php | GraphBuilder.getSPARQL | public function getSPARQL() {
// add subqueries to the beginning because they are logically evaluated first
$sparql = $this->formatSubqueries();
foreach ( $this->conditions as $subject => $predicates ) {
$sparql .= ' ' . $subject;
$sparql .= $this->formatPredicates( $predicates ) . ' .';
}
$sparql .= $this->formatOptionals();
$sparql .= $this->formatFilters();
$sparql .= $this->formatUnions();
return $sparql;
} | php | public function getSPARQL() {
// add subqueries to the beginning because they are logically evaluated first
$sparql = $this->formatSubqueries();
foreach ( $this->conditions as $subject => $predicates ) {
$sparql .= ' ' . $subject;
$sparql .= $this->formatPredicates( $predicates ) . ' .';
}
$sparql .= $this->formatOptionals();
$sparql .= $this->formatFilters();
$sparql .= $this->formatUnions();
return $sparql;
} | [
"public",
"function",
"getSPARQL",
"(",
")",
"{",
"// add subqueries to the beginning because they are logically evaluated first",
"$",
"sparql",
"=",
"$",
"this",
"->",
"formatSubqueries",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"conditions",
"as",
"$",
"subject",
"=>",
"$",
"predicates",
")",
"{",
"$",
"sparql",
".=",
"' '",
".",
"$",
"subject",
";",
"$",
"sparql",
".=",
"$",
"this",
"->",
"formatPredicates",
"(",
"$",
"predicates",
")",
".",
"' .'",
";",
"}",
"$",
"sparql",
".=",
"$",
"this",
"->",
"formatOptionals",
"(",
")",
";",
"$",
"sparql",
".=",
"$",
"this",
"->",
"formatFilters",
"(",
")",
";",
"$",
"sparql",
".=",
"$",
"this",
"->",
"formatUnions",
"(",
")",
";",
"return",
"$",
"sparql",
";",
"}"
] | Returns the plain SPARQL string of these conditions.
Surrounding brackets are not included.
@return string | [
"Returns",
"the",
"plain",
"SPARQL",
"string",
"of",
"these",
"conditions",
".",
"Surrounding",
"brackets",
"are",
"not",
"included",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/GraphBuilder.php#L243-L257 |
28,658 | Benestar/asparagus | src/RegexHelper.php | RegexHelper.getMatches | public function getMatches( $regex, $expression, $group = 1 ) {
if ( preg_match_all(
'/' . $this->resolveMagic( $regex ) . '/',
$this->escapeSequences( $expression ),
$matches
) ) {
return $matches[$group];
}
return array();
} | php | public function getMatches( $regex, $expression, $group = 1 ) {
if ( preg_match_all(
'/' . $this->resolveMagic( $regex ) . '/',
$this->escapeSequences( $expression ),
$matches
) ) {
return $matches[$group];
}
return array();
} | [
"public",
"function",
"getMatches",
"(",
"$",
"regex",
",",
"$",
"expression",
",",
"$",
"group",
"=",
"1",
")",
"{",
"if",
"(",
"preg_match_all",
"(",
"'/'",
".",
"$",
"this",
"->",
"resolveMagic",
"(",
"$",
"regex",
")",
".",
"'/'",
",",
"$",
"this",
"->",
"escapeSequences",
"(",
"$",
"expression",
")",
",",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"matches",
"[",
"$",
"group",
"]",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
] | Returns all matching groups for the given regex.
String and IRI equences are automatically escaped.
@param string $regex
@param string $expression
@param int $group
@return string[] | [
"Returns",
"all",
"matching",
"groups",
"for",
"the",
"given",
"regex",
".",
"String",
"and",
"IRI",
"equences",
"are",
"automatically",
"escaped",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/RegexHelper.php#L83-L93 |
28,659 | crazy-max/CwsDump | lib/Cws/CwsDump.php | CwsDump.dump | public function dump($var, $or = true)
{
$result = '';
if ($var === null) {
$result .= $this->dumpNull($or);
} elseif (is_bool($var)) {
$result .= $this->dumpBool($var, $or);
} elseif (is_string($var)) {
$result .= $this->dumpString($var, $or);
} elseif (is_int($var)) {
$result .= $this->dumpInt($var, $or);
} elseif (is_float($var)) {
$result .= $this->dumpFloat($var, $or);
} elseif (is_array($var) || is_object($var)) {
if ($this->recurseDepth >= $this->maxDepth) {
$type = is_object($var) ? self::NAME_OBJECT : self::NAME_ARRAY;
$maxDepthReached = $this->writeStart(false);
$maxDepthReached .= $this->writeRow('<strong>'.$type.'</strong>');
$maxDepthReached .= $this->writeRow('<span style="padding-left:10pt;font-style:italic;"><i>'
.self::DISPLAY_MAX_DEPTH.'</span>');
$maxDepthReached .= $this->writeEnd();
return $maxDepthReached;
}
$this->recurseDepth++;
if (is_array($var)) {
$result .= $this->dumpArray($var, $or);
} else {
$result .= $this->dumpObject($var, $or);
}
$this->recurseDepth--;
} elseif (is_resource($var)) {
$result .= $this->dumpRes($var, $or);
} else {
$result .= '???';
}
return $result;
} | php | public function dump($var, $or = true)
{
$result = '';
if ($var === null) {
$result .= $this->dumpNull($or);
} elseif (is_bool($var)) {
$result .= $this->dumpBool($var, $or);
} elseif (is_string($var)) {
$result .= $this->dumpString($var, $or);
} elseif (is_int($var)) {
$result .= $this->dumpInt($var, $or);
} elseif (is_float($var)) {
$result .= $this->dumpFloat($var, $or);
} elseif (is_array($var) || is_object($var)) {
if ($this->recurseDepth >= $this->maxDepth) {
$type = is_object($var) ? self::NAME_OBJECT : self::NAME_ARRAY;
$maxDepthReached = $this->writeStart(false);
$maxDepthReached .= $this->writeRow('<strong>'.$type.'</strong>');
$maxDepthReached .= $this->writeRow('<span style="padding-left:10pt;font-style:italic;"><i>'
.self::DISPLAY_MAX_DEPTH.'</span>');
$maxDepthReached .= $this->writeEnd();
return $maxDepthReached;
}
$this->recurseDepth++;
if (is_array($var)) {
$result .= $this->dumpArray($var, $or);
} else {
$result .= $this->dumpObject($var, $or);
}
$this->recurseDepth--;
} elseif (is_resource($var)) {
$result .= $this->dumpRes($var, $or);
} else {
$result .= '???';
}
return $result;
} | [
"public",
"function",
"dump",
"(",
"$",
"var",
",",
"$",
"or",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"var",
"===",
"null",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpNull",
"(",
"$",
"or",
")",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpBool",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpString",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpInt",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"elseif",
"(",
"is_float",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpFloat",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"var",
")",
"||",
"is_object",
"(",
"$",
"var",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"recurseDepth",
">=",
"$",
"this",
"->",
"maxDepth",
")",
"{",
"$",
"type",
"=",
"is_object",
"(",
"$",
"var",
")",
"?",
"self",
"::",
"NAME_OBJECT",
":",
"self",
"::",
"NAME_ARRAY",
";",
"$",
"maxDepthReached",
"=",
"$",
"this",
"->",
"writeStart",
"(",
"false",
")",
";",
"$",
"maxDepthReached",
".=",
"$",
"this",
"->",
"writeRow",
"(",
"'<strong>'",
".",
"$",
"type",
".",
"'</strong>'",
")",
";",
"$",
"maxDepthReached",
".=",
"$",
"this",
"->",
"writeRow",
"(",
"'<span style=\"padding-left:10pt;font-style:italic;\"><i>'",
".",
"self",
"::",
"DISPLAY_MAX_DEPTH",
".",
"'</span>'",
")",
";",
"$",
"maxDepthReached",
".=",
"$",
"this",
"->",
"writeEnd",
"(",
")",
";",
"return",
"$",
"maxDepthReached",
";",
"}",
"$",
"this",
"->",
"recurseDepth",
"++",
";",
"if",
"(",
"is_array",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpArray",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpObject",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"$",
"this",
"->",
"recurseDepth",
"--",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"dumpRes",
"(",
"$",
"var",
",",
"$",
"or",
")",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"'???'",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Dump variable into formatted XHTML string.
@param mixed $var
@param bool $or
@return string - Formatted XHTML | [
"Dump",
"variable",
"into",
"formatted",
"XHTML",
"string",
"."
] | 9d979a2a07a373fb265d72ec0cb7553cd00309cb | https://github.com/crazy-max/CwsDump/blob/9d979a2a07a373fb265d72ec0cb7553cd00309cb/lib/Cws/CwsDump.php#L110-L149 |
28,660 | Benestar/asparagus | src/QueryPrefixBuilder.php | QueryPrefixBuilder.setPrefixes | private function setPrefixes( array $prefixes ) {
foreach ( $prefixes as $prefix => $iri ) {
$this->expressionValidator->validate( $prefix, ExpressionValidator::VALIDATE_PREFIX );
$this->expressionValidator->validate( $iri, ExpressionValidator::VALIDATE_IRI );
$this->prefixes[$prefix] = $iri;
}
$this->usageValidator->trackDefinedPrefixes( array_keys( $this->prefixes ) );
} | php | private function setPrefixes( array $prefixes ) {
foreach ( $prefixes as $prefix => $iri ) {
$this->expressionValidator->validate( $prefix, ExpressionValidator::VALIDATE_PREFIX );
$this->expressionValidator->validate( $iri, ExpressionValidator::VALIDATE_IRI );
$this->prefixes[$prefix] = $iri;
}
$this->usageValidator->trackDefinedPrefixes( array_keys( $this->prefixes ) );
} | [
"private",
"function",
"setPrefixes",
"(",
"array",
"$",
"prefixes",
")",
"{",
"foreach",
"(",
"$",
"prefixes",
"as",
"$",
"prefix",
"=>",
"$",
"iri",
")",
"{",
"$",
"this",
"->",
"expressionValidator",
"->",
"validate",
"(",
"$",
"prefix",
",",
"ExpressionValidator",
"::",
"VALIDATE_PREFIX",
")",
";",
"$",
"this",
"->",
"expressionValidator",
"->",
"validate",
"(",
"$",
"iri",
",",
"ExpressionValidator",
"::",
"VALIDATE_IRI",
")",
";",
"$",
"this",
"->",
"prefixes",
"[",
"$",
"prefix",
"]",
"=",
"$",
"iri",
";",
"}",
"$",
"this",
"->",
"usageValidator",
"->",
"trackDefinedPrefixes",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"prefixes",
")",
")",
";",
"}"
] | Sets the prefixes for the given IRIs.
@param string[] $prefixes
@throws InvalidArgumentException | [
"Sets",
"the",
"prefixes",
"for",
"the",
"given",
"IRIs",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryPrefixBuilder.php#L45-L54 |
28,661 | Benestar/asparagus | src/QueryPrefixBuilder.php | QueryPrefixBuilder.getSPARQL | public function getSPARQL() {
return implode( array_map( function( $prefix, $iri ) {
return 'PREFIX ' . $prefix . ': <' . $iri . '> ';
}, array_keys( $this->prefixes ), $this->prefixes ) );
} | php | public function getSPARQL() {
return implode( array_map( function( $prefix, $iri ) {
return 'PREFIX ' . $prefix . ': <' . $iri . '> ';
}, array_keys( $this->prefixes ), $this->prefixes ) );
} | [
"public",
"function",
"getSPARQL",
"(",
")",
"{",
"return",
"implode",
"(",
"array_map",
"(",
"function",
"(",
"$",
"prefix",
",",
"$",
"iri",
")",
"{",
"return",
"'PREFIX '",
".",
"$",
"prefix",
".",
"': <'",
".",
"$",
"iri",
".",
"'> '",
";",
"}",
",",
"array_keys",
"(",
"$",
"this",
"->",
"prefixes",
")",
",",
"$",
"this",
"->",
"prefixes",
")",
")",
";",
"}"
] | Returns the plain SPARQL string of these prefixes.
@return string | [
"Returns",
"the",
"plain",
"SPARQL",
"string",
"of",
"these",
"prefixes",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryPrefixBuilder.php#L68-L72 |
28,662 | Benestar/asparagus | src/QueryFormatter.php | QueryFormatter.format | public function format( $sparql ) {
$this->formattedParts = array();
$this->indentationLevel = 0;
$this->replacements = array();
$regexHelper = new RegexHelper();
$sparql = $regexHelper->escapeSequences( $sparql, $this->replacements );
foreach ( $this->split( $sparql ) as $part ) {
if ( !empty( $this->formattedParts ) ) {
$this->before( $part );
}
$this->indentation( $part );
$this->append( $part );
$this->after( $part );
}
$this->trimEnd();
$this->formattedParts[] = "\n";
return strtr( implode( $this->formattedParts ), $this->replacements );
} | php | public function format( $sparql ) {
$this->formattedParts = array();
$this->indentationLevel = 0;
$this->replacements = array();
$regexHelper = new RegexHelper();
$sparql = $regexHelper->escapeSequences( $sparql, $this->replacements );
foreach ( $this->split( $sparql ) as $part ) {
if ( !empty( $this->formattedParts ) ) {
$this->before( $part );
}
$this->indentation( $part );
$this->append( $part );
$this->after( $part );
}
$this->trimEnd();
$this->formattedParts[] = "\n";
return strtr( implode( $this->formattedParts ), $this->replacements );
} | [
"public",
"function",
"format",
"(",
"$",
"sparql",
")",
"{",
"$",
"this",
"->",
"formattedParts",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"indentationLevel",
"=",
"0",
";",
"$",
"this",
"->",
"replacements",
"=",
"array",
"(",
")",
";",
"$",
"regexHelper",
"=",
"new",
"RegexHelper",
"(",
")",
";",
"$",
"sparql",
"=",
"$",
"regexHelper",
"->",
"escapeSequences",
"(",
"$",
"sparql",
",",
"$",
"this",
"->",
"replacements",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"split",
"(",
"$",
"sparql",
")",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"formattedParts",
")",
")",
"{",
"$",
"this",
"->",
"before",
"(",
"$",
"part",
")",
";",
"}",
"$",
"this",
"->",
"indentation",
"(",
"$",
"part",
")",
";",
"$",
"this",
"->",
"append",
"(",
"$",
"part",
")",
";",
"$",
"this",
"->",
"after",
"(",
"$",
"part",
")",
";",
"}",
"$",
"this",
"->",
"trimEnd",
"(",
")",
";",
"$",
"this",
"->",
"formattedParts",
"[",
"]",
"=",
"\"\\n\"",
";",
"return",
"strtr",
"(",
"implode",
"(",
"$",
"this",
"->",
"formattedParts",
")",
",",
"$",
"this",
"->",
"replacements",
")",
";",
"}"
] | Formats the given SPARQL string.
Note that there have to be spaces before and after brackets and dots.
@param string $sparql
@return string | [
"Formats",
"the",
"given",
"SPARQL",
"string",
".",
"Note",
"that",
"there",
"have",
"to",
"be",
"spaces",
"before",
"and",
"after",
"brackets",
"and",
"dots",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryFormatter.php#L37-L59 |
28,663 | Benestar/asparagus | src/QueryModifierBuilder.php | QueryModifierBuilder.groupBy | public function groupBy( array $expressions ) {
foreach ( $expressions as $expression ) {
$this->expressionValidator->validate( $expression,
ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS
);
}
$expression = implode( ' ', $expressions );
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->modifiers['GROUP BY'] = $expression;
} | php | public function groupBy( array $expressions ) {
foreach ( $expressions as $expression ) {
$this->expressionValidator->validate( $expression,
ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS
);
}
$expression = implode( ' ', $expressions );
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->modifiers['GROUP BY'] = $expression;
} | [
"public",
"function",
"groupBy",
"(",
"array",
"$",
"expressions",
")",
"{",
"foreach",
"(",
"$",
"expressions",
"as",
"$",
"expression",
")",
"{",
"$",
"this",
"->",
"expressionValidator",
"->",
"validate",
"(",
"$",
"expression",
",",
"ExpressionValidator",
"::",
"VALIDATE_VARIABLE",
"|",
"ExpressionValidator",
"::",
"VALIDATE_FUNCTION_AS",
")",
";",
"}",
"$",
"expression",
"=",
"implode",
"(",
"' '",
",",
"$",
"expressions",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedPrefixes",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedVariables",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"modifiers",
"[",
"'GROUP BY'",
"]",
"=",
"$",
"expression",
";",
"}"
] | Sets the GROUP BY modifiers.
@param string[] $expressions | [
"Sets",
"the",
"GROUP",
"BY",
"modifiers",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryModifierBuilder.php#L40-L51 |
28,664 | Benestar/asparagus | src/QueryModifierBuilder.php | QueryModifierBuilder.having | public function having( $expression ) {
$this->expressionValidator->validate( $expression, ExpressionValidator::VALIDATE_FUNCTION );
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->modifiers['HAVING'] = '(' . $expression . ')';
} | php | public function having( $expression ) {
$this->expressionValidator->validate( $expression, ExpressionValidator::VALIDATE_FUNCTION );
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->modifiers['HAVING'] = '(' . $expression . ')';
} | [
"public",
"function",
"having",
"(",
"$",
"expression",
")",
"{",
"$",
"this",
"->",
"expressionValidator",
"->",
"validate",
"(",
"$",
"expression",
",",
"ExpressionValidator",
"::",
"VALIDATE_FUNCTION",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedPrefixes",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedVariables",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"modifiers",
"[",
"'HAVING'",
"]",
"=",
"'('",
".",
"$",
"expression",
".",
"')'",
";",
"}"
] | Sets the HAVING modifier.
@param string $expression | [
"Sets",
"the",
"HAVING",
"modifier",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryModifierBuilder.php#L58-L64 |
28,665 | Benestar/asparagus | src/QueryModifierBuilder.php | QueryModifierBuilder.orderBy | public function orderBy( $expression, $direction = 'ASC' ) {
$direction = strtoupper( $direction );
if ( !in_array( $direction, array( 'ASC', 'DESC' ) ) ) {
throw new InvalidArgumentException( '$direction has to be either ASC or DESC' );
}
$this->expressionValidator->validate( $expression,
ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION
);
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->modifiers['ORDER BY'] = $direction . ' (' . $expression . ')';
} | php | public function orderBy( $expression, $direction = 'ASC' ) {
$direction = strtoupper( $direction );
if ( !in_array( $direction, array( 'ASC', 'DESC' ) ) ) {
throw new InvalidArgumentException( '$direction has to be either ASC or DESC' );
}
$this->expressionValidator->validate( $expression,
ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION
);
$this->usageValidator->trackUsedPrefixes( $expression );
$this->usageValidator->trackUsedVariables( $expression );
$this->modifiers['ORDER BY'] = $direction . ' (' . $expression . ')';
} | [
"public",
"function",
"orderBy",
"(",
"$",
"expression",
",",
"$",
"direction",
"=",
"'ASC'",
")",
"{",
"$",
"direction",
"=",
"strtoupper",
"(",
"$",
"direction",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"direction",
",",
"array",
"(",
"'ASC'",
",",
"'DESC'",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$direction has to be either ASC or DESC'",
")",
";",
"}",
"$",
"this",
"->",
"expressionValidator",
"->",
"validate",
"(",
"$",
"expression",
",",
"ExpressionValidator",
"::",
"VALIDATE_VARIABLE",
"|",
"ExpressionValidator",
"::",
"VALIDATE_FUNCTION",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedPrefixes",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"usageValidator",
"->",
"trackUsedVariables",
"(",
"$",
"expression",
")",
";",
"$",
"this",
"->",
"modifiers",
"[",
"'ORDER BY'",
"]",
"=",
"$",
"direction",
".",
"' ('",
".",
"$",
"expression",
".",
"')'",
";",
"}"
] | Sets the ORDER BY modifier.
@param string $expression
@param string $direction one of ASC or DESC
@throws InvalidArgumentException | [
"Sets",
"the",
"ORDER",
"BY",
"modifier",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryModifierBuilder.php#L73-L86 |
28,666 | Benestar/asparagus | src/QueryModifierBuilder.php | QueryModifierBuilder.getSPARQL | public function getSPARQL() {
$modifiers = $this->modifiers;
return implode( array_map( function( $key ) use ( $modifiers ) {
if ( isset( $modifiers[$key] ) ) {
return ' ' . $key . ' ' . $modifiers[$key];
}
}, array( 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET' ) ) );
} | php | public function getSPARQL() {
$modifiers = $this->modifiers;
return implode( array_map( function( $key ) use ( $modifiers ) {
if ( isset( $modifiers[$key] ) ) {
return ' ' . $key . ' ' . $modifiers[$key];
}
}, array( 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET' ) ) );
} | [
"public",
"function",
"getSPARQL",
"(",
")",
"{",
"$",
"modifiers",
"=",
"$",
"this",
"->",
"modifiers",
";",
"return",
"implode",
"(",
"array_map",
"(",
"function",
"(",
"$",
"key",
")",
"use",
"(",
"$",
"modifiers",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"modifiers",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"' '",
".",
"$",
"key",
".",
"' '",
".",
"$",
"modifiers",
"[",
"$",
"key",
"]",
";",
"}",
"}",
",",
"array",
"(",
"'GROUP BY'",
",",
"'HAVING'",
",",
"'ORDER BY'",
",",
"'LIMIT'",
",",
"'OFFSET'",
")",
")",
")",
";",
"}"
] | Returns the plain SPARQL string of these modifiers.
@return string | [
"Returns",
"the",
"plain",
"SPARQL",
"string",
"of",
"these",
"modifiers",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryModifierBuilder.php#L121-L128 |
28,667 | Benestar/asparagus | src/ExpressionValidator.php | ExpressionValidator.validate | public function validate( $expression, $options ) {
if ( !is_string( $expression ) ) {
throw new InvalidArgumentException( '$expression has to be a string.' );
}
if ( !$this->matches( $expression, $options ) ) {
throw new InvalidArgumentException( '$expression has to be a ' .
implode( ' or a ', $this->getOptionNames( $options ) ) . ', got ' . $expression
);
}
} | php | public function validate( $expression, $options ) {
if ( !is_string( $expression ) ) {
throw new InvalidArgumentException( '$expression has to be a string.' );
}
if ( !$this->matches( $expression, $options ) ) {
throw new InvalidArgumentException( '$expression has to be a ' .
implode( ' or a ', $this->getOptionNames( $options ) ) . ', got ' . $expression
);
}
} | [
"public",
"function",
"validate",
"(",
"$",
"expression",
",",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"expression",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$expression has to be a string.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"matches",
"(",
"$",
"expression",
",",
"$",
"options",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$expression has to be a '",
".",
"implode",
"(",
"' or a '",
",",
"$",
"this",
"->",
"getOptionNames",
"(",
"$",
"options",
")",
")",
".",
"', got '",
".",
"$",
"expression",
")",
";",
"}",
"}"
] | Validates the given expression and tracks it.
VALIDATE_PREFIX won't track prefixes.
@param string $expression
@param int $options
@throws InvalidArgumentException | [
"Validates",
"the",
"given",
"expression",
"and",
"tracks",
"it",
".",
"VALIDATE_PREFIX",
"won",
"t",
"track",
"prefixes",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/ExpressionValidator.php#L77-L87 |
28,668 | Benestar/asparagus | src/UsageValidator.php | UsageValidator.trackUsedVariables | public function trackUsedVariables( $variables ) {
if ( !is_array( $variables ) ) {
$variables = $this->matchVariables( $variables );
}
$this->usedVariables = array_unique( array_merge( $this->usedVariables, $variables ) );
} | php | public function trackUsedVariables( $variables ) {
if ( !is_array( $variables ) ) {
$variables = $this->matchVariables( $variables );
}
$this->usedVariables = array_unique( array_merge( $this->usedVariables, $variables ) );
} | [
"public",
"function",
"trackUsedVariables",
"(",
"$",
"variables",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"variables",
"=",
"$",
"this",
"->",
"matchVariables",
"(",
"$",
"variables",
")",
";",
"}",
"$",
"this",
"->",
"usedVariables",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"usedVariables",
",",
"$",
"variables",
")",
")",
";",
"}"
] | Trackes the list of variables as used.
@param string[]|string $variables list of variables without prefixes | [
"Trackes",
"the",
"list",
"of",
"variables",
"as",
"used",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/UsageValidator.php#L49-L55 |
28,669 | Benestar/asparagus | src/UsageValidator.php | UsageValidator.trackDefinedVariables | public function trackDefinedVariables( $variables ) {
if ( !is_array( $variables ) ) {
$variables = $this->matchVariables( $variables );
}
$this->definedVariables = array_unique( array_merge( $this->definedVariables, $variables ) );
} | php | public function trackDefinedVariables( $variables ) {
if ( !is_array( $variables ) ) {
$variables = $this->matchVariables( $variables );
}
$this->definedVariables = array_unique( array_merge( $this->definedVariables, $variables ) );
} | [
"public",
"function",
"trackDefinedVariables",
"(",
"$",
"variables",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"variables",
"=",
"$",
"this",
"->",
"matchVariables",
"(",
"$",
"variables",
")",
";",
"}",
"$",
"this",
"->",
"definedVariables",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"definedVariables",
",",
"$",
"variables",
")",
")",
";",
"}"
] | Trackes the list of variables as defined.
@param string[]|string $variables list of variables without prefixes | [
"Trackes",
"the",
"list",
"of",
"variables",
"as",
"defined",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/UsageValidator.php#L62-L68 |
28,670 | Benestar/asparagus | src/UsageValidator.php | UsageValidator.trackUsedPrefixes | public function trackUsedPrefixes( $prefixes ) {
if ( !is_array( $prefixes ) ) {
$prefixes = $this->matchPrefixes( $prefixes );
}
$this->usedPrefixes = array_merge( $this->usedPrefixes, $prefixes );
} | php | public function trackUsedPrefixes( $prefixes ) {
if ( !is_array( $prefixes ) ) {
$prefixes = $this->matchPrefixes( $prefixes );
}
$this->usedPrefixes = array_merge( $this->usedPrefixes, $prefixes );
} | [
"public",
"function",
"trackUsedPrefixes",
"(",
"$",
"prefixes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"prefixes",
")",
")",
"{",
"$",
"prefixes",
"=",
"$",
"this",
"->",
"matchPrefixes",
"(",
"$",
"prefixes",
")",
";",
"}",
"$",
"this",
"->",
"usedPrefixes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"usedPrefixes",
",",
"$",
"prefixes",
")",
";",
"}"
] | Trackes the list of prefixes as used.
@param string[]|string $prefixes list of prefixes | [
"Trackes",
"the",
"list",
"of",
"prefixes",
"as",
"used",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/UsageValidator.php#L75-L81 |
28,671 | Benestar/asparagus | src/UsageValidator.php | UsageValidator.trackDefinedPrefixes | public function trackDefinedPrefixes( $prefixes ) {
if ( !is_array( $prefixes ) ) {
$prefixes = $this->matchPrefixes( $prefixes );
}
$this->definedPrefixes = array_merge( $this->definedPrefixes, $prefixes );
} | php | public function trackDefinedPrefixes( $prefixes ) {
if ( !is_array( $prefixes ) ) {
$prefixes = $this->matchPrefixes( $prefixes );
}
$this->definedPrefixes = array_merge( $this->definedPrefixes, $prefixes );
} | [
"public",
"function",
"trackDefinedPrefixes",
"(",
"$",
"prefixes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"prefixes",
")",
")",
"{",
"$",
"prefixes",
"=",
"$",
"this",
"->",
"matchPrefixes",
"(",
"$",
"prefixes",
")",
";",
"}",
"$",
"this",
"->",
"definedPrefixes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"definedPrefixes",
",",
"$",
"prefixes",
")",
";",
"}"
] | Trackes the list of prefixes as defined.
@param string[]|string $prefixes list of prefixes | [
"Trackes",
"the",
"list",
"of",
"prefixes",
"as",
"defined",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/UsageValidator.php#L88-L94 |
28,672 | Benestar/asparagus | src/QueryExecuter.php | QueryExecuter.execute | public function execute( $query ) {
if ( $query instanceof QueryBuilder ) {
$query = $query->getSPARQL();
}
if ( !is_string( $query ) ) {
throw new InvalidArgumentException( '$query has to be a string or an instance of QueryBuilder' );
}
$result = $this->getResult( $query );
// TODO also support ask queries (with key 'boolean')
// https://www.w3.org/TR/rdf-sparql-json-res/
return $result['results'];
} | php | public function execute( $query ) {
if ( $query instanceof QueryBuilder ) {
$query = $query->getSPARQL();
}
if ( !is_string( $query ) ) {
throw new InvalidArgumentException( '$query has to be a string or an instance of QueryBuilder' );
}
$result = $this->getResult( $query );
// TODO also support ask queries (with key 'boolean')
// https://www.w3.org/TR/rdf-sparql-json-res/
return $result['results'];
} | [
"public",
"function",
"execute",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"instanceof",
"QueryBuilder",
")",
"{",
"$",
"query",
"=",
"$",
"query",
"->",
"getSPARQL",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"query",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$query has to be a string or an instance of QueryBuilder'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"getResult",
"(",
"$",
"query",
")",
";",
"// TODO also support ask queries (with key 'boolean')",
"// https://www.w3.org/TR/rdf-sparql-json-res/",
"return",
"$",
"result",
"[",
"'results'",
"]",
";",
"}"
] | Executes the given SPARQL query.
@param string|QueryBuilder $query
@return array
@throws InvalidArgumentException
@throws RangeException
@throws RuntimeException | [
"Executes",
"the",
"given",
"SPARQL",
"query",
"."
] | 6299517dc28ace1e5934a0b09a2ac6d8a2910032 | https://github.com/Benestar/asparagus/blob/6299517dc28ace1e5934a0b09a2ac6d8a2910032/src/QueryExecuter.php#L58-L72 |
28,673 | flash-global/logger-client | src/Builder/SearchBuilder.php | SearchBuilder.contextCondition | public function contextCondition($type = 'AND')
{
$type = strtoupper($type);
if (!in_array($type, ['AND', 'OR'])) {
throw new LoggerException('Type has to be either "AND" or "OR"!');
}
$params = $this->getParams();
$params['context_condition'] = $type;
$this->setParams($params);
return $this;
} | php | public function contextCondition($type = 'AND')
{
$type = strtoupper($type);
if (!in_array($type, ['AND', 'OR'])) {
throw new LoggerException('Type has to be either "AND" or "OR"!');
}
$params = $this->getParams();
$params['context_condition'] = $type;
$this->setParams($params);
return $this;
} | [
"public",
"function",
"contextCondition",
"(",
"$",
"type",
"=",
"'AND'",
")",
"{",
"$",
"type",
"=",
"strtoupper",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"[",
"'AND'",
",",
"'OR'",
"]",
")",
")",
"{",
"throw",
"new",
"LoggerException",
"(",
"'Type has to be either \"AND\" or \"OR\"!'",
")",
";",
"}",
"$",
"params",
"=",
"$",
"this",
"->",
"getParams",
"(",
")",
";",
"$",
"params",
"[",
"'context_condition'",
"]",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the condition type for the contexts
@param string $type
@return $this | [
"Set",
"the",
"condition",
"type",
"for",
"the",
"contexts"
] | f17f913a4adc04fa8648e474105e6c43e0d6384d | https://github.com/flash-global/logger-client/blob/f17f913a4adc04fa8648e474105e6c43e0d6384d/src/Builder/SearchBuilder.php#L106-L120 |
28,674 | flash-global/logger-client | src/Logger.php | Logger.registerErrorHandler | protected function registerErrorHandler()
{
$instance = $this;
$this->previousErrorHandler = set_error_handler(
function ($errno, $errstr, $errfile, $errline) use ($instance) {
$message = sprintf('%d: %s - File: %s - Line: %d', $errno, $errstr, $errfile, $errline);
throw new \Exception($message, $errno);
}
);
} | php | protected function registerErrorHandler()
{
$instance = $this;
$this->previousErrorHandler = set_error_handler(
function ($errno, $errstr, $errfile, $errline) use ($instance) {
$message = sprintf('%d: %s - File: %s - Line: %d', $errno, $errstr, $errfile, $errline);
throw new \Exception($message, $errno);
}
);
} | [
"protected",
"function",
"registerErrorHandler",
"(",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"previousErrorHandler",
"=",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"use",
"(",
"$",
"instance",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%d: %s - File: %s - Line: %d'",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"message",
",",
"$",
"errno",
")",
";",
"}",
")",
";",
"}"
] | Add a error handler | [
"Add",
"a",
"error",
"handler"
] | f17f913a4adc04fa8648e474105e6c43e0d6384d | https://github.com/flash-global/logger-client/blob/f17f913a4adc04fa8648e474105e6c43e0d6384d/src/Logger.php#L201-L210 |
28,675 | flash-global/logger-client | src/Logger.php | Logger.writeToExceptionLogFile | protected function writeToExceptionLogFile($message)
{
if (is_writable($this->exceptionLogFile) || is_writable(dirname($this->exceptionLogFile))) {
$message = sprintf('[%s] %s' . PHP_EOL, (new \DateTime())->format(\DateTime::ISO8601), $message);
@file_put_contents($this->exceptionLogFile, $message, FILE_APPEND);
}
} | php | protected function writeToExceptionLogFile($message)
{
if (is_writable($this->exceptionLogFile) || is_writable(dirname($this->exceptionLogFile))) {
$message = sprintf('[%s] %s' . PHP_EOL, (new \DateTime())->format(\DateTime::ISO8601), $message);
@file_put_contents($this->exceptionLogFile, $message, FILE_APPEND);
}
} | [
"protected",
"function",
"writeToExceptionLogFile",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"is_writable",
"(",
"$",
"this",
"->",
"exceptionLogFile",
")",
"||",
"is_writable",
"(",
"dirname",
"(",
"$",
"this",
"->",
"exceptionLogFile",
")",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'[%s] %s'",
".",
"PHP_EOL",
",",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
",",
"$",
"message",
")",
";",
"@",
"file_put_contents",
"(",
"$",
"this",
"->",
"exceptionLogFile",
",",
"$",
"message",
",",
"FILE_APPEND",
")",
";",
"}",
"}"
] | Write to exception log file
@param string $message | [
"Write",
"to",
"exception",
"log",
"file"
] | f17f913a4adc04fa8648e474105e6c43e0d6384d | https://github.com/flash-global/logger-client/blob/f17f913a4adc04fa8648e474105e6c43e0d6384d/src/Logger.php#L282-L288 |
28,676 | vend/php-resque | src/Failure/RedisBackend.php | RedisBackend.getBacktrace | protected function getBacktrace(\Exception $exception)
{
$backtrace = array();
$backtrace[] = '---';
$backtrace[] = $this->getErrorMessage($exception);
$backtrace[] = '---';
// Allow marshalling of the trace: PHP marks getTraceAsString as final :-(
if (method_exists($exception, 'getPreviousTraceAsString')) {
$backtrace = array_merge($backtrace, explode("\n", $exception->getPreviousTraceAsString()));
} else {
$backtrace = array_merge($backtrace, explode("\n", $exception->getTraceAsString()));
}
if (($previous = $exception->getPrevious())) {
$backtrace = array_merge($backtrace, $this->getBacktrace($previous)); // Recurse
}
return $backtrace;
} | php | protected function getBacktrace(\Exception $exception)
{
$backtrace = array();
$backtrace[] = '---';
$backtrace[] = $this->getErrorMessage($exception);
$backtrace[] = '---';
// Allow marshalling of the trace: PHP marks getTraceAsString as final :-(
if (method_exists($exception, 'getPreviousTraceAsString')) {
$backtrace = array_merge($backtrace, explode("\n", $exception->getPreviousTraceAsString()));
} else {
$backtrace = array_merge($backtrace, explode("\n", $exception->getTraceAsString()));
}
if (($previous = $exception->getPrevious())) {
$backtrace = array_merge($backtrace, $this->getBacktrace($previous)); // Recurse
}
return $backtrace;
} | [
"protected",
"function",
"getBacktrace",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"$",
"backtrace",
"=",
"array",
"(",
")",
";",
"$",
"backtrace",
"[",
"]",
"=",
"'---'",
";",
"$",
"backtrace",
"[",
"]",
"=",
"$",
"this",
"->",
"getErrorMessage",
"(",
"$",
"exception",
")",
";",
"$",
"backtrace",
"[",
"]",
"=",
"'---'",
";",
"// Allow marshalling of the trace: PHP marks getTraceAsString as final :-(",
"if",
"(",
"method_exists",
"(",
"$",
"exception",
",",
"'getPreviousTraceAsString'",
")",
")",
"{",
"$",
"backtrace",
"=",
"array_merge",
"(",
"$",
"backtrace",
",",
"explode",
"(",
"\"\\n\"",
",",
"$",
"exception",
"->",
"getPreviousTraceAsString",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"backtrace",
"=",
"array_merge",
"(",
"$",
"backtrace",
",",
"explode",
"(",
"\"\\n\"",
",",
"$",
"exception",
"->",
"getTraceAsString",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"(",
"$",
"previous",
"=",
"$",
"exception",
"->",
"getPrevious",
"(",
")",
")",
")",
"{",
"$",
"backtrace",
"=",
"array_merge",
"(",
"$",
"backtrace",
",",
"$",
"this",
"->",
"getBacktrace",
"(",
"$",
"previous",
")",
")",
";",
"// Recurse",
"}",
"return",
"$",
"backtrace",
";",
"}"
] | Gets the backtrace for the exception
The backtrace area is the only part of the failure that's shown on
multiple lines by resque-web. So, we'll also use it to mention the
wrapping exceptions.
@param \Exception $exception
@return array | [
"Gets",
"the",
"backtrace",
"for",
"the",
"exception"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Failure/RedisBackend.php#L51-L71 |
28,677 | vend/php-resque | src/Failure/RedisBackend.php | RedisBackend.getDistalCause | protected function getDistalCause(\Exception $exception)
{
if (($previous = $exception->getPrevious())) {
return $this->getDistalCause($previous);
}
return $exception;
} | php | protected function getDistalCause(\Exception $exception)
{
if (($previous = $exception->getPrevious())) {
return $this->getDistalCause($previous);
}
return $exception;
} | [
"protected",
"function",
"getDistalCause",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"if",
"(",
"(",
"$",
"previous",
"=",
"$",
"exception",
"->",
"getPrevious",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getDistalCause",
"(",
"$",
"previous",
")",
";",
"}",
"return",
"$",
"exception",
";",
"}"
] | Find the ultimate cause exception, by following previous members right back
@param Exception $exception
@return Exception | [
"Find",
"the",
"ultimate",
"cause",
"exception",
"by",
"following",
"previous",
"members",
"right",
"back"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Failure/RedisBackend.php#L79-L85 |
28,678 | vend/php-resque | src/Failure/RedisBackend.php | RedisBackend.getClass | protected function getClass(\Exception $exception)
{
$message = '';
if (($previous = $exception->getPrevious())) {
$message = $this->getClass($previous) . ' < '; // Recurse
}
// Let the exception lie about its class: to support marshalling exceptions
if (method_exists($exception, 'getClass')) {
$message .= $exception->getClass();
} else {
$message .= get_class($exception);
}
return $message;
} | php | protected function getClass(\Exception $exception)
{
$message = '';
if (($previous = $exception->getPrevious())) {
$message = $this->getClass($previous) . ' < '; // Recurse
}
// Let the exception lie about its class: to support marshalling exceptions
if (method_exists($exception, 'getClass')) {
$message .= $exception->getClass();
} else {
$message .= get_class($exception);
}
return $message;
} | [
"protected",
"function",
"getClass",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"$",
"message",
"=",
"''",
";",
"if",
"(",
"(",
"$",
"previous",
"=",
"$",
"exception",
"->",
"getPrevious",
"(",
")",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"getClass",
"(",
"$",
"previous",
")",
".",
"' < '",
";",
"// Recurse",
"}",
"// Let the exception lie about its class: to support marshalling exceptions",
"if",
"(",
"method_exists",
"(",
"$",
"exception",
",",
"'getClass'",
")",
")",
"{",
"$",
"message",
".=",
"$",
"exception",
"->",
"getClass",
"(",
")",
";",
"}",
"else",
"{",
"$",
"message",
".=",
"get_class",
"(",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
] | Find the class names of the exceptions
@param Exception $exception
@return string | [
"Find",
"the",
"class",
"names",
"of",
"the",
"exceptions"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Failure/RedisBackend.php#L93-L109 |
28,679 | vend/php-resque | src/Job/Status.php | Status.setAttributes | public function setAttributes(array $attributes)
{
$this->attributes = array_merge($this->attributes, $attributes);
$set = array();
foreach ($attributes as $name => $value) {
if ($name == 'status') {
$this->update($value);
continue;
}
$set[$name] = $value;
}
return call_user_func(array($this->client, 'hmset'), $this->getHashKey(), $set);
} | php | public function setAttributes(array $attributes)
{
$this->attributes = array_merge($this->attributes, $attributes);
$set = array();
foreach ($attributes as $name => $value) {
if ($name == 'status') {
$this->update($value);
continue;
}
$set[$name] = $value;
}
return call_user_func(array($this->client, 'hmset'), $this->getHashKey(), $set);
} | [
"public",
"function",
"setAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"attributes",
")",
";",
"$",
"set",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"'status'",
")",
"{",
"$",
"this",
"->",
"update",
"(",
"$",
"value",
")",
";",
"continue",
";",
"}",
"$",
"set",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"client",
",",
"'hmset'",
")",
",",
"$",
"this",
"->",
"getHashKey",
"(",
")",
",",
"$",
"set",
")",
";",
"}"
] | Sets all the given attributes
@param array<string,mixed> $attributes
@return mixed | [
"Sets",
"all",
"the",
"given",
"attributes"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Job/Status.php#L142-L156 |
28,680 | vend/php-resque | src/Job/Status.php | Status.incrementAttribute | public function incrementAttribute($name, $by = 1)
{
$pipeline = $this->client->pipeline();
$pipeline->hincrby($this->getHashKey(), $name, $by);
$pipeline->hset($this->getHashKey(), 'updated', time());
$result = $pipeline->execute();
return $this->attributes[$name] = $result[0];
} | php | public function incrementAttribute($name, $by = 1)
{
$pipeline = $this->client->pipeline();
$pipeline->hincrby($this->getHashKey(), $name, $by);
$pipeline->hset($this->getHashKey(), 'updated', time());
$result = $pipeline->execute();
return $this->attributes[$name] = $result[0];
} | [
"public",
"function",
"incrementAttribute",
"(",
"$",
"name",
",",
"$",
"by",
"=",
"1",
")",
"{",
"$",
"pipeline",
"=",
"$",
"this",
"->",
"client",
"->",
"pipeline",
"(",
")",
";",
"$",
"pipeline",
"->",
"hincrby",
"(",
"$",
"this",
"->",
"getHashKey",
"(",
")",
",",
"$",
"name",
",",
"$",
"by",
")",
";",
"$",
"pipeline",
"->",
"hset",
"(",
"$",
"this",
"->",
"getHashKey",
"(",
")",
",",
"'updated'",
",",
"time",
"(",
")",
")",
";",
"$",
"result",
"=",
"$",
"pipeline",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"result",
"[",
"0",
"]",
";",
"}"
] | Increments an attribute
The attribute should be an integer field
@param string $name
@param integer $by
@return integer The value after incrementing (see hincrby) | [
"Increments",
"an",
"attribute"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Job/Status.php#L186-L194 |
28,681 | vend/php-resque | src/Job/Status.php | Status.load | public function load()
{
if ($this->loaded) {
throw new \LogicException('The status is already loaded. Use another instance.');
}
$this->attributes = array_merge($this->attributes, $this->client->hgetall($this->getHashKey()));
$this->loaded = true;
} | php | public function load()
{
if ($this->loaded) {
throw new \LogicException('The status is already loaded. Use another instance.');
}
$this->attributes = array_merge($this->attributes, $this->client->hgetall($this->getHashKey()));
$this->loaded = true;
} | [
"public",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loaded",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The status is already loaded. Use another instance.'",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"client",
"->",
"hgetall",
"(",
"$",
"this",
"->",
"getHashKey",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"loaded",
"=",
"true",
";",
"}"
] | Loads all status attributes
@throws LogicException | [
"Loads",
"all",
"status",
"attributes"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Job/Status.php#L256-L264 |
28,682 | vend/php-resque | src/Job/Status.php | Status.getAttribute | public function getAttribute($name, $default = null)
{
if ($this->loaded) {
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
}
// Could be just hget, but Credis will return false?!
$attributes = $this->client->hGetAll($this->getHashKey());
return isset($attributes[$name]) ? $attributes[$name] : $default;
} | php | public function getAttribute($name, $default = null)
{
if ($this->loaded) {
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
}
// Could be just hget, but Credis will return false?!
$attributes = $this->client->hGetAll($this->getHashKey());
return isset($attributes[$name]) ? $attributes[$name] : $default;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loaded",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}",
"// Could be just hget, but Credis will return false?!",
"$",
"attributes",
"=",
"$",
"this",
"->",
"client",
"->",
"hGetAll",
"(",
"$",
"this",
"->",
"getHashKey",
"(",
")",
")",
";",
"return",
"isset",
"(",
"$",
"attributes",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"attributes",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
] | Gets a single attribute value
@param string $name
@param mixed $default
@return mixed | [
"Gets",
"a",
"single",
"attribute",
"value"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Job/Status.php#L328-L337 |
28,683 | vend/php-resque | src/Console/ConsoleRunner.php | ConsoleRunner.createHelperSet | public static function createHelperSet($client, LoggerInterface $logger = null)
{
$helper = new HelperSet();
$helper->set(new RedisHelper($client));
if ($logger) {
$helper->set(new LoggerHelper($logger));
}
return $helper;
} | php | public static function createHelperSet($client, LoggerInterface $logger = null)
{
$helper = new HelperSet();
$helper->set(new RedisHelper($client));
if ($logger) {
$helper->set(new LoggerHelper($logger));
}
return $helper;
} | [
"public",
"static",
"function",
"createHelperSet",
"(",
"$",
"client",
",",
"LoggerInterface",
"$",
"logger",
"=",
"null",
")",
"{",
"$",
"helper",
"=",
"new",
"HelperSet",
"(",
")",
";",
"$",
"helper",
"->",
"set",
"(",
"new",
"RedisHelper",
"(",
"$",
"client",
")",
")",
";",
"if",
"(",
"$",
"logger",
")",
"{",
"$",
"helper",
"->",
"set",
"(",
"new",
"LoggerHelper",
"(",
"$",
"logger",
")",
")",
";",
"}",
"return",
"$",
"helper",
";",
"}"
] | Creates a helper set for the console component
A convenience method (you could always define your own HelperSet separately). Useful for writing cli-config.php.
@param ClientInterface $client Redis connection
@param \Psr\Log\LoggerInterface $logger Optional logger
@return HelperSet | [
"Creates",
"a",
"helper",
"set",
"for",
"the",
"console",
"component"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Console/ConsoleRunner.php#L24-L34 |
28,684 | vend/php-resque | src/Console/ConsoleRunner.php | ConsoleRunner.run | public static function run(HelperSet $helperSet)
{
$application = new Application('Resque Console Tool', Version::VERSION);
$application->setCatchExceptions(true);
$application->setHelperSet($helperSet);
$application->add(new QueueListCommand());
$application->add(new QueueClearCommand());
$application->add(new EnqueueCommand());
$application->add(new WorkerCommand());
return $application->run();
} | php | public static function run(HelperSet $helperSet)
{
$application = new Application('Resque Console Tool', Version::VERSION);
$application->setCatchExceptions(true);
$application->setHelperSet($helperSet);
$application->add(new QueueListCommand());
$application->add(new QueueClearCommand());
$application->add(new EnqueueCommand());
$application->add(new WorkerCommand());
return $application->run();
} | [
"public",
"static",
"function",
"run",
"(",
"HelperSet",
"$",
"helperSet",
")",
"{",
"$",
"application",
"=",
"new",
"Application",
"(",
"'Resque Console Tool'",
",",
"Version",
"::",
"VERSION",
")",
";",
"$",
"application",
"->",
"setCatchExceptions",
"(",
"true",
")",
";",
"$",
"application",
"->",
"setHelperSet",
"(",
"$",
"helperSet",
")",
";",
"$",
"application",
"->",
"add",
"(",
"new",
"QueueListCommand",
"(",
")",
")",
";",
"$",
"application",
"->",
"add",
"(",
"new",
"QueueClearCommand",
"(",
")",
")",
";",
"$",
"application",
"->",
"add",
"(",
"new",
"EnqueueCommand",
"(",
")",
")",
";",
"$",
"application",
"->",
"add",
"(",
"new",
"WorkerCommand",
"(",
")",
")",
";",
"return",
"$",
"application",
"->",
"run",
"(",
")",
";",
"}"
] | Runs the application using the given HelperSet
This method is responsible for creating the console application, adding
relevant commands, and running it. Other code is responsible for producing
the HelperSet itself (your cli-config.php or bootstrap code), and for
calling this method (the actual bin command file).
@param HelperSet $helperSet
@return integer 0 if everything went fine, or an error code | [
"Runs",
"the",
"application",
"using",
"the",
"given",
"HelperSet"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Console/ConsoleRunner.php#L47-L59 |
28,685 | vend/php-resque | src/Resque.php | Resque.reconnect | public function reconnect()
{
if ($this->client->isConnected()) {
$this->client->disconnect();
}
$this->client->connect();
} | php | public function reconnect()
{
if ($this->client->isConnected()) {
$this->client->disconnect();
}
$this->client->connect();
} | [
"public",
"function",
"reconnect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"client",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"disconnect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"client",
"->",
"connect",
"(",
")",
";",
"}"
] | Causes the client to reconnect to the Redis server
@return void | [
"Causes",
"the",
"client",
"to",
"reconnect",
"to",
"the",
"Redis",
"server"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Resque.php#L145-L151 |
28,686 | vend/php-resque | src/Resque.php | Resque.clearQueue | public function clearQueue($queue)
{
$this->getClient()->del($this->getKey(self::QUEUE_KEY . $queue));
} | php | public function clearQueue($queue)
{
$this->getClient()->del($this->getKey(self::QUEUE_KEY . $queue));
} | [
"public",
"function",
"clearQueue",
"(",
"$",
"queue",
")",
"{",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"del",
"(",
"$",
"this",
"->",
"getKey",
"(",
"self",
"::",
"QUEUE_KEY",
".",
"$",
"queue",
")",
")",
";",
"}"
] | Clears the whole of a queue
@param string $queue | [
"Clears",
"the",
"whole",
"of",
"a",
"queue"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Resque.php#L231-L234 |
28,687 | vend/php-resque | src/Worker.php | Worker.configure | protected function configure(array $options)
{
$this->options = array_merge(array(
'server_name' => null,
'pid' => null,
'ps' => '/bin/ps',
'ps_args' => array('-o', 'pid,state', '-p'),
'id_format' => '%s:%d:%s',
'id_location_preg' => '/^([^:]+?):([0-9]+):/',
'shuffle_queues' => true,
'sort_queues' => false
), $options);
if (!$this->options['server_name']) {
$this->options['server_name'] = function_exists('gethostname') ? gethostname() : php_uname('n');
}
if (!$this->options['pid']) {
$this->options['pid'] = getmypid();
}
} | php | protected function configure(array $options)
{
$this->options = array_merge(array(
'server_name' => null,
'pid' => null,
'ps' => '/bin/ps',
'ps_args' => array('-o', 'pid,state', '-p'),
'id_format' => '%s:%d:%s',
'id_location_preg' => '/^([^:]+?):([0-9]+):/',
'shuffle_queues' => true,
'sort_queues' => false
), $options);
if (!$this->options['server_name']) {
$this->options['server_name'] = function_exists('gethostname') ? gethostname() : php_uname('n');
}
if (!$this->options['pid']) {
$this->options['pid'] = getmypid();
}
} | [
"protected",
"function",
"configure",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"array",
"(",
"'server_name'",
"=>",
"null",
",",
"'pid'",
"=>",
"null",
",",
"'ps'",
"=>",
"'/bin/ps'",
",",
"'ps_args'",
"=>",
"array",
"(",
"'-o'",
",",
"'pid,state'",
",",
"'-p'",
")",
",",
"'id_format'",
"=>",
"'%s:%d:%s'",
",",
"'id_location_preg'",
"=>",
"'/^([^:]+?):([0-9]+):/'",
",",
"'shuffle_queues'",
"=>",
"true",
",",
"'sort_queues'",
"=>",
"false",
")",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"options",
"[",
"'server_name'",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'server_name'",
"]",
"=",
"function_exists",
"(",
"'gethostname'",
")",
"?",
"gethostname",
"(",
")",
":",
"php_uname",
"(",
"'n'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"options",
"[",
"'pid'",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'pid'",
"]",
"=",
"getmypid",
"(",
")",
";",
"}",
"}"
] | Configures options for the worker
@param array<string,mixed> $options
Including
Worker identification
- server_name => string, default is FQDN hostname
- pid => int, default is current PID
- id_format => string, suitable for sprintf
- id_location_preg => string, Perl compat regex, gets hostname and PID
out of worker ID
- shuffle_queues => bool, whether to shuffle the queues on reserve, so we evenly check all queues
- sort_queues => bool, whether to check the queues in alphabetical order (mutually exclusive with shuffle_queues) | [
"Configures",
"options",
"for",
"the",
"worker"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Worker.php#L122-L142 |
28,688 | vend/php-resque | src/Worker.php | Worker.configureId | protected function configureId()
{
$this->id = sprintf(
$this->options['id_format'],
$this->options['server_name'],
$this->options['pid'],
implode(',', $this->queues)
);
} | php | protected function configureId()
{
$this->id = sprintf(
$this->options['id_format'],
$this->options['server_name'],
$this->options['pid'],
implode(',', $this->queues)
);
} | [
"protected",
"function",
"configureId",
"(",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"options",
"[",
"'id_format'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'server_name'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'pid'",
"]",
",",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"queues",
")",
")",
";",
"}"
] | Configures the ID of this worker | [
"Configures",
"the",
"ID",
"of",
"this",
"worker"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Worker.php#L147-L155 |
28,689 | vend/php-resque | src/Worker.php | Worker.getLocation | protected function getLocation()
{
$matches = array();
if (!preg_match($this->options['id_location_preg'], $this->getId(), $matches)) {
throw new Exception('Incompatible ID format: unable to determine worker location');
}
if (!isset($matches[1]) || !$matches[1]) {
throw new Exception('Invalid ID: invalid hostname');
}
if (!isset($matches[2]) || !$matches[2] || !is_numeric($matches[2])) {
throw new Exception('Invalid ID: invalid PID');
}
return array($matches[1], (int)$matches[2]);
} | php | protected function getLocation()
{
$matches = array();
if (!preg_match($this->options['id_location_preg'], $this->getId(), $matches)) {
throw new Exception('Incompatible ID format: unable to determine worker location');
}
if (!isset($matches[1]) || !$matches[1]) {
throw new Exception('Invalid ID: invalid hostname');
}
if (!isset($matches[2]) || !$matches[2] || !is_numeric($matches[2])) {
throw new Exception('Invalid ID: invalid PID');
}
return array($matches[1], (int)$matches[2]);
} | [
"protected",
"function",
"getLocation",
"(",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"this",
"->",
"options",
"[",
"'id_location_preg'",
"]",
",",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Incompatible ID format: unable to determine worker location'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"||",
"!",
"$",
"matches",
"[",
"1",
"]",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid ID: invalid hostname'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"||",
"!",
"$",
"matches",
"[",
"2",
"]",
"||",
"!",
"is_numeric",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid ID: invalid PID'",
")",
";",
"}",
"return",
"array",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"(",
"int",
")",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"}"
] | Parses a hostname and PID out of a string worker ID
If you change the format of the ID, you should also change the definition
of this method.
This method *always* parses the ID of the worker, rather than figuring out
the current processes' PID/hostname. This means you can use setId() to
interrogate the properties of other workers given their ID.
@throws Exception
@return array<string,int> | [
"Parses",
"a",
"hostname",
"and",
"PID",
"out",
"of",
"a",
"string",
"worker",
"ID"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Worker.php#L206-L223 |
28,690 | vend/php-resque | src/Worker.php | Worker.failJob | protected function failJob($job, Exception $exception)
{
if ($job instanceof JobInterface) {
$payload = $job->getPayload();
$queue = $job->getQueue();
} else {
$payload = $job;
$queue = isset($job['queue']) ? $job['queue'] : null;
}
$id = isset($job['id']) ? $job['id'] : null;
if ($id) {
try {
$status = $this->resque->getStatusFactory()->forId($id);
$status->update(Status::STATUS_FAILED);
} catch (JobIdException $e) {
$this->logger->warning($e);
}
} // else no status to update
$this->resque->getFailureBackend()->receiveFailure(
$payload,
$exception,
$this,
$queue
);
$this->getResque()->getStatistic('failed')->incr();
$this->getStatistic('failed')->incr();
} | php | protected function failJob($job, Exception $exception)
{
if ($job instanceof JobInterface) {
$payload = $job->getPayload();
$queue = $job->getQueue();
} else {
$payload = $job;
$queue = isset($job['queue']) ? $job['queue'] : null;
}
$id = isset($job['id']) ? $job['id'] : null;
if ($id) {
try {
$status = $this->resque->getStatusFactory()->forId($id);
$status->update(Status::STATUS_FAILED);
} catch (JobIdException $e) {
$this->logger->warning($e);
}
} // else no status to update
$this->resque->getFailureBackend()->receiveFailure(
$payload,
$exception,
$this,
$queue
);
$this->getResque()->getStatistic('failed')->incr();
$this->getStatistic('failed')->incr();
} | [
"protected",
"function",
"failJob",
"(",
"$",
"job",
",",
"Exception",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"job",
"instanceof",
"JobInterface",
")",
"{",
"$",
"payload",
"=",
"$",
"job",
"->",
"getPayload",
"(",
")",
";",
"$",
"queue",
"=",
"$",
"job",
"->",
"getQueue",
"(",
")",
";",
"}",
"else",
"{",
"$",
"payload",
"=",
"$",
"job",
";",
"$",
"queue",
"=",
"isset",
"(",
"$",
"job",
"[",
"'queue'",
"]",
")",
"?",
"$",
"job",
"[",
"'queue'",
"]",
":",
"null",
";",
"}",
"$",
"id",
"=",
"isset",
"(",
"$",
"job",
"[",
"'id'",
"]",
")",
"?",
"$",
"job",
"[",
"'id'",
"]",
":",
"null",
";",
"if",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"resque",
"->",
"getStatusFactory",
"(",
")",
"->",
"forId",
"(",
"$",
"id",
")",
";",
"$",
"status",
"->",
"update",
"(",
"Status",
"::",
"STATUS_FAILED",
")",
";",
"}",
"catch",
"(",
"JobIdException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"$",
"e",
")",
";",
"}",
"}",
"// else no status to update",
"$",
"this",
"->",
"resque",
"->",
"getFailureBackend",
"(",
")",
"->",
"receiveFailure",
"(",
"$",
"payload",
",",
"$",
"exception",
",",
"$",
"this",
",",
"$",
"queue",
")",
";",
"$",
"this",
"->",
"getResque",
"(",
")",
"->",
"getStatistic",
"(",
"'failed'",
")",
"->",
"incr",
"(",
")",
";",
"$",
"this",
"->",
"getStatistic",
"(",
"'failed'",
")",
"->",
"incr",
"(",
")",
";",
"}"
] | Marks the given job as failed
This happens whenever the job's perform() method emits an exception
@param JobInterface|array $job
@param Exception $exception | [
"Marks",
"the",
"given",
"job",
"as",
"failed"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Worker.php#L378-L408 |
28,691 | vend/php-resque | src/Worker.php | Worker.refreshQueues | protected function refreshQueues()
{
if ($this->refreshQueues) {
$this->queues = $this->resque->queues();
}
if (!$this->queues) {
if ($this->refreshQueues) {
$this->logger->info('Refreshing queues dynamically, but there are no queues yet');
} else {
$this->logger->notice('Not listening to any queues, and dynamic queue refreshing is disabled');
$this->shutdownNow();
}
}
// Each call to reserve, we check the queues in a different order
if ($this->options['shuffle_queues']) {
shuffle($this->queues);
} elseif ($this->options['sort_queues']) {
sort($this->queues);
}
} | php | protected function refreshQueues()
{
if ($this->refreshQueues) {
$this->queues = $this->resque->queues();
}
if (!$this->queues) {
if ($this->refreshQueues) {
$this->logger->info('Refreshing queues dynamically, but there are no queues yet');
} else {
$this->logger->notice('Not listening to any queues, and dynamic queue refreshing is disabled');
$this->shutdownNow();
}
}
// Each call to reserve, we check the queues in a different order
if ($this->options['shuffle_queues']) {
shuffle($this->queues);
} elseif ($this->options['sort_queues']) {
sort($this->queues);
}
} | [
"protected",
"function",
"refreshQueues",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"refreshQueues",
")",
"{",
"$",
"this",
"->",
"queues",
"=",
"$",
"this",
"->",
"resque",
"->",
"queues",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"queues",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"refreshQueues",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Refreshing queues dynamically, but there are no queues yet'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"notice",
"(",
"'Not listening to any queues, and dynamic queue refreshing is disabled'",
")",
";",
"$",
"this",
"->",
"shutdownNow",
"(",
")",
";",
"}",
"}",
"// Each call to reserve, we check the queues in a different order",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'shuffle_queues'",
"]",
")",
"{",
"shuffle",
"(",
"$",
"this",
"->",
"queues",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"options",
"[",
"'sort_queues'",
"]",
")",
"{",
"sort",
"(",
"$",
"this",
"->",
"queues",
")",
";",
"}",
"}"
] | Prepares the list of queues for a job to reserved
Updates/sorts/shuffles the array ahead of the call to reserve a job from one of them
@return void | [
"Prepares",
"the",
"list",
"of",
"queues",
"for",
"a",
"job",
"to",
"reserved"
] | 91ed2b96e426b32680c15fd099a4688d2f75c163 | https://github.com/vend/php-resque/blob/91ed2b96e426b32680c15fd099a4688d2f75c163/src/Worker.php#L417-L438 |
28,692 | slashtrace/slashtrace | src/Level.php | Level.severityToLevel | public static function severityToLevel($severity)
{
switch ($severity) {
case E_USER_NOTICE:
case E_NOTICE:
case E_STRICT:
return self::INFO;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
case E_DEPRECATED:
case E_USER_DEPRECATED:
return self::WARNING;
case E_ERROR:
case E_PARSE:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
default:
return self::ERROR;
}
} | php | public static function severityToLevel($severity)
{
switch ($severity) {
case E_USER_NOTICE:
case E_NOTICE:
case E_STRICT:
return self::INFO;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
case E_DEPRECATED:
case E_USER_DEPRECATED:
return self::WARNING;
case E_ERROR:
case E_PARSE:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
default:
return self::ERROR;
}
} | [
"public",
"static",
"function",
"severityToLevel",
"(",
"$",
"severity",
")",
"{",
"switch",
"(",
"$",
"severity",
")",
"{",
"case",
"E_USER_NOTICE",
":",
"case",
"E_NOTICE",
":",
"case",
"E_STRICT",
":",
"return",
"self",
"::",
"INFO",
";",
"case",
"E_WARNING",
":",
"case",
"E_CORE_WARNING",
":",
"case",
"E_COMPILE_WARNING",
":",
"case",
"E_USER_WARNING",
":",
"case",
"E_DEPRECATED",
":",
"case",
"E_USER_DEPRECATED",
":",
"return",
"self",
"::",
"WARNING",
";",
"case",
"E_ERROR",
":",
"case",
"E_PARSE",
":",
"case",
"E_CORE_ERROR",
":",
"case",
"E_COMPILE_ERROR",
":",
"case",
"E_USER_ERROR",
":",
"case",
"E_RECOVERABLE_ERROR",
":",
"default",
":",
"return",
"self",
"::",
"ERROR",
";",
"}",
"}"
] | Converts PHP error constants to custom log level
@param $severity
@return string | [
"Converts",
"PHP",
"error",
"constants",
"to",
"custom",
"log",
"level"
] | bc0501703546a2e62e79d02725dd173c45c49ff5 | https://github.com/slashtrace/slashtrace/blob/bc0501703546a2e62e79d02725dd173c45c49ff5/src/Level.php#L34-L59 |
28,693 | slashtrace/slashtrace | src/Http/Request.php | Request.getUrl | public function getUrl()
{
$https = $this->isHTTPS();
$protocol = strtolower($_SERVER["SERVER_PROTOCOL"]);
$protocol = substr($protocol, 0, strpos($protocol, "/")) . ($https ? "s" : "");
$port = $_SERVER["SERVER_PORT"];
$port = ($port == 80 && !$https) || ($port == 443 && $https) ? "" : ":$port";
$host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : null;
$host = $host ? $host : $_SERVER["SERVER_NAME"] . $port;
return "$protocol://$host" . $_SERVER["REQUEST_URI"];
} | php | public function getUrl()
{
$https = $this->isHTTPS();
$protocol = strtolower($_SERVER["SERVER_PROTOCOL"]);
$protocol = substr($protocol, 0, strpos($protocol, "/")) . ($https ? "s" : "");
$port = $_SERVER["SERVER_PORT"];
$port = ($port == 80 && !$https) || ($port == 443 && $https) ? "" : ":$port";
$host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : null;
$host = $host ? $host : $_SERVER["SERVER_NAME"] . $port;
return "$protocol://$host" . $_SERVER["REQUEST_URI"];
} | [
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"https",
"=",
"$",
"this",
"->",
"isHTTPS",
"(",
")",
";",
"$",
"protocol",
"=",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"\"SERVER_PROTOCOL\"",
"]",
")",
";",
"$",
"protocol",
"=",
"substr",
"(",
"$",
"protocol",
",",
"0",
",",
"strpos",
"(",
"$",
"protocol",
",",
"\"/\"",
")",
")",
".",
"(",
"$",
"https",
"?",
"\"s\"",
":",
"\"\"",
")",
";",
"$",
"port",
"=",
"$",
"_SERVER",
"[",
"\"SERVER_PORT\"",
"]",
";",
"$",
"port",
"=",
"(",
"$",
"port",
"==",
"80",
"&&",
"!",
"$",
"https",
")",
"||",
"(",
"$",
"port",
"==",
"443",
"&&",
"$",
"https",
")",
"?",
"\"\"",
":",
"\":$port\"",
";",
"$",
"host",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"\"HTTP_HOST\"",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"\"HTTP_HOST\"",
"]",
":",
"null",
";",
"$",
"host",
"=",
"$",
"host",
"?",
"$",
"host",
":",
"$",
"_SERVER",
"[",
"\"SERVER_NAME\"",
"]",
".",
"$",
"port",
";",
"return",
"\"$protocol://$host\"",
".",
"$",
"_SERVER",
"[",
"\"REQUEST_URI\"",
"]",
";",
"}"
] | Returns the full URL being requested
@return string | [
"Returns",
"the",
"full",
"URL",
"being",
"requested"
] | bc0501703546a2e62e79d02725dd173c45c49ff5 | https://github.com/slashtrace/slashtrace/blob/bc0501703546a2e62e79d02725dd173c45c49ff5/src/Http/Request.php#L101-L115 |
28,694 | slashtrace/slashtrace | src/SlashTrace.php | SlashTrace.checkUniqueHandler | private function checkUniqueHandler(EventHandler $input)
{
foreach ($this->handlers as $handler) {
if ($handler === $input) {
throw new RuntimeException();
}
}
} | php | private function checkUniqueHandler(EventHandler $input)
{
foreach ($this->handlers as $handler) {
if ($handler === $input) {
throw new RuntimeException();
}
}
} | [
"private",
"function",
"checkUniqueHandler",
"(",
"EventHandler",
"$",
"input",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"===",
"$",
"input",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"}",
"}"
] | Checks that a particular handler hasn't already been registered
@param EventHandler $input
@throws RuntimeException | [
"Checks",
"that",
"a",
"particular",
"handler",
"hasn",
"t",
"already",
"been",
"registered"
] | bc0501703546a2e62e79d02725dd173c45c49ff5 | https://github.com/slashtrace/slashtrace/blob/bc0501703546a2e62e79d02725dd173c45c49ff5/src/SlashTrace.php#L80-L87 |
28,695 | php-deal/framework | src/Aspect/PreconditionCheckerAspect.php | PreconditionCheckerAspect.preConditionContract | public function preConditionContract(MethodInvocation $invocation): void
{
$object = $invocation->getThis();
$args = $this->fetchMethodArguments($invocation);
$scope = $invocation->getMethod()->getDeclaringClass()->name;
$allContracts = $this->fetchAllContracts($invocation);
$this->ensureContracts($invocation, $allContracts, $object, $scope, $args);
} | php | public function preConditionContract(MethodInvocation $invocation): void
{
$object = $invocation->getThis();
$args = $this->fetchMethodArguments($invocation);
$scope = $invocation->getMethod()->getDeclaringClass()->name;
$allContracts = $this->fetchAllContracts($invocation);
$this->ensureContracts($invocation, $allContracts, $object, $scope, $args);
} | [
"public",
"function",
"preConditionContract",
"(",
"MethodInvocation",
"$",
"invocation",
")",
":",
"void",
"{",
"$",
"object",
"=",
"$",
"invocation",
"->",
"getThis",
"(",
")",
";",
"$",
"args",
"=",
"$",
"this",
"->",
"fetchMethodArguments",
"(",
"$",
"invocation",
")",
";",
"$",
"scope",
"=",
"$",
"invocation",
"->",
"getMethod",
"(",
")",
"->",
"getDeclaringClass",
"(",
")",
"->",
"name",
";",
"$",
"allContracts",
"=",
"$",
"this",
"->",
"fetchAllContracts",
"(",
"$",
"invocation",
")",
";",
"$",
"this",
"->",
"ensureContracts",
"(",
"$",
"invocation",
",",
"$",
"allContracts",
",",
"$",
"object",
",",
"$",
"scope",
",",
"$",
"args",
")",
";",
"}"
] | Verifies pre-condition contract for the method
@param MethodInvocation $invocation
@Before("@execution(PhpDeal\Annotation\Verify)")
@throws ContractViolation
@throws ReflectionException | [
"Verifies",
"pre",
"-",
"condition",
"contract",
"for",
"the",
"method"
] | 31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43 | https://github.com/php-deal/framework/blob/31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43/src/Aspect/PreconditionCheckerAspect.php#L48-L56 |
28,696 | php-deal/framework | src/Aspect/AbstractContractAspect.php | AbstractContractAspect.fetchMethodArguments | protected function fetchMethodArguments(MethodInvocation $invocation): array
{
$result = [];
$parameters = $invocation->getMethod()->getParameters();
$argumentValues = $invocation->getArguments();
// Number of arguments can be less than number of parameters because of default values
foreach ($parameters as $parameterIndex => $reflectionParameter) {
$hasArgumentValue = \array_key_exists($parameterIndex, $argumentValues);
$argumentValue = $hasArgumentValue ? $argumentValues[$parameterIndex] : null;
if (!$hasArgumentValue && $reflectionParameter->isDefaultValueAvailable()) {
$argumentValue = $reflectionParameter->getDefaultValue();
}
$result[$reflectionParameter->name] = $argumentValue;
}
return $result;
} | php | protected function fetchMethodArguments(MethodInvocation $invocation): array
{
$result = [];
$parameters = $invocation->getMethod()->getParameters();
$argumentValues = $invocation->getArguments();
// Number of arguments can be less than number of parameters because of default values
foreach ($parameters as $parameterIndex => $reflectionParameter) {
$hasArgumentValue = \array_key_exists($parameterIndex, $argumentValues);
$argumentValue = $hasArgumentValue ? $argumentValues[$parameterIndex] : null;
if (!$hasArgumentValue && $reflectionParameter->isDefaultValueAvailable()) {
$argumentValue = $reflectionParameter->getDefaultValue();
}
$result[$reflectionParameter->name] = $argumentValue;
}
return $result;
} | [
"protected",
"function",
"fetchMethodArguments",
"(",
"MethodInvocation",
"$",
"invocation",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"parameters",
"=",
"$",
"invocation",
"->",
"getMethod",
"(",
")",
"->",
"getParameters",
"(",
")",
";",
"$",
"argumentValues",
"=",
"$",
"invocation",
"->",
"getArguments",
"(",
")",
";",
"// Number of arguments can be less than number of parameters because of default values",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameterIndex",
"=>",
"$",
"reflectionParameter",
")",
"{",
"$",
"hasArgumentValue",
"=",
"\\",
"array_key_exists",
"(",
"$",
"parameterIndex",
",",
"$",
"argumentValues",
")",
";",
"$",
"argumentValue",
"=",
"$",
"hasArgumentValue",
"?",
"$",
"argumentValues",
"[",
"$",
"parameterIndex",
"]",
":",
"null",
";",
"if",
"(",
"!",
"$",
"hasArgumentValue",
"&&",
"$",
"reflectionParameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"argumentValue",
"=",
"$",
"reflectionParameter",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"$",
"result",
"[",
"$",
"reflectionParameter",
"->",
"name",
"]",
"=",
"$",
"argumentValue",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns an associative list of arguments for the method invocation
@param MethodInvocation $invocation
@return array
@throws \ReflectionException | [
"Returns",
"an",
"associative",
"list",
"of",
"arguments",
"for",
"the",
"method",
"invocation"
] | 31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43 | https://github.com/php-deal/framework/blob/31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43/src/Aspect/AbstractContractAspect.php#L43-L60 |
28,697 | php-deal/framework | src/Aspect/AbstractContractAspect.php | AbstractContractAspect.ensureContracts | protected function ensureContracts(
MethodInvocation $invocation,
array $contracts,
$instance,
string $scope,
array $args
): void {
static $invoker = null;
if (!$invoker) {
$invoker = function () {
$args = \func_get_arg(0);
\extract($args, EXTR_OVERWRITE);
return eval('return ' . \func_get_arg(1) . '; ?>');
};
}
$instance = \is_object($instance) ? $instance : null;
$boundInvoker = $invoker->bindTo($instance, $scope);
foreach ($contracts as $contract) {
$contractExpression = $contract->value;
try {
$invocationResult = $boundInvoker->__invoke($args, $contractExpression);
if ($invocationResult === false) {
throw new ContractViolation($invocation, $contractExpression);
}
// we accept as a result only true or null
// null may be a result of assertions from beberlei/assert which passed
if ($invocationResult !== null && $invocationResult !== true) {
$errorMessage = 'Invalid return value received from the assertion body,'
. ' only boolean or void can be returned';
throw new DomainException($errorMessage);
}
} catch (\Error $internalError) {
// PHP-7 friendly interceptor for fatal errors
throw new ContractViolation($invocation, $contractExpression, $internalError);
} catch (\Exception $internalException) {
throw new ContractViolation($invocation, $contractExpression, $internalException);
}
}
} | php | protected function ensureContracts(
MethodInvocation $invocation,
array $contracts,
$instance,
string $scope,
array $args
): void {
static $invoker = null;
if (!$invoker) {
$invoker = function () {
$args = \func_get_arg(0);
\extract($args, EXTR_OVERWRITE);
return eval('return ' . \func_get_arg(1) . '; ?>');
};
}
$instance = \is_object($instance) ? $instance : null;
$boundInvoker = $invoker->bindTo($instance, $scope);
foreach ($contracts as $contract) {
$contractExpression = $contract->value;
try {
$invocationResult = $boundInvoker->__invoke($args, $contractExpression);
if ($invocationResult === false) {
throw new ContractViolation($invocation, $contractExpression);
}
// we accept as a result only true or null
// null may be a result of assertions from beberlei/assert which passed
if ($invocationResult !== null && $invocationResult !== true) {
$errorMessage = 'Invalid return value received from the assertion body,'
. ' only boolean or void can be returned';
throw new DomainException($errorMessage);
}
} catch (\Error $internalError) {
// PHP-7 friendly interceptor for fatal errors
throw new ContractViolation($invocation, $contractExpression, $internalError);
} catch (\Exception $internalException) {
throw new ContractViolation($invocation, $contractExpression, $internalException);
}
}
} | [
"protected",
"function",
"ensureContracts",
"(",
"MethodInvocation",
"$",
"invocation",
",",
"array",
"$",
"contracts",
",",
"$",
"instance",
",",
"string",
"$",
"scope",
",",
"array",
"$",
"args",
")",
":",
"void",
"{",
"static",
"$",
"invoker",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"invoker",
")",
"{",
"$",
"invoker",
"=",
"function",
"(",
")",
"{",
"$",
"args",
"=",
"\\",
"func_get_arg",
"(",
"0",
")",
";",
"\\",
"extract",
"(",
"$",
"args",
",",
"EXTR_OVERWRITE",
")",
";",
"return",
"eval",
"(",
"'return '",
".",
"\\",
"func_get_arg",
"(",
"1",
")",
".",
"'; ?>'",
")",
";",
"}",
";",
"}",
"$",
"instance",
"=",
"\\",
"is_object",
"(",
"$",
"instance",
")",
"?",
"$",
"instance",
":",
"null",
";",
"$",
"boundInvoker",
"=",
"$",
"invoker",
"->",
"bindTo",
"(",
"$",
"instance",
",",
"$",
"scope",
")",
";",
"foreach",
"(",
"$",
"contracts",
"as",
"$",
"contract",
")",
"{",
"$",
"contractExpression",
"=",
"$",
"contract",
"->",
"value",
";",
"try",
"{",
"$",
"invocationResult",
"=",
"$",
"boundInvoker",
"->",
"__invoke",
"(",
"$",
"args",
",",
"$",
"contractExpression",
")",
";",
"if",
"(",
"$",
"invocationResult",
"===",
"false",
")",
"{",
"throw",
"new",
"ContractViolation",
"(",
"$",
"invocation",
",",
"$",
"contractExpression",
")",
";",
"}",
"// we accept as a result only true or null",
"// null may be a result of assertions from beberlei/assert which passed",
"if",
"(",
"$",
"invocationResult",
"!==",
"null",
"&&",
"$",
"invocationResult",
"!==",
"true",
")",
"{",
"$",
"errorMessage",
"=",
"'Invalid return value received from the assertion body,'",
".",
"' only boolean or void can be returned'",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"errorMessage",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Error",
"$",
"internalError",
")",
"{",
"// PHP-7 friendly interceptor for fatal errors",
"throw",
"new",
"ContractViolation",
"(",
"$",
"invocation",
",",
"$",
"contractExpression",
",",
"$",
"internalError",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"internalException",
")",
"{",
"throw",
"new",
"ContractViolation",
"(",
"$",
"invocation",
",",
"$",
"contractExpression",
",",
"$",
"internalException",
")",
";",
"}",
"}",
"}"
] | Performs verification of contracts for given invocation
@param MethodInvocation $invocation Current invocation
@param array|Annotation[] $contracts Contract annotation
@param object|string $instance Invocation instance or string for static class
@param string $scope Scope of method
@param array $args List of arguments for the method
@throws DomainException
@throws ContractViolation | [
"Performs",
"verification",
"of",
"contracts",
"for",
"given",
"invocation"
] | 31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43 | https://github.com/php-deal/framework/blob/31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43/src/Aspect/AbstractContractAspect.php#L74-L117 |
28,698 | php-deal/framework | src/ContractApplication.php | ContractApplication.configureAop | protected function configureAop(AspectContainer $container): void
{
/** @var AnnotationReader $reader */
$reader = $container->get('aspect.annotation.reader');
$container->registerAspect(new InvariantCheckerAspect($reader));
$container->registerAspect(new PostconditionCheckerAspect($reader));
$container->registerAspect(new PreconditionCheckerAspect($reader));
$container->registerAspect(new InheritCheckerAspect($reader));
} | php | protected function configureAop(AspectContainer $container): void
{
/** @var AnnotationReader $reader */
$reader = $container->get('aspect.annotation.reader');
$container->registerAspect(new InvariantCheckerAspect($reader));
$container->registerAspect(new PostconditionCheckerAspect($reader));
$container->registerAspect(new PreconditionCheckerAspect($reader));
$container->registerAspect(new InheritCheckerAspect($reader));
} | [
"protected",
"function",
"configureAop",
"(",
"AspectContainer",
"$",
"container",
")",
":",
"void",
"{",
"/** @var AnnotationReader $reader */",
"$",
"reader",
"=",
"$",
"container",
"->",
"get",
"(",
"'aspect.annotation.reader'",
")",
";",
"$",
"container",
"->",
"registerAspect",
"(",
"new",
"InvariantCheckerAspect",
"(",
"$",
"reader",
")",
")",
";",
"$",
"container",
"->",
"registerAspect",
"(",
"new",
"PostconditionCheckerAspect",
"(",
"$",
"reader",
")",
")",
";",
"$",
"container",
"->",
"registerAspect",
"(",
"new",
"PreconditionCheckerAspect",
"(",
"$",
"reader",
")",
")",
";",
"$",
"container",
"->",
"registerAspect",
"(",
"new",
"InheritCheckerAspect",
"(",
"$",
"reader",
")",
")",
";",
"}"
] | Configures an AspectContainer with advisors, aspects and pointcuts
@param AspectContainer&GoAspectContainer $container
@return void | [
"Configures",
"an",
"AspectContainer",
"with",
"advisors",
"aspects",
"and",
"pointcuts"
] | 31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43 | https://github.com/php-deal/framework/blob/31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43/src/ContractApplication.php#L36-L45 |
28,699 | php-deal/framework | src/Contract/Fetcher/Parent/InvariantFetcher.php | InvariantFetcher.getConditions | public function getConditions(ReflectionClass $class): array
{
$annotations = [];
$parents = [];
$this->getParentClasses($class, $parents);
$this->getInterfaces($class, $parents);
foreach ($parents as $parent) {
$annotations[] = $this->annotationReader->getClassAnnotations($parent);
}
if (\count($annotations)) {
$annotations = \array_merge(...$annotations);
}
return $this->filterContractAnnotation($annotations);
} | php | public function getConditions(ReflectionClass $class): array
{
$annotations = [];
$parents = [];
$this->getParentClasses($class, $parents);
$this->getInterfaces($class, $parents);
foreach ($parents as $parent) {
$annotations[] = $this->annotationReader->getClassAnnotations($parent);
}
if (\count($annotations)) {
$annotations = \array_merge(...$annotations);
}
return $this->filterContractAnnotation($annotations);
} | [
"public",
"function",
"getConditions",
"(",
"ReflectionClass",
"$",
"class",
")",
":",
"array",
"{",
"$",
"annotations",
"=",
"[",
"]",
";",
"$",
"parents",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"getParentClasses",
"(",
"$",
"class",
",",
"$",
"parents",
")",
";",
"$",
"this",
"->",
"getInterfaces",
"(",
"$",
"class",
",",
"$",
"parents",
")",
";",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"parent",
")",
"{",
"$",
"annotations",
"[",
"]",
"=",
"$",
"this",
"->",
"annotationReader",
"->",
"getClassAnnotations",
"(",
"$",
"parent",
")",
";",
"}",
"if",
"(",
"\\",
"count",
"(",
"$",
"annotations",
")",
")",
"{",
"$",
"annotations",
"=",
"\\",
"array_merge",
"(",
"...",
"$",
"annotations",
")",
";",
"}",
"return",
"$",
"this",
"->",
"filterContractAnnotation",
"(",
"$",
"annotations",
")",
";",
"}"
] | Fetches conditions from all parent classes recursively
@param ReflectionClass $class
@return array | [
"Fetches",
"conditions",
"from",
"all",
"parent",
"classes",
"recursively"
] | 31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43 | https://github.com/php-deal/framework/blob/31ff0b8fe6c76e4df8cc60b4a0da68a0177b7d43/src/Contract/Fetcher/Parent/InvariantFetcher.php#L26-L43 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.