_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q237200
MenuItem.icon
train
public function icon($icon = null) { if ($icon === null) { return $this->_icon; } $this->_icon = $icon; return $this; }
php
{ "resource": "" }
q237201
MenuItem.url
train
public function url($url = null) { if ($url === null) { return $this->_url; } $this->_url = $url; return $this; }
php
{ "resource": "" }
q237202
MenuItem.parent
train
public function parent($parent = null) { if ($parent === null) { return $this->_parent; } $this->_parent = $parent; return $this; }
php
{ "resource": "" }
q237203
MenuItem.matchAction
train
public function matchAction($matchAction = null) { if ($matchAction === null) { return $this->_matchAction; } $this->_matchAction = $matchAction; return $this; }
php
{ "resource": "" }
q237204
MenuItem.doNotMatchAction
train
public function doNotMatchAction(array $action, $reset = false) { if ($reset) { $this->_doNotMatchAction = []; } if (!empty($action)) { $this->_doNotMatchAction[] = $action; } return $this; }
php
{ "resource": "" }
q237205
AbstractValidator.getRules
train
public function getRules() { $rules = empty($this->rules) ? $this->rules($this->request, $this->params) : $this->rules; return $this->explodeRules($rules); }
php
{ "resource": "" }
q237206
AbstractValidator.removeRequired
train
public function removeRequired() { foreach ($this->getRules() as $key => $rules) { $newRules[$key] = preg_grep("/^required/", $rules, PREG_GREP_INVERT); } $this->rules = $newRules; return $this; }
php
{ "resource": "" }
q237207
AbstractValidator.getDbValues
train
public function getDbValues(array $input = [], $mappings = []) { $response = []; foreach ($mappings as $inputKey => $dbValue) { if (is_array($input) && array_get($input, $inputKey) !== null) { $value = array_get($input, $inputKey); if ($value instanceof Uplo...
php
{ "resource": "" }
q237208
MapperTree.findTreeItem
train
public function findTreeItem($id, MapperTreeItemInterface $item) { if ($id === $item->getId()) { return $item; } foreach ($item->getChildren() as $child) { if (null !== $treeItem = $this->findTreeItem($id, $child)) { return $treeItem; } ...
php
{ "resource": "" }
q237209
PingDriveCommand.getURLData
train
protected function getURLData(string $driveUrl): array { /* * Known URL types: * https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive * https://docs.google.com/document/d/1-phrJPVDf1SpQYU5SzJY00Ke0c6QJmILHrtm_pcQk4w/edit A Google...
php
{ "resource": "" }
q237210
PingDriveCommand.writeGoogleDriveFolderData
train
protected function writeGoogleDriveFolderData( OutputInterface $output, \Google_Service_Drive $drive, \Google_Service_Drive_DriveFile $folder ) { $output->writeln('<info>The URL is a Google Drive folder</info>'); $output->writeln('Name: '.$folder->getName()); $output-...
php
{ "resource": "" }
q237211
PingDriveCommand.writeGoogleSheetData
train
protected function writeGoogleSheetData( OutputInterface $output, \Google_Service_Sheets $service, \Google_Service_Drive_DriveFile $spreadsheet ) { $output->writeln('<info>The URL is a Google Sheets file</info>'); $output->writeln('Name: '.$spreadsheet->getName()); /...
php
{ "resource": "" }
q237212
PingDriveCommand.writeGoogleSheetTable
train
protected function writeGoogleSheetTable(OutputInterface $output, \Google_Service_Sheets_Sheet $sheet) { $table = new Table($output); $merges = $sheet->getMerges(); /** @var \Google_Service_Sheets_GridRange[] $merges (the SDK type hint is incorrect) */ foreach ($sheet->getData()[0]->getRowD...
php
{ "resource": "" }
q237213
SplitIterator.getIterator
train
public function getIterator(): \Generator { $line = ''; foreach ($this->readIterator as $content) { $parts = explode($this->delimiter, $content); $partCount = \count($parts); if ($partCount > 1) { foreach ($parts as $i => $part) { ...
php
{ "resource": "" }
q237214
Html.buildHtmlElement
train
public static function buildHtmlElement($name, array $attributes = [], $content = null, $closeEmptyTag = true, array $cssClasses = []): string { $html = '<' . $name . self::buildAttrs($attributes, $cssClasses); if ($content !== null) { $html .= '>' . $content . '</' . $name . '>'; ...
php
{ "resource": "" }
q237215
Html.buildHtmlScript
train
public static function buildHtmlScript($script, array $attributes = []): string { $scriptCleaned = trim($script); if ($scriptCleaned !== '') { return self::buildHtmlElement('script', $attributes, "\n" . $scriptCleaned . "\n"); } return ''; }
php
{ "resource": "" }
q237216
Html.toText
train
public static function toText($html, bool $ignoreErrors = false): string { return (string) (new \Html2Text\Html2Text())->convert((string) $html, $ignoreErrors); }
php
{ "resource": "" }
q237217
Iban.validateIban
train
private function validateIban(): bool { $value = \substr($this->value, 4).\substr($this->value, 0, 4); $value = \str_replace( ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], ['...
php
{ "resource": "" }
q237218
Db.connect
train
public function connect($pHost, $pDb, $pUser = NULL, $pPass = NULL) { try { if ($pUser !== NULL and $pPass !== NULL and is_string($pUser) and is_string($pPass)) { $connection = new PDO("mysql:host=$pHost;dbname=$pDb", $pUser, $pPass); } else { $connect...
php
{ "resource": "" }
q237219
Db.listCollections
train
public function listCollections(array $pWithFields = array()) { $tables = array(); $prepared = $this->getConnection()->prepare('SHOW TABLES FROM `' . $this->_dbName . '`'); if ($prepared->execute()) { while ($row = $prepared->fetchObject()) { $table = str_replace...
php
{ "resource": "" }
q237220
Util.zeroFill
train
public static function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z & 0xffffffff); $a |= 0x40000000; $a = ($a >> ($b-1)); } else { $a = ($a >> $b); } return $a; }
php
{ "resource": "" }
q237221
Util.str2bin
train
public static function str2bin($string) { if (is_array($string) || is_object($string)) { $caller = next(debug_backtrace()); $error['line'] = $caller['line']; $error['file'] = strip_tags($caller['file']); trigger_error( "str2bin() expects par...
php
{ "resource": "" }
q237222
Util.bin2str
train
public static function bin2str($string) { if (is_array($string) || is_object($string)) { $caller = next(debug_backtrace()); $error['line'] = $caller['line']; $error['file'] = strip_tags($caller['file']); trigger_error( "bin2str() expects par...
php
{ "resource": "" }
q237223
Util.byte2intSplit
train
public static function byte2intSplit($input) { $l = strlen($input); if ($l <= 0) { // right... return 0; } elseif (($l % 4) != 0) { // invalid input return false; } $result = array(); for ($i = 0; $i < $l; $i += 4) { ...
php
{ "resource": "" }
q237224
FacadeFactory.find
train
public function find() { foreach ($this->getSupportedGateways() as $gateway) { $class = $this->helper-getFacadeClassName($gateway); if (class_exists($class)) { $this->register($gateway); } } ksort($this->gat...
php
{ "resource": "" }
q237225
FacadeFactory.create
train
public function create($className) { $facade = $this->helper->getFacadeClassName($className); if (!class_exists($facade)) { throw new RuntimeException("Class '$facade' not found"); } $className = $this->helper->getSDKClassName($className); ...
php
{ "resource": "" }
q237226
AbstractObject.getOption
train
public function getOption($name) { $method = 'get' . ucfirst($name); if (method_exists($this, $method) && $method !== __FUNCTION__) { return $this->$method(); } elseif (isset($this->options[$name])) { return $this->options[$name]; } }
php
{ "resource": "" }
q237227
AbstractObject.setOption
train
public function setOption($name, $value) { $method = 'set' . ucfirst($name); if (method_exists($this, $method) && $method !== __FUNCTION__) { return $this->$method($value); } $this->options[$name] = $value; return $this; }
php
{ "resource": "" }
q237228
FileUploadTransformer.transform
train
public function transform($umbrellaFile) { return array( 'file' => null, 'id' => $umbrellaFile ? $umbrellaFile->id : null, 'text' => $umbrellaFile ? $umbrellaFile->name . ' (' . $umbrellaFile->getHumanSize() .')' : null ); }
php
{ "resource": "" }
q237229
FileUploadTransformer.reverseTransform
train
public function reverseTransform($array) { $id = ArrayUtils::get($array, 'id', null); $umbrellaFile = $id ? $this->em->getRepository(UmbrellaFile::class)->find($id) : null; $uploadedFile = ArrayUtils::get($array, 'file', null); $delete = ArrayUtils::get($array, 'delete', false); ...
php
{ "resource": "" }
q237230
Result.outputSingleResult
train
protected function outputSingleResult() { echo $this->line(); echo $this->title(); echo $this->line(); echo $this->content(); echo $this->line(); }
php
{ "resource": "" }
q237231
Result.outputMultipleResult
train
protected function outputMultipleResult() { $this->return = $max = max($this->print) . ' '; echo $this->line(); echo $this->title(); echo $this->line(); foreach( $this->print as $key...
php
{ "resource": "" }
q237232
ArrayObject.merge
train
public function merge(ArrayObject $other, $recursive = TRUE) { foreach($other as $key => $value) { if($recursive && $this->offsetExists($key)) { $ownvalue = $this->offsetGet($key); if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) { ...
php
{ "resource": "" }
q237233
ArrayObject.toArray
train
public function toArray() { $result = iterator_to_array($this); foreach($result as $key => &$value) { if($value instanceof ArrayObject) { $value = $value->toArray(); } } return $result; }
php
{ "resource": "" }
q237234
ArrayObject.fromArray
train
public static function fromArray(array $input) { $input = array_map(function($value) { return is_array($value) ? ArrayObject::fromArray($value) : $value; }, $input); return new ArrayObject($input); }
php
{ "resource": "" }
q237235
DashboardHooks.Gdn_Dispatcher_AppStartup_Handler
train
public function Gdn_Dispatcher_AppStartup_Handler($Sender) { header('P3P: CP="CAO PSA OUR"', TRUE); if (!Gdn::Session()->IsValid() && $SSO = Gdn::Request()->Get('sso')) { SaveToConfig('Garden.Registration.SendConnectEmail', FALSE, FALSE); $UserID = FALSE; try { ...
php
{ "resource": "" }
q237236
Action.console
train
public function console($message, $eolBefor = false) { $befor = ''; if ($eolBefor) { $befor = PHP_EOL; } echo $befor, $message, PHP_EOL; return $this; }
php
{ "resource": "" }
q237237
Action.run
train
public function run() { if ($this->initialized) { $this->console(sprintf("Start running '%s' method of script '%s'.", $this->opts->action, get_class($this))); $this->{$this->action}(); $this->console(sprintf("End of running '%s' cli script.", get_class($this)), true)...
php
{ "resource": "" }
q237238
WkhtmltopdfAdapter.createTmpFile
train
protected function createTmpFile($content = null) { $tmpPath = $this->getConfig('tmp', sys_get_temp_dir()); $tmpFile = tempnam($tmpPath,'tmp_WkHtmlToPdf_'); rename($tmpFile, $tmpFile .= '.html'); if (!is_null($content)) { file_put_contents($tmpFile, $content); } ...
php
{ "resource": "" }
q237239
WkhtmltopdfAdapter.buildArguments
train
protected function buildArguments(array $options = array()) { $arguments = array(); foreach ($options as $key => $value) { // Validate value and format it if ($value === false or is_int($key)) { continue; } $arguments[] = "--$key"; ...
php
{ "resource": "" }
q237240
WkhtmltopdfAdapter.buildArrayArguments
train
private function buildArrayArguments($value) { $arguments = array(); foreach ($value as $index => $option) { if (is_string($index)) { $arguments[] = $index; } $arguments[] = $option; } return $arguments; }
php
{ "resource": "" }
q237241
WkhtmltopdfAdapter.sendHeaders
train
protected function sendHeaders($tmpFile) { header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: application/pdf'); header('Content-Transfer-Encoding: binary'); header('Content-Length...
php
{ "resource": "" }
q237242
WkhtmltopdfAdapter.help
train
public function help() { $builder = new ProcessBuilder(array('--extended-help')); $builder->setPrefix($this->config['bin']); $process = $builder->getProcess(); $process->run(); if ($process->isSuccessful()) { return $process->getOutput(); } }
php
{ "resource": "" }
q237243
Routes.setRoot
train
private static function setRoot($url) { $segements = explode('/', $url); $count = count($segements) - 2; $path = ''; for ($i = 0; $i < $count; $i++) { $path .= '../'; } Application::$path .= $path; return Application::$path; }
php
{ "resource": "" }
q237244
Routes.treat
train
private static function treat(Route $route, $params) { // in case of get request or post request if (($route->getMethod() == 'post' && Request::isPost()) || ($route->getMethod() == 'get') || ($route->getMethod() == 'resource') || ($route->getMethod() == 'call')) { return static::execute(...
php
{ "resource": "" }
q237245
Routes.execute
train
private static function execute(&$route, $params) { array_shift($params); if (static::runAppMiddleware() && static::runRouteMiddleware($route)) { static::prepare($route, $params); return true; } }
php
{ "resource": "" }
q237246
Routes.runAppMiddleware
train
private static function runAppMiddleware() { $appMiddleware = Filter::$middleware; foreach ($appMiddleware as $middleware) { $middleware = instance($middleware); $middleware->handle(new Request()); } return true; }
php
{ "resource": "" }
q237247
Routes.runRouteMiddleware
train
private static function runRouteMiddleware($route) { $routeMiddleware = Filter::$routeMiddleware; if (!is_null($route->getMiddleware())) { // if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) { foreach ($route->getMiddleware...
php
{ "resource": "" }
q237248
Routes.prepare
train
private static function prepare(Route $route, $params) { static::$current = $route; if ($route->getMethod() == 'resource') { if ($route->getTarget()['method'] == 'update') { $id = $params[0]; $params[0] = new Request(); $params[] = $id; ...
php
{ "resource": "" }
q237249
Routes.treatment
train
private static function treatment($result) { if (is_string($result)) { echo $result; } elseif ($result instanceof Views) { View::show($result); } }
php
{ "resource": "" }
q237250
Routes.add
train
public static function add(Route $route) { exception_if(self::checkDuplicated($route), RouteDuplicatedException::class, $route); // Create new route for url ended with '/' $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); self::$register[$routeWithoutSl...
php
{ "resource": "" }
q237251
Routes.edit
train
public static function edit(Route $route) { $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash; self::$register[$routeWithSlash->getName()] = $routeWithSlash; }
php
{ "resource": "" }
q237252
Routes.delete
train
public static function delete(Route $route) { $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); // exception_if(! check(self::$register[$routeWithoutSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithoutSlash); // exception_if(! check(...
php
{ "resource": "" }
q237253
Routes.checkDuplicated
train
private static function checkDuplicated(Route $route) { foreach (self::$register as $registeredRoute) { if ($registeredRoute->getName() == $route->getName()) { return true; } } return false; }
php
{ "resource": "" }
q237254
HttpResponse.setCode
train
public function setCode($code) { $code = (int)$code; if (!empty($this->body) && !HttpCode::isBodyAllowed($code)) { //InvalidArgumentException can be thrown here throw new LogicException('HTTP response already contains body - response "' . HttpCode::getName($code) . '" cannot contain bod...
php
{ "resource": "" }
q237255
HttpResponse.setBody
train
public function setBody($body) { if (!empty($body) && !HttpCode::isBodyAllowed($this->code)) { throw new LogicException('You cannot set non-empty body for currently set code'); } $this->body = (string)$body; $this->setHeader('Content-Length', strlen($this->body)); ...
php
{ "resource": "" }
q237256
Controller.enableSmarty
train
private function enableSmarty() { if ($this->smarty !== NULL) { return; } $this->smarty = new Smarty; $this->smarty->setTemplateDir(PUBLIC_DIR); $this->smarty->setCompileDir(PUBLIC_DIR . 'smarty' . DSC . 'compile'); $this->smarty->setCac...
php
{ "resource": "" }
q237257
Controller.getViewPath
train
private function getViewPath($name) { $module = $this->module_name !== NULL ? ($this->module_name) . DSC : ''; return $this->getRealPath('views' . DSC . $module . $name); }
php
{ "resource": "" }
q237258
Controller.renderTemplate
train
public function renderTemplate($name) { $data = array_merge($this->view_data, $this->view); $template = $this->getRealPath('template' . DSC . $name); $this->loadView($template, $data); }
php
{ "resource": "" }
q237259
Controller.renderView
train
public function renderView($name, $data = array(), $return = FALSE) { $file = $this->getViewPath($name); return $this->loadView($file, $data, $return); }
php
{ "resource": "" }
q237260
Benchmark.stop
train
public function stop() { $temp['section'] = $this->section; // set start value for system + user time if (function_exists('getrusage')) { $use = getrusage(); $user = sprintf('%6d.%06d', $use['ru_utime.tv_sec'], $use['ru_utime.tv_usec']); $system = sprintf('%6d.%06d', $use['ru_stime.tv_sec'], $use['ru_...
php
{ "resource": "" }
q237261
Benchmark.get
train
public function get() { if ($this->active) $this->stop(); foreach (array_keys($this->data) as $key) { $row =& $this->data[$key]; $row['realtime_ms'] = $row['realtime']*1000; if (is_numeric($row['proctime'])) { $row['proctime_ms'] = $row['proctime']*1000; } else { $row['proctime_ms'] = 'n/a'; ...
php
{ "resource": "" }
q237262
BootstrapFormExtension.restoreFormSettings
train
public function restoreFormSettings() { if (count($this->settingsStack) < 1) { throw new \UnderflowException("No settings on the stack to restore"); } $settings = array_pop($this->settingsStack); $this->style = $settings['style']; $this->colSize = $setting...
php
{ "resource": "" }
q237263
ChannelFilter.filter
train
public function filter(EventInterface $event) { if (!$event instanceof UserEventInterface) { return null; } $channels = $this->getChannels($event); if (empty($channels)) { return null; } $commonChannels = array_intersect($channels, $this->cha...
php
{ "resource": "" }
q237264
ChannelFilter.getChannels
train
protected function getChannels(UserEventInterface $event) { $command = $event->getCommand(); if (isset($this->parameters[$command])) { $params = $event->getParams(); $param = $this->parameters[$command]; return preg_grep('/^[#&]/', explode(',', $params[$param])); ...
php
{ "resource": "" }
q237265
Request.getMethod
train
public function getMethod() { if ($this->method === null) { if (is_null($this->method_override)) { $this->method = $this->server->get('request-method'); } else { $this->method = $this->method_override; } $this->method = strtoupp...
php
{ "resource": "" }
q237266
Request.getBodyParams
train
public function getBodyParams() { if (is_array($this->bodyParams)) { return $this->bodyParams; } $content = $this->getBody()->getContents(); $contentType = $this->headers->get('content-type'); if ($contentType === 'application/json') { $bodyParams = j...
php
{ "resource": "" }
q237267
Request.getBodyParam
train
public function getBodyParam($key, $default = null) { $params = $this->getBodyParams(); if (array_key_exists($key, $params)) { return $params[$key]; } return $default; }
php
{ "resource": "" }
q237268
Request.withBodyParam
train
public function withBodyParam($key, $value) { $params = $this->getBodyParams(); $params[$key] = $value; $this->bodyParams = $params; }
php
{ "resource": "" }
q237269
Request.withBodyParams
train
public function withBodyParams(array $values) { $params = $this->getBodyParams(); foreach ($values as $key => $value) { $params[$key] = $value; } $this->bodyParams = $params; }
php
{ "resource": "" }
q237270
Request.getQueryParams
train
public function getQueryParams() { if (is_array($this->queryParams)) { return $this->queryParams; } if (empty($_SERVER['QUERY_STRING'])) { return []; } parse_str($_SERVER['QUERY_STRING'], $this->queryParams); return $this->queryParams; }
php
{ "resource": "" }
q237271
Request.withQueryParams
train
public function withQueryParams(array $query) { $params = $this->getQueryParams(); foreach ($query as $key => $value) { $params[$key] = $value; } $this->queryParams = $params; }
php
{ "resource": "" }
q237272
Request.withQueryParam
train
public function withQueryParam($key, $value) { $params = $this->getQueryParams(); $params[$key] = $value; $this->queryParams = $params; }
php
{ "resource": "" }
q237273
Api.redefineErrorHandlers
train
protected function redefineErrorHandlers(&$container) { // Redefine - errors $container['errorHandler'] = BuilderJsonErrorResponses::jsonError(); $container['phpErrorHandler'] = BuilderJsonErrorResponses::jsonPhpError(); $container['notFoundHandler'] = BuilderJsonErrorResponses::json...
php
{ "resource": "" }
q237274
Api.redefineResponse
train
protected function redefineResponse(&$container) { // Redefine - response $container['response'] = function (Container $container) { $headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']); $response = new Response(200, $headers); return $resp...
php
{ "resource": "" }
q237275
Authenticator.setAuthenticationUrl
train
public function setAuthenticationUrl($authenticationUrl) { if(!is_string($authenticationUrl) || strlen(trim($authenticationUrl)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid authentication url, must be a non empty string'); $this->authenticationUrl = $authenticationUrl; ...
php
{ "resource": "" }
q237276
Field.save
train
public function save($value, & $response = null) { /** @var mixed $previousValue Previous instance value for transfer in event handlers */ $previousValue = $this->dbObject[$this->param]; // Set field value $this->dbObject[$this->param] = $this->convert($value); // Create ne...
php
{ "resource": "" }
q237277
Field.view
train
public function view($renderer, $saveHandler = 'save') { // TODO: Context rewriting if in one chain! $fieldView = $this->viewField($renderer); return $renderer->view($this->defaultView) ->set($this->cssClass, 'cssClass') ->set($this->value(), 'value') ->se...
php
{ "resource": "" }
q237278
VfsHandler.setProtocol
train
public function setProtocol( string $name, string $separator = '://' ) : VfsHandler { $this->_protocolName = $name ?? ''; $this->_protocolSeparator = $separator ?? ''; return $this; }
php
{ "resource": "" }
q237279
VfsHandler.addReplacement
train
public function addReplacement( string $name, ?string $value ) : VfsHandler { if ( null === $value ) { unset( $this->_replacements[ $name ] ); return $this; } $this->_replacements[ $name ] = $value; return $this; }
php
{ "resource": "" }
q237280
VfsHandler.addReplacements
train
public function addReplacements( array $replacements ) : VfsHandler { foreach ( $replacements as $name => $value ) { if ( null === $value ) { unset( $this->_replacements[ $name ] ); continue; } $this->_replacements[ $name ] = $value; }...
php
{ "resource": "" }
q237281
VfsHandler.tryParse
train
public function tryParse( string &$pathRef, array $dynamicReplacements = [] ) : bool { $protocol = $this->getProtocol(); if ( '' === $protocol || ! strStartsWith( $pathRef, $protocol ) ) { return false; } if ( \count( $dynamicReplacements ) > 0 ) { $this->addR...
php
{ "resource": "" }
q237282
Gasto._calcularImporteNeto
train
private function _calcularImporteNeto(){ if (!empty($this->data['Gasto']['Impuesto']) && empty($this->data['Gasto']['importe_neto'])) { if (!empty($this->data['Gasto']['Impuesto'])) { foreach ($this->data['Gasto']['Impuesto'] as $imp){ $this->data[...
php
{ "resource": "" }
q237283
Gasto._refreshImpuestos
train
private function _refreshImpuestos($created){ if (!empty($this->data['Gasto']['Impuesto'])) { if (!$created){ $this->Impuesto->deleteAll(array('Impuesto.gasto_id'=>$this->id )); } foreach ($this->data['Gasto']['Impuesto...
php
{ "resource": "" }
q237284
Gasto.enDeuda
train
public function enDeuda($conditions = array()){ $dbo = $this->getDataSource(); $subQuery = $dbo->buildStatement( array( 'fields' => array('SUM( `Aeg`.`importe` )'), 'table' => 'account_egresos_gastos', ...
php
{ "resource": "" }
q237285
Gasto.importePagado
train
public function importePagado($id = null){ $importePagado = 0; if (empty($id)) { $id = $this->id; } $fieldContain['recursive'] = -1; $fieldContain['contain'] = 'Egreso'; $fieldContain['conditions'] = array(...
php
{ "resource": "" }
q237286
AbstractTable.extractHeaders
train
protected function extractHeaders($data) { $headers = array_keys($data[0]); // Remove hidden fields from headers if supplied foreach ($this->options['hiddenFields'] as $hiddenField) { if (in_array($hiddenField, $headers)) { array_splice($headers, array_search($hiddenField, $headers), 1); } } if (...
php
{ "resource": "" }
q237287
Purchase.getGrandTotalAttribute
train
public function getGrandTotalAttribute() { if (!$this->deliveryOption) return $this->total; return (float) round($this->total + $this->deliveryOption->price, 2); }
php
{ "resource": "" }
q237288
Purchase.useAddress
train
public function useAddress(PostalAddress $postalAddress) { $this->name = $postalAddress->name; $this->street1 = $postalAddress->street1; $this->street2 = $postalAddress->street2; $this->city = $postalAddress->city; $this->county = $postalAddress->county; $this->postco...
php
{ "resource": "" }
q237289
Purchase.averageAmount
train
public static function averageAmount($since = 0, $until = null) { $until = $until ?: time(); return (int) self::where('created', '>=', $since) ->where('created', '<=', $until) ->avg('total'); }
php
{ "resource": "" }
q237290
FieldMapperType.convert
train
protected function convert($data) { if ($data instanceof DateTime) { $data = clone $data; // don't change to original value return $data->setTimezone($this->timezone)->format('Y-m-d\TG:i:s\Z'); } if (is_object($data) && !method_exists($data, '__toString')) { ...
php
{ "resource": "" }
q237291
FieldMapperType.combine
train
protected function combine(array $data, $separator) { $results = array_shift($data); $results = is_array($results) ? $results : [$results]; while ($value = array_shift($data)) { if (is_array($value)) { $replacement = []; foreach ($value as $array...
php
{ "resource": "" }
q237292
Activation.activateUser
train
public function activateUser($key) { // Get tokendate from db $tokenhandler = new ActivationToken($this->db); $tokenhandler->setSelectorTokenString($key); // Store the current to extracted from selector:token string ($key) $token_from_key = $tokenhandler->getToken(); ...
php
{ "resource": "" }
q237293
Http.redirect
train
public static function redirect($url, $permanent = false, $timer = 0, $die = true, $noForceJsRedirect = false) { if (headers_sent()) { if ($noForceJsRedirect) { echo '<script language="javascript" type="text/javascript">window.setTimeout("location=(\'' . $url . '\');", ' . $timer ...
php
{ "resource": "" }
q237294
Http._getDataFromArray
train
protected static function _getDataFromArray(&$array, $key = false, $default = null, $allowHtmlTags = false) { if ($key === null) return !$allowHtmlTags ? self::_secure($array, $allowHtmlTags) : $array; else { if (!array_key_exists($key, $array)) return $defau...
php
{ "resource": "" }
q237295
Http._secure
train
protected static function _secure($value, $allowHtmlTags) { if (is_array($value)) { foreach ($value as &$v) $v = self::_secure($v, $allowHtmlTags); } elseif (is_string($value)) $value = htmlspecialchars(strip_tags($value, ((is_string($allowHtmlTags) && !empty...
php
{ "resource": "" }
q237296
SellerHubRefController.add_pickup_windowAction
train
public function add_pickup_windowAction(Request $request) { $id = $request->get('id'); $hub = $this->getRepo('Profile')->find($id); $seller = $this->getUser()->getCurrentProfile(); if (!$hub) { throw $this->createNotFoundException('No hub found for id '.$id);...
php
{ "resource": "" }
q237297
TypeMapAbstract.get
train
final public function get(string $type): object { if ($this->supports($type)) { $ret = $this->getObject($type); if ($ret instanceof $type) { return $ret; } throw new TypeError; } throw new UnavailableTypeException; }
php
{ "resource": "" }
q237298
Message.headers
train
public function headers() { $headers = []; foreach ($this->headers as $header) { $headers[$header->name()] = $header->value(); } return $headers; }
php
{ "resource": "" }
q237299
EntityLogger.onFlush
train
public function onFlush(OnFlushEventArgs $eventArgs) { $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { $this->debug('Inserting entity '.get_class($entity).'. Fields: '. js...
php
{ "resource": "" }