repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
apigee/apigee-client-php | src/Controller/PaginationHelperTrait.php | PaginationHelperTrait.listEntityIdsWithoutCps | private function listEntityIdsWithoutCps(PagerInterface $pager = null, array $query_params = []): array
{
$query_params = [
'expand' => 'false',
] + $query_params;
$uri = $this->getBaseEndpointUri()->withQuery(http_build_query($query_params));
$response = $this->getClient()->get($uri);
$ids = $this->responseToArray($response);
// Re-key the array from 0 if CPS had to be simulated.
return $pager ? array_values($this->simulateCpsPagination($pager, $ids)) : $ids;
} | php | private function listEntityIdsWithoutCps(PagerInterface $pager = null, array $query_params = []): array
{
$query_params = [
'expand' => 'false',
] + $query_params;
$uri = $this->getBaseEndpointUri()->withQuery(http_build_query($query_params));
$response = $this->getClient()->get($uri);
$ids = $this->responseToArray($response);
// Re-key the array from 0 if CPS had to be simulated.
return $pager ? array_values($this->simulateCpsPagination($pager, $ids)) : $ids;
} | [
"private",
"function",
"listEntityIdsWithoutCps",
"(",
"PagerInterface",
"$",
"pager",
"=",
"null",
",",
"array",
"$",
"query_params",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"query_params",
"=",
"[",
"'expand'",
"=>",
"'false'",
",",
"]",
"+",
"$",
... | Simulates paginated entity id listing on organization without CPS.
@param \Apigee\Edge\Structure\PagerInterface|null $pager
Pager.
@param array $query_params
Additional query parameters.
@return string[]
Array of entity ids. | [
"Simulates",
"paginated",
"entity",
"id",
"listing",
"on",
"organization",
"without",
"CPS",
"."
] | train | https://github.com/apigee/apigee-client-php/blob/7b4b4c29b65c06abe5ebef19634644271203a4e8/src/Controller/PaginationHelperTrait.php#L356-L369 |
apigee/apigee-client-php | src/Controller/PaginationHelperTrait.php | PaginationHelperTrait.simulateCpsPagination | private function simulateCpsPagination(PagerInterface $pager, array $result, array $array_search_haystack = null): array
{
$array_search_haystack = $array_search_haystack ?? $result;
// If start key is null let's set it to the first key in the
// result just like the API would do.
$start_key = $pager->getStartKey() ?? reset($array_search_haystack);
$offset = array_search($start_key, $array_search_haystack);
// Start key has not been found in the response. Apigee Edge with
// CPS enabled would return an HTTP 404, with error code
// "keymanagement.service.[ENTITY_TYPE]_doesnot_exist" which would
// trigger a ClientErrorException. We throw a RuntimeException
// instead of that because it does not require to construct an
// API response object.
if (false === $offset) {
throw new RuntimeException(sprintf('CPS simulation error: "%s" does not exist.', $start_key));
}
// The default pagination limit (aka. "count") on CPS supported
// listing endpoints varies. When this script was written it was
// 1000 on two endpoints and 100 on two app related endpoints,
// namely List Developer Apps and List Company Apps. A
// developer/company should not have 100 apps, this is
// the reason why this limit is smaller. Therefore we choose to
// use 1000 as pagination limit if it has not been set.
// https://apidocs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/apiproducts-0
// https://apidocs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/developers
// https://apidocs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/developers/%7Bdeveloper_email_or_id%7D/apps
return array_slice($result, $offset, $pager->getLimit() ?: 1000, true);
} | php | private function simulateCpsPagination(PagerInterface $pager, array $result, array $array_search_haystack = null): array
{
$array_search_haystack = $array_search_haystack ?? $result;
// If start key is null let's set it to the first key in the
// result just like the API would do.
$start_key = $pager->getStartKey() ?? reset($array_search_haystack);
$offset = array_search($start_key, $array_search_haystack);
// Start key has not been found in the response. Apigee Edge with
// CPS enabled would return an HTTP 404, with error code
// "keymanagement.service.[ENTITY_TYPE]_doesnot_exist" which would
// trigger a ClientErrorException. We throw a RuntimeException
// instead of that because it does not require to construct an
// API response object.
if (false === $offset) {
throw new RuntimeException(sprintf('CPS simulation error: "%s" does not exist.', $start_key));
}
// The default pagination limit (aka. "count") on CPS supported
// listing endpoints varies. When this script was written it was
// 1000 on two endpoints and 100 on two app related endpoints,
// namely List Developer Apps and List Company Apps. A
// developer/company should not have 100 apps, this is
// the reason why this limit is smaller. Therefore we choose to
// use 1000 as pagination limit if it has not been set.
// https://apidocs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/apiproducts-0
// https://apidocs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/developers
// https://apidocs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/developers/%7Bdeveloper_email_or_id%7D/apps
return array_slice($result, $offset, $pager->getLimit() ?: 1000, true);
} | [
"private",
"function",
"simulateCpsPagination",
"(",
"PagerInterface",
"$",
"pager",
",",
"array",
"$",
"result",
",",
"array",
"$",
"array_search_haystack",
"=",
"null",
")",
":",
"array",
"{",
"$",
"array_search_haystack",
"=",
"$",
"array_search_haystack",
"??"... | Simulates paginated response on an organization without CPS.
@param \Apigee\Edge\Structure\PagerInterface $pager
Pager.
@param array $result
The non-paginated result returned by the API.
@param array|null $array_search_haystack
Haystack for array_search, the needle is the start key from the pager.
If it is null, then the haystack is the $result.
@return array
The paginated result. | [
"Simulates",
"paginated",
"response",
"on",
"an",
"organization",
"without",
"CPS",
"."
] | train | https://github.com/apigee/apigee-client-php/blob/7b4b4c29b65c06abe5ebef19634644271203a4e8/src/Controller/PaginationHelperTrait.php#L385-L412 |
apigee/apigee-client-php | src/HttpClient/Plugin/ResponseHandlerPlugin.php | ResponseHandlerPlugin.handleRequest | public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
return $next($request)->then(function (ResponseInterface $response) use ($request) {
return $this->decodeResponse($response, $request);
}, function (Exception $e) use ($request): void {
if ($e instanceof ApiException) {
throw $e;
}
if ($e instanceof HttpException || in_array(HttpException::class, class_parents($e))) {
$this->decodeResponse($e->getResponse(), $request);
} elseif ($e instanceof RequestException || in_array(RequestException::class, class_parents($e))) {
throw new ApiRequestException($request, $e->getMessage(), $e->getCode(), $e);
}
throw new ApiException($e->getMessage(), $e->getCode(), $e);
});
} | php | public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
return $next($request)->then(function (ResponseInterface $response) use ($request) {
return $this->decodeResponse($response, $request);
}, function (Exception $e) use ($request): void {
if ($e instanceof ApiException) {
throw $e;
}
if ($e instanceof HttpException || in_array(HttpException::class, class_parents($e))) {
$this->decodeResponse($e->getResponse(), $request);
} elseif ($e instanceof RequestException || in_array(RequestException::class, class_parents($e))) {
throw new ApiRequestException($request, $e->getMessage(), $e->getCode(), $e);
}
throw new ApiException($e->getMessage(), $e->getCode(), $e);
});
} | [
"public",
"function",
"handleRequest",
"(",
"RequestInterface",
"$",
"request",
",",
"callable",
"$",
"next",
",",
"callable",
"$",
"first",
")",
"{",
"return",
"$",
"next",
"(",
"$",
"request",
")",
"->",
"then",
"(",
"function",
"(",
"ResponseInterface",
... | @inheritdoc
@psalm-suppress UndefinedMethod - $e->getResponse() is not undefined.
@psalm-suppress InvalidArgument - $e is not an invalid argument. | [
"@inheritdoc"
] | train | https://github.com/apigee/apigee-client-php/blob/7b4b4c29b65c06abe5ebef19634644271203a4e8/src/HttpClient/Plugin/ResponseHandlerPlugin.php#L60-L76 |
apigee/apigee-client-php | src/HttpClient/Plugin/ResponseHandlerPlugin.php | ResponseHandlerPlugin.decodeResponse | private function decodeResponse(ResponseInterface $response, RequestInterface $request)
{
if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
// Handle Oauth specific authentication errors.
if (401 === $response->getStatusCode()) {
if (0 === strpos($request->getHeaderLine('Authorization'), 'Bearer')) {
throw new OauthAccessTokenAuthenticationException($request);
}
$parsedBody = [];
parse_str((string) $request->getBody(), $parsedBody);
if (array_key_exists('grant_type', $parsedBody) && 'refresh_token' === $parsedBody['grant_type']) {
throw new OauthRefreshTokenExpiredException($response, $request);
}
}
throw new ClientErrorException($response, $request, (string) $response->getBody(), $response->getStatusCode(), null, $this->formatter);
} elseif ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
throw new ServerErrorException($response, $request, (string) $response->getBody(), $response->getStatusCode(), null, $this->formatter);
}
return $response;
} | php | private function decodeResponse(ResponseInterface $response, RequestInterface $request)
{
if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
// Handle Oauth specific authentication errors.
if (401 === $response->getStatusCode()) {
if (0 === strpos($request->getHeaderLine('Authorization'), 'Bearer')) {
throw new OauthAccessTokenAuthenticationException($request);
}
$parsedBody = [];
parse_str((string) $request->getBody(), $parsedBody);
if (array_key_exists('grant_type', $parsedBody) && 'refresh_token' === $parsedBody['grant_type']) {
throw new OauthRefreshTokenExpiredException($response, $request);
}
}
throw new ClientErrorException($response, $request, (string) $response->getBody(), $response->getStatusCode(), null, $this->formatter);
} elseif ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
throw new ServerErrorException($response, $request, (string) $response->getBody(), $response->getStatusCode(), null, $this->formatter);
}
return $response;
} | [
"private",
"function",
"decodeResponse",
"(",
"ResponseInterface",
"$",
"response",
",",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
">=",
"400",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
... | Throws one our of our exceptions if the API response code is higher than 399.
@param \Psr\Http\Message\ResponseInterface $response
@param \Psr\Http\Message\RequestInterface $request
@throws \Apigee\Edge\Exception\ClientErrorException
@throws \Apigee\Edge\Exception\ServerErrorException
@return \Psr\Http\Message\ResponseInterface | [
"Throws",
"one",
"our",
"of",
"our",
"exceptions",
"if",
"the",
"API",
"response",
"code",
"is",
"higher",
"than",
"399",
"."
] | train | https://github.com/apigee/apigee-client-php/blob/7b4b4c29b65c06abe5ebef19634644271203a4e8/src/HttpClient/Plugin/ResponseHandlerPlugin.php#L89-L110 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/UniqueNode.php | UniqueNode.getOpeningTagPos | protected function getOpeningTagPos()
{
$startPositionInBlob = false;
if (preg_match("/<" . preg_quote($this->options["uniqueNode"]) . "(>| )/", $this->workingBlob, $matches, PREG_OFFSET_CAPTURE) === 1) {
$startPositionInBlob = $matches[0][1];
}
if ($startPositionInBlob === false) {
$this->hasSearchedUntilPos = strlen($this->workingBlob) - 1;
}
return $startPositionInBlob;
} | php | protected function getOpeningTagPos()
{
$startPositionInBlob = false;
if (preg_match("/<" . preg_quote($this->options["uniqueNode"]) . "(>| )/", $this->workingBlob, $matches, PREG_OFFSET_CAPTURE) === 1) {
$startPositionInBlob = $matches[0][1];
}
if ($startPositionInBlob === false) {
$this->hasSearchedUntilPos = strlen($this->workingBlob) - 1;
}
return $startPositionInBlob;
} | [
"protected",
"function",
"getOpeningTagPos",
"(",
")",
"{",
"$",
"startPositionInBlob",
"=",
"false",
";",
"if",
"(",
"preg_match",
"(",
"\"/<\"",
".",
"preg_quote",
"(",
"$",
"this",
"->",
"options",
"[",
"\"uniqueNode\"",
"]",
")",
".",
"\"(>| )/\"",
",",
... | Search the blob for our unique node's opening tag
@return bool|int Either returns the char position of the opening tag or false | [
"Search",
"the",
"blob",
"for",
"our",
"unique",
"node",
"s",
"opening",
"tag"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/UniqueNode.php#L99-L112 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/UniqueNode.php | UniqueNode.checkShortClosingTag | private function checkShortClosingTag($workingBlob, $len) {
$resultEndPositionInBlob = false;
while ($len = strpos($workingBlob, "/>", $len + 1)) {
$subBlob = substr($workingBlob, $this->startPos, $len + strlen("/>") - $this->startPos);
$cntOpen = substr_count($subBlob, "<");
$cntClose = substr_count($subBlob, "/>");
if ($cntOpen === $cntClose && $cntOpen === 1) {
$resultEndPositionInBlob = $len + strlen("/>");
break; // end while. so $endPositionInBlob correct now
}
}
return $resultEndPositionInBlob;
} | php | private function checkShortClosingTag($workingBlob, $len) {
$resultEndPositionInBlob = false;
while ($len = strpos($workingBlob, "/>", $len + 1)) {
$subBlob = substr($workingBlob, $this->startPos, $len + strlen("/>") - $this->startPos);
$cntOpen = substr_count($subBlob, "<");
$cntClose = substr_count($subBlob, "/>");
if ($cntOpen === $cntClose && $cntOpen === 1) {
$resultEndPositionInBlob = $len + strlen("/>");
break; // end while. so $endPositionInBlob correct now
}
}
return $resultEndPositionInBlob;
} | [
"private",
"function",
"checkShortClosingTag",
"(",
"$",
"workingBlob",
",",
"$",
"len",
")",
"{",
"$",
"resultEndPositionInBlob",
"=",
"false",
";",
"while",
"(",
"$",
"len",
"=",
"strpos",
"(",
"$",
"workingBlob",
",",
"\"/>\"",
",",
"$",
"len",
"+",
"... | Search short closing tag in $workingBlob before
@param string $workingBlob
@param int $len
@return bool|int Either returns the char position of the short closing tag or false | [
"Search",
"short",
"closing",
"tag",
"in",
"$workingBlob",
"before"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/UniqueNode.php#L121-L133 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/UniqueNode.php | UniqueNode.getClosingTagPos | protected function getClosingTagPos()
{
$endPositionInBlob = strpos($this->workingBlob, "</" . $this->options["uniqueNode"] . ">");
if ($endPositionInBlob === false) {
if (isset($this->options["checkShortClosing"]) && $this->options["checkShortClosing"] === true) {
$endPositionInBlob = $this->checkShortClosingTag($this->workingBlob, $this->startPos);
}
if ($endPositionInBlob === false) {
$this->hasSearchedUntilPos = strlen($this->workingBlob) - 1;
} else {
$this->shortClosedTagNow = true;
}
} else {
if (isset($this->options["checkShortClosing"]) && $this->options["checkShortClosing"] === true) {
$tmpEndPositionInBlob = $this->checkShortClosingTag(substr($this->workingBlob, 0, $endPositionInBlob), $this->startPos);
if ($tmpEndPositionInBlob !== false) {
$this->shortClosedTagNow = true;
$endPositionInBlob = $tmpEndPositionInBlob;
}
}
}
return $endPositionInBlob;
} | php | protected function getClosingTagPos()
{
$endPositionInBlob = strpos($this->workingBlob, "</" . $this->options["uniqueNode"] . ">");
if ($endPositionInBlob === false) {
if (isset($this->options["checkShortClosing"]) && $this->options["checkShortClosing"] === true) {
$endPositionInBlob = $this->checkShortClosingTag($this->workingBlob, $this->startPos);
}
if ($endPositionInBlob === false) {
$this->hasSearchedUntilPos = strlen($this->workingBlob) - 1;
} else {
$this->shortClosedTagNow = true;
}
} else {
if (isset($this->options["checkShortClosing"]) && $this->options["checkShortClosing"] === true) {
$tmpEndPositionInBlob = $this->checkShortClosingTag(substr($this->workingBlob, 0, $endPositionInBlob), $this->startPos);
if ($tmpEndPositionInBlob !== false) {
$this->shortClosedTagNow = true;
$endPositionInBlob = $tmpEndPositionInBlob;
}
}
}
return $endPositionInBlob;
} | [
"protected",
"function",
"getClosingTagPos",
"(",
")",
"{",
"$",
"endPositionInBlob",
"=",
"strpos",
"(",
"$",
"this",
"->",
"workingBlob",
",",
"\"</\"",
".",
"$",
"this",
"->",
"options",
"[",
"\"uniqueNode\"",
"]",
".",
"\">\"",
")",
";",
"if",
"(",
"... | Search the blob for our unique node's closing tag
@return bool|int Either returns the char position of the closing tag or false | [
"Search",
"the",
"blob",
"for",
"our",
"unique",
"node",
"s",
"closing",
"tag"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/UniqueNode.php#L139-L164 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/UniqueNode.php | UniqueNode.flush | protected function flush($endPositionInBlob) {
$endTagLen = $this->shortClosedTagNow ? 0 : strlen("</" . $this->options["uniqueNode"] . ">");
$realEndPosition = $endPositionInBlob + $endTagLen;
$this->flushed = substr($this->workingBlob, $this->startPos, $realEndPosition - $this->startPos);
$this->workingBlob = substr($this->workingBlob, $realEndPosition);
$this->hasSearchedUntilPos = 0;
$this->shortClosedTagNow = false;
} | php | protected function flush($endPositionInBlob) {
$endTagLen = $this->shortClosedTagNow ? 0 : strlen("</" . $this->options["uniqueNode"] . ">");
$realEndPosition = $endPositionInBlob + $endTagLen;
$this->flushed = substr($this->workingBlob, $this->startPos, $realEndPosition - $this->startPos);
$this->workingBlob = substr($this->workingBlob, $realEndPosition);
$this->hasSearchedUntilPos = 0;
$this->shortClosedTagNow = false;
} | [
"protected",
"function",
"flush",
"(",
"$",
"endPositionInBlob",
")",
"{",
"$",
"endTagLen",
"=",
"$",
"this",
"->",
"shortClosedTagNow",
"?",
"0",
":",
"strlen",
"(",
"\"</\"",
".",
"$",
"this",
"->",
"options",
"[",
"\"uniqueNode\"",
"]",
".",
"\">\"",
... | Cut everything from the start position to the end position in the workingBlob (+ tag length) and flush it out for later return in getNodeFrom
@param int $endPositionInBlob Position of the closing tag | [
"Cut",
"everything",
"from",
"the",
"start",
"position",
"to",
"the",
"end",
"position",
"in",
"the",
"workingBlob",
"(",
"+",
"tag",
"length",
")",
"and",
"flush",
"it",
"out",
"for",
"later",
"return",
"in",
"getNodeFrom"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/UniqueNode.php#L179-L186 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/UniqueNode.php | UniqueNode.prepareChunk | protected function prepareChunk(StreamInterface $stream)
{
if ($this->hasSearchedUntilPos > -1 && $this->hasSearchedUntilPos < (strlen($this->workingBlob) - 1)) {
// More work to do
return true;
}
$chunk = $stream->getChunk();
if ($chunk === false) {
// EOF
if ($this->hasSearchedUntilPos === -1 && strlen($this->workingBlob) > 0) {
// EOF, but we haven't even started searching, special case that probably means we're dealing with a file of less size than the stream buffer
// Therefore, keep looping
return true;
}
return false;
} else {
// New chunk fetched
if (!$this->firstNodeFound && !$this->options["extractContainer"]) {
// Prevent a memory leak if we never find our first node, throw away our old stuff
// but keep some letters to not cut off a first node
$this->workingBlob = substr($this->workingBlob, -1 * strlen("<" . $this->options["uniqueNode"] . ">")) . $chunk;
} else {
$this->workingBlob .= $chunk;
}
return true;
}
} | php | protected function prepareChunk(StreamInterface $stream)
{
if ($this->hasSearchedUntilPos > -1 && $this->hasSearchedUntilPos < (strlen($this->workingBlob) - 1)) {
// More work to do
return true;
}
$chunk = $stream->getChunk();
if ($chunk === false) {
// EOF
if ($this->hasSearchedUntilPos === -1 && strlen($this->workingBlob) > 0) {
// EOF, but we haven't even started searching, special case that probably means we're dealing with a file of less size than the stream buffer
// Therefore, keep looping
return true;
}
return false;
} else {
// New chunk fetched
if (!$this->firstNodeFound && !$this->options["extractContainer"]) {
// Prevent a memory leak if we never find our first node, throw away our old stuff
// but keep some letters to not cut off a first node
$this->workingBlob = substr($this->workingBlob, -1 * strlen("<" . $this->options["uniqueNode"] . ">")) . $chunk;
} else {
$this->workingBlob .= $chunk;
}
return true;
}
} | [
"protected",
"function",
"prepareChunk",
"(",
"StreamInterface",
"$",
"stream",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSearchedUntilPos",
">",
"-",
"1",
"&&",
"$",
"this",
"->",
"hasSearchedUntilPos",
"<",
"(",
"strlen",
"(",
"$",
"this",
"->",
"worki... | Decides whether we're to fetch more chunks from the stream or keep working with what we have.
@param StreamInterface $stream The stream provider
@return bool Keep working? | [
"Decides",
"whether",
"we",
"re",
"to",
"fetch",
"more",
"chunks",
"from",
"the",
"stream",
"or",
"keep",
"working",
"with",
"what",
"we",
"have",
"."
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/UniqueNode.php#L193-L222 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/UniqueNode.php | UniqueNode.getNodeFrom | public function getNodeFrom(StreamInterface $stream)
{
while ($this->prepareChunk($stream)) {
// What's our next course of action?
if ($this->nextAction === self::FIND_OPENING_TAG_ACTION) {
// Try to find an opening tag
$positionInBlob = $this->getOpeningTagPos();
if ($positionInBlob !== false) {
// We found it, start salvaging
$this->firstNodeFound = true;
if ($this->options["extractContainer"] && $this->preCapture) {
$this->containerXml .= substr($this->workingBlob, 0, $positionInBlob);
$this->preCapture = false;
}
$this->startSalvaging($positionInBlob);
// The next course of action will be to find a closing tag
$this->nextAction = self::FIND_CLOSING_TAG_ACTION;
}
}
if ($this->nextAction === self::FIND_CLOSING_TAG_ACTION) {
// Try to find a closing tag
$positionInBlob = $this->getClosingTagPos();
if ($positionInBlob !== false) {
// We found it, we now have a full node to flush out
$this->flush($positionInBlob);
// The next course of action will be to find an opening tag
$this->nextAction = self::FIND_OPENING_TAG_ACTION;
// Get the flushed node and make way for the next node
$flushed = $this->flushed;
$this->flushed = "";
return $flushed;
}
}
}
if ($this->options["extractContainer"]) {
$this->containerXml .= $this->workingBlob;
}
return false;
} | php | public function getNodeFrom(StreamInterface $stream)
{
while ($this->prepareChunk($stream)) {
// What's our next course of action?
if ($this->nextAction === self::FIND_OPENING_TAG_ACTION) {
// Try to find an opening tag
$positionInBlob = $this->getOpeningTagPos();
if ($positionInBlob !== false) {
// We found it, start salvaging
$this->firstNodeFound = true;
if ($this->options["extractContainer"] && $this->preCapture) {
$this->containerXml .= substr($this->workingBlob, 0, $positionInBlob);
$this->preCapture = false;
}
$this->startSalvaging($positionInBlob);
// The next course of action will be to find a closing tag
$this->nextAction = self::FIND_CLOSING_TAG_ACTION;
}
}
if ($this->nextAction === self::FIND_CLOSING_TAG_ACTION) {
// Try to find a closing tag
$positionInBlob = $this->getClosingTagPos();
if ($positionInBlob !== false) {
// We found it, we now have a full node to flush out
$this->flush($positionInBlob);
// The next course of action will be to find an opening tag
$this->nextAction = self::FIND_OPENING_TAG_ACTION;
// Get the flushed node and make way for the next node
$flushed = $this->flushed;
$this->flushed = "";
return $flushed;
}
}
}
if ($this->options["extractContainer"]) {
$this->containerXml .= $this->workingBlob;
}
return false;
} | [
"public",
"function",
"getNodeFrom",
"(",
"StreamInterface",
"$",
"stream",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"prepareChunk",
"(",
"$",
"stream",
")",
")",
"{",
"// What's our next course of action?",
"if",
"(",
"$",
"this",
"->",
"nextAction",
"===",... | Tries to retrieve the next node or returns false
@param StreamInterface $stream The stream to use
@return string|bool The next xml node or false if one could not be retrieved | [
"Tries",
"to",
"retrieve",
"the",
"next",
"node",
"or",
"returns",
"false"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/UniqueNode.php#L229-L278 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/StringWalker.php | StringWalker.shave | protected function shave()
{
preg_match("/<[^>]+>/", $this->chunk, $matches, PREG_OFFSET_CAPTURE);
if (isset($matches[0], $matches[0][0], $matches[0][1])) {
list($captured, $offset) = $matches[0];
if ($this->options["expectGT"]) {
// Some elements support > inside
foreach ($this->options["tagsWithAllowedGT"] as $tag) {
list($opening, $closing) = $tag;
if (substr($captured, 0, strlen($opening)) === $opening) {
// We have a match, our preg_match may have ended too early
// Most often, this isn't the case
if (substr($captured, -1 * strlen($closing)) !== $closing) {
// In this case, the preg_match ended too early, let's find the real end
$position = strpos($this->chunk, $closing);
if ($position === false) {
// We need more XML!
return false;
}
// We found the end, modify $captured
$captured = substr($this->chunk, $offset, $position + strlen($closing) - $offset);
}
}
}
}
// Data in between
$data = substr($this->chunk, 0, $offset);
// Shave from chunk
$this->chunk = substr($this->chunk, $offset + strlen($captured));
return array($captured, $data . $captured);
}
return false;
} | php | protected function shave()
{
preg_match("/<[^>]+>/", $this->chunk, $matches, PREG_OFFSET_CAPTURE);
if (isset($matches[0], $matches[0][0], $matches[0][1])) {
list($captured, $offset) = $matches[0];
if ($this->options["expectGT"]) {
// Some elements support > inside
foreach ($this->options["tagsWithAllowedGT"] as $tag) {
list($opening, $closing) = $tag;
if (substr($captured, 0, strlen($opening)) === $opening) {
// We have a match, our preg_match may have ended too early
// Most often, this isn't the case
if (substr($captured, -1 * strlen($closing)) !== $closing) {
// In this case, the preg_match ended too early, let's find the real end
$position = strpos($this->chunk, $closing);
if ($position === false) {
// We need more XML!
return false;
}
// We found the end, modify $captured
$captured = substr($this->chunk, $offset, $position + strlen($closing) - $offset);
}
}
}
}
// Data in between
$data = substr($this->chunk, 0, $offset);
// Shave from chunk
$this->chunk = substr($this->chunk, $offset + strlen($captured));
return array($captured, $data . $captured);
}
return false;
} | [
"protected",
"function",
"shave",
"(",
")",
"{",
"preg_match",
"(",
"\"/<[^>]+>/\"",
",",
"$",
"this",
"->",
"chunk",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"$",
"matches"... | Shaves off the next element from the chunk
@return string[]|bool Either a shaved off element array(0 => Captured element, 1 => Data from last shaving point up to and including captured element) or false if one could not be obtained | [
"Shaves",
"off",
"the",
"next",
"element",
"from",
"the",
"chunk"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/StringWalker.php#L98-L139 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/StringWalker.php | StringWalker.getEdges | protected function getEdges($element)
{
// TODO: Performance tuning possible here by not looping
foreach ($this->options["tags"] as $tag) {
list($opening, $closing, $depth) = $tag;
if (substr($element, 0, strlen($opening)) === $opening
&& substr($element, -1 * strlen($closing)) === $closing) {
return $tag;
}
}
} | php | protected function getEdges($element)
{
// TODO: Performance tuning possible here by not looping
foreach ($this->options["tags"] as $tag) {
list($opening, $closing, $depth) = $tag;
if (substr($element, 0, strlen($opening)) === $opening
&& substr($element, -1 * strlen($closing)) === $closing) {
return $tag;
}
}
} | [
"protected",
"function",
"getEdges",
"(",
"$",
"element",
")",
"{",
"// TODO: Performance tuning possible here by not looping",
"foreach",
"(",
"$",
"this",
"->",
"options",
"[",
"\"tags\"",
"]",
"as",
"$",
"tag",
")",
"{",
"list",
"(",
"$",
"opening",
",",
"$... | Extract XML compatible tag head and tail
@param string $element XML element
@return string[] 0 => Opening tag, 1 => Closing tag | [
"Extract",
"XML",
"compatible",
"tag",
"head",
"and",
"tail"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/StringWalker.php#L146-L159 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/StringWalker.php | StringWalker.prepareChunk | protected function prepareChunk(StreamInterface $stream)
{
if (!$this->firstRun && is_null($this->shaved)) {
// We're starting again after a flush
$this->shaved = "";
return true;
} else if (is_null($this->shaved)) {
$this->shaved = "";
}
$newChunk = $stream->getChunk();
if ($newChunk !== false) {
$this->chunk .= $newChunk;
return true;
} else {
if (trim($this->chunk) !== "" && $this->chunk !== $this->lastChunk) {
// Update anti-freeze protection chunk
$this->lastChunk = $this->chunk;
// Continue
return true;
}
}
return false;
} | php | protected function prepareChunk(StreamInterface $stream)
{
if (!$this->firstRun && is_null($this->shaved)) {
// We're starting again after a flush
$this->shaved = "";
return true;
} else if (is_null($this->shaved)) {
$this->shaved = "";
}
$newChunk = $stream->getChunk();
if ($newChunk !== false) {
$this->chunk .= $newChunk;
return true;
} else {
if (trim($this->chunk) !== "" && $this->chunk !== $this->lastChunk) {
// Update anti-freeze protection chunk
$this->lastChunk = $this->chunk;
// Continue
return true;
}
}
return false;
} | [
"protected",
"function",
"prepareChunk",
"(",
"StreamInterface",
"$",
"stream",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"firstRun",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"shaved",
")",
")",
"{",
"// We're starting again after a flush",
"$",
"this",
"... | The shave method must be able to request more data even though there isn't any more to fetch from the stream, this method wraps the getChunk call so that it returns true as long as there is XML data left
@param StreamInterface $stream The stream to read from
@return bool Returns whether there is more XML data or not | [
"The",
"shave",
"method",
"must",
"be",
"able",
"to",
"request",
"more",
"data",
"even",
"though",
"there",
"isn",
"t",
"any",
"more",
"to",
"fetch",
"from",
"the",
"stream",
"this",
"method",
"wraps",
"the",
"getChunk",
"call",
"so",
"that",
"it",
"retu... | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/StringWalker.php#L166-L193 |
prewk/xml-string-streamer | src/XmlStringStreamer/Parser/StringWalker.php | StringWalker.getNodeFrom | public function getNodeFrom(StreamInterface $stream)
{
// Iterate and append to $this->chunk
while ($this->prepareChunk($stream)) {
$this->firstRun = false;
// Shave off elements
while ($shaved = $this->shave()) {
list($element, $data) = $shaved;
// Analyze element
list($opening, $closing, $depth) = $this->getEdges($element);
// Update depth
$this->depth += $depth;
$flush = false;
$captureOnce = false;
// Capture or don't?
if ($this->depth === $this->options["captureDepth"] && $depth > 0) {
// Yes, we've just entered capture depth, start capturing
$this->capture = true;
} else if ($this->depth === $this->options["captureDepth"] - 1 && $depth < 0) {
// No, we've just exited capture depth, stop capturing and prepare for flush
$flush = true;
$this->capture = false;
// ..but include this last node
$this->shaved .= $data;
} else if ($this->options["extractContainer"] && $this->depth < $this->options["captureDepth"]) {
// We're outside of our capture scope, save to the special buffer if extractContainer is true
$this->containerXml .= $element;
} else if ($depth === 0 && $this->depth + 1 === $this->options["captureDepth"]) {
// Self-closing element - capture this element and flush but don't start capturing everything yet
$captureOnce = true;
$flush = true;
}
// Capture the last retrieved node
if ($this->capture || $captureOnce) {
$this->shaved .= $data;
}
if ($flush) {
// Flush the whole node and start over on the next
$flush = $this->shaved;
$this->shaved = null;
return $flush;
}
}
}
return false;
} | php | public function getNodeFrom(StreamInterface $stream)
{
// Iterate and append to $this->chunk
while ($this->prepareChunk($stream)) {
$this->firstRun = false;
// Shave off elements
while ($shaved = $this->shave()) {
list($element, $data) = $shaved;
// Analyze element
list($opening, $closing, $depth) = $this->getEdges($element);
// Update depth
$this->depth += $depth;
$flush = false;
$captureOnce = false;
// Capture or don't?
if ($this->depth === $this->options["captureDepth"] && $depth > 0) {
// Yes, we've just entered capture depth, start capturing
$this->capture = true;
} else if ($this->depth === $this->options["captureDepth"] - 1 && $depth < 0) {
// No, we've just exited capture depth, stop capturing and prepare for flush
$flush = true;
$this->capture = false;
// ..but include this last node
$this->shaved .= $data;
} else if ($this->options["extractContainer"] && $this->depth < $this->options["captureDepth"]) {
// We're outside of our capture scope, save to the special buffer if extractContainer is true
$this->containerXml .= $element;
} else if ($depth === 0 && $this->depth + 1 === $this->options["captureDepth"]) {
// Self-closing element - capture this element and flush but don't start capturing everything yet
$captureOnce = true;
$flush = true;
}
// Capture the last retrieved node
if ($this->capture || $captureOnce) {
$this->shaved .= $data;
}
if ($flush) {
// Flush the whole node and start over on the next
$flush = $this->shaved;
$this->shaved = null;
return $flush;
}
}
}
return false;
} | [
"public",
"function",
"getNodeFrom",
"(",
"StreamInterface",
"$",
"stream",
")",
"{",
"// Iterate and append to $this->chunk",
"while",
"(",
"$",
"this",
"->",
"prepareChunk",
"(",
"$",
"stream",
")",
")",
"{",
"$",
"this",
"->",
"firstRun",
"=",
"false",
";",... | Tries to retrieve the next node or returns false
@param StreamInterface $stream The stream to use
@return string|bool The next xml node or false if one could not be retrieved | [
"Tries",
"to",
"retrieve",
"the",
"next",
"node",
"or",
"returns",
"false"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer/Parser/StringWalker.php#L214-L268 |
prewk/xml-string-streamer | src/XmlStringStreamer.php | XmlStringStreamer.createStringWalkerParser | public static function createStringWalkerParser($file, $options = array())
{
$stream = new Stream\File($file, 16384);
$parser = new Parser\StringWalker($options);
return new XmlStringStreamer($parser, $stream);
} | php | public static function createStringWalkerParser($file, $options = array())
{
$stream = new Stream\File($file, 16384);
$parser = new Parser\StringWalker($options);
return new XmlStringStreamer($parser, $stream);
} | [
"public",
"static",
"function",
"createStringWalkerParser",
"(",
"$",
"file",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"stream",
"=",
"new",
"Stream",
"\\",
"File",
"(",
"$",
"file",
",",
"16384",
")",
";",
"$",
"parser",
"=",
"new... | Convenience method for creating a StringWalker parser with a File stream
@param string|resource $file File path or handle
@param array $options Parser configuration
@return XmlStringStreamer A streamer ready for use | [
"Convenience",
"method",
"for",
"creating",
"a",
"StringWalker",
"parser",
"with",
"a",
"File",
"stream"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer.php#L49-L54 |
prewk/xml-string-streamer | src/XmlStringStreamer.php | XmlStringStreamer.createUniqueNodeParser | public static function createUniqueNodeParser($file, $options = array())
{
$stream = new Stream\File($file, 16384);
$parser = new Parser\UniqueNode($options);
return new XmlStringStreamer($parser, $stream);
} | php | public static function createUniqueNodeParser($file, $options = array())
{
$stream = new Stream\File($file, 16384);
$parser = new Parser\UniqueNode($options);
return new XmlStringStreamer($parser, $stream);
} | [
"public",
"static",
"function",
"createUniqueNodeParser",
"(",
"$",
"file",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"stream",
"=",
"new",
"Stream",
"\\",
"File",
"(",
"$",
"file",
",",
"16384",
")",
";",
"$",
"parser",
"=",
"new",... | Convenience method for creating a UniqueNode parser with a File stream
@param string|resource $file File path or handle
@param array $options Parser configuration
@return XmlStringStreamer A streamer ready for use | [
"Convenience",
"method",
"for",
"creating",
"a",
"UniqueNode",
"parser",
"with",
"a",
"File",
"stream"
] | train | https://github.com/prewk/xml-string-streamer/blob/df6a47d180c7f98a641bf412e0fd28371e169230/src/XmlStringStreamer.php#L62-L67 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.bootHasImageUploads | public static function bootHasImageUploads()
{
// hook up the events
static::saved(function ($model) {
// check for autoupload disabled
if (!$model->disableAutoUpload) {
$model->autoUpload();
}
});
// delete event
static::deleted(function ($model) {
$model->autoDeleteImage();
});
} | php | public static function bootHasImageUploads()
{
// hook up the events
static::saved(function ($model) {
// check for autoupload disabled
if (!$model->disableAutoUpload) {
$model->autoUpload();
}
});
// delete event
static::deleted(function ($model) {
$model->autoDeleteImage();
});
} | [
"public",
"static",
"function",
"bootHasImageUploads",
"(",
")",
"{",
"// hook up the events",
"static",
"::",
"saved",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"// check for autoupload disabled",
"if",
"(",
"!",
"$",
"model",
"->",
"disableAutoUpload",
")",
... | Boot up the trait | [
"Boot",
"up",
"the",
"trait"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L57-L71 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.imageUrl | public function imageUrl($field = null)
{
$this->uploadFieldName = $this->getUploadFieldName($field);
$this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);
// get the model attribute value
$attributeValue = $this->getOriginal($this->uploadFieldName);
// check for placeholder defined in option
$placeholderImage = array_get($this->uploadFieldOptions, 'placeholder');
return (empty($attributeValue) && $placeholderImage)
? $placeholderImage
: $this->getStorageDisk()->url($attributeValue);
} | php | public function imageUrl($field = null)
{
$this->uploadFieldName = $this->getUploadFieldName($field);
$this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);
// get the model attribute value
$attributeValue = $this->getOriginal($this->uploadFieldName);
// check for placeholder defined in option
$placeholderImage = array_get($this->uploadFieldOptions, 'placeholder');
return (empty($attributeValue) && $placeholderImage)
? $placeholderImage
: $this->getStorageDisk()->url($attributeValue);
} | [
"public",
"function",
"imageUrl",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"uploadFieldName",
"=",
"$",
"this",
"->",
"getUploadFieldName",
"(",
"$",
"field",
")",
";",
"$",
"this",
"->",
"uploadFieldOptions",
"=",
"$",
"this",
"->",
... | Get absolute url for a field
@param null $field
@return mixed|string
@throws InvalidUploadFieldException | [
"Get",
"absolute",
"url",
"for",
"a",
"field"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L80-L94 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.imageTag | public function imageTag($field = null, $attributes = '')
{
// if no field found just return empty string
if (!$this->hasImageField($field) || $this->hasFileField($field)) {
return '';
}
try {
return '<img src="' . $this->imageUrl($field) . '" ' . $attributes . ' />';
} catch (\Exception $exception) {
}
} | php | public function imageTag($field = null, $attributes = '')
{
// if no field found just return empty string
if (!$this->hasImageField($field) || $this->hasFileField($field)) {
return '';
}
try {
return '<img src="' . $this->imageUrl($field) . '" ' . $attributes . ' />';
} catch (\Exception $exception) {
}
} | [
"public",
"function",
"imageTag",
"(",
"$",
"field",
"=",
"null",
",",
"$",
"attributes",
"=",
"''",
")",
"{",
"// if no field found just return empty string",
"if",
"(",
"!",
"$",
"this",
"->",
"hasImageField",
"(",
"$",
"field",
")",
"||",
"$",
"this",
"... | Get html image tag for a field if image present
@param null $field
@param string $attributes
@return string | [
"Get",
"html",
"image",
"tag",
"for",
"a",
"field",
"if",
"image",
"present"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L115-L126 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.uploadImage | public function uploadImage($imageFile, $field = null)
{
$this->uploadFieldName = $this->getUploadFieldName($field);
$this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);
// validate it
$this->validateImage($imageFile, $this->uploadFieldName, $this->uploadFieldOptions);
// handle upload
$filePath = $this->hasFileField($this->uploadFieldName)
? $this->handleFileUpload($imageFile)
: $this->handleImageUpload($imageFile);
// hold old file
$currentFile = $this->getOriginal($this->uploadFieldName);
// update the model with field name
$this->updateModel($filePath, $this->uploadFieldName);
// delete old file
if ($currentFile != $filePath) {
$this->deleteImage($currentFile);
}
} | php | public function uploadImage($imageFile, $field = null)
{
$this->uploadFieldName = $this->getUploadFieldName($field);
$this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);
// validate it
$this->validateImage($imageFile, $this->uploadFieldName, $this->uploadFieldOptions);
// handle upload
$filePath = $this->hasFileField($this->uploadFieldName)
? $this->handleFileUpload($imageFile)
: $this->handleImageUpload($imageFile);
// hold old file
$currentFile = $this->getOriginal($this->uploadFieldName);
// update the model with field name
$this->updateModel($filePath, $this->uploadFieldName);
// delete old file
if ($currentFile != $filePath) {
$this->deleteImage($currentFile);
}
} | [
"public",
"function",
"uploadImage",
"(",
"$",
"imageFile",
",",
"$",
"field",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"uploadFieldName",
"=",
"$",
"this",
"->",
"getUploadFieldName",
"(",
"$",
"field",
")",
";",
"$",
"this",
"->",
"uploadFieldOptions",
... | Upload and resize image
@param $imageFile
@param null $field
@throws InvalidUploadFieldException|\Exception | [
"Upload",
"and",
"resize",
"image"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L135-L158 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.resizeImage | public function resizeImage($imageFile, $imageFieldOptions)
{
$image = Image::make($imageFile);
// check if resize needed
if (!$this->needResizing($imageFieldOptions)) {
return $image;
}
// resize it according to options
$width = array_get($imageFieldOptions, 'width');
$height = array_get($imageFieldOptions, 'height');
$cropHeight = empty($height) ? $width : $height;
$crop = $this->getCropOption($imageFieldOptions);
// crop it if option is set to true
if ($crop === true) {
$image->fit($width, $cropHeight, function ($constraint) {
$constraint->upsize();
});
return $image;
}
// crop with x,y coordinate array
if (is_array($crop) && count($crop) == 2) {
list($x, $y) = $crop;
$image->crop($width, $cropHeight, $x, $y);
return $image;
}
// or resize it with given width and height
$image->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
return $image;
} | php | public function resizeImage($imageFile, $imageFieldOptions)
{
$image = Image::make($imageFile);
// check if resize needed
if (!$this->needResizing($imageFieldOptions)) {
return $image;
}
// resize it according to options
$width = array_get($imageFieldOptions, 'width');
$height = array_get($imageFieldOptions, 'height');
$cropHeight = empty($height) ? $width : $height;
$crop = $this->getCropOption($imageFieldOptions);
// crop it if option is set to true
if ($crop === true) {
$image->fit($width, $cropHeight, function ($constraint) {
$constraint->upsize();
});
return $image;
}
// crop with x,y coordinate array
if (is_array($crop) && count($crop) == 2) {
list($x, $y) = $crop;
$image->crop($width, $cropHeight, $x, $y);
return $image;
}
// or resize it with given width and height
$image->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
return $image;
} | [
"public",
"function",
"resizeImage",
"(",
"$",
"imageFile",
",",
"$",
"imageFieldOptions",
")",
"{",
"$",
"image",
"=",
"Image",
"::",
"make",
"(",
"$",
"imageFile",
")",
";",
"// check if resize needed",
"if",
"(",
"!",
"$",
"this",
"->",
"needResizing",
... | Resize image based on options
@param $imageFile
@param $imageFieldOptions array
@return \Intervention\Image\Image | [
"Resize",
"image",
"based",
"on",
"options"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L179-L219 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.setImagesField | public function setImagesField($fieldsOptions)
{
if (isset(static::$imageFields)) {
static::$imageFields = array_merge($this->getDefinedUploadFields(), $fieldsOptions);
} else {
$this->imagesFields = $fieldsOptions;
}
return $this;
} | php | public function setImagesField($fieldsOptions)
{
if (isset(static::$imageFields)) {
static::$imageFields = array_merge($this->getDefinedUploadFields(), $fieldsOptions);
} else {
$this->imagesFields = $fieldsOptions;
}
return $this;
} | [
"public",
"function",
"setImagesField",
"(",
"$",
"fieldsOptions",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"imageFields",
")",
")",
"{",
"static",
"::",
"$",
"imageFields",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getDefinedUploadFields",... | Setter for model image fields
@param $fieldsOptions
@return $this | [
"Setter",
"for",
"model",
"image",
"fields"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L240-L249 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.setFilesField | public function setFilesField($fieldsOptions)
{
if (isset(static::$fileFields)) {
static::$fileFields = array_merge($this->getDefinedUploadFields(), $fieldsOptions);
} else {
$this->filesFields = $fieldsOptions;
}
return $this;
} | php | public function setFilesField($fieldsOptions)
{
if (isset(static::$fileFields)) {
static::$fileFields = array_merge($this->getDefinedUploadFields(), $fieldsOptions);
} else {
$this->filesFields = $fieldsOptions;
}
return $this;
} | [
"public",
"function",
"setFilesField",
"(",
"$",
"fieldsOptions",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"fileFields",
")",
")",
"{",
"static",
"::",
"$",
"fileFields",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getDefinedUploadFields",
... | Setter for model file fields
@param $fieldsOptions
@return $this | [
"Setter",
"for",
"model",
"file",
"fields"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L257-L266 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getUploadFieldOptions | public function getUploadFieldOptions($field = null)
{
// get first option if no field provided
if (is_null($field)) {
$imagesFields = $this->getDefinedUploadFields();
if (!$imagesFields) {
throw new InvalidUploadFieldException(
'No upload fields are defined in $imageFields/$fileFields array on model.'
);
}
$fieldKey = array_first(array_keys($imagesFields));
$options = is_int($fieldKey) ? [] : array_first($imagesFields);
return $options;
}
// check if provided filed defined
if (!$this->hasImageField($field)) {
throw new InvalidUploadFieldException(
'Image/File field `' . $field . '` is not defined in $imageFields/$fileFields array on model.'
);
}
return array_get($this->getDefinedUploadFields(), $field, []);
} | php | public function getUploadFieldOptions($field = null)
{
// get first option if no field provided
if (is_null($field)) {
$imagesFields = $this->getDefinedUploadFields();
if (!$imagesFields) {
throw new InvalidUploadFieldException(
'No upload fields are defined in $imageFields/$fileFields array on model.'
);
}
$fieldKey = array_first(array_keys($imagesFields));
$options = is_int($fieldKey) ? [] : array_first($imagesFields);
return $options;
}
// check if provided filed defined
if (!$this->hasImageField($field)) {
throw new InvalidUploadFieldException(
'Image/File field `' . $field . '` is not defined in $imageFields/$fileFields array on model.'
);
}
return array_get($this->getDefinedUploadFields(), $field, []);
} | [
"public",
"function",
"getUploadFieldOptions",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"// get first option if no field provided",
"if",
"(",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"$",
"imagesFields",
"=",
"$",
"this",
"->",
"getDefinedUploadFields",
"(... | Get upload field options
@param $field
@return array
@throws InvalidUploadFieldException | [
"Get",
"upload",
"field",
"options"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L275-L301 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getDefinedUploadFields | public function getDefinedUploadFields()
{
$fields = isset(static::$imageFields)
? static::$imageFields
: $this->imagesFields;
return array_merge($this->getDefinedFileFields(), $fields);
} | php | public function getDefinedUploadFields()
{
$fields = isset(static::$imageFields)
? static::$imageFields
: $this->imagesFields;
return array_merge($this->getDefinedFileFields(), $fields);
} | [
"public",
"function",
"getDefinedUploadFields",
"(",
")",
"{",
"$",
"fields",
"=",
"isset",
"(",
"static",
"::",
"$",
"imageFields",
")",
"?",
"static",
"::",
"$",
"imageFields",
":",
"$",
"this",
"->",
"imagesFields",
";",
"return",
"array_merge",
"(",
"$... | Get all the image and file fields defined on model
@return array | [
"Get",
"all",
"the",
"image",
"and",
"file",
"fields",
"defined",
"on",
"model"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L308-L315 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getUploadFieldName | public function getUploadFieldName($field = null)
{
if (!is_null($field)) {
return $field;
}
$imagesFields = $this->getDefinedUploadFields();
$fieldKey = array_first(array_keys($imagesFields));
// return first field name
return is_int($fieldKey)
? $imagesFields[$fieldKey]
: $fieldKey;
} | php | public function getUploadFieldName($field = null)
{
if (!is_null($field)) {
return $field;
}
$imagesFields = $this->getDefinedUploadFields();
$fieldKey = array_first(array_keys($imagesFields));
// return first field name
return is_int($fieldKey)
? $imagesFields[$fieldKey]
: $fieldKey;
} | [
"public",
"function",
"getUploadFieldName",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"return",
"$",
"field",
";",
"}",
"$",
"imagesFields",
"=",
"$",
"this",
"->",
"getDefinedUploadFields",
... | Get the upload field name
@param null $field
@return mixed|null | [
"Get",
"the",
"upload",
"field",
"name"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L335-L348 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.hasUploadField | private function hasUploadField($field, $definedField)
{
// check for string key
if (array_has($definedField, $field)) {
return true;
}
// check for value
$found = false;
foreach ($definedField as $key => $val) {
$found = (is_numeric($key) && $val === $field);
if ($found) {
break;
}
}
return $found;
} | php | private function hasUploadField($field, $definedField)
{
// check for string key
if (array_has($definedField, $field)) {
return true;
}
// check for value
$found = false;
foreach ($definedField as $key => $val) {
$found = (is_numeric($key) && $val === $field);
if ($found) {
break;
}
}
return $found;
} | [
"private",
"function",
"hasUploadField",
"(",
"$",
"field",
",",
"$",
"definedField",
")",
"{",
"// check for string key",
"if",
"(",
"array_has",
"(",
"$",
"definedField",
",",
"$",
"field",
")",
")",
"{",
"return",
"true",
";",
"}",
"// check for value",
"... | Check is upload field is defined
@param $field
@param $definedField
@return bool | [
"Check",
"is",
"upload",
"field",
"is",
"defined"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L379-L397 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.deleteUploadedFile | private function deleteUploadedFile($filePath)
{
if ($this->getStorageDisk()->exists($filePath)) {
$this->getStorageDisk()->delete($filePath);
}
} | php | private function deleteUploadedFile($filePath)
{
if ($this->getStorageDisk()->exists($filePath)) {
$this->getStorageDisk()->delete($filePath);
}
} | [
"private",
"function",
"deleteUploadedFile",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStorageDisk",
"(",
")",
"->",
"exists",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"this",
"->",
"getStorageDisk",
"(",
")",
"->",
"delete",
"... | Delete a file from disk
@param $filePath | [
"Delete",
"a",
"file",
"from",
"disk"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L424-L429 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getImageUploadPath | protected function getImageUploadPath()
{
// check for disk option
if ($pathInOption = array_get($this->uploadFieldOptions, 'path')) {
return $pathInOption;
}
return property_exists($this, 'imagesUploadPath')
? trim($this->imagesUploadPath, '/')
: trim(config('imageup.upload_directory', 'uploads'), '/');
} | php | protected function getImageUploadPath()
{
// check for disk option
if ($pathInOption = array_get($this->uploadFieldOptions, 'path')) {
return $pathInOption;
}
return property_exists($this, 'imagesUploadPath')
? trim($this->imagesUploadPath, '/')
: trim(config('imageup.upload_directory', 'uploads'), '/');
} | [
"protected",
"function",
"getImageUploadPath",
"(",
")",
"{",
"// check for disk option",
"if",
"(",
"$",
"pathInOption",
"=",
"array_get",
"(",
"$",
"this",
"->",
"uploadFieldOptions",
",",
"'path'",
")",
")",
"{",
"return",
"$",
"pathInOption",
";",
"}",
"re... | Get image upload path
@return string | [
"Get",
"image",
"upload",
"path"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L436-L446 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getFileUploadPath | protected function getFileUploadPath($file)
{
// check if path override is defined for current file
$pathOverrideMethod = camel_case(strtolower($this->uploadFieldName) . 'UploadFilePath');
if (method_exists($this, $pathOverrideMethod)) {
return $this->getImageUploadPath() . '/' . $this->$pathOverrideMethod($file);
}
return $this->getImageUploadPath() . '/' . $file->hashName();
} | php | protected function getFileUploadPath($file)
{
// check if path override is defined for current file
$pathOverrideMethod = camel_case(strtolower($this->uploadFieldName) . 'UploadFilePath');
if (method_exists($this, $pathOverrideMethod)) {
return $this->getImageUploadPath() . '/' . $this->$pathOverrideMethod($file);
}
return $this->getImageUploadPath() . '/' . $file->hashName();
} | [
"protected",
"function",
"getFileUploadPath",
"(",
"$",
"file",
")",
"{",
"// check if path override is defined for current file",
"$",
"pathOverrideMethod",
"=",
"camel_case",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"uploadFieldName",
")",
".",
"'UploadFilePath'",
"... | Get the full path to upload file
@param $file
@return string | [
"Get",
"the",
"full",
"path",
"to",
"upload",
"file"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L454-L464 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getImageUploadDisk | protected function getImageUploadDisk()
{
// check for disk option
if ($diskInOption = array_get($this->uploadFieldOptions, 'disk')) {
return $diskInOption;
}
return property_exists($this, 'imagesUploadDisk')
? $this->imagesUploadDisk
: config('imageup.upload_disk', 'public');
} | php | protected function getImageUploadDisk()
{
// check for disk option
if ($diskInOption = array_get($this->uploadFieldOptions, 'disk')) {
return $diskInOption;
}
return property_exists($this, 'imagesUploadDisk')
? $this->imagesUploadDisk
: config('imageup.upload_disk', 'public');
} | [
"protected",
"function",
"getImageUploadDisk",
"(",
")",
"{",
"// check for disk option",
"if",
"(",
"$",
"diskInOption",
"=",
"array_get",
"(",
"$",
"this",
"->",
"uploadFieldOptions",
",",
"'disk'",
")",
")",
"{",
"return",
"$",
"diskInOption",
";",
"}",
"re... | Get image upload disk
@return string | [
"Get",
"image",
"upload",
"disk"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L471-L481 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.validateImage | protected function validateImage($file, $fieldName, $imageOptions)
{
if ($rules = array_get($imageOptions, 'rules')) {
$this->validationFactory()->make(
[$fieldName => $file],
[$fieldName => $rules]
)->validate();
}
} | php | protected function validateImage($file, $fieldName, $imageOptions)
{
if ($rules = array_get($imageOptions, 'rules')) {
$this->validationFactory()->make(
[$fieldName => $file],
[$fieldName => $rules]
)->validate();
}
} | [
"protected",
"function",
"validateImage",
"(",
"$",
"file",
",",
"$",
"fieldName",
",",
"$",
"imageOptions",
")",
"{",
"if",
"(",
"$",
"rules",
"=",
"array_get",
"(",
"$",
"imageOptions",
",",
"'rules'",
")",
")",
"{",
"$",
"this",
"->",
"validationFacto... | Validate image file with given rules in option
@param $file
@param $fieldName
@param $imageOptions | [
"Validate",
"image",
"file",
"with",
"given",
"rules",
"in",
"option"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L512-L520 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.saveImage | protected function saveImage($imageFile, $image)
{
// Trigger before save hook
$this->triggerBeforeSaveHook($image);
$imageQuality = array_get(
$this->uploadFieldOptions,
'resize_image_quality',
config('imageup.resize_image_quality')
);
$imagePath = $this->getFileUploadPath($imageFile);
$this->getStorageDisk()->put(
$imagePath,
(string)$image->encode(null, $imageQuality),
'public'
);
// Trigger after save hook
$this->triggerAfterSaveHook($image);
// clean up
$image->destroy();
return $imagePath;
} | php | protected function saveImage($imageFile, $image)
{
// Trigger before save hook
$this->triggerBeforeSaveHook($image);
$imageQuality = array_get(
$this->uploadFieldOptions,
'resize_image_quality',
config('imageup.resize_image_quality')
);
$imagePath = $this->getFileUploadPath($imageFile);
$this->getStorageDisk()->put(
$imagePath,
(string)$image->encode(null, $imageQuality),
'public'
);
// Trigger after save hook
$this->triggerAfterSaveHook($image);
// clean up
$image->destroy();
return $imagePath;
} | [
"protected",
"function",
"saveImage",
"(",
"$",
"imageFile",
",",
"$",
"image",
")",
"{",
"// Trigger before save hook",
"$",
"this",
"->",
"triggerBeforeSaveHook",
"(",
"$",
"image",
")",
";",
"$",
"imageQuality",
"=",
"array_get",
"(",
"$",
"this",
"->",
"... | Save the image to disk
@param $imageFile
@param $image
@return string
@throws \Exception | [
"Save",
"the",
"image",
"to",
"disk"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L530-L556 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.updateModel | protected function updateModel($imagePath, $imageFieldName)
{
$this->attributes[$imageFieldName] = $imagePath;
$dispatcher = $this->getEventDispatcher();
self::unsetEventDispatcher();
$this->save();
self::setEventDispatcher($dispatcher);
} | php | protected function updateModel($imagePath, $imageFieldName)
{
$this->attributes[$imageFieldName] = $imagePath;
$dispatcher = $this->getEventDispatcher();
self::unsetEventDispatcher();
$this->save();
self::setEventDispatcher($dispatcher);
} | [
"protected",
"function",
"updateModel",
"(",
"$",
"imagePath",
",",
"$",
"imageFieldName",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"imageFieldName",
"]",
"=",
"$",
"imagePath",
";",
"$",
"dispatcher",
"=",
"$",
"this",
"->",
"getEventDispatcher"... | update the model field
@param $imagePath
@param $imageFieldName | [
"update",
"the",
"model",
"field"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L564-L572 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.getCropOption | protected function getCropOption($imageFieldOptions)
{
$crop = array_get($imageFieldOptions, 'crop', false);
// check for crop override
if (isset($this->cropCoordinates) && count($this->cropCoordinates) == 2) {
$crop = $this->cropCoordinates;
}
return $crop;
} | php | protected function getCropOption($imageFieldOptions)
{
$crop = array_get($imageFieldOptions, 'crop', false);
// check for crop override
if (isset($this->cropCoordinates) && count($this->cropCoordinates) == 2) {
$crop = $this->cropCoordinates;
}
return $crop;
} | [
"protected",
"function",
"getCropOption",
"(",
"$",
"imageFieldOptions",
")",
"{",
"$",
"crop",
"=",
"array_get",
"(",
"$",
"imageFieldOptions",
",",
"'crop'",
",",
"false",
")",
";",
"// check for crop override",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
... | Get the crop option
@param $imageFieldOptions
@return array|boolean | [
"Get",
"the",
"crop",
"option"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L580-L590 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.autoUpload | protected function autoUpload()
{
foreach ($this->getDefinedUploadFields() as $key => $val) {
$field = is_int($key) ? $val : $key;
$options = array_wrap($val);
// check if global upload is allowed, then in override in option
$autoUploadAllowed = array_get($options, 'auto_upload', $this->canAutoUploadImages());
if (!$autoUploadAllowed) {
continue;
}
// get the input file name
$requestFileName = array_get($options, 'file_input', $field);
// if request has the file upload it
if (request()->hasFile($requestFileName)) {
$this->uploadImage(
request()->file($requestFileName),
$field
);
}
}
} | php | protected function autoUpload()
{
foreach ($this->getDefinedUploadFields() as $key => $val) {
$field = is_int($key) ? $val : $key;
$options = array_wrap($val);
// check if global upload is allowed, then in override in option
$autoUploadAllowed = array_get($options, 'auto_upload', $this->canAutoUploadImages());
if (!$autoUploadAllowed) {
continue;
}
// get the input file name
$requestFileName = array_get($options, 'file_input', $field);
// if request has the file upload it
if (request()->hasFile($requestFileName)) {
$this->uploadImage(
request()->file($requestFileName),
$field
);
}
}
} | [
"protected",
"function",
"autoUpload",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDefinedUploadFields",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"field",
"=",
"is_int",
"(",
"$",
"key",
")",
"?",
"$",
"val",
":",
"$",... | Auto image upload handler
@throws InvalidUploadFieldException
@throws \Exception | [
"Auto",
"image",
"upload",
"handler"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L608-L632 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.autoDeleteImage | protected function autoDeleteImage()
{
if (config('imageup.auto_delete_images')) {
foreach ($this->getDefinedUploadFields() as $field => $options) {
$field = is_numeric($field) ? $options : $field;
$this->deleteImage($this->getOriginal($field));
}
}
} | php | protected function autoDeleteImage()
{
if (config('imageup.auto_delete_images')) {
foreach ($this->getDefinedUploadFields() as $field => $options) {
$field = is_numeric($field) ? $options : $field;
$this->deleteImage($this->getOriginal($field));
}
}
} | [
"protected",
"function",
"autoDeleteImage",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'imageup.auto_delete_images'",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDefinedUploadFields",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"options",
")",
"{",
"... | Auto delete image handler | [
"Auto",
"delete",
"image",
"handler"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L637-L645 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.triggerHook | protected function triggerHook($hook, $image)
{
if (is_callable($hook)) {
$hook($image);
}
// We assume that the user is passing the hook class name
if (is_string($hook)) {
$instance = app($hook);
$instance->handle($image);
}
} | php | protected function triggerHook($hook, $image)
{
if (is_callable($hook)) {
$hook($image);
}
// We assume that the user is passing the hook class name
if (is_string($hook)) {
$instance = app($hook);
$instance->handle($image);
}
} | [
"protected",
"function",
"triggerHook",
"(",
"$",
"hook",
",",
"$",
"image",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"hook",
")",
")",
"{",
"$",
"hook",
"(",
"$",
"image",
")",
";",
"}",
"// We assume that the user is passing the hook class name",
"if"... | This will try to trigger the hook depending on the user definition.
@param $hook
@param $image
@throws \Exception | [
"This",
"will",
"try",
"to",
"trigger",
"the",
"hook",
"depending",
"on",
"the",
"user",
"definition",
"."
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L666-L677 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.triggerBeforeSaveHook | protected function triggerBeforeSaveHook($image)
{
if (isset($this->uploadFieldOptions['before_save'])) {
$this->triggerHook($this->uploadFieldOptions['before_save'], $image);
}
return $this;
} | php | protected function triggerBeforeSaveHook($image)
{
if (isset($this->uploadFieldOptions['before_save'])) {
$this->triggerHook($this->uploadFieldOptions['before_save'], $image);
}
return $this;
} | [
"protected",
"function",
"triggerBeforeSaveHook",
"(",
"$",
"image",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uploadFieldOptions",
"[",
"'before_save'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"triggerHook",
"(",
"$",
"this",
"->",
"uploadFiel... | Trigger user defined before save hook.
@param $image
@return $this
@throws \Exception | [
"Trigger",
"user",
"defined",
"before",
"save",
"hook",
"."
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L687-L694 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.triggerAfterSaveHook | protected function triggerAfterSaveHook($image)
{
if (isset($this->uploadFieldOptions['after_save'])) {
$this->triggerHook($this->uploadFieldOptions['after_save'], $image);
}
return $this;
} | php | protected function triggerAfterSaveHook($image)
{
if (isset($this->uploadFieldOptions['after_save'])) {
$this->triggerHook($this->uploadFieldOptions['after_save'], $image);
}
return $this;
} | [
"protected",
"function",
"triggerAfterSaveHook",
"(",
"$",
"image",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uploadFieldOptions",
"[",
"'after_save'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"triggerHook",
"(",
"$",
"this",
"->",
"uploadFieldO... | Trigger user defined after save hook.
@param $image
@return $this
@throws \Exception | [
"Trigger",
"user",
"defined",
"after",
"save",
"hook",
"."
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L704-L711 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.handleImageUpload | protected function handleImageUpload($imageFile)
{
// resize the image with given option
$image = $this->resizeImage($imageFile, $this->uploadFieldOptions);
// save the uploaded file on disk
return $this->saveImage($imageFile, $image);
} | php | protected function handleImageUpload($imageFile)
{
// resize the image with given option
$image = $this->resizeImage($imageFile, $this->uploadFieldOptions);
// save the uploaded file on disk
return $this->saveImage($imageFile, $image);
} | [
"protected",
"function",
"handleImageUpload",
"(",
"$",
"imageFile",
")",
"{",
"// resize the image with given option",
"$",
"image",
"=",
"$",
"this",
"->",
"resizeImage",
"(",
"$",
"imageFile",
",",
"$",
"this",
"->",
"uploadFieldOptions",
")",
";",
"// save the... | Process image upload
@param $imageFile
@return string
@throws \Exception | [
"Process",
"image",
"upload"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L720-L727 |
qcod/laravel-imageup | src/HasImageUploads.php | HasImageUploads.handleFileUpload | public function handleFileUpload($file)
{
// Trigger before save hook
$this->triggerBeforeSaveHook($file);
$filePath = $this->getFileUploadPath($file);
$this->getStorageDisk()->put($filePath, file_get_contents($file), 'public');
// Trigger after save hook
$this->triggerAfterSaveHook($file);
return $filePath;
} | php | public function handleFileUpload($file)
{
// Trigger before save hook
$this->triggerBeforeSaveHook($file);
$filePath = $this->getFileUploadPath($file);
$this->getStorageDisk()->put($filePath, file_get_contents($file), 'public');
// Trigger after save hook
$this->triggerAfterSaveHook($file);
return $filePath;
} | [
"public",
"function",
"handleFileUpload",
"(",
"$",
"file",
")",
"{",
"// Trigger before save hook",
"$",
"this",
"->",
"triggerBeforeSaveHook",
"(",
"$",
"file",
")",
";",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFileUploadPath",
"(",
"$",
"file",
")",
... | Process file upload
@param $file
@return string
@throws \Exception | [
"Process",
"file",
"upload"
] | train | https://github.com/qcod/laravel-imageup/blob/675a99b51a9731890cf30205bf42d84744029b68/src/HasImageUploads.php#L736-L749 |
riskihajar/terbilang | src/TerbilangServiceProvider.php | TerbilangServiceProvider.register | public function register()
{
$this->mergeConfigFrom(
__DIR__ . '/../lib/config/terbilang.php', 'terbilang'
);
$this->app->singleton('terbilang', function($app){
return new Terbilang;
});
$this->app->booting(function(){
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Terbilang', 'Riskihajar\Terbilang\Facades\Terbilang');
});
} | php | public function register()
{
$this->mergeConfigFrom(
__DIR__ . '/../lib/config/terbilang.php', 'terbilang'
);
$this->app->singleton('terbilang', function($app){
return new Terbilang;
});
$this->app->booting(function(){
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Terbilang', 'Riskihajar\Terbilang\Facades\Terbilang');
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/../lib/config/terbilang.php'",
",",
"'terbilang'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'terbilang'",
",",
"function",
"(",
... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/riskihajar/terbilang/blob/2908d3d71eb9720b4c52732108a098067141923b/src/TerbilangServiceProvider.php#L32-L46 |
xoco70/laravel-tournaments | src/TreeGen/PlayOffTreeGen.php | PlayOffTreeGen.chunk | protected function chunk(Collection $fightersByEntity)
{
if ($this->championship->hasPreliminary()) {
$fightersGroup = $fightersByEntity->chunk($this->settings->preliminaryGroupSize);
return $fightersGroup;
}
return $fightersByEntity->chunk($fightersByEntity->count());
} | php | protected function chunk(Collection $fightersByEntity)
{
if ($this->championship->hasPreliminary()) {
$fightersGroup = $fightersByEntity->chunk($this->settings->preliminaryGroupSize);
return $fightersGroup;
}
return $fightersByEntity->chunk($fightersByEntity->count());
} | [
"protected",
"function",
"chunk",
"(",
"Collection",
"$",
"fightersByEntity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"championship",
"->",
"hasPreliminary",
"(",
")",
")",
"{",
"$",
"fightersGroup",
"=",
"$",
"fightersByEntity",
"->",
"chunk",
"(",
"$",
"... | Chunk Fighters into groups for fighting, and optionnaly shuffle.
@param $fightersByEntity
@return mixed | [
"Chunk",
"Fighters",
"into",
"groups",
"for",
"fighting",
"and",
"optionnaly",
"shuffle",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/PlayOffTreeGen.php#L34-L42 |
xoco70/laravel-tournaments | src/TreeGen/PlayOffTreeGen.php | PlayOffTreeGen.pushGroups | protected function pushGroups($numRounds, $numFightersElim)
{
for ($roundNumber = 2; $roundNumber <= $numRounds; $roundNumber++) {
// From last match to first match
$maxMatches = ($numFightersElim / pow(2, $roundNumber));
for ($matchNumber = 1; $matchNumber <= $maxMatches; $matchNumber++) {
$fighters = $this->createByeGroup(2);
$group = $this->saveGroup($matchNumber, $roundNumber, null);
$this->syncGroup($group, $fighters);
}
}
} | php | protected function pushGroups($numRounds, $numFightersElim)
{
for ($roundNumber = 2; $roundNumber <= $numRounds; $roundNumber++) {
// From last match to first match
$maxMatches = ($numFightersElim / pow(2, $roundNumber));
for ($matchNumber = 1; $matchNumber <= $maxMatches; $matchNumber++) {
$fighters = $this->createByeGroup(2);
$group = $this->saveGroup($matchNumber, $roundNumber, null);
$this->syncGroup($group, $fighters);
}
}
} | [
"protected",
"function",
"pushGroups",
"(",
"$",
"numRounds",
",",
"$",
"numFightersElim",
")",
"{",
"for",
"(",
"$",
"roundNumber",
"=",
"2",
";",
"$",
"roundNumber",
"<=",
"$",
"numRounds",
";",
"$",
"roundNumber",
"++",
")",
"{",
"// From last match to fi... | Save Groups with their parent info.
@param int $numRounds
@param $numFightersElim | [
"Save",
"Groups",
"with",
"their",
"parent",
"info",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/PlayOffTreeGen.php#L59-L70 |
xoco70/laravel-tournaments | src/TournamentsServiceProvider.php | TournamentsServiceProvider.boot | public function boot()
{
$viewPath = __DIR__.'/../resources/views';
$this->loadViewsFrom($viewPath, 'laravel-tournaments');
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadTranslationsFrom(__DIR__.'/../translations', 'laravel-tournaments');
$this->publishes([__DIR__.'/../database/seeds' => $this->app->databasePath().'/seeds'], 'laravel-tournaments');
$this->publishes([__DIR__.'/../database/factories' => $this->app->databasePath().'/factories'], 'laravel-tournaments');
$this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/laravel-tournaments')], 'laravel-tournaments');
$this->publishes([__DIR__.'/../config/laravel-tournaments.php' => config_path('laravel-tournaments.php')], 'laravel-tournaments');
} | php | public function boot()
{
$viewPath = __DIR__.'/../resources/views';
$this->loadViewsFrom($viewPath, 'laravel-tournaments');
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadTranslationsFrom(__DIR__.'/../translations', 'laravel-tournaments');
$this->publishes([__DIR__.'/../database/seeds' => $this->app->databasePath().'/seeds'], 'laravel-tournaments');
$this->publishes([__DIR__.'/../database/factories' => $this->app->databasePath().'/factories'], 'laravel-tournaments');
$this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/laravel-tournaments')], 'laravel-tournaments');
$this->publishes([__DIR__.'/../config/laravel-tournaments.php' => config_path('laravel-tournaments.php')], 'laravel-tournaments');
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"viewPath",
"=",
"__DIR__",
".",
"'/../resources/views'",
";",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"$",
"viewPath",
",",
"'laravel-tournaments'",
")",
";",
"$",
"this",
"->",
"loadMigrationsFrom",
"(",
"... | Bootstrap the application services.
@param Router $router
@return void | [
"Bootstrap",
"the",
"application",
"services",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TournamentsServiceProvider.php#L17-L29 |
xoco70/laravel-tournaments | database/migrations/2015_11_23_125510_create_lt_Fight_table.php | CreateLtFightTable.up | public function up()
{
if (!Schema::hasTable('fight')) {
Schema::create('fight', function (Blueprint $table) {
$table->increments('id');
$table->integer('short_id')->unsigned()->nullable();
$table->integer('fighters_group_id')->unsigned()->index();
$table->foreign('fighters_group_id')
->references('id')
->on('fighters_groups')
->onUpdate('cascade')
->onDelete('cascade');
$table->integer('c1')->nullable()->unsigned()->index();
$table->integer('c2')->nullable()->unsigned()->index();
$table->char('point1_c1')->nullable();
$table->char('point2_c1')->nullable();
$table->char('point1_c2')->nullable();
$table->char('point2_c2')->nullable();
$table->integer('winner_id')->unsigned()->nullable();
$table->boolean('hansoku1_c1')->nullable();
$table->boolean('hansoku2_c1')->nullable();
$table->boolean('hansoku3_c1')->nullable();
$table->boolean('hansoku4_c1')->nullable();
$table->boolean('hansoku1_c2')->nullable();
$table->boolean('hansoku2_c2')->nullable();
$table->boolean('hansoku3_c2')->nullable();
$table->boolean('hansoku4_c2')->nullable();
$table->tinyInteger('area')->default(1);
$table->tinyInteger('order')->default(1);
$table->timestamps();
$table->engine = 'InnoDB';
});
}
} | php | public function up()
{
if (!Schema::hasTable('fight')) {
Schema::create('fight', function (Blueprint $table) {
$table->increments('id');
$table->integer('short_id')->unsigned()->nullable();
$table->integer('fighters_group_id')->unsigned()->index();
$table->foreign('fighters_group_id')
->references('id')
->on('fighters_groups')
->onUpdate('cascade')
->onDelete('cascade');
$table->integer('c1')->nullable()->unsigned()->index();
$table->integer('c2')->nullable()->unsigned()->index();
$table->char('point1_c1')->nullable();
$table->char('point2_c1')->nullable();
$table->char('point1_c2')->nullable();
$table->char('point2_c2')->nullable();
$table->integer('winner_id')->unsigned()->nullable();
$table->boolean('hansoku1_c1')->nullable();
$table->boolean('hansoku2_c1')->nullable();
$table->boolean('hansoku3_c1')->nullable();
$table->boolean('hansoku4_c1')->nullable();
$table->boolean('hansoku1_c2')->nullable();
$table->boolean('hansoku2_c2')->nullable();
$table->boolean('hansoku3_c2')->nullable();
$table->boolean('hansoku4_c2')->nullable();
$table->tinyInteger('area')->default(1);
$table->tinyInteger('order')->default(1);
$table->timestamps();
$table->engine = 'InnoDB';
});
}
} | [
"public",
"function",
"up",
"(",
")",
"{",
"if",
"(",
"!",
"Schema",
"::",
"hasTable",
"(",
"'fight'",
")",
")",
"{",
"Schema",
"::",
"create",
"(",
"'fight'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/migrations/2015_11_23_125510_create_lt_Fight_table.php#L15-L50 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.getByeGroup | protected function getByeGroup($fighters)
{
$fighterCount = $fighters->count();
$firstRoundGroupSize = $this->firstRoundGroupSize(); // Get the size of groups in the first round (2,3,4)
// Max number of fighters for the first round
$treeSize = $this->getTreeSize($fighterCount, $firstRoundGroupSize);
$byeCount = $treeSize - $fighterCount;
return $this->createByeGroup($byeCount);
} | php | protected function getByeGroup($fighters)
{
$fighterCount = $fighters->count();
$firstRoundGroupSize = $this->firstRoundGroupSize(); // Get the size of groups in the first round (2,3,4)
// Max number of fighters for the first round
$treeSize = $this->getTreeSize($fighterCount, $firstRoundGroupSize);
$byeCount = $treeSize - $fighterCount;
return $this->createByeGroup($byeCount);
} | [
"protected",
"function",
"getByeGroup",
"(",
"$",
"fighters",
")",
"{",
"$",
"fighterCount",
"=",
"$",
"fighters",
"->",
"count",
"(",
")",
";",
"$",
"firstRoundGroupSize",
"=",
"$",
"this",
"->",
"firstRoundGroupSize",
"(",
")",
";",
"// Get the size of group... | Calculate the Byes needed to fill the Championship Tree.
@param $fighters
@return Collection | [
"Calculate",
"the",
"Byes",
"needed",
"to",
"fill",
"the",
"Championship",
"Tree",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L20-L28 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.pushGroups | protected function pushGroups($numRounds, $numFighters)
{
// TODO Here is where you should change when enable several winners for preliminary
for ($roundNumber = 2; $roundNumber <= $numRounds + 1; $roundNumber++) {
// From last match to first match
$maxMatches = ($numFighters / pow(2, $roundNumber));
for ($matchNumber = 1; $matchNumber <= $maxMatches; $matchNumber++) {
$fighters = $this->createByeGroup(2);
$group = $this->saveGroup($matchNumber, $roundNumber, null);
$this->syncGroup($group, $fighters);
}
}
// Third place Group
if ($numFighters >= $this->championship->getGroupSize() * 2) {
$fighters = $this->createByeGroup(2);
$group = $this->saveGroup($maxMatches, $numRounds, null);
$this->syncGroup($group, $fighters);
}
} | php | protected function pushGroups($numRounds, $numFighters)
{
// TODO Here is where you should change when enable several winners for preliminary
for ($roundNumber = 2; $roundNumber <= $numRounds + 1; $roundNumber++) {
// From last match to first match
$maxMatches = ($numFighters / pow(2, $roundNumber));
for ($matchNumber = 1; $matchNumber <= $maxMatches; $matchNumber++) {
$fighters = $this->createByeGroup(2);
$group = $this->saveGroup($matchNumber, $roundNumber, null);
$this->syncGroup($group, $fighters);
}
}
// Third place Group
if ($numFighters >= $this->championship->getGroupSize() * 2) {
$fighters = $this->createByeGroup(2);
$group = $this->saveGroup($maxMatches, $numRounds, null);
$this->syncGroup($group, $fighters);
}
} | [
"protected",
"function",
"pushGroups",
"(",
"$",
"numRounds",
",",
"$",
"numFighters",
")",
"{",
"// TODO Here is where you should change when enable several winners for preliminary",
"for",
"(",
"$",
"roundNumber",
"=",
"2",
";",
"$",
"roundNumber",
"<=",
"$",
"numRoun... | Save Groups with their parent info.
@param int $numRounds
@param int $numFighters | [
"Save",
"Groups",
"with",
"their",
"parent",
"info",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L36-L57 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.pushEmptyGroupsToTree | protected function pushEmptyGroupsToTree($numFighters)
{
if ($this->championship->hasPreliminary()) {
/* Should add * prelimWinner but it add complexity about parent / children in tree
*/
$numFightersElim = $numFighters / $this->settings->preliminaryGroupSize * 2;
// We calculate how much rounds we will have
$numRounds = intval(log($numFightersElim, 2)); // 3 rounds, but begining from round 2 ( ie => 4)
return $this->pushGroups($numRounds, $numFightersElim);
}
// We calculate how much rounds we will have
$numRounds = $this->getNumRounds($numFighters);
return $this->pushGroups($numRounds, $numFighters);
} | php | protected function pushEmptyGroupsToTree($numFighters)
{
if ($this->championship->hasPreliminary()) {
/* Should add * prelimWinner but it add complexity about parent / children in tree
*/
$numFightersElim = $numFighters / $this->settings->preliminaryGroupSize * 2;
// We calculate how much rounds we will have
$numRounds = intval(log($numFightersElim, 2)); // 3 rounds, but begining from round 2 ( ie => 4)
return $this->pushGroups($numRounds, $numFightersElim);
}
// We calculate how much rounds we will have
$numRounds = $this->getNumRounds($numFighters);
return $this->pushGroups($numRounds, $numFighters);
} | [
"protected",
"function",
"pushEmptyGroupsToTree",
"(",
"$",
"numFighters",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"championship",
"->",
"hasPreliminary",
"(",
")",
")",
"{",
"/* Should add * prelimWinner but it add complexity about parent / children in tree\n */",... | Create empty groups after round 1.
@param $numFighters | [
"Create",
"empty",
"groups",
"after",
"round",
"1",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L64-L78 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.chunk | protected function chunk(Collection $fightersByEntity)
{
//TODO Should Pull down to know if team or competitor
if ($this->championship->hasPreliminary()) {
return (new PlayOffCompetitorTreeGen($this->championship, null))->chunk($fightersByEntity);
}
$fightersGroup = $fightersByEntity->chunk(2);
return $fightersGroup;
} | php | protected function chunk(Collection $fightersByEntity)
{
//TODO Should Pull down to know if team or competitor
if ($this->championship->hasPreliminary()) {
return (new PlayOffCompetitorTreeGen($this->championship, null))->chunk($fightersByEntity);
}
$fightersGroup = $fightersByEntity->chunk(2);
return $fightersGroup;
} | [
"protected",
"function",
"chunk",
"(",
"Collection",
"$",
"fightersByEntity",
")",
"{",
"//TODO Should Pull down to know if team or competitor",
"if",
"(",
"$",
"this",
"->",
"championship",
"->",
"hasPreliminary",
"(",
")",
")",
"{",
"return",
"(",
"new",
"PlayOffC... | Chunk Fighters into groups for fighting, and optionnaly shuffle.
@param $fightersByEntity
@return Collection|null | [
"Chunk",
"Fighters",
"into",
"groups",
"for",
"fighting",
"and",
"optionnaly",
"shuffle",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L87-L95 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.generateFights | protected function generateFights()
{
// First Round Fights
$settings = $this->settings;
$initialRound = 1;
// Very specific case to common case : Preliminary with 3 fighters
if ($this->championship->hasPreliminary() && $settings->preliminaryGroupSize == 3) {
// First we make all first fights of all groups
// Then we make all second fights of all groups
// Then we make all third fights of all groups
$groups = $this->championship->groupsByRound(1)->get();
foreach ($groups as $numGroup => $group) {
for ($numFight = 1; $numFight <= $settings->preliminaryGroupSize; $numFight++) {
$fight = new PreliminaryFight();
$order = $numGroup * $settings->preliminaryGroupSize + $numFight;
$fight->saveFight2($group, $numFight, $order);
}
}
$initialRound++;
}
// Save Next rounds
$fight = new SingleEliminationFight();
$fight->saveFights($this->championship, $initialRound);
} | php | protected function generateFights()
{
// First Round Fights
$settings = $this->settings;
$initialRound = 1;
// Very specific case to common case : Preliminary with 3 fighters
if ($this->championship->hasPreliminary() && $settings->preliminaryGroupSize == 3) {
// First we make all first fights of all groups
// Then we make all second fights of all groups
// Then we make all third fights of all groups
$groups = $this->championship->groupsByRound(1)->get();
foreach ($groups as $numGroup => $group) {
for ($numFight = 1; $numFight <= $settings->preliminaryGroupSize; $numFight++) {
$fight = new PreliminaryFight();
$order = $numGroup * $settings->preliminaryGroupSize + $numFight;
$fight->saveFight2($group, $numFight, $order);
}
}
$initialRound++;
}
// Save Next rounds
$fight = new SingleEliminationFight();
$fight->saveFights($this->championship, $initialRound);
} | [
"protected",
"function",
"generateFights",
"(",
")",
"{",
"// First Round Fights",
"$",
"settings",
"=",
"$",
"this",
"->",
"settings",
";",
"$",
"initialRound",
"=",
"1",
";",
"// Very specific case to common case : Preliminary with 3 fighters",
"if",
"(",
"$",
"thi... | Generate First Round Fights. | [
"Generate",
"First",
"Round",
"Fights",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L100-L123 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.generateAllTrees | protected function generateAllTrees()
{
$this->minFightersCheck(); // Check there is enough fighters to generate trees
$usersByArea = $this->getFightersByArea(); // Get fighters by area (reparted by entities and filled with byes)
$this->generateGroupsForRound($usersByArea, 1); // Generate all groups for round 1
$numFighters = count($usersByArea->collapse());
$this->pushEmptyGroupsToTree($numFighters); // Fill tree with empty groups
$this->addParentToChildren($numFighters); // Build the entire tree and fill the next rounds if possible
} | php | protected function generateAllTrees()
{
$this->minFightersCheck(); // Check there is enough fighters to generate trees
$usersByArea = $this->getFightersByArea(); // Get fighters by area (reparted by entities and filled with byes)
$this->generateGroupsForRound($usersByArea, 1); // Generate all groups for round 1
$numFighters = count($usersByArea->collapse());
$this->pushEmptyGroupsToTree($numFighters); // Fill tree with empty groups
$this->addParentToChildren($numFighters); // Build the entire tree and fill the next rounds if possible
} | [
"protected",
"function",
"generateAllTrees",
"(",
")",
"{",
"$",
"this",
"->",
"minFightersCheck",
"(",
")",
";",
"// Check there is enough fighters to generate trees",
"$",
"usersByArea",
"=",
"$",
"this",
"->",
"getFightersByArea",
"(",
")",
";",
"// Get fighters by... | Generate all the groups, and assign figthers to group
@throws TreeGenerationException | [
"Generate",
"all",
"the",
"groups",
"and",
"assign",
"figthers",
"to",
"group"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L153-L161 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.minFightersCheck | private function minFightersCheck()
{
$fighters = $this->getFighters();
$areas = $this->settings->fightingAreas;
$fighterType = $this->championship->category->isTeam
? trans_choice('laravel-tournaments::core.team', 2)
: trans_choice('laravel-tournaments::core.competitor', 2);
$minFighterCount = $fighters->count() / $areas;
if ($this->settings->hasPreliminary && $fighters->count() / ($this->settings->preliminaryGroupSize * $areas) < 1) {
throw new TreeGenerationException(trans('laravel-tournaments::core.min_competitor_required', [
'number' => $this->settings->preliminaryGroupSize * $areas,
'fighter_type' => $fighterType,
]), 422);
}
if ($minFighterCount < ChampionshipSettings::MIN_COMPETITORS_BY_AREA) {
throw new TreeGenerationException(trans('laravel-tournaments::core.min_competitor_required', [
'number' => ChampionshipSettings::MIN_COMPETITORS_BY_AREA,
'fighter_type' => $fighterType,
]), 422);
}
} | php | private function minFightersCheck()
{
$fighters = $this->getFighters();
$areas = $this->settings->fightingAreas;
$fighterType = $this->championship->category->isTeam
? trans_choice('laravel-tournaments::core.team', 2)
: trans_choice('laravel-tournaments::core.competitor', 2);
$minFighterCount = $fighters->count() / $areas;
if ($this->settings->hasPreliminary && $fighters->count() / ($this->settings->preliminaryGroupSize * $areas) < 1) {
throw new TreeGenerationException(trans('laravel-tournaments::core.min_competitor_required', [
'number' => $this->settings->preliminaryGroupSize * $areas,
'fighter_type' => $fighterType,
]), 422);
}
if ($minFighterCount < ChampionshipSettings::MIN_COMPETITORS_BY_AREA) {
throw new TreeGenerationException(trans('laravel-tournaments::core.min_competitor_required', [
'number' => ChampionshipSettings::MIN_COMPETITORS_BY_AREA,
'fighter_type' => $fighterType,
]), 422);
}
} | [
"private",
"function",
"minFightersCheck",
"(",
")",
"{",
"$",
"fighters",
"=",
"$",
"this",
"->",
"getFighters",
"(",
")",
";",
"$",
"areas",
"=",
"$",
"this",
"->",
"settings",
"->",
"fightingAreas",
";",
"$",
"fighterType",
"=",
"$",
"this",
"->",
"... | Check if there is enough fighters, throw exception otherwise.
@throws TreeGenerationException | [
"Check",
"if",
"there",
"is",
"enough",
"fighters",
"throw",
"exception",
"otherwise",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L188-L211 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.insertByes | private function insertByes(Collection $fighters, $numByeTotal)
{
$bye = $this->createByeFighter();
$groupSize = $this->firstRoundGroupSize();
$frequency = $groupSize != 0
? (int)floor(count($fighters) / $groupSize / $groupSize)
: -1;
if ($frequency < $groupSize) {
$frequency = $groupSize;
}
$newFighters = new Collection();
$count = 0;
$byeCount = 0;
foreach ($fighters as $fighter) {
// Each $frequency(3) try to insert $groupSize byes (3)
// Not the first iteration, and at the good frequency, and with $numByeTotal as limit
if ($this->shouldInsertBye($frequency, $count, $byeCount, $numByeTotal)) { //
for ($i = 0; $i < $groupSize; $i++) {
if ($byeCount < $numByeTotal) {
$newFighters->push($bye);
$byeCount++;
}
}
}
$newFighters->push($fighter);
$count++;
}
return $newFighters;
} | php | private function insertByes(Collection $fighters, $numByeTotal)
{
$bye = $this->createByeFighter();
$groupSize = $this->firstRoundGroupSize();
$frequency = $groupSize != 0
? (int)floor(count($fighters) / $groupSize / $groupSize)
: -1;
if ($frequency < $groupSize) {
$frequency = $groupSize;
}
$newFighters = new Collection();
$count = 0;
$byeCount = 0;
foreach ($fighters as $fighter) {
// Each $frequency(3) try to insert $groupSize byes (3)
// Not the first iteration, and at the good frequency, and with $numByeTotal as limit
if ($this->shouldInsertBye($frequency, $count, $byeCount, $numByeTotal)) { //
for ($i = 0; $i < $groupSize; $i++) {
if ($byeCount < $numByeTotal) {
$newFighters->push($bye);
$byeCount++;
}
}
}
$newFighters->push($fighter);
$count++;
}
return $newFighters;
} | [
"private",
"function",
"insertByes",
"(",
"Collection",
"$",
"fighters",
",",
"$",
"numByeTotal",
")",
"{",
"$",
"bye",
"=",
"$",
"this",
"->",
"createByeFighter",
"(",
")",
";",
"$",
"groupSize",
"=",
"$",
"this",
"->",
"firstRoundGroupSize",
"(",
")",
... | Insert byes group alternated with full groups.
@param Collection $fighters - List of fighters
@param integer $numByeTotal - Quantity of byes to insert
@return Collection - Full list of fighters including byes | [
"Insert",
"byes",
"group",
"alternated",
"with",
"full",
"groups",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L220-L249 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.shouldInsertBye | private
function shouldInsertBye($frequency, $count, $byeCount, $numByeTotal): bool
{
return $count != 0 && $count % $frequency == 0 && $byeCount < $numByeTotal;
} | php | private
function shouldInsertBye($frequency, $count, $byeCount, $numByeTotal): bool
{
return $count != 0 && $count % $frequency == 0 && $byeCount < $numByeTotal;
} | [
"private",
"function",
"shouldInsertBye",
"(",
"$",
"frequency",
",",
"$",
"count",
",",
"$",
"byeCount",
",",
"$",
"numByeTotal",
")",
":",
"bool",
"{",
"return",
"$",
"count",
"!=",
"0",
"&&",
"$",
"count",
"%",
"$",
"frequency",
"==",
"0",
"&&",
"... | @param $frequency
@param $groupSize
@param $count
@param $byeCount
@return bool | [
"@param",
"$frequency",
"@param",
"$groupSize",
"@param",
"$count",
"@param",
"$byeCount"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L260-L263 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.adjustFightersGroupWithByes | public function adjustFightersGroupWithByes($fighters, $fighterGroups): Collection
{
$tmpFighterGroups = clone $fighterGroups;
$numBye = count($this->getByeGroup($fighters));
// Get biggest competitor's group
$max = $this->getMaxFightersByEntity($tmpFighterGroups);
// We put them so that we can mix them up and they don't fight with another competitor of his entity.
$fighters = $this->repart($fighterGroups, $max);
if (!app()->runningUnitTests()) {
$fighters = $fighters->shuffle();
}
// Insert byes to fill the tree.
// Strategy: first, one group full, one group empty with byes, then groups of 2 fighters
$fighters = $this->insertByes($fighters, $numBye);
return $fighters;
} | php | public function adjustFightersGroupWithByes($fighters, $fighterGroups): Collection
{
$tmpFighterGroups = clone $fighterGroups;
$numBye = count($this->getByeGroup($fighters));
// Get biggest competitor's group
$max = $this->getMaxFightersByEntity($tmpFighterGroups);
// We put them so that we can mix them up and they don't fight with another competitor of his entity.
$fighters = $this->repart($fighterGroups, $max);
if (!app()->runningUnitTests()) {
$fighters = $fighters->shuffle();
}
// Insert byes to fill the tree.
// Strategy: first, one group full, one group empty with byes, then groups of 2 fighters
$fighters = $this->insertByes($fighters, $numBye);
return $fighters;
} | [
"public",
"function",
"adjustFightersGroupWithByes",
"(",
"$",
"fighters",
",",
"$",
"fighterGroups",
")",
":",
"Collection",
"{",
"$",
"tmpFighterGroups",
"=",
"clone",
"$",
"fighterGroups",
";",
"$",
"numBye",
"=",
"count",
"(",
"$",
"this",
"->",
"getByeGro... | Method that fills fighters with Bye Groups at the end
@param $fighters
@param Collection $fighterGroups
@return Collection | [
"Method",
"that",
"fills",
"fighters",
"with",
"Bye",
"Groups",
"at",
"the",
"end",
"@param",
"$fighters",
"@param",
"Collection",
"$fighterGroups"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L273-L291 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.getMaxFightersByEntity | private
function getMaxFightersByEntity($userGroups): int
{
return $userGroups
->sortByDesc(function ($group) {
return $group->count();
})
->first()
->count();
} | php | private
function getMaxFightersByEntity($userGroups): int
{
return $userGroups
->sortByDesc(function ($group) {
return $group->count();
})
->first()
->count();
} | [
"private",
"function",
"getMaxFightersByEntity",
"(",
"$",
"userGroups",
")",
":",
"int",
"{",
"return",
"$",
"userGroups",
"->",
"sortByDesc",
"(",
"function",
"(",
"$",
"group",
")",
"{",
"return",
"$",
"group",
"->",
"count",
"(",
")",
";",
"}",
")",
... | Get the biggest entity group.
@param $userGroups
@return int | [
"Get",
"the",
"biggest",
"entity",
"group",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L301-L309 |
xoco70/laravel-tournaments | src/TreeGen/SingleEliminationTreeGen.php | SingleEliminationTreeGen.repart | private
function repart($fighterGroups, $max)
{
$fighters = new Collection();
for ($i = 0; $i < $max; $i++) {
foreach ($fighterGroups as $fighterGroup) {
$fighter = $fighterGroup->values()->get($i);
if ($fighter != null) {
$fighters->push($fighter);
}
}
}
return $fighters;
} | php | private
function repart($fighterGroups, $max)
{
$fighters = new Collection();
for ($i = 0; $i < $max; $i++) {
foreach ($fighterGroups as $fighterGroup) {
$fighter = $fighterGroup->values()->get($i);
if ($fighter != null) {
$fighters->push($fighter);
}
}
}
return $fighters;
} | [
"private",
"function",
"repart",
"(",
"$",
"fighterGroups",
",",
"$",
"max",
")",
"{",
"$",
"fighters",
"=",
"new",
"Collection",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"max",
";",
"$",
"i",
"++",
")",
"{",
"f... | Repart BYE in the tree,.
@param $fighterGroups
@param int $max
@return Collection | [
"Repart",
"BYE",
"in",
"the",
"tree",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/SingleEliminationTreeGen.php#L320-L332 |
xoco70/laravel-tournaments | database/migrations/2014_12_03_230347_create_lt_Category_table.php | CreateLtCategoryTable.up | public function up()
{
Schema::create('category', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('gender')->nullable();
$table->integer('isTeam')->unsigned()->default(0);
$table->integer('ageCategory')->unsigned()->default(0); // 0 = none, 1 = child, 2= teenager, 3 = adult, 4 = master
$table->integer('ageMin')->unsigned()->default(0);
$table->integer('ageMax')->unsigned()->default(0);
$table->integer('gradeCategory')->unsigned()->default(0);
$table->integer('gradeMin')->unsigned()->default(0);
$table->integer('gradeMax')->unsigned()->default(0);
$table->unique(['name', 'gender', 'isTeam', 'ageCategory', 'ageMin', 'ageMax', 'gradeCategory', 'gradeMin', 'gradeMax'], 'category_fields_unique');
$table->timestamps();
$table->engine = 'InnoDB';
});
Schema::create('championship', function (Blueprint $table) {
$table->increments('id');
$table->integer('tournament_id')->unsigned()->index();
$table->integer('category_id')->unsigned()->index();
$table->unique(['tournament_id', 'category_id']);
$table->foreign('tournament_id')
->references('id')
->on('tournament')
->onUpdate('cascade')
->onDelete('cascade');
$table->foreign('category_id')
->references('id')
->on('category')
->onDelete('cascade');
$table->timestamps();
$table->softDeletes();
$table->engine = 'InnoDB';
});
Schema::create('competitor', function (Blueprint $table) {
$table->increments('id');
$table->integer('short_id')->unsigned()->nullable();
$table->integer('championship_id')->unsigned()->index();
$table->foreign('championship_id')
->references('id')
->on('championship')
->onUpdate('cascade')
->onDelete('cascade');
$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')
->references('id')
->on('users')
->onUpdate('cascade')
->onDelete('cascade');
$table->unique(['championship_id', 'short_id']);
$table->unique(['championship_id', 'user_id']);
$table->boolean('confirmed');
$table->timestamps();
$table->softDeletes();
$table->engine = 'InnoDB';
});
} | php | public function up()
{
Schema::create('category', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('gender')->nullable();
$table->integer('isTeam')->unsigned()->default(0);
$table->integer('ageCategory')->unsigned()->default(0); // 0 = none, 1 = child, 2= teenager, 3 = adult, 4 = master
$table->integer('ageMin')->unsigned()->default(0);
$table->integer('ageMax')->unsigned()->default(0);
$table->integer('gradeCategory')->unsigned()->default(0);
$table->integer('gradeMin')->unsigned()->default(0);
$table->integer('gradeMax')->unsigned()->default(0);
$table->unique(['name', 'gender', 'isTeam', 'ageCategory', 'ageMin', 'ageMax', 'gradeCategory', 'gradeMin', 'gradeMax'], 'category_fields_unique');
$table->timestamps();
$table->engine = 'InnoDB';
});
Schema::create('championship', function (Blueprint $table) {
$table->increments('id');
$table->integer('tournament_id')->unsigned()->index();
$table->integer('category_id')->unsigned()->index();
$table->unique(['tournament_id', 'category_id']);
$table->foreign('tournament_id')
->references('id')
->on('tournament')
->onUpdate('cascade')
->onDelete('cascade');
$table->foreign('category_id')
->references('id')
->on('category')
->onDelete('cascade');
$table->timestamps();
$table->softDeletes();
$table->engine = 'InnoDB';
});
Schema::create('competitor', function (Blueprint $table) {
$table->increments('id');
$table->integer('short_id')->unsigned()->nullable();
$table->integer('championship_id')->unsigned()->index();
$table->foreign('championship_id')
->references('id')
->on('championship')
->onUpdate('cascade')
->onDelete('cascade');
$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')
->references('id')
->on('users')
->onUpdate('cascade')
->onDelete('cascade');
$table->unique(['championship_id', 'short_id']);
$table->unique(['championship_id', 'user_id']);
$table->boolean('confirmed');
$table->timestamps();
$table->softDeletes();
$table->engine = 'InnoDB';
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'category'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'name'",
"... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/migrations/2014_12_03_230347_create_lt_Category_table.php#L14-L80 |
xoco70/laravel-tournaments | database/migrations/2014_12_03_230347_create_lt_Category_table.php | CreateLtCategoryTable.down | public function down()
{
DBHelpers::setFKCheckOff();
Schema::dropIfExists('competitor');
Schema::dropIfExists('championship');
Schema::dropIfExists('category');
DBHelpers::setFKCheckOn();
} | php | public function down()
{
DBHelpers::setFKCheckOff();
Schema::dropIfExists('competitor');
Schema::dropIfExists('championship');
Schema::dropIfExists('category');
DBHelpers::setFKCheckOn();
} | [
"public",
"function",
"down",
"(",
")",
"{",
"DBHelpers",
"::",
"setFKCheckOff",
"(",
")",
";",
"Schema",
"::",
"dropIfExists",
"(",
"'competitor'",
")",
";",
"Schema",
"::",
"dropIfExists",
"(",
"'championship'",
")",
";",
"Schema",
"::",
"dropIfExists",
"(... | Reverse the migrations.
@return void | [
"Reverse",
"the",
"migrations",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/migrations/2014_12_03_230347_create_lt_Category_table.php#L87-L94 |
xoco70/laravel-tournaments | src/Models/PreliminaryFight.php | PreliminaryFight.saveFights | public static function saveFights(Collection $groups, $numGroup = 1)
{
$competitor1 = $competitor2 = null;
$order = 1;
foreach ($groups as $group) {
$fighters = $group->getFightersWithBye();
$fighter1 = $fighters->get(0);
$fighter2 = $fighters->get(1);
$fighter3 = $fighters->get(2);
switch ($numGroup) {
case 1:
$competitor1 = $fighter1;
$competitor2 = $fighter2;
break;
case 2:
$competitor1 = $fighter2;
$competitor2 = $fighter3;
break;
case 3:
$competitor1 = $fighter3;
$competitor2 = $fighter1;
break;
}
$order = self::saveFight($group, $competitor1, $competitor2, $order);
}
} | php | public static function saveFights(Collection $groups, $numGroup = 1)
{
$competitor1 = $competitor2 = null;
$order = 1;
foreach ($groups as $group) {
$fighters = $group->getFightersWithBye();
$fighter1 = $fighters->get(0);
$fighter2 = $fighters->get(1);
$fighter3 = $fighters->get(2);
switch ($numGroup) {
case 1:
$competitor1 = $fighter1;
$competitor2 = $fighter2;
break;
case 2:
$competitor1 = $fighter2;
$competitor2 = $fighter3;
break;
case 3:
$competitor1 = $fighter3;
$competitor2 = $fighter1;
break;
}
$order = self::saveFight($group, $competitor1, $competitor2, $order);
}
} | [
"public",
"static",
"function",
"saveFights",
"(",
"Collection",
"$",
"groups",
",",
"$",
"numGroup",
"=",
"1",
")",
"{",
"$",
"competitor1",
"=",
"$",
"competitor2",
"=",
"null",
";",
"$",
"order",
"=",
"1",
";",
"foreach",
"(",
"$",
"groups",
"as",
... | Save all fights.
@param Collection $groups
@param int $numGroup | [
"Save",
"all",
"fights",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/PreliminaryFight.php#L27-L55 |
xoco70/laravel-tournaments | src/Models/PreliminaryFight.php | PreliminaryFight.saveFight2 | public static function saveFight2(FightersGroup $group, $numGroup = 1, $order = 1) // TODO Rename it, bad name
{
$competitor1 = $competitor2 = null;
$fighters = $group->getFightersWithBye();
$fighter1 = $fighters->get(0);
$fighter2 = $fighters->get(1);
$fighter3 = $fighters->get(2);
switch ($numGroup) {
case 1:
$competitor1 = $fighter1;
$competitor2 = $fighter2;
break;
case 2:
$competitor1 = $fighter2;
$competitor2 = $fighter3;
break;
case 3:
$competitor1 = $fighter3;
$competitor2 = $fighter1;
break;
}
self::saveFight($group, $competitor1, $competitor2, $order);
} | php | public static function saveFight2(FightersGroup $group, $numGroup = 1, $order = 1) // TODO Rename it, bad name
{
$competitor1 = $competitor2 = null;
$fighters = $group->getFightersWithBye();
$fighter1 = $fighters->get(0);
$fighter2 = $fighters->get(1);
$fighter3 = $fighters->get(2);
switch ($numGroup) {
case 1:
$competitor1 = $fighter1;
$competitor2 = $fighter2;
break;
case 2:
$competitor1 = $fighter2;
$competitor2 = $fighter3;
break;
case 3:
$competitor1 = $fighter3;
$competitor2 = $fighter1;
break;
}
self::saveFight($group, $competitor1, $competitor2, $order);
} | [
"public",
"static",
"function",
"saveFight2",
"(",
"FightersGroup",
"$",
"group",
",",
"$",
"numGroup",
"=",
"1",
",",
"$",
"order",
"=",
"1",
")",
"// TODO Rename it, bad name",
"{",
"$",
"competitor1",
"=",
"$",
"competitor2",
"=",
"null",
";",
"$",
"fig... | Save a Fight.
@param Collection $group
@param int $numGroup
@param int $order | [
"Save",
"a",
"Fight",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/PreliminaryFight.php#L65-L89 |
xoco70/laravel-tournaments | src/Models/PreliminaryFight.php | PreliminaryFight.saveFight | private static function saveFight($group, $competitor1, $competitor2, $order)
{
$fight = new Fight();
$fight->fighters_group_id = $group->id;
$fight->c1 = optional($competitor1)->id;
$fight->c2 = optional($competitor2)->id;
$fight->short_id = $order++;
$fight->area = $group->area;
$fight->save();
return $order;
} | php | private static function saveFight($group, $competitor1, $competitor2, $order)
{
$fight = new Fight();
$fight->fighters_group_id = $group->id;
$fight->c1 = optional($competitor1)->id;
$fight->c2 = optional($competitor2)->id;
$fight->short_id = $order++;
$fight->area = $group->area;
$fight->save();
return $order;
} | [
"private",
"static",
"function",
"saveFight",
"(",
"$",
"group",
",",
"$",
"competitor1",
",",
"$",
"competitor2",
",",
"$",
"order",
")",
"{",
"$",
"fight",
"=",
"new",
"Fight",
"(",
")",
";",
"$",
"fight",
"->",
"fighters_group_id",
"=",
"$",
"group"... | @param $group
@param $competitor1
@param $competitor2
@param $order
@return mixed | [
"@param",
"$group",
"@param",
"$competitor1",
"@param",
"$competitor2",
"@param",
"$order"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/PreliminaryFight.php#L99-L109 |
xoco70/laravel-tournaments | database/migrations/2014_12_23_025812_create_lt_ChampionshipSettings_table.php | CreateLtChampionshipSettingsTable.up | public function up()
{
Schema::create('championship_settings', function (Blueprint $table) {
$table->increments('id');
$table->string('alias')->nullable();
$table->integer('championship_id')->unsigned()->unique();
$table->foreign('championship_id')
->references('id')
->onUpdate('cascade')
->on('championship')
->onDelete('cascade');
// Category Section
$table->tinyInteger('treeType')->default(ChampionshipSettings::SINGLE_ELIMINATION);
$table->tinyInteger('fightingAreas')->unsigned()->nullable()->default(1);
$table->integer('limitByEntity')->unsigned()->nullable();
// Preliminary
$table->boolean('hasPreliminary')->default(1);
$table->boolean('preliminaryGroupSize')->default(3);
$table->tinyInteger('preliminaryWinner')->default(1); // Number of Competitors that go to next level
$table->string('preliminaryDuration')->nullable(); // Match Duration in preliminary heat
// Team
$table->tinyInteger('teamSize')->nullable(); // Default is null
$table->tinyInteger('teamReserve')->nullable(); // Default is null
// Seed
$table->smallInteger('seedQuantity')->nullable(); // Competitors seeded in tree
//TODO This should go in another table that is not for tree construction but for rules
// Rules
$table->boolean('hasEncho')->default(1);
$table->tinyInteger('enchoQty')->default(0);
$table->string('enchoDuration')->nullable();
$table->boolean('hasHantei')->default(false);
$table->smallInteger('cost')->nullable(); // Cost of competition
$table->string('fightDuration')->nullable(); // Can't apply default because text
$table->smallInteger('hanteiLimit')->default(0); // 0 = none, 1 = 1/8, 2 = 1/4, 3=1/2, 4 = FINAL
$table->smallInteger('enchoGoldPoint')->default(0); // 0 = none, 1 = 1/8, 2 = 1/4, 3=1/2, 4 = FINAL
$table->timestamps();
$table->softDeletes();
$table->engine = 'InnoDB';
});
} | php | public function up()
{
Schema::create('championship_settings', function (Blueprint $table) {
$table->increments('id');
$table->string('alias')->nullable();
$table->integer('championship_id')->unsigned()->unique();
$table->foreign('championship_id')
->references('id')
->onUpdate('cascade')
->on('championship')
->onDelete('cascade');
// Category Section
$table->tinyInteger('treeType')->default(ChampionshipSettings::SINGLE_ELIMINATION);
$table->tinyInteger('fightingAreas')->unsigned()->nullable()->default(1);
$table->integer('limitByEntity')->unsigned()->nullable();
// Preliminary
$table->boolean('hasPreliminary')->default(1);
$table->boolean('preliminaryGroupSize')->default(3);
$table->tinyInteger('preliminaryWinner')->default(1); // Number of Competitors that go to next level
$table->string('preliminaryDuration')->nullable(); // Match Duration in preliminary heat
// Team
$table->tinyInteger('teamSize')->nullable(); // Default is null
$table->tinyInteger('teamReserve')->nullable(); // Default is null
// Seed
$table->smallInteger('seedQuantity')->nullable(); // Competitors seeded in tree
//TODO This should go in another table that is not for tree construction but for rules
// Rules
$table->boolean('hasEncho')->default(1);
$table->tinyInteger('enchoQty')->default(0);
$table->string('enchoDuration')->nullable();
$table->boolean('hasHantei')->default(false);
$table->smallInteger('cost')->nullable(); // Cost of competition
$table->string('fightDuration')->nullable(); // Can't apply default because text
$table->smallInteger('hanteiLimit')->default(0); // 0 = none, 1 = 1/8, 2 = 1/4, 3=1/2, 4 = FINAL
$table->smallInteger('enchoGoldPoint')->default(0); // 0 = none, 1 = 1/8, 2 = 1/4, 3=1/2, 4 = FINAL
$table->timestamps();
$table->softDeletes();
$table->engine = 'InnoDB';
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'championship_settings'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"string",
"(",
... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/migrations/2014_12_23_025812_create_lt_ChampionshipSettings_table.php#L15-L61 |
xoco70/laravel-tournaments | database/seeds/CompetitorSeeder.php | CompetitorSeeder.run | public function run()
{
$this->command->info('Competitors seeding!');
$userClass = config('laravel-tournaments.user.model');
$championship = Championship::where('tournament_id', 1)->first();
$users[] = factory($userClass)->create(['name' => 't1']);
$users[] = factory($userClass)->create(['name' => 't2']);
$users[] = factory($userClass)->create(['name' => 't3']);
$users[] = factory($userClass)->create(['name' => 't4']);
$users[] = factory($userClass)->create(['name' => 't5']);
foreach ($users as $user) {
factory(Competitor::class)->create([
'championship_id' => $championship->id,
'user_id' => $user->id,
'confirmed' => 1,
]);
}
} | php | public function run()
{
$this->command->info('Competitors seeding!');
$userClass = config('laravel-tournaments.user.model');
$championship = Championship::where('tournament_id', 1)->first();
$users[] = factory($userClass)->create(['name' => 't1']);
$users[] = factory($userClass)->create(['name' => 't2']);
$users[] = factory($userClass)->create(['name' => 't3']);
$users[] = factory($userClass)->create(['name' => 't4']);
$users[] = factory($userClass)->create(['name' => 't5']);
foreach ($users as $user) {
factory(Competitor::class)->create([
'championship_id' => $championship->id,
'user_id' => $user->id,
'confirmed' => 1,
]);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"info",
"(",
"'Competitors seeding!'",
")",
";",
"$",
"userClass",
"=",
"config",
"(",
"'laravel-tournaments.user.model'",
")",
";",
"$",
"championship",
"=",
"Championship",
"::",... | Run the database seeds.
@return void | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/seeds/CompetitorSeeder.php#L14-L33 |
xoco70/laravel-tournaments | database/seeds/TournamentSeeder.php | TournamentSeeder.run | public function run()
{
$venues = Venue::all()->pluck('id')->toArray();
Tournament::truncate();
$faker = Faker\Factory::create();
$dateIni = $faker->dateTimeBetween('now', '+2 weeks')->format('Y-m-d');
Tournament::create([
'id' => 1,
'slug' => md5(uniqid(rand(), true)),
'user_id' => 1,
'name' => 'Test Tournament',
'dateIni' => $dateIni,
'dateFin' => $dateIni,
'registerDateLimit' => $dateIni,
'sport' => 1,
'type' => 0,
'level_id' => 7,
'venue_id' => $faker->randomElement($venues),
]);
Championship::truncate();
factory(Championship::class)->create(['tournament_id' => 1, 'category_id' => 1]);
factory(Championship::class)->create(['tournament_id' => 1, 'category_id' => 2]);
} | php | public function run()
{
$venues = Venue::all()->pluck('id')->toArray();
Tournament::truncate();
$faker = Faker\Factory::create();
$dateIni = $faker->dateTimeBetween('now', '+2 weeks')->format('Y-m-d');
Tournament::create([
'id' => 1,
'slug' => md5(uniqid(rand(), true)),
'user_id' => 1,
'name' => 'Test Tournament',
'dateIni' => $dateIni,
'dateFin' => $dateIni,
'registerDateLimit' => $dateIni,
'sport' => 1,
'type' => 0,
'level_id' => 7,
'venue_id' => $faker->randomElement($venues),
]);
Championship::truncate();
factory(Championship::class)->create(['tournament_id' => 1, 'category_id' => 1]);
factory(Championship::class)->create(['tournament_id' => 1, 'category_id' => 2]);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"venues",
"=",
"Venue",
"::",
"all",
"(",
")",
"->",
"pluck",
"(",
"'id'",
")",
"->",
"toArray",
"(",
")",
";",
"Tournament",
"::",
"truncate",
"(",
")",
";",
"$",
"faker",
"=",
"Faker",
"\\",
"Fac... | Run the database seeds.
@return void | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/seeds/TournamentSeeder.php#L15-L41 |
xoco70/laravel-tournaments | database/seeds/CategorySeeder.php | CategorySeeder.run | public function run()
{
Category::truncate();
// Presets
Category::create(['name' => 'categories.junior', 'gender' => 'X', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '13', 'ageMax' => '15', 'gradeCategory' => 0]);
Category::create(['name' => 'categories.junior_team', 'gender' => 'X', 'isTeam' => 1, 'ageCategory' => 5, 'ageMin' => '13', 'ageMax' => '15', 'gradeCategory' => 0]);
Category::create(['name' => 'categories.men_single', 'gender' => 'M', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.men_team', 'gender' => 'M', 'isTeam' => 1, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.ladies_single', 'gender' => 'F', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.ladies_team', 'gender' => 'F', 'isTeam' => 1, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.master', 'gender' => 'F', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '50', 'gradeMin' => '8']); // 8 = Shodan
// Junior Team : 3 - 5
// Junior Individual,
// Senior Male Team : Team 5 - 7
// Senior Female Team : Team 5 - 7
// Senior Female Individual,
// Senior Male Individual
} | php | public function run()
{
Category::truncate();
// Presets
Category::create(['name' => 'categories.junior', 'gender' => 'X', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '13', 'ageMax' => '15', 'gradeCategory' => 0]);
Category::create(['name' => 'categories.junior_team', 'gender' => 'X', 'isTeam' => 1, 'ageCategory' => 5, 'ageMin' => '13', 'ageMax' => '15', 'gradeCategory' => 0]);
Category::create(['name' => 'categories.men_single', 'gender' => 'M', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.men_team', 'gender' => 'M', 'isTeam' => 1, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.ladies_single', 'gender' => 'F', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.ladies_team', 'gender' => 'F', 'isTeam' => 1, 'ageCategory' => 5, 'ageMin' => '18']);
Category::create(['name' => 'categories.master', 'gender' => 'F', 'isTeam' => 0, 'ageCategory' => 5, 'ageMin' => '50', 'gradeMin' => '8']); // 8 = Shodan
// Junior Team : 3 - 5
// Junior Individual,
// Senior Male Team : Team 5 - 7
// Senior Female Team : Team 5 - 7
// Senior Female Individual,
// Senior Male Individual
} | [
"public",
"function",
"run",
"(",
")",
"{",
"Category",
"::",
"truncate",
"(",
")",
";",
"// Presets",
"Category",
"::",
"create",
"(",
"[",
"'name'",
"=>",
"'categories.junior'",
",",
"'gender'",
"=>",
"'X'",
",",
"'isTeam'",
"=>",
"0",
",",
"'ageCategory... | Run the database seeds.
@return void | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/seeds/CategorySeeder.php#L13-L37 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.getFightersByEntity | private function getFightersByEntity($fighters): Collection
{
// Right now, we are treating users and teams as equals.
// It doesn't matter right now, because we only need name attribute which is common to both models
// $this->groupBy contains federation_id, association_id, club_id, etc.
if (($this->groupBy) != null) {
return $fighters->groupBy($this->groupBy); // Collection of Collection
}
return $fighters->chunk(1); // Collection of Collection
} | php | private function getFightersByEntity($fighters): Collection
{
// Right now, we are treating users and teams as equals.
// It doesn't matter right now, because we only need name attribute which is common to both models
// $this->groupBy contains federation_id, association_id, club_id, etc.
if (($this->groupBy) != null) {
return $fighters->groupBy($this->groupBy); // Collection of Collection
}
return $fighters->chunk(1); // Collection of Collection
} | [
"private",
"function",
"getFightersByEntity",
"(",
"$",
"fighters",
")",
":",
"Collection",
"{",
"// Right now, we are treating users and teams as equals.",
"// It doesn't matter right now, because we only need name attribute which is common to both models",
"// $this->groupBy contains feder... | Get Competitor's list ordered by entities
Countries for Internation Tournament, State for a National Tournament, etc.
@param $fighters
@return Collection | [
"Get",
"Competitor",
"s",
"list",
"ordered",
"by",
"entities",
"Countries",
"for",
"Internation",
"Tournament",
"State",
"for",
"a",
"National",
"Tournament",
"etc",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L70-L81 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.getTreeSize | protected function getTreeSize($fighterCount, $groupSize)
{
$squareMultiplied = collect([1, 2, 4, 8, 16, 32, 64])
->map(function ($item) use ($groupSize) {
return $item * $groupSize;
}); // [4, 8, 16, 32, 64,...]
foreach ($squareMultiplied as $limit) {
if ($fighterCount <= $limit) {
$treeSize = $limit;
$numAreas = $this->settings->fightingAreas;
$fighterCountPerArea = $treeSize / $numAreas;
if ($fighterCountPerArea < $groupSize) {
$treeSize = $treeSize * $numAreas;
}
return $treeSize;
}
}
return 64 * $groupSize;
} | php | protected function getTreeSize($fighterCount, $groupSize)
{
$squareMultiplied = collect([1, 2, 4, 8, 16, 32, 64])
->map(function ($item) use ($groupSize) {
return $item * $groupSize;
}); // [4, 8, 16, 32, 64,...]
foreach ($squareMultiplied as $limit) {
if ($fighterCount <= $limit) {
$treeSize = $limit;
$numAreas = $this->settings->fightingAreas;
$fighterCountPerArea = $treeSize / $numAreas;
if ($fighterCountPerArea < $groupSize) {
$treeSize = $treeSize * $numAreas;
}
return $treeSize;
}
}
return 64 * $groupSize;
} | [
"protected",
"function",
"getTreeSize",
"(",
"$",
"fighterCount",
",",
"$",
"groupSize",
")",
"{",
"$",
"squareMultiplied",
"=",
"collect",
"(",
"[",
"1",
",",
"2",
",",
"4",
",",
"8",
",",
"16",
",",
"32",
",",
"64",
"]",
")",
"->",
"map",
"(",
... | Get the size the first round will have.
@param $fighterCount
@param $groupSize
@return int | [
"Get",
"the",
"size",
"the",
"first",
"round",
"will",
"have",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L91-L112 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.saveGroup | protected function saveGroup($order, $round, $parent): FightersGroup
{
$group = new FightersGroup();
$this->championship->isSingleEliminationType()
? $group->area = $this->getNumArea($round, $order)
: $group->area = 1; // Area limited to 1 in playoff
$group->order = $order;
$group->round = $round;
$group->championship_id = $this->championship->id;
if ($parent != null) {
$group->parent_id = $parent->id;
}
$group->save();
return $group;
} | php | protected function saveGroup($order, $round, $parent): FightersGroup
{
$group = new FightersGroup();
$this->championship->isSingleEliminationType()
? $group->area = $this->getNumArea($round, $order)
: $group->area = 1; // Area limited to 1 in playoff
$group->order = $order;
$group->round = $round;
$group->championship_id = $this->championship->id;
if ($parent != null) {
$group->parent_id = $parent->id;
}
$group->save();
return $group;
} | [
"protected",
"function",
"saveGroup",
"(",
"$",
"order",
",",
"$",
"round",
",",
"$",
"parent",
")",
":",
"FightersGroup",
"{",
"$",
"group",
"=",
"new",
"FightersGroup",
"(",
")",
";",
"$",
"this",
"->",
"championship",
"->",
"isSingleEliminationType",
"(... | @param $order
@param $round
@param $parent
@return FightersGroup | [
"@param",
"$order",
"@param",
"$round",
"@param",
"$parent"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L123-L139 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.createByeGroup | public function createByeGroup($groupSize): Collection
{
$byeFighter = $this->createByeFighter();
$group = new Collection();
for ($i = 0; $i < $groupSize; $i++) {
$group->push($byeFighter);
}
return $group;
} | php | public function createByeGroup($groupSize): Collection
{
$byeFighter = $this->createByeFighter();
$group = new Collection();
for ($i = 0; $i < $groupSize; $i++) {
$group->push($byeFighter);
}
return $group;
} | [
"public",
"function",
"createByeGroup",
"(",
"$",
"groupSize",
")",
":",
"Collection",
"{",
"$",
"byeFighter",
"=",
"$",
"this",
"->",
"createByeFighter",
"(",
")",
";",
"$",
"group",
"=",
"new",
"Collection",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
... | @param int $groupSize
@return Collection | [
"@param",
"int",
"$groupSize"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L146-L155 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.getParentGroup | private function getParentGroup($matchNumber, $previousRound)
{
$parentIndex = intval(($matchNumber + 1) / 2);
$parent = $previousRound->get($parentIndex - 1);
return $parent;
} | php | private function getParentGroup($matchNumber, $previousRound)
{
$parentIndex = intval(($matchNumber + 1) / 2);
$parent = $previousRound->get($parentIndex - 1);
return $parent;
} | [
"private",
"function",
"getParentGroup",
"(",
"$",
"matchNumber",
",",
"$",
"previousRound",
")",
"{",
"$",
"parentIndex",
"=",
"intval",
"(",
"(",
"$",
"matchNumber",
"+",
"1",
")",
"/",
"2",
")",
";",
"$",
"parent",
"=",
"$",
"previousRound",
"->",
"... | Get the next group on the right ( parent ), final round being the ancestor.
@param $matchNumber
@param Collection $previousRound
@return mixed | [
"Get",
"the",
"next",
"group",
"on",
"the",
"right",
"(",
"parent",
")",
"final",
"round",
"being",
"the",
"ancestor",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L181-L187 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.getFightersByArea | protected function getFightersByArea()
{
$areas = $this->settings->fightingAreas;
$fighters = $this->getFighters(); // Get Competitor or Team Objects
$fighterByEntity = $this->getFightersByEntity($fighters); // Chunk it by entities (Fede, Assoc, Club,...)
$fightersWithBye = $this->adjustFightersGroupWithByes($fighters, $fighterByEntity); // Fill with Byes
return $fightersWithBye->chunk(count($fightersWithBye) / $areas); // Chunk user by areas
} | php | protected function getFightersByArea()
{
$areas = $this->settings->fightingAreas;
$fighters = $this->getFighters(); // Get Competitor or Team Objects
$fighterByEntity = $this->getFightersByEntity($fighters); // Chunk it by entities (Fede, Assoc, Club,...)
$fightersWithBye = $this->adjustFightersGroupWithByes($fighters, $fighterByEntity); // Fill with Byes
return $fightersWithBye->chunk(count($fightersWithBye) / $areas); // Chunk user by areas
} | [
"protected",
"function",
"getFightersByArea",
"(",
")",
"{",
"$",
"areas",
"=",
"$",
"this",
"->",
"settings",
"->",
"fightingAreas",
";",
"$",
"fighters",
"=",
"$",
"this",
"->",
"getFighters",
"(",
")",
";",
"// Get Competitor or Team Objects",
"$",
"fighter... | Group Fighters by area.
Here is where we fill with empty fighters
@throws TreeGenerationException
@return Collection | [
"Group",
"Fighters",
"by",
"area",
".",
"Here",
"is",
"where",
"we",
"fill",
"with",
"empty",
"fighters"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L197-L204 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.addParentToChildren | protected function addParentToChildren($numFighters)
{
$numRounds = $this->getNumRounds($numFighters);
$groupsDesc = $this->championship
->fightersGroups()
->where('round', '<', $numRounds)
->orderByDesc('id')->get();
$groupsDescByRound = $groupsDesc->groupBy('round');
foreach ($groupsDescByRound as $round => $groups) {
$previousRound = $this->getPreviousRound($round);
foreach ($groups->reverse()->values() as $matchNumber => $group) {
$parent = $this->getParentGroup($matchNumber + 1, $previousRound);
$group->parent_id = $parent->id;
$group->save();
}
}
} | php | protected function addParentToChildren($numFighters)
{
$numRounds = $this->getNumRounds($numFighters);
$groupsDesc = $this->championship
->fightersGroups()
->where('round', '<', $numRounds)
->orderByDesc('id')->get();
$groupsDescByRound = $groupsDesc->groupBy('round');
foreach ($groupsDescByRound as $round => $groups) {
$previousRound = $this->getPreviousRound($round);
foreach ($groups->reverse()->values() as $matchNumber => $group) {
$parent = $this->getParentGroup($matchNumber + 1, $previousRound);
$group->parent_id = $parent->id;
$group->save();
}
}
} | [
"protected",
"function",
"addParentToChildren",
"(",
"$",
"numFighters",
")",
"{",
"$",
"numRounds",
"=",
"$",
"this",
"->",
"getNumRounds",
"(",
"$",
"numFighters",
")",
";",
"$",
"groupsDesc",
"=",
"$",
"this",
"->",
"championship",
"->",
"fightersGroups",
... | Logically build the tree ( attach a parent to every child for nestedSet Navigation )
@param $numFighters | [
"Logically",
"build",
"the",
"tree",
"(",
"attach",
"a",
"parent",
"to",
"every",
"child",
"for",
"nestedSet",
"Navigation",
")"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L211-L229 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.destroyPreviousFights | protected function destroyPreviousFights()
{
// Delete previous fight for this championship
$arrGroupsId = $this->championship->fightersGroups()->get()->pluck('id');
if (count($arrGroupsId) > 0) {
Fight::destroy($arrGroupsId);
}
} | php | protected function destroyPreviousFights()
{
// Delete previous fight for this championship
$arrGroupsId = $this->championship->fightersGroups()->get()->pluck('id');
if (count($arrGroupsId) > 0) {
Fight::destroy($arrGroupsId);
}
} | [
"protected",
"function",
"destroyPreviousFights",
"(",
")",
"{",
"// Delete previous fight for this championship",
"$",
"arrGroupsId",
"=",
"$",
"this",
"->",
"championship",
"->",
"fightersGroups",
"(",
")",
"->",
"get",
"(",
")",
"->",
"pluck",
"(",
"'id'",
")",... | Destroy Previous Fights for demo. | [
"Destroy",
"Previous",
"Fights",
"for",
"demo",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L235-L242 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.generateNextRoundsFights | public function generateNextRoundsFights()
{
$fightersCount = $this->championship->competitors->count() + $this->championship->teams->count();
$maxRounds = $this->getNumRounds($fightersCount);
for ($numRound = 1; $numRound < $maxRounds; $numRound++) {
$groupsByRound = $this->championship->fightersGroups()->where('round', $numRound)->with('parent', 'children')->get();
$this->updateParentFight($groupsByRound); // should be groupsByRound
}
} | php | public function generateNextRoundsFights()
{
$fightersCount = $this->championship->competitors->count() + $this->championship->teams->count();
$maxRounds = $this->getNumRounds($fightersCount);
for ($numRound = 1; $numRound < $maxRounds; $numRound++) {
$groupsByRound = $this->championship->fightersGroups()->where('round', $numRound)->with('parent', 'children')->get();
$this->updateParentFight($groupsByRound); // should be groupsByRound
}
} | [
"public",
"function",
"generateNextRoundsFights",
"(",
")",
"{",
"$",
"fightersCount",
"=",
"$",
"this",
"->",
"championship",
"->",
"competitors",
"->",
"count",
"(",
")",
"+",
"$",
"this",
"->",
"championship",
"->",
"teams",
"->",
"count",
"(",
")",
";"... | Generate Fights for next rounds. | [
"Generate",
"Fights",
"for",
"next",
"rounds",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L247-L255 |
xoco70/laravel-tournaments | src/TreeGen/TreeGen.php | TreeGen.getNumArea | protected function getNumArea($round, $order)
{
$totalAreas = $this->settings->fightingAreas;
$numFighters = $this->championship->fighters->count(); // 4
$numGroups = $this->getTreeSize($numFighters, $this->championship->getGroupSize()) / $this->championship->getGroupSize(); // 1 -> 1
$areaSize = $numGroups / ($totalAreas * pow(2, $round - 1));
$numArea = intval(ceil($order / $areaSize)); // if round == 4, and second match 2/2 = 1 BAD
return $numArea;
} | php | protected function getNumArea($round, $order)
{
$totalAreas = $this->settings->fightingAreas;
$numFighters = $this->championship->fighters->count(); // 4
$numGroups = $this->getTreeSize($numFighters, $this->championship->getGroupSize()) / $this->championship->getGroupSize(); // 1 -> 1
$areaSize = $numGroups / ($totalAreas * pow(2, $round - 1));
$numArea = intval(ceil($order / $areaSize)); // if round == 4, and second match 2/2 = 1 BAD
return $numArea;
} | [
"protected",
"function",
"getNumArea",
"(",
"$",
"round",
",",
"$",
"order",
")",
"{",
"$",
"totalAreas",
"=",
"$",
"this",
"->",
"settings",
"->",
"fightingAreas",
";",
"$",
"numFighters",
"=",
"$",
"this",
"->",
"championship",
"->",
"fighters",
"->",
... | Calculate the area of the group ( group is still not created ).
@param $round
@param $order
@return int | [
"Calculate",
"the",
"area",
"of",
"the",
"group",
"(",
"group",
"is",
"still",
"not",
"created",
")",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/TreeGen.php#L304-L314 |
xoco70/laravel-tournaments | database/migrations/2014_10_12_000001_alter_lt_users_table.php | AlterLtUsersTable.up | public function up()
{
if (!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('firstname')->default('firstname');
$table->string('lastname')->default('lastname');
$table->string('email')->unique();
$table->string('password', 60);
$table->timestamps();
});
} else {
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'name')) {
$table->string('name')->default('name');
}
if (!Schema::hasColumn('users', 'firstname')) {
$table->string('firstname')->default('firstname');
}
if (!Schema::hasColumn('users', 'lastname')) {
$table->string('lastname')->default('lastname');
}
if (!Schema::hasColumn('users', 'email')) {
$table->string('email')->default('user_'.rand(100000, 999999).'@kendozone.com')->unique();
}
if (!Schema::hasColumn('users', 'password')) {
$table->string('password', 60)->default('kendozone');
}
});
}
} | php | public function up()
{
if (!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('firstname')->default('firstname');
$table->string('lastname')->default('lastname');
$table->string('email')->unique();
$table->string('password', 60);
$table->timestamps();
});
} else {
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'name')) {
$table->string('name')->default('name');
}
if (!Schema::hasColumn('users', 'firstname')) {
$table->string('firstname')->default('firstname');
}
if (!Schema::hasColumn('users', 'lastname')) {
$table->string('lastname')->default('lastname');
}
if (!Schema::hasColumn('users', 'email')) {
$table->string('email')->default('user_'.rand(100000, 999999).'@kendozone.com')->unique();
}
if (!Schema::hasColumn('users', 'password')) {
$table->string('password', 60)->default('kendozone');
}
});
}
} | [
"public",
"function",
"up",
"(",
")",
"{",
"if",
"(",
"!",
"Schema",
"::",
"hasTable",
"(",
"'users'",
")",
")",
"{",
"Schema",
"::",
"create",
"(",
"'users'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/migrations/2014_10_12_000001_alter_lt_users_table.php#L14-L46 |
xoco70/laravel-tournaments | src/TreeGen/CreateSingleEliminationTree.php | CreateSingleEliminationTree.getRoundTitles | public function getRoundTitles()
{
$semiFinalTitles = ['Semi-Finals', 'Final'];
$quarterFinalTitles = ['Quarter-Finals', 'Semi-Finals', 'Final'];
$roundTitle = [
2 => ['Final'],
3 => $semiFinalTitles,
4 => $semiFinalTitles,
5 => $semiFinalTitles,
6 => $quarterFinalTitles,
7 => $quarterFinalTitles,
8 => $quarterFinalTitles,
];
if ($this->numFighters > 8) {
$roundTitles = ['Quarter-Finals', 'Semi-Finals', 'Final'];
$noRounds = ceil(log($this->numFighters, 2));
$noTeamsInFirstRound = pow(2, ceil(log($this->numFighters) / log(2)));
$tempRounds = [];
//The minus 3 is to ignore the final, semi final and quarter final rounds
for ($i = 0; $i < $noRounds - 3; $i++) {
$tempRounds[] = 'Last ' . $noTeamsInFirstRound;
$noTeamsInFirstRound /= 2;
}
return array_merge($tempRounds, $roundTitles);
}
return $roundTitle[$this->numFighters];
} | php | public function getRoundTitles()
{
$semiFinalTitles = ['Semi-Finals', 'Final'];
$quarterFinalTitles = ['Quarter-Finals', 'Semi-Finals', 'Final'];
$roundTitle = [
2 => ['Final'],
3 => $semiFinalTitles,
4 => $semiFinalTitles,
5 => $semiFinalTitles,
6 => $quarterFinalTitles,
7 => $quarterFinalTitles,
8 => $quarterFinalTitles,
];
if ($this->numFighters > 8) {
$roundTitles = ['Quarter-Finals', 'Semi-Finals', 'Final'];
$noRounds = ceil(log($this->numFighters, 2));
$noTeamsInFirstRound = pow(2, ceil(log($this->numFighters) / log(2)));
$tempRounds = [];
//The minus 3 is to ignore the final, semi final and quarter final rounds
for ($i = 0; $i < $noRounds - 3; $i++) {
$tempRounds[] = 'Last ' . $noTeamsInFirstRound;
$noTeamsInFirstRound /= 2;
}
return array_merge($tempRounds, $roundTitles);
}
return $roundTitle[$this->numFighters];
} | [
"public",
"function",
"getRoundTitles",
"(",
")",
"{",
"$",
"semiFinalTitles",
"=",
"[",
"'Semi-Finals'",
",",
"'Final'",
"]",
";",
"$",
"quarterFinalTitles",
"=",
"[",
"'Quarter-Finals'",
",",
"'Semi-Finals'",
",",
"'Final'",
"]",
";",
"$",
"roundTitle",
"=",... | returns titles depending of number of rounds.
@return array | [
"returns",
"titles",
"depending",
"of",
"number",
"of",
"rounds",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/CreateSingleEliminationTree.php#L116-L147 |
xoco70/laravel-tournaments | src/TreeGen/CreateSingleEliminationTree.php | CreateSingleEliminationTree.printRoundTitles | public function printRoundTitles()
{
$roundTitles = $this->getRoundTitles();
echo '<div id="round-titles-wrapper">';
foreach ($roundTitles as $key => $roundTitle) {
$left = $key * ($this->matchWrapperWidth + $this->roundSpacing - 1);
echo '<div class="round-title" style="left: ' . $left . 'px;">' . $roundTitle . '</div>';
}
echo '</div>';
} | php | public function printRoundTitles()
{
$roundTitles = $this->getRoundTitles();
echo '<div id="round-titles-wrapper">';
foreach ($roundTitles as $key => $roundTitle) {
$left = $key * ($this->matchWrapperWidth + $this->roundSpacing - 1);
echo '<div class="round-title" style="left: ' . $left . 'px;">' . $roundTitle . '</div>';
}
echo '</div>';
} | [
"public",
"function",
"printRoundTitles",
"(",
")",
"{",
"$",
"roundTitles",
"=",
"$",
"this",
"->",
"getRoundTitles",
"(",
")",
";",
"echo",
"'<div id=\"round-titles-wrapper\">'",
";",
"foreach",
"(",
"$",
"roundTitles",
"as",
"$",
"key",
"=>",
"$",
"roundTit... | Print Round Titles. | [
"Print",
"Round",
"Titles",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/CreateSingleEliminationTree.php#L152-L164 |
xoco70/laravel-tournaments | src/TreeGen/CreateSingleEliminationTree.php | CreateSingleEliminationTree.getPlayerList | public function getPlayerList($selected)
{
$html = '<select>
<option' . ($selected == '' ? ' selected' : '') . '></option>';
foreach ($this->championship->fighters as $fighter) {
$html = $this->addOptionToSelect($selected, $fighter, $html);
}
$html .= '</select>';
return $html;
} | php | public function getPlayerList($selected)
{
$html = '<select>
<option' . ($selected == '' ? ' selected' : '') . '></option>';
foreach ($this->championship->fighters as $fighter) {
$html = $this->addOptionToSelect($selected, $fighter, $html);
}
$html .= '</select>';
return $html;
} | [
"public",
"function",
"getPlayerList",
"(",
"$",
"selected",
")",
"{",
"$",
"html",
"=",
"'<select>\n <option'",
".",
"(",
"$",
"selected",
"==",
"''",
"?",
"' selected'",
":",
"''",
")",
".",
"'></option>'",
";",
"foreach",
"(",
"$",
"this",
... | @param $selected
@return string | [
"@param",
"$selected"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/CreateSingleEliminationTree.php#L171-L183 |
xoco70/laravel-tournaments | src/TreeGen/CreateSingleEliminationTree.php | CreateSingleEliminationTree.addOptionToSelect | private function addOptionToSelect($selected, $fighter, $html): string
{
if ($fighter != null) {
$select = $selected != null && $selected->id == $fighter->id ? ' selected' : '';
$html .= '<option' . $select
. ' value='
. ($fighter->id ?? '')
. '>'
. $fighter->name
. '</option>';
}
return $html;
} | php | private function addOptionToSelect($selected, $fighter, $html): string
{
if ($fighter != null) {
$select = $selected != null && $selected->id == $fighter->id ? ' selected' : '';
$html .= '<option' . $select
. ' value='
. ($fighter->id ?? '')
. '>'
. $fighter->name
. '</option>';
}
return $html;
} | [
"private",
"function",
"addOptionToSelect",
"(",
"$",
"selected",
",",
"$",
"fighter",
",",
"$",
"html",
")",
":",
"string",
"{",
"if",
"(",
"$",
"fighter",
"!=",
"null",
")",
"{",
"$",
"select",
"=",
"$",
"selected",
"!=",
"null",
"&&",
"$",
"select... | @param $selected
@param $fighter
@param $html
@return string | [
"@param",
"$selected",
"@param",
"$fighter",
"@param",
"$html"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/TreeGen/CreateSingleEliminationTree.php#L230-L243 |
xoco70/laravel-tournaments | database/seeds/VenueSeeder.php | VenueSeeder.run | public function run()
{
$this->command->info('Venues seeding!');
DB::table('venue')->truncate();
factory(Venue::class, 5)->create();
} | php | public function run()
{
$this->command->info('Venues seeding!');
DB::table('venue')->truncate();
factory(Venue::class, 5)->create();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"info",
"(",
"'Venues seeding!'",
")",
";",
"DB",
"::",
"table",
"(",
"'venue'",
")",
"->",
"truncate",
"(",
")",
";",
"factory",
"(",
"Venue",
"::",
"class",
",",
"5",
... | Run the database seeds.
@return void | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/seeds/VenueSeeder.php#L14-L19 |
xoco70/laravel-tournaments | src/Models/Fight.php | Fight.getFightersWithByes | protected static function getFightersWithByes(FightersGroup $group)
{
if ($group == null) {
return;
}
$fighters = $group->getFightersWithBye();
$fighterType = $group->getFighterType();
if (count($fighters) == 0) {
$fighters->push(new $fighterType());
$fighters->push(new $fighterType());
} elseif (count($fighters) % 2 != 0) {
$fighters->push(new $fighterType());
}
return $fighters;
} | php | protected static function getFightersWithByes(FightersGroup $group)
{
if ($group == null) {
return;
}
$fighters = $group->getFightersWithBye();
$fighterType = $group->getFighterType();
if (count($fighters) == 0) {
$fighters->push(new $fighterType());
$fighters->push(new $fighterType());
} elseif (count($fighters) % 2 != 0) {
$fighters->push(new $fighterType());
}
return $fighters;
} | [
"protected",
"static",
"function",
"getFightersWithByes",
"(",
"FightersGroup",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"group",
"==",
"null",
")",
"{",
"return",
";",
"}",
"$",
"fighters",
"=",
"$",
"group",
"->",
"getFightersWithBye",
"(",
")",
";",
"$... | @param FightersGroup|null $group
@return Collection | [
"@param",
"FightersGroup|null",
"$group"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/Fight.php#L48-L63 |
xoco70/laravel-tournaments | src/Models/Fight.php | Fight.fighter1 | public function fighter1()
{
return $this->group->championship->category->isTeam
? $this->team1()
: $this->competitor1();
} | php | public function fighter1()
{
return $this->group->championship->category->isTeam
? $this->team1()
: $this->competitor1();
} | [
"public",
"function",
"fighter1",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"group",
"->",
"championship",
"->",
"category",
"->",
"isTeam",
"?",
"$",
"this",
"->",
"team1",
"(",
")",
":",
"$",
"this",
"->",
"competitor1",
"(",
")",
";",
"}"
] | Get First Fighter.
@return \Illuminate\Database\Eloquent\Relations\BelongsTo | [
"Get",
"First",
"Fighter",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/Fight.php#L110-L115 |
xoco70/laravel-tournaments | src/Models/Fight.php | Fight.fighter2 | public function fighter2()
{
return $this->group->championship->category->isTeam
? $this->team2()
: $this->competitor2();
} | php | public function fighter2()
{
return $this->group->championship->category->isTeam
? $this->team2()
: $this->competitor2();
} | [
"public",
"function",
"fighter2",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"group",
"->",
"championship",
"->",
"category",
"->",
"isTeam",
"?",
"$",
"this",
"->",
"team2",
"(",
")",
":",
"$",
"this",
"->",
"competitor2",
"(",
")",
";",
"}"
] | Get First Fighter.
@return \Illuminate\Database\Eloquent\Relations\BelongsTo | [
"Get",
"First",
"Fighter",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/Fight.php#L122-L127 |
xoco70/laravel-tournaments | src/Models/Fight.php | Fight.getFighterAttr | public function getFighterAttr($numFighter, $attr)
{
$isTeam = $this->group->championship->category->isTeam;
if ($isTeam) {
$teamToUpdate = 'team'.$numFighter;
return optional($this->$teamToUpdate)->$attr;
}
$competitorToUpdate = 'competitor'.$numFighter;
if ($attr == 'name') {
return $this->$competitorToUpdate == null
? ''
: $this->$competitorToUpdate->user->firstname.' '.$this->$competitorToUpdate->user->lastname;
} elseif ($attr == 'short_id') {
return optional($this->$competitorToUpdate)->short_id;
}
} | php | public function getFighterAttr($numFighter, $attr)
{
$isTeam = $this->group->championship->category->isTeam;
if ($isTeam) {
$teamToUpdate = 'team'.$numFighter;
return optional($this->$teamToUpdate)->$attr;
}
$competitorToUpdate = 'competitor'.$numFighter;
if ($attr == 'name') {
return $this->$competitorToUpdate == null
? ''
: $this->$competitorToUpdate->user->firstname.' '.$this->$competitorToUpdate->user->lastname;
} elseif ($attr == 'short_id') {
return optional($this->$competitorToUpdate)->short_id;
}
} | [
"public",
"function",
"getFighterAttr",
"(",
"$",
"numFighter",
",",
"$",
"attr",
")",
"{",
"$",
"isTeam",
"=",
"$",
"this",
"->",
"group",
"->",
"championship",
"->",
"category",
"->",
"isTeam",
";",
"if",
"(",
"$",
"isTeam",
")",
"{",
"$",
"teamToUpd... | @param $numFighter
@param $attr
@return null|string | [
"@param",
"$numFighter",
"@param",
"$attr"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/Fight.php#L135-L151 |
xoco70/laravel-tournaments | src/Models/Fight.php | Fight.updateShortId | private function updateShortId($order)
{
if ($this->shouldBeInFightList(false)) {
$this->short_id = $order;
$this->save();
return ++$order;
}
return $order;
} | php | private function updateShortId($order)
{
if ($this->shouldBeInFightList(false)) {
$this->short_id = $order;
$this->save();
return ++$order;
}
return $order;
} | [
"private",
"function",
"updateShortId",
"(",
"$",
"order",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shouldBeInFightList",
"(",
"false",
")",
")",
"{",
"$",
"this",
"->",
"short_id",
"=",
"$",
"order",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
... | @param $order
@return int | [
"@param",
"$order"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/Fight.php#L234-L244 |
xoco70/laravel-tournaments | database/migrations/2015_10_24_223707_create_lt_FightersGroup_table.php | CreateLtFightersGroupTable.up | public function up()
{
Schema::create('fighters_groups', function (Blueprint $table) {
$table->increments('id');
$table->tinyInteger('short_id')->unsigned()->nullable();
$table->integer('championship_id')->unsigned()->index();
$table->tinyInteger('round')->default(0); // Eliminitory, 1/8, 1/4, etc.
$table->tinyInteger('area');
$table->tinyInteger('order');
NestedSet::columns($table);
$table->timestamps();
$table->engine = 'InnoDB';
$table->foreign('championship_id')
->references('id')
->onUpdate('cascade')
->on('championship')
->onDelete('cascade');
});
} | php | public function up()
{
Schema::create('fighters_groups', function (Blueprint $table) {
$table->increments('id');
$table->tinyInteger('short_id')->unsigned()->nullable();
$table->integer('championship_id')->unsigned()->index();
$table->tinyInteger('round')->default(0); // Eliminitory, 1/8, 1/4, etc.
$table->tinyInteger('area');
$table->tinyInteger('order');
NestedSet::columns($table);
$table->timestamps();
$table->engine = 'InnoDB';
$table->foreign('championship_id')
->references('id')
->onUpdate('cascade')
->on('championship')
->onDelete('cascade');
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'fighters_groups'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"tinyInteger",
"(",
"... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/database/migrations/2015_10_24_223707_create_lt_FightersGroup_table.php#L16-L36 |
xoco70/laravel-tournaments | src/Models/ChampionshipSettings.php | ChampionshipSettings.createOrUpdate | public static function createOrUpdate(Request $request, Championship $championship): self
{
$request->request->add(['championship_id' => $championship->id]);
$arrSettings = $request->except('_token', 'numFighters', 'isTeam');
$settings = static::where(['championship_id' => $championship->id])->first();
if ($settings == null) {
$settings = new self();
}
$settings->fill($arrSettings);
$settings->save();
return $settings;
} | php | public static function createOrUpdate(Request $request, Championship $championship): self
{
$request->request->add(['championship_id' => $championship->id]);
$arrSettings = $request->except('_token', 'numFighters', 'isTeam');
$settings = static::where(['championship_id' => $championship->id])->first();
if ($settings == null) {
$settings = new self();
}
$settings->fill($arrSettings);
$settings->save();
return $settings;
} | [
"public",
"static",
"function",
"createOrUpdate",
"(",
"Request",
"$",
"request",
",",
"Championship",
"$",
"championship",
")",
":",
"self",
"{",
"$",
"request",
"->",
"request",
"->",
"add",
"(",
"[",
"'championship_id'",
"=>",
"$",
"championship",
"->",
"... | @param Request $request
@param Championship $championship
@return ChampionshipSettings | [
"@param",
"Request",
"$request",
"@param",
"Championship",
"$championship"
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/ChampionshipSettings.php#L61-L74 |
xoco70/laravel-tournaments | src/Models/FightersGroup.php | FightersGroup.syncTeams | public function syncTeams($fighters)
{
$this->teams()->detach();
foreach ($fighters as $fighter) {
if ($fighter != null) {
$this->teams()->attach($fighter);
} else {
// Insert row manually
DB::table('fighters_group_team')->insertGetId(
['team_id' => null, 'fighters_group_id' => $this->id]
);
}
}
} | php | public function syncTeams($fighters)
{
$this->teams()->detach();
foreach ($fighters as $fighter) {
if ($fighter != null) {
$this->teams()->attach($fighter);
} else {
// Insert row manually
DB::table('fighters_group_team')->insertGetId(
['team_id' => null, 'fighters_group_id' => $this->id]
);
}
}
} | [
"public",
"function",
"syncTeams",
"(",
"$",
"fighters",
")",
"{",
"$",
"this",
"->",
"teams",
"(",
")",
"->",
"detach",
"(",
")",
";",
"foreach",
"(",
"$",
"fighters",
"as",
"$",
"fighter",
")",
"{",
"if",
"(",
"$",
"fighter",
"!=",
"null",
")",
... | Supercharge of sync Many2Many function.
Original sync doesn't insert NULL ids.
@param $fighters | [
"Supercharge",
"of",
"sync",
"Many2Many",
"function",
".",
"Original",
"sync",
"doesn",
"t",
"insert",
"NULL",
"ids",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/FightersGroup.php#L61-L74 |
xoco70/laravel-tournaments | src/Models/FightersGroup.php | FightersGroup.syncCompetitors | public function syncCompetitors($fighters)
{
$this->competitors()->detach();
foreach ($fighters as $fighter) {
if ($fighter != null) {
$this->competitors()->attach($fighter);
} else {
DB::table('fighters_group_competitor')->insertGetId(
['competitor_id' => null, 'fighters_group_id' => $this->id,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]
);
}
}
} | php | public function syncCompetitors($fighters)
{
$this->competitors()->detach();
foreach ($fighters as $fighter) {
if ($fighter != null) {
$this->competitors()->attach($fighter);
} else {
DB::table('fighters_group_competitor')->insertGetId(
['competitor_id' => null, 'fighters_group_id' => $this->id,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]
);
}
}
} | [
"public",
"function",
"syncCompetitors",
"(",
"$",
"fighters",
")",
"{",
"$",
"this",
"->",
"competitors",
"(",
")",
"->",
"detach",
"(",
")",
";",
"foreach",
"(",
"$",
"fighters",
"as",
"$",
"fighter",
")",
"{",
"if",
"(",
"$",
"fighter",
"!=",
"nul... | Supercharge of sync Many2Many function.
Original sync doesn't insert NULL ids.
@param $fighters | [
"Supercharge",
"of",
"sync",
"Many2Many",
"function",
".",
"Original",
"sync",
"doesn",
"t",
"insert",
"NULL",
"ids",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/FightersGroup.php#L82-L97 |
xoco70/laravel-tournaments | src/Models/FightersGroup.php | FightersGroup.competitorsWithBye | public function competitorsWithBye(): Collection
{
$competitors = new Collection();
$fgcs = FighterGroupCompetitor::where('fighters_group_id', $this->id)
->with('competitor')
->get();
foreach ($fgcs as $fgc) {
$competitors->push($fgc->competitor ?? new Competitor());
}
return $competitors;
} | php | public function competitorsWithBye(): Collection
{
$competitors = new Collection();
$fgcs = FighterGroupCompetitor::where('fighters_group_id', $this->id)
->with('competitor')
->get();
foreach ($fgcs as $fgc) {
$competitors->push($fgc->competitor ?? new Competitor());
}
return $competitors;
} | [
"public",
"function",
"competitorsWithBye",
"(",
")",
":",
"Collection",
"{",
"$",
"competitors",
"=",
"new",
"Collection",
"(",
")",
";",
"$",
"fgcs",
"=",
"FighterGroupCompetitor",
"::",
"where",
"(",
"'fighters_group_id'",
",",
"$",
"this",
"->",
"id",
")... | Get the many 2 many relationship with the Null Rows.
@return Collection | [
"Get",
"the",
"many",
"2",
"many",
"relationship",
"with",
"the",
"Null",
"Rows",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/FightersGroup.php#L104-L116 |
xoco70/laravel-tournaments | src/Models/FightersGroup.php | FightersGroup.hasDeterminedParent | public function hasDeterminedParent()
{
// There is more than 1 fight, should be Preliminary
if (count($this->fighters()) > 1) {
return false;
}
foreach ($this->children as $child) {
if (count($child->fighters()) > 1) {
return false;
}
}
return true;
} | php | public function hasDeterminedParent()
{
// There is more than 1 fight, should be Preliminary
if (count($this->fighters()) > 1) {
return false;
}
foreach ($this->children as $child) {
if (count($child->fighters()) > 1) {
return false;
}
}
return true;
} | [
"public",
"function",
"hasDeterminedParent",
"(",
")",
"{",
"// There is more than 1 fight, should be Preliminary",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"fighters",
"(",
")",
")",
">",
"1",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"... | Check if we are able to fill the parent fight or not
If one of the children has c1 x c2, then we must wait to fill parent.
@return bool | [
"Check",
"if",
"we",
"are",
"able",
"to",
"fill",
"the",
"parent",
"fight",
"or",
"not",
"If",
"one",
"of",
"the",
"children",
"has",
"c1",
"x",
"c2",
"then",
"we",
"must",
"wait",
"to",
"fill",
"parent",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/FightersGroup.php#L175-L188 |
xoco70/laravel-tournaments | src/Models/FightersGroup.php | FightersGroup.getValueToUpdate | public function getValueToUpdate()
{
try {
if ($this->championship->category->isTeam()) {
return $this->teams->map->id[0];
}
return $this->competitors->map->id[0];
} catch (ErrorException $e) {
return;
}
} | php | public function getValueToUpdate()
{
try {
if ($this->championship->category->isTeam()) {
return $this->teams->map->id[0];
}
return $this->competitors->map->id[0];
} catch (ErrorException $e) {
return;
}
} | [
"public",
"function",
"getValueToUpdate",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"championship",
"->",
"category",
"->",
"isTeam",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"teams",
"->",
"map",
"->",
"id",
"[",
"0",
"]",
"... | In the original fight ( child ) return the field that contains data to copy to parent.
@return int | [
"In",
"the",
"original",
"fight",
"(",
"child",
")",
"return",
"the",
"field",
"that",
"contains",
"data",
"to",
"copy",
"to",
"parent",
"."
] | train | https://github.com/xoco70/laravel-tournaments/blob/d1d065f2f815b7d587b23d21ad585aeba6197464/src/Models/FightersGroup.php#L195-L206 |
blackfireio/player | Player/Console/ConsoleLogger.php | ConsoleLogger.log | public function log($level, $message, array $context = [])
{
parent::log($level, $message, $context);
if (isset($this->errorLevels[$level])) {
$this->errored = true;
}
} | php | public function log($level, $message, array $context = [])
{
parent::log($level, $message, $context);
if (isset($this->errorLevels[$level])) {
$this->errored = true;
}
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"parent",
"::",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"if",
"(",
"isset",
"(",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/blackfireio/player/blob/f2410f88eb8c32441bd8aa98625819e8c5a4aa16/Player/Console/ConsoleLogger.php#L31-L38 |
blackfireio/player | Player/Console/PlayerCommand.php | PlayerCommand.createCurlHandler | private function createCurlHandler()
{
$handlerOptions = [
'handle_factory' => new CurlFactory(3),
];
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
return Proxy::wrapSync(new CurlMultiHandler($handlerOptions), new CurlHandler($handlerOptions));
}
if (\function_exists('curl_exec')) {
return new CurlHandler($handlerOptions);
}
if (\function_exists('curl_multi_exec')) {
return new CurlMultiHandler($handlerOptions);
}
throw new \RuntimeException('Blackfire Player requires cURL.');
} | php | private function createCurlHandler()
{
$handlerOptions = [
'handle_factory' => new CurlFactory(3),
];
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
return Proxy::wrapSync(new CurlMultiHandler($handlerOptions), new CurlHandler($handlerOptions));
}
if (\function_exists('curl_exec')) {
return new CurlHandler($handlerOptions);
}
if (\function_exists('curl_multi_exec')) {
return new CurlMultiHandler($handlerOptions);
}
throw new \RuntimeException('Blackfire Player requires cURL.');
} | [
"private",
"function",
"createCurlHandler",
"(",
")",
"{",
"$",
"handlerOptions",
"=",
"[",
"'handle_factory'",
"=>",
"new",
"CurlFactory",
"(",
"3",
")",
",",
"]",
";",
"if",
"(",
"\\",
"function_exists",
"(",
"'curl_multi_exec'",
")",
"&&",
"\\",
"function... | Adapted from \GuzzleHttp\choose_handler() to allow setting the 'handle_factory" option. | [
"Adapted",
"from",
"\\",
"GuzzleHttp",
"\\",
"choose_handler",
"()",
"to",
"allow",
"setting",
"the",
"handle_factory",
"option",
"."
] | train | https://github.com/blackfireio/player/blob/f2410f88eb8c32441bd8aa98625819e8c5a4aa16/Player/Console/PlayerCommand.php#L174-L193 |
blackfireio/player | Player/ExpressionLanguage/Provider.php | Provider.getFunctions | public function getFunctions()
{
$compiler = function () {};
return [
new ExpressionFunction('url', $compiler, function ($arguments, $url) {
return $url;
}),
new ExpressionFunction('link', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to get link "%s" as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->selectLink($selector);
}),
new ExpressionFunction('button', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to submit on selector "%s" as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->selectButton($selector);
}),
new ExpressionFunction('file', $compiler, function ($arguments, $filename, $name = null) {
return [$filename, $name ?: basename($filename)];
}),
new ExpressionFunction('current_url', $compiler, function ($arguments) {
if (null === $arguments['_crawler']) {
throw new LogicException('Unable to get the current URL as the page is not crawlable.');
}
return (string) $arguments['_crawler']->getUri();
}),
new ExpressionFunction('status_code', $compiler, function ($arguments) {
return $arguments['_response']->getStatusCode();
}),
new ExpressionFunction('headers', $compiler, function ($arguments) {
$headers = [];
foreach ($arguments['_response']->getHeaders() as $key => $value) {
$headers[$key] = $value[0];
}
return $headers;
}),
new ExpressionFunction('body', $compiler, function ($arguments) {
return (string) $arguments['_response']->getBody();
}),
new ExpressionFunction('header', $compiler, function ($arguments, $name) {
$name = str_replace('_', '-', strtolower($name));
if (!$arguments['_response']->hasHeader($name)) {
return;
}
return $arguments['_response']->getHeader($name)[0];
}),
new ExpressionFunction('trim', $compiler, function ($arguments, $scalar) {
return trim($scalar);
}),
new ExpressionFunction('unique', $compiler, function ($arguments, $arr) {
return array_unique($arr);
}),
new ExpressionFunction('join', $compiler, function ($arguments, $value, $glue) {
if ($value instanceof \Traversable) {
$value = iterator_to_array($value, false);
}
return implode($glue, (array) $value);
}),
new ExpressionFunction('merge', $compiler, function ($arguments, $arr1, $arr2) {
if ($arr1 instanceof \Traversable) {
$arr1 = iterator_to_array($arr1);
} elseif (!\is_array($arr1)) {
throw new InvalidArgumentException(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($arr1)));
}
if ($arr2 instanceof \Traversable) {
$arr2 = iterator_to_array($arr2);
} elseif (!\is_array($arr2)) {
throw new InvalidArgumentException(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', \gettype($arr2)));
}
return array_merge($arr1, $arr2);
}),
new ExpressionFunction('fake', $compiler, function ($arguments, $provider = null/*, $othersArgs ...*/) {
$arguments = \func_get_args();
if (!$provider) {
throw new InvalidArgumentException('Missing first argument (provider) for the fake function.');
}
return $this->faker->format($provider, array_splice($arguments, 2));
}),
new ExpressionFunction('regex', $compiler, function ($arguments, $regex, $str = null) {
if (null === $str) {
$str = (string) $arguments['_response']->getBody();
}
$ret = @preg_match($regex, $str, $matches);
if (false === $ret) {
throw new InvalidArgumentException(sprintf('Regex "%s" is not valid: %s.', $regex, error_get_last()['message']));
}
return isset($matches[1]) ? $matches[1] : null;
}),
new ExpressionFunction('css', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to get the "%s" CSS selector as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->filter($selector);
}),
new ExpressionFunction('xpath', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to get "%s" XPATH selector as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->filterXPath($selector);
}),
new ExpressionFunction('json', $compiler, function ($arguments, $selector) {
if (null === $data = json_decode((string) $arguments['_response']->getBody(), true)) {
throw new LogicException(sprintf(' Unable to get the "%s" JSON path as the Response body does not seem to be JSON.', $selector));
}
return JmesPath::search($selector, $data);
}),
new ExpressionFunction('transform', $compiler, function ($arguments, $selector, $data) {
return JmesPath::search($selector, $data);
}),
];
} | php | public function getFunctions()
{
$compiler = function () {};
return [
new ExpressionFunction('url', $compiler, function ($arguments, $url) {
return $url;
}),
new ExpressionFunction('link', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to get link "%s" as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->selectLink($selector);
}),
new ExpressionFunction('button', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to submit on selector "%s" as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->selectButton($selector);
}),
new ExpressionFunction('file', $compiler, function ($arguments, $filename, $name = null) {
return [$filename, $name ?: basename($filename)];
}),
new ExpressionFunction('current_url', $compiler, function ($arguments) {
if (null === $arguments['_crawler']) {
throw new LogicException('Unable to get the current URL as the page is not crawlable.');
}
return (string) $arguments['_crawler']->getUri();
}),
new ExpressionFunction('status_code', $compiler, function ($arguments) {
return $arguments['_response']->getStatusCode();
}),
new ExpressionFunction('headers', $compiler, function ($arguments) {
$headers = [];
foreach ($arguments['_response']->getHeaders() as $key => $value) {
$headers[$key] = $value[0];
}
return $headers;
}),
new ExpressionFunction('body', $compiler, function ($arguments) {
return (string) $arguments['_response']->getBody();
}),
new ExpressionFunction('header', $compiler, function ($arguments, $name) {
$name = str_replace('_', '-', strtolower($name));
if (!$arguments['_response']->hasHeader($name)) {
return;
}
return $arguments['_response']->getHeader($name)[0];
}),
new ExpressionFunction('trim', $compiler, function ($arguments, $scalar) {
return trim($scalar);
}),
new ExpressionFunction('unique', $compiler, function ($arguments, $arr) {
return array_unique($arr);
}),
new ExpressionFunction('join', $compiler, function ($arguments, $value, $glue) {
if ($value instanceof \Traversable) {
$value = iterator_to_array($value, false);
}
return implode($glue, (array) $value);
}),
new ExpressionFunction('merge', $compiler, function ($arguments, $arr1, $arr2) {
if ($arr1 instanceof \Traversable) {
$arr1 = iterator_to_array($arr1);
} elseif (!\is_array($arr1)) {
throw new InvalidArgumentException(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($arr1)));
}
if ($arr2 instanceof \Traversable) {
$arr2 = iterator_to_array($arr2);
} elseif (!\is_array($arr2)) {
throw new InvalidArgumentException(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', \gettype($arr2)));
}
return array_merge($arr1, $arr2);
}),
new ExpressionFunction('fake', $compiler, function ($arguments, $provider = null/*, $othersArgs ...*/) {
$arguments = \func_get_args();
if (!$provider) {
throw new InvalidArgumentException('Missing first argument (provider) for the fake function.');
}
return $this->faker->format($provider, array_splice($arguments, 2));
}),
new ExpressionFunction('regex', $compiler, function ($arguments, $regex, $str = null) {
if (null === $str) {
$str = (string) $arguments['_response']->getBody();
}
$ret = @preg_match($regex, $str, $matches);
if (false === $ret) {
throw new InvalidArgumentException(sprintf('Regex "%s" is not valid: %s.', $regex, error_get_last()['message']));
}
return isset($matches[1]) ? $matches[1] : null;
}),
new ExpressionFunction('css', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to get the "%s" CSS selector as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->filter($selector);
}),
new ExpressionFunction('xpath', $compiler, function ($arguments, $selector) {
if (null === $arguments['_crawler']) {
throw new LogicException(sprintf('Unable to get "%s" XPATH selector as the page is not crawlable.', $selector));
}
return $arguments['_crawler']->filterXPath($selector);
}),
new ExpressionFunction('json', $compiler, function ($arguments, $selector) {
if (null === $data = json_decode((string) $arguments['_response']->getBody(), true)) {
throw new LogicException(sprintf(' Unable to get the "%s" JSON path as the Response body does not seem to be JSON.', $selector));
}
return JmesPath::search($selector, $data);
}),
new ExpressionFunction('transform', $compiler, function ($arguments, $selector, $data) {
return JmesPath::search($selector, $data);
}),
];
} | [
"public",
"function",
"getFunctions",
"(",
")",
"{",
"$",
"compiler",
"=",
"function",
"(",
")",
"{",
"}",
";",
"return",
"[",
"new",
"ExpressionFunction",
"(",
"'url'",
",",
"$",
"compiler",
",",
"function",
"(",
"$",
"arguments",
",",
"$",
"url",
")"... | {@inheritdoc} | [
"{"
] | train | https://github.com/blackfireio/player/blob/f2410f88eb8c32441bd8aa98625819e8c5a4aa16/Player/ExpressionLanguage/Provider.php#L37-L185 |
youzan/zanphp | toolkit/debugger_trace_httpd.php | TraceServer.getHostByAddr | private function getHostByAddr($addr)
{
static $cache = [];
if (!isset($cache[$addr])) {
$cache[$addr] = gethostbyaddr($addr) ?: $addr;
}
return $cache[$addr];
} | php | private function getHostByAddr($addr)
{
static $cache = [];
if (!isset($cache[$addr])) {
$cache[$addr] = gethostbyaddr($addr) ?: $addr;
}
return $cache[$addr];
} | [
"private",
"function",
"getHostByAddr",
"(",
"$",
"addr",
")",
"{",
"static",
"$",
"cache",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cache",
"[",
"$",
"addr",
"]",
")",
")",
"{",
"$",
"cache",
"[",
"$",
"addr",
"]",
"=",
"gethost... | block | [
"block"
] | train | https://github.com/youzan/zanphp/blob/48cb1180f08368c7690b240949ad951ba0be308c/toolkit/debugger_trace_httpd.php#L176-L184 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.