_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q253200
Collection.splice
validation
public function splice($offset = 0, $length = 0, $replacement = []) { return new static(array_splice($this->elements, $offset, $length, $replacement)); }
php
{ "resource": "" }
q253201
Collection.reduce
validation
public function reduce(Closure $fn, $initial = null) { return array_reduce($this->elements, $fn, $initial); }
php
{ "resource": "" }
q253202
Collection.each
validation
public function each(Closure $fn) { foreach ($this->elements as $key => $element) { if ($fn($element, $key) === false) { return false; } } return true; }
php
{ "resource": "" }
q253203
Connection.parseConfig
validation
private function parseConfig($connection) { $this->debug = false; $allowed_keys = array_keys(get_object_vars($this)); foreach ($connection as $key => $value) { // Check if host has a trailing slash and remove it if ($key === 'host' && substr($value, -1) === '/') { ...
php
{ "resource": "" }
q253204
Connection.setParam
validation
private function setParam($key, $value, $allowed_keys) { if (in_array($key, $allowed_keys)) { $this->{$key} = $value; } }
php
{ "resource": "" }
q253205
Connection.checkSource
validation
private function checkSource($connection) { if (gettype($connection)=="string") { $config = include(__DIR__.'/../../../../../clusterpoint.php'); $connection = $config[$connection]; } return $connection; }
php
{ "resource": "" }
q253206
Password.hash
validation
public static function hash($password) { return \Yii::$app->security->generatePasswordHash($password, \Yii::$app->getModule('user')->cost); }
php
{ "resource": "" }
q253207
PageRendererProduction.renderSlots
validation
public function renderSlots(Page $page, array $slots, array $options = array()) { $renderedSlots = array(); $slots = $this->dispatchSlotsEvent(RenderEvents::SLOTS_RENDERING, $page, $slots); foreach ($slots as $slotName => $slot) { if (is_string($slot)) { $rendered...
php
{ "resource": "" }
q253208
SupervisorProcess.getPidByProgramName
validation
public function getPidByProgramName($name) { $process = new Process(sprintf('supervisorctl pid %s', $name)); $process->run(); return $process->getOutput(); }
php
{ "resource": "" }
q253209
Auth.GetAuthClass
validation
public static function GetAuthClass () { if (self::$authClass === NULL) { if (class_exists(self::AUTH_CLASS_FULL)) { self::$authClass = self::AUTH_CLASS_FULL; } else { self::$authClass = self::AUTH_CLASS_BASIC; } } return self::$authClass; }
php
{ "resource": "" }
q253210
Auth.SetAuthClass
validation
public static function SetAuthClass ($authClass) { $toolClass = \MvcCore\Application::GetInstance()->GetToolClass(); if ($toolClass::CheckClassInterface($authClass, 'MvcCore\Ext\Auths\Basics\IAuth', TRUE, TRUE)) self::$authClass = $authClass; }
php
{ "resource": "" }
q253211
ExpiringLockTrait.extendExpiration
validation
public function extendExpiration() { if (null === $this->ttl) { throw new DomainException('There is no TTL set for this Lock.'); } if (!$this->expiresAt) { $this->expiresAt = new \DateTime(); $this->expiresAt->setTimestamp(time()); } $thi...
php
{ "resource": "" }
q253212
Plugin.handleCommand
validation
public function handleCommand(Event $event, Queue $queue) { if ($this->validateParams($event)) { $params = $event->getCustomParams(); $results = array(); $total = 0; $count = $params[0]; $sides = (isset($params[1])) ? $params[1] : $this->defaultDie...
php
{ "resource": "" }
q253213
Plugin.validateParams
validation
protected function validateParams(Event $event) { return ( $this->genericParamValidation($event) && $this->firstParamValidation($event) && $this->secondParamValidation($event) ); }
php
{ "resource": "" }
q253214
Plugin.genericParamValidation
validation
private function genericParamValidation(Event $event) { $params = $event->getCustomParams(); return (count($params) >= 1 && count($params) <= 2); }
php
{ "resource": "" }
q253215
Plugin.firstParamValidation
validation
private function firstParamValidation(Event $event) { $params = $event->getCustomParams(); return (is_numeric($params[0]) && $params[0] > 0 && $params[0] <= $this->maxDieRolls); }
php
{ "resource": "" }
q253216
Plugin.secondParamValidation
validation
private function secondParamValidation(Event $event) { $params = $event->getCustomParams(); return (!isset($params[1]) || (is_numeric($params[1]) && $params[1] >= 1 && $params[1] <= $this->maxDieSides)); }
php
{ "resource": "" }
q253217
Plugin.handleCommandHelp
validation
public function handleCommandHelp(Event $event, Queue $queue) { $this->sendIrcResponse($event, $queue, $this->getHelpLines()); }
php
{ "resource": "" }
q253218
Item.getInterfaceObject
validation
public function getInterfaceObject() { if (is_null($this->_interfaceObject)) { $this->_interfaceObject = DataInterface::find()->where(['system_id' => $this->object->systemId])->one(); if (empty($this->_interfaceObject)) { $this->_interfaceObject = new DataInterface();...
php
{ "resource": "" }
q253219
Transformer.transform
validation
public function transform($message) { if (is_array($message)) { $class = News::class; } else { if (is_string($message)) { $message = new Text(['content' => $message]); } $class = get_class($message); } $handle = 'trans...
php
{ "resource": "" }
q253220
Transformer.transformCard
validation
public function transformCard(AbstractMessage $message) { $type = $message->getType(); return [ 'msgtype' => $type, $type => [ 'card_id' => $message->get('card_id'), ], ]; }
php
{ "resource": "" }
q253221
Stats.query
validation
protected function query($api, $from, $to) { $params = [ 'begin_date' => $from, 'end_date' => $to, ]; return $this->parseJSON('json', [$api, $params]); }
php
{ "resource": "" }
q253222
LockManager.isAccessible
validation
public function isAccessible(AcquirerInterface $acquirer, ResourceInterface $resource) { if (!$resource->isLocked()) { return true; } $lock = $resource->getLock(); if ($lock instanceof ExpiringLockInterface and $this->isLockExpired($lock)) { $this->release($l...
php
{ "resource": "" }
q253223
LockManager.acquire
validation
public function acquire(AcquirerInterface $acquirer, ResourceInterface $resource) { if (!$this->isAccessible($acquirer, $resource)) { throw new ResourceLockedException(sprintf('The resource is not accessible. It is locked by "%s".', $resource->getLock()->getAcquirer()->getIdentifier())); ...
php
{ "resource": "" }
q253224
BaseCliApplication.getConfig
validation
public function getConfig($name, $default = null) { return array_key_exists($name, $this->settings) ? $this->settings[$name] : $default; }
php
{ "resource": "" }
q253225
BaseCliApplication.boot
validation
public function boot() { if ($this->booted) { return $this; } // If we have pinba, disable it. if (extension_loaded('pinba')) { ini_set('pinba.enabled', false); } // If we have newrelic, disable it. if (extension_loaded('newrelic')) {...
php
{ "resource": "" }
q253226
StringBuffer.scanf
validation
function scanf($format) { $spec_pattern = "/%[+-]?('.)?[-]?(\d)*(\..\d)?[%bcdeEfFgGosuxX]/"; $source = substr($this->data,$this->pos); $result = sscanf($source,$format); if ($result==-1) return; else { $l = 0; foreach ($result as $v) { ...
php
{ "resource": "" }
q253227
StringBuffer.read
validation
function read($length) { $l = $this->pos+$length < strlen($this->data) ? $length : strlen($this->data)-$this->pos; $result = substr($this->data,$this->pos,$l); $this->pos+=$l; return $result; }
php
{ "resource": "" }
q253228
StringBuffer.isEndOfLine
validation
private function isEndOfLine($i) { $ch = $this->data[$i]; if ($this->getLineEndingModeCrlf()) { if ($ch=="\r") { $more_ch = $i + 1 < strlen($this->data); if ($more_ch) { $next_n = $this->data[$i + 1] == "\n"; if ($nex...
php
{ "resource": "" }
q253229
StringBuffer.readLine
validation
function readLine() { $i = $this->pos; $tot_len = strlen($this->data); while ($i<$tot_len && !$this->isEndOfLine($i)) { $i++; } $result = substr($this->data,$this->pos,$i-$this->pos); $i++; //skip first EOL char if ($this->getLineEndingModeCrlf(...
php
{ "resource": "" }
q253230
AdminManager.sort
validation
public function sort($entityName, $values) { $values = json_decode($values); for ($i=0; $i<count($values); $i++) { $this->entityManager ->getRepository($entityName) ->createQueryBuilder('e') ->update() ->set('e.order', $i) ...
php
{ "resource": "" }
q253231
AdminManager.toggleFiltrable
validation
public function toggleFiltrable($entityName, $id) { $entity = $this->entityManager->getRepository($entityName)->find($id); if (!$entity) { throw new NotFoundHttpException(); } $entity->toggleFiltrable(); $this->entityManager->persist($entity); $this->en...
php
{ "resource": "" }
q253232
Slug.validateSlug
validation
private function validateSlug(string $sku) { if (strlen($sku) == 0) { throw new SlugException("A Slug cannot be empty"); } // check for white-space $containsWhitespace = preg_match($this->whiteSpacePattern, $sku) == 1; if ($containsWhitespace) { throw...
php
{ "resource": "" }
q253233
Collection.toArray
validation
public function toArray() { $urls = []; $actions = []; if (count($this->items) < 1) { return parent::toArray(); } $entity = $this->items[0]; if (is_array($entity->load)) { foreach ($entity->load as $k => $...
php
{ "resource": "" }
q253234
Collection.orderBy
validation
public function orderBy($key, $direction = 'asc') { return $this->sort(function($a, $b) use ($key, $direction) { $valueA = is_object($a) ? $a->{$key} : $a[$key]; $valueB = is_object($b) ? $b->{$key} : $b[$key]; if ($valueA == $valueB) return 0; $result = ($valueA < $valueB) ? -1 : 1; // If the di...
php
{ "resource": "" }
q253235
Stream.pipe
validation
public function pipe($data, $index, $isHeader = false) { $this->lastIndex++; $this->data[$this->lastIndex] = $data; }
php
{ "resource": "" }
q253236
CatalogMapper.getCatalog
validation
public function getCatalog(array $catalogData) { /** @var array $skuIndex A list of all SKUs */ $skuIndex = []; /** @var array $slugIndex A list of all product slugs */ $slugIndex = []; $index = 1; $products = []; foreach ($catalogData as $catalogItem) { ...
php
{ "resource": "" }
q253237
Generator.doctrine
validation
static public function doctrine($tableName, $field, $length = 16) { do { $generate = self::generate($length); } while (self::doctrineQuery($tableName, $field, $generate)); return $generate; }
php
{ "resource": "" }
q253238
Generator.generateDoctrine2
validation
static public function generateDoctrine2(\Doctrine\ORM\EntityManager $entityManager, $entityName, $field, $length = 16) { do { $generate = self::generate($length); } while (self::doctrine2Query($entityManager, $entityName, $field, $generate)); return $generate;...
php
{ "resource": "" }
q253239
Generator.generatePhalcon
validation
static public function generatePhalcon($modelName, $field, $length = 16) { do { $generate = self::generate($length); } while (self::phalconQuery($modelName, $field, $generate)); return $generate; }
php
{ "resource": "" }
q253240
Generator.phalconQuery
validation
static protected function phalconQuery($modelName, $field, $generate) { $return = \Phalcon\Mvc\Model::query() ->setModelName($modelName) ->where("$field = :value:") ->bind(array('value' => $gener...
php
{ "resource": "" }
q253241
Generator.doctrineQuery
validation
static protected function doctrineQuery($tableName, $field, $generate) { return \Doctrine_Query::create() ->select($field) ->from($tableName)->where("$field = ?", $generate) ->execute(array(), \Doctrine_Core::HYDR...
php
{ "resource": "" }
q253242
Generator.doctrine2Query
validation
static protected function doctrine2Query(\Doctrine\ORM\EntityManager $entityManager, $entityName, $field, $generate) { $result = $entityManager->createQueryBuilder() ->select("entity.$field") ->from($entityName, 'entity') ...
php
{ "resource": "" }
q253243
Generator.generate
validation
static public function generate($length = 16, $algorithm = 'sha256') { if (!in_array($algorithm, self::$allowedAlgorithm)) { throw new Exception("Hash algorithm $algorithm doesn't exists!"); } $salt = hash($algorithm, time()); return substr(hash($algorithm, ...
php
{ "resource": "" }
q253244
Sns.getSessionKey
validation
public function getSessionKey($jsCode) { $params = [ 'appid' => $this->config['app_id'], 'secret' => $this->config['secret'], 'js_code' => $jsCode, 'grant_type' => 'authorization_code', ]; return $this->parseJSON('GET', [self::JSCODE_TO_SESSIO...
php
{ "resource": "" }
q253245
ObjectOperation.objectToArray
validation
public static function objectToArray($mObject) : array { if ( is_object($mObject)) { $mObject = (array) $mObject; } if (is_array($mObject)) { $aNew = array(); foreach($mObject as $sKey => $mValues) { $sKey = preg_replace("/^\\0(.*)\\0/", "", $sKey); $aNew[$sKey] = self::objectToArray...
php
{ "resource": "" }
q253246
BlockManagerArchive.archive
validation
public function archive($sourceDir, array $options, $username, $block) { $this->resolveOptions($options); $block = json_decode($block, true); $block["history"] = array(); $this->init($sourceDir, $options, $username); $historyDirName = sprintf('%s/archive/%s', $this->getDirIn...
php
{ "resource": "" }
q253247
Authority.getAuthorityTree
validation
final public function getAuthorityTree() { $database = $this->database; $statement = $database->select()->from('?authority')->between("lft", '1', '6')->prepare(); $results = $statement->execute(); $right = array(); }
php
{ "resource": "" }
q253248
Authority.getPermissions
validation
final public function getPermissions( $authenticated ) { //$authority = $this; $this->userid = (int) $authenticated->get("user_id"); //Authenticated? if ($authenticated->authenticated && !empty($this->userid)) { //At least we know the user is authenticated ...
php
{ "resource": "" }
q253249
MwTranslator.getMessages
validation
public function getMessages( $domain = 'default', $locale = null ) { if( $locale === null ) { $locale = $this->getLocale(); } if( !isset( $this->messages[$domain][$locale] ) ) { $this->loadMessages( $domain, $locale ); } return $this->messages[$domain][$locale]; }
php
{ "resource": "" }
q253250
Breadcrumb.setTitle
validation
public function setTitle(string $title): void { $this->title = $this->translator !== null ? $this->translator->translate($title) : $title; }
php
{ "resource": "" }
q253251
Breadcrumb.addLink
validation
public function addLink(string $name, string $link = null, array $arguments = []): Link { $name = $this->translator !== null ? $this->translator->translate($name) : $name; return $this->addLinkUntranslated($name, $link, $arguments); }
php
{ "resource": "" }
q253252
Configuration.addBlockSection
validation
private function addBlockSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('block_theme') ->children() ->arrayNode('block_themes') ->prototype('scalar')->end() ->example(['@App/block.html.twig']) ...
php
{ "resource": "" }
q253253
Configuration.addDoctrineSection
validation
private function addDoctrineSection(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('doctrine') ->info('doctrine configuration') ->canBeEnabled() ->children() ->booleanNode('en...
php
{ "resource": "" }
q253254
AbstractExtendedCompilerFactory.instantiateCompiler
validation
protected function instantiateCompiler(string &$className, &$description): CompilerInterface { if(is_array($description)) { $class = $description[ self::COMPILER_CLASS_KEY ] ?? $className; if(!isset($description[ self::COMPILER_ID_KEY ])) $description[ self::COMPILER_ID_K...
php
{ "resource": "" }
q253255
Rest.execute
validation
public static function execute(ConnectionInterface $connection, $forceSimpleUrl = false) { $url = $connection->host.'/'.$connection->accountId.'/'.$connection->db.''.$connection->action.(isset($connection->transactionId) ? '?transaction_id='.$connection->transactionId : ''); if ($forceSimpleUrl){ $url = ...
php
{ "resource": "" }
q253256
MultiExec.assertClient
validation
private function assertClient(ClientInterface $client) { if ($client->getConnection() instanceof AggregateConnectionInterface) { throw new NotSupportedException( 'Cannot initialize a MULTI/EXEC transaction over aggregate connections.' ); } if (!$clien...
php
{ "resource": "" }
q253257
MultiExec.unwatch
validation
public function unwatch() { if (!$this->client->getCommandFactory()->supportsCommand('UNWATCH')) { throw new NotSupportedException( 'UNWATCH is not supported by the current command factory.' ); } $this->state->unflag(MultiExecState::WATCH); $t...
php
{ "resource": "" }
q253258
FileResponseCache.calculateRequestFilename
validation
public function calculateRequestFilename(Request $request) { $string = $request->getUri(); $filename = parse_url($string, PHP_URL_HOST); $filename .= '_'.parse_url($string, PHP_URL_PATH); $headers = $request->getAllHeaders(); ksort($headers); foreach ($headers as $header ...
php
{ "resource": "" }
q253259
LazyQueue.setup
validation
protected function setup(\AMQPQueue $queue) { $queue->declareQueue(); foreach ($this->binds as $exchange => $params) { $queue->bind($exchange, $params['routing_key'], $params['arguments']); } }
php
{ "resource": "" }
q253260
OperationGenerator.addProperties
validation
function addProperties() { $requiredProperties = [ 'api' => '\\'.$this->apiClassname, 'parameters' => 'array', 'response' => '\Amp\Artax\Response', 'originalResponse' => '\Amp\Artax\Response', ]; //TODO - deal with clashes between this and bits ...
php
{ "resource": "" }
q253261
OperationGenerator.addSetAPIMethod
validation
function addSetAPIMethod() { $methodGenerator = new MethodGenerator('setAPI'); $methodGenerator->setBody('$this->api = $api;'); $parameterGenerator = new ParameterGenerator('api', $this->apiClassname); $methodGenerator->setParameter($parameterGenerator); $this->classGenerator->ad...
php
{ "resource": "" }
q253262
OperationGenerator.generateParameterSetBlock
validation
private function generateParameterSetBlock($indent, \ArtaxServiceBuilder\Parameter $operationParameter) { switch ($operationParameter->getLocation()) { case 'absoluteURL': { return $indent.'$url = $value;'.PHP_EOL; break; } case 'postField': ...
php
{ "resource": "" }
q253263
OperationGenerator.addCheckScopeMethod
validation
function addCheckScopeMethod() { $scopes = $this->operationDefinition->getScopes(); if (count($scopes) == 0) { //TODO - should the method be added anyway? For now, no. return; } $methodGenerator = new MethodGenerator('checkScopeRequirement'); $parameterG...
php
{ "resource": "" }
q253264
OperationGenerator.addAccessorMethods
validation
function addAccessorMethods() { foreach($this->operationDefinition->getParameters() as $parameter) { $translatedParam = $this->apiGenerator->translateParameter($parameter->getName()); $methodGenerator = new MethodGenerator('set'.ucfirst($translatedParam)); $body = sprintf('$t...
php
{ "resource": "" }
q253265
OperationGenerator.addConstructorMethod
validation
private function addConstructorMethod() { $requiredParameters = $this->operationDefinition->getRequiredParams(); $methodGenerator = new MethodGenerator('__construct'); $defaultParams = $this->operationDefinition->getDefaultParams(); $body = ''; if (count($defau...
php
{ "resource": "" }
q253266
OperationGenerator.generateExecuteFragment
validation
private function generateExecuteFragment() { $body = ''; if ($this->operationDefinition->getNeedsSigning()) { $body .= '$request = $this->api->signRequest($request);'.PHP_EOL; } $body .= '$response = $this->api->execute($request, $this);'.PHP_EOL; $body .= '$this->r...
php
{ "resource": "" }
q253267
OperationGenerator.generateExecuteDocBlock
validation
private function generateExecuteDocBlock($methodDescription) { $responseClass = $this->operationDefinition->getResponseClass(); $docBlock = new DocBlockGenerator($methodDescription, null); if ($responseClass) { $tags[] = new GenericTag('return', '\\'.$responseClass); } ...
php
{ "resource": "" }
q253268
OperationGenerator.addExecuteMethod
validation
function addExecuteMethod() { $body = $this->generateCreateFragment(); $body .= 'return $this->dispatch($request);'; $docBlock = $this->generateExecuteDocBlock('Execute the operation, returning the parsed response'); $methodGenerator = new MethodGenerator('execute'); $methodGen...
php
{ "resource": "" }
q253269
OperationGenerator.addExecuteAsyncMethod
validation
function addExecuteAsyncMethod() { $body = $this->generateCreateFragment(); $body .= 'return $this->dispatchAsync($request, $callable);'; $docBlock = new DocBlockGenerator('Execute the operation asynchronously, passing the parsed response to the callback', null); $tags[] = new GenericT...
php
{ "resource": "" }
q253270
OperationGenerator.generateParamFilterBlock
validation
function generateParamFilterBlock(\ArtaxServiceBuilder\Parameter $parameter) { $i1 = ' ';//Indent 1 $i2 = ' ';//Indent 1 $text = ''; $text .= sprintf( $i1."case ('%s'): {".PHP_EOL, $parameter->getName() ); foreach ($parameter-...
php
{ "resource": "" }
q253271
OperationGenerator.addFilteredParameterMethod
validation
function addFilteredParameterMethod() { $methodGenerator = new MethodGenerator('getFilteredParameter'); $body = 'if (array_key_exists($name, $this->parameters) == false) {'.PHP_EOL; //TODO - make this be the correct type $body .= ' throw new \Exception(\'Parameter \'.$name.\' does not...
php
{ "resource": "" }
q253272
OperationGenerator.addCreateAndExecuteMethod
validation
function addCreateAndExecuteMethod() { $methodGenerator = new MethodGenerator('createAndExecute'); $body = ''; $body .= $this->generateCreateFragment(); $body .= $this->generateExecuteFragment(); $body .= PHP_EOL; $body .= 'return $response;'.PHP_EOL;; $docBlock =...
php
{ "resource": "" }
q253273
OperationGenerator.addDispatchMethod
validation
function addDispatchMethod() { $methodGenerator = new MethodGenerator('dispatch'); $body = ''; $body .= $this->generateExecuteFragment(); $body .= $this->generateResponseFragment(); $docBlock = $this->generateExecuteDocBlock('Dispatch the request for this operation and process ...
php
{ "resource": "" }
q253274
OperationGenerator.addDispatchAsyncMethod
validation
function addDispatchAsyncMethod() { $methodGenerator = new MethodGenerator('dispatchAsync'); $body = 'return $this->api->executeAsync($request, $this, $callable);'; $docBlock = $this->generateExecuteDocBlock('Dispatch the request for this operation and process the response asynchronously. Allow...
php
{ "resource": "" }
q253275
OperationGenerator.addProcessResponseMethod
validation
function addProcessResponseMethod() { $methodGenerator = new MethodGenerator('processResponse'); $body = ''; $body .= $this->generateResponseFragment(); $docBlock = $this->generateExecuteDocBlock('Dispatch the request for this operation and process the response. Allows you to modify t...
php
{ "resource": "" }
q253276
OperationGenerator.createMethodGenerator
validation
private function createMethodGenerator($methodName, $body, DocBlockGenerator $docBlock, $parameterInfoArray, $returnType = null) { $parameters = []; foreach ($parameterInfoArray as $parameterInfo) { $parameters[] = new ParameterGenerator($parameterInfo[0], $parameterInfo[1]); } ...
php
{ "resource": "" }
q253277
OperationGenerator.addTranslateResponseToExceptionMethod
validation
public function addTranslateResponseToExceptionMethod() { $body = 'return $this->api->translateResponseToException($response);'; $docBlock = new DocBlockGenerator('Determine whether the response is an error. Override this method to have a per-operation decision, otherwise the function from the API clas...
php
{ "resource": "" }
q253278
OperationGenerator.generate
validation
function generate() { if ($this->namespace) { $fqcn = $this->namespace.'\\'.$this->className; } else { $fqcn = $this->className; } $this->addProperties(); $this->addConstructorMethod(); $this->addSetAPIMethod(); $this->addSetParam...
php
{ "resource": "" }
q253279
Native.drop
validation
public function drop($key) { if($this->has($key)) { unset($_SESSION[$this->root][$key]); return true; } return false; }
php
{ "resource": "" }
q253280
Benri_Controller_Response_Http.sendHeaders
validation
public function sendHeaders() { // Only check if we can send headers if we have headers to send if (count($this->_headersRaw) || count($this->_headers) || (200 !== $this->_httpResponseCode)) { $this->canSendHeaders(true); } elseif (200 === $this->_httpResponseCode) { ...
php
{ "resource": "" }
q253281
User.getCurrentUser
validation
public function getCurrentUser(){ // //@TODO Rework the userid, use case, if user id is not provided or is null //Get the authenticated user //Also load some user data from the user database table, some basic info $this->authenticated = false; //Authenticate $authenticate ...
php
{ "resource": "" }
q253282
User.getFullName
validation
public function getFullName($first = NULL, $middle = NULL, $last = NULL) { $user_first_name = $this->getPropertyValue("user_first_name"); $user_middle_name = $this->getPropertyValue("user_middle_name"); $user_last_name = $this->getPropertyValue("user_last_name"); $user_full_name = implo...
php
{ "resource": "" }
q253283
User.update
validation
public function update($usernameId, $data = array()) { if (empty($usernameId)) return false; $existing = (array) $this->getPropertyData(); $data = empty($data) ? $existing : array_merge($data, $existing); //Load the username; $profile = $this->loadObjectByURI($user...
php
{ "resource": "" }
q253284
User.search
validation
public function search($query, &$results = array()) { if (!empty($query)): $words = explode(' ', $query); foreach ($words as $word) { $_results = $this->setListLookUpConditions("user_first_name", $word, 'OR') ->setListLookUpCon...
php
{ "resource": "" }
q253285
QuestionPolicy.view
validation
public function view(UserPolicy $user, Question $question) { if ($user->canDo('forum.question.view') && $user->isAdmin()) { return true; } return $question->user_id == user_id() && $question->user_type == user_type(); }
php
{ "resource": "" }
q253286
QuestionPolicy.destroy
validation
public function destroy(UserPolicy $user, Question $question) { return $question->user_id == user_id() && $question->user_type == user_type(); }
php
{ "resource": "" }
q253287
YoutubeService.getThumbnails
validation
public function getThumbnails($videoId, $format = null) { $listResponse = $this->videos->listVideos('snippet', array('id' => $videoId)); if (empty($listResponse)) { throw new \RuntimeException(sprintf('Could not find video with id %s', $videoId)); } $video = $listResponse...
php
{ "resource": "" }
q253288
VerbalExpressions.range
validation
public function range() { $arg_num = func_num_args(); if ($arg_num % 2 != 0) { throw new \InvalidArgumentException("Number of args must be even", 1); } $value = "["; $arg_list = func_get_args(); for ($i = 0; $i < $arg_num;) { $value .= self::saniti...
php
{ "resource": "" }
q253289
FormElement.render
validation
public function render(ElementInterface $element) { $renderer = $this->getView(); if ($element instanceof CkEditor) { /** @noinspection PhpUndefinedMethodInspection */ $plugin = $renderer->plugin('form_ckeditor'); return $plugin($element); } ret...
php
{ "resource": "" }
q253290
Image.showImageInSize
validation
public static function showImageInSize(int $iImageUri, int $iWidth, int $iHeight, bool $bKeepDimension = false) { $aSize = getimagesize($iImageUri); $rActualImage = imagecreatefromjpeg($iImageUri); $ImageChoisie = imagecreatefromjpeg($_FILES['ImageNews']['tmp_name']); $TailleImageChoisie ...
php
{ "resource": "" }
q253291
GuzzleHttp.initClient
validation
public function initClient($headers) { try { $this->request = new Client($headers); } catch (Exception $e) { echo 'Unable to initialise http client because '.$e->getMessage()."\n"; } }
php
{ "resource": "" }
q253292
CreateRendererExceptionCapableTrait._createRendererException
validation
protected function _createRendererException( $message = null, $code = null, RootException $previous = null, RendererInterface $renderer = null ) { return new RendererException($message, $code, $previous, $renderer); }
php
{ "resource": "" }
q253293
Relation.getRelationModelField
validation
public function getRelationModelField() { $field = $this->model->tabularPrefix; if ($this->modelField->relationship->companionRole($this->modelField->modelRole) === 'child') { $field .= 'child_object_id'; } else { $field .= 'parent_object_id'; } retur...
php
{ "resource": "" }
q253294
Modules.set
validation
public function set($name, AbstractModule $module) { $this->container[(string) $name] = $module; return $this; }
php
{ "resource": "" }
q253295
Modules.remove
validation
public function remove($name) { if (isset($this->container[$name])) { unset($this->container[$name]); } return $this; }
php
{ "resource": "" }
q253296
Modules.get
validation
public function get($name) { if (! isset($this->container[$name])) { throw new RuntimeException( sprintf( 'Module "%s" is not found', $name ) ); } return $this->container[$name]; }
php
{ "resource": "" }
q253297
DeleteForm.getLabels
validation
public function getLabels() { $labels = []; $labels['delete_object'] = [ 'short' => 'Delete ' . $this->object->objectType->title->getSingular(true), 'long' => 'delete the ' . $this->object->objectType->title->getSingular(false) . ' <em>' . $this->object->descriptor . '</em>',...
php
{ "resource": "" }
q253298
DeleteForm.getTarget
validation
public function getTarget() { if (is_null($this->_target) && !empty($this->possibleTargets)) { $this->_target = $this->possibleTargets[0]; } return $this->_target; }
php
{ "resource": "" }
q253299
DeleteForm.getPossibleTargets
validation
public function getPossibleTargets() { if (is_null($this->_possibleTargets)) { $this->_possibleTargets = []; if ($this->canEndRelation()) { $this->_possibleTargets[] = 'end_relationship'; } if ($this->canDeleteRelation()) { $t...
php
{ "resource": "" }