_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | 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);
}
| php | {
"resource": ""
} |
q8101 | XMLAssertTrait.assertXMLValid | train | public static function assertXMLValid($XML, string $message = '')
{
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLValid', | php | {
"resource": ""
} |
q8102 | BlendableLoader.getBlendablePlugin | train | public function getBlendablePlugin($name)
{
/** @var \LCI\Blend\Blendable\Plugin $plugin */ | php | {
"resource": ""
} |
q8103 | BlendableLoader.getBlendableSnippet | train | public function getBlendableSnippet($name)
{
/** @var Snippet $snippet */
$snippet = new Snippet($this->modx, $this->blender, $name);
| php | {
"resource": ""
} |
q8104 | BlendableLoader.getBlendableTemplate | train | public function getBlendableTemplate($name)
{
/** @var \LCI\Blend\Blendable\Template $template */
| php | {
"resource": ""
} |
q8105 | BlendableLoader.getBlendableTemplateVariable | train | public function getBlendableTemplateVariable($name)
{
/** @var \LCI\Blend\Blendable\TemplateVariable $tv */
| 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]);
| 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 = | 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 ( | 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 | 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
| php | {
"resource": ""
} |
q8111 | Player.getStats | train | public function getStats()
{
if ($this->stats) {
return $this->stats;
}
| 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(),
| 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."'!");
}
| 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; | 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)) {
| php | {
"resource": ""
} |
q8116 | Sharpen.setType | train | public function setType($type)
{
if (!array_key_exists($type, self::$Supported)) {
throw new \InvalidArgumentException(sprintf(
| 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":
| 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":
| 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);
| 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":
| 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.
| 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 | 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
| 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']);
}
| php | {
"resource": ""
} |
q8125 | HttpResponse.getBody | train | public function getBody() {
if (!isset($this->body)) {
$contentType = $this->getHeader('Content-Type');
if (stripos($contentType, 'application/json') !== | php | {
"resource": ""
} |
q8126 | HttpResponse.isResponseClass | train | public function isResponseClass(string $class): bool {
$pattern = '`^'.str_ireplace('x', '\d', preg_quote($class, '`')).'$`';
| php | {
"resource": ""
} |
q8127 | HttpResponse.setRawBody | train | public function setRawBody(string $body) {
$this->rawBody = $body;
| 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) | 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 {
| php | {
"resource": ""
} |
q8130 | HttpResponse.offsetGet | train | public function offsetGet($offset) {
$this->getBody();
| 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']));
| php | {
"resource": ""
} |
q8132 | Transformation.rotate | train | public function rotate($degree, ColorInterface $background = | php | {
"resource": ""
} |
q8133 | Transformation.watermark | train | public function watermark(CanvasInterface $watermark, Coordinate $cooridnate = | php | {
"resource": ""
} |
q8134 | Transformation.overlay | train | public function overlay(CanvasInterface $overlay, $mount = 100, Box $box = null)
{
return | php | {
"resource": ""
} |
q8135 | Transformation.overlayWatermark | train | public function overlayWatermark(CanvasInterface $watermark, Coordinate $cooridnate = null, $mount | 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 = | php | {
"resource": ""
} |
q8137 | RewriteRouting.rewriteRoutingProcessPreHandler | train | protected function rewriteRoutingProcessPreHandler ($firstPathWord) {
if ($this->preRouteMatchingHandler === NULL) return;
| php | {
"resource": ""
} |
q8138 | RewriteRouting.& | train | protected function & rewriteRoutingGetRoutesToMatch ($firstPathWord) {
if (isset($this->routesGroups[$firstPathWord])) {
$routes = & $this->routesGroups[$firstPathWord];
} else if (isset($this->routesGroups[''])) | php | {
"resource": ""
} |
q8139 | RewriteRouting.rewriteRoutingCheckRoute | train | protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) {
list ($requestMethod,) = $additionalInfo;
$routeMethod = $route->GetMethod();
| 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;
| 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; | php | {
"resource": ""
} |
q8142 | RewriteRouting.rewriteRoutingSetUpCurrentRouteByRequest | train | protected function rewriteRoutingSetUpCurrentRouteByRequest () {
$request = & $this->request;
$toolClass = self::$toolClass;
$this->currentRoute
->SetController(str_replace(['/', '\\\\'], ['\\', '//'],
| php | {
"resource": ""
} |
q8143 | Timing.time | train | public function time(string $name, string $message = null): TimerContract
{
$id = isset($this->timers[$name]) ? | php | {
"resource": ""
} |
q8144 | Timing.timeEnd | train | public function timeEnd($name = null): void
{
$timer = $name instanceof TimerContract ? $name | php | {
"resource": ""
} |
q8145 | Timing.resolveTimerFromName | train | protected function resolveTimerFromName(string $name = null): TimerContract
{
$id = \is_null($name) ? \uniqid() : $name;
if (isset($this->timers[$id])) {
| php | {
"resource": ""
} |
q8146 | Timing.createTimer | train | protected function createTimer(string $name, $startedAt, string $message = null): TimerContract | php | {
"resource": ""
} |
q8147 | CollectionsMethods.HasHeader | train | public function HasHeader ($name = '') {
if ($this->headers === NULL) $this->initHeaders();
| php | {
"resource": ""
} |
q8148 | CollectionsMethods.& | train | public function & SetParam ($name = '', $value = '') {
/** @var $this \MvcCore\Request | php | {
"resource": ""
} |
q8149 | CollectionsMethods.& | train | public function & RemoveParam ($name = '') {
/** @var $this \MvcCore\Request | php | {
"resource": ""
} |
q8150 | Entry.addDevelopmentAsset | train | public function addDevelopmentAsset($value, $fingerprint = null, $group = null)
{
if ($value instanceof Asset)
{
$group = $value->getGroup();
$fingerprint = $value->getBuildPath();
| php | {
"resource": ""
} |
q8151 | Entry.getDevelopmentAsset | train | public function getDevelopmentAsset($value, $group = null)
{
if ($value instanceof Asset)
{
$group = $value->getGroup();
$value = $value->getRelativePath();
}
| php | {
"resource": ""
} |
q8152 | Entry.getDevelopmentAssets | train | public function getDevelopmentAssets($group = null)
{
return is_null($group) | php | {
"resource": ""
} |
q8153 | Entry.hasDevelopmentAssets | train | public function hasDevelopmentAssets($group = null)
{
return is_null($group) ? ! | php | {
"resource": ""
} |
q8154 | Entry.resetDevelopmentAssets | train | public function resetDevelopmentAssets($group = null)
{
if (is_null($group))
{
$this->development = array();
}
else
| php | {
"resource": ""
} |
q8155 | Entry.getProductionFingerprint | train | public function getProductionFingerprint($group)
{
return | 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);
| php | {
"resource": ""
} |
q8157 | Filter.whenAssetIs | train | public function whenAssetIs($pattern)
{
return $this->when(function($asset) use ($pattern)
{
| php | {
"resource": ""
} |
q8158 | Filter.whenEnvironmentIs | train | public function whenEnvironmentIs()
{
$environments = func_get_args();
$appEnvironment = $this->appEnvironment;
| php | {
"resource": ""
} |
q8159 | Filter.setArgument | train | public function setArgument($argument, $position = null)
{
array_splice($this->arguments, $position ?: | 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();
| php | {
"resource": ""
} |
q8161 | Filter.processRequirements | train | public function processRequirements()
{
foreach ($this->requirements as $requirement)
{
if ( ! call_user_func($requirement, $this->resource, $this))
| php | {
"resource": ""
} |
q8162 | CacheListClassLoader.loadClass | train | public function loadClass($class)
{
$result = $this->loadCachedClass($class);
if ($result === false) | php | {
"resource": ""
} |
q8163 | CacheListClassLoader.loadCachedClass | train | private function loadCachedClass($class)
{
$result = false;
if (isset($this->cache[$class])) {
$result = include $this->cache[$class];
| php | {
"resource": ""
} |
q8164 | CacheListClassLoader.loadFile | train | protected function loadFile($file, $class)
{
parent::loadFile($file, $class);
| php | {
"resource": ""
} |
q8165 | Polygon.addCoordinate | train | public function addCoordinate(Coordinate $coordinate)
{
$this->coordinates[] = $coordinate;
| php | {
"resource": ""
} |
q8166 | Polygon.setCoordinate | train | public function setCoordinate(\ArrayObject $coordinates)
{
$this->coordinates = $coordinates;
| 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(
| php | {
"resource": ""
} |
q8168 | Polygon.assertPointsArrayLength | train | private function assertPointsArrayLength()
{
if (count($this->getCoordinates()) < self::$MIN_LENGTH) {
throw new \RuntimeException(sprintf(
| php | {
"resource": ""
} |
q8169 | CanBeLiked.likeIt | train | public function likeIt($user = null)
{
if (!$this->isLiked()) {
$this->likes()->create([
'user_id'=> $user | php | {
"resource": ""
} |
q8170 | CanBeLiked.unLikeIt | train | public function unLikeIt($user = null)
{
if ($like = $this->isLiked($user)) { | php | {
"resource": ""
} |
q8171 | CanBeLiked.isLiked | train | public function isLiked($user = null)
{
return $this->likes()->where([
'user_id' => $user ? $user->id : auth()->id(),
| php | {
"resource": ""
} |
q8172 | CanBeLiked.toggleLike | train | public function toggleLike($user = null)
{
$this->isLiked($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)) {
| php | {
"resource": ""
} |
q8174 | Repository.find | train | public function find($id)
{
return Arr::first($this->items, function ($key, Contract $skill) use ($id) {
| php | {
"resource": ""
} |
q8175 | Repository.findByName | train | public function findByName($name)
{
return Arr::first($this->items, function ($key, Contract $skill) use ($name) {
| 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) {
| php | {
"resource": ""
} |
q8177 | Request.getCurrentRoute | train | protected function getCurrentRoute(): string
{
$request = resolve(HttpRequest::class);
$method = strtoupper($request->getMethod());
$path = ltrim($request->path(), '/');
| php | {
"resource": ""
} |
q8178 | Gamma.setLevel | train | public function setLevel($level)
{
if (!($level >= 0.01 && $level <= 4.99)) {
throw | 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)) {
| php | {
"resource": ""
} |
q8180 | Rating.getFieldDefinition | train | public function getFieldDefinition($arrOverrides = [])
{
$arrFieldDef = parent::getFieldDefinition($arrOverrides);
$arrFieldDef['inputType'] = 'text';
| 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' => | php | {
"resource": ""
} |
q8182 | Rating.unsetDataFor | train | public function unsetDataFor($arrIds)
{
$this->connection->createQueryBuilder()
->delete('tl_metamodel_rating')
->andWhere('mid=:mid AND aid=:aid AND | 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')
| php | {
"resource": ""
} |
q8184 | Rating.ensureImage | train | protected function ensureImage($uuidImage, $strDefault)
{
$imagePath = ToolboxFile::convertValueToPath($uuidImage);
| 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 = | 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'))
| php | {
"resource": ""
} |
q8187 | Rating.getSessionBag | train | protected function getSessionBag()
{
if ($this->scopeDeterminator->currentScopeIsBackend()) {
return $this->session->getBag('contao_backend');
| php | {
"resource": ""
} |
q8188 | GettersSetters.GetMicrotime | train | public function GetMicrotime () {
if ($this->microtime === NULL) $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 | 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);
| php | {
"resource": ""
} |
q8191 | Environment.prepareDefaultDirectory | train | protected function prepareDefaultDirectory() : Directory {
$path = $this->finder->setWorkingDirectory('/');
| php | {
"resource": ""
} |
q8192 | Environment.package | train | public function package(string $package, ?string $namespace = null) : void {
if (is_null($namespace)) {
list($vendor, $namespace) = explode('/', $package); | php | {
"resource": ""
} |
q8193 | Environment.collections | train | public function collections(array $collections) : void {
foreach ($collections as $name => $callback) {
| php | {
"resource": ""
} |
q8194 | Environment.offsetGet | train | public function offsetGet($offset) : ?Collection {
return $this->has($offset) | 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 | 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));
| 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];
}
| php | {
"resource": ""
} |
q8198 | Helpers.IsErrorDispatched | train | public function IsErrorDispatched () {
$toolClass = $this->toolClass;
$defaultCtrlName = $toolClass::GetDashedFromPascalCase($this->defaultControllerName); | php | {
"resource": ""
} |
q8199 | Helpers.IsNotFoundDispatched | train | public function IsNotFoundDispatched () {
$toolClass = $this->toolClass;
$defaultCtrlName = $toolClass::GetDashedFromPascalCase($this->defaultControllerName); | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.