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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38,800 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/DeployKeys.php | DeployKeys.listDeployKeys | public function listDeployKeys(): array
{
return $this->getApi()->request($this->getApi()
->sprintf('/repos/:owner/:repo/keys', $this->getRepositories()->getOwner(),
$this->getRepositories()->getRepo()));
} | php | public function listDeployKeys(): array
{
return $this->getApi()->request($this->getApi()
->sprintf('/repos/:owner/:repo/keys', $this->getRepositories()->getOwner(),
$this->getRepositories()->getRepo()));
} | [
"public",
"function",
"listDeployKeys",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/keys'",
",",
"$",
"this",
"->",... | List deploy keys
@link https://developer.github.com/v3/repos/keys/#list
@return array | [
"List",
"deploy",
"keys"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/DeployKeys.php#L21-L26 |
38,801 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/DeployKeys.php | DeployKeys.addNewDeployKey | public function addNewDeployKey(string $title, string $key): array
{
return $this->getApi()->request($this->getApi()
->sprintf('/repos/:owner/:repo/keys', $this->getRepositories()->getOwner(),
$this->getRepositories()->getRepo()), Request::METHOD_POST, [
'title' => $title,
'key' => $key
]);
} | php | public function addNewDeployKey(string $title, string $key): array
{
return $this->getApi()->request($this->getApi()
->sprintf('/repos/:owner/:repo/keys', $this->getRepositories()->getOwner(),
$this->getRepositories()->getRepo()), Request::METHOD_POST, [
'title' => $title,
'key' => $key
]);
} | [
"public",
"function",
"addNewDeployKey",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"key",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(... | Add a new deploy key
@link https://developer.github.com/v3/repos/keys/#create
@param string $title
@param string $key
@return array | [
"Add",
"a",
"new",
"deploy",
"key"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/DeployKeys.php#L53-L61 |
38,802 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/DeployKeys.php | DeployKeys.removeDeployKey | public function removeDeployKey(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/keys/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $id), Request::METHOD_DELETE);
} | php | public function removeDeployKey(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/keys/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $id), Request::METHOD_DELETE);
} | [
"public",
"function",
"removeDeployKey",
"(",
"int",
"$",
"id",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/keys/:id'",
... | Remove a deploy key
@link https://developer.github.com/v3/repos/keys/#delete
@param int $id
@return array | [
"Remove",
"a",
"deploy",
"key"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/DeployKeys.php#L72-L76 |
38,803 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Comments.php | Comments.listComments | public function listComments(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | php | public function listComments(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | [
"public",
"function",
"listComments",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/comments'",
",",
"$",
"this",
"->... | List commit comments for a repository
@link https://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
@return array | [
"List",
"commit",
"comments",
"for",
"a",
"repository"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Comments.php#L21-L25 |
38,804 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Comments.php | Comments.getCommitComment | public function getCommitComment(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), (string)$id));
} | php | public function getCommitComment(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), (string)$id));
} | [
"public",
"function",
"getCommitComment",
"(",
"int",
"$",
"id",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/comments/:id'... | Get a single commit comment
@link https://developer.github.com/v3/repos/comments/#get-a-single-commit-comment
@param int $id
@return array | [
"Get",
"a",
"single",
"commit",
"comment"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Comments.php#L73-L77 |
38,805 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Comments.php | Comments.updateCommitComment | public function updateCommitComment(int $id, string $body): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), (string)$id),
Request::METHOD_PATCH, [
'body' => $body
]);
} | php | public function updateCommitComment(int $id, string $body): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), (string)$id),
Request::METHOD_PATCH, [
'body' => $body
]);
} | [
"public",
"function",
"updateCommitComment",
"(",
"int",
"$",
"id",
",",
"string",
"$",
"body",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"("... | Update a commit comment
@link https://developer.github.com/v3/repos/comments/#update-a-commit-comment
@param int $id
@param string $body
@return array
@throws \Exception | [
"Update",
"a",
"commit",
"comment"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Comments.php#L90-L97 |
38,806 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Comments.php | Comments.deleteCommitComment | public function deleteCommitComment(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), (string)$id),
Request::METHOD_DELETE);
} | php | public function deleteCommitComment(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/comments/:id',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), (string)$id),
Request::METHOD_DELETE);
} | [
"public",
"function",
"deleteCommitComment",
"(",
"int",
"$",
"id",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/comments/:... | Delete a commit comment
@link https://developer.github.com/v3/repos/comments/#delete-a-commit-comment
@param int $id
@return array | [
"Delete",
"a",
"commit",
"comment"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Comments.php#L108-L113 |
38,807 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Statistics.php | Statistics.listContributors | public function listContributors(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/contributors',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | php | public function listContributors(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/contributors',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | [
"public",
"function",
"listContributors",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/stats/contributors'",
",",
"$",
... | Get contributors list with additions, deletions, and commit counts
@link https://developer.github.com/v3/repos/statistics/#contributors
@return array | [
"Get",
"contributors",
"list",
"with",
"additions",
"deletions",
"and",
"commit",
"counts"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Statistics.php#L19-L23 |
38,808 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Statistics.php | Statistics.getCommitActivity | public function getCommitActivity(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/commit_activity',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | php | public function getCommitActivity(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/commit_activity',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | [
"public",
"function",
"getCommitActivity",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/stats/commit_activity'",
",",
"$... | Get the last year of commit activity data
@link https://developer.github.com/v3/repos/statistics/#commit-activity
@return array | [
"Get",
"the",
"last",
"year",
"of",
"commit",
"activity",
"data"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Statistics.php#L31-L35 |
38,809 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Statistics.php | Statistics.getCodeFrequency | public function getCodeFrequency(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/code_frequency',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | php | public function getCodeFrequency(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/code_frequency',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | [
"public",
"function",
"getCodeFrequency",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/stats/code_frequency'",
",",
"$",... | Get the number of additions and deletions per week
@link https://developer.github.com/v3/repos/statistics/#code-frequency
@return array | [
"Get",
"the",
"number",
"of",
"additions",
"and",
"deletions",
"per",
"week"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Statistics.php#L43-L47 |
38,810 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Statistics.php | Statistics.getParticipation | public function getParticipation(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/participation',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | php | public function getParticipation(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/participation',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | [
"public",
"function",
"getParticipation",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/stats/participation'",
",",
"$",
... | Get the weekly commit count for the repository owner and everyone else
@link https://developer.github.com/v3/repos/statistics/#participation
@return array | [
"Get",
"the",
"weekly",
"commit",
"count",
"for",
"the",
"repository",
"owner",
"and",
"everyone",
"else"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Statistics.php#L55-L59 |
38,811 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Statistics.php | Statistics.getPunchCard | public function getPunchCard(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/punch_card',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | php | public function getPunchCard(): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/punch_card',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
} | [
"public",
"function",
"getPunchCard",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/stats/punch_card'",
",",
"$",
"this... | Get the number of commits per hour in each day
@link https://developer.github.com/v3/repos/statistics/#punch-card
@return array | [
"Get",
"the",
"number",
"of",
"commits",
"per",
"hour",
"in",
"each",
"day"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Statistics.php#L67-L71 |
38,812 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Activity/Notifications.php | Notifications.viewThread | public function viewThread(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id', (string)$id));
} | php | public function viewThread(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id', (string)$id));
} | [
"public",
"function",
"viewThread",
"(",
"int",
"$",
"id",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/notifications/threads/:id'",
",",
... | View a single thread
@link https://developer.github.com/v3/activity/notifications/#view-a-single-thread
@param int $id
@return array | [
"View",
"a",
"single",
"thread"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Activity/Notifications.php#L108-L111 |
38,813 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Activity/Notifications.php | Notifications.markThreadAsRead | public function markThreadAsRead(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id', (string)$id),
Request::METHOD_PATCH);
} | php | public function markThreadAsRead(int $id): array
{
return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id', (string)$id),
Request::METHOD_PATCH);
} | [
"public",
"function",
"markThreadAsRead",
"(",
"int",
"$",
"id",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/notifications/threads/:id'",
"... | Mark a thread as read
@link https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
@param int $id
@return array | [
"Mark",
"a",
"thread",
"as",
"read"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Activity/Notifications.php#L122-L126 |
38,814 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Activity/Notifications.php | Notifications.getThreadSubscription | public function getThreadSubscription(int $id): array
{
return $this->getApi()->request($this->getApi()
->sprintf('/notifications/threads/:id/subscription', (string)$id));
} | php | public function getThreadSubscription(int $id): array
{
return $this->getApi()->request($this->getApi()
->sprintf('/notifications/threads/:id/subscription', (string)$id));
} | [
"public",
"function",
"getThreadSubscription",
"(",
"int",
"$",
"id",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/notifications/threads/:id/s... | Get a Thread Subscription
@link https://developer.github.com/v3/activity/notifications/#get-a-thread-subscription
@param int $id
@return array | [
"Get",
"a",
"Thread",
"Subscription"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Activity/Notifications.php#L137-L141 |
38,815 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Activity/Notifications.php | Notifications.setThreadSubscription | public function setThreadSubscription(int $id, bool $subscribed = false, bool $ignored = false): array
{
return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id/subscription?:args', $id,
http_build_query(['subscribed' => $subscribed, 'ignored' => $ignored])), Request::METHOD_PUT);
} | php | public function setThreadSubscription(int $id, bool $subscribed = false, bool $ignored = false): array
{
return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id/subscription?:args', $id,
http_build_query(['subscribed' => $subscribed, 'ignored' => $ignored])), Request::METHOD_PUT);
} | [
"public",
"function",
"setThreadSubscription",
"(",
"int",
"$",
"id",
",",
"bool",
"$",
"subscribed",
"=",
"false",
",",
"bool",
"$",
"ignored",
"=",
"false",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"("... | Set a Thread Subscription
@link https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription
@param int $id
@param bool $subscribed
@param bool $ignored
@return array | [
"Set",
"a",
"Thread",
"Subscription"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Activity/Notifications.php#L154-L158 |
38,816 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Miscellaneous/Markdown.php | Markdown.render | public function render(string $text, string $mode = AbstractApi::MODE_MARKDOWN, string $context = ''): array
{
return $this->getApi()->request('/markdown', Request::METHOD_POST, [
'text' => $text,
'mode' => $mode,
'context' => $context
]);
} | php | public function render(string $text, string $mode = AbstractApi::MODE_MARKDOWN, string $context = ''): array
{
return $this->getApi()->request('/markdown', Request::METHOD_POST, [
'text' => $text,
'mode' => $mode,
'context' => $context
]);
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"mode",
"=",
"AbstractApi",
"::",
"MODE_MARKDOWN",
",",
"string",
"$",
"context",
"=",
"''",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
... | Render an arbitrary Markdown document
@link https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document
@param string $text The Markdown text to render
@param string $mode The rendering mode.
@param string $context The repository context. Only taken into account when rendering as gfm
@return array | [
"Render",
"an",
"arbitrary",
"Markdown",
"document"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Miscellaneous/Markdown.php#L27-L34 |
38,817 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Miscellaneous/Markdown.php | Markdown.renderRaw | public function renderRaw(string $string): array
{
return $this->getApi()->setContentType('text/plain')
->request('/markdown/raw', Request::METHOD_POST, ['file' => $string]);
} | php | public function renderRaw(string $string): array
{
return $this->getApi()->setContentType('text/plain')
->request('/markdown/raw', Request::METHOD_POST, ['file' => $string]);
} | [
"public",
"function",
"renderRaw",
"(",
"string",
"$",
"string",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"setContentType",
"(",
"'text/plain'",
")",
"->",
"request",
"(",
"'/markdown/raw'",
",",
"Request",
"::",
"METH... | Render a Markdown document in raw mode
@link https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode
@param string $string
@return array | [
"Render",
"a",
"Markdown",
"document",
"in",
"raw",
"mode"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Miscellaneous/Markdown.php#L45-L49 |
38,818 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Collaborators.php | Collaborators.checkUserIsACollaborator | public function checkUserIsACollaborator(string $username): bool
{
$this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username));
if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
return true;
}
return false;
} | php | public function checkUserIsACollaborator(string $username): bool
{
$this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username));
if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
return true;
}
return false;
} | [
"public",
"function",
"checkUserIsACollaborator",
"(",
"string",
"$",
"username",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo/collabora... | Check if a user is a collaborator
@link https://developer.github.com/v3/repos/collaborators/#get
@param string $username
@return bool | [
"Check",
"if",
"a",
"user",
"is",
"a",
"collaborator"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Collaborators.php#L36-L46 |
38,819 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Collaborators.php | Collaborators.addUserAsCollaborator | public function addUserAsCollaborator(string $username): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username), Request::METHOD_PUT);
} | php | public function addUserAsCollaborator(string $username): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username), Request::METHOD_PUT);
} | [
"public",
"function",
"addUserAsCollaborator",
"(",
"string",
"$",
"username",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:repo... | Add user as a collaborator
@link https://developer.github.com/v3/repos/collaborators/#add-collaborator
@param string $username
@return array | [
"Add",
"user",
"as",
"a",
"collaborator"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Collaborators.php#L57-L61 |
38,820 | FlexyProject/GitHubAPI | lib/GitHub/Receiver/Repositories/Collaborators.php | Collaborators.removeUserAsCollaborator | public function removeUserAsCollaborator(string $username): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username),
Request::METHOD_DELETE);
} | php | public function removeUserAsCollaborator(string $username): array
{
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username),
Request::METHOD_DELETE);
} | [
"public",
"function",
"removeUserAsCollaborator",
"(",
"string",
"$",
"username",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"sprintf",
"(",
"'/repos/:owner/:r... | Remove user as a collaborator
@link https://developer.github.com/v3/repos/collaborators/#remove-collaborator
@param string $username
@return array | [
"Remove",
"user",
"as",
"a",
"collaborator"
] | cb5044443daf138787a7feb9aa9bf50220a44fd6 | https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Repositories/Collaborators.php#L72-L77 |
38,821 | wa0x6e/php-resque-ex | lib/Redisent/RedisentCluster.php | RedisentCluster.nextNode | private function nextNode($needle) {
$haystack = $this->nodes;
while (count($haystack) > 2) {
$try = floor(count($haystack) / 2);
if ($haystack[$try] == $needle) {
return $needle;
}
if ($needle < $haystack[$try]) {
$haystack = array_slice($haystack, 0, $try + 1);
}
if ($needle > $haystack[$try]) {
$haystack = array_slice($haystack, $try + 1);
}
}
return $haystack[count($haystack)-1];
} | php | private function nextNode($needle) {
$haystack = $this->nodes;
while (count($haystack) > 2) {
$try = floor(count($haystack) / 2);
if ($haystack[$try] == $needle) {
return $needle;
}
if ($needle < $haystack[$try]) {
$haystack = array_slice($haystack, 0, $try + 1);
}
if ($needle > $haystack[$try]) {
$haystack = array_slice($haystack, $try + 1);
}
}
return $haystack[count($haystack)-1];
} | [
"private",
"function",
"nextNode",
"(",
"$",
"needle",
")",
"{",
"$",
"haystack",
"=",
"$",
"this",
"->",
"nodes",
";",
"while",
"(",
"count",
"(",
"$",
"haystack",
")",
">",
"2",
")",
"{",
"$",
"try",
"=",
"floor",
"(",
"count",
"(",
"$",
"hayst... | Routes to the proper server node
@param integer $needle The hash value of the Redis command
@return Redisent The Redisent object associated with the hash | [
"Routes",
"to",
"the",
"proper",
"server",
"node"
] | 108261d37e4c79d049b4443b0ec5eb1906fdfffe | https://github.com/wa0x6e/php-resque-ex/blob/108261d37e4c79d049b4443b0ec5eb1906fdfffe/lib/Redisent/RedisentCluster.php#L121-L136 |
38,822 | wa0x6e/php-resque-ex | lib/Resque/Failure.php | Resque_Failure.getBackend | public static function getBackend()
{
if(self::$backend === null) {
require dirname(__FILE__) . '/Failure/Redis.php';
self::$backend = 'Resque_Failure_Redis';
}
return self::$backend;
} | php | public static function getBackend()
{
if(self::$backend === null) {
require dirname(__FILE__) . '/Failure/Redis.php';
self::$backend = 'Resque_Failure_Redis';
}
return self::$backend;
} | [
"public",
"static",
"function",
"getBackend",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"backend",
"===",
"null",
")",
"{",
"require",
"dirname",
"(",
"__FILE__",
")",
".",
"'/Failure/Redis.php'",
";",
"self",
"::",
"$",
"backend",
"=",
"'Resque_Failure... | Return an instance of the backend for saving job failures.
@return object Instance of backend object. | [
"Return",
"an",
"instance",
"of",
"the",
"backend",
"for",
"saving",
"job",
"failures",
"."
] | 108261d37e4c79d049b4443b0ec5eb1906fdfffe | https://github.com/wa0x6e/php-resque-ex/blob/108261d37e4c79d049b4443b0ec5eb1906fdfffe/lib/Resque/Failure.php#L37-L45 |
38,823 | clean/phpdoc-md | src/Markdown/ClassInfo.php | ClassInfo.render | public function render()
{
$parser = new ClassParser($this->reflectionClass);
$methods = $parser->getMethodsDetails();
ksort($methods);
$this->setData(
[
'className' => $this->reflectionClass->getName(),
'classShortName' => $this->reflectionClass->getShortName(),
'methods' => $methods,
'classDescription' => $parser->getClassDescription(),
'interfaces' => $parser->getInterfaces(),
'parentClass' => $parser->getParentClassName(),
'inheritedMethods' => $parser->getInheritedMethods(),
]
);
return parent::render();
} | php | public function render()
{
$parser = new ClassParser($this->reflectionClass);
$methods = $parser->getMethodsDetails();
ksort($methods);
$this->setData(
[
'className' => $this->reflectionClass->getName(),
'classShortName' => $this->reflectionClass->getShortName(),
'methods' => $methods,
'classDescription' => $parser->getClassDescription(),
'interfaces' => $parser->getInterfaces(),
'parentClass' => $parser->getParentClassName(),
'inheritedMethods' => $parser->getInheritedMethods(),
]
);
return parent::render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"parser",
"=",
"new",
"ClassParser",
"(",
"$",
"this",
"->",
"reflectionClass",
")",
";",
"$",
"methods",
"=",
"$",
"parser",
"->",
"getMethodsDetails",
"(",
")",
";",
"ksort",
"(",
"$",
"methods",
")... | Renders markdown for class
@return string | [
"Renders",
"markdown",
"for",
"class"
] | 738e6d89db0db1a7a1f3bc86ef2fe74897688eab | https://github.com/clean/phpdoc-md/blob/738e6d89db0db1a7a1f3bc86ef2fe74897688eab/src/Markdown/ClassInfo.php#L29-L47 |
38,824 | wa0x6e/php-resque-ex | lib/Resque.php | Resque.redis | public static function redis()
{
// Detect when the PID of the current process has changed (from a fork, etc)
// and force a reconnect to redis.
$pid = getmypid();
if (self::$pid !== $pid) {
self::$redis = null;
self::$pid = $pid;
}
if (!is_null(self::$redis)) {
return self::$redis;
}
$server = self::$redisServer;
if (empty($server)) {
$server = 'localhost:6379';
}
if (is_array($server)) {
require_once dirname(__FILE__) . '/Resque/RedisCluster.php';
self::$redis = new Resque_RedisCluster($server);
} else {
if (strpos($server, 'unix:') === false) {
list($host, $port) = explode(':', $server);
} else {
$host = $server;
$port = null;
}
require_once dirname(__FILE__) . '/Resque/Redis.php';
$redisInstance = new Resque_Redis($host, $port, self::$password);
$redisInstance->prefix(self::$namespace);
self::$redis = $redisInstance;
}
if (!empty(self::$redisDatabase)) {
self::$redis->select(self::$redisDatabase);
}
return self::$redis;
} | php | public static function redis()
{
// Detect when the PID of the current process has changed (from a fork, etc)
// and force a reconnect to redis.
$pid = getmypid();
if (self::$pid !== $pid) {
self::$redis = null;
self::$pid = $pid;
}
if (!is_null(self::$redis)) {
return self::$redis;
}
$server = self::$redisServer;
if (empty($server)) {
$server = 'localhost:6379';
}
if (is_array($server)) {
require_once dirname(__FILE__) . '/Resque/RedisCluster.php';
self::$redis = new Resque_RedisCluster($server);
} else {
if (strpos($server, 'unix:') === false) {
list($host, $port) = explode(':', $server);
} else {
$host = $server;
$port = null;
}
require_once dirname(__FILE__) . '/Resque/Redis.php';
$redisInstance = new Resque_Redis($host, $port, self::$password);
$redisInstance->prefix(self::$namespace);
self::$redis = $redisInstance;
}
if (!empty(self::$redisDatabase)) {
self::$redis->select(self::$redisDatabase);
}
return self::$redis;
} | [
"public",
"static",
"function",
"redis",
"(",
")",
"{",
"// Detect when the PID of the current process has changed (from a fork, etc)",
"// and force a reconnect to redis.",
"$",
"pid",
"=",
"getmypid",
"(",
")",
";",
"if",
"(",
"self",
"::",
"$",
"pid",
"!==",
"$",
"... | Return an instance of the Resque_Redis class instantiated for Resque.
@return Resque_Redis Instance of Resque_Redis. | [
"Return",
"an",
"instance",
"of",
"the",
"Resque_Redis",
"class",
"instantiated",
"for",
"Resque",
"."
] | 108261d37e4c79d049b4443b0ec5eb1906fdfffe | https://github.com/wa0x6e/php-resque-ex/blob/108261d37e4c79d049b4443b0ec5eb1906fdfffe/lib/Resque.php#L70-L110 |
38,825 | wa0x6e/php-resque-ex | lib/Resque.php | Resque.removeItems | private static function removeItems($queue, $items = [])
{
$counter = 0;
$originalQueue = 'queue:' . $queue;
$tempQueue = $originalQueue . ':temp:' . time();
$requeueQueue = $tempQueue . ':requeue';
// move each item from original queue to temp queue and process it
$finished = false;
while (!$finished) {
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
if (!empty($string)) {
if (self::matchItem($string, $items)) {
self::redis()->rpop($tempQueue);
$counter++;
} else {
self::redis()->rpoplpush($tempQueue, self::redis()->getPrefix() . $requeueQueue);
}
} else {
$finished = true;
}
}
// move back from temp queue to original queue
$finished = false;
while (!$finished) {
$string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() . $originalQueue);
if (empty($string)) {
$finished = true;
}
}
// remove temp queue and requeue queue
self::redis()->del($requeueQueue);
self::redis()->del($tempQueue);
return $counter;
} | php | private static function removeItems($queue, $items = [])
{
$counter = 0;
$originalQueue = 'queue:' . $queue;
$tempQueue = $originalQueue . ':temp:' . time();
$requeueQueue = $tempQueue . ':requeue';
// move each item from original queue to temp queue and process it
$finished = false;
while (!$finished) {
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
if (!empty($string)) {
if (self::matchItem($string, $items)) {
self::redis()->rpop($tempQueue);
$counter++;
} else {
self::redis()->rpoplpush($tempQueue, self::redis()->getPrefix() . $requeueQueue);
}
} else {
$finished = true;
}
}
// move back from temp queue to original queue
$finished = false;
while (!$finished) {
$string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() . $originalQueue);
if (empty($string)) {
$finished = true;
}
}
// remove temp queue and requeue queue
self::redis()->del($requeueQueue);
self::redis()->del($tempQueue);
return $counter;
} | [
"private",
"static",
"function",
"removeItems",
"(",
"$",
"queue",
",",
"$",
"items",
"=",
"[",
"]",
")",
"{",
"$",
"counter",
"=",
"0",
";",
"$",
"originalQueue",
"=",
"'queue:'",
".",
"$",
"queue",
";",
"$",
"tempQueue",
"=",
"$",
"originalQueue",
... | Remove Items from the queue
Safely moving each item to a temporary queue before processing it
If the Job matches, counts otherwise puts it in a requeue_queue
which at the end eventually be copied back into the original queue
@private
@param string $queue The name of the queue
@param array $items
@return integer number of deleted items | [
"Remove",
"Items",
"from",
"the",
"queue",
"Safely",
"moving",
"each",
"item",
"to",
"a",
"temporary",
"queue",
"before",
"processing",
"it",
"If",
"the",
"Job",
"matches",
"counts",
"otherwise",
"puts",
"it",
"in",
"a",
"requeue_queue",
"which",
"at",
"the"... | 108261d37e4c79d049b4443b0ec5eb1906fdfffe | https://github.com/wa0x6e/php-resque-ex/blob/108261d37e4c79d049b4443b0ec5eb1906fdfffe/lib/Resque.php#L235-L273 |
38,826 | mmucklo/email-parse | src/Parse.php | Parse.handleQuote | private function handleQuote(array &$emailAddress)
{
if ($emailAddress['quote_temp']) {
$emailAddress['name_parsed'] .= $emailAddress['quote_temp'];
$emailAddress['name_quoted'] = true;
$emailAddress['quote_temp'] = '';
} elseif ($emailAddress['address_temp']) {
$emailAddress['name_parsed'] .= $emailAddress['address_temp'];
$emailAddress['name_quoted'] = $emailAddress['address_temp_quoted'];
$emailAddress['address_temp_quoted'] = false;
$emailAddress['address_temp'] = '';
if ($emailAddress['address_temp_period'] > 0) {
$emailAddress['invalid'] = true;
$emailAddress['invalid_reason'] = 'Periods within the name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com>';
}
}
} | php | private function handleQuote(array &$emailAddress)
{
if ($emailAddress['quote_temp']) {
$emailAddress['name_parsed'] .= $emailAddress['quote_temp'];
$emailAddress['name_quoted'] = true;
$emailAddress['quote_temp'] = '';
} elseif ($emailAddress['address_temp']) {
$emailAddress['name_parsed'] .= $emailAddress['address_temp'];
$emailAddress['name_quoted'] = $emailAddress['address_temp_quoted'];
$emailAddress['address_temp_quoted'] = false;
$emailAddress['address_temp'] = '';
if ($emailAddress['address_temp_period'] > 0) {
$emailAddress['invalid'] = true;
$emailAddress['invalid_reason'] = 'Periods within the name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com>';
}
}
} | [
"private",
"function",
"handleQuote",
"(",
"array",
"&",
"$",
"emailAddress",
")",
"{",
"if",
"(",
"$",
"emailAddress",
"[",
"'quote_temp'",
"]",
")",
"{",
"$",
"emailAddress",
"[",
"'name_parsed'",
"]",
".=",
"$",
"emailAddress",
"[",
"'quote_temp'",
"]",
... | Handles the case of a quoted name
@param array $emailAddress | [
"Handles",
"the",
"case",
"of",
"a",
"quoted",
"name"
] | 106326e5760c9d1d05c3aa392c1a3fbba72bf9c1 | https://github.com/mmucklo/email-parse/blob/106326e5760c9d1d05c3aa392c1a3fbba72bf9c1/src/Parse.php#L637-L653 |
38,827 | mmucklo/email-parse | src/Parse.php | Parse.validateDomainName | protected function validateDomainName($domain, $encoding = 'UTF-8')
{
if (mb_strlen($domain, $encoding) > 255) {
return ['valid' => false, 'reason' => 'Domain name too long'];
} else {
$origEncoding = mb_regex_encoding();
mb_regex_encoding($encoding);
$parts = mb_split('\\.', $domain);
mb_regex_encoding($origEncoding);
foreach ($parts as $part) {
if (mb_strlen($part, $encoding) > 63) {
return ['valid' => false, 'reason' => "Domain name part '${part}' too long"];
}
if (!preg_match('/^[a-zA-Z0-9\-]+$/', $part)) {
return ['valid' => false, 'reason' => "Domain name '${domain}' can only contain letters a through z, numbers 0 through 9 and hyphen. The part '${part}' contains characters outside of that range."];
}
if (mb_substr($part, 0, 1, $encoding) == '-' || mb_substr($part, mb_strlen($part) - 1, 1, $encoding) == '-') {
return ['valid' => false, 'reason' => "Parts of the domain name '${domain}' can not start or end with '-'. This part does: ${part}"];
}
}
}
// @TODO - possibly check DNS / MX records for domain to make sure it exists?
return ['valid' => true];
} | php | protected function validateDomainName($domain, $encoding = 'UTF-8')
{
if (mb_strlen($domain, $encoding) > 255) {
return ['valid' => false, 'reason' => 'Domain name too long'];
} else {
$origEncoding = mb_regex_encoding();
mb_regex_encoding($encoding);
$parts = mb_split('\\.', $domain);
mb_regex_encoding($origEncoding);
foreach ($parts as $part) {
if (mb_strlen($part, $encoding) > 63) {
return ['valid' => false, 'reason' => "Domain name part '${part}' too long"];
}
if (!preg_match('/^[a-zA-Z0-9\-]+$/', $part)) {
return ['valid' => false, 'reason' => "Domain name '${domain}' can only contain letters a through z, numbers 0 through 9 and hyphen. The part '${part}' contains characters outside of that range."];
}
if (mb_substr($part, 0, 1, $encoding) == '-' || mb_substr($part, mb_strlen($part) - 1, 1, $encoding) == '-') {
return ['valid' => false, 'reason' => "Parts of the domain name '${domain}' can not start or end with '-'. This part does: ${part}"];
}
}
}
// @TODO - possibly check DNS / MX records for domain to make sure it exists?
return ['valid' => true];
} | [
"protected",
"function",
"validateDomainName",
"(",
"$",
"domain",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"if",
"(",
"mb_strlen",
"(",
"$",
"domain",
",",
"$",
"encoding",
")",
">",
"255",
")",
"{",
"return",
"[",
"'valid'",
"=>",
"false",
","... | Determines whether the domain name is valid
@param string $domain The domain name to validate
@param string $encoding The encoding of the string (if not UTF-8)
@return array array('valid' => boolean: whether valid or not,
'reason' => string: if not valid, the reason why); | [
"Determines",
"whether",
"the",
"domain",
"name",
"is",
"valid"
] | 106326e5760c9d1d05c3aa392c1a3fbba72bf9c1 | https://github.com/mmucklo/email-parse/blob/106326e5760c9d1d05c3aa392c1a3fbba72bf9c1/src/Parse.php#L804-L828 |
38,828 | ua1-labs/firesql | Fire/Sql/Filter.php | Filter.where | public function where($propertyName)
{
$this->indexType(self::INDEX_SEARCH_TYPE_VALUE);
return $this->_addComparison(new WhereExpression($propertyName));
} | php | public function where($propertyName)
{
$this->indexType(self::INDEX_SEARCH_TYPE_VALUE);
return $this->_addComparison(new WhereExpression($propertyName));
} | [
"public",
"function",
"where",
"(",
"$",
"propertyName",
")",
"{",
"$",
"this",
"->",
"indexType",
"(",
"self",
"::",
"INDEX_SEARCH_TYPE_VALUE",
")",
";",
"return",
"$",
"this",
"->",
"_addComparison",
"(",
"new",
"WhereExpression",
"(",
"$",
"propertyName",
... | Adds a WHERE logic operator to the search statement.
@param string $propertyName The name of the property you would like to search on
@return \Fire\Sql\Filter\LogicExpression | [
"Adds",
"a",
"WHERE",
"logic",
"operator",
"to",
"the",
"search",
"statement",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Filter.php#L116-L120 |
38,829 | ua1-labs/firesql | Fire/Sql/Filter.php | Filter.filter | public function filter()
{
return (object) [
'type' => $this->_indexType,
'filters' => $this->_comparisons,
'order' => $this->_orderBy,
'reverse' => $this->_reverse,
'offset' => $this->_offset,
'length' => $this->_length
];
} | php | public function filter()
{
return (object) [
'type' => $this->_indexType,
'filters' => $this->_comparisons,
'order' => $this->_orderBy,
'reverse' => $this->_reverse,
'offset' => $this->_offset,
'length' => $this->_length
];
} | [
"public",
"function",
"filter",
"(",
")",
"{",
"return",
"(",
"object",
")",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"_indexType",
",",
"'filters'",
"=>",
"$",
"this",
"->",
"_comparisons",
",",
"'order'",
"=>",
"$",
"this",
"->",
"_orderBy",
",",
"'re... | Returns the filter model
@return object | [
"Returns",
"the",
"filter",
"model"
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Filter.php#L251-L261 |
38,830 | ua1-labs/firesql | Fire/Sql/Filter.php | Filter._addComparison | private function _addComparison(LogicExpression $logicExpression) {
$this->_comparisons[] = $logicExpression;
end($this->_comparisons);
$i = key($this->_comparisons);
return $this->_comparisons[$i];
} | php | private function _addComparison(LogicExpression $logicExpression) {
$this->_comparisons[] = $logicExpression;
end($this->_comparisons);
$i = key($this->_comparisons);
return $this->_comparisons[$i];
} | [
"private",
"function",
"_addComparison",
"(",
"LogicExpression",
"$",
"logicExpression",
")",
"{",
"$",
"this",
"->",
"_comparisons",
"[",
"]",
"=",
"$",
"logicExpression",
";",
"end",
"(",
"$",
"this",
"->",
"_comparisons",
")",
";",
"$",
"i",
"=",
"key",... | Used to add logic expressions to the _comparisons array.
@param LogicExpression $logicExpression
@return \Fire\Sql\Filter\LogicExpression | [
"Used",
"to",
"add",
"logic",
"expressions",
"to",
"the",
"_comparisons",
"array",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Filter.php#L268-L273 |
38,831 | ua1-labs/firesql | Fire/Sql/Filter.php | Filter._addFilterComparison | private function _addFilterComparison($firstObj, $firstProperty, $property, $value)
{
if ($firstObj && $firstProperty) {
$this->_parseComparison(self::COMPARISON_LOGIC_WHERE, $property, $value);
} else if (!$firstObj && $firstProperty) {
$this->_parseComparison(self::COMPARISON_LOGIC_OR, $property, $value);
} else {
$this->_parseComparison(self::COMPARISON_LOGIC_AND, $property, $value);
}
} | php | private function _addFilterComparison($firstObj, $firstProperty, $property, $value)
{
if ($firstObj && $firstProperty) {
$this->_parseComparison(self::COMPARISON_LOGIC_WHERE, $property, $value);
} else if (!$firstObj && $firstProperty) {
$this->_parseComparison(self::COMPARISON_LOGIC_OR, $property, $value);
} else {
$this->_parseComparison(self::COMPARISON_LOGIC_AND, $property, $value);
}
} | [
"private",
"function",
"_addFilterComparison",
"(",
"$",
"firstObj",
",",
"$",
"firstProperty",
",",
"$",
"property",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"firstObj",
"&&",
"$",
"firstProperty",
")",
"{",
"$",
"this",
"->",
"_parseComparison",
"(",... | Adds a comparison to the filter from the queryString
@param boolean $firstObj
@param boolean $firstProperty
@param string $property
@param mixed $value
@return void | [
"Adds",
"a",
"comparison",
"to",
"the",
"filter",
"from",
"the",
"queryString"
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Filter.php#L323-L332 |
38,832 | ua1-labs/firesql | Fire/Sql/Filter.php | Filter._parseComparison | private function _parseComparison($compareLogic, $property, $value)
{
switch ($property) {
case self::FILTER_CONFIG_LENGTH:
$this->length($value);
break;
case self::FILTER_CONFIG_OFFSET:
$this->offset($value);
break;
case self::FILTER_CONFIG_ORDER_BY:
$this->orderBy($value);
break;
case self::FILTER_CONFIG_REVERSE:
$this->reverse($value);
break;
default:
$compare = $this->_extractComparisonTypeAndValue($value);
$compareType = $compare->type;
$compareValue = $compare->value;
$this->{$compareLogic}($property)->{$compareType}($compareValue);
}
} | php | private function _parseComparison($compareLogic, $property, $value)
{
switch ($property) {
case self::FILTER_CONFIG_LENGTH:
$this->length($value);
break;
case self::FILTER_CONFIG_OFFSET:
$this->offset($value);
break;
case self::FILTER_CONFIG_ORDER_BY:
$this->orderBy($value);
break;
case self::FILTER_CONFIG_REVERSE:
$this->reverse($value);
break;
default:
$compare = $this->_extractComparisonTypeAndValue($value);
$compareType = $compare->type;
$compareValue = $compare->value;
$this->{$compareLogic}($property)->{$compareType}($compareValue);
}
} | [
"private",
"function",
"_parseComparison",
"(",
"$",
"compareLogic",
",",
"$",
"property",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"property",
")",
"{",
"case",
"self",
"::",
"FILTER_CONFIG_LENGTH",
":",
"$",
"this",
"->",
"length",
"(",
"$",
"v... | Parses comparisons and adds logic to the filter.
@param string $compareLogic
@param string $property
@param mixed $value
@return void | [
"Parses",
"comparisons",
"and",
"adds",
"logic",
"to",
"the",
"filter",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Filter.php#L341-L362 |
38,833 | ua1-labs/firesql | Fire/Sql/Filter.php | Filter._extractComparisonTypeAndValue | private function _extractComparisonTypeAndValue($val)
{
$validComparisons = [
self::COMPARISON_TYPE_GREATERTHAN_EQUAL,
self::COMPARISON_TYPE_LESSTHAN_EQUAL,
self::COMPARISON_TYPE_NOT_EQUAL,
self::COMPARISON_TYPE_GREATERTHAN,
self::COMPARISON_TYPE_LESSTHAN,
self::METHOD_LOGIC_TYPE_EQUAL
];
$comparison = substr($val, 0, 2);
switch ($comparison) {
case self::COMPARISON_TYPE_GREATERTHAN_EQUAL:
$type = self::METHOD_LOGIC_TYPE_GREATERTHAN_EQUAL;
break;
case self::COMPARISON_TYPE_LESSTHAN_EQUAL:
$type = self::METHOD_LOGIC_TYPE_LESSTHAN_EQUAL;
break;
case self::COMPARISON_TYPE_NOT_EQUAL:
$type = self::METHOD_LOGIC_TYPE_NOT_EQUAL;
break;
}
if (empty($type)) {
$comparison = substr($val, 0, 1);
switch ($comparison) {
case self::COMPARISON_TYPE_GREATERTHAN:
$type = self::METHOD_LOGIC_TYPE_GREATERTHAN;
break;
case self::COMPARISON_TYPE_LESSTHAN:
$type = self::METHOD_LOGIC_TYPE_LESSTHAN;
break;
default:
$type = self::METHOD_LOGIC_TYPE_EQUAL;
}
}
return (object) [
'type' => $type,
'value' => (is_string($val) && in_array($comparison, $validComparisons))
? str_replace($comparison, '', $val)
: $val
];
} | php | private function _extractComparisonTypeAndValue($val)
{
$validComparisons = [
self::COMPARISON_TYPE_GREATERTHAN_EQUAL,
self::COMPARISON_TYPE_LESSTHAN_EQUAL,
self::COMPARISON_TYPE_NOT_EQUAL,
self::COMPARISON_TYPE_GREATERTHAN,
self::COMPARISON_TYPE_LESSTHAN,
self::METHOD_LOGIC_TYPE_EQUAL
];
$comparison = substr($val, 0, 2);
switch ($comparison) {
case self::COMPARISON_TYPE_GREATERTHAN_EQUAL:
$type = self::METHOD_LOGIC_TYPE_GREATERTHAN_EQUAL;
break;
case self::COMPARISON_TYPE_LESSTHAN_EQUAL:
$type = self::METHOD_LOGIC_TYPE_LESSTHAN_EQUAL;
break;
case self::COMPARISON_TYPE_NOT_EQUAL:
$type = self::METHOD_LOGIC_TYPE_NOT_EQUAL;
break;
}
if (empty($type)) {
$comparison = substr($val, 0, 1);
switch ($comparison) {
case self::COMPARISON_TYPE_GREATERTHAN:
$type = self::METHOD_LOGIC_TYPE_GREATERTHAN;
break;
case self::COMPARISON_TYPE_LESSTHAN:
$type = self::METHOD_LOGIC_TYPE_LESSTHAN;
break;
default:
$type = self::METHOD_LOGIC_TYPE_EQUAL;
}
}
return (object) [
'type' => $type,
'value' => (is_string($val) && in_array($comparison, $validComparisons))
? str_replace($comparison, '', $val)
: $val
];
} | [
"private",
"function",
"_extractComparisonTypeAndValue",
"(",
"$",
"val",
")",
"{",
"$",
"validComparisons",
"=",
"[",
"self",
"::",
"COMPARISON_TYPE_GREATERTHAN_EQUAL",
",",
"self",
"::",
"COMPARISON_TYPE_LESSTHAN_EQUAL",
",",
"self",
"::",
"COMPARISON_TYPE_NOT_EQUAL",
... | Returns comparison value and type
@param mixed $val
@return object | [
"Returns",
"comparison",
"value",
"and",
"type"
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Filter.php#L369-L411 |
38,834 | yuan1994/ZCrawler | src/Schedule/School.php | School.parseHtml | public function parseHtml($html)
{
return Parser::table($html, '#DBGrid', [
'status', 'name', 'credit', 'examination', 'property', 'teacher', 'code', 'week',
['hour', function (Crawler $crawler) {
return $crawler->attr("title") ?: $crawler->text();
}],
['place', function (Crawler $crawler) {
return $crawler->text() == ";" ? '' : ($crawler->attr("title") ?: $crawler->text());
}],
'campus',
['class', function (Crawler $crawler) {
return $crawler->attr("title") ?: $crawler->text();
}],
], 12, 1, 'text');
} | php | public function parseHtml($html)
{
return Parser::table($html, '#DBGrid', [
'status', 'name', 'credit', 'examination', 'property', 'teacher', 'code', 'week',
['hour', function (Crawler $crawler) {
return $crawler->attr("title") ?: $crawler->text();
}],
['place', function (Crawler $crawler) {
return $crawler->text() == ";" ? '' : ($crawler->attr("title") ?: $crawler->text());
}],
'campus',
['class', function (Crawler $crawler) {
return $crawler->attr("title") ?: $crawler->text();
}],
], 12, 1, 'text');
} | [
"public",
"function",
"parseHtml",
"(",
"$",
"html",
")",
"{",
"return",
"Parser",
"::",
"table",
"(",
"$",
"html",
",",
"'#DBGrid'",
",",
"[",
"'status'",
",",
"'name'",
",",
"'credit'",
",",
"'examination'",
",",
"'property'",
",",
"'teacher'",
",",
"'... | Parse html to array
@param string $html
@return array | [
"Parse",
"html",
"to",
"array"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Schedule/School.php#L28-L43 |
38,835 | ua1-labs/firesql | Fire/Sql/Connector.php | Connector.exec | public function exec($sql) {
// get start time of sql execution
$start = $this->_firebug->timer();
// execute sql
$this->_pdo->exec($sql);
// record sql statement
if ($this->_firebug->isEnabled()) {
$trace = debug_backtrace();
$this->_recordSqlStatement($start, $sql, $trace);
}
} | php | public function exec($sql) {
// get start time of sql execution
$start = $this->_firebug->timer();
// execute sql
$this->_pdo->exec($sql);
// record sql statement
if ($this->_firebug->isEnabled()) {
$trace = debug_backtrace();
$this->_recordSqlStatement($start, $sql, $trace);
}
} | [
"public",
"function",
"exec",
"(",
"$",
"sql",
")",
"{",
"// get start time of sql execution",
"$",
"start",
"=",
"$",
"this",
"->",
"_firebug",
"->",
"timer",
"(",
")",
";",
"// execute sql",
"$",
"this",
"->",
"_pdo",
"->",
"exec",
"(",
"$",
"sql",
")"... | Executes a SQL statement. This method is meant for executing
SQL statements that manipulate data within the database.
@param string $sql
@return void | [
"Executes",
"a",
"SQL",
"statement",
".",
"This",
"method",
"is",
"meant",
"for",
"executing",
"SQL",
"statements",
"that",
"manipulate",
"data",
"within",
"the",
"database",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Connector.php#L58-L68 |
38,836 | ua1-labs/firesql | Fire/Sql/Connector.php | Connector.query | public function query($sql)
{
// get start time of sql execution
$start = $this->_firebug->timer();
// execute sql
$records = $this->_pdo->query($sql);
// record sql statement
if ($this->_firebug->isEnabled()) {
$trace = debug_backtrace();
$this->_recordSqlStatement($start, $sql, $trace);
}
return $records;
} | php | public function query($sql)
{
// get start time of sql execution
$start = $this->_firebug->timer();
// execute sql
$records = $this->_pdo->query($sql);
// record sql statement
if ($this->_firebug->isEnabled()) {
$trace = debug_backtrace();
$this->_recordSqlStatement($start, $sql, $trace);
}
return $records;
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
")",
"{",
"// get start time of sql execution",
"$",
"start",
"=",
"$",
"this",
"->",
"_firebug",
"->",
"timer",
"(",
")",
";",
"// execute sql",
"$",
"records",
"=",
"$",
"this",
"->",
"_pdo",
"->",
"query",... | Executes a SQL query. This meathod is meant for executing
SQL queries that will return records.
@param string $sql
@return array | [
"Executes",
"a",
"SQL",
"query",
".",
"This",
"meathod",
"is",
"meant",
"for",
"executing",
"SQL",
"queries",
"that",
"will",
"return",
"records",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Connector.php#L76-L89 |
38,837 | ua1-labs/firesql | Fire/Sql/Connector.php | Connector._recordSqlStatement | private function _recordSqlStatement($start, $sql, $trace)
{
$sqlStatement = new SqlStatement();
$sqlStatement->setStatement($sql);
$sqlStatement->setTime($this->_firebug->timer($start));
$sqlStatement->setTrace($trace);
$this->_firebug
->getPanel(FireSqlPanel::ID)
->addSqlStatement($sqlStatement);
} | php | private function _recordSqlStatement($start, $sql, $trace)
{
$sqlStatement = new SqlStatement();
$sqlStatement->setStatement($sql);
$sqlStatement->setTime($this->_firebug->timer($start));
$sqlStatement->setTrace($trace);
$this->_firebug
->getPanel(FireSqlPanel::ID)
->addSqlStatement($sqlStatement);
} | [
"private",
"function",
"_recordSqlStatement",
"(",
"$",
"start",
",",
"$",
"sql",
",",
"$",
"trace",
")",
"{",
"$",
"sqlStatement",
"=",
"new",
"SqlStatement",
"(",
")",
";",
"$",
"sqlStatement",
"->",
"setStatement",
"(",
"$",
"sql",
")",
";",
"$",
"s... | Records SQL statements to the FireBug Panel created to
track SQL queries.
@param float $start A timestamp created by FireBug::timer()
@param string $sql The SQL Statement to Record
@param array $trace The trace generated by debug_backtrace()
@return void | [
"Records",
"SQL",
"statements",
"to",
"the",
"FireBug",
"Panel",
"created",
"to",
"track",
"SQL",
"queries",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Connector.php#L109-L118 |
38,838 | yuan1994/ZCrawler | src/Core/AbstractAPIBase.php | AbstractAPIBase.request | protected function request($method, array $args)
{
$http = $this->getHttp();
// If didn`t set $args then set $args to the empty array
$args = array_replace(['', [], []], $args);
// Set the cookies
if (!isset($args[2]['cookies'])) {
$args[2]['cookies'] = $this->getCookie();
// Set the query string xh
$args[2]['query']['xh'] = $this->getUserName();
}
// Set the proxy and cross the campus network vpn
if (Config::get('proxy_status', false)) {
$args[2]['proxy'] = Config::get('proxy', '');
}
// Set the request headers
if ($headers = Config::get('http_headers')) {
$args[2]['headers'] = $headers;
}
// Get the viewstate field
if (isset($args[1]['__VIEWSTATE']) && true === $args[1]['__VIEWSTATE']) {
$args[1]['__VIEWSTATE'] = $this->getViewsState($args[0]);
}
// Set the uri prefix for the cookies in url
$args[0] = Config::get('param.url_prefix', '') . $args[0];
// Try to get the response
$response = call_user_func_array([$http, $method], $args);
// Check whether need to request again with the url prefix
$body = (string)$response->getBody();
// The case of "Object moved to <a href='/(palpi545qhgbee55fvfekz45)/path.aspx" retry to new uri
if (preg_match('/Object\ moved\ to\ <a\ href=[\'"]?\/(\(\w+\))/i', $body, $matches)) {
// Set the new retry request`s uri
$uriPrefix = $matches[1] . '/';
Config::set('param.url_prefix', $uriPrefix);
// Reset the request url path and request again
$args[0] = $uriPrefix . $args[0];
$response = call_user_func_array([$http, $method], $args);
}
return $response;
} | php | protected function request($method, array $args)
{
$http = $this->getHttp();
// If didn`t set $args then set $args to the empty array
$args = array_replace(['', [], []], $args);
// Set the cookies
if (!isset($args[2]['cookies'])) {
$args[2]['cookies'] = $this->getCookie();
// Set the query string xh
$args[2]['query']['xh'] = $this->getUserName();
}
// Set the proxy and cross the campus network vpn
if (Config::get('proxy_status', false)) {
$args[2]['proxy'] = Config::get('proxy', '');
}
// Set the request headers
if ($headers = Config::get('http_headers')) {
$args[2]['headers'] = $headers;
}
// Get the viewstate field
if (isset($args[1]['__VIEWSTATE']) && true === $args[1]['__VIEWSTATE']) {
$args[1]['__VIEWSTATE'] = $this->getViewsState($args[0]);
}
// Set the uri prefix for the cookies in url
$args[0] = Config::get('param.url_prefix', '') . $args[0];
// Try to get the response
$response = call_user_func_array([$http, $method], $args);
// Check whether need to request again with the url prefix
$body = (string)$response->getBody();
// The case of "Object moved to <a href='/(palpi545qhgbee55fvfekz45)/path.aspx" retry to new uri
if (preg_match('/Object\ moved\ to\ <a\ href=[\'"]?\/(\(\w+\))/i', $body, $matches)) {
// Set the new retry request`s uri
$uriPrefix = $matches[1] . '/';
Config::set('param.url_prefix', $uriPrefix);
// Reset the request url path and request again
$args[0] = $uriPrefix . $args[0];
$response = call_user_func_array([$http, $method], $args);
}
return $response;
} | [
"protected",
"function",
"request",
"(",
"$",
"method",
",",
"array",
"$",
"args",
")",
"{",
"$",
"http",
"=",
"$",
"this",
"->",
"getHttp",
"(",
")",
";",
"// If didn`t set $args then set $args to the empty array",
"$",
"args",
"=",
"array_replace",
"(",
"[",... | Send a request with some options
@param string $method
@param array $args
@return ResponseInterface | [
"Send",
"a",
"request",
"with",
"some",
"options"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Core/AbstractAPIBase.php#L107-L147 |
38,839 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection.find | public function find($filter = null)
{
if (is_string($filter)) {
json_decode($filter);
$isJson = (json_last_error() === JSON_ERROR_NONE) ? true :false;
if ($isJson) {
$filter = new Filter($filter);
return $this->_getObjectsByFilter($filter);
} else {
return $this->_getObject($filter);
}
} else if (is_object($filter) && $filter instanceof Filter) {
return $this->_getObjectsByFilter($filter);
}
return [];
} | php | public function find($filter = null)
{
if (is_string($filter)) {
json_decode($filter);
$isJson = (json_last_error() === JSON_ERROR_NONE) ? true :false;
if ($isJson) {
$filter = new Filter($filter);
return $this->_getObjectsByFilter($filter);
} else {
return $this->_getObject($filter);
}
} else if (is_object($filter) && $filter instanceof Filter) {
return $this->_getObjectsByFilter($filter);
}
return [];
} | [
"public",
"function",
"find",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"filter",
")",
")",
"{",
"json_decode",
"(",
"$",
"filter",
")",
";",
"$",
"isJson",
"=",
"(",
"json_last_error",
"(",
")",
"===",
"JSON_ERROR_... | Returns a collection of objects that match the filter criteria
@param string|null|Fire\Sql\Filter $filter
@return void | [
"Returns",
"a",
"collection",
"of",
"objects",
"that",
"match",
"the",
"filter",
"criteria"
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L86-L101 |
38,840 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection.delete | public function delete($id)
{
$delete = Statement::get(
'DELETE_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$delete .= Statement::get(
'DELETE_OBJECT',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$this->_connector->exec($delete);
} | php | public function delete($id)
{
$delete = Statement::get(
'DELETE_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$delete .= Statement::get(
'DELETE_OBJECT',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$this->_connector->exec($delete);
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"delete",
"=",
"Statement",
"::",
"get",
"(",
"'DELETE_OBJECT_INDEX'",
",",
"[",
"'@collection'",
"=>",
"$",
"this",
"->",
"_name",
",",
"'@id'",
"=>",
"$",
"this",
"->",
"_connector",
"->",
... | Deletes an object from the database.
@param string $id The ID of the object you want to delete
@return void | [
"Deletes",
"an",
"object",
"from",
"the",
"database",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L129-L147 |
38,841 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection.count | public function count($filter = null)
{
if (is_null($filter)) {
return $this->_countObjectsInCollection();
} else if (is_string($filter)) {
json_decode($filter);
$isJson = (json_last_error() === JSON_ERROR_NONE) ? true :false;
if ($isJson) {
$filter = new Filter($filter);
return $this->_countObjectsInCollectionByFilter($filter);
}
} else if (is_object($filter) && $filter instanceof Filter) {
return $this->_countObjectsInCollectionByFilter($filter);
}
return 0;
} | php | public function count($filter = null)
{
if (is_null($filter)) {
return $this->_countObjectsInCollection();
} else if (is_string($filter)) {
json_decode($filter);
$isJson = (json_last_error() === JSON_ERROR_NONE) ? true :false;
if ($isJson) {
$filter = new Filter($filter);
return $this->_countObjectsInCollectionByFilter($filter);
}
} else if (is_object($filter) && $filter instanceof Filter) {
return $this->_countObjectsInCollectionByFilter($filter);
}
return 0;
} | [
"public",
"function",
"count",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"filter",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_countObjectsInCollection",
"(",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",... | Returns the total number of objects in a collection.
@param string|null|Fire\Sql\Filter $filter
@return int | [
"Returns",
"the",
"total",
"number",
"of",
"objects",
"in",
"a",
"collection",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L154-L169 |
38,842 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._commitObject | private function _commitObject($id, $revision)
{
$update = '';
//if version tracking is disabled, delete previous revisions of the object
if (!$this->_options->versionTracking) {
$update .= Statement::get(
'DELETE_OBJECT_EXCEPT_REVISION',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id),
'@revision' => $this->_connector->quote($revision)
]
);
}
$update .= Statement::get(
'UPDATE_OBJECT_TO_COMMITTED',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id),
'@revision' => $this->_connector->quote($revision)
]
);
$this->_connector->exec($update);
} | php | private function _commitObject($id, $revision)
{
$update = '';
//if version tracking is disabled, delete previous revisions of the object
if (!$this->_options->versionTracking) {
$update .= Statement::get(
'DELETE_OBJECT_EXCEPT_REVISION',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id),
'@revision' => $this->_connector->quote($revision)
]
);
}
$update .= Statement::get(
'UPDATE_OBJECT_TO_COMMITTED',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id),
'@revision' => $this->_connector->quote($revision)
]
);
$this->_connector->exec($update);
} | [
"private",
"function",
"_commitObject",
"(",
"$",
"id",
",",
"$",
"revision",
")",
"{",
"$",
"update",
"=",
"''",
";",
"//if version tracking is disabled, delete previous revisions of the object",
"if",
"(",
"!",
"$",
"this",
"->",
"_options",
"->",
"versionTracking... | After an object has been fully indexed, the object needs to be updated to
indicated it is ready to be used within the collection.
@param string $id
@param int $revision
@return void | [
"After",
"an",
"object",
"has",
"been",
"fully",
"indexed",
"the",
"object",
"needs",
"to",
"be",
"updated",
"to",
"indicated",
"it",
"is",
"ready",
"to",
"be",
"used",
"within",
"the",
"collection",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L178-L202 |
38,843 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._generateAlphaToken | private function _generateAlphaToken()
{
$timestamp = strtotime($this->_generateTimestamp());
$characters = str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
shuffle($characters);
$randomString = '';
foreach (str_split((string) $timestamp) as $num) {
$randomString .= $characters[$num];
}
return $randomString;
} | php | private function _generateAlphaToken()
{
$timestamp = strtotime($this->_generateTimestamp());
$characters = str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
shuffle($characters);
$randomString = '';
foreach (str_split((string) $timestamp) as $num) {
$randomString .= $characters[$num];
}
return $randomString;
} | [
"private",
"function",
"_generateAlphaToken",
"(",
")",
"{",
"$",
"timestamp",
"=",
"strtotime",
"(",
"$",
"this",
"->",
"_generateTimestamp",
"(",
")",
")",
";",
"$",
"characters",
"=",
"str_split",
"(",
"'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
")"... | This method is used to dynamically create tokens to help manage
temporary tables within SQL queries.
@return string A randomly genereated token | [
"This",
"method",
"is",
"used",
"to",
"dynamically",
"create",
"tokens",
"to",
"help",
"manage",
"temporary",
"tables",
"within",
"SQL",
"queries",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L209-L219 |
38,844 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._generateTimestamp | private function _generateTimestamp()
{
$time = microtime(true);
$micro = sprintf('%06d', ($time - floor($time)) * 1000000);
$date = new DateTime(date('Y-m-d H:i:s.' . $micro, $time));
return $date->format("Y-m-d H:i:s.u");
} | php | private function _generateTimestamp()
{
$time = microtime(true);
$micro = sprintf('%06d', ($time - floor($time)) * 1000000);
$date = new DateTime(date('Y-m-d H:i:s.' . $micro, $time));
return $date->format("Y-m-d H:i:s.u");
} | [
"private",
"function",
"_generateTimestamp",
"(",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"micro",
"=",
"sprintf",
"(",
"'%06d'",
",",
"(",
"$",
"time",
"-",
"floor",
"(",
"$",
"time",
")",
")",
"*",
"1000000",
")",
";"... | Generates a timestamp with micro seconds.
@return string | [
"Generates",
"a",
"timestamp",
"with",
"micro",
"seconds",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L234-L240 |
38,845 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._generateUniqueId | private function _generateUniqueId()
{
$rand = uniqid(rand(10, 99));
$time = microtime(true);
$micro = sprintf('%06d', ($time - floor($time)) * 1000000);
$date = new DateTime(date('Y-m-d H:i:s.' . $micro, $time));
return sha1($date->format('YmdHisu'));
} | php | private function _generateUniqueId()
{
$rand = uniqid(rand(10, 99));
$time = microtime(true);
$micro = sprintf('%06d', ($time - floor($time)) * 1000000);
$date = new DateTime(date('Y-m-d H:i:s.' . $micro, $time));
return sha1($date->format('YmdHisu'));
} | [
"private",
"function",
"_generateUniqueId",
"(",
")",
"{",
"$",
"rand",
"=",
"uniqid",
"(",
"rand",
"(",
"10",
",",
"99",
")",
")",
";",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"micro",
"=",
"sprintf",
"(",
"'%06d'",
",",
"(",
... | Generates a unique id based on a timestamp so that it is truely unique.
@return string | [
"Generates",
"a",
"unique",
"id",
"based",
"on",
"a",
"timestamp",
"so",
"that",
"it",
"is",
"truely",
"unique",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L246-L253 |
38,846 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._getObject | private function _getObject($id, $revision = null)
{
if ($revision === null) {
$select = Statement::get(
'GET_CURRENT_OBJECT',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$record = $this->_connector->query($select)->fetch();
if ($record) {
return json_decode($record['obj']);
}
}
return null;
} | php | private function _getObject($id, $revision = null)
{
if ($revision === null) {
$select = Statement::get(
'GET_CURRENT_OBJECT',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$record = $this->_connector->query($select)->fetch();
if ($record) {
return json_decode($record['obj']);
}
}
return null;
} | [
"private",
"function",
"_getObject",
"(",
"$",
"id",
",",
"$",
"revision",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"revision",
"===",
"null",
")",
"{",
"$",
"select",
"=",
"Statement",
"::",
"get",
"(",
"'GET_CURRENT_OBJECT'",
",",
"[",
"'@collection'",
... | Returns an object in the collection. If the revision isn't provided, the
latest revision of the object will be returned.
@param string $id
@param int $revision
@return object|null | [
"Returns",
"an",
"object",
"in",
"the",
"collection",
".",
"If",
"the",
"revision",
"isn",
"t",
"provided",
"the",
"latest",
"revision",
"of",
"the",
"object",
"will",
"be",
"returned",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L262-L278 |
38,847 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._getObjectOrigin | private function _getObjectOrigin($id)
{
$select = Statement::get(
'GET_OBJECT_ORIGIN_DATE',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$record = $this->_connector->query($select)->fetch();
return ($record) ? $record['updated'] : null;
} | php | private function _getObjectOrigin($id)
{
$select = Statement::get(
'GET_OBJECT_ORIGIN_DATE',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($id)
]
);
$record = $this->_connector->query($select)->fetch();
return ($record) ? $record['updated'] : null;
} | [
"private",
"function",
"_getObjectOrigin",
"(",
"$",
"id",
")",
"{",
"$",
"select",
"=",
"Statement",
"::",
"get",
"(",
"'GET_OBJECT_ORIGIN_DATE'",
",",
"[",
"'@collection'",
"=>",
"$",
"this",
"->",
"_name",
",",
"'@id'",
"=>",
"$",
"this",
"->",
"_connec... | Returns an object's origin timestamp date.
@param string $id
@return string|null | [
"Returns",
"an",
"object",
"s",
"origin",
"timestamp",
"date",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L285-L296 |
38,848 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._getObjectsByFilter | private function _getObjectsByFilter(Filter $filterQuery)
{
$records = [];
$props = [];
$filters = [];
foreach ($filterQuery->getComparisons() as $comparison) {
$props[] = $comparison->prop;
if ($comparison->expression && $comparison->comparison && $comparison->prop) {
$expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
$prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
$compare = $comparison->comparison;
$value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
$filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
}
}
$props = array_unique($props);
$joins = [];
foreach ($props as $prop)
{
$standardFields = [
'__id',
'__type',
'__collection',
'__origin'
];
if (!in_array($prop, $standardFields)) {
$asTbl = $this->_generateAlphaToken();
$joins[] =
'JOIN(' .
'SELECT id, val AS ' . $prop . ' ' .
'FROM ' . $this->_name . '__index ' .
'WHERE prop = \'' . $prop . '\'' .
') AS ' . $asTbl . ' ' .
'ON A.id = ' . $asTbl . '.id';
}
}
$select = Statement::get(
'GET_OBJECTS_BY_FILTER',
[
'@collection' => $this->_name,
'@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
'@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
'@type' => $this->_connector->quote($filterQuery->getIndexType()),
'@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : '',
'@order' => $filterQuery->getOrderBy(),
'@reverse' => ($filterQuery->getReverse()) ? 'DESC' : 'ASC',
'@limit' => $filterQuery->getLength(),
'@offset' => $filterQuery->getOffset()
]
);
$result = $this->_connector->query($select);
if ($result) {
$records = $result->fetchAll();
}
return ($records) ? array_map([$this, '_mapObjectIds'], $records) : [];
} | php | private function _getObjectsByFilter(Filter $filterQuery)
{
$records = [];
$props = [];
$filters = [];
foreach ($filterQuery->getComparisons() as $comparison) {
$props[] = $comparison->prop;
if ($comparison->expression && $comparison->comparison && $comparison->prop) {
$expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
$prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
$compare = $comparison->comparison;
$value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
$filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
}
}
$props = array_unique($props);
$joins = [];
foreach ($props as $prop)
{
$standardFields = [
'__id',
'__type',
'__collection',
'__origin'
];
if (!in_array($prop, $standardFields)) {
$asTbl = $this->_generateAlphaToken();
$joins[] =
'JOIN(' .
'SELECT id, val AS ' . $prop . ' ' .
'FROM ' . $this->_name . '__index ' .
'WHERE prop = \'' . $prop . '\'' .
') AS ' . $asTbl . ' ' .
'ON A.id = ' . $asTbl . '.id';
}
}
$select = Statement::get(
'GET_OBJECTS_BY_FILTER',
[
'@collection' => $this->_name,
'@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
'@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
'@type' => $this->_connector->quote($filterQuery->getIndexType()),
'@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : '',
'@order' => $filterQuery->getOrderBy(),
'@reverse' => ($filterQuery->getReverse()) ? 'DESC' : 'ASC',
'@limit' => $filterQuery->getLength(),
'@offset' => $filterQuery->getOffset()
]
);
$result = $this->_connector->query($select);
if ($result) {
$records = $result->fetchAll();
}
return ($records) ? array_map([$this, '_mapObjectIds'], $records) : [];
} | [
"private",
"function",
"_getObjectsByFilter",
"(",
"Filter",
"$",
"filterQuery",
")",
"{",
"$",
"records",
"=",
"[",
"]",
";",
"$",
"props",
"=",
"[",
"]",
";",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filterQuery",
"->",
"getCompariso... | Returns a collection of objects that matches a filter.
@param Filter $filterQuery
@return array | [
"Returns",
"a",
"collection",
"of",
"objects",
"that",
"matches",
"a",
"filter",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L303-L361 |
38,849 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._isValueIndexable | public function _isValueIndexable($value)
{
return (
is_string($value)
|| is_null($value)
|| is_bool($value)
|| is_integer($value)
);
} | php | public function _isValueIndexable($value)
{
return (
is_string($value)
|| is_null($value)
|| is_bool($value)
|| is_integer($value)
);
} | [
"public",
"function",
"_isValueIndexable",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"is_string",
"(",
"$",
"value",
")",
"||",
"is_null",
"(",
"$",
"value",
")",
"||",
"is_bool",
"(",
"$",
"value",
")",
"||",
"is_integer",
"(",
"$",
"value",
")",
... | Determines if a value is indexable.
@param mixed $value
@return boolean | [
"Determines",
"if",
"a",
"value",
"is",
"indexable",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L379-L387 |
38,850 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._updateObjectIndexes | private function _updateObjectIndexes($object)
{
//delete all indexed references to this object
$update = Statement::get(
'DELETE_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($object->__id)
]
);
//parse each property of the object an attempt to index each value
foreach (get_object_vars($object) as $property => $value) {
if (
$this->_isPropertyIndexable($property)
&& $this->_isValueIndexable($value)
) {
$insert = Statement::get(
'INSERT_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@type' => $this->_connector->quote('value'),
'@prop' => $this->_connector->quote($property),
'@val' => $this->_connector->quote($value),
'@id' => $this->_connector->quote($object->__id),
'@origin' => $this->_connector->quote($object->__origin)
]
);
$update .= $insert;
}
}
//add the object registry index
$insert = Statement::get(
'INSERT_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@type' => $this->_connector->quote('registry'),
'@prop' => $this->_connector->quote(''),
'@val' => $this->_connector->quote(''),
'@id' => $this->_connector->quote($object->__id),
'@origin' => $this->_connector->quote($object->__origin)
]
);
$update .= $insert;
//execute all the sql to update indexes.
$this->_connector->exec($update);
} | php | private function _updateObjectIndexes($object)
{
//delete all indexed references to this object
$update = Statement::get(
'DELETE_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($object->__id)
]
);
//parse each property of the object an attempt to index each value
foreach (get_object_vars($object) as $property => $value) {
if (
$this->_isPropertyIndexable($property)
&& $this->_isValueIndexable($value)
) {
$insert = Statement::get(
'INSERT_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@type' => $this->_connector->quote('value'),
'@prop' => $this->_connector->quote($property),
'@val' => $this->_connector->quote($value),
'@id' => $this->_connector->quote($object->__id),
'@origin' => $this->_connector->quote($object->__origin)
]
);
$update .= $insert;
}
}
//add the object registry index
$insert = Statement::get(
'INSERT_OBJECT_INDEX',
[
'@collection' => $this->_name,
'@type' => $this->_connector->quote('registry'),
'@prop' => $this->_connector->quote(''),
'@val' => $this->_connector->quote(''),
'@id' => $this->_connector->quote($object->__id),
'@origin' => $this->_connector->quote($object->__origin)
]
);
$update .= $insert;
//execute all the sql to update indexes.
$this->_connector->exec($update);
} | [
"private",
"function",
"_updateObjectIndexes",
"(",
"$",
"object",
")",
"{",
"//delete all indexed references to this object",
"$",
"update",
"=",
"Statement",
"::",
"get",
"(",
"'DELETE_OBJECT_INDEX'",
",",
"[",
"'@collection'",
"=>",
"$",
"this",
"->",
"_name",
",... | Updates an object's "value" index.
@param object $object
@return void | [
"Updates",
"an",
"object",
"s",
"value",
"index",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L405-L450 |
38,851 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._upsert | private function _upsert($object, $id = null)
{
$object = $this->_writeObjectToDb($object, $id);
$this->_updateObjectIndexes($object);
$this->_commitObject($object->__id, $object->__revision);
return $object;
} | php | private function _upsert($object, $id = null)
{
$object = $this->_writeObjectToDb($object, $id);
$this->_updateObjectIndexes($object);
$this->_commitObject($object->__id, $object->__revision);
return $object;
} | [
"private",
"function",
"_upsert",
"(",
"$",
"object",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"_writeObjectToDb",
"(",
"$",
"object",
",",
"$",
"id",
")",
";",
"$",
"this",
"->",
"_updateObjectIndexes",
"(",
"$",... | Upserts an object into the collection. Since update and inserts are the same logic,
this method handles both.
@param object $object
@param string $id
@return void | [
"Upserts",
"an",
"object",
"into",
"the",
"collection",
".",
"Since",
"update",
"and",
"inserts",
"are",
"the",
"same",
"logic",
"this",
"method",
"handles",
"both",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L459-L465 |
38,852 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._writeObjectToDb | private function _writeObjectToDb($object, $id)
{
$objectId = (!is_null($id)) ? $id : $this->_generateUniqueId();
$origin = $this->_getObjectOrigin($objectId);
$object = json_decode(json_encode($object));
$object->__id = $objectId;
$object->__revision = $this->_generateRevisionNumber();
$object->__updated = $this->_generateTimestamp();
$object->__origin = ($origin) ? $origin : $object->__updated;
//insert into database
$insert = Statement::get(
'INSERT_OBJECT',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($object->__id),
'@revision' => $this->_connector->quote($object->__revision),
'@committed' => $this->_connector->quote(0),
'@updated' => $this->_connector->quote($object->__updated),
'@origin' => $this->_connector->quote($object->__origin),
'@obj' => $this->_connector->quote(json_encode($object))
]
);
$this->_connector->exec($insert);
return $object;
} | php | private function _writeObjectToDb($object, $id)
{
$objectId = (!is_null($id)) ? $id : $this->_generateUniqueId();
$origin = $this->_getObjectOrigin($objectId);
$object = json_decode(json_encode($object));
$object->__id = $objectId;
$object->__revision = $this->_generateRevisionNumber();
$object->__updated = $this->_generateTimestamp();
$object->__origin = ($origin) ? $origin : $object->__updated;
//insert into database
$insert = Statement::get(
'INSERT_OBJECT',
[
'@collection' => $this->_name,
'@id' => $this->_connector->quote($object->__id),
'@revision' => $this->_connector->quote($object->__revision),
'@committed' => $this->_connector->quote(0),
'@updated' => $this->_connector->quote($object->__updated),
'@origin' => $this->_connector->quote($object->__origin),
'@obj' => $this->_connector->quote(json_encode($object))
]
);
$this->_connector->exec($insert);
return $object;
} | [
"private",
"function",
"_writeObjectToDb",
"(",
"$",
"object",
",",
"$",
"id",
")",
"{",
"$",
"objectId",
"=",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"?",
"$",
"id",
":",
"$",
"this",
"->",
"_generateUniqueId",
"(",
")",
";",
"$",
"origin",... | Part of the upsert process, this method contains logic to write an object
to the database. This method will also add the appropriate meta data to the object
and return it.
@param object $object
@param string $id
@return object | [
"Part",
"of",
"the",
"upsert",
"process",
"this",
"method",
"contains",
"logic",
"to",
"write",
"an",
"object",
"to",
"the",
"database",
".",
"This",
"method",
"will",
"also",
"add",
"the",
"appropriate",
"meta",
"data",
"to",
"the",
"object",
"and",
"retu... | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L475-L500 |
38,853 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._countObjectsInCollection | private function _countObjectsInCollection()
{
$select = Statement::get(
'GET_COLLECTION_OBJECT_COUNT',
[
'@collection' => $this->_name
]
);
$count = $this->_connector->query($select)->fetch();
if ($count) {
return (int) $count[0];
} else {
return 0;
}
} | php | private function _countObjectsInCollection()
{
$select = Statement::get(
'GET_COLLECTION_OBJECT_COUNT',
[
'@collection' => $this->_name
]
);
$count = $this->_connector->query($select)->fetch();
if ($count) {
return (int) $count[0];
} else {
return 0;
}
} | [
"private",
"function",
"_countObjectsInCollection",
"(",
")",
"{",
"$",
"select",
"=",
"Statement",
"::",
"get",
"(",
"'GET_COLLECTION_OBJECT_COUNT'",
",",
"[",
"'@collection'",
"=>",
"$",
"this",
"->",
"_name",
"]",
")",
";",
"$",
"count",
"=",
"$",
"this",... | This method is used will return the count of objects contained with
the collection.
@return int | [
"This",
"method",
"is",
"used",
"will",
"return",
"the",
"count",
"of",
"objects",
"contained",
"with",
"the",
"collection",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L507-L521 |
38,854 | ua1-labs/firesql | Fire/Sql/Collection.php | Collection._countObjectsInCollectionByFilter | private function _countObjectsInCollectionByFilter(Filter $filterQuery)
{
$records = [];
$props = [];
$filters = [];
foreach ($filterQuery->getComparisons() as $comparison) {
$props[] = $comparison->prop;
if ($comparison->expression && $comparison->comparison && $comparison->prop) {
$expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
$prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
$compare = $comparison->comparison;
$value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
$filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
}
}
$props = array_unique($props);
$joins = [];
foreach ($props as $prop)
{
$standardFields = [
'__id',
'__type',
'__collection',
'__origin'
];
if (!in_array($prop, $standardFields)) {
$asTbl = $this->_generateAlphaToken();
$joins[] =
'JOIN(' .
'SELECT id, val AS ' . $prop . ' ' .
'FROM ' . $this->_name . '__index ' .
'WHERE prop = \'' . $prop . '\'' .
') AS ' . $asTbl . ' ' .
'ON A.id = ' . $asTbl . '.id';
}
}
$select = Statement::get(
'GET_OBJECTS_COUNT_BY_FILTER',
[
'@collection' => $this->_name,
'@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
'@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
'@type' => $this->_connector->quote($filterQuery->getIndexType()),
'@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : ''
]
);
$count = $this->_connector->query($select)->fetch();
if ($count) {
return (int) $count[0];
} else {
return 0;
}
} | php | private function _countObjectsInCollectionByFilter(Filter $filterQuery)
{
$records = [];
$props = [];
$filters = [];
foreach ($filterQuery->getComparisons() as $comparison) {
$props[] = $comparison->prop;
if ($comparison->expression && $comparison->comparison && $comparison->prop) {
$expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
$prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
$compare = $comparison->comparison;
$value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
$filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
}
}
$props = array_unique($props);
$joins = [];
foreach ($props as $prop)
{
$standardFields = [
'__id',
'__type',
'__collection',
'__origin'
];
if (!in_array($prop, $standardFields)) {
$asTbl = $this->_generateAlphaToken();
$joins[] =
'JOIN(' .
'SELECT id, val AS ' . $prop . ' ' .
'FROM ' . $this->_name . '__index ' .
'WHERE prop = \'' . $prop . '\'' .
') AS ' . $asTbl . ' ' .
'ON A.id = ' . $asTbl . '.id';
}
}
$select = Statement::get(
'GET_OBJECTS_COUNT_BY_FILTER',
[
'@collection' => $this->_name,
'@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
'@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
'@type' => $this->_connector->quote($filterQuery->getIndexType()),
'@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : ''
]
);
$count = $this->_connector->query($select)->fetch();
if ($count) {
return (int) $count[0];
} else {
return 0;
}
} | [
"private",
"function",
"_countObjectsInCollectionByFilter",
"(",
"Filter",
"$",
"filterQuery",
")",
"{",
"$",
"records",
"=",
"[",
"]",
";",
"$",
"props",
"=",
"[",
"]",
";",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filterQuery",
"->",
... | This method is used to return an object count by the filter that is passed in.
@param Filter $filterQuery
@return int | [
"This",
"method",
"is",
"used",
"to",
"return",
"an",
"object",
"count",
"by",
"the",
"filter",
"that",
"is",
"passed",
"in",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Collection.php#L528-L583 |
38,855 | yuan1994/ZCrawler | src/Grade/Cet.php | Cet.grade | public function grade()
{
$url = Config::get('url.grade_class_exam');
$response = $this->request('get', [$url]);
$body = $this->checkAndThrow($response);
return Parser::table($body, '#DataGrid1', [
'year', 'term', 'name', 'number', 'date', 'grade_all', 'grade_listening',
'grade_reading', 'grade_writing', 'grade_synthesizing',
], 10);
} | php | public function grade()
{
$url = Config::get('url.grade_class_exam');
$response = $this->request('get', [$url]);
$body = $this->checkAndThrow($response);
return Parser::table($body, '#DataGrid1', [
'year', 'term', 'name', 'number', 'date', 'grade_all', 'grade_listening',
'grade_reading', 'grade_writing', 'grade_synthesizing',
], 10);
} | [
"public",
"function",
"grade",
"(",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'url.grade_class_exam'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"'get'",
",",
"[",
"$",
"url",
"]",
")",
";",
"$",
"body",
"=",
... | Query student CET4 and CET6 grade
@return array | [
"Query",
"student",
"CET4",
"and",
"CET6",
"grade"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Grade/Cet.php#L28-L40 |
38,856 | yuan1994/ZCrawler | src/Support/Parser.php | Parser.schedule | public static function schedule($body, $selector = '#Table1')
{
$array = [];
$crawler = $body instanceof Crawler ? $body : new Crawler((string)$body);
// to array
$crawler->filter($selector)->children()->each(function (Crawler $node, $i) use (&$array) {
// 删除前两行
if ($i < 2) {
return false;
}
$array[] = $node->children()->each(function (Crawler $node, $j) {
$span = (int)$node->attr('rowspan') ?: 0;
return [$node->html(), $span];
});
});
// If there are some classes in the table is in two or more lines,
// insert it into the next lines in $array.
$lineCount = count($array);
$schedule = [];
for ($i = 0; $i < $lineCount; $i++) { // lines
for ($j = 0; $j < 9; $j++) { // rows
if (isset($array[$i][$j])) {
$k = $array[$i][$j][1];
while (--$k > 0) { // insert element to next line
// Set the span 0
$array[$i][$j][1] = 0;
$array[$i + $k] = array_merge(
array_slice($array[$i + $k], 0, $j),
[$array[$i][$j]],
array_splice($array[$i + $k], $j)
);
}
}
$schedule[$i][$j] = isset($array[$i][$j][0]) ? $array[$i][$j][0] : '';
}
}
return $schedule;
} | php | public static function schedule($body, $selector = '#Table1')
{
$array = [];
$crawler = $body instanceof Crawler ? $body : new Crawler((string)$body);
// to array
$crawler->filter($selector)->children()->each(function (Crawler $node, $i) use (&$array) {
// 删除前两行
if ($i < 2) {
return false;
}
$array[] = $node->children()->each(function (Crawler $node, $j) {
$span = (int)$node->attr('rowspan') ?: 0;
return [$node->html(), $span];
});
});
// If there are some classes in the table is in two or more lines,
// insert it into the next lines in $array.
$lineCount = count($array);
$schedule = [];
for ($i = 0; $i < $lineCount; $i++) { // lines
for ($j = 0; $j < 9; $j++) { // rows
if (isset($array[$i][$j])) {
$k = $array[$i][$j][1];
while (--$k > 0) { // insert element to next line
// Set the span 0
$array[$i][$j][1] = 0;
$array[$i + $k] = array_merge(
array_slice($array[$i + $k], 0, $j),
[$array[$i][$j]],
array_splice($array[$i + $k], $j)
);
}
}
$schedule[$i][$j] = isset($array[$i][$j][0]) ? $array[$i][$j][0] : '';
}
}
return $schedule;
} | [
"public",
"static",
"function",
"schedule",
"(",
"$",
"body",
",",
"$",
"selector",
"=",
"'#Table1'",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"$",
"crawler",
"=",
"$",
"body",
"instanceof",
"Crawler",
"?",
"$",
"body",
":",
"new",
"Crawler",
"(",... | Parser the schedule data.
@param string|Crawler $body
@param string $selector
@return array | [
"Parser",
"the",
"schedule",
"data",
"."
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Support/Parser.php#L26-L67 |
38,857 | yuan1994/ZCrawler | src/Support/Parser.php | Parser.fieldName | public static function fieldName($body, $fieldName, $attr = 'value')
{
$crawler = $body instanceof Crawler ? $body : new Crawler((string)$body);
return $crawler->filterXPath('//input[@name="' . $fieldName . '"]')->attr($attr);
} | php | public static function fieldName($body, $fieldName, $attr = 'value')
{
$crawler = $body instanceof Crawler ? $body : new Crawler((string)$body);
return $crawler->filterXPath('//input[@name="' . $fieldName . '"]')->attr($attr);
} | [
"public",
"static",
"function",
"fieldName",
"(",
"$",
"body",
",",
"$",
"fieldName",
",",
"$",
"attr",
"=",
"'value'",
")",
"{",
"$",
"crawler",
"=",
"$",
"body",
"instanceof",
"Crawler",
"?",
"$",
"body",
":",
"new",
"Crawler",
"(",
"(",
"string",
... | Parser the form control name`s attribute
@param string|object|Crawler $body
@param string $fieldName
@param string $attr
@return string | [
"Parser",
"the",
"form",
"control",
"name",
"s",
"attribute"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Support/Parser.php#L123-L128 |
38,858 | yuan1994/ZCrawler | src/Exam/Exam.php | Exam.current | public function current()
{
$url = Config::get('url.exam_basic');
$response = $this->request('get', [$url]);
return $this->parseExam($response);
} | php | public function current()
{
$url = Config::get('url.exam_basic');
$response = $this->request('get', [$url]);
return $this->parseExam($response);
} | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'url.exam_basic'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"'get'",
",",
"[",
"$",
"url",
"]",
")",
";",
"return",
"$",
"this",... | Query current exam
@return array | [
"Query",
"current",
"exam"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Exam/Exam.php#L26-L33 |
38,859 | yuan1994/ZCrawler | src/Exam/Exam.php | Exam.getByTerm | public function getByTerm($year, $term)
{
$url = Config::get('url.exam_basic');
$param['__VIEWSTATE'] = true;
$param['__EVENTTARGET'] = "xnd";
$param['__EVENTARGUMENT'] = "";
$param['xnd'] = $year;
$param['xqd'] = $term;
$response = $this->request('post', [$url, $param]);
return $this->parseExam($response);
} | php | public function getByTerm($year, $term)
{
$url = Config::get('url.exam_basic');
$param['__VIEWSTATE'] = true;
$param['__EVENTTARGET'] = "xnd";
$param['__EVENTARGUMENT'] = "";
$param['xnd'] = $year;
$param['xqd'] = $term;
$response = $this->request('post', [$url, $param]);
return $this->parseExam($response);
} | [
"public",
"function",
"getByTerm",
"(",
"$",
"year",
",",
"$",
"term",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'url.exam_basic'",
")",
";",
"$",
"param",
"[",
"'__VIEWSTATE'",
"]",
"=",
"true",
";",
"$",
"param",
"[",
"'__EVENTTARGET'",... | Get exam by the year and term
@param string $year
@param string|int $term
@return array | [
"Get",
"exam",
"by",
"the",
"year",
"and",
"term"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Exam/Exam.php#L43-L56 |
38,860 | yuan1994/ZCrawler | src/Exam/Exam.php | Exam.currentMakeUp | public function currentMakeUp()
{
$url = Config::get('url.exam_make_up');
$response = $this->request('get', [$url]);
return $this->parseMakeUpExam($response);
} | php | public function currentMakeUp()
{
$url = Config::get('url.exam_make_up');
$response = $this->request('get', [$url]);
return $this->parseMakeUpExam($response);
} | [
"public",
"function",
"currentMakeUp",
"(",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'url.exam_make_up'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"'get'",
",",
"[",
"$",
"url",
"]",
")",
";",
"return",
"$",
... | Query current make-up exam
@return array | [
"Query",
"current",
"make",
"-",
"up",
"exam"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Exam/Exam.php#L78-L85 |
38,861 | yuan1994/ZCrawler | src/Exam/Exam.php | Exam.getMakeUpByTerm | public function getMakeUpByTerm($year, $term)
{
$url = Config::get('url.exam_make_up');
$param['__VIEWSTATE'] = true;
$param['__EVENTTARGET'] = "xqd";
$param['__EVENTARGUMENT'] = "";
$param['__VIEWSTATEGENERATOR'] = "3F4872EB";
$param['xnd'] = $year;
$param['xqd'] = $term;
$response = $this->request('post', [$url, $param]);
return $this->parseMakeUpExam($response);
} | php | public function getMakeUpByTerm($year, $term)
{
$url = Config::get('url.exam_make_up');
$param['__VIEWSTATE'] = true;
$param['__EVENTTARGET'] = "xqd";
$param['__EVENTARGUMENT'] = "";
$param['__VIEWSTATEGENERATOR'] = "3F4872EB";
$param['xnd'] = $year;
$param['xqd'] = $term;
$response = $this->request('post', [$url, $param]);
return $this->parseMakeUpExam($response);
} | [
"public",
"function",
"getMakeUpByTerm",
"(",
"$",
"year",
",",
"$",
"term",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'url.exam_make_up'",
")",
";",
"$",
"param",
"[",
"'__VIEWSTATE'",
"]",
"=",
"true",
";",
"$",
"param",
"[",
"'__EVENTT... | Get make-up exam by the year and term
@param string $year
@param string|int $term
@return array | [
"Get",
"make",
"-",
"up",
"exam",
"by",
"the",
"year",
"and",
"term"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Exam/Exam.php#L95-L109 |
38,862 | yuan1994/ZCrawler | src/Schedule/Schedule.php | Schedule.current | public function current()
{
$url = $this->requestUrl;
$response = $this->request('get', [$url]);
return $this->parseSchedule($response);
} | php | public function current()
{
$url = $this->requestUrl;
$response = $this->request('get', [$url]);
return $this->parseSchedule($response);
} | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"requestUrl",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"'get'",
",",
"[",
"$",
"url",
"]",
")",
";",
"return",
"$",
"this",
"->",
"parseSchedul... | Get the current term`s schedule
@return array | [
"Get",
"the",
"current",
"term",
"s",
"schedule"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Schedule/Schedule.php#L47-L54 |
38,863 | yuan1994/ZCrawler | src/Schedule/Schedule.php | Schedule.getByTerm | public function getByTerm($year, $term)
{
$url = $this->requestUrl;
$param['__VIEWSTATE'] = true;
$param['__EVENTTARGET'] = "xnd";
$param['__EVENTARGUMENT'] = "";
$param['xnd'] = $year;
$param['xqd'] = $term;
$response = $this->request('post', [$url, $param]);
return $this->parseSchedule($response);
} | php | public function getByTerm($year, $term)
{
$url = $this->requestUrl;
$param['__VIEWSTATE'] = true;
$param['__EVENTTARGET'] = "xnd";
$param['__EVENTARGUMENT'] = "";
$param['xnd'] = $year;
$param['xqd'] = $term;
$response = $this->request('post', [$url, $param]);
return $this->parseSchedule($response);
} | [
"public",
"function",
"getByTerm",
"(",
"$",
"year",
",",
"$",
"term",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"requestUrl",
";",
"$",
"param",
"[",
"'__VIEWSTATE'",
"]",
"=",
"true",
";",
"$",
"param",
"[",
"'__EVENTTARGET'",
"]",
"=",
"\"xnd\... | Get schedule by the year and term
@param string $year
@param string|int $term
@return array | [
"Get",
"schedule",
"by",
"the",
"year",
"and",
"term"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Schedule/Schedule.php#L64-L77 |
38,864 | yuan1994/ZCrawler | src/Login/Login.php | Login.getCookie | public function getCookie($forceRefresh = false, $method = 'noCode')
{
$cacheKey = $this->getCacheKey();
$cookie = $this->getCache()->fetch($cacheKey);
if ($forceRefresh || empty($cookie)) {
if (is_array($method)) {
$cookie = call_user_func_array([$this, $method['method']], $method['param']);
} else {
$cookie = call_user_func([$this, $method]);
}
$this->setCookie($cookie);
}
return $cookie;
} | php | public function getCookie($forceRefresh = false, $method = 'noCode')
{
$cacheKey = $this->getCacheKey();
$cookie = $this->getCache()->fetch($cacheKey);
if ($forceRefresh || empty($cookie)) {
if (is_array($method)) {
$cookie = call_user_func_array([$this, $method['method']], $method['param']);
} else {
$cookie = call_user_func([$this, $method]);
}
$this->setCookie($cookie);
}
return $cookie;
} | [
"public",
"function",
"getCookie",
"(",
"$",
"forceRefresh",
"=",
"false",
",",
"$",
"method",
"=",
"'noCode'",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
";",
"$",
"cookie",
"=",
"$",
"this",
"->",
"getCache",
"(",
"... | Get the cookies for login.
@param bool $forceRefresh
@param string|array $method
@return mixed | [
"Get",
"the",
"cookies",
"for",
"login",
"."
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Login/Login.php#L61-L77 |
38,865 | yuan1994/ZCrawler | src/Login/Login.php | Login.setCookie | public function setCookie(CookieJar $cookie)
{
return $this->getCache()->save($this->getCacheKey(), $cookie, Config::get('cache.expire', 100));
} | php | public function setCookie(CookieJar $cookie)
{
return $this->getCache()->save($this->getCacheKey(), $cookie, Config::get('cache.expire', 100));
} | [
"public",
"function",
"setCookie",
"(",
"CookieJar",
"$",
"cookie",
")",
"{",
"return",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"save",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
",",
"$",
"cookie",
",",
"Config",
"::",
"get",
"(",
"'cac... | Set new cookies
@param CookieJar $cookie
@return bool | [
"Set",
"new",
"cookies"
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Login/Login.php#L86-L89 |
38,866 | yuan1994/ZCrawler | src/Login/Login.php | Login.getCaptcha | public function getCaptcha($path)
{
$url = Config::get('url.login_captcha');
$cookie = new CookieJar();
$codePath = $path . sha1($this->getUsername() . '-' . microtime(true)) . '.gif';
$options = ['cookies' => $cookie, 'save_to' => $codePath];
$response = $this->request('get', [$url, [], $options]);
// Check the StatusCode
if ($response->getStatusCode() == 200) {
throw new HttpException('get the captcha failed!', 10005);
}
return $codePath;
} | php | public function getCaptcha($path)
{
$url = Config::get('url.login_captcha');
$cookie = new CookieJar();
$codePath = $path . sha1($this->getUsername() . '-' . microtime(true)) . '.gif';
$options = ['cookies' => $cookie, 'save_to' => $codePath];
$response = $this->request('get', [$url, [], $options]);
// Check the StatusCode
if ($response->getStatusCode() == 200) {
throw new HttpException('get the captcha failed!', 10005);
}
return $codePath;
} | [
"public",
"function",
"getCaptcha",
"(",
"$",
"path",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'url.login_captcha'",
")",
";",
"$",
"cookie",
"=",
"new",
"CookieJar",
"(",
")",
";",
"$",
"codePath",
"=",
"$",
"path",
".",
"sha1",
"(",
... | Get the login captcha.
@param string $codePath
@return string | [
"Get",
"the",
"login",
"captcha",
"."
] | 46c48a7c1837e404c324811776fc60f7b2a80df6 | https://github.com/yuan1994/ZCrawler/blob/46c48a7c1837e404c324811776fc60f7b2a80df6/src/Login/Login.php#L160-L175 |
38,867 | ua1-labs/firesql | Fire/Sql/Statement.php | Statement.get | static public function get($sqlStatement, $variables = [])
{
if (!is_array(self::$_statements)) {
self::init();
}
$sql = self::$_statements[$sqlStatement];
if ($variables) {
foreach ($variables as $variable => $value) {
$sql = str_replace($variable, $value, $sql);
}
}
return $sql;
} | php | static public function get($sqlStatement, $variables = [])
{
if (!is_array(self::$_statements)) {
self::init();
}
$sql = self::$_statements[$sqlStatement];
if ($variables) {
foreach ($variables as $variable => $value) {
$sql = str_replace($variable, $value, $sql);
}
}
return $sql;
} | [
"static",
"public",
"function",
"get",
"(",
"$",
"sqlStatement",
",",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
"::",
"$",
"_statements",
")",
")",
"{",
"self",
"::",
"init",
"(",
")",
";",
"}",
"$",
"sql... | This method is responsible for returning the associated SQL statement
that has been prepared with the proper variables.
@param string $sqlStatement The key associated with the SQL statement you want to return
@param array $variables An array of variables
@return string | [
"This",
"method",
"is",
"responsible",
"for",
"returning",
"the",
"associated",
"SQL",
"statement",
"that",
"has",
"been",
"prepared",
"with",
"the",
"proper",
"variables",
"."
] | 9c2a480ad16429e659ba9f476c27b73c9b5c9a06 | https://github.com/ua1-labs/firesql/blob/9c2a480ad16429e659ba9f476c27b73c9b5c9a06/Fire/Sql/Statement.php#L117-L129 |
38,868 | obsh/sse-client | src/Client.php | Client.getEvents | public function getEvents()
{
$buffer = '';
$body = $this->response->getBody();
while (true) {
// if server close connection - try to reconnect
if ($body->eof()) {
// wait retry period before reconnection
sleep($this->retry / 1000);
$this->connect();
// clear buffer since there is no sense in partial message
$buffer = '';
}
$buffer .= $body->read(1);
if (preg_match(self::END_OF_MESSAGE, $buffer)) {
$parts = preg_split(self::END_OF_MESSAGE, $buffer, 2);
$rawMessage = $parts[0];
$remaining = $parts[1];
$buffer = $remaining;
$event = Event::parse($rawMessage);
// if message contains id set it to last received message id
if ($event->getId()) {
$this->lastId = $event->getId();
}
// take into account server request for reconnection delay
if ($event->getRetry()) {
$this->retry = $event->getRetry();
}
yield $event;
}
}
} | php | public function getEvents()
{
$buffer = '';
$body = $this->response->getBody();
while (true) {
// if server close connection - try to reconnect
if ($body->eof()) {
// wait retry period before reconnection
sleep($this->retry / 1000);
$this->connect();
// clear buffer since there is no sense in partial message
$buffer = '';
}
$buffer .= $body->read(1);
if (preg_match(self::END_OF_MESSAGE, $buffer)) {
$parts = preg_split(self::END_OF_MESSAGE, $buffer, 2);
$rawMessage = $parts[0];
$remaining = $parts[1];
$buffer = $remaining;
$event = Event::parse($rawMessage);
// if message contains id set it to last received message id
if ($event->getId()) {
$this->lastId = $event->getId();
}
// take into account server request for reconnection delay
if ($event->getRetry()) {
$this->retry = $event->getRetry();
}
yield $event;
}
}
} | [
"public",
"function",
"getEvents",
"(",
")",
"{",
"$",
"buffer",
"=",
"''",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"// if server close connection - try to reconnect",
"if",
"(",... | Returns generator that yields new event when it's available on stream.
@return Event[] | [
"Returns",
"generator",
"that",
"yields",
"new",
"event",
"when",
"it",
"s",
"available",
"on",
"stream",
"."
] | 4f459f735917e84723bfd80eb1461e3f791e33ce | https://github.com/obsh/sse-client/blob/4f459f735917e84723bfd80eb1461e3f791e33ce/src/Client.php#L65-L103 |
38,869 | Snowfire/Laravel-Postmark-Driver | src/Snowfire/Mail/PostmarkServiceProvider.php | PostmarkServiceProvider.registerPostmarkMailer | protected function registerPostmarkMailer()
{
$postmark = $this->app['config']->get('services.postmark', []);
$this->app->singleton('swift.mailer', function ($app) use ($postmark) {
return new Swift_Mailer(
new Swift_PostmarkTransport($postmark['api_key'])
);
});
} | php | protected function registerPostmarkMailer()
{
$postmark = $this->app['config']->get('services.postmark', []);
$this->app->singleton('swift.mailer', function ($app) use ($postmark) {
return new Swift_Mailer(
new Swift_PostmarkTransport($postmark['api_key'])
);
});
} | [
"protected",
"function",
"registerPostmarkMailer",
"(",
")",
"{",
"$",
"postmark",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'services.postmark'",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
... | Register the Postmark Swift Mailer.
@return void | [
"Register",
"the",
"Postmark",
"Swift",
"Mailer",
"."
] | f073dfe0d8e5d61bcb9a63719f51f8caec8aa9f6 | https://github.com/Snowfire/Laravel-Postmark-Driver/blob/f073dfe0d8e5d61bcb9a63719f51f8caec8aa9f6/src/Snowfire/Mail/PostmarkServiceProvider.php#L33-L42 |
38,870 | andegna/calender | src/Operations/Formatter.php | Formatter.getValueOfFormatCharacter | protected function getValueOfFormatCharacter(string $name, bool &$skip = false): string
{
if (($r = $this->shouldWeSkip($name, $skip)) !== false) {
return ''.$r;
}
if ($this->isOverrideFormatCharacter($name)) {
return ''.$this->{Constants::FORMAT_MAPPER[$name]}();
} | php | protected function getValueOfFormatCharacter(string $name, bool &$skip = false): string
{
if (($r = $this->shouldWeSkip($name, $skip)) !== false) {
return ''.$r;
}
if ($this->isOverrideFormatCharacter($name)) {
return ''.$this->{Constants::FORMAT_MAPPER[$name]}();
} | [
"protected",
"function",
"getValueOfFormatCharacter",
"(",
"string",
"$",
"name",
",",
"bool",
"&",
"$",
"skip",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"(",
"$",
"r",
"=",
"$",
"this",
"->",
"shouldWeSkip",
"(",
"$",
"name",
",",
"$",
"ski... | Return the value of the format character.
@param string $name of the field
@param bool $skip
@return string | [
"Return",
"the",
"value",
"of",
"the",
"format",
"character",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Operations/Formatter.php#L50-L58 |
38,871 | andegna/calender | src/Holiday/Easter.php | Easter.get | public function get(int $year)
{
// convert the Ethiopian year to a Julian year
// ሚያዝያ 1 is just a random day after the Gregorian new year
$julian_year = (int) DateTimeFactory::of($year, 8, 1)
->toGregorian()->format('Y');
// get the number of days from vernal equinox to the Easter in the given Julian year
$days_after = easter_days($julian_year, CAL_EASTER_ALWAYS_JULIAN);
// get the JDN of vernal equinox (March 21) in the given Julian year
$jdn = juliantojd(3, 21, $julian_year);
// add the number of days to Easter
$jdn += $days_after;
// create a Ethiopian Date to JDN converter
$con = new FromJdnConverter($jdn);
// create an Ethiopian date from the converter
return DateTimeFactory::of($con->getYear(), $con->getMonth(), $con->getDay(),
0, 0, 0, $this->dateTimeZone);
} | php | public function get(int $year)
{
// convert the Ethiopian year to a Julian year
// ሚያዝያ 1 is just a random day after the Gregorian new year
$julian_year = (int) DateTimeFactory::of($year, 8, 1)
->toGregorian()->format('Y');
// get the number of days from vernal equinox to the Easter in the given Julian year
$days_after = easter_days($julian_year, CAL_EASTER_ALWAYS_JULIAN);
// get the JDN of vernal equinox (March 21) in the given Julian year
$jdn = juliantojd(3, 21, $julian_year);
// add the number of days to Easter
$jdn += $days_after;
// create a Ethiopian Date to JDN converter
$con = new FromJdnConverter($jdn);
// create an Ethiopian date from the converter
return DateTimeFactory::of($con->getYear(), $con->getMonth(), $con->getDay(),
0, 0, 0, $this->dateTimeZone);
} | [
"public",
"function",
"get",
"(",
"int",
"$",
"year",
")",
"{",
"// convert the Ethiopian year to a Julian year",
"// ሚያዝያ 1 is just a random day after the Gregorian new year",
"$",
"julian_year",
"=",
"(",
"int",
")",
"DateTimeFactory",
"::",
"of",
"(",
"$",
"year",
",... | Get the easter date of a given Ethiopian year.
@param $year int Ethiopian year
@return \Andegna\DateTime | [
"Get",
"the",
"easter",
"date",
"of",
"a",
"given",
"Ethiopian",
"year",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Holiday/Easter.php#L34-L56 |
38,872 | andegna/calender | src/Converter/ToJdnConverter.php | ToJdnConverter.set | public function set(int $day, int $month, int $year)
{
$validator = new DateValidator($day, $month, $year);
if (!$validator->isValid()) {
throw new InvalidDateException();
}
$this->day = $day;
$this->month = $month;
$this->year = $year;
$this->jdn = (int) static::process($day, $month, $year);
return $this;
} | php | public function set(int $day, int $month, int $year)
{
$validator = new DateValidator($day, $month, $year);
if (!$validator->isValid()) {
throw new InvalidDateException();
}
$this->day = $day;
$this->month = $month;
$this->year = $year;
$this->jdn = (int) static::process($day, $month, $year);
return $this;
} | [
"public",
"function",
"set",
"(",
"int",
"$",
"day",
",",
"int",
"$",
"month",
",",
"int",
"$",
"year",
")",
"{",
"$",
"validator",
"=",
"new",
"DateValidator",
"(",
"$",
"day",
",",
"$",
"month",
",",
"$",
"year",
")",
";",
"if",
"(",
"!",
"$"... | Set the date for processing.
@param $day
@param $month
@param $year
@throws \Andegna\Exception\InvalidDateException
@return $this | [
"Set",
"the",
"date",
"for",
"processing",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Converter/ToJdnConverter.php#L38-L53 |
38,873 | andegna/calender | src/Validator/DateValidator.php | DateValidator.isValid | public function isValid()
{
$validators = [
'isDateValuesIntegers',
'isValidDayRange',
'isValidMonthRange',
'isValidPagumeDayRange',
'isValidLeapDay',
];
return array_reduce($validators, function ($result, $validator) {
return $result && $this->{$validator}();
}, true);
} | php | public function isValid()
{
$validators = [
'isDateValuesIntegers',
'isValidDayRange',
'isValidMonthRange',
'isValidPagumeDayRange',
'isValidLeapDay',
];
return array_reduce($validators, function ($result, $validator) {
return $result && $this->{$validator}();
}, true);
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"$",
"validators",
"=",
"[",
"'isDateValuesIntegers'",
",",
"'isValidDayRange'",
",",
"'isValidMonthRange'",
",",
"'isValidPagumeDayRange'",
",",
"'isValidLeapDay'",
",",
"]",
";",
"return",
"array_reduce",
"(",
"$",
... | validate the ethiopian date.
@return bool true if valid | [
"validate",
"the",
"ethiopian",
"date",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Validator/DateValidator.php#L52-L65 |
38,874 | andegna/calender | src/Converter/FromJdnConverter.php | FromJdnConverter.set | public function set(int $jdn)
{
if (!$this->isValidInteger($jdn)) {
throw new InvalidDateException();
}
$this->jdn = $jdn;
$date = static::process($jdn);
return $this->setDate($date);
} | php | public function set(int $jdn)
{
if (!$this->isValidInteger($jdn)) {
throw new InvalidDateException();
}
$this->jdn = $jdn;
$date = static::process($jdn);
return $this->setDate($date);
} | [
"public",
"function",
"set",
"(",
"int",
"$",
"jdn",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidInteger",
"(",
"$",
"jdn",
")",
")",
"{",
"throw",
"new",
"InvalidDateException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"jdn",
"=",
"$",
"j... | Set the JDN for processing.
@param $jdn
@throws \Andegna\Exception\InvalidDateException
@return $this | [
"Set",
"the",
"JDN",
"for",
"processing",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Converter/FromJdnConverter.php#L33-L44 |
38,875 | andegna/calender | src/Operations/Initiator.php | Initiator.updateComputedFields | protected function updateComputedFields()
{
// Julian Date Number of the available datetime
$jdn = $this->getJdnFromBase($this->dateTime);
$converter = new FromJdnConverter($jdn);
$this->setDateFromConverter($converter);
$this->cacheTimestamp();
$this->computeFields();
} | php | protected function updateComputedFields()
{
// Julian Date Number of the available datetime
$jdn = $this->getJdnFromBase($this->dateTime);
$converter = new FromJdnConverter($jdn);
$this->setDateFromConverter($converter);
$this->cacheTimestamp();
$this->computeFields();
} | [
"protected",
"function",
"updateComputedFields",
"(",
")",
"{",
"// Julian Date Number of the available datetime",
"$",
"jdn",
"=",
"$",
"this",
"->",
"getJdnFromBase",
"(",
"$",
"this",
"->",
"dateTime",
")",
";",
"$",
"converter",
"=",
"new",
"FromJdnConverter",
... | This fields are just for catching.
@return void | [
"This",
"fields",
"are",
"just",
"for",
"catching",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Operations/Initiator.php#L20-L30 |
38,876 | andegna/calender | src/Operations/Initiator.php | Initiator.getJdnFromBase | protected function getJdnFromBase(GregorianDateTime $dateTime): int
{
$year = $dateTime->format('Y');
$month = $dateTime->format('m');
$day = $dateTime->format('d');
return gregoriantojd($month, $day, $year);
} | php | protected function getJdnFromBase(GregorianDateTime $dateTime): int
{
$year = $dateTime->format('Y');
$month = $dateTime->format('m');
$day = $dateTime->format('d');
return gregoriantojd($month, $day, $year);
} | [
"protected",
"function",
"getJdnFromBase",
"(",
"GregorianDateTime",
"$",
"dateTime",
")",
":",
"int",
"{",
"$",
"year",
"=",
"$",
"dateTime",
"->",
"format",
"(",
"'Y'",
")",
";",
"$",
"month",
"=",
"$",
"dateTime",
"->",
"format",
"(",
"'m'",
")",
";... | Return the JDN of the given gregorian date time.
@param GregorianDateTime $dateTime
@return int | [
"Return",
"the",
"JDN",
"of",
"the",
"given",
"gregorian",
"date",
"time",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Operations/Initiator.php#L39-L46 |
38,877 | andegna/calender | src/Operations/Initiator.php | Initiator.setDateFromConverter | protected function setDateFromConverter(Converter $converter)
{
$this->year = $converter->getYear();
$this->month = $converter->getMonth();
$this->day = $converter->getDay();
} | php | protected function setDateFromConverter(Converter $converter)
{
$this->year = $converter->getYear();
$this->month = $converter->getMonth();
$this->day = $converter->getDay();
} | [
"protected",
"function",
"setDateFromConverter",
"(",
"Converter",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"year",
"=",
"$",
"converter",
"->",
"getYear",
"(",
")",
";",
"$",
"this",
"->",
"month",
"=",
"$",
"converter",
"->",
"getMonth",
"(",
")"... | Set the converted year, month and day from the given converter.
@param Converter $converter
@return void | [
"Set",
"the",
"converted",
"year",
"month",
"and",
"day",
"from",
"the",
"given",
"converter",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/Operations/Initiator.php#L55-L60 |
38,878 | andegna/calender | src/DateTimeFactory.php | DateTimeFactory.fromConverter | public static function fromConverter(Converter $con, DateTimeZone $dateTimeZone = null)
{
return static::of(
$con->getYear(), $con->getMonth(), $con->getDay(),
0, 0, 0, $dateTimeZone
);
} | php | public static function fromConverter(Converter $con, DateTimeZone $dateTimeZone = null)
{
return static::of(
$con->getYear(), $con->getMonth(), $con->getDay(),
0, 0, 0, $dateTimeZone
);
} | [
"public",
"static",
"function",
"fromConverter",
"(",
"Converter",
"$",
"con",
",",
"DateTimeZone",
"$",
"dateTimeZone",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"of",
"(",
"$",
"con",
"->",
"getYear",
"(",
")",
",",
"$",
"con",
"->",
"getMonth",... | Just for convenience.
@param Converter $con
@param DateTimeZone|null $dateTimeZone
@return DateTime the datetime u wanted | [
"Just",
"for",
"convenience",
"."
] | 66e868422d1ac771c5063021638d022a0dc571be | https://github.com/andegna/calender/blob/66e868422d1ac771c5063021638d022a0dc571be/src/DateTimeFactory.php#L118-L124 |
38,879 | xfra35/f3-multilang | lib/multilang.php | Multilang.isLocalized | function isLocalized($name,$lang=NULL) {
if (!isset($lang))
$lang=$this->current;
return !$this->isGlobal($name) && array_key_exists($name,$this->_aliases) &&
(!isset($this->rules[$lang][$name]) || $this->rules[$lang][$name]!==FALSE);
} | php | function isLocalized($name,$lang=NULL) {
if (!isset($lang))
$lang=$this->current;
return !$this->isGlobal($name) && array_key_exists($name,$this->_aliases) &&
(!isset($this->rules[$lang][$name]) || $this->rules[$lang][$name]!==FALSE);
} | [
"function",
"isLocalized",
"(",
"$",
"name",
",",
"$",
"lang",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"lang",
")",
")",
"$",
"lang",
"=",
"$",
"this",
"->",
"current",
";",
"return",
"!",
"$",
"this",
"->",
"isGlobal",
"(",
"... | Check if a route is localized in a given language
@param string $name
@param string $lang
@return bool | [
"Check",
"if",
"a",
"route",
"is",
"localized",
"in",
"a",
"given",
"language"
] | ffaf7eb49af12fdd61e89fb6c740a994c960975c | https://github.com/xfra35/f3-multilang/blob/ffaf7eb49af12fdd61e89fb6c740a994c960975c/lib/multilang.php#L88-L93 |
38,880 | xfra35/f3-multilang | lib/multilang.php | Multilang.detect | protected function detect($uri=NULL) {
$this->current=$this->primary;
if (preg_match('/^'.preg_quote($this->f3->get('BASE'),'/').'\/([^\/?]+)([\/?]|$)/',$uri?:$_SERVER['REQUEST_URI'],$m) &&
array_key_exists($m[1],$this->languages))
$this->current=$m[1];
else {//auto-detect language
$this->auto=TRUE;
$detected=array_intersect(explode(',',$this->f3->get('LANGUAGE')),explode(',',implode(',',$this->languages)));
if ($detected=reset($detected))
foreach($this->languages as $lang=>$locales)
if (in_array($detected,explode(',',$locales))) {
$this->current=$lang;
break;
}
}
$this->f3->set('LANGUAGE',$this->languages[$this->current]);
} | php | protected function detect($uri=NULL) {
$this->current=$this->primary;
if (preg_match('/^'.preg_quote($this->f3->get('BASE'),'/').'\/([^\/?]+)([\/?]|$)/',$uri?:$_SERVER['REQUEST_URI'],$m) &&
array_key_exists($m[1],$this->languages))
$this->current=$m[1];
else {//auto-detect language
$this->auto=TRUE;
$detected=array_intersect(explode(',',$this->f3->get('LANGUAGE')),explode(',',implode(',',$this->languages)));
if ($detected=reset($detected))
foreach($this->languages as $lang=>$locales)
if (in_array($detected,explode(',',$locales))) {
$this->current=$lang;
break;
}
}
$this->f3->set('LANGUAGE',$this->languages[$this->current]);
} | [
"protected",
"function",
"detect",
"(",
"$",
"uri",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"current",
"=",
"$",
"this",
"->",
"primary",
";",
"if",
"(",
"preg_match",
"(",
"'/^'",
".",
"preg_quote",
"(",
"$",
"this",
"->",
"f3",
"->",
"get",
"("... | ! Detects the current language | [
"!",
"Detects",
"the",
"current",
"language"
] | ffaf7eb49af12fdd61e89fb6c740a994c960975c | https://github.com/xfra35/f3-multilang/blob/ffaf7eb49af12fdd61e89fb6c740a994c960975c/lib/multilang.php#L173-L189 |
38,881 | xfra35/f3-multilang | lib/multilang.php | Multilang.rewrite | protected function rewrite() {
$routes=array();
$aliases=&$this->f3->ref('ALIASES');
$redirects=array();
foreach($this->f3->get('ROUTES') as $old=>$data) {
$route=current(current($data));//let's pick up any route just to get the URL name
$name=@$route[3];//PHP 5.3 compatibility
$new=$old;
if (!($name && in_array($name,$this->global_aliases)
|| isset($this->global_regex) && preg_match($this->global_regex,$old))) {
if (isset($this->rules[$this->current][$name])) {
$new=$this->rules[$this->current][$name];
if ($new===FALSE) {
if (isset($aliases[$name]))
unset($aliases[$name]);
continue;
}
}
$new=rtrim('/'.$this->current.($new),'/');
if ($this->migrate && $this->auto) {
$redir=$old;
if (isset($this->rules[$this->primary][$name]))
$redir=$this->rules[$this->primary][$name];
if ($redir!==FALSE)
$redirects[$old]=rtrim('/'.$this->primary.($redir),'/');
}
}
if (isset($routes[$new]) && $this->strict)
user_error(sprintf(self::E_Duplicate,$new),E_USER_ERROR);
$routes[$new]=$data;
if (isset($aliases[$name]))
$aliases[$name]=$new;
}
$this->f3->set('ROUTES',$routes);
foreach($redirects as $old=>$new)
$this->f3->route('GET '.$old,function($f3)use($new){$f3->reroute($new,TRUE);});
} | php | protected function rewrite() {
$routes=array();
$aliases=&$this->f3->ref('ALIASES');
$redirects=array();
foreach($this->f3->get('ROUTES') as $old=>$data) {
$route=current(current($data));//let's pick up any route just to get the URL name
$name=@$route[3];//PHP 5.3 compatibility
$new=$old;
if (!($name && in_array($name,$this->global_aliases)
|| isset($this->global_regex) && preg_match($this->global_regex,$old))) {
if (isset($this->rules[$this->current][$name])) {
$new=$this->rules[$this->current][$name];
if ($new===FALSE) {
if (isset($aliases[$name]))
unset($aliases[$name]);
continue;
}
}
$new=rtrim('/'.$this->current.($new),'/');
if ($this->migrate && $this->auto) {
$redir=$old;
if (isset($this->rules[$this->primary][$name]))
$redir=$this->rules[$this->primary][$name];
if ($redir!==FALSE)
$redirects[$old]=rtrim('/'.$this->primary.($redir),'/');
}
}
if (isset($routes[$new]) && $this->strict)
user_error(sprintf(self::E_Duplicate,$new),E_USER_ERROR);
$routes[$new]=$data;
if (isset($aliases[$name]))
$aliases[$name]=$new;
}
$this->f3->set('ROUTES',$routes);
foreach($redirects as $old=>$new)
$this->f3->route('GET '.$old,function($f3)use($new){$f3->reroute($new,TRUE);});
} | [
"protected",
"function",
"rewrite",
"(",
")",
"{",
"$",
"routes",
"=",
"array",
"(",
")",
";",
"$",
"aliases",
"=",
"&",
"$",
"this",
"->",
"f3",
"->",
"ref",
"(",
"'ALIASES'",
")",
";",
"$",
"redirects",
"=",
"array",
"(",
")",
";",
"foreach",
"... | ! Rewrite ROUTES and ALIASES | [
"!",
"Rewrite",
"ROUTES",
"and",
"ALIASES"
] | ffaf7eb49af12fdd61e89fb6c740a994c960975c | https://github.com/xfra35/f3-multilang/blob/ffaf7eb49af12fdd61e89fb6c740a994c960975c/lib/multilang.php#L192-L228 |
38,882 | hassansin/dbcart | src/Hassansin/DBCart/Models/Cart.php | Cart.current | public static function current($instance_name = 'default', $save_on_demand = null){
$save_on_demand = is_null($save_on_demand)? config('cart.save_on_demand', false): $save_on_demand;
return static::init($instance_name, $save_on_demand);
} | php | public static function current($instance_name = 'default', $save_on_demand = null){
$save_on_demand = is_null($save_on_demand)? config('cart.save_on_demand', false): $save_on_demand;
return static::init($instance_name, $save_on_demand);
} | [
"public",
"static",
"function",
"current",
"(",
"$",
"instance_name",
"=",
"'default'",
",",
"$",
"save_on_demand",
"=",
"null",
")",
"{",
"$",
"save_on_demand",
"=",
"is_null",
"(",
"$",
"save_on_demand",
")",
"?",
"config",
"(",
"'cart.save_on_demand'",
",",... | Get the current cart instance
@param string $instance_name
@return mixed | [
"Get",
"the",
"current",
"cart",
"instance"
] | eb44d6adc3819151fee2e8bea64c76dbdef3e01c | https://github.com/hassansin/dbcart/blob/eb44d6adc3819151fee2e8bea64c76dbdef3e01c/src/Hassansin/DBCart/Models/Cart.php#L106-L109 |
38,883 | hassansin/dbcart | src/Hassansin/DBCart/Models/Cart.php | Cart.init | public static function init($instance_name, $save_on_demand){
$request = app('request');
$session_id = $request->session()->getId();
$user_id = config('cart.user_id');
$app = Application::getInstance();
$carts = $app->offsetGet("cart_instances");
if ($user_id instanceof \Closure)
$user_id = $user_id();
//if user logged in
if( $user_id ){
$user_cart = static::active()->user()->where('name', $instance_name)->first();
$session_cart_id = $request->session()->get('cart_'.$instance_name);
$session_cart = is_null($session_cart_id)? null: static::active()->session($session_cart_id)->where('name', $instance_name)->first();
switch (true) {
case is_null($user_cart) && is_null($session_cart): //no user cart or session cart
$attributes = array(
'user_id' => $user_id,
'name' => $instance_name,
'status' => STATUS_ACTIVE
);
if($save_on_demand)
$cart = new static($attributes);
else
$cart = static::create($attributes);
break;
case !is_null($user_cart) && is_null($session_cart): //only user cart
$cart = $user_cart;
break;
case is_null($user_cart) && !is_null($session_cart): //only session cart
$cart = $session_cart;
$cart->user_id = $user_id;
$cart->session = null;
$cart->save();
break;
case !is_null($user_cart) && !is_null($session_cart): //both user cart and session cart exists
$session_cart->moveItemsTo($user_cart); //move items from session cart to user cart
$session_cart->delete(); //delete session cart
$cart = $user_cart;
break;
}
$request->session()->forget('cart_'.$instance_name); //no longer need it.
$carts[$instance_name] = $cart;
}
//guest user, create cart with session id
else{
$attributes = array(
'session' => $session_id,
'name' => $instance_name,
'status' => STATUS_ACTIVE
);
$cart = static::firstOrNew($attributes);
if(!$save_on_demand)
$cart->save();
//save current session id, since upon login session id will be regenerated
//we will use this id to get back the cart before login
$request->session()->put('cart_'.$instance_name, $session_id);
$carts[$instance_name] = $cart;
}
$app->offsetSet("cart_instances", $carts);
return $carts[$instance_name];
} | php | public static function init($instance_name, $save_on_demand){
$request = app('request');
$session_id = $request->session()->getId();
$user_id = config('cart.user_id');
$app = Application::getInstance();
$carts = $app->offsetGet("cart_instances");
if ($user_id instanceof \Closure)
$user_id = $user_id();
//if user logged in
if( $user_id ){
$user_cart = static::active()->user()->where('name', $instance_name)->first();
$session_cart_id = $request->session()->get('cart_'.$instance_name);
$session_cart = is_null($session_cart_id)? null: static::active()->session($session_cart_id)->where('name', $instance_name)->first();
switch (true) {
case is_null($user_cart) && is_null($session_cart): //no user cart or session cart
$attributes = array(
'user_id' => $user_id,
'name' => $instance_name,
'status' => STATUS_ACTIVE
);
if($save_on_demand)
$cart = new static($attributes);
else
$cart = static::create($attributes);
break;
case !is_null($user_cart) && is_null($session_cart): //only user cart
$cart = $user_cart;
break;
case is_null($user_cart) && !is_null($session_cart): //only session cart
$cart = $session_cart;
$cart->user_id = $user_id;
$cart->session = null;
$cart->save();
break;
case !is_null($user_cart) && !is_null($session_cart): //both user cart and session cart exists
$session_cart->moveItemsTo($user_cart); //move items from session cart to user cart
$session_cart->delete(); //delete session cart
$cart = $user_cart;
break;
}
$request->session()->forget('cart_'.$instance_name); //no longer need it.
$carts[$instance_name] = $cart;
}
//guest user, create cart with session id
else{
$attributes = array(
'session' => $session_id,
'name' => $instance_name,
'status' => STATUS_ACTIVE
);
$cart = static::firstOrNew($attributes);
if(!$save_on_demand)
$cart->save();
//save current session id, since upon login session id will be regenerated
//we will use this id to get back the cart before login
$request->session()->put('cart_'.$instance_name, $session_id);
$carts[$instance_name] = $cart;
}
$app->offsetSet("cart_instances", $carts);
return $carts[$instance_name];
} | [
"public",
"static",
"function",
"init",
"(",
"$",
"instance_name",
",",
"$",
"save_on_demand",
")",
"{",
"$",
"request",
"=",
"app",
"(",
"'request'",
")",
";",
"$",
"session_id",
"=",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"getId",
"(",
")",... | Initialize the cart
@param string $instance_name
@return mixed | [
"Initialize",
"the",
"cart"
] | eb44d6adc3819151fee2e8bea64c76dbdef3e01c | https://github.com/hassansin/dbcart/blob/eb44d6adc3819151fee2e8bea64c76dbdef3e01c/src/Hassansin/DBCart/Models/Cart.php#L117-L190 |
38,884 | hassansin/dbcart | src/Hassansin/DBCart/Models/Cart.php | Cart.addItem | public function addItem(array $attributes = []){
if($item = $this->getItem(collect($attributes)->except(['quantity']))){
$item->quantity += $attributes['quantity'];
$item->save();
return $item;
}
return $this->items()->create($attributes);
} | php | public function addItem(array $attributes = []){
if($item = $this->getItem(collect($attributes)->except(['quantity']))){
$item->quantity += $attributes['quantity'];
$item->save();
return $item;
}
return $this->items()->create($attributes);
} | [
"public",
"function",
"addItem",
"(",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"item",
"=",
"$",
"this",
"->",
"getItem",
"(",
"collect",
"(",
"$",
"attributes",
")",
"->",
"except",
"(",
"[",
"'quantity'",
"]",
")",
")"... | Add item to a cart. Increases quantity if the item already exists.
@param array $attributes | [
"Add",
"item",
"to",
"a",
"cart",
".",
"Increases",
"quantity",
"if",
"the",
"item",
"already",
"exists",
"."
] | eb44d6adc3819151fee2e8bea64c76dbdef3e01c | https://github.com/hassansin/dbcart/blob/eb44d6adc3819151fee2e8bea64c76dbdef3e01c/src/Hassansin/DBCart/Models/Cart.php#L211-L218 |
38,885 | hassansin/dbcart | src/Hassansin/DBCart/Models/Cart.php | Cart.updateItem | public function updateItem(array $where, array $values){
return $this->items()->where($where)->first()->update($values);
} | php | public function updateItem(array $where, array $values){
return $this->items()->where($where)->first()->update($values);
} | [
"public",
"function",
"updateItem",
"(",
"array",
"$",
"where",
",",
"array",
"$",
"values",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"(",
")",
"->",
"where",
"(",
"$",
"where",
")",
"->",
"first",
"(",
")",
"->",
"update",
"(",
"$",
"values... | update item in a cart
@param array $attributes | [
"update",
"item",
"in",
"a",
"cart"
] | eb44d6adc3819151fee2e8bea64c76dbdef3e01c | https://github.com/hassansin/dbcart/blob/eb44d6adc3819151fee2e8bea64c76dbdef3e01c/src/Hassansin/DBCart/Models/Cart.php#L234-L236 |
38,886 | hassansin/dbcart | src/Hassansin/DBCart/Models/Cart.php | Cart.clear | public function clear(){
$this->items()->delete();
$this->updateTimestamps();
$this->total_price = 0;
$this->item_count = 0;
$this->relations = [];
return $this->save();
} | php | public function clear(){
$this->items()->delete();
$this->updateTimestamps();
$this->total_price = 0;
$this->item_count = 0;
$this->relations = [];
return $this->save();
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"items",
"(",
")",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"updateTimestamps",
"(",
")",
";",
"$",
"this",
"->",
"total_price",
"=",
"0",
";",
"$",
"this",
"->",
"item_count... | Empties a cart | [
"Empties",
"a",
"cart"
] | eb44d6adc3819151fee2e8bea64c76dbdef3e01c | https://github.com/hassansin/dbcart/blob/eb44d6adc3819151fee2e8bea64c76dbdef3e01c/src/Hassansin/DBCart/Models/Cart.php#L286-L293 |
38,887 | hassansin/dbcart | src/Hassansin/DBCart/Models/Cart.php | Cart.moveItemsTo | public function moveItemsTo(Cart $cart){
\DB::transaction(function () use(&$cart){
$current_items = $cart->items()->pluck('product_id');
$items_to_move = $this->items()->whereNotIn('product_id', $current_items->toArray())->get();
if($items_to_move->count() === 0){
return;
}
$this->items()->whereNotIn('product_id', $current_items->toArray())->update([
'cart_id' => $cart->id
]);
foreach($items_to_move as $item) {
$this->item_count -= $item->quantity;
$this->total_price -= $item->getPrice();
$cart->item_count += $item->quantity;
$cart->total_price += $item->getPrice();
}
$this->relations = [];
$cart->relations = [];
$this->save();
$cart->save();
});
return $cart;
} | php | public function moveItemsTo(Cart $cart){
\DB::transaction(function () use(&$cart){
$current_items = $cart->items()->pluck('product_id');
$items_to_move = $this->items()->whereNotIn('product_id', $current_items->toArray())->get();
if($items_to_move->count() === 0){
return;
}
$this->items()->whereNotIn('product_id', $current_items->toArray())->update([
'cart_id' => $cart->id
]);
foreach($items_to_move as $item) {
$this->item_count -= $item->quantity;
$this->total_price -= $item->getPrice();
$cart->item_count += $item->quantity;
$cart->total_price += $item->getPrice();
}
$this->relations = [];
$cart->relations = [];
$this->save();
$cart->save();
});
return $cart;
} | [
"public",
"function",
"moveItemsTo",
"(",
"Cart",
"$",
"cart",
")",
"{",
"\\",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"cart",
")",
"{",
"$",
"current_items",
"=",
"$",
"cart",
"->",
"items",
"(",
")",
"->",
"plu... | Move Items to another cart instance
@param Cart $cart | [
"Move",
"Items",
"to",
"another",
"cart",
"instance"
] | eb44d6adc3819151fee2e8bea64c76dbdef3e01c | https://github.com/hassansin/dbcart/blob/eb44d6adc3819151fee2e8bea64c76dbdef3e01c/src/Hassansin/DBCart/Models/Cart.php#L300-L323 |
38,888 | antonioribeiro/random | src/Faker.php | Faker.getFaker | public function getFaker()
{
if (is_null($this->faker) && class_exists($this->fakerClass)) {
$this->faker = call_user_func("$this->fakerClass::create");
}
return $this->faker;
} | php | public function getFaker()
{
if (is_null($this->faker) && class_exists($this->fakerClass)) {
$this->faker = call_user_func("$this->fakerClass::create");
}
return $this->faker;
} | [
"public",
"function",
"getFaker",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"faker",
")",
"&&",
"class_exists",
"(",
"$",
"this",
"->",
"fakerClass",
")",
")",
"{",
"$",
"this",
"->",
"faker",
"=",
"call_user_func",
"(",
"\"$this->fa... | Instantiate and get Faker.
@return \Faker\Generator|null | [
"Instantiate",
"and",
"get",
"Faker",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/Faker.php#L37-L44 |
38,889 | antonioribeiro/random | src/CharCase.php | CharCase.changeCase | protected function changeCase($string)
{
if ($this->isLowercase()) {
return strtolower($string);
}
if ($this->isUppercase()) {
return strtoupper($string);
}
return $string;
} | php | protected function changeCase($string)
{
if ($this->isLowercase()) {
return strtolower($string);
}
if ($this->isUppercase()) {
return strtoupper($string);
}
return $string;
} | [
"protected",
"function",
"changeCase",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLowercase",
"(",
")",
")",
"{",
"return",
"strtolower",
"(",
"$",
"string",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isUppercase",
"(",
")",
... | Return a string in the proper case.
@param $string
@return string | [
"Return",
"a",
"string",
"in",
"the",
"proper",
"case",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/CharCase.php#L37-L48 |
38,890 | antonioribeiro/random | src/Generators/AlphaGenerator.php | AlphaGenerator.generateNumeric | protected function generateNumeric()
{
if (is_null($this->size) && $this->pattern == static::DEFAULT_PATTERN) {
return $this->generateInteger();
}
return $this->generateString($this->getNumericGenerator());
} | php | protected function generateNumeric()
{
if (is_null($this->size) && $this->pattern == static::DEFAULT_PATTERN) {
return $this->generateInteger();
}
return $this->generateString($this->getNumericGenerator());
} | [
"protected",
"function",
"generateNumeric",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"size",
")",
"&&",
"$",
"this",
"->",
"pattern",
"==",
"static",
"::",
"DEFAULT_PATTERN",
")",
"{",
"return",
"$",
"this",
"->",
"generateInteger",
"... | Generate a numeric random value.
@return int|string | [
"Generate",
"a",
"numeric",
"random",
"value",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/Generators/AlphaGenerator.php#L34-L41 |
38,891 | antonioribeiro/random | src/Trivia.php | Trivia.trivia | public function trivia()
{
$this->array = true;
$this->count = 1;
$this->items = (new TriviaService())->all();
return $this;
} | php | public function trivia()
{
$this->array = true;
$this->count = 1;
$this->items = (new TriviaService())->all();
return $this;
} | [
"public",
"function",
"trivia",
"(",
")",
"{",
"$",
"this",
"->",
"array",
"=",
"true",
";",
"$",
"this",
"->",
"count",
"=",
"1",
";",
"$",
"this",
"->",
"items",
"=",
"(",
"new",
"TriviaService",
"(",
")",
")",
"->",
"all",
"(",
")",
";",
"re... | Generate trivia lines.
@return static | [
"Generate",
"trivia",
"lines",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/Trivia.php#L17-L26 |
38,892 | antonioribeiro/random | src/Generators/ArrayGenerator.php | ArrayGenerator.generateArray | protected function generateArray()
{
$result = [];
$last = count($this->items)-1;
for ($counter = 1; $counter <= $this->count; $counter++) {
$result[] = $this->items[$this->generateRandomInt(0, $last)];
}
if ($this->count == 1) {
return $result[0];
}
return $result;
} | php | protected function generateArray()
{
$result = [];
$last = count($this->items)-1;
for ($counter = 1; $counter <= $this->count; $counter++) {
$result[] = $this->items[$this->generateRandomInt(0, $last)];
}
if ($this->count == 1) {
return $result[0];
}
return $result;
} | [
"protected",
"function",
"generateArray",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"last",
"=",
"count",
"(",
"$",
"this",
"->",
"items",
")",
"-",
"1",
";",
"for",
"(",
"$",
"counter",
"=",
"1",
";",
"$",
"counter",
"<=",
"$",
"t... | Generate random array elements.
@return array | [
"Generate",
"random",
"array",
"elements",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/Generators/ArrayGenerator.php#L31-L46 |
38,893 | antonioribeiro/random | src/Random.php | Random.extractPattern | protected function extractPattern($string)
{
if (is_null($pattern = $this->getPattern())) {
return $string;
}
preg_match_all("/$pattern/", $string, $matches);
return implode('', $matches[0]);
} | php | protected function extractPattern($string)
{
if (is_null($pattern = $this->getPattern())) {
return $string;
}
preg_match_all("/$pattern/", $string, $matches);
return implode('', $matches[0]);
} | [
"protected",
"function",
"extractPattern",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"pattern",
"=",
"$",
"this",
"->",
"getPattern",
"(",
")",
")",
")",
"{",
"return",
"$",
"string",
";",
"}",
"preg_match_all",
"(",
"\"/$pattern/\"",... | Extract a string pattern from a string.
@param $string
@return string | [
"Extract",
"a",
"string",
"pattern",
"from",
"a",
"string",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/Random.php#L87-L96 |
38,894 | antonioribeiro/random | src/Random.php | Random.resetOneTimeValues | public function resetOneTimeValues()
{
$this->prefix = null;
$this->suffix = null;
$this->fakerString = null;
return $this;
} | php | public function resetOneTimeValues()
{
$this->prefix = null;
$this->suffix = null;
$this->fakerString = null;
return $this;
} | [
"public",
"function",
"resetOneTimeValues",
"(",
")",
"{",
"$",
"this",
"->",
"prefix",
"=",
"null",
";",
"$",
"this",
"->",
"suffix",
"=",
"null",
";",
"$",
"this",
"->",
"fakerString",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Reset one-time values.
@return $this | [
"Reset",
"one",
"-",
"time",
"values",
"."
] | ae85276f4e83dc4e25dd05c3d9116dd0261c2deb | https://github.com/antonioribeiro/random/blob/ae85276f4e83dc4e25dd05c3d9116dd0261c2deb/src/Random.php#L189-L198 |
38,895 | php-ddd/domain-driven-design | src/Domain/CommandEventDispatcher.php | CommandEventDispatcher.handle | public function handle(AbstractCommand $command)
{
$this->commandDispatcher->handle($command);
// Now that the command is handled, let's found if there is some events to publish
$events = $this->extractEventsFromCommand($command);
foreach ($events as $event) {
// we will only publish event to synchronous listeners
$this->publish($event);
}
return $command;
} | php | public function handle(AbstractCommand $command)
{
$this->commandDispatcher->handle($command);
// Now that the command is handled, let's found if there is some events to publish
$events = $this->extractEventsFromCommand($command);
foreach ($events as $event) {
// we will only publish event to synchronous listeners
$this->publish($event);
}
return $command;
} | [
"public",
"function",
"handle",
"(",
"AbstractCommand",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"commandDispatcher",
"->",
"handle",
"(",
"$",
"command",
")",
";",
"// Now that the command is handled, let's found if there is some events to publish",
"$",
"events",
... | Try to handle the command given in argument.
It will look over every handlers registered and find the one that knows how handle it.
@param AbstractCommand $command
@return AbstractCommand | [
"Try",
"to",
"handle",
"the",
"command",
"given",
"in",
"argument",
".",
"It",
"will",
"look",
"over",
"every",
"handlers",
"registered",
"and",
"find",
"the",
"one",
"that",
"knows",
"how",
"handle",
"it",
"."
] | 764f48657f8c3a0ad0e4eea1df6b6dacb89b8c49 | https://github.com/php-ddd/domain-driven-design/blob/764f48657f8c3a0ad0e4eea1df6b6dacb89b8c49/src/Domain/CommandEventDispatcher.php#L46-L57 |
38,896 | mmoreram/symfony-bundle-dependencies | BundleDependenciesResolver.php | BundleDependenciesResolver.getBundleInstances | protected function getBundleInstances(
KernelInterface $kernel,
array $bundles
): array {
$bundleStack = $this
->resolveAndReturnBundleDependencies(
$kernel,
$bundles
);
$builtBundles = [];
foreach ($bundleStack as $bundle) {
$builtBundles[] = $this
->getBundleDefinitionInstance($bundle);
}
return $builtBundles;
} | php | protected function getBundleInstances(
KernelInterface $kernel,
array $bundles
): array {
$bundleStack = $this
->resolveAndReturnBundleDependencies(
$kernel,
$bundles
);
$builtBundles = [];
foreach ($bundleStack as $bundle) {
$builtBundles[] = $this
->getBundleDefinitionInstance($bundle);
}
return $builtBundles;
} | [
"protected",
"function",
"getBundleInstances",
"(",
"KernelInterface",
"$",
"kernel",
",",
"array",
"$",
"bundles",
")",
":",
"array",
"{",
"$",
"bundleStack",
"=",
"$",
"this",
"->",
"resolveAndReturnBundleDependencies",
"(",
"$",
"kernel",
",",
"$",
"bundles",... | Get bundle instances given the namespace stack.
@param KernelInterface $kernel
@param array $bundles
@return BundleInterface[] | [
"Get",
"bundle",
"instances",
"given",
"the",
"namespace",
"stack",
"."
] | aed90cc4b91e08ce6b01506d5b36830041ceb18e | https://github.com/mmoreram/symfony-bundle-dependencies/blob/aed90cc4b91e08ce6b01506d5b36830041ceb18e/BundleDependenciesResolver.php#L36-L53 |
38,897 | mmoreram/symfony-bundle-dependencies | BundleDependenciesResolver.php | BundleDependenciesResolver.resolveBundleDependencies | private function resolveBundleDependencies(
KernelInterface $kernel,
array &$bundleStack,
array &$visitedBundles,
array $bundles
) {
$bundles = array_reverse($bundles);
foreach ($bundles as $bundle) {
/*
* Each visited node is prioritized and placed at the beginning.
*/
$this
->prioritizeBundle(
$bundleStack,
$bundle
);
}
foreach ($bundles as $bundle) {
$bundleNamespace = $this->getBundleDefinitionNamespace($bundle);
/*
* If have already visited this bundle, continue. One bundle can be
* processed once.
*/
if (isset($visitedBundles[$bundleNamespace])) {
continue;
}
$visitedBundles[$bundleNamespace] = true;
$bundleNamespaceObj = new \ReflectionClass($bundleNamespace);
if ($bundleNamespaceObj->implementsInterface(DependentBundleInterface::class)) {
/**
* @var DependentBundleInterface
*/
$bundleDependencies = $bundleNamespace::getBundleDependencies($kernel);
$this->resolveBundleDependencies(
$kernel,
$bundleStack,
$visitedBundles,
$bundleDependencies
);
}
}
} | php | private function resolveBundleDependencies(
KernelInterface $kernel,
array &$bundleStack,
array &$visitedBundles,
array $bundles
) {
$bundles = array_reverse($bundles);
foreach ($bundles as $bundle) {
/*
* Each visited node is prioritized and placed at the beginning.
*/
$this
->prioritizeBundle(
$bundleStack,
$bundle
);
}
foreach ($bundles as $bundle) {
$bundleNamespace = $this->getBundleDefinitionNamespace($bundle);
/*
* If have already visited this bundle, continue. One bundle can be
* processed once.
*/
if (isset($visitedBundles[$bundleNamespace])) {
continue;
}
$visitedBundles[$bundleNamespace] = true;
$bundleNamespaceObj = new \ReflectionClass($bundleNamespace);
if ($bundleNamespaceObj->implementsInterface(DependentBundleInterface::class)) {
/**
* @var DependentBundleInterface
*/
$bundleDependencies = $bundleNamespace::getBundleDependencies($kernel);
$this->resolveBundleDependencies(
$kernel,
$bundleStack,
$visitedBundles,
$bundleDependencies
);
}
}
} | [
"private",
"function",
"resolveBundleDependencies",
"(",
"KernelInterface",
"$",
"kernel",
",",
"array",
"&",
"$",
"bundleStack",
",",
"array",
"&",
"$",
"visitedBundles",
",",
"array",
"$",
"bundles",
")",
"{",
"$",
"bundles",
"=",
"array_reverse",
"(",
"$",
... | Resolve bundle dependencies.
Given a set of already loaded bundles and a set of new needed bundles,
build new dependencies and fill given array of loaded bundles.
@param KernelInterface $kernel
@param array $bundleStack
@param array $visitedBundles
@param array $bundles | [
"Resolve",
"bundle",
"dependencies",
"."
] | aed90cc4b91e08ce6b01506d5b36830041ceb18e | https://github.com/mmoreram/symfony-bundle-dependencies/blob/aed90cc4b91e08ce6b01506d5b36830041ceb18e/BundleDependenciesResolver.php#L91-L136 |
38,898 | mmoreram/symfony-bundle-dependencies | BundleDependenciesResolver.php | BundleDependenciesResolver.prioritizeBundle | private function prioritizeBundle(
array &$bundleStack,
$elementToPrioritize
) {
$elementNamespace = $this->getBundleDefinitionNamespace($elementToPrioritize);
foreach ($bundleStack as $bundlePosition => $bundle) {
$bundleNamespace = $this->getBundleDefinitionNamespace($bundle);
if ($elementNamespace == $bundleNamespace) {
unset($bundleStack[$bundlePosition]);
}
}
array_unshift($bundleStack, $elementToPrioritize);
} | php | private function prioritizeBundle(
array &$bundleStack,
$elementToPrioritize
) {
$elementNamespace = $this->getBundleDefinitionNamespace($elementToPrioritize);
foreach ($bundleStack as $bundlePosition => $bundle) {
$bundleNamespace = $this->getBundleDefinitionNamespace($bundle);
if ($elementNamespace == $bundleNamespace) {
unset($bundleStack[$bundlePosition]);
}
}
array_unshift($bundleStack, $elementToPrioritize);
} | [
"private",
"function",
"prioritizeBundle",
"(",
"array",
"&",
"$",
"bundleStack",
",",
"$",
"elementToPrioritize",
")",
"{",
"$",
"elementNamespace",
"=",
"$",
"this",
"->",
"getBundleDefinitionNamespace",
"(",
"$",
"elementToPrioritize",
")",
";",
"foreach",
"(",... | Given the global bundle stack and a bundle definition, considering this
bundle definition as an instance or a namespace, prioritize this bundle
inside this stack.
To prioritize a bundle means that must be placed in the beginning of the
stack. If already exists, then remove the old entry just before adding it
again.
@param array $bundleStack
@param BundleInterface|string $elementToPrioritize | [
"Given",
"the",
"global",
"bundle",
"stack",
"and",
"a",
"bundle",
"definition",
"considering",
"this",
"bundle",
"definition",
"as",
"an",
"instance",
"or",
"a",
"namespace",
"prioritize",
"this",
"bundle",
"inside",
"this",
"stack",
"."
] | aed90cc4b91e08ce6b01506d5b36830041ceb18e | https://github.com/mmoreram/symfony-bundle-dependencies/blob/aed90cc4b91e08ce6b01506d5b36830041ceb18e/BundleDependenciesResolver.php#L150-L163 |
38,899 | mmoreram/symfony-bundle-dependencies | BundleDependenciesResolver.php | BundleDependenciesResolver.getBundleDefinitionInstance | private function getBundleDefinitionInstance($bundle): BundleInterface
{
if (!is_object($bundle)) {
$bundle = new $bundle($this);
}
if (!$bundle instanceof BundleInterface) {
throw new BundleDependencyException(get_class($bundle));
}
return $bundle;
} | php | private function getBundleDefinitionInstance($bundle): BundleInterface
{
if (!is_object($bundle)) {
$bundle = new $bundle($this);
}
if (!$bundle instanceof BundleInterface) {
throw new BundleDependencyException(get_class($bundle));
}
return $bundle;
} | [
"private",
"function",
"getBundleDefinitionInstance",
"(",
"$",
"bundle",
")",
":",
"BundleInterface",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"bundle",
")",
")",
"{",
"$",
"bundle",
"=",
"new",
"$",
"bundle",
"(",
"$",
"this",
")",
";",
"}",
"if",... | Given a bundle instance or a namespace, return the instance.
Each bundle is instanced with the Kernel as the first element of the
construction, by default.
@param BundleInterface|string $bundle
@return BundleInterface
@throws BundleDependencyException Is not a BundleInterface implementation | [
"Given",
"a",
"bundle",
"instance",
"or",
"a",
"namespace",
"return",
"the",
"instance",
".",
"Each",
"bundle",
"is",
"instanced",
"with",
"the",
"Kernel",
"as",
"the",
"first",
"element",
"of",
"the",
"construction",
"by",
"default",
"."
] | aed90cc4b91e08ce6b01506d5b36830041ceb18e | https://github.com/mmoreram/symfony-bundle-dependencies/blob/aed90cc4b91e08ce6b01506d5b36830041ceb18e/BundleDependenciesResolver.php#L190-L201 |
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.