_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q8100 | XMLAssertTrait.assertXMLMatchesXSD | train | public static function assertXMLMatchesXSD($XSD, $XML, string $message = '')
{
if (!is_string($XSD)) {
throw AssertHelper::createArgumentException(__TRAIT__, 'assertXMLMatchesXSD', 'string', $XSD);
}
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLMatchesXSD', ['assertThat']);
self::assertThat($XML, new XMLMatchesXSDConstraint($XSD), $message);
} | php | {
"resource": ""
} |
q8101 | XMLAssertTrait.assertXMLValid | train | public static function assertXMLValid($XML, string $message = '')
{
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLValid', ['assertThat']);
self::assertThat($XML, new XMLValidConstraint(), $message);
} | php | {
"resource": ""
} |
q8102 | BlendableLoader.getBlendablePlugin | train | public function getBlendablePlugin($name)
{
/** @var \LCI\Blend\Blendable\Plugin $plugin */
$plugin = new Plugin($this->modx, $this->blender, $name);
return $plugin->setSeedsDir($this->blender->getSeedsDir());
} | php | {
"resource": ""
} |
q8103 | BlendableLoader.getBlendableSnippet | train | public function getBlendableSnippet($name)
{
/** @var Snippet $snippet */
$snippet = new Snippet($this->modx, $this->blender, $name);
return $snippet->setSeedsDir($this->blender->getSeedsDir());
} | php | {
"resource": ""
} |
q8104 | BlendableLoader.getBlendableTemplate | train | public function getBlendableTemplate($name)
{
/** @var \LCI\Blend\Blendable\Template $template */
$template = new Template($this->modx, $this->blender, $name);
return $template->setSeedsDir($this->blender->getSeedsDir());
} | php | {
"resource": ""
} |
q8105 | BlendableLoader.getBlendableTemplateVariable | train | public function getBlendableTemplateVariable($name)
{
/** @var \LCI\Blend\Blendable\TemplateVariable $tv */
$tv = new TemplateVariable($this->modx, $this->blender, $name);
return $tv->setSeedsDir($this->blender->getSeedsDir());
} | php | {
"resource": ""
} |
q8106 | Convolution.assertValidMatrix | train | private function assertValidMatrix(array $matrix)
{
$count = count($matrix);
if ($count === 3) {
for ($x = 0; $x < $count; $x++) {
if (!is_array($matrix[$x])) {
throw new \RuntimeException(sprintf(
'Item "%d" In The Given Matrix Is Not An Array', $x
));
}
$subcount = count($matrix[$x]);
if ($subcount < 3 || $subcount > 3) {
throw new \RuntimeException(sprintf(
'Item "%d" In The Given Matrix Must Be An Array With (3) '
. 'Flotas But "%d" Float(s) Was Found'
, $x, $subcount
));
}
}
} else {
throw new \RuntimeException(sprintf(
'Expect Matrix (3*3) But The Given Matrix Length is (%s)'
, $count
));
}
} | php | {
"resource": ""
} |
q8107 | Canonical.canonicalRedirectQueryStringStrategy | train | protected function canonicalRedirectQueryStringStrategy () {
/** @var $request \MvcCore\Request */
$request = & $this->request;
$redirectToCanonicalUrl = FALSE;
$requestGlobalGet = & $request->GetGlobalCollection('get');
$requestedCtrlDc = isset($requestGlobalGet[static::URL_PARAM_CONTROLLER]) ? $requestGlobalGet[static::URL_PARAM_CONTROLLER] : NULL;
$requestedActionDc = isset($requestGlobalGet[static::URL_PARAM_ACTION]) ? $requestGlobalGet[static::URL_PARAM_ACTION] : NULL;
$toolClass = self::$toolClass;
list($dfltCtrlPc, $dftlActionPc) = $this->application->GetDefaultControllerAndActionNames();
$dfltCtrlDc = $toolClass::GetDashedFromPascalCase($dfltCtrlPc);
$dftlActionDc = $toolClass::GetDashedFromPascalCase($dftlActionPc);
$requestedParamsClone = array_merge([], $this->requestedParams);
if ($requestedCtrlDc !== NULL && $requestedCtrlDc === $dfltCtrlDc) {
unset($requestedParamsClone[static::URL_PARAM_CONTROLLER]);
$redirectToCanonicalUrl = TRUE;
}
if ($requestedActionDc !== NULL && $requestedActionDc === $dftlActionDc) {
unset($requestedParamsClone[static::URL_PARAM_ACTION]);
$redirectToCanonicalUrl = TRUE;
}
if ($redirectToCanonicalUrl) {
$selfCanonicalUrl = $this->UrlByQueryString($this->selfRouteName, $requestedParamsClone);
$this->redirect($selfCanonicalUrl, \MvcCore\IResponse::MOVED_PERMANENTLY);
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q8108 | Canonical.canonicalRedirectRewriteRoutesStrategy | train | protected function canonicalRedirectRewriteRoutesStrategy () {
/** @var $request \MvcCore\Request */
$request = & $this->request;
$redirectToCanonicalUrl = FALSE;
$defaultParams = $this->GetDefaultParams() ?: [];
list($selfUrlDomainAndBasePart, $selfUrlPathAndQueryPart) = $this->currentRoute->Url(
$request, $this->requestedParams, $defaultParams, $this->getQueryStringParamsSepatator(), TRUE
);
if (mb_strpos($selfUrlDomainAndBasePart, '//') === FALSE)
$selfUrlDomainAndBasePart = $request->GetDomainUrl() . $selfUrlDomainAndBasePart;
if (
mb_strlen($selfUrlDomainAndBasePart) > 0 &&
$selfUrlDomainAndBasePart !== $request->GetBaseUrl()
) {
$redirectToCanonicalUrl = TRUE;
} else if (mb_strlen($selfUrlPathAndQueryPart) > 0) {
$path = $request->GetPath(FALSE);
$requestedUrl = $path === '' ? '/' : $path ;
if (mb_strpos($selfUrlPathAndQueryPart, '?') !== FALSE) {
$selfUrlPathAndQueryPart = rawurldecode($selfUrlPathAndQueryPart);
$requestedUrl .= $request->GetQuery(TRUE, FALSE);
}
if ($selfUrlPathAndQueryPart !== $requestedUrl)
$redirectToCanonicalUrl = TRUE;
}
if ($redirectToCanonicalUrl) {
$selfCanonicalUrl = $this->Url($this->selfRouteName, $this->requestedParams);
$this->redirect($selfCanonicalUrl, \MvcCore\IResponse::MOVED_PERMANENTLY);
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q8109 | UrlRewriteProductCategoryRepository.load | train | public function load($urlRewriteId)
{
// initialize the parameters
$params = array(MemberNames::URL_REWRITE_ID => $urlRewriteId);
// load and return the URL rewrite product category relation
$this->urlRewriteProductCategoryStmt->execute($params);
return $this->urlRewriteProductCategoryStmt->fetch(\PDO::FETCH_ASSOC);
} | php | {
"resource": ""
} |
q8110 | UrlRewriteProductCategoryRepository.findAllBySku | train | public function findAllBySku($sku)
{
// initialize the params
$params = array(MemberNames::SKU => $sku);
// load and return the URL rewrite product category relations for the passed SKU
$this->urlRewriteProductCategoriesBySkuStmt->execute($params);
return $this->urlRewriteProductCategoriesBySkuStmt->fetchAll(\PDO::FETCH_ASSOC);
} | php | {
"resource": ""
} |
q8111 | Player.getStats | train | public function getStats()
{
if ($this->stats) {
return $this->stats;
}
return $this->stats = $this->api->stats($this->getDisplayName());
} | php | {
"resource": ""
} |
q8112 | Player.getCombatLevel | train | public function getCombatLevel($float = false)
{
$stats = $this->getStats();
return $this->api->calculateCombatLevel(
$stats->findByClass(Attack::class)->getLevel(),
$stats->findByClass(Strength::class)->getLevel(),
$stats->findByClass(Magic::class)->getLevel(),
$stats->findByClass(Ranged::class)->getLevel(),
$stats->findByClass(Defence::class)->getLevel(),
$stats->findByClass(Constitution::class)->getLevel(),
$stats->findByClass(Prayer::class)->getLevel(),
$stats->findByClass(Summoning::class)->getLevel(),
$float
);
} | php | {
"resource": ""
} |
q8113 | Reports.init | train | public function init() {
if (VERBOSE) echo 'INIT:' ,PHP_EOL;
if (VERBOSE) echo ' CONNECTING API' ,PHP_EOL;
$this->api->auth();
if (VERBOSE) echo ' API CONNECTED' ,PHP_EOL;
if (VERBOSE) echo ' CONNECTING SQL' ,PHP_EOL;
$this->db->connect();
if (VERBOSE) echo ' SQL CONNECTED' ,PHP_EOL;
if (VERBOSE) echo ' CHECKING PATHS' ,PHP_EOL;
if (DEBUG) echo ' CHECKING TMP DIR AT : '.$this->tmp_dir ,PHP_EOL;
if (!file_exists($this->tmp_dir)) {
throw new Exception("Path for 'tmp_dir' not found at '".$this->tmp_dir."'!");
}
if (DEBUG) echo ' CHECKING DUMP DIR AT : '.$this->dumps_dir ,PHP_EOL;
if (!file_exists($this->dumps_dir)) {
throw new Exception("Path for 'dumps_dir' not found at '".$this->dumps_dir."'!");
}
if (VERBOSE) echo ' PATHS FOUND' ,PHP_EOL;
} | php | {
"resource": ""
} |
q8114 | Reports.importDumps | train | public function importDumps() {
if (VERBOSE) echo 'GETTING DUMP LIST',PHP_EOL;
$dumps = $this->api->api('/reports/dumps', 'GET');
if (VERBOSE) echo 'GOT DUMP LIST',PHP_EOL;
$dumps = array_reverse($dumps);
if (VERBOSE) echo 'EXECUTING DUMPS!',PHP_EOL;
foreach ($dumps as $dump) {
if ($dump['status'] == 1) {
$this->dump($dump['dumpId']);
}
}
} | php | {
"resource": ""
} |
q8115 | Reports.dump | train | public function dump($id) {
if (VERBOSE) echo " DUMP $id" ,PHP_EOL;
$filename = $this->dumps_dir . 'dump-' . $id . '.tar.gz';
if (file_exists($filename)) {
// skip
if (VERBOSE) echo " SKIPPING : $filename exists" ,PHP_EOL;
return false;
} else {
try {
$tgz_data = $this->api->api("/reports/dump/{$id}.tgz", 'GET');
} catch (Exception $e) {
throw new Exception('Could not find dump with id '.$id);
exit;
}
file_put_contents($filename, $tgz_data);
}
$unpacked_files = array();
chdir(dirname($filename));
if (exec("/bin/tar -zxvf $filename -C ".$this->tmp_dir, $output)) {
$injects = array();
foreach ($output as $file) {
$thisFile = $this->tmp_dir . $file;
$unpacked_files[] = $thisFile;
if (file_exists($thisFile)) {
list($model, ) = explode('-', $file);
if (isset($this->modelsToTable[$model])) {
$table = $this->modelsToTable[$model];
} else {
// or auto guess?
if (DEBUG) echo " SKIPPING $model : table not found!" ,PHP_EOL;
continue;
}
$sql = "LOAD DATA INFILE '$thisFile' REPLACE INTO TABLE $table CHARACTER SET utf8 IGNORE 1 LINES";
if (DEBUG) echo PHP_EOL, 'DEBUG : $sql : ' . $sql, PHP_EOL;
$this->db->query($sql);
}
}
} else {
throw new Exception('File uncompression failed for file ' . $filename);
}
foreach ($unpacked_files as $file) {
unlink($file);
}
return true;
} | php | {
"resource": ""
} |
q8116 | Sharpen.setType | train | public function setType($type)
{
if (!array_key_exists($type, self::$Supported)) {
throw new \InvalidArgumentException(sprintf(
'Invalid Sharpen Type "%s"', $type
));
}
$this->type = $type;
} | php | {
"resource": ""
} |
q8117 | Result.seek | train | public function seek($row)
{
switch ($this->mode) {
case "mysql":
$this->result->data_seek($row);
break;
case "postgres":
case "redshift":
pg_result_seek($this->result, $row);
break;
case "odbc":
case "mssqlsrv":
# The odbc driver doesn't support seeking, so we fetch specific rows in getNextRow(), and here all we need to do is set the current position instance variable
break;
case "sqlite":
$this->result->reset();
for ($i = 0; $i < $row; $i++) {
$this->result->fetchArray();
}
break;
case "mssql":
mssql_data_seek($this->result, $row);
break;
}
$this->position = $row;
} | php | {
"resource": ""
} |
q8118 | Result.count | train | public function count()
{
switch ($this->mode) {
case "mysql":
$rows = $this->result->num_rows;
break;
case "postgres":
case "redshift":
$rows = pg_num_rows($this->result);
break;
case "odbc":
$rows = odbc_num_rows($this->result);
# The above function is unreliable, so if we got a zero count then double check it
if ($rows < 1) {
$rows = 0;
/**
* If it is an update/delete then we just have to trust the odbc_num_rows() result,
* however it is some kind of select, then we can manually count the rows returned.
*/
if (odbc_num_fields($this->result) > 0) {
$position = $this->position;
$this->seek(0);
while ($this->getNextRow()) {
++$rows;
}
$this->seek($position);
}
}
break;
case "sqlite":
$rows = 0;
while ($this->result->fetchArray()) {
$rows++;
}
$this->seek($this->position);
break;
case "mssql":
$rows = mssql_num_rows($this->result);
break;
case "mssqlsrv":
$rows = sqlsrv_num_rows($this->result);
break;
}
if ($rows === false || $rows < 0) {
throw new \Exception("Failed to get the row count from the result set");
}
return $rows;
} | php | {
"resource": ""
} |
q8119 | Result.columnCount | train | public function columnCount()
{
switch ($this->mode) {
case "mysql":
$columns = $this->result->field_count;
break;
case "postgres":
case "redshift":
$columns = pg_num_fields($this->result);
break;
case "odbc":
$columns = odbc_num_fields($this->result);
break;
case "sqlite":
$columns = $this->result->numColumns();
break;
case "mssql":
$columns = mssql_num_fields($this->result);
break;
case "mssqlsrv":
$columns = sqlsrv_num_fields($this->result);
break;
}
if ($columns === false || $columns < 0) {
throw new \Exception("Failed to get the column count from the result set");
}
return $columns;
} | php | {
"resource": ""
} |
q8120 | Result.free | train | public function free()
{
switch ($this->mode) {
case "mysql":
$this->result->free();
break;
case "postgres":
case "redshift":
pg_free_result($this->result);
break;
case "odbc":
odbc_free_result($this->result);
break;
case "sqlite":
$this->result->finalize();
break;
case "mssql":
mssql_free_result($this->result);
break;
case "mssqlsrv":
sqlsrv_free_stmt($this->result);
break;
}
} | php | {
"resource": ""
} |
q8121 | Collection.getAssetsOnlyRaw | train | public function getAssetsOnlyRaw($group = null)
{
// Get all the assets for the given group and filter out assets that aren't listed
// as being raw.
$assets = $this->getAssets($group, true)->filter(function($asset)
{
return $asset->isRaw();
});
return $assets;
} | php | {
"resource": ""
} |
q8122 | Collection.getAssets | train | public function getAssets($group = null, $raw = true)
{
// Spin through all of the assets that belong to the given group and push them on
// to the end of the array.
$assets = clone $this->directory->getAssets();
foreach ($assets as $key => $asset)
{
if ( ! $raw and $asset->isRaw() or ! is_null($group) and ! $asset->{'is'.ucfirst(str_singular($group))}())
{
$assets->forget($key);
}
}
// Spin through each of the assets and build an ordered array of assets. Once
// we have the ordered array we'll transform it into a collection and apply
// the collection wide filters to each asset.
$ordered = array();
foreach ($assets as $asset)
{
$this->orderAsset($asset, $ordered);
}
return new \Illuminate\Support\Collection($ordered);
} | php | {
"resource": ""
} |
q8123 | Collection.orderAsset | train | protected function orderAsset(Asset $asset, array &$assets)
{
$order = $asset->getOrder() and $order--;
// If an asset already exists at the given order key then we'll add one to the order
// so the asset essentially appears after the existing asset. This makes sense since
// the array of assets has been reversed, so if the last asset was told to be first
// then when we finally get to the first added asset it's added second.
if (array_key_exists($order, $assets))
{
array_splice($assets, $order, 0, array(null));
}
$assets[$order] = $asset;
ksort($assets);
} | php | {
"resource": ""
} |
q8124 | Builder.build | train | public function build()
{
$this->overseer->clearRoles();
if (isset($this->config['roles'])) {
$this->saveRoles($this->config['roles']);
}
$this->overseer->clearPermissions();
if (isset($this->config['permissions'])) {
$this->savePermissions($this->config['permissions']);
}
$this->overseer->clearAssignments();
if (isset($this->config['assignments'])) {
$this->saveAssignments($this->config['assignments']);
}
} | php | {
"resource": ""
} |
q8125 | HttpResponse.getBody | train | public function getBody() {
if (!isset($this->body)) {
$contentType = $this->getHeader('Content-Type');
if (stripos($contentType, 'application/json') !== false) {
$this->body = json_decode($this->rawBody, true);
} else {
$this->body = $this->rawBody;
}
}
return $this->body;
} | php | {
"resource": ""
} |
q8126 | HttpResponse.isResponseClass | train | public function isResponseClass(string $class): bool {
$pattern = '`^'.str_ireplace('x', '\d', preg_quote($class, '`')).'$`';
$result = preg_match($pattern, $this->statusCode);
return $result === 1;
} | php | {
"resource": ""
} |
q8127 | HttpResponse.setRawBody | train | public function setRawBody(string $body) {
$this->rawBody = $body;
$this->body = null;
return $this;
} | php | {
"resource": ""
} |
q8128 | HttpResponse.setStatus | train | public function setStatus($code, $reasonPhrase = null) {
if (preg_match('`(?:HTTP/([\d.]+)\s+)?(\d{3})\s*(.*)`i', $code, $matches)) {
$this->protocolVersion = $matches[1] ?: $this->protocolVersion;
$code = (int)$matches[2];
$reasonPhrase = $reasonPhrase ?: $matches[3];
}
if (empty($reasonPhrase) && isset(static::$reasonPhrases[$code])) {
$reasonPhrase = static::$reasonPhrases[$code];
}
if (is_numeric($code)) {
$this->setStatusCode((int)$code);
}
$this->setReasonPhrase((string)$reasonPhrase);
return $this;
} | php | {
"resource": ""
} |
q8129 | HttpResponse.parseStatusLine | train | private function parseStatusLine($headers): string {
if (empty($headers)) {
return '';
}
if (is_string($headers)) {
if (preg_match_all('`(?:^|\n)(HTTP/[^\r]+)\r\n`', $headers, $matches)) {
$firstLine = end($matches[1]);
} else {
$firstLine = trim(strstr($headers, "\r\n", true));
}
} else {
$firstLine = (string)reset($headers);
}
// Test the status line.
if (strpos($firstLine, 'HTTP/') === 0) {
return $firstLine;
}
return '';
} | php | {
"resource": ""
} |
q8130 | HttpResponse.offsetGet | train | public function offsetGet($offset) {
$this->getBody();
$result = isset($this->body[$offset]) ? $this->body[$offset] : null;
return $result;
} | php | {
"resource": ""
} |
q8131 | ScriptContainerTrait.withScript | train | public function withScript(ScriptElement $script, $scope = 'header')
{
// These are the only legal values.
assert(in_array($scope, ['header', 'footer']));
$that = clone($this);
$that->scripts[$scope][] = $script;
return $that;
} | php | {
"resource": ""
} |
q8132 | Transformation.rotate | train | public function rotate($degree, ColorInterface $background = null)
{
return $this->apply(new Rotate($degree, $background));
} | php | {
"resource": ""
} |
q8133 | Transformation.watermark | train | public function watermark(CanvasInterface $watermark, Coordinate $cooridnate = null)
{
return $this->apply(new Watermark($watermark, $cooridnate));
} | php | {
"resource": ""
} |
q8134 | Transformation.overlay | train | public function overlay(CanvasInterface $overlay, $mount = 100, Box $box = null)
{
return $this->apply(new Overlay($overlay, $mount, $box));
} | php | {
"resource": ""
} |
q8135 | Transformation.overlayWatermark | train | public function overlayWatermark(CanvasInterface $watermark, Coordinate $cooridnate = null, $mount = 100)
{
return $this->overlay($watermark, $mount, new Box($watermark->getDimension(), $cooridnate));
} | php | {
"resource": ""
} |
q8136 | RewriteRouting.rewriteRouting | train | protected function rewriteRouting ($requestCtrlName, $requestActionName) {
$request = & $this->request;
$requestedPathFirstWord = $this->rewriteRoutingGetReqPathFirstWord();
$this->rewriteRoutingProcessPreHandler($requestedPathFirstWord);
$routes = & $this->rewriteRoutingGetRoutesToMatch($requestedPathFirstWord);
$requestMethod = $request->GetMethod();
foreach ($routes as & $route) {
/** @var $route \MvcCore\Route */
if ($this->rewriteRoutingCheckRoute($route, [$requestMethod])) continue;
$allMatchedParams = $route->Matches($request);
if ($allMatchedParams !== NULL) {
$this->currentRoute = clone $route;
$this->currentRoute->SetMatchedParams($allMatchedParams);
$this->rewriteRoutingSetRequestedAndDefaultParams(
$allMatchedParams, $requestCtrlName, $requestActionName
);
if ($this->rewriteRoutingSetRequestParams($allMatchedParams)) continue;
$this->rewriteRoutingSetUpCurrentRouteByRequest();
break;
}
}
} | php | {
"resource": ""
} |
q8137 | RewriteRouting.rewriteRoutingProcessPreHandler | train | protected function rewriteRoutingProcessPreHandler ($firstPathWord) {
if ($this->preRouteMatchingHandler === NULL) return;
call_user_func($this->preRouteMatchingHandler, $this, $this->request, $firstPathWord);
} | php | {
"resource": ""
} |
q8138 | RewriteRouting.& | train | protected function & rewriteRoutingGetRoutesToMatch ($firstPathWord) {
if (isset($this->routesGroups[$firstPathWord])) {
$routes = & $this->routesGroups[$firstPathWord];
} else if (isset($this->routesGroups[''])) {
$routes = & $this->routesGroups[''];
} else {
$routes = [];
}
reset($routes);
return $routes;
} | php | {
"resource": ""
} |
q8139 | RewriteRouting.rewriteRoutingCheckRoute | train | protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) {
list ($requestMethod,) = $additionalInfo;
$routeMethod = $route->GetMethod();
if ($routeMethod !== NULL && $routeMethod !== $requestMethod) return TRUE;
return FALSE;
} | php | {
"resource": ""
} |
q8140 | RewriteRouting.rewriteRoutingSetRequestedAndDefaultParams | train | protected function rewriteRoutingSetRequestedAndDefaultParams (array & $allMatchedParams, $requestCtrlName = NULL, $requestActionName = NULL) {
/** @var $this \MvcCore\Router */
// in array `$allMatchedParams` - there could be sometimes presented matched
// or route specified values from configuration already, under keys `controller` and
// `action`, always with a value, never with `NULL`
/** @var $request \MvcCore\Request */
$request = & $this->request;
$rawQueryParams = array_merge([], $request->GetParams(FALSE));
// complete controller and action from any possible source
list($ctrlDfltNamePc, $actionDfltNamePc) = $this->application->GetDefaultControllerAndActionNames();
$toolClass = self::$toolClass;
if ($requestCtrlName !== NULL) {
$request->SetControllerName($requestCtrlName);
$allMatchedParams[static::URL_PARAM_CONTROLLER] = $requestCtrlName;
$rawQueryParams[static::URL_PARAM_CONTROLLER] = $requestCtrlName;
} else if (isset($allMatchedParams[static::URL_PARAM_CONTROLLER])) {
$request->SetControllerName($allMatchedParams[static::URL_PARAM_CONTROLLER]);
} else {
$defaultCtrlNameDashed = $toolClass::GetDashedFromPascalCase($ctrlDfltNamePc);
$request->SetControllerName($defaultCtrlNameDashed);
$allMatchedParams[static::URL_PARAM_CONTROLLER] = $defaultCtrlNameDashed;
}
if ($requestActionName !== NULL) {
$request->SetActionName($requestActionName);
$allMatchedParams[static::URL_PARAM_ACTION] = $requestActionName;
$rawQueryParams[static::URL_PARAM_ACTION] = $requestActionName;
} else if (isset($allMatchedParams[static::URL_PARAM_ACTION])) {
$request->SetActionName($allMatchedParams[static::URL_PARAM_ACTION]);
} else {
$defaultActionNameDashed = $toolClass::GetDashedFromPascalCase($actionDfltNamePc);
$request->SetActionName($defaultActionNameDashed);
$allMatchedParams[static::URL_PARAM_ACTION] = $defaultActionNameDashed;
}
// complete params for request object - there have to be everything including ctrl and action
$this->defaultParams = array_merge(
// default params are merged with previous default params to have
// possibility to add domain params by extended module router
$this->currentRoute->GetDefaults(), $this->defaultParams,
$allMatchedParams, $rawQueryParams
);
// redirect route with strictly defined match regular expression and not defined reverse could have `NULL` method result:
$routeReverseParams = $this->currentRoute->GetReverseParams() ?: [];
// complete really matched params from path - unset ctrl and action if ctrl and even action are not in pattern
$pathOnlyMatchedParams = array_merge([], $allMatchedParams);
$controllerInReverse = in_array(static::URL_PARAM_CONTROLLER, $routeReverseParams, TRUE);
$actionInReverse = in_array(static::URL_PARAM_ACTION, $routeReverseParams, TRUE);
if (!$controllerInReverse) unset($pathOnlyMatchedParams[static::URL_PARAM_CONTROLLER]);
if (!$actionInReverse) unset($pathOnlyMatchedParams[static::URL_PARAM_ACTION]);
// requested params - all really requested params for self URL addresses
// building base params array, parsed from path, merged with all query params
// and merged later with given params array into method `Url()`.
// There cannot be `controller` and `action` keys from route configuration,
// only if ctrl and action is defined by query string, that's different
$this->requestedParams = array_merge([], $pathOnlyMatchedParams, $rawQueryParams);
} | php | {
"resource": ""
} |
q8141 | RewriteRouting.rewriteRoutingSetRequestParams | train | protected function rewriteRoutingSetRequestParams (array & $allMatchedParams) {
$request = & $this->request;
$defaultParamsBefore = array_merge([], $this->defaultParams);
$requestParams = array_merge([], $this->defaultParams);
// filter request params
list($success, $requestParamsFiltered) = $this->currentRoute->Filter(
$requestParams, $this->defaultParams, \MvcCore\IRoute::CONFIG_FILTER_IN
);
if ($success === FALSE) {
$this->defaultParams = $defaultParamsBefore;
$this->requestedParams = [];
$allMatchedParams = NULL;
$this->currentRoute = NULL;
return TRUE;
}
$requestParamsFiltered = $requestParamsFiltered ?: $requestParams;
$request->SetParams($requestParamsFiltered);
if (isset($requestParamsFiltered[static::URL_PARAM_CONTROLLER]))
$request->SetControllerName($requestParamsFiltered[static::URL_PARAM_CONTROLLER]);
if (isset($requestParamsFiltered[static::URL_PARAM_ACTION]))
$request->SetActionName($requestParamsFiltered[static::URL_PARAM_ACTION]);
return FALSE;
} | php | {
"resource": ""
} |
q8142 | RewriteRouting.rewriteRoutingSetUpCurrentRouteByRequest | train | protected function rewriteRoutingSetUpCurrentRouteByRequest () {
$request = & $this->request;
$toolClass = self::$toolClass;
$this->currentRoute
->SetController(str_replace(['/', '\\\\'], ['\\', '//'],
$toolClass::GetPascalCaseFromDashed($request->GetControllerName())
))
->SetAction(
$toolClass::GetPascalCaseFromDashed($request->GetActionName())
);
} | php | {
"resource": ""
} |
q8143 | Timing.time | train | public function time(string $name, string $message = null): TimerContract
{
$id = isset($this->timers[$name]) ? \uniqid($name) : $name;
$this->timers[$id] = $this->createTimer($name, \microtime(true), $message);
return $this->timers[$id];
} | php | {
"resource": ""
} |
q8144 | Timing.timeEnd | train | public function timeEnd($name = null): void
{
$timer = $name instanceof TimerContract ? $name : $this->resolveTimerFromName($name);
$timer->end();
} | php | {
"resource": ""
} |
q8145 | Timing.resolveTimerFromName | train | protected function resolveTimerFromName(string $name = null): TimerContract
{
$id = \is_null($name) ? \uniqid() : $name;
if (isset($this->timers[$id])) {
return $this->timers[$id];
}
return $this->createTimer($name, constant('LARAVEL_START'));
} | php | {
"resource": ""
} |
q8146 | Timing.createTimer | train | protected function createTimer(string $name, $startedAt, string $message = null): TimerContract
{
return (new Timer($name, $startedAt, $message))->setLogger($this->getLogger());
} | php | {
"resource": ""
} |
q8147 | CollectionsMethods.HasHeader | train | public function HasHeader ($name = '') {
if ($this->headers === NULL) $this->initHeaders();
return isset($this->headers[$name]);
} | php | {
"resource": ""
} |
q8148 | CollectionsMethods.& | train | public function & SetParam ($name = '', $value = '') {
/** @var $this \MvcCore\Request */
if ($this->params === NULL) $this->initParams();
$this->params[$name] = $value;
return $this;
} | php | {
"resource": ""
} |
q8149 | CollectionsMethods.& | train | public function & RemoveParam ($name = '') {
/** @var $this \MvcCore\Request */
if ($this->params === NULL) $this->initParams();
unset($this->params[$name]);
return $this;
} | php | {
"resource": ""
} |
q8150 | Entry.addDevelopmentAsset | train | public function addDevelopmentAsset($value, $fingerprint = null, $group = null)
{
if ($value instanceof Asset)
{
$group = $value->getGroup();
$fingerprint = $value->getBuildPath();
$value = $value->getRelativePath();
}
$this->development[$group][$value] = $fingerprint;
} | php | {
"resource": ""
} |
q8151 | Entry.getDevelopmentAsset | train | public function getDevelopmentAsset($value, $group = null)
{
if ($value instanceof Asset)
{
$group = $value->getGroup();
$value = $value->getRelativePath();
}
return isset($this->development[$group][$value]) ? $this->development[$group][$value] : null;
} | php | {
"resource": ""
} |
q8152 | Entry.getDevelopmentAssets | train | public function getDevelopmentAssets($group = null)
{
return is_null($group) ? $this->development : $this->development[$group];
} | php | {
"resource": ""
} |
q8153 | Entry.hasDevelopmentAssets | train | public function hasDevelopmentAssets($group = null)
{
return is_null($group) ? ! empty($this->development) : ! empty($this->development[$group]);
} | php | {
"resource": ""
} |
q8154 | Entry.resetDevelopmentAssets | train | public function resetDevelopmentAssets($group = null)
{
if (is_null($group))
{
$this->development = array();
}
else
{
$this->development[$group] = array();
}
} | php | {
"resource": ""
} |
q8155 | Entry.getProductionFingerprint | train | public function getProductionFingerprint($group)
{
return isset($this->fingerprints[$group]) ? $this->fingerprints[$group] : null;
} | php | {
"resource": ""
} |
q8156 | Filter.findMissingConstructorArgs | train | public function findMissingConstructorArgs()
{
try
{
$class = new ReflectionClass($this->getClassName());
}
catch (ReflectionException $e)
{
return $this;
}
if ($constructor = $class->getConstructor())
{
$finder = $this->getExecutableFinder();
// Spin through all of the constructor parameters and for those that we can find the executable
// path for we'll attempt to locate the executable. If we can't find the path then its more
// then we'll ignore this filter as it will fail during the build.
foreach ($constructor->getParameters() as $key => $parameter)
{
if ($this->hasArgumentAtPosition($key))
{
continue;
}
$snakeParameter = $this->normalizeConstructorParameter($parameter->name);
list($name, $suffix) = explode('_', $snakeParameter);
// If the suffix is in the array of valid suffixes we can attempt to locate the parameter
// first as an environment variable and secondly by recursively searching through our
// paths defined in PATH. If we can't find it then ignore the filter.
if (in_array($suffix, $this->validSuffixes))
{
$path = $this->getEnvironmentVariable($snakeParameter) ?: $finder->find($name);
if ($path)
{
$this->setArgument($path, $key);
}
else
{
// There was a problem locating the path to the argument, we'll log that the
// filter was ignored here so that the developer can debug this better.
$this->log->error(sprintf('Failed to find required constructor argument for filter "%s". (%s)', $this->filter, $parameter));
$this->ignored = true;
}
}
elseif(str_is('nodePaths', $parameter->name))
{
$this->setArgument($this->nodePaths, $key);
}
}
}
return $this;
} | php | {
"resource": ""
} |
q8157 | Filter.whenAssetIs | train | public function whenAssetIs($pattern)
{
return $this->when(function($asset) use ($pattern)
{
return (bool) preg_match('#'.$pattern.'#', $asset->getRelativePath());
});
} | php | {
"resource": ""
} |
q8158 | Filter.whenEnvironmentIs | train | public function whenEnvironmentIs()
{
$environments = func_get_args();
$appEnvironment = $this->appEnvironment;
return $this->when(function($asset) use ($environments, $appEnvironment)
{
return in_array($appEnvironment, $environments);
});
} | php | {
"resource": ""
} |
q8159 | Filter.setArgument | train | public function setArgument($argument, $position = null)
{
array_splice($this->arguments, $position ?: count($this->arguments), 0, array($argument));
return $this;
} | php | {
"resource": ""
} |
q8160 | Filter.getInstance | train | public function getInstance()
{
if ( ! $class = $this->getClassName())
{
$this->log->error(sprintf('"%s" will not be applied to asset "%s" due to an invalid filter name.', $this->filter, $this->resource->getRelativePath()));
}
if ($this->ignored or is_null($class) or ! $this->processRequirements()) return;
// If the class returned is already implements Assetic\Filter\FilterInterface then
// we can set the instance directly and not worry about using reflection.
if ($class instanceof FilterInterface)
{
$instance = $class;
}
else
{
$reflection = new ReflectionClass($class);
// If no constructor is available on the filters class then we'll instantiate
// the filter without passing in any arguments.
if ( ! $reflection->getConstructor())
{
$instance = $reflection->newInstance();
}
else
{
$instance = $reflection->newInstanceArgs($this->arguments);
}
}
// Spin through each of the before filtering callbacks and fire each one. We'll
// pass in an instance of the filter to the callback.
foreach ($this->before as $callback)
{
if (is_callable($callback))
{
call_user_func($callback, $instance);
}
}
return $instance;
} | php | {
"resource": ""
} |
q8161 | Filter.processRequirements | train | public function processRequirements()
{
foreach ($this->requirements as $requirement)
{
if ( ! call_user_func($requirement, $this->resource, $this))
{
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q8162 | CacheListClassLoader.loadClass | train | public function loadClass($class)
{
$result = $this->loadCachedClass($class);
if ($result === false) {
$result = parent::loadClass($class);
}
if ($this->verbose) {
return $result !== false;
}
} | php | {
"resource": ""
} |
q8163 | CacheListClassLoader.loadCachedClass | train | private function loadCachedClass($class)
{
$result = false;
if (isset($this->cache[$class])) {
$result = include $this->cache[$class];
if ($result === false) {
unset($this->cache[$class]);
$this->saveCache();
}
}
return $result !== false;
} | php | {
"resource": ""
} |
q8164 | CacheListClassLoader.loadFile | train | protected function loadFile($file, $class)
{
parent::loadFile($file, $class);
$this->cache[$class] = $file;
$this->saveCache();
return true;
} | php | {
"resource": ""
} |
q8165 | Polygon.addCoordinate | train | public function addCoordinate(Coordinate $coordinate)
{
$this->coordinates[] = $coordinate;
$this->setNumber(count($this->coordinates));
return $this;
} | php | {
"resource": ""
} |
q8166 | Polygon.setCoordinate | train | public function setCoordinate(\ArrayObject $coordinates)
{
$this->coordinates = $coordinates;
$this->setNumber(count($coordinates));
return $this;
} | php | {
"resource": ""
} |
q8167 | Polygon.setNumber | train | public function setNumber($num)
{
$num = (int) $num;
if ($num <= 0) {
throw new \InvalidArgumentException(sprintf(
'Invalid Number "%s" - Polygon Coordinates Number Must Be '
. 'Greater Than Zero'
, $num
));
}
$count = count($this->getCoordinates());
if ($num > $count) {
throw new \OutOfBoundsException(sprintf(
'Given Coodrinates Number "%s" Is Greater Than The Actual '
. 'Coordinates Array Size "%s"'
, $num, $count
));
}
$this->count = $num;
return $this;
} | php | {
"resource": ""
} |
q8168 | Polygon.assertPointsArrayLength | train | private function assertPointsArrayLength()
{
if (count($this->getCoordinates()) < self::$MIN_LENGTH) {
throw new \RuntimeException(sprintf(
'There Must Be At Least "%s" Coordinates To Draw A Polygon'
, self::$MIN_LENGTH
));
}
} | php | {
"resource": ""
} |
q8169 | CanBeLiked.likeIt | train | public function likeIt($user = null)
{
if (!$this->isLiked()) {
$this->likes()->create([
'user_id'=> $user ? $user->id : auth()->id()
]);
$this->incrementCount();
}
} | php | {
"resource": ""
} |
q8170 | CanBeLiked.unLikeIt | train | public function unLikeIt($user = null)
{
if ($like = $this->isLiked($user)) {
$like->delete();
$this->decrementCount();
}
} | php | {
"resource": ""
} |
q8171 | CanBeLiked.isLiked | train | public function isLiked($user = null)
{
return $this->likes()->where([
'user_id' => $user ? $user->id : auth()->id(),
'likeable_type' => get_class($this),
'likeable_id' => $this->id
])->first();
} | php | {
"resource": ""
} |
q8172 | CanBeLiked.toggleLike | train | public function toggleLike($user = null)
{
$this->isLiked($user) ? $this->unLikeIt($user) : $this->likeIt($user);
} | php | {
"resource": ""
} |
q8173 | Flatten.byObjectMethod | train | public static function byObjectMethod($values, $method)
{
if (isset($values) && Inspector::isTraversable($values)) {
if (is_array($values)) {
$flat_values = array();
$setter = 'setArrayValue';
} else {
$flat_values = new \stdClass();
$setter = 'setObjectValue';
}
foreach ($values as $key => $value) {
if (is_object($value) && method_exists($value, $method)) {
$flat_value = $value->{$method}();
static::$setter($flat_values, $key, $flat_value);
} else {
static::$setter($flat_values, $key, $value);
}
}
return $flat_values;
}
return $values;
} | php | {
"resource": ""
} |
q8174 | Repository.find | train | public function find($id)
{
return Arr::first($this->items, function ($key, Contract $skill) use ($id) {
return $skill->getId() === $id;
}, null);
} | php | {
"resource": ""
} |
q8175 | Repository.findByName | train | public function findByName($name)
{
return Arr::first($this->items, function ($key, Contract $skill) use ($name) {
return $skill->getName() === strtolower($name);
}, null);
} | php | {
"resource": ""
} |
q8176 | Generator.calcMod10V1 | train | public function calcMod10V1(string $number, string $separator = "", int $minimumLength = 6): string
{
$revstr = strrev((string) intval($number));
$revstrLen = strlen($revstr);
$total = 0;
for ($i = 0; $i < $revstrLen; $i++) {
if ($i % 2 == 0) {
$multiplier = 2;
} else {
$multiplier = 1;
}
$subtotal = intval($revstr[$i]) * $multiplier;
if ($subtotal >= 10) {
$temp = (string) $subtotal;
$subtotal = intval($temp[0]) + intval($temp[1]);
}
$total += $subtotal;
}
$checkDigit = (10 - ($total % 10)) % 10;
$crn = str_pad(ltrim($number, "0"), $minimumLength - 1, "0", STR_PAD_LEFT) . $separator . $checkDigit;
return $crn;
} | php | {
"resource": ""
} |
q8177 | Request.getCurrentRoute | train | protected function getCurrentRoute(): string
{
$request = resolve(HttpRequest::class);
$method = strtoupper($request->getMethod());
$path = ltrim($request->path(), '/');
$host = $request->getHost();
! is_null($host) && $host = rtrim($host, '/');
return "{$method} {$host}/{$path}";
} | php | {
"resource": ""
} |
q8178 | Gamma.setLevel | train | public function setLevel($level)
{
if (!($level >= 0.01 && $level <= 4.99)) {
throw new \InvalidArgumentException("Gamma Level Must Be In Range(0.01,4.99)");
}
$this->level = (float) $level;
return $this;
} | php | {
"resource": ""
} |
q8179 | ModuleMakeCommand.createConfigFile | train | protected function createConfigFile(string $name): void
{
$file = base_path($this->moduleName().'/'.$name.'/Config/config.php');
if (! $this->files->exists($file)) {
$this->files->put($file, $this->files->get(__DIR__.'/stubs/config.stub'));
}
} | php | {
"resource": ""
} |
q8180 | Rating.getFieldDefinition | train | public function getFieldDefinition($arrOverrides = [])
{
$arrFieldDef = parent::getFieldDefinition($arrOverrides);
$arrFieldDef['inputType'] = 'text';
// We must not change the value.
$arrFieldDef['eval']['disabled'] = true;
return $arrFieldDef;
} | php | {
"resource": ""
} |
q8181 | Rating.getDataFor | train | public function getDataFor($arrIds)
{
$statement = $this->connection->createQueryBuilder()
->select('*')
->from('tl_metamodel_rating')
->andWhere('mid=:mid AND aid=:aid AND iid IN (:iids)')
->setParameter('mid', $this->getMetaModel()->get('id'))
->setParameter('aid', $this->get('id'))
->setParameter('iids', $arrIds, Connection::PARAM_STR_ARRAY)
->execute();
$arrResult = [];
while ($objData = $statement->fetch(\PDO::FETCH_OBJ)) {
$arrResult[$objData->iid] = [
'votecount' => (int) $objData->votecount,
'meanvalue' => (float) $objData->meanvalue,
];
}
foreach (\array_diff($arrIds, \array_keys($arrResult)) as $intId) {
$arrResult[$intId] = [
'votecount' => 0,
'meanvalue' => 0,
];
}
return $arrResult;
} | php | {
"resource": ""
} |
q8182 | Rating.unsetDataFor | train | public function unsetDataFor($arrIds)
{
$this->connection->createQueryBuilder()
->delete('tl_metamodel_rating')
->andWhere('mid=:mid AND aid=:aid AND iid IN (:iids)')
->setParameter('mid', $this->getMetaModel()->get('id'))
->setParameter('aid', $this->get('id'))
->setParameter('iids', $arrIds, Connection::PARAM_STR_ARRAY)
->execute();
} | php | {
"resource": ""
} |
q8183 | Rating.addVote | train | public function addVote($intItemId, $fltValue, $blnLock = false)
{
if ($this->getSessionBag()->get($this->getLockId($intItemId))) {
return;
}
$arrData = $this->getDataFor([$intItemId]);
if (!$arrData || !$arrData[$intItemId]['votecount']) {
$voteCount = 0;
$prevPercent = 0;
} else {
$voteCount = $arrData[$intItemId]['votecount'];
$prevPercent = (float) $arrData[$intItemId]['meanvalue'];
}
$grandTotal = ($voteCount * $this->get('rating_max') * $prevPercent);
$hundred = ($this->get('rating_max') * (++$voteCount));
// Calculate the percentage.
$value = (1 / $hundred * ($grandTotal + $fltValue));
$arrSet = [
'mid' => $this->getMetaModel()->get('id'),
'aid' => $this->get('id'),
'iid' => $intItemId,
'votecount' => $voteCount,
'meanvalue' => $value,
];
$queryBuilder = $this->connection->createQueryBuilder();
if (!$arrData || !$arrData[$intItemId]['votecount']) {
$queryBuilder
->insert('tl_metamodel_rating')
->values($arrSet);
} else {
foreach ($arrSet as $key => $value) {
$queryBuilder
->set($key, ':' . $key)
->setParameter($key, $value);
}
$queryBuilder
->update('tl_metamodel_rating')
->andWhere('mid=:mid AND aid=:aid AND iid=:iid')
->setParameter('mid', $this->getMetaModel()->get('id'))
->setParameter('aid', $this->get('id'))
->setParameter('iid', $intItemId);
}
$queryBuilder->execute();
if ($blnLock) {
$this->getSessionBag()->set($this->getLockId($intItemId), true);
}
} | php | {
"resource": ""
} |
q8184 | Rating.ensureImage | train | protected function ensureImage($uuidImage, $strDefault)
{
$imagePath = ToolboxFile::convertValueToPath($uuidImage);
if (\strlen($imagePath) && \file_exists(TL_ROOT . '/' . $imagePath)) {
return $imagePath;
}
return $strDefault;
} | php | {
"resource": ""
} |
q8185 | Rating.prepareTemplate | train | public function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings)
{
parent::prepareTemplate($objTemplate, $arrRowData, $objSettings);
$base = Environment::get('base');
$lang = $this->getActiveLanguageArray();
$strEmpty = $this->ensureImage(
$this->get('rating_emtpy'),
'bundles/metamodelsattributerating/star-empty.png'
);
$strFull = $this->ensureImage(
$this->get('rating_full'),
'bundles/metamodelsattributerating/star-full.png'
);
$strHover = $this->ensureImage(
$this->get('rating_hover'),
'bundles/metamodelsattributerating/star-hover.png'
);
if (\file_exists(TL_ROOT . '/' . $strEmpty)) {
$size = \getimagesize(TL_ROOT . '/' . $strEmpty);
} else {
$size = \getimagesize(TL_ROOT . '/web/' . $strEmpty);
}
$objTemplate->imageWidth = $size[0];
$objTemplate->rateHalf = $this->get('rating_half') ? 'true' : 'false';
$objTemplate->name = 'rating_attribute_'.$this->get('id').'_'.$arrRowData['id'];
$objTemplate->ratingDisabled = (
$this->scopeDeterminator->currentScopeIsBackend()
|| $objSettings->get('rating_disabled')
|| $this->getSessionBag()->get($this->getLockId($arrRowData['id']))
);
$value = ($this->get('rating_max') * (float) $arrRowData[$this->getColName()]['meanvalue']);
$intInc = \strlen($this->get('rating_half')) ? .5 : 1;
$objTemplate->currentValue = (\round(($value / $intInc), 0) * $intInc);
$objTemplate->tipText = \sprintf(
$lang['metamodel_rating_label'],
'[VALUE]',
$this->get('rating_max')
);
$objTemplate->ajaxUrl = $this->router->generate('metamodels.attribute_rating.rate');
$objTemplate->ajaxData = \json_encode(
[
'id' => $this->get('id'),
'pid' => $this->get('pid'),
'item' => $arrRowData['id'],
]
);
$arrOptions = [];
$intValue = $intInc;
while ($intValue <= $this->get('rating_max')) {
$arrOptions[] = $intValue;
$intValue += $intInc;
}
$objTemplate->options = $arrOptions;
$objTemplate->imageEmpty = $base.$strEmpty;
$objTemplate->imageFull = $base.$strFull;
$objTemplate->imageHover = $base.$strHover;
} | php | {
"resource": ""
} |
q8186 | Rating.sortIds | train | public function sortIds($idList, $strDirection)
{
$statement = $this->connection->createQueryBuilder()
->select('iid')
->from('tl_metamodel_rating')
->andWhere('mid=:mid AND aid=:aid AND iid IN (:iids)')
->setParameter('mid', $this->getMetaModel()->get('id'))
->setParameter('aid', $this->get('id'))
->setParameter('iids', $idList, Connection::PARAM_STR_ARRAY)
->orderBy('meanvalue', $strDirection)
->execute();
$arrSorted = $statement->fetchAll(\PDO::FETCH_COLUMN, 'iid');
return ($strDirection == 'DESC')
? \array_merge($arrSorted, \array_diff($idList, $arrSorted))
: \array_merge(\array_diff($idList, $arrSorted), $arrSorted);
} | php | {
"resource": ""
} |
q8187 | Rating.getSessionBag | train | protected function getSessionBag()
{
if ($this->scopeDeterminator->currentScopeIsBackend()) {
return $this->session->getBag('contao_backend');
}
if ($this->scopeDeterminator->currentScopeIsFrontend()) {
return $this->session->getBag('contao_frontend');
}
return $this->session->getBag('attributes');
} | php | {
"resource": ""
} |
q8188 | GettersSetters.GetMicrotime | train | public function GetMicrotime () {
if ($this->microtime === NULL) $this->microtime = $this->globalServer['REQUEST_TIME_FLOAT'];
return $this->microtime;
} | php | {
"resource": ""
} |
q8189 | GettersSetters.& | train | public function & SetTopLevelDomain ($topLevelDomain) {
/** @var $this \MvcCore\Request */
if ($this->domainParts === NULL) $this->initDomainSegments();
$this->domainParts[2] = $topLevelDomain;
$this->hostName = trim(implode('.', $this->domainParts), '.');
if ($this->hostName && $this->portDefined)
$this->host = $this->hostName . ':' . $this->port;
$this->domainUrl = NULL;
$this->baseUrl = NULL;
$this->requestUrl = NULL;
$this->fullUrl = NULL;
return $this;
} | php | {
"resource": ""
} |
q8190 | Environment.collection | train | public function collection(string $identifier, ?Closure $callback = null) : Collection {
if ( ! isset($this->collections[$identifier])) {
$directory = $this->prepareDefaultDirectory();
$this->collections[$identifier] = new Collection($directory, $identifier);
}
// If the collection has been given a callable closure then we'll execute the closure with
// the collection instance being the only parameter given. This allows users to begin
// using the collection instance to add assets.
if (is_callable($callback)) {
call_user_func($callback, $this->collections[$identifier]);
}
return $this->collections[$identifier];
} | php | {
"resource": ""
} |
q8191 | Environment.prepareDefaultDirectory | train | protected function prepareDefaultDirectory() : Directory {
$path = $this->finder->setWorkingDirectory('/');
return new Directory($this->factory, $this->finder, $path);
} | php | {
"resource": ""
} |
q8192 | Environment.package | train | public function package(string $package, ?string $namespace = null) : void {
if (is_null($namespace)) {
list($vendor, $namespace) = explode('/', $package);
}
$this->finder->addNamespace($namespace, $package);
} | php | {
"resource": ""
} |
q8193 | Environment.collections | train | public function collections(array $collections) : void {
foreach ($collections as $name => $callback) {
$this->make($name, $callback);
}
} | php | {
"resource": ""
} |
q8194 | Environment.offsetGet | train | public function offsetGet($offset) : ?Collection {
return $this->has($offset) ? $this->collection($offset) : null;
} | php | {
"resource": ""
} |
q8195 | FilterFactory.make | train | public function make($filter)
{
if ($filter instanceof Filter)
{
return clone $filter;
}
$filter = isset($this->aliases[$filter]) ? $this->aliases[$filter] : $filter;
if (is_array($filter))
{
list($filter, $callback) = array(current($filter), next($filter));
}
// If the filter was aliased and the value of the array was a callable closure then
// we'll return and fire the callback on the filter instance so that any arguments
// can be set for the filters constructor.
$filter = new Filter($this->log, $filter, $this->nodePaths, $this->appEnvironment);
if (isset($callback) and is_callable($callback))
{
call_user_func($callback, $filter);
}
return $filter;
} | php | {
"resource": ""
} |
q8196 | AbstractResult.getValues | train | public function getValues()
{
while ($row = $this->getNextRow()) {
if ($this->columnCount() > 1) {
$key = rtrim(reset($row));
$val = rtrim(next($row));
yield $key => $val;
} else {
yield rtrim(reset($row));
}
}
} | php | {
"resource": ""
} |
q8197 | AbstractResult.groupBy | train | public function groupBy(...$keys)
{
$data = [];
while ($row = $this->getNextRow()) {
$position = &$data;
foreach ($keys as $key) {
if (is_callable($key)) {
$value = $key($row);
} else {
$value = $row[$key];
}
if (!array_key_exists($value, $position)) {
$position[$value] = [];
}
$position = &$position[$value];
}
$position[] = $row;
unset($position);
}
return $data;
} | php | {
"resource": ""
} |
q8198 | Helpers.IsErrorDispatched | train | public function IsErrorDispatched () {
$toolClass = $this->toolClass;
$defaultCtrlName = $toolClass::GetDashedFromPascalCase($this->defaultControllerName);
$errorActionName = $toolClass::GetDashedFromPascalCase($this->defaultControllerErrorActionName);
return $this->request->GetControllerName() == $defaultCtrlName &&
$this->request->GetActionName() == $errorActionName;
} | php | {
"resource": ""
} |
q8199 | Helpers.IsNotFoundDispatched | train | public function IsNotFoundDispatched () {
$toolClass = $this->toolClass;
$defaultCtrlName = $toolClass::GetDashedFromPascalCase($this->defaultControllerName);
$errorActionName = $toolClass::GetDashedFromPascalCase($this->defaultControllerNotFoundActionName);
return $this->request->GetControllerName() == $defaultCtrlName &&
$this->request->GetActionName() == $errorActionName;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.