_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q251900
AbstractTransport.normalizeHeaderName
validation
protected function normalizeHeaderName($keyName) { if (!is_string($keyName)) { return null; } return ucwords(trim(strtolower($keyName)), '-') ?: null; }
php
{ "resource": "" }
q251901
AbstractTransport.withHeaders
validation
public function withHeaders(array $headers) { $object = clone $this; $object->configs['headers'] = []; $object->inProcessingLoop = true; $object->replaceHeaders($headers); $object->inProcessingLoop = true; return $object->buildConfigClient(); }
php
{ "resource": "" }
q251902
AbstractTransport.withoutCookie
validation
public function withoutCookie($cookieName = null) { $object = clone $this; if (! $this->configs['cookies'] instanceof CookieJarInterface) { return $object; } if (!$cookieName) { unset($object->configs['cookies']); } else { if (!is_array($c...
php
{ "resource": "" }
q251903
AbstractTransport.withoutParam
validation
public function withoutParam($paramName = null) { $object = clone $this; if (is_null($paramName)) { unset($object->configs[$this->currentParamType]); } else { if (isset($object->configs[$this->currentParamType])) { if (!is_array($object->configs[$this-...
php
{ "resource": "" }
q251904
AbstractTransport.setParamType
validation
public function setParamType($type) { if (! is_string($type) || ! in_array($type, [self::PARAM_MULTIPART, self::PARAM_FORM]) ) { throw new InvalidArgumentException( sprintf( "Invalid parameter form type, form type only allowed $1s and $2s", ...
php
{ "resource": "" }
q251905
AbstractTransport.withRequest
validation
public function withRequest(RequestInterface $request) { $object = clone $this; $object->request = $request; $object->method = $request->getMethod(); return $object; }
php
{ "resource": "" }
q251906
XssProtectionMiddleware.enableBlockMode
validation
public function enableBlockMode():void { if (!$this->enableProtection) { throw new MiddlewareException( $this, "You can't enable the block mode because the XSS protection is disabled" ); } if ($this->reportUri) { throw new M...
php
{ "resource": "" }
q251907
XssProtectionMiddleware.setReportUri
validation
public function setReportUri(string $reportUri):void { if (!$this->enableProtection) { throw new MiddlewareException( $this, "You can't set the report URI because the XSS protection is disabled" ); } if ($this->blockMode) { ...
php
{ "resource": "" }
q251908
OnDupTrait.buildOnDup
validation
protected function buildOnDup()/*# : array */ { $result = []; foreach ($this->clause_ondup as $col => $expr) { $result[] = $col . ' = ' . $expr; } return $result; }
php
{ "resource": "" }
q251909
Xml.build
validation
public static function build($input, array $options = []) { if (!\is_array($options)) { $options = ['return' => (string)$options]; } $defaults = [ 'return' => 'simplexml', ]; $options = array_merge($defaults, $options); if (is_array($input) ||...
php
{ "resource": "" }
q251910
Xml.fromArray
validation
public static function fromArray($input, array $options = []) { if (!\is_array($input) || \count($input) !== 1) { throw new \RuntimeException(Tools::poorManTranslate('fts-shared', 'Invalid input.')); } $key = key($input); if (\is_int($key)) { throw new \Runtim...
php
{ "resource": "" }
q251911
Xml._fromArray
validation
protected static function _fromArray($dom, $node, &$data, $format) { if ($data === null || $data === '' || !\is_array($data)) { return; } foreach ($data as $key => $value) { if (\is_string($key)) { if (!\is_array($value)) { if (\is_...
php
{ "resource": "" }
q251912
Xml.toArray
validation
public static function toArray($obj) { if ($obj instanceof \DOMNode) { $obj = simplexml_import_dom($obj); } if (!($obj instanceof \SimpleXMLElement)) { throw new \RuntimeException(Tools::poorManTranslate('fts-shared', 'The input is not instance of SimpleXMLElement, DO...
php
{ "resource": "" }
q251913
Path.addSegmentsToPath
validation
private static function addSegmentsToPath($path, $segments) { $segments = Arr::toArray($segments); if (count($segments) > 0) { $path .= '/' . implode('/', $segments); } return $path; }
php
{ "resource": "" }
q251914
GetCachedCapableTrait._getCached
validation
protected function _getCached($key, $default = null, $ttl = null) { try { return $this->_get($key); } catch (NotFoundExceptionInterface $e) { if (is_callable($default)) { try { $args = $this->_normalizeArray($this->_getGeneratorArgs($key...
php
{ "resource": "" }
q251915
Inflection._cmpFrm
validation
private function _cmpFrm($txt) { $CmpFrmRV = ''; $length = mb_strlen($txt, 'UTF-8'); for ($CmpFrmI = 0; $CmpFrmI < $length; $CmpFrmI++) { if (mb_substr($txt, $CmpFrmI, 1, 'UTF-8') === '0') { $CmpFrmRV .= $this->aCmpReg[0]; } elseif (mb_substr($txt, $Cm...
php
{ "resource": "" }
q251916
Inflection._sklon
validation
private function _sklon($nPad, $vzndx, $txt, $zivotne = false) { if ($vzndx < 0 || $vzndx >= \count($this->vzor)) { return '???'; } $txt3 = $this->_xEdeten($txt); $kndx = $this->_isShoda($this->vzor[$vzndx][1], $txt3); if ($kndx < 0 || $nPad < 1 || $nPad > 14) {...
php
{ "resource": "" }
q251917
Inflection._rightStr
validation
private function _rightStr($n, $txt) { $rv = ''; $length = mb_strlen($txt, 'UTF-8'); for ($i = $n; $i < $length; $i++) { $rv .= mb_substr($txt, $i, 1, 'UTF-8'); } return $rv; }
php
{ "resource": "" }
q251918
Inflection._txtSplit
validation
private function _txtSplit($txt) { $skp = 1; $rv = []; $rvx = 0; $acc = ''; $length = mb_strlen($txt, 'UTF-8'); for ($i = 0; $i < $length; $i++) { if (mb_substr($txt, $i, 1, 'UTF-8') === ' ') { if ($skp) { continue; ...
php
{ "resource": "" }
q251919
Inflection.inflect
validation
public function inflect($text, $zivotne = false, $preferovanyRod = '') { $aTxt = $this->_txtSplit($text); $this->PrefRod = '0'; $out = []; for ($i = \count($aTxt) - 1; $i >= 0; $i--) { // vysklonovani $this->_skl2($aTxt[$i], $preferovanyRod, $zivotne); ...
php
{ "resource": "" }
q251920
Inflection._sklStd
validation
private function _sklStd($slovo, $ii, $zivotne) { if ($ii < 0 || $ii > \count($this->vzor)) { $this->astrTvar[0] = '!!!???'; } // - seznam nedoresenych slov $count = \count($this->v0); for ($jj = 0; $jj < $count; $jj++) { if ($this->_isShoda($this->v0...
php
{ "resource": "" }
q251921
SeoFriendlyDataObject.generateURLSegment
validation
protected function generateURLSegment($title){ $filter = URLSegmentFilter::create(); $t = $filter->filter($title); // Fallback to generic name if path is empty (= no valid, convertable characters) if(!$t || $t == '-' || $t == '-1') { $t = "{$this->owner->ClassName}-{$this->owner->ID}"; } else { ...
php
{ "resource": "" }
q251922
SeoFriendlyDataObject.onBeforeWrite
validation
public function onBeforeWrite(){ if($this->owner->Title){ $this->owner->URLSegment = $this->generateURLSegment($this->owner->Title); } parent::onBeforeWrite(); }
php
{ "resource": "" }
q251923
Str.quoteWith
validation
public static function quoteWith($o, $quote = '\'') { if (strlen($quote) !== 1) { throw new InvalidArgumentException('2nd parameter must be single character, two or more characters are given'); } if (is_array($o)) { $len = count($o); for ($i = 0; $i < $le...
php
{ "resource": "" }
q251924
AcceptTypes.preferred
validation
public function preferred(array $types): ?string { if (empty($types)) { return null; } foreach ($this->types as $type) { if (in_array($type, $types, true)) { return $type; } elseif ('*/*' == $type) { return current($types); ...
php
{ "resource": "" }
q251925
Application.bootstrap
validation
private function bootstrap() { // Attach the error handler - all PHP Errors should be thrown as Exceptions ErrorInterceptor::registerErrorHandler(); set_exception_handler(array(static::class, 'handleException')); // Set character set ini_set('default_charset', 'UTF-8'); ...
php
{ "resource": "" }
q251926
Application.get
validation
public function get($parameter) { switch ($parameter) { // Essential components are instantiated during application set up case "dev": return $this->dev ?? true; case "config": return $this->config; case "injector": ...
php
{ "resource": "" }
q251927
Application.showPermissionError
validation
private function showPermissionError(PermissionError $e) { if (PHP_SAPI !== "cli") { http_response_code(500); header("Content-type: text/plain"); } if ($this->dev) { $file = $e->path; echo "{$e->getMessage()}\n"; ec...
php
{ "resource": "" }
q251928
Application.setCreatePermissions
validation
private function setCreatePermissions() { if ($this->config->has('io', 'group')) Path::setDefaultFileGroup($this->config->get('io', 'group')); $file_mode = (int)$this->config->get('io', 'file_mode'); if ($file_mode) { $of = $file_mode; $file_mode ...
php
{ "resource": "" }
q251929
Application.configureAutoloaderAndResolver
validation
private function configureAutoloaderAndResolver() { if ($this->autoloader !== null) return; // Construct the Wedeto autoloader and resolver $cache = $this->cachemanager->getCache("resolution"); $this->autoloader = new Autoloader(); $this->autoloader->setCache($c...
php
{ "resource": "" }
q251930
Application.setupLogging
validation
private function setupLogging() { $test = defined('WEDETO_TEST') && WEDETO_TEST === 1 ? 'test' : ''; $root_logger = Logger::getLogger(); $root_logger->setLevel(LogLevel::INFO); if ($this->path_config->log) { $logfile = $this->path_config->log . '/wedeto' . $test...
php
{ "resource": "" }
q251931
Application.handleException
validation
public static function handleException(\Throwable $e) { $app = self::getInstance(); if ($app->request === null) $app->request = Request::createFromGlobals(); $req = $app->request; try { // Try to form a good looking response if (!Request:...
php
{ "resource": "" }
q251932
Application.shutdown
validation
public function shutdown() { if (!$this->is_shutdown) { $this->is_shutdown = true; // Unregister the autoloader if (!empty($this->autoloader)) spl_autoload_unregister(array($this->autoloader, 'autoload')); // Unregister the error hand...
php
{ "resource": "" }
q251933
Builder.getDialectStatement
validation
protected function getDialectStatement( /*# string */ $method, /*# bool */ $setTable = true )/*# StatementInterface */ { // dialect $dialect = $this->getDialect(); // check method if (!method_exists($dialect, $method)) { throw new BadMethodCallException( ...
php
{ "resource": "" }
q251934
Builder.fixTable
validation
protected function fixTable( $table, /*# string */ $tableAlias = '' )/*# : array */ { if (empty($table)) { $table = []; } else { if (!is_array($table)) { $table = empty($tableAlias) ? [$table] : [$table => $tableAlias]; ...
php
{ "resource": "" }
q251935
Session.startOrRestart
validation
protected function startOrRestart() { // if we have an active session: stop here if ( session_status() == PHP_SESSION_ACTIVE ) return; // set the session dir if needed if ( $this->SessionDir ) { if ( !file_exists( $this->SessionDir ) ) { ...
php
{ "resource": "" }
q251936
Insert.select
validation
public function select( $col = '', /*# string */ $colAlias = '' )/*# : SelectStatementInterface */ { return $this->getBuilder()->setPrevious($this)->select($col, $colAlias); }
php
{ "resource": "" }
q251937
ProblemDetails.toArray
validation
public function toArray(): array { if (empty($this->output)) { $problem = [ 'type' => $this->type ? (string)$this->type : 'about:blank' ]; if ($this->title) { $problem['title'] = $this->title; } if ($this->status) { ...
php
{ "resource": "" }
q251938
ProblemDetails.send
validation
public function send(ResponseInterface $response): ResponseInterface { $response->getBody()->write(json_encode($this->toArray())); return $response->withHeader('Content-Type', self::MIME_TYPE_JSON); }
php
{ "resource": "" }
q251939
Validate.isPasswd
validation
public static function isPasswd($passwd, $size = Validate::PASSWORD_LENGTH) { return self::getPasswordComplexity($passwd, $size) >= self::PASSWORD_COMPLEXITY_MEDIUM; }
php
{ "resource": "" }
q251940
Validate.isBirthDate
validation
public static function isBirthDate($date) { if ($date === null || $date === '0000-00-00') { return true; } if (preg_match('/^(\d{4})-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[1-2]\d)|(?:3[01]))(\d{2}:\d{2}:\d{2})?$/', $date, $birth_date)) { return !(($birth_date[1] > ...
php
{ "resource": "" }
q251941
Validate.isMobilePhoneNumber
validation
public static function isMobilePhoneNumber($phone) { $phoneNumber = substr(Tools::removeSpace($phone), -9, 1); return (!self::isCzechPhoneNumber($phoneNumber) || ($phoneNumber === '6' || $phoneNumber === '7')); }
php
{ "resource": "" }
q251942
Validate.isBirthNumber
validation
public static function isBirthNumber($no) { if (!preg_match('#^\s*(\d\d)(\d\d)(\d\d)[ /]*(\d\d\d)(\d?)\s*$#', $no, $matches)) { return false; } list(, $year, $month, $day, $ext, $c) = $matches; if ($c === '') { $year += $year < 54 ? 1900 : 1800; } el...
php
{ "resource": "" }
q251943
Validate.getPasswordComplexity
validation
public static function getPasswordComplexity($password, $minLength) { $group = [ 'upper' => '/[A-Z]/', 'lower' => '/[a-z]/', 'number' => '/[0-9]/', 'special' => '/[^A-Za-z0-9]/', ]; $score = 0; $length = \strlen($password); if ...
php
{ "resource": "" }
q251944
LEController.loadLanguage
validation
public function loadLanguage( $controller, $language = 'en_US', $return = FALSE ) { $langDirEvent = new GetLanguageDirEvent(); $this->dispatcher->fire( Events::EVENT_GET_LANG_DIR, $langDirEvent ); $langDir = $langDirEvent->getLangDir(); $retVal = FALSE; if ( NULL === $lan...
php
{ "resource": "" }
q251945
RestController.getModel
validation
public function getModel() { if(null === $this->model) { $mainService = $this->getServiceLocator()->get('neobazaar.service.main'); $this->model = $mainService->getUserEntityRepository(); } return $this->model; }
php
{ "resource": "" }
q251946
RestController.getEntityManager
validation
public function getEntityManager() { if (null === $this->em) { $mainService = $this->getServiceLocator()->get('neobazaar.service.main'); $this->em = $mainService->getEntityManager(); } return $this->em; }
php
{ "resource": "" }
q251947
RestController.getUserAddForm
validation
public function getUserAddForm() { if (null === $this->userAddForm) { $this->userAddForm = $this->getServiceLocator()->get('user.form.useradd'); } return $this->userAddForm; }
php
{ "resource": "" }
q251948
BaseRepository.applyCriteria
validation
public function applyCriteria($criteria) { $query = $this->getQuery(); if($criteria instanceof Criteria){ $criteria->apply($query); return $this; } if($criteria instanceof Closure){ $criteria($query); return $this; } ...
php
{ "resource": "" }
q251949
BaseRepository.getMany
validation
public function getMany($columns = ['*'], $paginated = false, $perPage = null) { $results = $paginated ? $this->getManyPaginated($perPage, $columns) : $this->getQuery()->get($columns); return $this->returnResults($results); }
php
{ "resource": "" }
q251950
BaseRepository.getManyPaginated
validation
public function getManyPaginated($perPage = null, $columns = ['*']) { $query = $this->getQuery(); $results = $query->paginate($perPage, $columns); return $this->returnResults($results); }
php
{ "resource": "" }
q251951
BaseRepository.getById
validation
public function getById($id, $columns = ['*']) { try { $results = $this->getQuery()->findOrFail($id, $columns); } catch(ModelNotFoundException $e){ throw new NotFoundRepositoryException($e); } return $this->returnResults($results); }
php
{ "resource": "" }
q251952
BaseRepository.getManyByIds
validation
public function getManyByIds(array $ids, $columns = ['*']) { $results = $this->getQuery()->findMany($ids, $columns); return $this->returnResults($results); }
php
{ "resource": "" }
q251953
BaseRepository.create
validation
public function create(array $attributes = []) { $model = $this->newModel(); $model->fill($attributes); $this->save($model); return $model; }
php
{ "resource": "" }
q251954
BaseRepository.saveMany
validation
public function saveMany(ArrayAccess $models) { //transform to collection if(!$models instanceof Collection){ $models = collect($models); } foreach ($models as $model) { $this->save($model); } return $models; }
php
{ "resource": "" }
q251955
BaseRepository.updateById
validation
public function updateById($id, array $newAttributes) { $model = $this->getById($id); $results = $model->update($newAttributes); if(!$results){ throw new UpdateFailedRepositoryException(); } return $model; }
php
{ "resource": "" }
q251956
BaseRepository.update
validation
public function update(Model $model, array $newAttributes) { $results = $model->update($newAttributes); if(!$results){ throw new UpdateFailedRepositoryException(); } return $model; }
php
{ "resource": "" }
q251957
BaseRepository.deleteMany
validation
public function deleteMany(ArrayAccess $models) { $results = []; foreach ($models as $model) { $results[] = $this->delete($model); } return $this->returnResults($results); }
php
{ "resource": "" }
q251958
BaseRepository.newModel
validation
public function newModel() { $model = app()->make($this->modelClass); if (!$model instanceof Model) { throw new RepositoryException("Class {$this->modelClass} must be an instance of Illuminate\\Database\\Eloquent\\Model"); } return $model; }
php
{ "resource": "" }
q251959
BaseRepository.paginate
validation
public function paginate($page = 1, $perPage = null, $columns = ['*']) { $perPage = $perPage ?: $this->defaultPageSize; $query = $this->getQuery(); $total = $query->getQuery()->getCountForPagination($columns); $query->getQuery()->forPage($page, $perPage); $results = $query-...
php
{ "resource": "" }
q251960
OverviewNavigationItem.addThumbnail
validation
public function addThumbnail(\TYPO3\CMS\Extbase\Domain\Model\FileReference $thumbnail) { $this->thumbnails->attach($thumbnail); }
php
{ "resource": "" }
q251961
OverviewNavigationItem.removeThumbnail
validation
public function removeThumbnail(\TYPO3\CMS\Extbase\Domain\Model\FileReference $thumbnail) { $this->thumbnails->detach($thumbnail); }
php
{ "resource": "" }
q251962
OverviewNavigationItem.getLabel
validation
public function getLabel() { $label = $this->label; $title = $this->title; if ($label) { return $label; } else { return $title; } }
php
{ "resource": "" }
q251963
Connection.count
validation
public function count($col, $alias, $distinct = false) { $this->counts[] = [$col, $alias, $distinct]; return $this; }
php
{ "resource": "" }
q251964
Connection.raw
validation
public function raw($sql, array $params) { $stmt = $this->connect()->prepare($sql); $stmt->execute($params); if (stripos($sql, 'select') === 0) { return $stmt->fetchAll(PDO::FETCH_ASSOC); } if (stripos($sql, 'insert') === 0) { return $this->connect()...
php
{ "resource": "" }
q251965
Connection.getNumRows
validation
public function getNumRows() { $builtSql = SqlBuilder::buildRowCountSql($this); if (is_array($builtSql)) { $preparedSth = $this->connect()->prepare($builtSql[0]); $boundSth = StatementBuilder::bindValues($preparedSth, $builtSql[1]); $boundSth->execute(); ...
php
{ "resource": "" }
q251966
MelisPageHistoricTable.getPageHistoricListOfActions
validation
public function getPageHistoricListOfActions($order = 'ASC') { $select = $this->tableGateway->getSql()->select(); $select->columns(["action" => new Expression('DISTINCT(hist_action)')]); $select->order('hist_action' . ' ' . $order); $resultSet = $this->tableGateway->selectWith($sele...
php
{ "resource": "" }
q251967
MelisPageHistoricTable.getUsers
validation
public function getUsers() { $select = $this->tableGateway->getSql()->select(); $select->columns(["fullname" => new Expression("DISTINCT(CONCAT(usr_firstname, ' ', usr_lastname))")]); $select->join('melis_core_user', 'melis_core_user.usr_id = melis_hist_page_historic.hist_user_id', ...
php
{ "resource": "" }
q251968
TimeType.getYear
validation
public function getYear() { if ($this->value !== null) { preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $this->value, $m); return (int) $m['year']; } }
php
{ "resource": "" }
q251969
TimeType.getMonth
validation
public function getMonth() { if ($this->value !== null) { preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $this->value, $m); return (int) $m['month']; } }
php
{ "resource": "" }
q251970
TimeType.getDay
validation
public function getDay() { if ($this->value !== null) { preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $this->value, $m); return (int) $m['day']; } }
php
{ "resource": "" }
q251971
TimeType.getHour
validation
public function getHour() { if ($this->value !== null) { preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $this->value, $m); return (int) $m['hour']; } }
php
{ "resource": "" }
q251972
TimeType.getMinute
validation
public function getMinute() { if ($this->value !== null) { preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $this->value, $m); return (int) $m['minute']; } }
php
{ "resource": "" }
q251973
TimeType.getSecond
validation
public function getSecond() { if ($this->value !== null) { preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $this->value, $m); return (int) $m['second']; } }
php
{ "resource": "" }
q251974
TimeType.checkLeapYear
validation
public static function checkLeapYear($year) { $year = Cast::_Int($year); if ($year % 4 !== 0) { return false; } elseif ($year % 100 !== 0) { return true; } elseif ($year % 400 !== 0) { return false; } elseif ($year === 0) { ret...
php
{ "resource": "" }
q251975
Interval.setLower
validation
public function setLower($lower): self { // if $lower is not a number, short-circuit if ( ! is_numeric($lower)) { throw new InvalidArgumentException( __METHOD__ . "() expects parameter one, lower, to be a number" ); } $this->lower = +$...
php
{ "resource": "" }
q251976
Interval.setUpper
validation
public function setUpper($upper): self { if ( ! is_numeric($upper)) { throw new InvalidArgumentException( __METHOD__ . "() expects parameter one, upper, to be a number" ); } $this->upper = $upper; return $this; }
php
{ "resource": "" }
q251977
Interval.compare
validation
public function compare($x): int { // if $x is not numeric, short-circuit if ( ! is_numeric($x)) { throw new InvalidArgumentException( __METHOD__ . "() expects parameter one, x, to be a number" ); } if ( $x < $this->low...
php
{ "resource": "" }
q251978
Interval.parse
validation
public function parse(string $string): self { // if the $string is not valid interval, short-circuit $pattern = '/^[\[\(]-?(\d*[\.]?\d+|INF), -?(\d*[\.]?\d+|INF)[\]\)]$/'; if ( ! preg_match($pattern, $string)) { throw new InvalidArgumentException( __METHOD__ . "()...
php
{ "resource": "" }
q251979
ChainEngine.search
validation
public function search($query) { $results = new ResultCollection(); foreach ($this->engines as $eachEngine) { if (!$eachEngine->supports($query)) { continue; } if ($more = $eachEngine->search($query)) { if (!is_array($more) and !$...
php
{ "resource": "" }
q251980
ChainEngine.supports
validation
public function supports($query) { foreach ($this->engines as $eachEngine) { if ($eachEngine->supports($query)) { return true; } } return false; }
php
{ "resource": "" }
q251981
Action._init
validation
private function _init( $params ) { if ( NULL !== $params && 0 < count( $params ) ) { foreach ( $params as $key => $value ) { $this->_params[ ] = $value; } } }
php
{ "resource": "" }
q251982
DeleteRecordTrait.buildRecord
validation
protected function buildRecord()/*# : array */ { $res = []; foreach ($this->clause_records as $tbl) { $res[] = $this->quote($tbl) . '.*'; } if (!empty($res)) { return [join(', ', $res)]; } else { return []; } }
php
{ "resource": "" }
q251983
DataContainer.get
validation
public function get($keys, $default = null) { $result = $this->data; foreach (is_array($keys) ? $keys : [$keys] as $key) { if (is_array($result) && isset($result[$key])) { $result = $result[$key]; } else { $result = $default; br...
php
{ "resource": "" }
q251984
DataContainer.getDateTime
validation
public function getDateTime($keys, DateTime $default = null) { $value = $this->getString($keys); if (empty($value)) { $result = $default; } elseif ($value === (string)(int)$value) { $result = new DateTime(); $result->setTimestamp((int)$value); } el...
php
{ "resource": "" }
q251985
DataContainer.getArray
validation
public function getArray($keys, array $default = []): array { $result = $this->get($keys, $default); if (!is_array($result)) { $result = $default; } return $result; }
php
{ "resource": "" }
q251986
DataContainer.getObjectArray
validation
public function getObjectArray($keys): array { return array_map(function ($value) { return $this->createObject($value); }, $this->getArray($keys)); }
php
{ "resource": "" }
q251987
JsonHelper.sendJson
validation
protected function sendJson(Response $response, $payload): Response { $response->getBody()->write(json_encode($payload)); return $response->withHeader('Content-Type', 'application/json'); }
php
{ "resource": "" }
q251988
JsonHelper.sendItems
validation
protected function sendItems(Response $response, iterable $items, ?Pagination $pagination = null, ?int $total = null): Response { $items = is_array($items) ? $items : ($items instanceof \Traversable ? iterator_to_array($items, false) : []); $total = $total ?? count($items); $start = $paginat...
php
{ "resource": "" }
q251989
JsonHelper.sendCreated
validation
protected function sendCreated(Response $response, string $type, array $ids, array $extra = []): Response { return $this->sendVerb('created', $response, $type, $ids, $extra) ->withStatus(201, "Created"); }
php
{ "resource": "" }
q251990
JsonHelper.sendDeleted
validation
protected function sendDeleted(Response $response, string $type, array $ids, array $extra = []): Response { return $this->sendVerb('deleted', $response, $type, $ids, $extra); }
php
{ "resource": "" }
q251991
JsonHelper.sendVerb
validation
protected function sendVerb(string $verb, Response $response, string $type, array $ids, array $extra = []): Response { $send = array_merge([], $extra); $send['success'] = true; $send['message'] = "Objects $verb successfully"; $send['objects'] = array_map(function ($id) use ($type) { ...
php
{ "resource": "" }
q251992
User.init
validation
public function init(UserEntity $user, ServiceManager $sm) { $main = $sm->get('neobazaar.service.main'); $userRepository = $main->getUserEntityRepository(); $this->hashId = $userRepository->getEncryptedId($user->getUserId()); $this->name = $user->getName(); $this->surname = $user->getSurname(); $this->emai...
php
{ "resource": "" }
q251993
User.getStateFormatted
validation
protected function getStateFormatted(UserEntity $user) { switch($user->getState()) { case UserEntity::USER_STATE_ACTIVE: $this->stateClass = 'success'; return 'Attivo'; break; case UserEntity::USER_STATE_BANNED: $this->stateClass = 'danger'; return 'Bannato'; break; case UserEntity:...
php
{ "resource": "" }
q251994
User.getMobile
validation
protected function getMobile(UserEntity $user) { $metadata = $user->getMetadata(); foreach($metadata as $meta) { if('cellulare' == $meta->getKey()) { return $meta->getValue(); } } return null; }
php
{ "resource": "" }
q251995
User.getDateBorn
validation
public function getDateBorn(UserEntity $user, $sm) { $dateFormatter = new \IntlDateFormatter( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, \date_default_timezone_get(), \IntlDateFormatter::GREGORIAN, "dd MMMM YYYY" ); $date = $user->getDateBorn(); return...
php
{ "resource": "" }
q251996
TableOptionTrait.buildTblOpt
validation
protected function buildTblOpt()/*# : array */ { $result = []; foreach ($this->tbl_option as $opt) { $result[] = $opt; } if (empty($result)) { $result[] = ''; } return $result; }
php
{ "resource": "" }
q251997
HaltoRouter.map
validation
public function map($method, $route, $target, $name = null, $hostGroup = null, $prepend = false) { if (!$hostGroup) { $hostGroup = null; } if ($prepend) { array_unshift($this->routes, array($method, $route, $target, $name, $hostGroup)); } else { $...
php
{ "resource": "" }
q251998
StatsTable.totals
validation
public function totals($locale = null) { $this->setLocale($locale); $totals = Collection::make(); foreach (Arr::except($this->footer(), 'all') as $level => $count) { $totals->put($level, [ 'label' => trans('dashboard::logs.'.$level), 'value' ...
php
{ "resource": "" }
q251999
StatsTable.prepareHeader
validation
protected function prepareHeader(array $data) { return array_merge_recursive( [ 'date' => trans('dashboard::logs.date'), 'all' => trans('dashboard::logs.all'), ], $this->levels->names($this->locale) ); }
php
{ "resource": "" }